osm2pgsql icon indicating copy to clipboard operation
osm2pgsql copied to clipboard

`object:as_multipolygon()` does not take `object.members` into account.

Open docentYT opened this issue 2 years ago • 2 comments

The following code removes members from object.members that have a role other than 'inner' or 'outer'.

function osm2pgsql.process_relation(object)
    if object.tags.type == 'boundary' and object.tags.boundary == 'religious_administration' and object.tags.admin_level == '10' then
        for i = #object.members, 1, -1 do
            if object.members[i].role ~= "inner" and object.members[i].role ~= "outer" then
              table.remove(object.members, i)
            end
        end

        local mp = object:as_multipolygon()
        
        parishes:insert{
            name = object.tags.name,
            geom = mp
        }
    end
end

However, although object.members only contains objects from which a boundary should be created object:as_multipolygon() takes into account all members, even removed ones.

docentYT avatar Oct 19 '23 12:10 docentYT

Yes. Changing anything in the object doesn't affect the geometry generation. In this case the behaviour is generally the "right thing", because the roles inner and outer are not always tagged correctly. And the boundary relations shouldn't have any way member objects that are not part of the boundary, if they do, that tagging is wrong in my opinion. If you want to do more specialized processing, you have to do that in the database.

joto avatar Oct 19 '23 13:10 joto

As a data consumer, I want to be sure that even if the tagging is not 100% correct, I will get the data I need, so I think that the option of doing my own data filtering could be helpful.

docentYT avatar Oct 19 '23 13:10 docentYT