Пример #1
0
/*private*/
void
ScaledNoder::scale(SegmentString::NonConstVect& segStrings) const
{
	Scaler scaler(*this);
	for (SegmentString::NonConstVect::const_iterator
		i0=segStrings.begin(), i0End=segStrings.end();
			i0!=i0End; ++i0)
	{
		SegmentString* ss=*i0;

		CoordinateSequence* cs=ss->getCoordinates();

#ifndef NDEBUG
		size_t npts = cs->size();
#endif
		cs->apply_rw(&scaler);
		assert(cs->size() == npts);

		// Actually, we should be creating *new*
		// SegmentStrings here, but who's going
		// to delete them then ? And is it worth
		// the memory cost ?
		cs->removeRepeatedPoints();

	}
}
Пример #2
0
/*public*/
void
SimpleSnapRounder::computeVertexSnaps(const SegmentString::NonConstVect& edges)
{
	for (SegmentString::NonConstVect::const_iterator
			i0=edges.begin(), i0End=edges.end();
			i0!=i0End; ++i0)
	{
		NodedSegmentString* edge0 = dynamic_cast<NodedSegmentString*>(*i0);
		assert(edge0);
		for (SegmentString::NonConstVect::const_iterator
				i1=edges.begin(), i1End=edges.end();
				i1!=i1End; ++i1)
		{
			NodedSegmentString* edge1 = dynamic_cast<NodedSegmentString*>(*i1);
			assert(edge1);
			computeVertexSnaps(edge0, edge1);
		}
	}
}
Пример #3
0
/*public*/
void
MCIndexSnapRounder::computeVertexSnaps(SegmentString::NonConstVect& edges)
{
	SegmentString::NonConstVect::iterator i=edges.begin(), e=edges.end();
	for (; i!=e; ++i)
	{
		NodedSegmentString* edge0 =
			dynamic_cast<NodedSegmentString*>(*i);
		assert(edge0);
		computeVertexSnaps(edge0);
	}
}
Пример #4
0
/*private*/
void
SimpleSnapRounder::computeSnaps(const SegmentString::NonConstVect& segStrings,
		vector<Coordinate>& snapPts)
{
	for (SegmentString::NonConstVect::const_iterator
			i=segStrings.begin(), iEnd=segStrings.end();
			i!=iEnd; ++i)
	{
		NodedSegmentString* ss = dynamic_cast<NodedSegmentString*>(*i);

		computeSnaps(ss, snapPts);
	}
}
Пример #5
0
/*private*/
void
SimpleSnapRounder::checkCorrectness(
		SegmentString::NonConstVect& inputSegmentStrings)
{
  SegmentString::NonConstVect resultSegStrings;
  NodedSegmentString::getNodedSubstrings(
    inputSegmentStrings.begin(), inputSegmentStrings.end(), &resultSegStrings
  );

  NodingValidator nv(resultSegStrings);

  try {
    nv.checkValid();
  }

  catch (const std::exception &ex) {

    for ( SegmentString::NonConstVect::iterator i=resultSegStrings.begin(),
                                                e=resultSegStrings.end();
          i!=e; ++i )
    {
      delete *i;
    }

    std::cerr << ex.what() << std::endl;
    throw;
  }

  for ( SegmentString::NonConstVect::iterator i=resultSegStrings.begin(),
                                              e=resultSegStrings.end();
        i!=e; ++i )
  {
    delete *i;
  }
 
}
Пример #6
0
/* public static */
void
NodedSegmentString::getNodedSubstrings(
	const SegmentString::NonConstVect& segStrings,
	SegmentString::NonConstVect *resultEdgeList)
{
	assert(resultEdgeList);
	for ( SegmentString::NonConstVect::const_iterator
		i=segStrings.begin(), iEnd=segStrings.end();
		i != iEnd; ++i )
	{
		NodedSegmentString* ss = dynamic_cast<NodedSegmentString*>(*i);
		assert(ss);
		ss->getNodeList().addSplitEdges(resultEdgeList);
	}
}
Пример #7
0
/*private*/
void
ScaledNoder::rescale(SegmentString::NonConstVect& segStrings) const
{
	ReScaler rescaler(*this);
	for (SegmentString::NonConstVect::const_iterator
		i0=segStrings.begin(), i0End=segStrings.end();
			i0!=i0End; ++i0)
	{

		SegmentString* ss=*i0;

		ss->getCoordinates()->apply_rw(&rescaler);

	}
}
/* private */
void
BufferBuilder::computeNodedEdges(SegmentString::NonConstVect& bufferSegStrList,
		const PrecisionModel *precisionModel) // throw(GEOSException)
{
	Noder* noder = getNoder( precisionModel );

	noder->computeNodes(&bufferSegStrList);

	SegmentString::NonConstVect* nodedSegStrings = \
			noder->getNodedSubstrings();


	for (SegmentString::NonConstVect::iterator
		i=nodedSegStrings->begin(), e=nodedSegStrings->end();
		i!=e;
		++i)
	{
		SegmentString* segStr = *i;
		const Label* oldLabel = static_cast<const Label*>(segStr->getData());

		CoordinateSequence* cs = CoordinateSequence::removeRepeatedPoints(segStr->getCoordinates());
		if ( cs->size() < 2 ) 
		{
			delete cs; // we need to take care of the memory here as cs is a new sequence
			return; // don't insert collapsed edges
		}
		// we need to clone SegmentString coordinates
		// as Edge will take ownership of them
		// TODO: find a way to transfer ownership instead
		// Who will own the edge ? FIXME: find out and handle that!
		Edge* edge = new Edge(cs, new Label(*oldLabel));

		// will take care of the Edge ownership
		insertUniqueEdge(edge);
	}

	if ( nodedSegStrings != &bufferSegStrList )
	{
		delete nodedSegStrings;
	}

	if ( noder != workingNoder ) delete noder;
}
Пример #9
0
/* private */
void
NodingValidator::checkEndPtVertexIntersections(const Coordinate& testPt,
		const SegmentString::NonConstVect& segStrings) const
{
	for (SegmentString::NonConstVect::const_iterator
		it = segStrings.begin(), itEnd = segStrings.end();
		it != itEnd;
		++it)
	{
		const SegmentString* ss0 = *it;
		const CoordinateSequence& pts = *(ss0->getCoordinates());
		for (unsigned int j=1, n=pts.size()-1; j<n; ++j)
		{
			if (pts[j].equals(testPt))
			{
				stringstream s;
				s<<"found endpt/interior pt intersection ";
				s<<"at index "<<j<<" :pt "<<testPt;
				throw util::TopologyException(s.str());
			}
		}
	}
}
Пример #10
0
/*public*/
void
MCIndexSnapRounder::computeVertexSnaps(SegmentString::NonConstVect& edges)
{
	for_each(edges.begin(), edges.end(), bind1st(mem_fun(&MCIndexSnapRounder::computeEdgeVertexSnaps), this));
}