Java 类com.vividsolutions.jts.geomgraph.index.SegmentIntersector 实例源码

项目:Earth    文件:ConsistentAreaTester.java   
/**
 * Check all nodes to see if their labels are consistent with area topology.
 *
 * @return <code>true</code> if this area has a consistent node labelling
 */
public boolean isNodeConsistentArea() {
    /**
     * To fully check validity, it is necessary to
     * compute ALL intersections, including self-intersections within a single edge.
     */
    SegmentIntersector intersector = this.geomGraph.computeSelfNodes(this.li, true);
    if (intersector.hasProperIntersection()) {
        this.invalidPoint = intersector.getProperIntersectionPoint();
        return false;
    }

    this.nodeGraph.build(this.geomGraph);

    return this.isNodeEdgeAreaLabelsConsistent();
}
项目:Earth    文件:IsSimpleOp.java   
private boolean isSimpleLinearGeometry(Geometry geom) {
    if (geom.isEmpty()) {
        return true;
    }
    GeometryGraph graph = new GeometryGraph(0, geom);
    LineIntersector li = new RobustLineIntersector();
    SegmentIntersector si = graph.computeSelfNodes(li, true);
    // if no self-intersection, must be simple
    if (!si.hasIntersection()) {
        return true;
    }
    if (si.hasProperIntersection()) {
        this.nonSimpleLocation = si.getProperIntersectionPoint();
        return false;
    }
    if (this.hasNonEndpointIntersection(graph)) {
        return false;
    }
    if (this.isClosedEndpointsInInterior) {
        if (this.hasClosedEndpointIntersection(graph)) {
            return false;
        }
    }
    return true;
}
项目:Earth    文件:GeometryGraph.java   
/**
     * Compute self-nodes, taking advantage of the Geometry type to
     * minimize the number of intersection tests.  (E.g. rings are
     * not tested for self-intersection, since they are assumed to be valid).
     *
     * @param li the LineIntersector to use
     * @param computeRingSelfNodes if <false>, intersection checks are optimized to not test rings for self-intersection
     * @return the SegmentIntersector used, containing information about the intersections found
     */
    public SegmentIntersector computeSelfNodes(LineIntersector li, boolean computeRingSelfNodes) {
        SegmentIntersector si = new SegmentIntersector(li, true, false);
        EdgeSetIntersector esi = this.createEdgeSetIntersector();
        // optimized test for Polygons and Rings
        if (!computeRingSelfNodes
                && (this.parentGeom instanceof LinearRing
                || this.parentGeom instanceof Polygon
                || this.parentGeom instanceof MultiPolygon)) {
            esi.computeIntersections(this.edges, si, false);
        } else {
            esi.computeIntersections(this.edges, si, true);
        }
//System.out.println("SegmentIntersector # tests = " + si.numTests);
        this.addSelfIntersectionNodes(this.argIndex);
        return si;
    }
项目:Earth    文件:GeometryGraph.java   
public SegmentIntersector computeEdgeIntersections(
            GeometryGraph g,
            LineIntersector li,
            boolean includeProper) {
        SegmentIntersector si = new SegmentIntersector(li, includeProper, true);
        si.setBoundaryNodes(this.getBoundaryNodes(), g.getBoundaryNodes());

        EdgeSetIntersector esi = this.createEdgeSetIntersector();
        esi.computeIntersections(this.edges, g.edges, si);
/*
for (Iterator i = g.edges.iterator(); i.hasNext();) {
Edge e = (Edge) i.next();
Debug.print(e.getEdgeIntersectionList());
}
*/
        return si;
    }
项目:jts    文件:ConsistentAreaTester.java   
/**
 * Check all nodes to see if their labels are consistent with area topology.
 *
 * @return <code>true</code> if this area has a consistent node labelling
 */
