Skip to content

as_linestring() and likely other geometry transform functions can only be called from the process_way() function, not custom functions. #2171

@mboeringa

Description

@mboeringa

What version of osm2pgsql are you using?

osm2pgsql version 1.11.0 (1.8.1-397-gcf66989f)

What operating system and PostgreSQL/PostGIS version are you using?

Ubuntu 22.04
PostgreSQL 16.2 (Ubuntu 16.2-1.pgdg22.04+1), PostGIS 3.4

Tell us something about your system

What did you do exactly?

I have been trying to convert an existing style that still used the now deprecated 'add_row()' function to use the new 'insert()' function (the style is a derivative of Paul Norman's work for the flex style of OpenStreetMap carto: openstreetmap-carto/openstreetmap-carto#4431 and more specifically https://github.com/gravitystorm/openstreetmap-carto/blob/c7066c8a0b670fbd19532241f912c13f55eef215/openstreetmap-carto.lua).

Although I think I have the syntax right now, I run into an issue with a check that osm2pgsql seems to do, I get an error message:

ERROR: Failed to execute Lua function 'osm2pgsql.process_relation': osm2pgsql/flex-config/openstreetmap-carto.lua:1228: Error in 'as_linestring': The function as_linestring() can only be called from the process_way() function.

It is true that Paul's work for that style uses a couple of helper functions which implement the actual insertion 'add_row/insert', and that the 'as_linestring()' function call thus is not inside the 'process_way' function.

While I could theoretically rewrite everything to be inside the 'process_way' function, this not only would bloat the function, but this limitation also hampers general Lua development.

It also kind of breaks "backward compatibility" with the deprecated 'add_row' function, as using that function in a helper function outside 'process_way' was never a problem and simply worked.

Could this limitation with 'insert' and required 'as_linestring/multipolygon' etc. be lifted and allow more flexible function and code design?

What did you expect to happen?

Geometry transforms for the new 'insert' work outside the 'process_way' function.

What did happen instead?

What did you do to try analyzing the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions