kopia lustrzana https://github.com/JOSM/MapWithAI
Use new Geometry.filterInsideAnyPolygon (JOSM r15730)
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
9d4e7bdbf1
commit
b798cef706
|
@ -72,15 +72,7 @@ public class MergeAddressBuildings extends AbstractConflationCommand {
|
|||
private static Collection<? extends Command> mergeAddressBuilding(DataSet affectedDataSet, OsmPrimitive object) {
|
||||
final List<IPrimitive> toCheck = new ArrayList<>();
|
||||
toCheck.addAll(affectedDataSet.searchNodes(object.getBBox()));
|
||||
final Collection<IPrimitive> nodesInside;
|
||||
|
||||
if (object instanceof Way) {
|
||||
nodesInside = Geometry.filterInsidePolygon(toCheck, (Way) object);
|
||||
} else if (object instanceof Relation) {
|
||||
nodesInside = Geometry.filterInsideMultipolygon(toCheck, (Relation) object);
|
||||
} else {
|
||||
throw new IllegalArgumentException("The method needs a way or a relation");
|
||||
}
|
||||
final Collection<IPrimitive> nodesInside = Geometry.filterInsideAnyPolygon(toCheck, object);
|
||||
|
||||
final List<Node> nodesWithAddresses = nodesInside.stream().filter(Node.class::isInstance).map(Node.class::cast)
|
||||
.filter(node -> node.hasKey("addr:housenumber", "addr:housename")).collect(Collectors.toList());
|
||||
|
|
|
@ -95,19 +95,9 @@ public class MergeBuildingAddress extends AbstractConflationCommand {
|
|||
}
|
||||
|
||||
private static Collection<Node> getAddressPoints(OsmPrimitive prim) {
|
||||
if (prim instanceof Way && ((Way) prim).isClosed()) {
|
||||
return Geometry
|
||||
.filterInsidePolygon(new ArrayList<>(prim.getDataSet().allNonDeletedPrimitives()), (Way) prim)
|
||||
.parallelStream().filter(Node.class::isInstance).map(Node.class::cast).filter(n -> n.hasTag(KEY))
|
||||
.collect(Collectors.toList());
|
||||
} else if (prim instanceof Relation) {
|
||||
return Geometry
|
||||
.filterInsideMultipolygon(new ArrayList<>(prim.getDataSet().allNonDeletedPrimitives()),
|
||||
(Relation) prim)
|
||||
.parallelStream().filter(Node.class::isInstance).map(Node.class::cast).filter(n -> n.hasKey(KEY))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return Geometry.filterInsideAnyPolygon(new ArrayList<>(prim.getDataSet().allNonDeletedPrimitives()), prim)
|
||||
.parallelStream().filter(Node.class::isInstance).map(Node.class::cast).filter(n -> n.hasTag(KEY))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Ładowanie…
Reference in New Issue