public boolean isNodeConsistentArea() {
    /**
     * To fully check validity, it is necessary to
     * compute ALL intersections, including self-intersections within a single edge.
     */
    SegmentIntersector intersector = geomGraph.computeSelfNodes(li, true);
    if (intersector.hasProperIntersection()) {
        invalidPoint = intersector.getProperIntersectionPoint();
        return false;
    }

    nodeGraph.build(geomGraph);

    return isNodeEdgeAreaLabelsConsistent();
}
项目:jts    文件:IsSimpleOp.java   
private boolean isSimpleLinearGeometry(Geometry geom) {
    if (geom.isEmpty()) return true;
    GeometryGraph graph = new GeometryGraph(0, geom);
    LineIntersector li = new RobustLineIntersector();
    SegmentIntersector si = graph.computeSelfNodes(li, true);
    // if no self-intersection, must be simple
    if (!si.hasIntersection()) return true;
    if (si.hasProperIntersection()) {
        nonSimpleLocation = si.getProperIntersectionPoint();
        return false;
    }
    if (hasNonEndpointIntersection(graph)) return false;
    if (isClosedEndpointsInInterior) {
        if (hasClosedEndpointIntersection(graph)) return false;
    }
    return true;
}
项目:jts    文件:GeometryGraph.java   
/**
     * Compute self-nodes, taking advantage of the Geometry type to
     * minimize the number of intersection tests.  (E.g. rings are
     * not tested for self-intersection, since they are assumed to be valid).
     *
     * @param li                   the LineIntersector to use
     * @param computeRingSelfNodes if <false>, intersection checks are optimized to not test rings for self-intersection
     * @return the SegmentIntersector used, containing information about the intersections found
     */
    public SegmentIntersector computeSelfNodes(LineIntersector li, boolean computeRingSelfNodes) {
        SegmentIntersector si = new SegmentIntersector(li, true, false);
        EdgeSetIntersector esi = createEdgeSetIntersector();
        // optimized test for Polygons and Rings
        if (!computeRingSelfNodes
                && (parentGeom instanceof LinearRing
                || parentGeom instanceof Polygon
                || parentGeom instanceof MultiPolygon)) {
            esi.computeIntersections(edges, si, false);
        } else {
            esi.computeIntersections(edges, si, true);
        }
//System.out.println("SegmentIntersector # tests = " + si.numTests);
        addSelfIntersectionNodes(argIndex);
        return si;
    }
项目:jts    文件:GeometryGraph.java   
public SegmentIntersector computeEdgeIntersections(
            GeometryGraph g,
            LineIntersector li,
            boolean includeProper) {
        SegmentIntersector si = new SegmentIntersector(li, includeProper, true);
        si.setBoundaryNodes(this.getBoundaryNodes(), g.getBoundaryNodes());

        EdgeSetIntersector esi = createEdgeSetIntersector();
        esi.computeIntersections(edges, g.edges, si);
/*
for (Iterator i = g.edges.iterator(); i.hasNext();) {
Edge e = (Edge) i.next();
Debug.print(e.getEdgeIntersectionList());
}
*/
        return si;
    }
项目:geodroid_master_update    文件:ConsistentAreaTester.java   
/**
 * Check all nodes to see if their labels are consistent with area topology.
 *
 * @return <code>true</code> if this area has a consistent node labelling
 */
public boolean isNodeConsistentArea()
{
  /**
   * To fully check validity, it is necessary to
   * compute ALL intersections, including self-intersections within a single edge.
   */
  SegmentIntersector intersector = geomGraph.computeSelfNodes(li, true);
  if (intersector.hasProperIntersection()) {
    invalidPoint = intersector.getProperIntersectionPoint();
    return false;
  }

  nodeGraph.build(geomGraph);

  return isNodeEdgeAreaLabelsConsistent();
}
项目:geodroid_master_update    文件:IsSimpleOp.java   
private boolean isSimpleLinearGeometry(Geometry geom)
{
  if (geom.isEmpty()) return true;
  GeometryGraph graph = new GeometryGraph(0, geom);
  LineIntersector li = new RobustLineIntersector();
  SegmentIntersector si = graph.computeSelfNodes(li, true);
  // if no self-intersection, must be simple
  if (! si.hasIntersection()) return true;
  if (si.hasProperIntersection()) {
    nonSimpleLocation = si.getProperIntersectionPoint();
    return false;
  }
  if (hasNonEndpointIntersection(graph)) return false;
  if (isClosedEndpointsInInterior) {
    if (hasClosedEndpointIntersection(graph)) return false;
  }
  return true;
}
项目:terraingis    文件:ConsistentAreaTester.java   
/**
 * Check all nodes to see if their labels are consistent with area topology.
 *
 * @return <code>true</code> if this area has a consistent node labelling
 */
