Ignore:
Timestamp:
2012-01-25T15:46:41+01:00 (13 years ago)
Author:
tilusnet
Message:

Angle preserving alignment: when the alignee's endpoint is joint to two other segments which form a straight(ened) line, alignment is only allowed when the intersection point doesn't fall outside the adjacent nodes.

Location:
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways
Files:
2 edited

Legend:

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

    r27606 r27619  
    9595            // there's no need to update this node
    9696            if (isectPnt != null) {
    97                 enIsectPt = new EastNorth(isectPnt.getX(), isectPnt.getY());           
    98                 calculatedNodes.put(endpoint, enIsectPt);
     97                enIsectPt = new EastNorth(isectPnt.getX(), isectPnt.getY());
     98                // Don't "record" it yet as it may not be valid
    9999            } else if (alignedLineKeepLength.getIntersectionStatus() == IntersectionStatus.LINES_PARALLEL) {
    100100                alignableStatKeepAngles = AlignableStatus.ALGN_INV_ANGLE_PRESERVING_CONFLICT;
    101             }
    102            
    103             // TODO - THIS APPROACH IS FAULTY!
    104             //
     101                return;
     102            }
     103           
    105104            // For the case of two adjacent segments with collinear points, the new endpoint may 
    106             // not fall between enAdjOther1 and enAdjOther2; in this case one of them is redundant
    107             // and should be deleted from OSM
     105            // not fall between enAdjOther1 and enAdjOther2;
     106            // this scenario is not allowed for the time being as placing the new intersection point on the line
     107            // triggers complications.
     108            // TODO - find a solution
    108109            if (alws.size() == 2 && enIsectPt != null) {
    109110                int middlePtIdx = AlignWaysGeomPoint.getMiddleOf3(
     
    127128                                double eps = 1E-6;
    128129                                if (!middlePt.equalsEpsilon(enIsectPt, eps)) {
    129                                         // Intersection point didn't fall between the two adjacent points; something must go
     130                                        // Intersection point didn't fall between the two adjacent points; not allowed
     131                                alignableStatKeepAngles = AlignableStatus.ALGN_INV_XPOINT_FALLSOUT;
     132                                return;
     133                                       
     134                                /*
    130135                                        if (middlePt.equalsEpsilon(enAdjOther1, eps)) {
    131136                                                // Delete adjOther1
     
    135140                                                // Delete adjOther2
    136141                                                // adjOther2.setDeleted(true);
     142                                         */
    137143                                }
    138144                        }
    139145                }
    140146            }
     147           
     148            if (isectPnt != null) {
     149                // Angle preserving alignment passed all verification tests: record it.
     150                calculatedNodes.put(endpoint, enIsectPt);
     151            }
     152           
    141153           
    142154        } else {
     
    196208                    + "Either choose the ''keep length'' aligning method or select other segments.\n");
    197209            break;
     210        case ALGN_INV_XPOINT_FALLSOUT:
     211            statMsg = tr("An intersection point would fall outside its adjacent nodes.\n"
     212                    + "This is an unsupported scenario.\n");
     213            break;
    198214        default:
    199215            statMsg = tr("Undocumented problem occured.\n");
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysCmdKeepLength.java

    r27353 r27619  
    3838        ALGN_INV_OUTSIDE_WORLD,
    3939        ALGN_INV_TOOMANY_CONNECTED_WS,      // for AlignWaysCmdKeepAngles
    40         ALGN_INV_ANGLE_PRESERVING_CONFLICT  // for AlignWaysCmdKeepAngles
     40        ALGN_INV_ANGLE_PRESERVING_CONFLICT, // for AlignWaysCmdKeepAngles
     41        ALGN_INV_XPOINT_FALLSOUT            // for AlignWaysCmdKeepAngles
    4142    }
    4243    final AlignWaysAlgnSegment algnSeg;
Note: See TracChangeset for help on using the changeset viewer.