Changeset 13671 in josm for trunk/src/org
- Timestamp:
- 2018-04-23T23:46:31+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/Test.java
r12864 r13671 347 347 } 348 348 349 /** 350 * Determines if the specified primitive denotes a residential area. 351 * @param p The primitive to be tested 352 * @return True if landuse key is equal to residential 353 */ 354 protected static final boolean isResidentialArea(OsmPrimitive p) { 355 return p.hasTag("landuse", "residential"); 356 } 357 349 358 @Override 350 359 public int hashCode() { -
trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
r12986 r13671 6 6 import java.awt.geom.Point2D; 7 7 import java.util.ArrayList; 8 import java.util.Arrays; 8 9 import java.util.HashMap; 9 10 import java.util.List; … … 35 36 static final String RAILWAY = "railway"; 36 37 static final String WATERWAY = "waterway"; 38 static final String LANDUSE = "landuse"; 39 40 /** 41 * Type of way. Entries have to be declared in alphabetical order, see sort below. 42 */ 43 private enum WayType { 44 BUILDING, HIGHWAY, RESIDENTIAL_AREA, WATERWAY, WAY 45 } 37 46 38 47 /** All way segments, grouped by cells */ … … 65 74 || isRailway(w) 66 75 || isCoastline(w) 67 || isBuilding(w)); 76 || isBuilding(w) 77 || isResidentialArea(w)); 68 78 } 69 79 … … 78 88 return true; 79 89 } 90 if ((w1.hasKey(HIGHWAY) && isResidentialArea(w2)) 91 || (w2.hasKey(HIGHWAY) && isResidentialArea(w1))) 92 return true; 80 93 if (isSubwayOrTramOrRazed(w2)) { 81 94 return true; … … 91 104 } 92 105 106 private static WayType getWayType(Way w) { 107 if (isBuilding(w)) 108 return WayType.BUILDING; 109 else if (w.hasKey(HIGHWAY)) 110 return WayType.HIGHWAY; 111 else if (isResidentialArea(w)) 112 return WayType.RESIDENTIAL_AREA; 113 else if (w.hasKey(WATERWAY)) 114 return WayType.WATERWAY; 115 else 116 return WayType.WAY; 117 } 118 93 119 @Override 94 120 String createMessage(Way w1, Way w2) { 95 if (isBuilding(w1)) { 96 return tr("Crossing buildings"); 97 } else if (w1.hasKey(WATERWAY) && w2.hasKey(WATERWAY)) { 98 return tr("Crossing waterways"); 99 } else if ((w1.hasKey(HIGHWAY) && w2.hasKey(WATERWAY)) 100 || (w2.hasKey(HIGHWAY) && w1.hasKey(WATERWAY))) { 101 return tr("Crossing waterway/highway"); 121 WayType[] types = {getWayType(w1), getWayType(w2)}; 122 Arrays.sort(types); 123 124 if (types[0] == types[1]) { 125 switch(types[0]) { 126 case BUILDING: 127 return tr("Crossing buildings"); 128 case HIGHWAY: 129 return tr("Crossing highways"); 130 case RESIDENTIAL_AREA: 131 return tr("Crossing residential areas"); 132 case WATERWAY: 133 return tr("Crossing waterways"); 134 case WAY: 135 default: 136 return tr("Crossing ways"); 137 } 102 138 } else { 103 return tr("Crossing ways"); 139 switch (types[0]) { 140 case BUILDING: 141 switch (types[1]) { 142 case HIGHWAY: 143 return tr("Crossing building/highway"); 144 case RESIDENTIAL_AREA: 145 return tr("Crossing building/residential area"); 146 case WATERWAY: 147 return tr("Crossing building/waterway"); 148 case WAY: 149 default: 150 return tr("Crossing building/way"); 151 } 152 case HIGHWAY: 153 switch (types[1]) { 154 case RESIDENTIAL_AREA: 155 return tr("Crossing highway/residential area"); 156 case WATERWAY: 157 return tr("Crossing highway/waterway"); 158 case WAY: 159 default: 160 return tr("Crossing highway/way"); 161 } 162 case RESIDENTIAL_AREA: 163 switch (types[1]) { 164 case WATERWAY: 165 return tr("Crossing residential area/waterway"); 166 case WAY: 167 default: 168 return tr("Crossing residential area/way"); 169 } 170 case WATERWAY: 171 default: 172 return tr("Crossing waterway/way"); 173 } 104 174 } 105 175 } … … 236 306 237 307 static boolean isCoastline(OsmPrimitive w) { 238 return w.hasTag("natural", "water", "coastline") || w.hasTag( "landuse", "reservoir");308 return w.hasTag("natural", "water", "coastline") || w.hasTag(LANDUSE, "reservoir"); 239 309 } 240 310
Note:
See TracChangeset
for help on using the changeset viewer.