public boolean isNodeConsistentArea()
{
  /**
   * To fully check validity, it is necessary to
   * compute ALL intersections, including self-intersections within a single edge.
   */
  SegmentIntersector intersector = geomGraph.computeSelfNodes(li, true);
  if (intersector.hasProperIntersection()) {
    invalidPoint = intersector.getProperIntersectionPoint();
    return false;
  }

  nodeGraph.build(geomGraph);

  return isNodeEdgeAreaLabelsConsistent();
}
项目:terraingis    文件:IsSimpleOp.java   
private boolean isSimpleLinearGeometry(Geometry geom)
{
  if (geom.isEmpty()) return true;
  GeometryGraph graph = new GeometryGraph(0, geom);
  LineIntersector li = new RobustLineIntersector();
  SegmentIntersector si = graph.computeSelfNodes(li, true);
  // if no self-intersection, must be simple
  if (! si.hasIntersection()) return true;
  if (si.hasProperIntersection()) {
    nonSimpleLocation = si.getProperIntersectionPoint();
    return false;
  }
  if (hasNonEndpointIntersection(graph)) return false;
  if (isClosedEndpointsInInterior) {
    if (hasClosedEndpointIntersection(graph)) return false;
  }
  return true;
}
项目:Earth    文件:EdgeSetNoder.java   
public List getNodedEdges() {
        EdgeSetIntersector esi = new SimpleMCSweepLineIntersector();
        SegmentIntersector si = new SegmentIntersector(this.li, true, false);
        esi.computeIntersections(this.inputEdges, si, true);
//Debug.println("has proper int = " + si.hasProperIntersection());

        List splitEdges = new ArrayList();
        for (Object inputEdge : inputEdges) {
            Edge e = (Edge) inputEdge;
            e.getEdgeIntersectionList().addSplitEdges(splitEdges);
        }
        return splitEdges;
    }
项目:OSMemory    文件:ExtendedRelation.java   
LineString fullClosedLine(List<LineString> lines) {
    List<Coordinate> tail = new ArrayList<>();

    boolean found;
    do {
        found = false;
        for (int i = 0; i < lines.size(); i++) {
            if (addToClosed(tail, lines.get(i))) {
                lines.remove(i);
                i--;
                found = true;
            }
        }
    } while (found);

    LineString s = GeometryHelper.createLine(tail);
    if (!s.isClosed()) {
        throw new RuntimeException("Non-closed line starts from " + tail.get(0) + " ends to "
                + tail.get(tail.size() - 1));
    }
    if (!s.isSimple()) {
        GeometryGraph graph = new GeometryGraph(0, s);
        LineIntersector li = new RobustLineIntersector();
        SegmentIntersector si = graph.computeSelfNodes(li, true);
        if (si.hasProperInteriorIntersection()) {
            throw new RuntimeException("Self-intersection for " + relation.getObjectCode()
                    + " near point " + si.getProperIntersectionPoint());
        }else {
            throw new RuntimeException("Self-intersected line: " + s);
        }
    }
    return s;
}
项目:jts    文件:EdgeSetNoder.java   
public List getNodedEdges() {
        EdgeSetIntersector esi = new SimpleMCSweepLineIntersector();
        SegmentIntersector si = new SegmentIntersector(li, true, false);
        esi.computeIntersections(inputEdges, si, true);
//Debug.println("has proper int = " + si.hasProperIntersection());

        List splitEdges = new ArrayList();
        for (Iterator i = inputEdges.iterator(); i.hasNext(); ) {
            Edge e = (Edge) i.next();
            e.getEdgeIntersectionList().addSplitEdges(splitEdges);
        }
        return splitEdges;
    }
