zdila left a comment (osm2pgsql-dev/osm2pgsql#2442)

To public lua API.

My quick draft which works good in vscode with Lua language server:

<details>
<summary>osm2pgsql.lua</summary>

```lua
---@meta

---@class Osm2pgsqlTable
---@field insert fun(self: Osm2pgsqlTable, row: table<string, unknown>)

---@class OsmGeometry
---@field area fun(self: OsmGeometry): number
---@field centroid fun(self: OsmGeometry): OsmGeometry
---@field get_bbox fun(self: OsmGeometry): number, number, number, number
---@field geometries fun(self: OsmGeometry): fun(): OsmGeometry
---@field geometry_n fun(self: OsmGeometry, index: integer): OsmGeometry
---@field geometry_type fun(self: OsmGeometry): string
---@field is_null fun(self: OsmGeometry): boolean
---@field length fun(self: OsmGeometry): number
---@field line_merge fun(self: OsmGeometry): OsmGeometry
---@field num_geometries fun(self: OsmGeometry): integer
---@field pole_of_inaccessibility fun(self: OsmGeometry, opts?: 
OsmPoleOptions): OsmGeometry
---@field segmentize fun(self: OsmGeometry, max_segment_length: number): 
OsmGeometry
---@field simplify fun(self: OsmGeometry, tolerance: number): OsmGeometry
---@field spherical_area fun(self: OsmGeometry): number
---@field srid fun(self: OsmGeometry): integer
---@field transform fun(self: OsmGeometry, target_srid: integer): OsmGeometry

---@class OsmIdSpec
---@field type string
---@field id_column string

---@class OsmColumnDef
---@field column string
---@field type? string
---@field sql_type? string
---@field projection? number|string
---@field not_null? boolean
---@field create_only? boolean
---@field expire? Expire

---@class Expire
---@field maxzoom? number
---@field minzoom? number
---@field filename? string
---@field schema? string
---@field table? string

---@class ExpireConfig
---@field maxzoom? number
---@field minzoom? number
---@field filename? string
---@field schema? string
---@field table? string

---@class OsmDefineTableOpts
---@field name string                       @ The name of the table (without 
schema).
---@field ids? OsmIdSpec                    @ Id handling; tables without ids 
cannot be updated.
---@field columns OsmColumnDef[]            @ Column definitions.
---@field schema? string                    @ Target PostgreSQL schema.
---@field data_tablespace? string           @ Tablespace for table data.
---@field index_tablespace? string          @ Tablespace for table indexes.
---@field cluster? "auto"|"no"              @ Clustering strategy; defaults to 
"auto".
---@field indexes? table[]                  @ Index definitions; defaults to a 
GIST on first geometry column.

---@class OsmPoleOptions
---@field stretch? number

---@class OsmMember
---@field ref string
---@field type string
---@field role string

---@class OsmObject
---@field id integer
---@field tags table<string, string>
---@field is_closed boolean
---@field members (OsmMember[]|nil)
---@field as_point fun(self: OsmObject): OsmGeometry
---@field as_linestring fun(self: OsmObject): OsmGeometry
---@field as_multilinestring fun(self: OsmObject): OsmGeometry
---@field as_polygon fun(self: OsmObject): OsmGeometry
---@field as_multipolygon fun(self: OsmObject): OsmGeometry
---@field as_geometrycollection fun(self: OsmObject): OsmGeometry

---@class Osm2pgsql
---@field define_table fun(opts: OsmDefineTableOpts): Osm2pgsqlTable
---@field define_node_table fun(name: string, columns: OsmColumnDef[]): 
Osm2pgsqlTable
---@field define_way_table fun(name: string, columns: OsmColumnDef[]): 
Osm2pgsqlTable
---@field define_area_table fun(name: string, columns: OsmColumnDef[]): 
Osm2pgsqlTable
---@field define_relation_table fun(name: string, columns: OsmColumnDef[]): 
Osm2pgsqlTable
---@field process_node fun(object: OsmObject)
---@field process_way fun(object: OsmObject)
---@field process_relation fun(object: OsmObject)
---@field process_untagged_node fun(object: OsmObject)
---@field process_untagged_way fun(object: OsmObject)
---@field process_untagged_relation fun(object: OsmObject)
---@field process_deleted_node fun(object: OsmObject)
---@field process_deleted_way fun(object: OsmObject)
---@field process_deleted_relation fun(object: OsmObject)
---@field define_expire_output fun(object: ExpireConfig): Expire

---@type Osm2pgsql
osm2pgsql = osm2pgsql
```
</details>

This is a standalone definition (something like *.d.ts of Definitely Typed 
module in TypeScript world) byt maybe inlining it into your source lua files 
would be more appropriate. I am just scratching the surface with lua so I can't 
tell the best way to integrate it.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/issues/2442#issuecomment-3705355811
You are receiving this because you are subscribed to this thread.

Message ID: <osm2pgsql-dev/osm2pgsql/issues/2442/[email protected]>
_______________________________________________
Tile-serving mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/tile-serving

Reply via email to