Ignore:
Timestamp:
2013-09-24T08:38:26+02:00 (6 years ago)
Author:
stoecker
Message:

fix #8798 - patch by AlfonZ - fix extruder

File:
1 edited

Legend:

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

    r6162 r6252  
    7474    private Stroke mainStroke;
    7575
     76    /** settings value whether shared nodes should be ignored or not */
     77    private boolean ignoreSharedNodes;
     78
    7679    /**
    7780     * drawing settings for helper lines
     
    214217        oldLineStroke = GuiHelper.getCustomizedStroke(Main.pref.get("extrude.ctrl.stroke.old-line", "1"));
    215218        mainStroke = GuiHelper.getCustomizedStroke(Main.pref.get("extrude.stroke.main", "3"));
     219
     220        ignoreSharedNodes = Main.pref.getBoolean("extrude.ignore-shared-nodes", true);
    216221    }
    217222
     
    443448        Node prevNode = getPreviousNode(selectedSegment.lowerIndex);
    444449        boolean nodeOverlapsSegment = prevNode != null && Geometry.segmentsParallel(initialN1en, prevNode.getEastNorth(), initialN1en, newN1en);
     450        // segmentAngleZero marks subset of nodeOverlapsSegment. nodeOverlapsSegment is true if angle between segments is 0 or PI, segmentAngleZero only if angle is 0
     451        boolean segmentAngleZero = prevNode != null && Math.abs(Geometry.getCornerAngle(prevNode.getEastNorth(), initialN1en, newN1en)) < 1e-5;
    445452        boolean hasOtherWays = this.hasNodeOtherWays(selectedSegment.getFirstNode(), selectedSegment.way);
    446453
     
    449456            Node n1Old = selectedSegment.getFirstNode();
    450457            cmds.add(new MoveCommand(n1Old, Main.getProjection().eastNorth2latlon(newN1en)));
     458        } else if (ignoreSharedNodes && segmentAngleZero && !alwaysCreateNodes && hasOtherWays) {
     459            // replace shared node with new one
     460            Node n1Old = selectedSegment.getFirstNode();
     461            Node n1New = new Node(Main.getProjection().eastNorth2latlon(newN1en));
     462            wnew.addNode(insertionPoint, n1New);
     463            wnew.removeNode(n1Old);
     464            wayWasModified = true;
     465            cmds.add(new AddCommand(n1New));
    451466        } else {
    452467            //introduce new node
     
    461476        Node nextNode = getNextNode(selectedSegment.lowerIndex + 1);
    462477        nodeOverlapsSegment = nextNode != null && Geometry.segmentsParallel(initialN2en, nextNode.getEastNorth(), initialN2en, newN2en);
     478        segmentAngleZero = nextNode != null && Math.abs(Geometry.getCornerAngle(nextNode.getEastNorth(), initialN2en, newN2en)) < 1e-5;
    463479        hasOtherWays = hasNodeOtherWays(selectedSegment.getSecondNode(), selectedSegment.way);
    464480
     
    467483            Node n2Old = selectedSegment.getSecondNode();
    468484            cmds.add(new MoveCommand(n2Old, Main.getProjection().eastNorth2latlon(newN2en)));
     485        } else if (ignoreSharedNodes && segmentAngleZero && !alwaysCreateNodes && hasOtherWays) {
     486            // replace shared node with new one
     487            Node n2Old = selectedSegment.getSecondNode();
     488            Node n2New = new Node(Main.getProjection().eastNorth2latlon(newN2en));
     489            wnew.addNode(insertionPoint, n2New);
     490            wnew.removeNode(n2Old);
     491            wayWasModified = true;
     492            cmds.add(new AddCommand(n2New));
    469493        } else {
    470494            //introduce new node
Note: See TracChangeset for help on using the changeset viewer.