Trying to make multipolygon from type=boundary #504
-
I'm trying to get Hungarian national parks to show correctly. This is the process.lua I was able to put together based on the docs and the OMT process.lua function relation_scan_function(relation)
if relation:Find("type")=="boundary" and relation:Find("boundary")=="national_park" then
relation:Accept()
end
end
function way_function(way)
local isBoundary = false
local name = ""
while true do
local rel = way:NextRelation()
if not rel then break end
isBoundary = true
if name == "" then
name = way:FindInRelation("name")
end
end
if isBoundary then
way:Layer("park", true)
way:Attribute("class", "national_park")
way:Attribute("name", name)
end
end |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I doubt that'll work like that. tilemaker has special handling for multipolygon relations (i.e. I imagine you could get some way towards this by patching read_pbf.cpp: (in PbfReader::ScanRelations) int typeKey = findStringPosition(pb, "type");
int mpKey = findStringPosition(pb, "multipolygon");
int boundaryKey = findStringPosition(pb, "boundary");
for (int j=0; j<pg.relations_size(); j++) {
Relation pbfRelation = pg.relations(j);
bool isMultiPolygon = (find(pbfRelation.keys().begin(), pbfRelation.keys().end(), typeKey) != pbfRelation.keys().end()) &&
((find(pbfRelation.vals().begin(), pbfRelation.vals().end(), mpKey ) != pbfRelation.vals().end()) ||
(find(pbfRelation.vals().begin(), pbfRelation.vals().end(), boundaryKey) != pbfRelation.vals().end())); (in PbfReader::ReadRelations) int typeKey = findStringPosition(pb, "type");
int mpKey = findStringPosition(pb, "multipolygon");
int boundaryKey = findStringPosition(pb, "boundary");
int innerKey= findStringPosition(pb, "inner");
//int outerKey= findStringPosition(pb, "outer");
if (typeKey >-1 && mpKey>-1) {
for (int j=0; j<pg.relations_size(); j++) {
Relation pbfRelation = pg.relations(j);
bool isMultiPolygon = (find(pbfRelation.keys().begin(), pbfRelation.keys().end(), typeKey) != pbfRelation.keys().end()) &&
((find(pbfRelation.vals().begin(), pbfRelation.vals().end(), mpKey ) != pbfRelation.vals().end()) ||
(find(pbfRelation.vals().begin(), pbfRelation.vals().end(), boundaryKey) != pbfRelation.vals().end())); (I haven't tried this!) |
Beta Was this translation helpful? Give feedback.
-
Hi, do you mind sharing your solution @sn4k3ch4rm3r ? If we should handle the "boundary" as multipolygon with the solution provided above, then how can I pick the ways to re-build this relation R3659121 and store them in a specific layer knowing those ways (in my example) have no tags? thanks in advance for your feedback |
Beta Was this translation helpful? Give feedback.
I doubt that'll work like that. tilemaker has special handling for multipolygon relations (i.e.
type=multipolygon
). It looks like boundary relations probably need to be processed that way, rather than withrelation_scan_function
.I imagine you could get some way towards this by patching read_pbf.cpp:
(in PbfReader::ScanRelations)