Changeset 30631 in osm for applications/editors/josm


Ignore:
Timestamp:
2014-09-14T19:56:42+02:00 (10 years ago)
Author:
donvip
Message:

[josm_alignways] fix #josm7883 - IndexOutOfBoundsException when aligning segment with free node using Angle preservation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysCmdKeepAngles.java

    r30345 r30631  
    1919import com.tilusnet.josm.plugins.alignways.geometry.AlignWaysGeomLine.IntersectionStatus;
    2020import com.tilusnet.josm.plugins.alignways.geometry.AlignWaysGeomPoint;
    21 
    2221
    2322/**
     
    2726public class AlignWaysCmdKeepAngles extends AlignWaysCmdKeepLength {
    2827
    29     AlignableStatus alignableStatKeepAngles = AlignableStatus.ALGN_VALID;
     28    private AlignableStatus alignableStatKeepAngles = AlignableStatus.ALGN_VALID;
    3029
    3130    public AlignWaysCmdKeepAngles() {
    32         super();
    33 
    3431        // Now the calculatedNodes reflect the coordinates that we'd have
    3532        // without preserving the angles, i.e. preserving the length.
     
    4845        recalculateNodesAndValidate(lineKeepLength, nodeArr[0]);
    4946        recalculateNodesAndValidate(lineKeepLength, nodeArr[1]);
    50 
    51     }
    52 
    53 
    54     void recalculateNodesAndValidate(AlignWaysGeomLine alignedLineKeepLength, Node endpoint) {
     47    }
     48
     49    private void recalculateNodesAndValidate(AlignWaysGeomLine alignedLineKeepLength, Node endpoint) {
    5550
    5651        if (endpoint.getEastNorth().equals(pivot)) {
     
    6055       
    6156        ArrayList<WaySegment> alws = algnSeg.getAdjacentWaySegments(endpoint);
    62         if (alws.size() <= 2) {
     57        int alwsSize = alws.size();
     58        if (0 < alwsSize && alwsSize <= 2) {
    6359            // We need the intersection point of
    6460            //  - the alignee following the keep length rule
     
    7066            EastNorth enAdjOther2 = null;
    7167
    72             if (alws.size() == 2) {
     68            if (alwsSize == 2) {
    7369                adjOther2 = getNonEqualNode(alws.get(1), endpoint);
    7470                enAdjOther2 = adjOther2.getEastNorth();
     
    106102            // triggers complications.
    107103            // TODO - find a solution
    108             if (alws.size() == 2 && enIsectPt != null) {
     104            if (alwsSize == 2 && enIsectPt != null) {
    109105                int middlePtIdx = AlignWaysGeomPoint.getMiddleOf3(
    110106                        new AlignWaysGeomPoint(enIsectPt),
     
    155151            alignableStatKeepAngles = AlignableStatus.ALGN_INV_TOOMANY_CONNECTED_WS;
    156152        }
    157 
    158     }
    159 
     153    }
    160154
    161155    private boolean isEnSetCollinear(ArrayList<EastNorth> enAdjPts) {
     
    169163        return AlignWaysGeomPoint.isSetCollinear(awAdjPts);
    170164    }
    171 
    172165
    173166    private Node getNonEqualNode(WaySegment waySegment, Node endpoint) {
     
    179172            return null;
    180173    }
    181 
    182174
    183175    /**
     
    222214                JOptionPane.WARNING_MESSAGE
    223215                );
    224 
    225     }
    226 
     216    }
    227217
    228218    /**
Note: See TracChangeset for help on using the changeset viewer.