GEOS 3.3.8

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

LinearLocation.h
1 /**********************************************************************
2 * $Id: LinearLocation.h 2809 2009-12-06 01:05:24Z mloskot $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2005-2006 Refractions Research Inc.
8 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 *
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
14 *
15 **********************************************************************
16 *
17 * Last port: linearref/LinearLocation.java rev. 1.10
18 *
19 **********************************************************************/
20
21 #ifndef GEOS_LINEARREF_LINEARLOCATION_H
22 #define GEOS_LINEARREF_LINEARLOCATION_H
23
24 #include <string>
25 #include <memory> // for std::auto_ptr
26
27 #include <geos/geom/Coordinate.h>
28 #include <geos/geom/Geometry.h>
29 #include <geos/geom/LineSegment.h>
30
31 namespace geos {
32 namespace linearref { // geos::linearref
33
34
43 class LinearLocation
44 {
45 private:
46 unsigned int componentIndex;
47 unsigned int segmentIndex;
48 double segmentFraction;
49
57 void normalize();
58
59 public:
65 static LinearLocation getEndLocation(const geom::Geometry* linear);
66
82 static geom::Coordinate pointAlongSegmentByFraction(const geom::Coordinate& p0, const geom::Coordinate& p1, double frac);
83
84
88 LinearLocation(unsigned int segmentIndex = 0, double segmentFraction = 0.0);
89
90 LinearLocation(unsigned int componentIndex, unsigned int segmentIndex, double segmentFraction);
91
97 void clamp(const geom::Geometry* linear);
98
107 void snapToVertex(const geom::Geometry* linearGeom, double minDistance);
108
116 double getSegmentLength(const geom::Geometry* linearGeom) const;
117
124 void setToEnd(const geom::Geometry* linear);
125
131 unsigned int getComponentIndex() const;
132
138 unsigned int getSegmentIndex() const;
139
145 double getSegmentFraction() const;
146
152 bool isVertex() const;
153
162 geom::Coordinate getCoordinate(const geom::Geometry* linearGeom) const;
163
171 std::auto_ptr<geom::LineSegment> getSegment(const geom::Geometry* linearGeom) const;
172
180 bool isValid(const geom::Geometry* linearGeom) const;
181
190 int compareTo(const LinearLocation& other) const;
191
201 int compareLocationValues(unsigned int componentIndex1, unsigned int segmentIndex1, double segmentFraction1) const;
202
216 static int compareLocationValues(
217 unsigned int componentIndex0, unsigned int segmentIndex0, double segmentFraction0,
218 unsigned int componentIndex1, unsigned int segmentIndex1, double segmentFraction1);
219
227 bool isOnSameSegment(const LinearLocation& loc) const;
228
229
230 friend std::ostream& operator<< (std::ostream& out, const LinearLocation& obj );
231
232 };
233
234
235 } // namespace geos.linearref
236 } // namespace geos
237
238 #endif