[Tile-serving] [openstreetmap/osm2pgsql] How to select specific role members of relations and combine to create geometry (Discussion #1752)

mboeringa notifications at github.com
Tue Sep 6 19:56:30 UTC 2022


@joto,

I am afraid I still need a bit more help. I have gotten this far with the specific piece of code that should handle the selection of specific role members, or exclusion of any others. 

My problem is that I do not understand if, and how, it is possible to manipulate the 'geom' variable, the 'geometrycollection', to exclude certain members, and then be able insert the entire collection (or even preferably a multilinestring') of the correct ways of role 'main_stream', into a _**single**_ record.

Yes, it is possible and I do understand how to insert individual geometry records / selected ways each in their own record, but since I seem to be unable to remove objects from the 'geometrycollection', or create e.g. a new empty 'multilinestring' Lua geometry object and add each 'way' object I want to keep to it one-by-one, I do not see how to create and fill a single record with the entire "cleaned up" waterway relation only consisting of members of role 'main_stream'.

```
function osm2pgsql.process_relation(object)

    local type = object.tags.type
    
    if type == "waterway" and add_waterway_table then
        
        local geom = object:as_geometrycollection()
        local object_members = object.members

        for i in 1,object.num_geometries(),1 do

            n_geom = object.geometry_n(i)
            n_member_table = object_members[i]
            n_member_type = n_member_table.type
            n_member_ref = n_member_table.ref
            n_member_role = n_member_table.role

            if n_member_type == 'w' then
                if n_member_role ~= 'main_stream' then
                <NOW WHAT DO I NEED TO DO HERE?>
                end
            end

        end
        
    end

end
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/discussions/1752#discussioncomment-3579004
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/osm2pgsql/repo-discussions/1752/comments/3579004 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20220906/37e9fb7b/attachment.htm>


More information about the Tile-serving mailing list