GEOS  3.8.0dev
PointLocator.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2005-2011 Refractions Research Inc.
7  * Copyright (C) 2001-2002 Vivid Solutions Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************
15  *
16  * Last port: algorithm/PointLocator.java 95fbe34b (JTS-1.15.2-SNAPSHOT)
17  *
18  **********************************************************************/
19
20 #ifndef GEOS_ALGORITHM_POINTLOCATOR_H
21 #define GEOS_ALGORITHM_POINTLOCATOR_H
22
23 #include <geos/export.h>
24 #include <geos/geom/Location.h> // for inlines
25
26 // Forward declarations
27 namespace geos {
28 namespace geom {
29 class Coordinate;
30 class Geometry;
31 class LinearRing;
32 class LineString;
33 class Polygon;
34 class Point;
35 }
36 }
37
38 namespace geos {
39 namespace algorithm { // geos::algorithm
40
57 class GEOS_DLL PointLocator {
58 public:
59  PointLocator() {}
60  ~PointLocator() {}
61
70  geom::Location locate(const geom::Coordinate& p, const geom::Geometry* geom);
71
80  bool
82  {
83  return locate(p, geom) != geom::Location::EXTERIOR;
84  }
85
86 private:
87
88  bool isIn; // true if the point lies in or on any Geometry element
89
90  int numBoundaries; // the number of sub-elements whose boundaries the point lies in
91
92  void computeLocation(const geom::Coordinate& p, const geom::Geometry* geom);
93
94  void updateLocationInfo(geom::Location loc);
95
96  geom::Location locate(const geom::Coordinate& p, const geom::Point* pt);
97
98  geom::Location locate(const geom::Coordinate& p, const geom::LineString* l);
99
100  geom::Location locateInPolygonRing(const geom::Coordinate& p, const geom::LinearRing* ring);
101
102  geom::Location locate(const geom::Coordinate& p, const geom::Polygon* poly);
103
104 };
105
106 } // namespace geos::algorithm
107 } // namespace geos
108
109
110 #endif // GEOS_ALGORITHM_POINTLOCATOR_H
111
bool intersects(const geom::Coordinate &p, const geom::Geometry *geom)
Definition: PointLocator.h:81
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Computes the topological relationship (Location) of a single point to a Geometry. ...
Definition: PointLocator.h:57
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Definition: LineString.h:68
Represents a linear polygon, which may include holes.
Definition: Polygon.h:64
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:33
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple...
Definition: LinearRing.h:54
Definition: Point.h:65