Skip to content

Centroid of linestrings #1771

@FaFre

Description

@FaFre

In some scenarios it is not possible to create a polygon (when e.g. the way has less than 4 points). But I still want to obtain the centroid.

In the documentation it is stated, that this only works with polygons/multipolygons. I gave it a shot and anyways, it is possible to obtain a centroid from linestrings like object:as_linestring():centroid(). This works in all cases, when it is not possible to create a polygon (when polygon:is_null()), with the single exception when a line(multiline has only one node (like https://www.openstreetmap.org/relation/7360610). PostGis is working in this scenario select ST_Centroid(ST_MakePoint(1, 1)).

I tried to convert the geometry into a single point via object:as_point() but the call is not possible outside node processing.

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