00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GEOS_GEOM_LINESEGMENT_H
00022 #define GEOS_GEOM_LINESEGMENT_H
00023
00024 #include <geos/export.h>
00025 #include <geos/geom/Coordinate.h>
00026
00027 #include <geos/inline.h>
00028
00029 #include <iostream>
00030 #include <memory>
00031
00032
00033 namespace geos {
00034 namespace geom {
00035 class CoordinateSequence;
00036 class GeometryFactory;
00037 class LineString;
00038 }
00039 }
00040
00041 namespace geos {
00042 namespace geom {
00043
00057 class GEOS_DLL LineSegment {
00058 public:
00059
00060 friend std::ostream& operator<< (std::ostream& o, const LineSegment& l);
00061
00062 Coordinate p0;
00063
00064 Coordinate p1;
00065
00066 LineSegment();
00067
00068 LineSegment(const LineSegment &ls);
00069
00071 LineSegment(const Coordinate& c0, const Coordinate& c1);
00072
00073 LineSegment(double x0, double y0, double x1, double y1);
00074
00075 virtual ~LineSegment();
00076
00077 void setCoordinates(const Coordinate& c0, const Coordinate& c1);
00078
00079
00080
00081
00082 const Coordinate& operator[](size_t i) const;
00083 Coordinate& operator[](size_t i);
00084
00085 void setCoordinates(const LineSegment& ls);
00086
00088 double getLength() const;
00089
00091
00094 bool isHorizontal() const;
00095
00097
00100 bool isVertical() const;
00101
00123 int orientationIndex(const LineSegment& seg) const;
00124
00125
00126 int orientationIndex(const LineSegment* seg) const;
00127
00144 int orientationIndex(const Coordinate& p) const;
00145
00147 void reverse();
00148
00150
00154 void normalize();
00155
00157 double angle() const;
00158
00160
00163 void midPoint(Coordinate& ret) const;
00164
00166 double distance(const LineSegment& ls) const;
00167
00169 double distance(const Coordinate& p) const;
00170
00175 double distancePerpendicular(const Coordinate& p) const;
00176
00191 void pointAlong(double segmentLengthFraction, Coordinate& ret) const;
00192
00215 void pointAlongOffset(double segmentLengthFraction,
00216 double offsetDistance,
00217 Coordinate& ret) const;
00218
00236 double projectionFactor(const Coordinate& p) const;
00237
00253 double segmentFraction(const Coordinate& inputPt) const;
00254
00263 void project(const Coordinate& p, Coordinate& ret) const;
00264
00280 bool project(const LineSegment& seg, LineSegment& ret) const;
00281
00283
00288 void closestPoint(const Coordinate& p, Coordinate& ret) const;
00289
00301 int compareTo(const LineSegment& other) const;
00302
00312 bool equalsTopo(const LineSegment& other) const;
00313
00321 CoordinateSequence* closestPoints(const LineSegment& line);
00322
00323 CoordinateSequence* closestPoints(const LineSegment* line);
00324
00338 bool intersection(const LineSegment& line, Coordinate& coord) const;
00339
00357 bool lineIntersection(const LineSegment& line, Coordinate& coord) const;
00358
00365 std::auto_ptr<LineString> toGeometry(const GeometryFactory& gf) const;
00366
00367 };
00368
00369 std::ostream& operator<< (std::ostream& o, const LineSegment& l);
00370
00372 bool operator==(const LineSegment& a, const LineSegment& b);
00373
00374
00375 }
00376 }
00377
00378 #ifdef GEOS_INLINE
00379 # include "geos/geom/LineSegment.inl"
00380 #endif
00381
00382 #endif // ndef GEOS_GEOM_LINESEGMENT_H
00383
00384
00385
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