Changeset 8941 in josm for trunk/src/org


Ignore:
Timestamp:
2015-10-24T21:32:35+02:00 (4 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/src/org/openstreetmap/josm
Files:
2 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
Note: See TracChangeset for help on using the changeset viewer.