Changeset 11913 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2017-04-15T01:38:46+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r11746 r11913 106 106 public class Preferences { 107 107 108 private static final String COLOR_PREFIX = "color."; 109 108 110 private static final String[] OBSOLETE_PREF_KEYS = { 109 111 "hdop.factor", /* remove entry after April 2017 */ … … 501 503 final Map<String, String> all = new TreeMap<>(); 502 504 for (final Entry<String, Setting<?>> e : defaultsMap.entrySet()) { 503 if (e.getKey().startsWith( "color.") && e.getValue() instanceof StringSetting) {505 if (e.getKey().startsWith(COLOR_PREFIX) && e.getValue() instanceof StringSetting) { 504 506 StringSetting d = (StringSetting) e.getValue(); 505 507 if (d.getValue() != null) { … … 509 511 } 510 512 for (final Entry<String, Setting<?>> e : settingsMap.entrySet()) { 511 if (e.getKey().startsWith( "color.") && (e.getValue() instanceof StringSetting)) {513 if (e.getKey().startsWith(COLOR_PREFIX) && (e.getValue() instanceof StringSetting)) { 512 514 all.put(e.getKey().substring(6), ((StringSetting) e.getValue()).getValue()); 513 515 } … … 864 866 String colKey = ColorProperty.getColorKey(colName); 865 867 registerColor(colKey, colName); 866 String colStr = specName != null ? get( "color."+specName) : "";868 String colStr = specName != null ? get(COLOR_PREFIX+specName) : ""; 867 869 if (colStr.isEmpty()) { 868 870 colStr = get(colKey, ColorHelper.color2html(def, true)); … … 888 890 889 891 public synchronized Color getDefaultColor(String colKey) { 890 StringSetting col = Utils.cast(defaultsMap.get( "color."+colKey), StringSetting.class);892 StringSetting col = Utils.cast(defaultsMap.get(COLOR_PREFIX+colKey), StringSetting.class); 891 893 String colStr = col == null ? null : col.getValue(); 892 894 return colStr == null || colStr.isEmpty() ? null : ColorHelper.html2color(colStr); … … 894 896 895 897 public synchronized boolean putColor(String colKey, Color val) { 896 return put( "color."+colKey, val != null ? ColorHelper.color2html(val, true) : null);898 return put(COLOR_PREFIX+colKey, val != null ? ColorHelper.color2html(val, true) : null); 897 899 } 898 900 … … 1532 1534 private void migrateOldColorKeys() { 1533 1535 settingsMap.keySet().stream() 1534 .filter(key -> key.startsWith( "color."))1536 .filter(key -> key.startsWith(COLOR_PREFIX)) 1535 1537 .flatMap(key -> { 1536 final String newKey = ColorProperty.getColorKey(key.substring( "color.".length()));1538 final String newKey = ColorProperty.getColorKey(key.substring(COLOR_PREFIX.length())); 1537 1539 return key.equals(newKey) || settingsMap.containsKey(newKey) 1538 1540 ? Stream.empty() -
trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
r11893 r11913 32 32 protected static final int CROSSING_WAYS = 601; 33 33 34 privatestatic final String HIGHWAY = "highway";35 privatestatic final String RAILWAY = "railway";36 privatestatic final String WATERWAY = "waterway";34 static final String HIGHWAY = "highway"; 35 static final String RAILWAY = "railway"; 36 static final String WATERWAY = "waterway"; 37 37 38 38 /** All way segments, grouped by cells */ -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
r11893 r11913 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.openstreetmap.josm.data.validation.tests.CrossingWays.HIGHWAY; 5 import static org.openstreetmap.josm.data.validation.tests.CrossingWays.RAILWAY; 6 import static org.openstreetmap.josm.data.validation.tests.CrossingWays.WATERWAY; 4 7 import static org.openstreetmap.josm.tools.I18n.tr; 5 8 … … 99 102 100 103 private static final String[] TYPES = { 101 "none", "highway", "railway", "waterway", "boundary", "power", "natural", "landuse", "building"};104 "none", HIGHWAY, RAILWAY, WATERWAY, "boundary", "power", "natural", "landuse", "building"}; 102 105 103 106 /** The map of potential duplicates. … … 210 213 .primitives(primitives) 211 214 .build()); 212 } else if (typeMap.get( "highway")) {215 } else if (typeMap.get(HIGHWAY)) { 213 216 errors.add(TestError.builder(parentTest, Severity.ERROR, DUPLICATE_NODE_HIGHWAY) 214 217 .message(tr("Highway duplicated nodes")) 215 218 .primitives(primitives) 216 219 .build()); 217 } else if (typeMap.get( "railway")) {220 } else if (typeMap.get(RAILWAY)) { 218 221 errors.add(TestError.builder(parentTest, Severity.ERROR, DUPLICATE_NODE_RAILWAY) 219 222 .message(tr("Railway duplicated nodes")) 220 223 .primitives(primitives) 221 224 .build()); 222 } else if (typeMap.get( "waterway")) {225 } else if (typeMap.get(WATERWAY)) { 223 226 errors.add(TestError.builder(parentTest, Severity.ERROR, DUPLICATE_NODE_WATERWAY) 224 227 .message(tr("Waterway duplicated nodes")) -
trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java
r11807 r11913 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.openstreetmap.josm.data.validation.tests.CrossingWays.HIGHWAY; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 77 78 if (n.isUsable()) { 78 79 if (!n.hasTag("crossing", "no") 79 && !(n.hasKey("crossing") && (n.hasTag("highway", "crossing") || n.hasTag("highway", "traffic_signals"))) 80 && !(n.hasKey("crossing") && (n.hasTag(HIGHWAY, "crossing") 81 || n.hasTag(HIGHWAY, "traffic_signals"))) 80 82 && n.isReferredByWays(2)) { 81 83 testMissingPedestrianCrossing(n); … … 92 94 public void visit(Way w) { 93 95 if (w.isUsable()) { 94 if (w.isClosed() && w.hasTag( "highway", CLASSIFIED_HIGHWAYS) && w.hasTag("junction", "roundabout")) {96 if (w.isClosed() && w.hasTag(HIGHWAY, CLASSIFIED_HIGHWAYS) && w.hasTag("junction", "roundabout")) { 95 97 // TODO: find out how to handle splitted roundabouts (see #12841) 96 98 testWrongRoundabout(w); … … 110 112 for (Node n : new HashSet<>(w.getNodes())) { 111 113 for (Way h : Utils.filteredCollection(n.getReferrers(), Way.class)) { 112 String value = h.get( "highway");114 String value = h.get(HIGHWAY); 113 115 if (h != w && value != null && !value.endsWith("_link")) { 114 116 List<Way> list = map.get(value); … … 130 132 if (list.size() > 2 || oneway1 == null || oneway2 == null || !oneway1 || !oneway2) { 131 133 // Error when the highway tags do not match 132 String value = w.get( "highway");134 String value = w.get(HIGHWAY); 133 135 if (!value.equals(s)) { 134 136 errors.add(TestError.builder(this, Severity.WARNING, WRONG_ROUNDABOUT_HIGHWAY) 135 137 .message(tr("Incorrect roundabout (highway: {0} instead of {1})", value, s)) 136 138 .primitives(w) 137 .fix(() -> new ChangePropertyCommand(w, "highway", s))139 .fix(() -> new ChangePropertyCommand(w, HIGHWAY, s)) 138 140 .build()); 139 141 } … … 145 147 146 148 public static boolean isHighwayLinkOkay(final Way way) { 147 final String highway = way.get( "highway");149 final String highway = way.get(HIGHWAY); 148 150 if (highway == null || !highway.endsWith("_link") 149 151 || !IN_DOWNLOADED_AREA.test(way.getNode(0)) || !IN_DOWNLOADED_AREA.test(way.getNode(way.getNodesCount()-1))) { … … 164 166 165 167 return Utils.filteredCollection(referrers, Way.class).stream().anyMatch( 166 otherWay -> !way.equals(otherWay) && otherWay.hasTag( "highway", highway, highway.replaceAll("_link$", "")));168 otherWay -> !way.equals(otherWay) && otherWay.hasTag(HIGHWAY, highway, highway.replaceAll("_link$", ""))); 167 169 } 168 170 … … 185 187 186 188 for (Way w : OsmPrimitive.getFilteredList(n.getReferrers(), Way.class)) { 187 String highway = w.get( "highway");189 String highway = w.get(HIGHWAY); 188 190 if (highway != null) { 189 191 if ("footway".equals(highway) || "path".equals(highway)) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java
r11608 r11913 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.openstreetmap.josm.data.validation.tests.CrossingWays.HIGHWAY; 5 import static org.openstreetmap.josm.data.validation.tests.CrossingWays.RAILWAY; 4 6 import static org.openstreetmap.josm.tools.I18n.tr; 5 7 … … 90 92 91 93 for (WaySegment ws : duplicated) { 92 if (ws.way.hasKey( "highway")) {94 if (ws.way.hasKey(HIGHWAY)) { 93 95 highway++; 94 } else if (ws.way.hasKey( "railway")) {96 } else if (ws.way.hasKey(RAILWAY)) { 95 97 railway++; 96 98 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
r11621 r11913 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.openstreetmap.josm.data.validation.tests.CrossingWays.HIGHWAY; 5 import static org.openstreetmap.josm.data.validation.tests.CrossingWays.RAILWAY; 4 6 import static org.openstreetmap.josm.tools.I18n.tr; 5 7 … … 57 59 @Override 58 60 public boolean isPrimitiveUsable(OsmPrimitive p) { 59 return super.isPrimitiveUsable(p) && p.hasKey( "highway");61 return super.isPrimitiveUsable(p) && p.hasKey(HIGHWAY); 60 62 } 61 63 } … … 181 183 continue; 182 184 } 183 if (en.hasTag( "highway", "turning_circle", "bus_stop")185 if (en.hasTag(HIGHWAY, "turning_circle", "bus_stop") 184 186 || en.hasTag("amenity", "parking_entrance") 185 || en.hasTag( "railway", "buffer_stop")187 || en.hasTag(RAILWAY, "buffer_stop") 186 188 || en.isKeyTrue("noexit") 187 189 || en.hasKey("entrance", "barrier")) { … … 302 304 MyWaySegment(Way w, Node n1, Node n2) { 303 305 this.w = w; 304 String railway = w.get( "railway");305 String highway = w.get( "highway");306 String railway = w.get(RAILWAY); 307 String highway = w.get(HIGHWAY); 306 308 this.isAbandoned = "abandoned".equals(railway) || w.isKeyTrue("disused"); 307 309 this.highway = (highway != null || railway != null) && !isAbandoned; … … 449 451 && !w.hasKey("addr:interpolation") 450 452 // similarly for public transport platforms 451 && !w.hasTag( "highway", "platform") && !w.hasTag("railway", "platform")453 && !w.hasTag(HIGHWAY, "platform") && !w.hasTag(RAILWAY, "platform") 452 454 ) { 453 455 ways.addAll(getWaySegments(w)); 454 456 QuadBuckets<Node> set = endnodes; 455 if (w.hasKey( "highway", "railway")) {457 if (w.hasKey(HIGHWAY, RAILWAY)) { 456 458 set = endnodesHighway; 457 459 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java
r11384 r11913 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.openstreetmap.josm.data.validation.tests.CrossingWays.HIGHWAY; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 81 82 Map<String, String> tags = w.getKeys(); 82 83 if (!tags.isEmpty()) { 83 String highway = tags.get( "highway");84 String highway = tags.get(HIGHWAY); 84 85 if (highway != null && NAMED_WAYS.contains(highway) && !tags.containsKey("name") && !tags.containsKey("ref") 85 86 && !"yes".equals(tags.get("noname"))) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/WayConnectedToArea.java
r11587 r11913 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.openstreetmap.josm.data.validation.tests.CrossingWays.HIGHWAY; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 30 31 @Override 31 32 public void visit(Way w) { 32 if (!w.isUsable() || w.isClosed() || !w.hasKey( "highway")) {33 if (!w.isUsable() || w.isClosed() || !w.hasKey(HIGHWAY)) { 33 34 return; 34 35 } … … 37 38 List<OsmPrimitive> r = w.firstNode().getReferrers(); 38 39 for (OsmPrimitive p : r) { 39 if (p != w && p.hasKey( "highway")) {40 if (p != w && p.hasKey(HIGHWAY)) { 40 41 hasway = true; 41 42 break; … … 50 51 r = w.lastNode().getReferrers(); 51 52 for (OsmPrimitive p : r) { 52 if (p != w && p.hasKey( "highway")) {53 if (p != w && p.hasKey(HIGHWAY)) { 53 54 hasway = true; 54 55 break; … … 86 87 private void addPossibleError(Way w, Node wayNode, OsmPrimitive p, OsmPrimitive area) { 87 88 // Avoid "legal" cases (see #10655) 88 if (w.hasKey( "highway") && wayNode.hasTag("leisure", "slipway") && area.hasTag("natural", "water")) {89 if (w.hasKey(HIGHWAY) && wayNode.hasTag("leisure", "slipway") && area.hasTag("natural", "water")) { 89 90 return; 90 91 }
Note:
See TracChangeset
for help on using the changeset viewer.