Exemple #1
0
void
RelateNodeGraph::build(GeometryGraph *geomGraph)
{
	// compute nodes for intersections between previously noded edges
	computeIntersectionNodes(geomGraph,0);

	/**
	 * Copy the labelling for the nodes in the parent Geometry.  These override
	 * any labels determined by intersections.
	 */
	copyNodesAndLabels(geomGraph,0);

	/**
	 * Build EdgeEnds for all intersections.
	 */
	EdgeEndBuilder *eeBuilder=new EdgeEndBuilder();
	vector<EdgeEnd*> *eeList=eeBuilder->computeEdgeEnds(geomGraph->getEdges());
	insertEdgeEnds(eeList);
	delete eeBuilder;
	delete eeList;
	//Debug.println("==== NodeList ===");
	//Debug.print(nodes);
}
Exemple #2
0
IntersectionMatrix*
RelateComputer::computeIM()
{
	// 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
	const Envelope *e1=(*arg)[0]->getGeometry()->getEnvelopeInternal();
	const Envelope *e2=(*arg)[1]->getGeometry()->getEnvelopeInternal();
	if (!e1->intersects(e2)) {
		computeDisjointIM(im.get());
		return im.release();
	}

	std::auto_ptr<SegmentIntersector> si1 (
		(*arg)[0]->computeSelfNodes(&li,false)
	);
	std::auto_ptr<SegmentIntersector> si2 (
		(*arg)[1]->computeSelfNodes(&li,false)
	);

	// compute intersections between edges of the two input geometries
	std::auto_ptr< SegmentIntersector> intersector (
    (*arg)[0]->computeEdgeIntersections((*arg)[1], &li,false)
  );
	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.get(), im.get());

	/*
	 * Now process improper intersections
	 * (eg where one or other of the geometrys 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;
	std::auto_ptr< std::vector<EdgeEnd*> > ee0 (
		eeBuilder.computeEdgeEnds((*arg)[0]->getEdges())
  );
	insertEdgeEnds(ee0.get());
	std::auto_ptr< std::vector<EdgeEnd*> > ee1 (
		eeBuilder.computeEdgeEnds((*arg)[1]->getEdges())
  );
	insertEdgeEnds(ee1.get());
	//Debug.println("==== NodeList ===");
	//Debug.print(nodes);
	labelNodeEdges();

	/**
	 * Compute the labeling for isolated components.
	 * 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.get());
	return im.release();
}