예제 #1
0
/*private*/
void
MCIndexNoder::intersectChains()
{
	assert(segInt);

	SegmentOverlapAction overlapAction(*segInt);

	for (vector<MonotoneChain*>::iterator
			i=monoChains.begin(), iEnd=monoChains.end();
			i != iEnd;
			++i)
	{

		GEOS_CHECK_FOR_INTERRUPTS();

		MonotoneChain* queryChain = *i;
		assert(queryChain);
		vector<void*> overlapChains;
		index.query(&(queryChain->getEnvelope()), overlapChains);
		for (vector<void*>::iterator
			j=overlapChains.begin(), jEnd=overlapChains.end();
			j != jEnd;
			++j)
		{
			MonotoneChain* testChain = static_cast<MonotoneChain*>(*j);
			assert(testChain);

			/**
			 * following test makes sure we only compare each
			 * pair of chains once and that we don't compare a
			 * chain to itself
			 */
			if (testChain->getId() > queryChain->getId()) {
				queryChain->computeOverlaps(testChain,
						&overlapAction);
				nOverlaps++;
			}

			// short-circuit if possible
			if (segInt->isDone()) return;

		}
	}
}
예제 #2
0
void
MCQuadtreeNoder::intersectChains()
{
#if PROFILE
	static Profile *queryprof = Profiler::instance()->get("MCQuadtreeNoder::intersectChains query");
	static Profile *overlprof = Profiler::instance()->get("MCQuadtreeNoder::intersectChains computeOverlap");
#endif
	//MonotoneChainOverlapAction *overlapAction = new SegmentOverlapAction(segInt);
	SegmentOverlapAction overlapAction(segInt);

	for (int i=0; i<(int)chains->size();i++) {
		indexMonotoneChain *queryChain=(*chains)[i];
#if PROFILE
		queryprof->start();
#endif
		vector<void*> *overlapChains = index->query(queryChain->getEnvelope());
#if PROFILE
		queryprof->stop();
#endif
		for (int j=0; j<(int)overlapChains->size();j++) {
			indexMonotoneChain *testChain=(indexMonotoneChain*)(*overlapChains)[j];
			/**
			 * following test makes sure we only compare each
			 * pair of chains once
			 * and that we don't compare a chain to itself
			 */
			if (testChain->getId()>queryChain->getId()) {
#if PROFILE
	overlprof->start();
#endif
				queryChain->computeOverlaps(testChain, &overlapAction);
#if PROFILE
	overlprof->stop();
#endif
				nOverlaps++;
			}
		}
		delete overlapChains;
	}

	//delete overlapAction;
}
/*private*/
void
MCIndexSegmentSetMutualIntersector::intersectChains()
{
    MCIndexSegmentSetMutualIntersector::SegmentOverlapAction overlapAction(*segInt);

    for(const auto& queryChain : monoChains) {
        std::vector<void*> overlapChains;
        index->query(&(queryChain->getEnvelope()), overlapChains);

        for(std::size_t j = 0, nj = overlapChains.size(); j < nj; j++) {
            MonotoneChain* testChain = (MonotoneChain*)(overlapChains[j]);

            queryChain->computeOverlaps(testChain, &overlapAction);
            nOverlaps++;
            if(segInt->isDone()) {
                return;
            }
        }
    }
}