GEOS  3.8.0dev
LinearLocation.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
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 r463
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_LINEARREF_LINEARLOCATION_H
22 #define GEOS_LINEARREF_LINEARLOCATION_H
23 
24 #include <string>
25 #include <memory> // for std::unique_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 
44 private:
45  size_t componentIndex;
46  size_t segmentIndex;
47  double segmentFraction;
48 
56  void normalize();
57 
58 public:
64  static LinearLocation getEndLocation(const geom::Geometry* linear);
65 
82  double frac);
83 
84 
88  LinearLocation(size_t segmentIndex = 0, double segmentFraction = 0.0);
89 
90  LinearLocation(size_t componentIndex, size_t 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  size_t getComponentIndex() const;
132 
138  size_t 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::unique_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(size_t componentIndex1, size_t segmentIndex1, double segmentFraction1) const;
202 
216  static int compareLocationValues(
217  size_t componentIndex0, size_t segmentIndex0, double segmentFraction0,
218  size_t componentIndex1, size_t segmentIndex1, double segmentFraction1);
219 
227  bool isOnSameSegment(const LinearLocation& loc) const;
228 
237  bool isEndpoint(const geom::Geometry& linearGeom) const;
238 
239  friend std::ostream& operator<< (std::ostream& out, const LinearLocation& obj);
240 
241 };
242 
243 
244 } // namespace geos.linearref
245 } // namespace geos
246 
247 #endif
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
double getSegmentFraction() const
geom::Coordinate getCoordinate(const geom::Geometry *linearGeom) const
void clamp(const geom::Geometry *linear)
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:187
double getSegmentLength(const geom::Geometry *linearGeom) const
int compareLocationValues(size_t componentIndex1, size_t segmentIndex1, double segmentFraction1) const
Represents a location along a LineString or MultiLineString.
Definition: LinearLocation.h:43
std::unique_ptr< geom::LineSegment > getSegment(const geom::Geometry *linearGeom) const
bool isOnSameSegment(const LinearLocation &loc) const
bool isEndpoint(const geom::Geometry &linearGeom) const
Tests whether this location is an endpoint of the linear component it refers to.
static geom::Coordinate pointAlongSegmentByFraction(const geom::Coordinate &p0, const geom::Coordinate &p1, double frac)
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
LinearLocation(size_t segmentIndex=0, double segmentFraction=0.0)
bool isValid(const geom::Geometry *linearGeom) const
static LinearLocation getEndLocation(const geom::Geometry *linear)
void setToEnd(const geom::Geometry *linear)
void snapToVertex(const geom::Geometry *linearGeom, double minDistance)
int compareTo(const LinearLocation &other) const