IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java b/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java
|
a
|
b
|
|
| 47 | 47 | /** Bag of all way segments */ |
| 48 | 48 | private MultiMap<Pair<Node, Node>, WaySegment> nodePairs; |
| 49 | 49 | |
| 50 | | private boolean onlyKnwonLinear; |
| | 50 | private boolean onlyKnownLinear; |
| 51 | 51 | private boolean includeOther; |
| 52 | 52 | private boolean ignoreLayer; |
| 53 | 53 | |
| … |
… |
|
| 83 | 83 | super.startTest(monitor); |
| 84 | 84 | nodePairs = new MultiMap<>(1000); |
| 85 | 85 | includeOther = isBeforeUpload ? ValidatorPrefHelper.PREF_OTHER_UPLOAD.get() : ValidatorPrefHelper.PREF_OTHER.get(); |
| 86 | | onlyKnwonLinear = Config.getPref().getBoolean("overlapping-ways.only-known-linear", true); |
| | 86 | onlyKnownLinear = Config.getPref().getBoolean("overlapping-ways.only-known-linear", true); |
| 87 | 87 | ignoreLayer = Config.getPref().getBoolean("overlapping-ways.ignore-layer", false); |
| 88 | 88 | } |
| 89 | 89 | |
| … |
… |
|
| 192 | 192 | errortype = tr("Waterway shares segment with linear way"); |
| 193 | 193 | type = OVERLAPPING_WATERWAY_LINEAR_WAY; |
| 194 | 194 | severity = Severity.WARNING; |
| 195 | | } else if (!includeOther || onlyKnwonLinear) { |
| | 195 | } else if (!includeOther || onlyKnownLinear) { |
| 196 | 196 | return; |
| 197 | 197 | } else if (countHighway > 0) { |
| 198 | 198 | errortype = tr("Highway shares segment with other way"); |
| … |
… |
|
| 269 | 269 | if (IGNORED.test(w)) |
| 270 | 270 | return; |
| 271 | 271 | |
| 272 | | if (onlyKnwonLinear && (w.concernsArea() || w.getInterestingTags().isEmpty())) |
| | 272 | if (onlyKnownLinear && (w.concernsArea() || w.getInterestingTags().isEmpty())) |
| 273 | 273 | return; |
| 274 | 274 | |
| 275 | 275 | Node lastN = null; |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java b/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java
|
a
|
b
|
|
| 11 | 11 | import java.util.Set; |
| 12 | 12 | |
| 13 | 13 | import org.openstreetmap.josm.data.osm.Node; |
| | 14 | import org.openstreetmap.josm.data.osm.NodePair; |
| 14 | 15 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
| 15 | 16 | import org.openstreetmap.josm.data.osm.Relation; |
| 16 | 17 | import org.openstreetmap.josm.data.osm.RelationMember; |
| … |
… |
|
| 25 | 26 | import org.openstreetmap.josm.tools.Geometry; |
| 26 | 27 | |
| 27 | 28 | /** |
| 28 | | * Checks for nodes in power lines/minor_lines that do not have a power=tower/pole tag.<br> |
| 29 | | * See #7812 for discussions about this test. |
| | 29 | * Checks for nodes in power lines/minor_lines that do not have a power=tower/pole/portal tag and also for ways where |
| | 30 | * are unusually long segments without line support feature.<br> |
| | 31 | * See #7812 and #{FIXME number} for discussions about this test. |
| 30 | 32 | */ |
| 31 | 33 | public class PowerLines extends Test { |
| 32 | 34 | |
| 33 | 35 | /** Test identifier */ |
| 34 | 36 | protected static final int POWER_LINES = 2501; |
| 35 | 37 | protected static final int POWER_CONNECTION = 2502; |
| | 38 | protected static final int POWER_SEGMENT_LENGTH = 2503; |
| 36 | 39 | |
| 37 | 40 | /** Values for {@code power} key interpreted as power lines */ |
| 38 | 41 | static final Collection<String> POWER_LINE_TAGS = Arrays.asList("line", "minor_line"); |
| 39 | 42 | /** Values for {@code power} key interpreted as power towers */ |
| 40 | | static final Collection<String> POWER_TOWER_TAGS = Arrays.asList("tower", "pole"); |
| | 43 | static final Collection<String> POWER_TOWER_TAGS = Arrays.asList("tower", "pole", "portal"); |
| 41 | 44 | /** Values for {@code power} key interpreted as power stations */ |
| 42 | 45 | static final Collection<String> POWER_STATION_TAGS = Arrays.asList("station", "sub_station", "substation", "plant", "generator"); |
| 43 | 46 | /** Values for {@code building} key interpreted as power stations */ |
| … |
… |
|
| 47 | 50 | "portal", "terminal", "insulator"); |
| 48 | 51 | |
| 49 | 52 | private final Set<Node> badConnections = new LinkedHashSet<>(); |
| 50 | | private final Set<Node> missingTowerOrPole = new LinkedHashSet<>(); |
| | 53 | private final Set<Node> missingTag = new LinkedHashSet<>(); |
| | 54 | private final Set<NodePair> missingNode = new LinkedHashSet<>(); |
| 51 | 55 | |
| 52 | 56 | private final List<OsmPrimitive> powerStations = new ArrayList<>(); |
| 53 | 57 | |
| … |
… |
|
| 58 | 62 | super(tr("Power lines"), tr("Checks for nodes in power lines that do not have a power=tower/pole tag.")); |
| 59 | 63 | } |
| 60 | 64 | |
| 61 | | @Override |
| 62 | | public void visit(Way w) { |
| 63 | | if (w.isUsable()) { |
| 64 | | if (isPowerLine(w) && !w.hasTag("location", "underground")) { |
| 65 | | for (Node n : w.getNodes()) { |
| 66 | | if (!isPowerTower(n) && !isPowerAllowed(n) && IN_DOWNLOADED_AREA.test(n) |
| 67 | | && (!w.isFirstLastNode(n) || !isPowerStation(n))) { |
| 68 | | missingTowerOrPole.add(n); |
| 69 | | } |
| 70 | | } |
| 71 | | } else if (w.isClosed() && isPowerStation(w)) { |
| 72 | | powerStations.add(w); |
| 73 | | } |
| 74 | | } |
| 75 | | } |
| 76 | | |
| 77 | 65 | @Override |
| 78 | 66 | public void visit(Node n) { |
| 79 | 67 | boolean nodeInLineOrCable = false; |
| … |
… |
|
| 89 | 77 | badConnections.add(n); |
| 90 | 78 | } |
| 91 | 79 | |
| 92 | | private static boolean isRelatedToPower(Way way) { |
| 93 | | if (way.hasTag("power") || way.hasTag("building")) |
| 94 | | return true; |
| 95 | | for (OsmPrimitive ref : way.getReferrers()) { |
| 96 | | if (ref instanceof Relation && ref.isMultipolygon() && (ref.hasTag("power") || ref.hasTag("building"))) { |
| 97 | | for (RelationMember rm : ((Relation) ref).getMembers()) { |
| 98 | | if (way == rm.getMember()) |
| 99 | | return true; |
| | 80 | @Override |
| | 81 | public void visit(Way w) { |
| | 82 | if (w.isUsable()) { |
| | 83 | if (isPowerLine(w) && !w.hasTag("location", "underground")) { |
| | 84 | float avgWayLength = (float) (w.getLength() / w.getRealNodesCount()); |
| | 85 | Node prevNode = w.firstNode(); |
| | 86 | |
| | 87 | for (Node n : w.getNodes()) { |
| | 88 | if (!isPowerTower(n) && !isPowerAllowed(n) && IN_DOWNLOADED_AREA.test(n) |
| | 89 | && (!w.isFirstLastNode(n) || !isPowerStation(n))) { |
| | 90 | missingTag.add(n); |
| | 91 | } |
| | 92 | |
| | 93 | double distance = n.getCoor().greatCircleDistance(prevNode.getCoor()); |
| | 94 | if (w.getRealNodesCount() > 4 && distance > avgWayLength * 2.0f && !isPowerAllowed(n)) { |
| | 95 | missingNode.add(new NodePair(prevNode, n)); |
| | 96 | } |
| | 97 | prevNode = n; |
| 100 | 98 | } |
| | 99 | } else if (w.isClosed() && isPowerStation(w)) { |
| | 100 | powerStations.add(w); |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | | return false; |
| 104 | 103 | } |
| 105 | 104 | |
| 106 | 105 | @Override |
| … |
… |
|
| 118 | 117 | |
| 119 | 118 | @Override |
| 120 | 119 | public void endTest() { |
| 121 | | for (Node n : missingTowerOrPole) { |
| | 120 | for (Node n : missingTag) { |
| 122 | 121 | if (!isInPowerStation(n)) { |
| 123 | 122 | errors.add(TestError.builder(this, Severity.WARNING, POWER_LINES) |
| 124 | | .message(tr("Missing power tower/pole within power line")) |
| | 123 | .message(tr("Missing power line support tag from node")) |
| 125 | 124 | .primitives(n) |
| 126 | 125 | .build()); |
| 127 | 126 | } |
| … |
… |
|
| 130 | 129 | for (Node n : badConnections) { |
| 131 | 130 | errors.add(TestError.builder(this, Severity.WARNING, POWER_CONNECTION) |
| 132 | 131 | .message(tr("Node connects a power line or cable with an object " |
| 133 | | + "which is not related to the power infrastructure.")) |
| 134 | | .primitives(n).build()); |
| | 132 | + "which is not related to the power infrastructure")) |
| | 133 | .primitives(n) |
| | 134 | .build()); |
| 135 | 135 | } |
| | 136 | |
| | 137 | for (NodePair pair : missingNode) { |
| | 138 | errors.add(TestError.builder(this, Severity.WARNING, POWER_SEGMENT_LENGTH) |
| | 139 | .message(tr("Missing line support node within power line")) |
| | 140 | .primitives(pair.getA(), pair.getB()) |
| | 141 | .build()); |
| | 142 | } |
| | 143 | |
| 136 | 144 | clearCollections(); |
| 137 | 145 | super.endTest(); |
| 138 | 146 | } |
| 139 | 147 | |
| | 148 | private static boolean isRelatedToPower(Way way) { |
| | 149 | if (way.hasTag("power") || way.hasTag("building")) |
| | 150 | return true; |
| | 151 | for (OsmPrimitive ref : way.getReferrers()) { |
| | 152 | if (ref instanceof Relation && ref.isMultipolygon() && (ref.hasTag("power") || ref.hasTag("building"))) { |
| | 153 | for (RelationMember rm : ((Relation) ref).getMembers()) { |
| | 154 | if (way == rm.getMember()) |
| | 155 | return true; |
| | 156 | } |
| | 157 | } |
| | 158 | } |
| | 159 | return false; |
| | 160 | } |
| | 161 | |
| 140 | 162 | protected final boolean isInPowerStation(Node n) { |
| 141 | 163 | for (OsmPrimitive station : powerStations) { |
| 142 | 164 | List<List<Node>> nodesLists = new ArrayList<>(); |
| … |
… |
|
| 189 | 211 | /** |
| 190 | 212 | * Determines if the specified node denotes a power infrastructure allowed on a power line. |
| 191 | 213 | * @param n The node to be tested |
| 192 | | * @return True if power key is set and equal to switch/tranformer/busbar/generator |
| | 214 | * @return True if power key is set and equal to switch/transformer/busbar/generator |
| 193 | 215 | */ |
| 194 | 216 | protected static final boolean isPowerAllowed(Node n) { |
| 195 | 217 | return isPowerIn(n, POWER_ALLOWED_TAGS); |
| … |
… |
|
| 218 | 240 | private void clearCollections() { |
| 219 | 241 | powerStations.clear(); |
| 220 | 242 | badConnections.clear(); |
| 221 | | missingTowerOrPole.clear(); |
| | 243 | missingTag.clear(); |
| | 244 | missingNode.clear(); |
| 222 | 245 | } |
| 223 | 246 | } |