Changeset 8941 in josm


Ignore:
Timestamp:
2015-10-24T21:32:35+02:00 (9 years ago)
Author:
Don-vip
Message:

fix #12004 - suggest to replace source:maxspeed=UK:* by source:maxspeed=GB:* as per ISO 3166-2

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java

    r8846 r8941  
    1717import javax.swing.Icon;
    1818
    19 import org.openstreetmap.josm.Main;
     19import org.openstreetmap.josm.data.osm.DataSet;
    2020import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2121import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     
    106106    }
    107107
    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();
    110112        try {
    111113            super.executeCommand(); // save old
     
    129131            return true;
    130132        } 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) {
    136139        modified.addAll(objects);
    137140    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java

    r8840 r8941  
    2020import org.openstreetmap.josm.data.osm.OsmUtils;
    2121import org.openstreetmap.josm.data.osm.Way;
     22import org.openstreetmap.josm.data.validation.FixableTestError;
    2223import org.openstreetmap.josm.data.validation.Severity;
    2324import org.openstreetmap.josm.data.validation.Test;
     
    3940    protected static final int SOURCE_MAXSPEED_CONTEXT_MISMATCH_VS_HIGHWAY = 2706;
    4041    protected static final int SOURCE_WRONG_LINK = 2707;
     42
     43    protected static final String SOURCE_MAXSPEED = "source:maxspeed";
    4144
    4245    /**
     
    9295                testMissingPedestrianCrossing(n);
    9396            }
    94             if (n.hasKey("source:maxspeed")) {
     97            if (n.hasKey(SOURCE_MAXSPEED)) {
    9598                // Check maxspeed but not context against highway for nodes
    9699                // as maxspeed is not set on highways here but on signs, speed cameras, etc.
     
    107110                testWrongRoundabout(w);
    108111            }
    109             if (w.hasKey("source:maxspeed")) {
     112            if (w.hasKey(SOURCE_MAXSPEED)) {
    110113                // Check maxspeed, including context against highway
    111114                testSourceMaxspeed(w, true);
     
    240243
    241244    private void testSourceMaxspeed(OsmPrimitive p, boolean testContextHighway) {
    242         String value = p.get("source:maxspeed");
     245        String value = p.get(SOURCE_MAXSPEED);
    243246        if (value.matches("[A-Z]{2}:.+")) {
    244247            int index = value.indexOf(':');
     
    246249            String country = value.substring(0, index);
    247250            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                }
    250259            }
    251260            // Check context
  • trunk/test/config/unit-josm.home

    • Property svn:ignore
      •  

        old new  
        77elevation
        88preferences.xml.bak
         9plugins
         10ebdirigo
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/HighwaysTest.groovy

    r7938 r8941  
    55import org.openstreetmap.josm.data.coor.LatLon
    66import org.openstreetmap.josm.data.osm.DataSet
     7import org.openstreetmap.josm.data.osm.Node
    78import org.openstreetmap.josm.data.osm.Way
    89
     
    1718        def ds = new DataSet()
    1819
    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))
    2526
    2627        ds.addPrimitive(n00)
     
    6162        assert Highways.isHighwayLinkOkay(createTestSetting("residential", "residential"))
    6263    }
     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    }
    6377}
Note: See TracChangeset for help on using the changeset viewer.