Changeset 3515 in josm


Ignore:
Timestamp:
2010-09-09T17:14:05+02:00 (10 years ago)
Author:
stoecker
Message:

fixed #5431 - splitting way fails when outer-node is also inner node

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

Legend:

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

    r3437 r3515  
    118118                while (it.hasNext()) {
    119119                    Way w = it.next();
    120                     assert w.isUsable(); // Way is referrer of selected node(s) so it must be usable
    121                     int last = w.getNodesCount() - 1;
    122                     boolean circular = w.isClosed();
    123 
    124120                    for (Node n : selectedNodes) {
    125                         int i = w.getNodes().indexOf(n);
    126                         if (!(circular || (i > 0 && i < last))) {
     121                        if(!w.isInnerNode(n)) {
    127122                            it.remove();
    128123                            continue WAY_LOOP;
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r3468 r3515  
    407407    }
    408408
     409    public boolean isInnerNode(Node n) {
     410        Node[] nodes = this.nodes;
     411        if (isIncomplete() || nodes.length <= 2) return false;
     412        /* circular ways have only inner nodes, so return true for them! */
     413        if (n == nodes[0] && n == nodes[nodes.length-1]) return true;
     414        for(int i = 1; i < nodes.length - 1; ++i) {
     415            if(nodes[i] == n) return true;
     416        }
     417        return false;
     418    }
     419
     420
    409421    @Override
    410422    public String getDisplayName(NameFormatter formatter) {
Note: See TracChangeset for help on using the changeset viewer.