21 #ifndef GEOS_GEOM_LINESEGMENT_H
22 #define GEOS_GEOM_LINESEGMENT_H
24 #include <geos/export.h>
25 #include <geos/geom/Coordinate.h>
27 #include <geos/inline.h>
37 class CoordinateSequence;
38 class GeometryFactory;
75 LineSegment(
double x0,
double y0,
double x1,
double y1);
84 const Coordinate& operator[](std::size_t i)
const;
128 int orientationIndex(
const LineSegment* seg)
const;
220 double offsetDistance,
326 std::array<Coordinate, 2> closestPoints(
const LineSegment* line);
370 size_t h = std::hash<double>{}(s.p0.
x);
371 h ^= (std::hash<double>{}(s.p0.
y) << 1);
372 h ^= (std::hash<double>{}(s.
p1.
x) << 1);
373 return h ^ (std::hash<double>{}(s.
p1.
y) << 1);
378 std::ostream&
operator<< (std::ostream& o,
const LineSegment& l);
388 # include "geos/geom/LineSegment.inl"
391 #endif // ndef GEOS_GEOM_LINESEGMENT_H
void closestPoint(const Coordinate &p, Coordinate &ret) const
Computes the closest point on this line segment to another point.
int orientationIndex(const LineSegment &seg) const
Coordinate p1
Segment start.
Definition: LineSegment.h:66
void reverse()
Reverses the direction of the line segment.
void project(const Coordinate &p, Coordinate &ret) const
Compute the projection of a point onto the line determined by this line segment.
Coordinate intersection(const LineSegment &line) const
std::ostream & operator<<(std::ostream &os, const Coordinate &c)
Output function.
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
void pointAlongOffset(double segmentLengthFraction, double offsetDistance, Coordinate &ret) const
Computes the Coordinate that lies a given fraction along the line defined by this segment and offset ...
double segmentFraction(const Coordinate &inputPt) const
Computes the fraction of distance (in [0.0, 1.0]) that the projection of a point occurs along this li...
LineSegment()
Segment end.
int compareTo(const LineSegment &other) const
Compares this object with the specified object for order.
bool operator==(const Coordinate &a, const Coordinate &b)
Equality operator for Coordinate. 2D only.
Coordinate lineIntersection(const LineSegment &line) const
Computes the intersection point of the lines defined by two segments, if there is one.
int orientationIndex(const Coordinate &p) const
Determines the orientation index of a Coordinate relative to this segment.
double y
y-coordinate
Definition: Coordinate.h:107
double distance(const Coordinate &p) const
Computes the distance between this line segment and a point.
bool equalsTopo(const LineSegment &other) const
Returns true if other is topologically equal to this LineSegment (e.g. irrespective of orientation).
void midPoint(Coordinate &ret) const
Computes the midpoint of the segment.
void normalize()
Puts the line segment into a normalized form.
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:84
std::unique_ptr< LineString > toGeometry(const GeometryFactory &gf) const
double x
x-coordinate
Definition: Coordinate.h:104
std::array< Coordinate, 2 > closestPoints(const LineSegment &line)
void pointAlong(double segmentLengthFraction, Coordinate &ret) const
Computes the Coordinate that lies a given fraction along the line defined by this segment.
LineSegment(const Coordinate &c0, const Coordinate &c1)
Constructs a LineSegment with the given start and end Coordinates.
Definition: LineSegment.h:59
double distancePerpendicular(const Coordinate &p) const
Computes the perpendicular distance between the (infinite) line defined by this line segment and a po...
bool isHorizontal() const
Tests whether the segment is horizontal.
double getLength() const
Computes the length of the line segment.
double distance(const LineSegment &ls) const
Computes the distance between this line segment and another one.
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
bool project(const LineSegment &seg, LineSegment &ret) const
Project a line segment onto this line segment and return the resulting line segment.
double projectionFactor(const Coordinate &p) const
Compute the projection factor for the projection of the point p onto this LineSegment.
bool isVertical() const
Tests whether the segment is vertical.