Skip to content

Commit

Permalink
Revert "Break multipolygons into multiple areas"
Browse files Browse the repository at this point in the history
  • Loading branch information
siren authored Mar 13, 2017
1 parent 8ab0c7d commit da60a41
Showing 1 changed file with 4 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ the License, or (at your option) any later version.
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.stream.Collectors;

public class OSMDatabase implements OpenStreetMapContentHandler {

Expand Down Expand Up @@ -662,29 +661,10 @@ private void processMultipolygonRelations() {
}
}
processedAreas.add(relation);

Map<Ring, OSMWay> wayForRing = new HashMap<>();
List<List<Ring>> groups = new ArrayList<>();;
for (OSMWay way : outerWays) {
Ring ring = new Ring(way.getNodeRefs(), nodesById);
wayForRing.put(ring, way);
for (List<Ring> group : groups) {
if (ring.toJtsPolygon().intersects(group.get(0).toJtsPolygon())) {
group.add(ring);
break;
}
}
groups.add(new ArrayList<>(Collections.singletonList(ring)));
}

for (List<Ring> group : groups) {
try {
List<OSMWay> outerRingWays = group.stream().map(wayForRing::get)
.collect(Collectors.toList());
newArea(new Area(relation, outerRingWays, innerWays, nodesById));
} catch (Area.AreaConstructionException|Ring.RingConstructionException e) {
continue;
}
try {
newArea(new Area(relation, outerWays, innerWays, nodesById));
} catch (Area.AreaConstructionException|Ring.RingConstructionException e) {
continue;
}

for (OSMRelationMember member : relation.getMembers()) {
Expand Down

0 comments on commit da60a41

Please sign in to comment.