[Tile-serving] [osm2pgsql-dev/osm2pgsql] Add method signature annotations (Issue #2442)

Martin Ždila notifications at github.com
Fri Jan 2 13:46:40 UTC 2026


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
--- at meta

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

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

--- at class OsmIdSpec
--- at field type string
--- at field id_column string

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

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

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

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

--- at class OsmPoleOptions
--- at field stretch? number

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

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

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

--- at 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/3705355811 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20260102/ca0c0a57/attachment-0001.htm>


More information about the Tile-serving mailing list