コード例 #1
0
  /**
   * Tests whether this geometry intersects a given geometry.
   *
   * @param geom the test geometry
   * @return true if the test geometry intersects
   */
  public boolean intersects(Geometry geom) {
    /** If any segments intersect, obviously intersects = true */
    List lineSegStr = SegmentStringUtil.extractSegmentStrings(geom);
    boolean segsIntersect = prepLine.getIntersectionFinder().intersects(lineSegStr);
    // MD - performance testing
    //		boolean segsIntersect = false;
    if (segsIntersect) return true;

    /** For L/L case we are done */
    if (geom.getDimension() == 1) return false;

    /** For L/A case, need to check for proper inclusion of the target in the test */
    if (geom.getDimension() == 2 && prepLine.isAnyTargetComponentInTest(geom)) return true;

    /** For L/P case, need to check if any points lie on line(s) */
    if (geom.getDimension() == 0) return isAnyTestPointInTarget(geom);

    //		return prepLine.getGeometry().intersects(geom);
    return false;
  }
コード例 #2
0
 /**
  * Tests whether any representative point of the test Geometry intersects the target geometry.
  * Only handles test geometries which are Puntal (dimension 0)
  *
  * @param geom a Puntal geometry to test
  * @return true if any point of the argument intersects the prepared geometry
  */
 protected boolean isAnyTestPointInTarget(Geometry testGeom) {
   /**
    * This could be optimized by using the segment index on the lineal target. However, it seems
    * like the L/P case would be pretty rare in practice.
    */
   PointLocator locator = new PointLocator();
   List coords = ComponentCoordinateExtracter.getCoordinates(testGeom);
   for (Iterator i = coords.iterator(); i.hasNext(); ) {
     Coordinate p = (Coordinate) i.next();
     if (locator.intersects(p, prepLine.getGeometry())) return true;
   }
   return false;
 }