Example #1
0
/*public*/
EdgeRing*
EdgeRing::findEdgeRingContaining(EdgeRing* testEr,
                                 vector<EdgeRing*>* shellList)
{
    const LinearRing* testRing = testEr->getRingInternal();
    if(! testRing) {
        return nullptr;
    }
    const Envelope* testEnv = testRing->getEnvelopeInternal();
    Coordinate testPt = testRing->getCoordinateN(0);
    EdgeRing* minShell = nullptr;
    const Envelope* minEnv = nullptr;

    typedef std::vector<EdgeRing*> ERList;
    for(ERList::size_type i = 0, e = shellList->size(); i < e; ++i) {
        EdgeRing* tryShell = (*shellList)[i];
        LinearRing* tryRing = tryShell->getRingInternal();
        const Envelope* tryEnv = tryRing->getEnvelopeInternal();
        if(minShell != nullptr) {
            minEnv = minShell->getRingInternal()->getEnvelopeInternal();
        }
        bool isContained = false;

        // the hole envelope cannot equal the shell envelope

        if(tryEnv->equals(testEnv)) {
            continue;
        }

        const CoordinateSequence* tryCoords =
            tryRing->getCoordinatesRO();

        if(tryEnv->contains(testEnv)) {

            // TODO: don't copy testPt !
            testPt = ptNotInList(testRing->getCoordinatesRO(), tryCoords);

            if(PointLocation::isInRing(testPt, tryCoords)) {
                isContained = true;
            }

        }

        // check if this new containing ring is smaller
        // than the current minimum ring
        if(isContained) {
            if(minShell == nullptr || minEnv->contains(tryEnv)) {
                minShell = tryShell;
            }
        }
    }
    return minShell;
}
Example #2
0
/*public*/
EdgeRing *
EdgeRing::findEdgeRingContaining(EdgeRing *testEr,
	vector<EdgeRing*> *shellList)
{
	const LinearRing *testRing=testEr->getRingInternal();
	if ( ! testRing ) return NULL;
	const Envelope *testEnv=testRing->getEnvelopeInternal();
	Coordinate testPt=testRing->getCoordinateN(0);
	EdgeRing *minShell=NULL;
	const Envelope *minEnv=NULL;

	typedef std::vector<EdgeRing*> ERList;
	for(ERList::size_type i=0, e=shellList->size(); i<e; ++i) {
		EdgeRing *tryShell=(*shellList)[i];
		LinearRing *tryRing=tryShell->getRingInternal();
		const Envelope *tryEnv=tryRing->getEnvelopeInternal();
		if (minShell!=NULL) minEnv=minShell->getRingInternal()->getEnvelopeInternal();
		bool isContained=false;

		// the hole envelope cannot equal the shell envelope

		if (tryEnv->equals(testEnv)) continue;

		const CoordinateSequence *tryCoords =
			tryRing->getCoordinatesRO();

		testPt=ptNotInList(testRing->getCoordinatesRO(),
			tryCoords);

		if (tryEnv->contains(testEnv)
			&& CGAlgorithms::isPointInRing(testPt, tryCoords))
				isContained=true;
		// check if this new containing ring is smaller
		// than the current minimum ring
		if (isContained) {
			if (minShell==NULL || minEnv->contains(tryEnv)) {
				minShell=tryShell;
			}
		}
	}
	return minShell;
}