for (MapOverlap<?,?> overlap : area.getOverlaps()) {
if (overlap instanceof MapOverlapWA) {
MapWaySegment waySegment = ((MapOverlapWA)overlap).e1;
boolean isRidge = waySegment.getTags().contains("roof:ridge", "yes");
boolean isEdge = waySegment.getTags().contains("roof:edge", "yes");
if (!(isRidge || isEdge))
continue;
boolean inside = polygon.contains(waySegment.getCenter());
// check also endpoints as pnpoly algo is not reliable when
// segment lies on the polygon edge
boolean containsStart = nodes.contains(waySegment.getStartNode());
boolean containsEnd = nodes.contains(waySegment.getEndNode());
if (!inside && !(containsStart && containsEnd))
continue;
if (isEdge)
edges.add(waySegment);
else
ridges.add(waySegment);
ridgeAndEdgeSegments.add(waySegment.getLineSegment());
}
}
for (MapWaySegment waySegment : edges){
for (MapNode node : waySegment.getStartEndNodes()) {
// height of node (above roof base)
Float nodeHeight = null;
if (node.getTags().containsKey("roof:height")) {
nodeHeight = parseMeasure(node.getTags()
.getValue("roof:height"));
// hmm, shouldnt edges be interpolated? some seem to think they dont
} else if (waySegment.getTags().containsKey("roof:height")) {
nodeHeight = parseMeasure(waySegment.getTags()
.getValue("roof:height"));
} else if (node.getTags().contains("roof:apex", "yes")) {
nodeHeight = (float)roofHeight;
}
if (nodeHeight == null) {
nodeSet.add(node.getPos());
continue;
}
roofHeightMap.put(node.getPos(), (double) nodeHeight);
if (usePartRoofHeight)
roofHeight = max(roofHeight, nodeHeight);
}
}
for (MapWaySegment waySegment : ridges){
// height of node (above roof base)
Float nodeHeight = null;
if (waySegment.getTags().containsKey("roof:height")) {
nodeHeight = parseMeasure(waySegment.getTags()
.getValue("roof:height"));
} else {
nodeHeight = (float) roofHeight;
}
if (usePartRoofHeight)
roofHeight = max(roofHeight, nodeHeight);
for (MapNode node : waySegment.getStartEndNodes())
roofHeightMap.put(node.getPos(), (double) nodeHeight);
}
/* join colinear segments, but not the nodes that are connected to ridge/edges
* often there are nodes that are only added to join one building to another