Changeset 8941 in josm
- Timestamp:
- 2015-10-24T21:32:35+02:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r8846 r8941 17 17 import javax.swing.Icon; 18 18 19 import org.openstreetmap.josm. Main;19 import org.openstreetmap.josm.data.osm.DataSet; 20 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 21 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 106 106 } 107 107 108 @Override public boolean executeCommand() { 109 Main.main.getCurrentDataSet().beginUpdate(); 108 @Override 109 public boolean executeCommand() { 110 final DataSet dataSet = objects.get(0).getDataSet(); 111 dataSet.beginUpdate(); 110 112 try { 111 113 super.executeCommand(); // save old … … 129 131 return true; 130 132 } finally { 131 Main.main.getCurrentDataSet().endUpdate(); 132 } 133 } 134 135 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 133 dataSet.endUpdate(); 134 } 135 } 136 137 @Override 138 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 136 139 modified.addAll(objects); 137 140 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java
r8840 r8941 20 20 import org.openstreetmap.josm.data.osm.OsmUtils; 21 21 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.data.validation.FixableTestError; 22 23 import org.openstreetmap.josm.data.validation.Severity; 23 24 import org.openstreetmap.josm.data.validation.Test; … … 39 40 protected static final int SOURCE_MAXSPEED_CONTEXT_MISMATCH_VS_HIGHWAY = 2706; 40 41 protected static final int SOURCE_WRONG_LINK = 2707; 42 43 protected static final String SOURCE_MAXSPEED = "source:maxspeed"; 41 44 42 45 /** … … 92 95 testMissingPedestrianCrossing(n); 93 96 } 94 if (n.hasKey( "source:maxspeed")) {97 if (n.hasKey(SOURCE_MAXSPEED)) { 95 98 // Check maxspeed but not context against highway for nodes 96 99 // as maxspeed is not set on highways here but on signs, speed cameras, etc. … … 107 110 testWrongRoundabout(w); 108 111 } 109 if (w.hasKey( "source:maxspeed")) {112 if (w.hasKey(SOURCE_MAXSPEED)) { 110 113 // Check maxspeed, including context against highway 111 114 testSourceMaxspeed(w, true); … … 240 243 241 244 private void testSourceMaxspeed(OsmPrimitive p, boolean testContextHighway) { 242 String value = p.get( "source:maxspeed");245 String value = p.get(SOURCE_MAXSPEED); 243 246 if (value.matches("[A-Z]{2}:.+")) { 244 247 int index = value.indexOf(':'); … … 246 249 String country = value.substring(0, index); 247 250 if (!ISO_COUNTRIES.contains(country)) { 248 errors.add(new TestError(this, Severity.WARNING, 249 tr("Unknown country code: {0}", country), SOURCE_MAXSPEED_UNKNOWN_COUNTRY_CODE, p)); 251 if ("UK".equals(country)) { 252 errors.add(new FixableTestError(this, Severity.WARNING, 253 tr("Unknown country code: {0}", country), SOURCE_MAXSPEED_UNKNOWN_COUNTRY_CODE, p, 254 new ChangePropertyCommand(p, SOURCE_MAXSPEED, value.replace("UK:", "GB:")))); 255 } else { 256 errors.add(new TestError(this, Severity.WARNING, 257 tr("Unknown country code: {0}", country), SOURCE_MAXSPEED_UNKNOWN_COUNTRY_CODE, p)); 258 } 250 259 } 251 260 // Check context -
trunk/test/config/unit-josm.home
- Property svn:ignore
-
old new 7 7 elevation 8 8 preferences.xml.bak 9 plugins 10 ebdirigo
-
- Property svn:ignore
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/HighwaysTest.groovy
r7938 r8941 5 5 import org.openstreetmap.josm.data.coor.LatLon 6 6 import org.openstreetmap.josm.data.osm.DataSet 7 import org.openstreetmap.josm.data.osm.Node 7 8 import org.openstreetmap.josm.data.osm.Way 8 9 … … 17 18 def ds = new DataSet() 18 19 19 def n00 = new org.openstreetmap.josm.data.osm.Node(new LatLon(0, 0))20 def n10 = new org.openstreetmap.josm.data.osm.Node(new LatLon(1, 0))21 def n20 = new org.openstreetmap.josm.data.osm.Node(new LatLon(2, 0))22 def n01 = new org.openstreetmap.josm.data.osm.Node(new LatLon(0, 1))23 def n11 = new org.openstreetmap.josm.data.osm.Node(new LatLon(1, 1))24 def n21 = new org.openstreetmap.josm.data.osm.Node(new LatLon(2, 1))20 def n00 = new Node(new LatLon(0, 0)) 21 def n10 = new Node(new LatLon(1, 0)) 22 def n20 = new Node(new LatLon(2, 0)) 23 def n01 = new Node(new LatLon(0, 1)) 24 def n11 = new Node(new LatLon(1, 1)) 25 def n21 = new Node(new LatLon(2, 1)) 25 26 26 27 ds.addPrimitive(n00) … … 61 62 assert Highways.isHighwayLinkOkay(createTestSetting("residential", "residential")) 62 63 } 64 65 void testSourceMaxSpeedUnitedKingdom() { 66 def link = createTestSetting("primary", "primary") 67 link.put("maxspeed", "60 mph") 68 link.put("source:maxspeed", "UK:nsl_single") 69 def test = new Highways() 70 test.visit(link) 71 assert test.errors.size() == 1 72 def error = test.errors.get(0) 73 assert error.isFixable() 74 assert error.getFix().executeCommand() 75 assert "GB:nsl_single".equals(link.get("source:maxspeed")) 76 } 63 77 }
Note:
See TracChangeset
for help on using the changeset viewer.