GEOS: LocationIndexedLine.h Source File

GEOS 3.5.0

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

- File List

LocationIndexedLine.h
1 /**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************
14 *
15 * Last port: linearref/LocationIndexedLine.java r466
16 *
17 **********************************************************************/
18
19 #ifndef GEOS_LINEARREF_LOCATIONINDEXEDLINE_H
20 #define GEOS_LINEARREF_LOCATIONINDEXEDLINE_H
21
22 #include <geos/export.h>
23 #include <geos/geom/Coordinate.h>
24 #include <geos/geom/Geometry.h>
25 #include <geos/geom/Lineal.h>
26 #include <geos/linearref/LinearLocation.h>
27 #include <geos/linearref/LocationIndexOfPoint.h>
28 #include <geos/linearref/LocationIndexOfLine.h>
29 #include <geos/util/IllegalArgumentException.h>
30
31 namespace geos {
32 namespace linearref { // geos::linearref
33
40 class GEOS_DLL LocationIndexedLine
41 {
42 private:
43 const geom::Geometry *linearGeom;
44
45 void checkGeometryType()
46 {
47 if ( ! dynamic_cast<const geom::Lineal*>(linearGeom) )
48 throw util::IllegalArgumentException("Input geometry must be linear");
49 }
50
51 public:
52
60 LocationIndexedLine(const geom::Geometry *linearGeom)
61 : linearGeom(linearGeom)
62 {
63 checkGeometryType();
64 }
65
79 geom::Coordinate extractPoint(const LinearLocation& index) const
80 {
81 return index.getCoordinate(linearGeom);
82 }
83
84
103 geom::Coordinate extractPoint(const LinearLocation& index,
104 double offsetDistance) const
105 {
106 geom::Coordinate ret;
107 index.getSegment(linearGeom)->pointAlongOffset(
108 index.getSegmentFraction(), offsetDistance, ret
109 );
110 return ret;
111 }
112
125 geom::Geometry *extractLine(const LinearLocation& startIndex,
126 const LinearLocation& endIndex) const
127 {
128 return ExtractLineByLocation::extract(linearGeom, startIndex, endIndex);
129 }
130
131
147 LinearLocation indexOf(const geom::Coordinate& pt) const
148 {
149 return LocationIndexOfPoint::indexOf(linearGeom, pt);
150 }
151
176 LinearLocation indexOfAfter(const geom::Coordinate& pt,
177 const LinearLocation& minIndex) const
178 {
179 return LocationIndexOfPoint::indexOfAfter(linearGeom, pt, &minIndex);
180 }
181
193 LinearLocation* indicesOf(const geom::Geometry *subLine) const
194 {
195 return LocationIndexOfLine::indicesOf(linearGeom, subLine);
196 }
197
198
210 LinearLocation project(const geom::Coordinate& pt) const
211 {
212 return LocationIndexOfPoint::indexOf(linearGeom, pt);
213 }
214
221 LinearLocation getStartIndex() const
222 {
223 return LinearLocation();
224 }
225
232 LinearLocation getEndIndex() const
233 {
234 return LinearLocation::getEndLocation(linearGeom);
235 }
236
244 bool isValidIndex(const LinearLocation& index) const
245 {
246 return index.isValid(linearGeom);
247 }
248
249
257 LinearLocation clampIndex(const LinearLocation& index) const
258 {
259 LinearLocation loc = index;
260 loc.clamp(linearGeom);
261 return loc;
262 }
263 };
264
265 } // geos::linearref
266 } // geos
267 #endif
geos::linearref::LocationIndexOfLine::indicesOf
static LinearLocation * indicesOf(const geom::Geometry *linearGeom, const geom::Geometry *subLine)
Determines the location of a subline along a linear Geometry.
geos::linearref::LocationIndexedLine::indexOf
LinearLocation indexOf(const geom::Coordinate &pt) const
Computes the index for a given point on the line.
Definition: LocationIndexedLine.h:147
geos::linearref::LocationIndexedLine::indexOfAfter
LinearLocation indexOfAfter(const geom::Coordinate &pt, const LinearLocation &minIndex) const
Finds the index for a point on the line which is greater than the given index.
Definition: LocationIndexedLine.h:176
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
geos::linearref::ExtractLineByLocation::extract
static geom::Geometry * extract(const geom::Geometry *line, const LinearLocation &start, const LinearLocation &end)
geos::linearref::LocationIndexedLine::getStartIndex
LinearLocation getStartIndex() const
Returns the index of the start of the line.
Definition: LocationIndexedLine.h:221
geos::linearref::LinearLocation::getSegmentFraction
double getSegmentFraction() const
geos::linearref::LinearLocation::getCoordinate
geom::Coordinate getCoordinate(const geom::Geometry *linearGeom) const
geos::linearref::LocationIndexedLine::indicesOf
LinearLocation * indicesOf(const geom::Geometry *subLine) const
Computes the indices for a subline of the line.
Definition: LocationIndexedLine.h:193
geos::linearref::LinearLocation::clamp
void clamp(const geom::Geometry *linear)
geos::linearref::LocationIndexedLine::LocationIndexedLine
LocationIndexedLine(const geom::Geometry *linearGeom)
Constructs an object which allows linear referencing along a given linear Geometry.
Definition: LocationIndexedLine.h:60
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
geos::util::IllegalArgumentException
Indicates one or more illegal arguments.
Definition: IllegalArgumentException.h:34
geos::linearref::LinearLocation
Represents a location along a LineString or MultiLineString.
Definition: LinearLocation.h:43
geos::linearref::LinearLocation::getSegment
std::auto_ptr< geom::LineSegment > getSegment(const geom::Geometry *linearGeom) const
geos::linearref::LocationIndexedLine::isValidIndex
bool isValidIndex(const LinearLocation &index) const
Tests whether an index is in the valid index range for the line.
Definition: LocationIndexedLine.h:244
geos::linearref::LocationIndexedLine::extractLine
geom::Geometry * extractLine(const LinearLocation &startIndex, const LinearLocation &endIndex) const
Computes the LineString for the interval on the line between the given indices.
Definition: LocationIndexedLine.h:125
geos::linearref::LocationIndexedLine::extractPoint
geom::Coordinate extractPoint(const LinearLocation &index, double offsetDistance) const
Computes the Coordinate for the point on the line at the given index, offset by the given distance...
Definition: LocationIndexedLine.h:103
geos::linearref::LocationIndexedLine::extractPoint
geom::Coordinate extractPoint(const LinearLocation &index) const
Computes the Coordinate for the point on the line at the given index.
Definition: LocationIndexedLine.h:79
geos::linearref::LocationIndexedLine::clampIndex
LinearLocation clampIndex(const LinearLocation &index) const
Computes a valid index for this line by clamping the given index to the valid range of index values...
Definition: LocationIndexedLine.h:257
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::linearref::LinearLocation::isValid
bool isValid(const geom::Geometry *linearGeom) const
geos::linearref::LinearLocation::getEndLocation
static LinearLocation getEndLocation(const geom::Geometry *linear)
geos::linearref::LocationIndexedLine::getEndIndex
LinearLocation getEndIndex() const
Returns the index of the end of the line.
Definition: LocationIndexedLine.h:232
geos::linearref::LocationIndexedLine::project
LinearLocation project(const geom::Coordinate &pt) const
Computes the index for the closest point on the line to the given point.
Definition: LocationIndexedLine.h:210
geos::linearref::LocationIndexedLine
Supports linear referencing along a linear Geometry using LinearLocations as the index.
Definition: LocationIndexedLine.h:40