项目:Earth    文件:RelateComputer.java   
public IntersectionMatrix computeIM() {
        IntersectionMatrix im = new IntersectionMatrix();
        // since Geometries are finite and embedded in a 2-D space, the EE element must always be 2
        im.set(Location.EXTERIOR, Location.EXTERIOR, 2);

        // if the Geometries don't overlap there is nothing to do
        if (!this.arg[0].getGeometry().getEnvelopeInternal().intersects(
                this.arg[1].getGeometry().getEnvelopeInternal())) {
            this.computeDisjointIM(im);
            return im;
        }
        this.arg[0].computeSelfNodes(this.li, false);
        this.arg[1].computeSelfNodes(this.li, false);

        // compute intersections between edges of the two input geometries
        SegmentIntersector intersector = this.arg[0].computeEdgeIntersections(this.arg[1], this.li, false);
//System.out.println("computeIM: # segment intersection tests: " + intersector.numTests);
        this.computeIntersectionNodes(0);
        this.computeIntersectionNodes(1);
        /**
         * Copy the labelling for the nodes in the parent Geometries.  These override
         * any labels determined by intersections between the geometries.
         */
        this.copyNodesAndLabels(0);
        this.copyNodesAndLabels(1);

        // complete the labelling for any nodes which only have a label for a single geometry
//Debug.addWatch(nodes.find(new Coordinate(110, 200)));
//Debug.printWatch();
        this.labelIsolatedNodes();
//Debug.printWatch();

        // If a proper intersection was found, we can set a lower bound on the IM.
        this.computeProperIntersectionIM(intersector, im);

        /**
         * Now process improper intersections
         * (eg where one or other of the geometries has a vertex at the intersection point)
         * We need to compute the edge graph at all nodes to determine the IM.
         */

        // build EdgeEnds for all intersections
        EdgeEndBuilder eeBuilder = new EdgeEndBuilder();
        List ee0 = eeBuilder.computeEdgeEnds(this.arg[0].getEdgeIterator());
        this.insertEdgeEnds(ee0);
        List ee1 = eeBuilder.computeEdgeEnds(this.arg[1].getEdgeIterator());
        this.insertEdgeEnds(ee1);

//Debug.println("==== NodeList ===");
//Debug.print(nodes);

        this.labelNodeEdges();

        /**
         * Compute the labeling for isolated components
         * <br>
         * Isolated components are components that do not touch any other components in the graph.
         * They can be identified by the fact that they will
         * contain labels containing ONLY a single element, the one for their parent geometry.
         * We only need to check components contained in the input graphs, since
         * isolated components will not have been replaced by new components formed by intersections.
         */
//debugPrintln("Graph A isolated edges - ");
        this.labelIsolatedEdges(0, 1);
//debugPrintln("Graph B isolated edges - ");
        this.labelIsolatedEdges(1, 0);

        // update the IM from all components
        this.updateIM(im);
        return im;
    }
