00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GEOS_GEOM_LINESEGMENT_H
00023 #define GEOS_GEOM_LINESEGMENT_H
00024
00025 #include <geos/export.h>
00026 #include <geos/geom/Coordinate.h>
00027
00028 #include <geos/inline.h>
00029
00030 #include <iostream>
00031 #include <memory>
00032
00033
00034 namespace geos {
00035 namespace geom {
00036 class CoordinateSequence;
00037 class GeometryFactory;
00038 class LineString;
00039 }
00040 }
00041
00042 namespace geos {
00043 namespace geom {
00044
00058 class GEOS_DLL LineSegment {
00059 public:
00060
00061 friend std::ostream& operator<< (std::ostream& o, const LineSegment& l);
00062
00063 Coordinate p0;
00064
00065 Coordinate p1;
00066
00067 LineSegment();
00068
00069 LineSegment(const LineSegment &ls);
00070
00072 LineSegment(const Coordinate& c0, const Coordinate& c1);
00073
00074 LineSegment(double x0, double y0, double x1, double y1);
00075
00076 virtual ~LineSegment();
00077
00078 void setCoordinates(const Coordinate& c0, const Coordinate& c1);
00079
00080
00081
00082
00083 const Coordinate& operator[](std::size_t i) const;
00084 Coordinate& operator[](std::size_t i);
00085
00086 void setCoordinates(const LineSegment& ls);
00087
00089 double getLength() const;
00090
00092
00095 bool isHorizontal() const;
00096
00098
00101 bool isVertical() const;
00102
00124 int orientationIndex(const LineSegment& seg) const;
00125
00126
00127 int orientationIndex(const LineSegment* seg) const;
00128
00145 int orientationIndex(const Coordinate& p) const;
00146
00148 void reverse();
00149
00151
00155 void normalize();
00156
00158 double angle() const;
00159
00161
00164 void midPoint(Coordinate& ret) const;
00165
00167 double distance(const LineSegment& ls) const;
00168
00170 double distance(const Coordinate& p) const;
00171
00176 double distancePerpendicular(const Coordinate& p) const;
00177
00192 void pointAlong(double segmentLengthFraction, Coordinate& ret) const;
00193
00218 void pointAlongOffset(double segmentLengthFraction,
00219 double offsetDistance,
00220 Coordinate& ret) const;
00221
00239 double projectionFactor(const Coordinate& p) const;
00240
00256 double segmentFraction(const Coordinate& inputPt) const;
00257
00266 void project(const Coordinate& p, Coordinate& ret) const;
00267
00283 bool project(const LineSegment& seg, LineSegment& ret) const;
00284
00286
00291 void closestPoint(const Coordinate& p, Coordinate& ret) const;
00292
00304 int compareTo(const LineSegment& other) const;
00305
00315 bool equalsTopo(const LineSegment& other) const;
00316
00324 CoordinateSequence* closestPoints(const LineSegment& line);
00325
00326 CoordinateSequence* closestPoints(const LineSegment* line);
00327
00341 bool intersection(const LineSegment& line, Coordinate& coord) const;
00342
00360 bool lineIntersection(const LineSegment& line, Coordinate& coord) const;
00361
00368 std::auto_ptr<LineString> toGeometry(const GeometryFactory& gf) const;
00369
00370 };
00371
00372 std::ostream& operator<< (std::ostream& o, const LineSegment& l);
00373
00375 bool operator==(const LineSegment& a, const LineSegment& b);
00376
00377
00378 }
00379 }
00380
00381 #ifdef GEOS_INLINE
00382 # include "geos/geom/LineSegment.inl"
00383 #endif
00384
00385 #endif // ndef GEOS_GEOM_LINESEGMENT_H
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414