Changeset 19658 in josm
- Timestamp:
- 2026-10-23T16:06:36+02:00 (15 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java
r19629 r19658 6 6 import java.awt.geom.Point2D; 7 7 import java.util.ArrayList; 8 import java.util.Arrays;9 8 import java.util.Collection; 10 import java.util.Collections;11 9 import java.util.EnumSet; 12 10 import java.util.HashMap; … … 66 64 67 65 /** Values for {@code power} key interpreted as power lines */ 68 static final Collection<String> POWER_LINE_TAGS =Arrays.asList("line", MINOR_LINE);66 static final Set<String> POWER_LINE_TAGS = Set.of("line", MINOR_LINE); 69 67 /** Values for {@code power} key interpreted as power towers */ 70 static final Collection<String> POWER_TOWER_TAGS =Arrays.asList("catenary_mast", "pole", "portal", "tower");68 static final Set<String> POWER_TOWER_TAGS = Set.of("catenary_mast", "pole", "portal", "tower"); 71 69 /** Values for {@code power} key interpreted as power stations */ 72 static final Collection<String> POWER_STATION_TAGS =Arrays.asList("generator", "plant", "substation");70 static final Set<String> POWER_STATION_TAGS = Set.of("generator", "plant", "substation"); 73 71 /** Values for {@code building} key interpreted as power stations */ 74 static final Collection<String> BUILDING_STATION_TAGS =Collections.singletonList("transformer_tower");72 static final Set<String> BUILDING_STATION_TAGS = Set.of("transformer_tower"); 75 73 /** Values for {@code power} key interpreted as allowed power items */ 76 static final Collection<String> POWER_INFRASTRUCTURE_TAGS =Arrays.asList("compensator", "connection", "converter",74 static final Set<String> POWER_INFRASTRUCTURE_TAGS = Set.of("compensator", "connection", "converter", 77 75 "generator", "insulator", "switch", "switchgear", "terminal", "transformer"); 76 77 /** Values for {@code power} key interpreted as power lines or cables */ 78 private static final Set<String> POWER_LINE_OR_CABLE_TAGS = Set.of("line", MINOR_LINE, "cable"); 78 79 79 80 private double hillyCompensation; … … 190 191 .message(tr("Possibly missing line support node within power line")) 191 192 .primitives(s.getFirstNode(), s.getSecondNode()) 192 .highlightWaySegments( new HashSet<>(Collections.singleton(s)))193 .highlightWaySegments(Set.of(s)) 193 194 .build()); 194 195 } … … 250 251 final double stdDev = Utils.getStandardDeviation(w.getSegmentLengths(), mean); 251 252 final boolean isContinuesAsMinorLine = isContinuesAsMinorLine(w); 252 boolean isCrossingWater = false; 253 // the crossings only depend on the way, so look them up once instead of for every node 254 final Set<Way> crossingWaterWays = new HashSet<>(8); 255 final Set<ILatLon> crossingPositions = new HashSet<>(8); 256 findCrossings(this.cellSegmentsWater, w, crossingWaterWays, crossingPositions); 257 final boolean isCrossingWater = !crossingWaterWays.isEmpty(); 253 258 int poleCount = 0; 254 259 int towerCount = 0; … … 278 283 /// handle missing nodes 279 284 double segmentLen = n.greatCircleDistance(prevNode); 280 final Set<Way> crossingWaterWays = new HashSet<>(8); 281 final Set<ILatLon> crossingPositions = new HashSet<>(8); 282 findCrossings(this.cellSegmentsWater, w, crossingWaterWays, crossingPositions); 283 284 if (!crossingWaterWays.isEmpty()) { 285 if (isCrossingWater) { 285 286 double compensation = calculateIntersectingLen(prevNode, crossingPositions); 286 287 segmentLen -= compensation; … … 294 295 295 296 /// handle wrong line types 296 if (!crossingWaterWays.isEmpty())297 isCrossingWater = true;298 299 297 if (n.hasTag(POWER, "pole")) 300 298 poleCount++; … … 600 598 return true; 601 599 for (OsmPrimitive ref : way.getReferrers()) { 602 if (ref instanceof Relation && ref.isMultipolygon() && (ref.hasTag(POWER) || ref.hasTag(BUILDING))) { 603 for (RelationMember rm : ((Relation) ref).getMembers()) { 604 if (way == rm.getMember()) 605 return true; 600 if (ref instanceof Relation) { 601 Relation r = (Relation) ref; 602 if (r.isMultipolygon() && (r.hasTag(POWER) || r.hasTag(BUILDING))) { 603 for (RelationMember rm : r.getMembers()) { 604 if (rm.getMember() == way) 605 return true; 606 } 606 607 } 607 608 } … … 659 660 protected final boolean isInPowerStation(Node n) { 660 661 for (OsmPrimitive station : powerStations) { 661 List<List<Node>> nodesLists = new ArrayList<>();662 662 if (station instanceof Way) { 663 nodesLists.add(((Way) station).getNodes()); 663 if (Geometry.nodeInsidePolygon(n, ((Way) station).getNodes())) { 664 return true; 665 } 664 666 } else if (station instanceof Relation) { 665 667 Multipolygon polygon = MultipolygonCache.getInstance().get((Relation) station); 666 668 if (polygon != null) { 667 669 for (JoinedWay outer : Multipolygon.joinWays(polygon.getOuterWays())) { 668 nodesLists.add(outer.getNodes()); 670 if (Geometry.nodeInsidePolygon(n, outer.getNodes())) { 671 return true; 672 } 669 673 } 670 }671 }672 for (List<Node> nodes : nodesLists) {673 if (Geometry.nodeInsidePolygon(n, nodes)) {674 return true;675 674 } 676 675 } … … 694 693 */ 695 694 protected static boolean isPowerLineOrCable(Way w) { 696 return isPowerIn(w, Arrays.asList("line", MINOR_LINE, "cable"));695 return isPowerIn(w, POWER_LINE_OR_CABLE_TAGS); 697 696 } 698 697
Note:
See TracChangeset
for help on using the changeset viewer.