项目:Earth    文件:RelateComputer.java   
private void computeProperIntersectionIM(SegmentIntersector intersector, IntersectionMatrix im) {
    // If a proper intersection is found, we can set a lower bound on the IM.
    int dimA = this.arg[0].getGeometry().getDimension();
    int dimB = this.arg[1].getGeometry().getDimension();
    boolean hasProper = intersector.hasProperIntersection();
    boolean hasProperInterior = intersector.hasProperInteriorIntersection();

    // For Geometry's of dim 0 there can never be proper intersections.

    /**
     * If edge segments of Areas properly intersect, the areas must properly overlap.
     */
    if (dimA == 2 && dimB == 2) {
        if (hasProper) {
            im.setAtLeast("212101212");
        }
    }
    /**
     * If an Line segment properly intersects an edge segment of an Area,
     * it follows that the Interior of the Line intersects the Boundary of the Area.
     * If the intersection is a proper <i>interior</i> intersection, then
     * there is an Interior-Interior intersection too.
     * Note that it does not follow that the Interior of the Line intersects the Exterior
     * of the Area, since there may be another Area component which contains the rest of the Line.
     */
    else if (dimA == 2 && dimB == 1) {
        if (hasProper) {
            im.setAtLeast("FFF0FFFF2");
        }
        if (hasProperInterior) {
            im.setAtLeast("1FFFFF1FF");
        }
    } else if (dimA == 1 && dimB == 2) {
        if (hasProper) {
            im.setAtLeast("F0FFFFFF2");
        }
        if (hasProperInterior) {
            im.setAtLeast("1F1FFFFFF");
        }
    }
/* If edges of LineStrings properly intersect *in an interior point*, all
    we can deduce is that
    the interiors intersect.  (We can NOT deduce that the exteriors intersect,
    since some other segments in the geometries might cover the points in the
    neighbourhood of the intersection.)
    It is important that the point be known to be an interior point of
    both Geometries, since it is possible in a self-intersecting geometry to
    have a proper intersection on one segment that is also a boundary point of another segment.
*/
    else if (dimA == 1 && dimB == 1) {
        if (hasProperInterior) {
            im.setAtLeast("0FFFFFFFF");
        }
    }
}
项目:jts    文件:RelateComputer.java   
public IntersectionMatrix computeIM() {
        IntersectionMatrix im = new IntersectionMatrix();
        // since Geometries are finite and embedded in a 2-D space, the EE element must always be 2
        im.set(Location.EXTERIOR, Location.EXTERIOR, 2);

        // if the Geometries don't overlap there is nothing to do
        if (!arg[0].getGeometry().getEnvelopeInternal().intersects(
                arg[1].getGeometry().getEnvelopeInternal())) {
            computeDisjointIM(im);
            return im;
        }
        arg[0].computeSelfNodes(li, false);
        arg[1].computeSelfNodes(li, false);

        // compute intersections between edges of the two input geometries
        SegmentIntersector intersector = arg[0].computeEdgeIntersections(arg[1], li, false);
//System.out.println("computeIM: # segment intersection tests: " + intersector.numTests);
        computeIntersectionNodes(0);
        computeIntersectionNodes(1);
        /**
         * Copy the labelling for the nodes in the parent Geometries.  These override
         * any labels determined by intersections between the geometries.
         */
        copyNodesAndLabels(0);
        copyNodesAndLabels(1);

        // complete the labelling for any nodes which only have a label for a single geometry
//Debug.addWatch(nodes.find(new Coordinate(110, 200)));
//Debug.printWatch();
        labelIsolatedNodes();
//Debug.printWatch();

        // If a proper intersection was found, we can set a lower bound on the IM.
        computeProperIntersectionIM(intersector, im);

        /**
         * Now process improper intersections
         * (eg where one or other of the geometries has a vertex at the intersection point)
         * We need to compute the edge graph at all nodes to determine the IM.
         */

        // build EdgeEnds for all intersections
        EdgeEndBuilder eeBuilder = new EdgeEndBuilder();
        List ee0 = eeBuilder.computeEdgeEnds(arg[0].getEdgeIterator());
        insertEdgeEnds(ee0);
        List ee1 = eeBuilder.computeEdgeEnds(arg[1].getEdgeIterator());
        insertEdgeEnds(ee1);

//Debug.println("==== NodeList ===");
//Debug.print(nodes);

        labelNodeEdges();

        /**
         * Compute the labeling for isolated components
         * <br>
         * Isolated components are components that do not touch any other components in the graph.
         * They can be identified by the fact that they will
         * contain labels containing ONLY a single element, the one for their parent geometry.
         * We only need to check components contained in the input graphs, since
         * isolated components will not have been replaced by new components formed by intersections.
         */
//debugPrintln("Graph A isolated edges - ");
        labelIsolatedEdges(0, 1);
//debugPrintln("Graph B isolated edges - ");
        labelIsolatedEdges(1, 0);

        // update the IM from all components
        updateIM(im);
        return im;
    }
