Ignore:
Timestamp:
2013-12-31T14:35:34+01:00 (10 years ago)
Author:
simon04
Message:

see #6536 - Refactor crossing way test in order to decrease memory footprint

Drop data structure ExtendedSegment and obtain needed values on demand
from the way tags.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/WaySegment.java

    r6380 r6580  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm;
     3
     4import java.awt.geom.Line2D;
    35
    46/**
     
    6365        return equals(o) ? 0 : toWay().compareTo(o.toWay());
    6466    }
     67
     68    /**
     69     * Checks whether this segment crosses other segment
     70     *
     71     * @param s2 The other segment
     72     * @return true if both segments crosses
     73     */
     74    public boolean intersects(WaySegment s2) {
     75        if (getFirstNode().equals(s2.getFirstNode()) || getSecondNode().equals(s2.getSecondNode()) ||
     76                getFirstNode().equals(s2.getSecondNode()) || getSecondNode().equals(s2.getFirstNode()))
     77            return false;
     78
     79        return Line2D.linesIntersect(
     80                getFirstNode().getEastNorth().east(), getFirstNode().getEastNorth().north(),
     81                getSecondNode().getEastNorth().east(), getSecondNode().getEastNorth().north(),
     82                s2.getFirstNode().getEastNorth().east(), s2.getFirstNode().getEastNorth().north(),
     83                s2.getSecondNode().getEastNorth().east(), s2.getSecondNode().getEastNorth().north());
     84    }
    6585}
Note: See TracChangeset for help on using the changeset viewer.