00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GEOS_LINEARREF_LINEARLOCATION_H
00022 #define GEOS_LINEARREF_LINEARLOCATION_H
00023
00024 #include <string>
00025 #include <memory>
00026
00027 #include <geos/geom/Coordinate.h>
00028 #include <geos/geom/Geometry.h>
00029 #include <geos/geom/LineSegment.h>
00030
00031 namespace geos {
00032 namespace linearref {
00033
00034
00043 class LinearLocation
00044 {
00045 private:
00046 unsigned int componentIndex;
00047 unsigned int segmentIndex;
00048 double segmentFraction;
00049
00057 void normalize();
00058
00059 public:
00065 static LinearLocation getEndLocation(const geom::Geometry* linear);
00066
00082 static geom::Coordinate pointAlongSegmentByFraction(const geom::Coordinate& p0, const geom::Coordinate& p1, double frac);
00083
00084
00088 LinearLocation(unsigned int segmentIndex = 0, double segmentFraction = 0.0);
00089
00090 LinearLocation(unsigned int componentIndex, unsigned int segmentIndex, double segmentFraction);
00091
00097 void clamp(const geom::Geometry* linear);
00098
00107 void snapToVertex(const geom::Geometry* linearGeom, double minDistance);
00108
00116 double getSegmentLength(const geom::Geometry* linearGeom) const;
00117
00124 void setToEnd(const geom::Geometry* linear);
00125
00131 unsigned int getComponentIndex() const;
00132
00138 unsigned int getSegmentIndex() const;
00139
00145 double getSegmentFraction() const;
00146
00152 bool isVertex() const;
00153
00162 geom::Coordinate getCoordinate(const geom::Geometry* linearGeom) const;
00163
00171 std::auto_ptr<geom::LineSegment> getSegment(const geom::Geometry* linearGeom) const;
00172
00180 bool isValid(const geom::Geometry* linearGeom) const;
00181
00190 int compareTo(const LinearLocation& other) const;
00191
00201 int compareLocationValues(unsigned int componentIndex1, unsigned int segmentIndex1, double segmentFraction1) const;
00202
00216 static int compareLocationValues(
00217 unsigned int componentIndex0, unsigned int segmentIndex0, double segmentFraction0,
00218 unsigned int componentIndex1, unsigned int segmentIndex1, double segmentFraction1);
00219
00227 bool isOnSameSegment(const LinearLocation& loc) const;
00228
00229
00230 friend std::ostream& operator<< (std::ostream& out, const LinearLocation& obj );
00231
00232 };
00233
00234
00235 }
00236 }
00237
00238 #endif