项目:jts    文件:RelateComputer.java   
private void computeProperIntersectionIM(SegmentIntersector intersector, IntersectionMatrix im) {
    // If a proper intersection is found, we can set a lower bound on the IM.
    int dimA = arg[0].getGeometry().getDimension();
    int dimB = arg[1].getGeometry().getDimension();
    boolean hasProper = intersector.hasProperIntersection();
    boolean hasProperInterior = intersector.hasProperInteriorIntersection();

    // For Geometry's of dim 0 there can never be proper intersections.

    /**
     * If edge segments of Areas properly intersect, the areas must properly overlap.
     */
    if (dimA == 2 && dimB == 2) {
        if (hasProper) im.setAtLeast("212101212");
    }
    /**
     * If an Line segment properly intersects an edge segment of an Area,
     * it follows that the Interior of the Line intersects the Boundary of the Area.
     * If the intersection is a proper <i>interior</i> intersection, then
     * there is an Interior-Interior intersection too.
     * Note that it does not follow that the Interior of the Line intersects the Exterior
     * of the Area, since there may be another Area component which contains the rest of the Line.
     */
    else if (dimA == 2 && dimB == 1) {
        if (hasProper) im.setAtLeast("FFF0FFFF2");
        if (hasProperInterior) im.setAtLeast("1FFFFF1FF");
    } else if (dimA == 1 && dimB == 2) {
        if (hasProper) im.setAtLeast("F0FFFFFF2");
        if (hasProperInterior) im.setAtLeast("1F1FFFFFF");
    }
/* If edges of LineStrings properly intersect *in an interior point*, all
    we can deduce is that
    the interiors intersect.  (We can NOT deduce that the exteriors intersect,
    since some other segments in the geometries might cover the points in the
    neighbourhood of the intersection.)
    It is important that the point be known to be an interior point of
    both Geometries, since it is possible in a self-intersecting geometry to
    have a proper intersection on one segment that is also a boundary point of another segment.
*/
    else if (dimA == 1 && dimB == 1) {
        if (hasProperInterior) im.setAtLeast("0FFFFFFFF");
    }
}
项目:geodroid_master_update    文件:RelateComputer.java   
public IntersectionMatrix computeIM()
  {
    IntersectionMatrix im = new IntersectionMatrix();
    // since Geometries are finite and embedded in a 2-D space, the EE element must always be 2
    im.set(Location.EXTERIOR, Location.EXTERIOR, 2);

    // if the Geometries don't overlap there is nothing to do
    if (! arg[0].getGeometry().getEnvelopeInternal().intersects(
            arg[1].getGeometry().getEnvelopeInternal()) ) {
      computeDisjointIM(im);
      return im;
    }
    arg[0].computeSelfNodes(li, false);
    arg[1].computeSelfNodes(li, false);

    // compute intersections between edges of the two input geometries
    SegmentIntersector intersector = arg[0].computeEdgeIntersections(arg[1], li, false);
//System.out.println("computeIM: # segment intersection tests: " + intersector.numTests);
    computeIntersectionNodes(0);
    computeIntersectionNodes(1);
    /**
     * Copy the labelling for the nodes in the parent Geometries.  These override
     * any labels determined by intersections between the geometries.
     */
    copyNodesAndLabels(0);
    copyNodesAndLabels(1);

    // complete the labelling for any nodes which only have a label for a single geometry
//Debug.addWatch(nodes.find(new Coordinate(110, 200)));
//Debug.printWatch();
    labelIsolatedNodes();
//Debug.printWatch();

    // If a proper intersection was found, we can set a lower bound on the IM.
    computeProperIntersectionIM(intersector, im);

    /**
     * Now process improper intersections
     * (eg where one or other of the geometries has a vertex at the intersection point)
     * We need to compute the edge graph at all nodes to determine the IM.
     */

    // build EdgeEnds for all intersections
    EdgeEndBuilder eeBuilder = new EdgeEndBuilder();
    List ee0 = eeBuilder.computeEdgeEnds(arg[0].getEdgeIterator());
    insertEdgeEnds(ee0);
    List ee1 = eeBuilder.computeEdgeEnds(arg[1].getEdgeIterator());
    insertEdgeEnds(ee1);

//Debug.println("==== NodeList ===");
//Debug.print(nodes);

    labelNodeEdges();

  /**
   * Compute the labeling for isolated components
   * <br>
   * Isolated components are components that do not touch any other components in the graph.
   * They can be identified by the fact that they will
   * contain labels containing ONLY a single element, the one for their parent geometry.
   * We only need to check components contained in the input graphs, since
   * isolated components will not have been replaced by new components formed by intersections.
   */
//debugPrintln("Graph A isolated edges - ");
    labelIsolatedEdges(0, 1);
//debugPrintln("Graph B isolated edges - ");
    labelIsolatedEdges(1, 0);

    // update the IM from all components
    updateIM(im);
    return im;
  }
