コード例 #1
0
bool
SegmentIntersectionTester::hasIntersectionWithEnvelopeFilter(
	const LineString &line, const LineString &testLine)
{
  typedef std::size_t size_type;

	const CoordinateSequence &seq0 = *(line.getCoordinatesRO());
  size_type seq0size = seq0.getSize();

  const CoordinateSequence &seq1 = *(testLine.getCoordinatesRO());
  size_type seq1size = seq1.getSize();

  const Envelope* lineEnv = line.getEnvelopeInternal();

  typedef std::size_t size_type;

  for (size_type i = 1; i<seq1size && !hasIntersectionVar; ++i)
	{
    seq1.getAt(i-1, pt10);
    seq1.getAt(i, pt11);

    // skip test if segment does not intersect query envelope
    if (! lineEnv->intersects(Envelope(pt10, pt11))) continue;

    for (size_type j = 1; j < seq0size && !hasIntersectionVar; ++j)
		{
      seq0.getAt(j - 1, pt00);
      seq0.getAt(j, pt01);

			li.computeIntersection(pt00, pt01, pt10, pt11);
			if (li.hasIntersection()) hasIntersectionVar = true;
		}
	}

	return hasIntersectionVar;
}