Changeset 11385 in josm
- Timestamp:
- 2016-12-13T01:57:37+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/MergeLayerAction.java
r11290 r11385 49 49 if (sourceLayer != null && !sourceLayer.equals(targetLayer)) { 50 50 if (sourceLayer instanceof OsmDataLayer && targetLayer instanceof OsmDataLayer 51 && ((OsmDataLayer) sourceLayer).isUploadDiscouraged() != ((OsmDataLayer) targetLayer).isUploadDiscouraged() ) {52 if (Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() ->51 && ((OsmDataLayer) sourceLayer).isUploadDiscouraged() != ((OsmDataLayer) targetLayer).isUploadDiscouraged() 52 && Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() -> 53 53 warnMergingUploadDiscouragedLayers(sourceLayer, targetLayer)))) { 54 break; 55 } 54 break; 56 55 } 57 56 targetLayer.mergeFrom(sourceLayer); -
trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
r11118 r11385 194 194 } 195 195 196 if ((newNodes.size() > 3) && (newNodes.get(0) == newNodes.get(newNodes.size() - 1))) { 197 // Closed way, check if the first node could also be simplified ... 198 if (!isRequiredNode(w, newNodes.get(0))) { 199 final List<Node> l1 = Arrays.asList(newNodes.get(newNodes.size() - 2), newNodes.get(0), newNodes.get(1)); 200 final List<Node> l2 = new ArrayList<>(3); 201 buildSimplifiedNodeList(l1, 0, 2, threshold, l2); 202 if (!l2.contains(newNodes.get(0))) { 203 newNodes.remove(0); 204 newNodes.set(newNodes.size() - 1, newNodes.get(0)); // close the way 205 } 196 // Closed way, check if the first node could also be simplified ... 197 if (newNodes.size() > 3 && newNodes.get(0) == newNodes.get(newNodes.size() - 1) && !isRequiredNode(w, newNodes.get(0))) { 198 final List<Node> l1 = Arrays.asList(newNodes.get(newNodes.size() - 2), newNodes.get(0), newNodes.get(1)); 199 final List<Node> l2 = new ArrayList<>(3); 200 buildSimplifiedNodeList(l1, 0, 2, threshold, l2); 201 if (!l2.contains(newNodes.get(0))) { 202 newNodes.remove(0); 203 newNodes.set(newNodes.size() - 1, newNodes.get(0)); // close the way 206 204 } 207 205 } -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r10446 r11385 187 187 */ 188 188 public static boolean checkPreUploadConditions(AbstractModifiableLayer layer, APIDataSet apiData) { 189 if (layer.isUploadDiscouraged()) { 190 if (warnUploadDiscouraged(layer)) { 191 return false; 192 } 189 if (layer.isUploadDiscouraged() && warnUploadDiscouraged(layer)) { 190 return false; 193 191 } 194 192 if (layer instanceof OsmDataLayer) { -
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r11109 r11385 91 91 if (!isEnabled()) 92 92 return; 93 if (editLayer.isUploadDiscouraged()) { 94 if (UploadAction.warnUploadDiscouraged(editLayer)) { 95 return; 96 } 93 if (editLayer.isUploadDiscouraged() && UploadAction.warnUploadDiscouraged(editLayer)) { 94 return; 97 95 } 98 96 Collection<OsmPrimitive> modifiedCandidates = getModifiedPrimitives(editLayer.data.getAllSelected()); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWays.java
r10247 r11385 75 75 for (int i = 0; i < sortedNodesPath.size(); i++) { 76 76 Node n = sortedNodesPath.get(i); 77 if (i < sortedNodesPath.size()-1) { 78 if (sortedNodesPath.get(i+1).getCoor().equals(n.getCoor())) { 79 removedNodes.add(n); 80 for (Way w : ways) { 81 w.removeNode(n); 82 } 83 continue; 77 if (i < sortedNodesPath.size()-1 && sortedNodesPath.get(i+1).getCoor().equals(n.getCoor())) { 78 removedNodes.add(n); 79 for (Way w : ways) { 80 w.removeNode(n); 84 81 } 82 continue; 85 83 } 86 84 if (!removedNodes.contains(n)) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r10827 r11385 253 253 254 254 virtualManager.clear(); 255 if (mode == Mode.MOVE) { 256 if (!dragInProgress() && virtualManager.activateVirtualNodeNearPoint(e.getPoint())) { 257 DataSet ds = getLayerManager().getEditDataSet(); 258 if (ds != null && drawTargetHighlight) { 259 ds.setHighlightedVirtualNodes(virtualManager.virtualWays); 260 } 261 mv.setNewCursor(SelectActionCursor.virtual_node.cursor(), this); 262 // don't highlight anything else if a virtual node will be 263 return repaintIfRequired(newHighlights); 264 } 255 if (mode == Mode.MOVE && !dragInProgress() && virtualManager.activateVirtualNodeNearPoint(e.getPoint())) { 256 DataSet ds = getLayerManager().getEditDataSet(); 257 if (ds != null && drawTargetHighlight) { 258 ds.setHighlightedVirtualNodes(virtualManager.virtualWays); 259 } 260 mv.setNewCursor(SelectActionCursor.virtual_node.cursor(), this); 261 // don't highlight anything else if a virtual node will be 262 return repaintIfRequired(newHighlights); 265 263 } 266 264 -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r11288 r11385 849 849 case ANY_VALUE_REGEXP: 850 850 case EXACT_REGEXP: 851 for (String key: osm.keySet()) { 852 if (keyPattern.matcher(key).matches()) { 853 if (mode == Mode.ANY_VALUE_REGEXP 854 || valuePattern.matcher(osm.get(key)).matches()) 855 return true; 856 } 851 for (String k : osm.keySet()) { 852 if (keyPattern.matcher(k).matches() 853 && (mode == Mode.ANY_VALUE_REGEXP || valuePattern.matcher(osm.get(k)).matches())) 854 return true; 857 855 } 858 856 return false; -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
r10662 r11385 239 239 for (ImageryInfo info : layers) { 240 240 for (ImageryInfo def : defaultLayers) { 241 if (isSimilar(def, info)) { 242 if (def.getId() != null && !addedIds.contains(def.getId())) { 243 if (!defaultLayerIds.containsKey(def.getId())) { 244 // ignore ids used more than once (have been purged from the map) 245 continue; 246 } 247 newAddedIds.add(def.getId()); 248 if (info.getId() == null) { 249 info.setId(def.getId()); 250 changed = true; 251 } 241 if (isSimilar(def, info) && def.getId() != null && !addedIds.contains(def.getId())) { 242 if (!defaultLayerIds.containsKey(def.getId())) { 243 // ignore ids used more than once (have been purged from the map) 244 continue; 245 } 246 newAddedIds.add(def.getId()); 247 if (info.getId() == null) { 248 info.setId(def.getId()); 249 changed = true; 252 250 } 253 251 } -
trunk/src/org/openstreetmap/josm/data/osm/FilterMatcher.java
r10716 r11385 134 134 } 135 135 } else { 136 if (filter.mode == SearchMode.replace) { 137 if (filter.hiding) { 138 hiddenFilters.clear(); 139 disabledFilters.clear(); 140 } 136 if (filter.mode == SearchMode.replace && filter.hiding) { 137 hiddenFilters.clear(); 138 disabledFilters.clear(); 141 139 } 142 140 -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r11383 r11385 1050 1050 int counter = 0; 1051 1051 for (OsmPrimitive o : (OsmPrimitive[]) referrers) { 1052 if (dataSet == o.dataSet && o instanceof Way) { 1053 if (++counter >= n) 1054 return true; 1055 } 1052 if (dataSet == o.dataSet && o instanceof Way && ++counter >= n) 1053 return true; 1056 1054 } 1057 1055 return false; -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
r11360 r11385 645 645 PolyData result = null; 646 646 for (PolyData combined : outerPolygons) { 647 if (combined.contains(inner.poly) != Intersection.OUTSIDE) { 648 if (result == null || result.contains(combined.poly) == Intersection.INSIDE) { 649 result = combined; 650 } 647 if (combined.contains(inner.poly) != Intersection.OUTSIDE 648 && (result == null || result.contains(combined.poly) == Intersection.INSIDE)) { 649 result = combined; 651 650 } 652 651 } -
trunk/src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java
r10693 r11385 314 314 String authority = urlMatcher.group(PARSE_URL_AUTHORITY); 315 315 if ("file".equals(scheme)) { // Special case - file: allows an empty authority 316 if (!"".equals(authority)) { 317 if (authority.contains(":")) { // but cannot allow trailing : 318 setErrorMessage(tr("URL contains an invalid authority: {0}", authority)); 319 return false; 320 } 316 if (!"".equals(authority) && authority.contains(":")) { // but cannot allow trailing : 317 setErrorMessage(tr("URL contains an invalid authority: {0}", authority)); 318 return false; 321 319 } 322 320 // drop through to continue validation -
trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java
r11384 r11385 65 65 for (Node n : w.getNodes()) { 66 66 if (!isPowerTower(n)) { 67 if (!isPowerAllowed(n) && IN_DOWNLOADED_AREA.test(n)) { 68 if (!w.isFirstLastNode(n) || !isPowerStation(n)) { 69 error = TestError.builder(this, Severity.WARNING, POWER_LINES) 70 .message(tr("Missing power tower/pole within power line")) 71 .primitives(n); 72 errorNode = n; 73 } 67 if (!isPowerAllowed(n) && IN_DOWNLOADED_AREA.test(n) && (!w.isFirstLastNode(n) || !isPowerStation(n))) { 68 error = TestError.builder(this, Severity.WARNING, POWER_LINES) 69 .message(tr("Missing power tower/pole within power line")) 70 .primitives(n); 71 errorNode = n; 74 72 } 75 73 } else if (fixValue == null) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r11381 r11385 466 466 withErrors.put(p, "HTML"); 467 467 } 468 if (checkValues && key != null && value != null && !value.isEmpty() && presetsValueData != null) { 469 if (!isTagIgnored(key, value)) { 470 if (!isKeyInPresets(key)) { 471 String prettifiedKey = harmonizeKey(key); 472 String fixedKey = harmonizedKeys.get(prettifiedKey); 473 if (fixedKey != null && !"".equals(fixedKey) && !fixedKey.equals(key)) { 474 // misspelled preset key 475 final TestError.Builder error = TestError.builder(this, Severity.WARNING, MISSPELLED_KEY) 476 .message(tr("Misspelled property key"), marktr("Key ''{0}'' looks like ''{1}''."), key, fixedKey) 477 .primitives(p); 478 if (p.hasKey(fixedKey)) { 479 errors.add(error.build()); 480 } else { 481 errors.add(error.fix(() -> new ChangePropertyKeyCommand(p, key, fixedKey)).build()); 482 } 483 withErrors.put(p, "WPK"); 468 if (checkValues && key != null && value != null && !value.isEmpty() && presetsValueData != null && !isTagIgnored(key, value)) { 469 if (!isKeyInPresets(key)) { 470 String prettifiedKey = harmonizeKey(key); 471 String fixedKey = harmonizedKeys.get(prettifiedKey); 472 if (fixedKey != null && !"".equals(fixedKey) && !fixedKey.equals(key)) { 473 // misspelled preset key 474 final TestError.Builder error = TestError.builder(this, Severity.WARNING, MISSPELLED_KEY) 475 .message(tr("Misspelled property key"), marktr("Key ''{0}'' looks like ''{1}''."), key, fixedKey) 476 .primitives(p); 477 if (p.hasKey(fixedKey)) { 478 errors.add(error.build()); 484 479 } else { 485 errors.add(TestError.builder(this, Severity.OTHER, INVALID_VALUE) 486 .message(tr("Presets do not contain property key"), marktr("Key ''{0}'' not in presets."), key) 487 .primitives(p) 488 .build()); 489 withErrors.put(p, "UPK"); 480 errors.add(error.fix(() -> new ChangePropertyKeyCommand(p, key, fixedKey)).build()); 490 481 } 491 } else if (!isTagInPresets(key, value)) { 492 // try to fix common typos and check again if value is still unknown 493 String fixedValue = harmonizeValue(prop.getValue()); 494 Map<String, String> possibleValues = getPossibleValues(presetsValueData.get(key)); 495 if (possibleValues.containsKey(fixedValue)) { 496 final String newKey = possibleValues.get(fixedValue); 497 // misspelled preset value 498 errors.add(TestError.builder(this, Severity.WARNING, MISSPELLED_VALUE) 499 .message(tr("Misspelled property value"), 500 marktr("Value ''{0}'' for key ''{1}'' looks like ''{2}''."), prop.getValue(), key, fixedValue) 501 .primitives(p) 502 .fix(() -> new ChangePropertyCommand(p, key, newKey)) 503 .build()); 504 withErrors.put(p, "WPV"); 505 } else { 506 // unknown preset value 507 errors.add(TestError.builder(this, Severity.OTHER, INVALID_VALUE) 508 .message(tr("Presets do not contain property value"), 509 marktr("Value ''{0}'' for key ''{1}'' not in presets."), prop.getValue(), key) 510 .primitives(p) 511 .build()); 512 withErrors.put(p, "UPV"); 513 } 482 withErrors.put(p, "WPK"); 483 } else { 484 errors.add(TestError.builder(this, Severity.OTHER, INVALID_VALUE) 485 .message(tr("Presets do not contain property key"), marktr("Key ''{0}'' not in presets."), key) 486 .primitives(p) 487 .build()); 488 withErrors.put(p, "UPK"); 514 489 } 515 } 516 } 517 if (checkFixmes && key != null && value != null && !value.isEmpty()) { 518 if ((value.toLowerCase(Locale.ENGLISH).contains("fixme") 519 || value.contains("check and delete") 520 || key.contains("todo") || key.toLowerCase(Locale.ENGLISH).contains("fixme")) 521 && !withErrors.contains(p, "FIXME")) { 522 errors.add(TestError.builder(this, Severity.OTHER, FIXME) 523 .message(tr("FIXMES")) 524 .primitives(p) 525 .build()); 526 withErrors.put(p, "FIXME"); 527 } 528 } 529 } 490 } else if (!isTagInPresets(key, value)) { 491 // try to fix common typos and check again if value is still unknown 492 String fixedValue = harmonizeValue(prop.getValue()); 493 Map<String, String> possibleValues = getPossibleValues(presetsValueData.get(key)); 494 if (possibleValues.containsKey(fixedValue)) { 495 final String newKey = possibleValues.get(fixedValue); 496 // misspelled preset value 497 errors.add(TestError.builder(this, Severity.WARNING, MISSPELLED_VALUE) 498 .message(tr("Misspelled property value"), 499 marktr("Value ''{0}'' for key ''{1}'' looks like ''{2}''."), prop.getValue(), key, fixedValue) 500 .primitives(p) 501 .fix(() -> new ChangePropertyCommand(p, key, newKey)) 502 .build()); 503 withErrors.put(p, "WPV"); 504 } else { 505 // unknown preset value 506 errors.add(TestError.builder(this, Severity.OTHER, INVALID_VALUE) 507 .message(tr("Presets do not contain property value"), 508 marktr("Value ''{0}'' for key ''{1}'' not in presets."), prop.getValue(), key) 509 .primitives(p) 510 .build()); 511 withErrors.put(p, "UPV"); 512 } 513 } 514 } 515 if (checkFixmes && key != null && value != null && !value.isEmpty() && isFixme(key, value) && !withErrors.contains(p, "FIXME")) { 516 errors.add(TestError.builder(this, Severity.OTHER, FIXME) 517 .message(tr("FIXMES")) 518 .primitives(p) 519 .build()); 520 withErrors.put(p, "FIXME"); 521 } 522 } 523 } 524 525 private static boolean isFixme(String key, String value) { 526 return key.toLowerCase(Locale.ENGLISH).contains("fixme") || key.contains("todo") 527 || value.toLowerCase(Locale.ENGLISH).contains("fixme") || value.contains("check and delete"); 530 528 } 531 529
Note:
See TracChangeset
for help on using the changeset viewer.