项目:geodroid_master_update    文件:RelateComputer.java   
private void computeProperIntersectionIM(SegmentIntersector intersector, IntersectionMatrix im)
{
  // If a proper intersection is found, we can set a lower bound on the IM.
  int dimA = arg[0].getGeometry().getDimension();
  int dimB = arg[1].getGeometry().getDimension();
  boolean hasProper         = intersector.hasProperIntersection();
  boolean hasProperInterior = intersector.hasProperInteriorIntersection();

    // For Geometry's of dim 0 there can never be proper intersections.

    /**
     * If edge segments of Areas properly intersect, the areas must properly overlap.
     */
  if (dimA == 2 && dimB == 2) {
    if (hasProper) im.setAtLeast("212101212");
  }
    /**
     * If an Line segment properly intersects an edge segment of an Area,
     * it follows that the Interior of the Line intersects the Boundary of the Area.
     * If the intersection is a proper <i>interior</i> intersection, then
     * there is an Interior-Interior intersection too.
     * Note that it does not follow that the Interior of the Line intersects the Exterior
     * of the Area, since there may be another Area component which contains the rest of the Line.
     */
  else if (dimA == 2 && dimB == 1) {
    if (hasProper)          im.setAtLeast("FFF0FFFF2");
    if (hasProperInterior)  im.setAtLeast("1FFFFF1FF");
  }
  else if (dimA == 1 && dimB == 2) {
    if (hasProper)          im.setAtLeast("F0FFFFFF2");
    if (hasProperInterior)  im.setAtLeast("1F1FFFFFF");
  }
  /* If edges of LineStrings properly intersect *in an interior point*, all
      we can deduce is that
      the interiors intersect.  (We can NOT deduce that the exteriors intersect,
      since some other segments in the geometries might cover the points in the
      neighbourhood of the intersection.)
      It is important that the point be known to be an interior point of
      both Geometries, since it is possible in a self-intersecting geometry to
      have a proper intersection on one segment that is also a boundary point of another segment.
  */
  else if (dimA == 1 && dimB == 1) {
    if (hasProperInterior)    im.setAtLeast("0FFFFFFFF");
  }
}
项目:terraingis    文件:RelateComputer.java   
public IntersectionMatrix computeIM()
  {
    IntersectionMatrix im = new IntersectionMatrix();
    // since Geometries are finite and embedded in a 2-D space, the EE element must always be 2
    im.set(Location.EXTERIOR, Location.EXTERIOR, 2);

    // if the Geometries don't overlap there is nothing to do
    if (! arg[0].getGeometry().getEnvelopeInternal().intersects(
            arg[1].getGeometry().getEnvelopeInternal()) ) {
      computeDisjointIM(im);
      return im;
    }
    arg[0].computeSelfNodes(li, false);
    arg[1].computeSelfNodes(li, false);

    // compute intersections between edges of the two input geometries
    SegmentIntersector intersector = arg[0].computeEdgeIntersections(arg[1], li, false);
//System.out.println("computeIM: # segment intersection tests: " + intersector.numTests);
    computeIntersectionNodes(0);
    computeIntersectionNodes(1);
    /**
     * Copy the labelling for the nodes in the parent Geometries.  These override
     * any labels determined by intersections between the geometries.
     */
    copyNodesAndLabels(0);
    copyNodesAndLabels(1);

    // complete the labelling for any nodes which only have a label for a single geometry
//Debug.addWatch(nodes.find(new Coordinate(110, 200)));
//Debug.printWatch();
    labelIsolatedNodes();
//Debug.printWatch();

    // If a proper intersection was found, we can set a lower bound on the IM.
    computeProperIntersectionIM(intersector, im);

    /**
     * Now process improper intersections
     * (eg where one or other of the geometries has a vertex at the intersection point)
     * We need to compute the edge graph at all nodes to determine the IM.
     */

    // build EdgeEnds for all intersections
    EdgeEndBuilder eeBuilder = new EdgeEndBuilder();
    List ee0 = eeBuilder.computeEdgeEnds(arg[0].getEdgeIterator());
    insertEdgeEnds(ee0);
    List ee1 = eeBuilder.computeEdgeEnds(arg[1].getEdgeIterator());
    insertEdgeEnds(ee1);

//Debug.println("==== NodeList ===");
//Debug.print(nodes);

    labelNodeEdges();

  /**
   * Compute the labeling for isolated components
   * <br>
   * Isolated components are components that do not touch any other components in the graph.
   * They can be identified by the fact that they will
   * contain labels containing ONLY a single element, the one for their parent geometry.
   * We only need to check components contained in the input graphs, since
   * isolated components will not have been replaced by new components formed by intersections.
   */
//debugPrintln("Graph A isolated edges - ");
    labelIsolatedEdges(0, 1);
//debugPrintln("Graph B isolated edges - ");
    labelIsolatedEdges(1, 0);

    // update the IM from all components
    updateIM(im);
    return im;
  }
