22#include <geos/export.h>
23#include <geos/algorithm/Intersection.h>
24#include <geos/geom/Coordinate.h>
25#include <geos/geom/Envelope.h>
84 precisionModel(initialPrecisionModel),
101 if(isInteriorIntersection(0)) {
104 if(isInteriorIntersection(1)) {
119 for(std::size_t i = 0; i < result; ++i) {
120 if(!(intPt[i].equals2D(*inputLines[inputLineIndex][0])
121 || intPt[i].equals2D(*inputLines[inputLineIndex][1]))) {
137 precisionModel = newPM;
156 POINT_INTERSECTION = 1,
159 COLLINEAR_INTERSECTION = 2
166 std::string toString()
const;
176 return result != NO_INTERSECTION;
190 return inputLines[segmentIndex][ptIndex];
213 return intPt[intIndex];
234 for(std::size_t i = 0; i < result; ++i) {
235 if(intPt[i].equals2D(pt)) {
259 return hasIntersection() && isProperVar;
318 std::size_t intLineIndex[2][2];
327 return result == COLLINEAR_INTERSECTION;
336 return hasIntersection() && !isProperVar;
339 void computeIntLineIndex();
341 void computeIntLineIndex(std::size_t segmentIndex);
374 return env0.contains(pt) && env1.contains(pt);
389 geom::Coordinate intersectionSafe(
const geom::Coordinate& p1,
const geom::Coordinate& p2,
390 const geom::Coordinate& q1,
const geom::Coordinate& q2)
const
392 geom::Coordinate ptInt = Intersection::intersection(p1, p2, q1, q2);
393 if (ptInt.isNull()) {
394 ptInt = nearestEndpoint(p1, p2, q1, q2);
418 static geom::Coordinate nearestEndpoint(
const geom::Coordinate& p1,
419 const geom::Coordinate& p2,
420 const geom::Coordinate& q1,
421 const geom::Coordinate& q2);
424 const geom::Coordinate& p,
425 const geom::Coordinate& q)
428 if ( std::isnan(z) ) {
434 static double zGetOrInterpolate(
435 const geom::Coordinate& p,
436 const geom::Coordinate& p1,
437 const geom::Coordinate& p2)
440 if (! std::isnan(z) )
return z;
441 return zInterpolate(p, p1, p2);
444 static geom::Coordinate zGetOrInterpolateCopy(
445 const geom::Coordinate& p,
446 const geom::Coordinate& p1,
447 const geom::Coordinate& p2)
449 geom::Coordinate pCopy = p;
450 double z = zGetOrInterpolate(p, p1, p2);
458 static double zInterpolate(
const geom::Coordinate& p,
459 const geom::Coordinate& p0,
460 const geom::Coordinate& p1);
462 static double zInterpolate(
const geom::Coordinate& p,
463 const geom::Coordinate& p1,
464 const geom::Coordinate& p2,
465 const geom::Coordinate& q1,
466 const geom::Coordinate& q2);
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:50
intersection_type
Definition: LineIntersector.h:151
void computeIntersection(const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &p3, const geom::Coordinate &p4)
Computes the intersection of the lines p1-p2 and p3-p4.
const geom::Coordinate * getEndpoint(std::size_t segmentIndex, std::size_t ptIndex) const
Definition: LineIntersector.h:188
static bool hasIntersection(const geom::Coordinate &p, const geom::Coordinate &p1, const geom::Coordinate &p2)
Same as above but doesn't compute intersection point. Faster.
bool isInteriorIntersection(std::size_t inputLineIndex)
Tests whether either intersection point is an interior point of the specified input segment.
Definition: LineIntersector.h:117
const geom::Coordinate & getIntersectionAlongSegment(std::size_t segmentIndex, std::size_t intIndex)
Computes the intIndex'th intersection point in the direction of a specified input line segment.
void setPrecisionModel(const geom::PrecisionModel *newPM)
Definition: LineIntersector.h:135
bool isInteriorIntersection()
Tests whether either intersection point is an interior point of one of the input segments.
Definition: LineIntersector.h:99
bool hasIntersection() const
Definition: LineIntersector.h:174
static bool isSameSignAndNonZero(double a, double b)
const geom::Coordinate & getIntersection(std::size_t intIndex) const
Definition: LineIntersector.h:211
void computeIntersection(const geom::Coordinate &p, const geom::Coordinate &p1, const geom::Coordinate &p2)
bool isProper() const
Tests whether an intersection is proper.
Definition: LineIntersector.h:257
static double computeEdgeDistance(const geom::Coordinate &p, const geom::Coordinate &p0, const geom::Coordinate &p1)
static double interpolateZ(const geom::Coordinate &p, const geom::Coordinate &p0, const geom::Coordinate &p1)
Return a Z value being the interpolation of Z from p0 and p1 at the given point p.
size_t getIntersectionNum() const
Definition: LineIntersector.h:198
double getEdgeDistance(std::size_t geomIndex, std::size_t intIndex) const
Computes the "edge distance" of an intersection point along the specified input line segment.
std::size_t getIndexAlongSegment(std::size_t segmentIndex, std::size_t intIndex)
Computes the index of the intIndex'th intersection point in the direction of a specified input line s...
bool isIntersection(const geom::Coordinate &pt) const
Test whether a point is a intersection point of two line segments.
Definition: LineIntersector.h:232
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:90
Basic namespace for all GEOS functionalities.
Definition: geos.h:39