Changeset 6639 in josm


Ignore:
Timestamp:
2014-01-06T12:27:11+01:00 (6 years ago)
Author:
simon04
Message:

fix #9544 - Skip nodes outside of download area for BarriersEntrances and WayConnectedToArea validation tests

Location:
trunk/src/org/openstreetmap/josm
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r6380 r6639  
    88import java.awt.event.ActionEvent;
    99import java.awt.event.KeyEvent;
    10 import java.awt.geom.Area;
    1110import java.util.ArrayList;
    1211import java.util.Collection;
     
    338337
    339338        // TODO: Only display this warning when nodes outside dataSourceArea are deleted
    340         Area dataSourceArea = Main.main.getCurrentDataSet().getDataSourceArea();
    341339        boolean ok = Command.checkAndConfirmOutlyingOperation("joinarea", tr("Join area confirmation"),
    342340                trn("The selected way has nodes outside of the downloaded data region.",
     
    347345                    + tr("Please abort if you are not sure"),
    348346                tr("The selected area is incomplete. Continue?"),
    349                 dataSourceArea, allNodes, null);
     347                allNodes, null);
    350348        if(!ok) return;
    351349
  • trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java

    r6411 r6639  
    4949
    5050    protected boolean confirmWayWithNodesOutsideBoundingBox(List<? extends OsmPrimitive> primitives) {
    51         return DeleteCommand.checkAndConfirmOutlyingDelete(Main.main.getEditLayer(), primitives, null);
     51        return DeleteCommand.checkAndConfirmOutlyingDelete(primitives, null);
    5252    }
    5353
  • trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java

    r6507 r6639  
    438438                        + "This will cause problems because you don''t see the real object."
    439439                        + "<br>" + "Do you really want to unglue?"),
    440                 getEditLayer().data.getDataSourceArea(), primitives, null);
     440                primitives, null);
    441441    }
    442442}
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r6538 r6639  
    191191     * @param outsideDialogMessage the message text to be displayed when data is outside of the download area
    192192     * @param incompleteDialogMessage the message text to be displayed when data is incomplete
    193      * @param area the area used to determine whether data is outlying
    194193     * @param primitives the primitives to operate on
    195194     * @param ignore {@code null} or a primitive to be ignored
     
    198197    public static boolean checkAndConfirmOutlyingOperation(String operation,
    199198            String dialogTitle, String outsideDialogMessage, String incompleteDialogMessage,
    200             Area area, Collection<? extends OsmPrimitive> primitives,
     199            Collection<? extends OsmPrimitive> primitives,
    201200            Collection<? extends OsmPrimitive> ignore) {
    202201        boolean outside = false;
     
    205204            if (osm.isIncomplete()) {
    206205                incomplete = true;
    207             } else if (area != null && isOutlying(osm, area)
     206            } else if (osm.isOutsideDownloadArea()
    208207                    && (ignore == null || !ignore.contains(osm))) {
    209208                outside = true;
     
    241240    }
    242241
    243     private static boolean isOutlying(OsmPrimitive osm, Area area) {
    244         if (osm instanceof Node && !osm.isNewOrUndeleted()) {
    245             return !((Node) osm).getCoor().isIn(area);
    246         } else if (osm instanceof Way) {
    247             for (Node n : ((Way) osm).getNodes()) {
    248                 if (isOutlying(n, area)) {
    249                     return true;
    250                 }
    251             }
    252             return false;
    253         }
    254         return false;
    255     }
    256242}
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r6524 r6639  
    77
    88import java.awt.GridBagLayout;
    9 import java.awt.geom.Area;
    109import java.util.ArrayList;
    1110import java.util.Collection;
     
    253252        if (parents.isEmpty())
    254253            return null;
    255         if (!silent && !checkAndConfirmOutlyingDelete(layer, parents, null))
     254        if (!silent && !checkAndConfirmOutlyingDelete(parents, null))
    256255            return null;
    257256        return new DeleteCommand(layer,parents);
     
    355354        }
    356355
    357         if (!silent && !checkAndConfirmOutlyingDelete(layer,
     356        if (!silent && !checkAndConfirmOutlyingDelete(
    358357                primitivesToDelete, Utils.filteredCollection(primitivesToDelete, Way.class)))
    359358            return null;
     
    450449    }
    451450
    452     public static boolean checkAndConfirmOutlyingDelete(OsmDataLayer layer, Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> ignore) {
    453         return checkAndConfirmOutlyingDelete(layer.data.getDataSourceArea(), primitives, ignore);
    454     }
    455 
    456     public static boolean checkAndConfirmOutlyingDelete(Area area, Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> ignore) {
     451    public static boolean checkAndConfirmOutlyingDelete(Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> ignore) {
    457452        return Command.checkAndConfirmOutlyingOperation("delete",
    458453                tr("Delete confirmation"),
     
    466461                        + "This will cause problems because you don''t see the real object."
    467462                        + "<br>" + "Do you really want to delete?"),
    468                 area, primitives, ignore);
     463                primitives, ignore);
    469464    }
    470465
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r6556 r6639  
    376376        return false;
    377377    }
     378
     379    @Override
     380    public boolean isOutsideDownloadArea() {
     381        return !isNewOrUndeleted() && getDataSet() != null && getDataSet().getDataSourceArea() != null
     382                && !getCoor().isIn(getDataSet().getDataSourceArea());
     383    }
    378384}
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r6629 r6639  
    13671367     */
    13681368    public abstract boolean concernsArea();
     1369
     1370    /**
     1371     * Tests if this primitive lies outside of the downloaded area of its {@link DataSet}.
     1372     * @return {@code true} if this primitive lies outside of the downloaded area
     1373     */
     1374    public abstract boolean isOutsideDownloadArea();
    13691375}
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r6575 r6639  
    550550        return isMultipolygon() && hasAreaTags();
    551551    }
     552
     553    @Override
     554    public boolean isOutsideDownloadArea() {
     555        return false;
     556    }
    552557}
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r6491 r6639  
    726726        return hasAreaTags();
    727727    }
     728
     729    @Override
     730    public boolean isOutsideDownloadArea() {
     731        for (final Node n : nodes) {
     732            if (n.isOutsideDownloadArea()) {
     733                return true;
     734            }
     735        }
     736        return false;
     737    }
    728738}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/BarriersEntrances.java

    r6192 r6639  
    2727    @Override
    2828    public void visit(Node n) {
    29         if (n.hasTag("barrier", "entrance")) {
     29        if (n.hasTag("barrier", "entrance") && !n.isOutsideDownloadArea()) {
    3030            for (OsmPrimitive p : n.getReferrers()) {
    3131                if (p.hasKey("barrier")) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java

    r6258 r6639  
    409409            }
    410410
    411             if (DeleteCommand.checkAndConfirmOutlyingDelete(Main.main.getCurrentDataSet().getDataSourceArea(), nodes, Collections.singleton(target)))
     411            if (DeleteCommand.checkAndConfirmOutlyingDelete(nodes, Collections.singleton(target)))
    412412                return MergeNodesAction.mergeNodes(Main.main.getEditLayer(), nodes, target);
    413413        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/WayConnectedToArea.java

    r6494 r6639  
    6464
    6565    private void testForError(Way w, Node wayNode, OsmPrimitive p) {
    66         if (isArea(p)) {
     66        if (wayNode.isOutsideDownloadArea()) {
     67        } else if (isArea(p)) {
    6768            addError(w, wayNode, p);
    6869        } else {
Note: See TracChangeset for help on using the changeset viewer.