项目:terraingis    文件:RelateComputer.java   
private void computeProperIntersectionIM(SegmentIntersector intersector, IntersectionMatrix im)
{
  // If a proper intersection is found, we can set a lower bound on the IM.
  int dimA = arg[0].getGeometry().getDimension();
  int dimB = arg[1].getGeometry().getDimension();
  boolean hasProper         = intersector.hasProperIntersection();
  boolean hasProperInterior = intersector.hasProperInteriorIntersection();

    // For Geometry's of dim 0 there can never be proper intersections.

    /**
     * If edge segments of Areas properly intersect, the areas must properly overlap.
     */
  if (dimA == 2 && dimB == 2) {
    if (hasProper) im.setAtLeast("212101212");
  }
    /**
     * If an Line segment properly intersects an edge segment of an Area,
     * it follows that the Interior of the Line intersects the Boundary of the Area.
     * If the intersection is a proper <i>interior</i> intersection, then
     * there is an Interior-Interior intersection too.
     * Note that it does not follow that the Interior of the Line intersects the Exterior
     * of the Area, since there may be another Area component which contains the rest of the Line.
     */
  else if (dimA == 2 && dimB == 1) {
    if (hasProper)          im.setAtLeast("FFF0FFFF2");
    if (hasProperInterior)  im.setAtLeast("1FFFFF1FF");
  }
  else if (dimA == 1 && dimB == 2) {
    if (hasProper)          im.setAtLeast("F0FFFFFF2");
    if (hasProperInterior)  im.setAtLeast("1F1FFFFFF");
  }
  /* If edges of LineStrings properly intersect *in an interior point*, all
      we can deduce is that
      the interiors intersect.  (We can NOT deduce that the exteriors intersect,
      since some other segments in the geometries might cover the points in the
      neighbourhood of the intersection.)
      It is important that the point be known to be an interior point of
      both Geometries, since it is possible in a self-intersecting geometry to
      have a proper intersection on one segment that is also a boundary point of another segment.
  */
  else if (dimA == 1 && dimB == 1) {
    if (hasProperInterior)    im.setAtLeast("0FFFFFFFF");
  }
}