GEOS  3.6.1
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 r320 (JTS-1.12)
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 
58 class GEOS_DLL PointLocator {
59 public:
60  PointLocator() {}
61  ~PointLocator() {}
62 
73  int locate(const geom::Coordinate& p, const geom::Geometry *geom);
74 
83  bool intersects(const geom::Coordinate& p, const geom::Geometry *geom) {
84  return locate(p, geom) != geom::Location::EXTERIOR;
85  }
86 
87 private:
88 
89  bool isIn; // true if the point lies in or on any Geometry element
90 
91  int numBoundaries; // the number of sub-elements whose boundaries the point lies in
92 
93  void computeLocation(const geom::Coordinate& p, const geom::Geometry *geom);
94 
95  void updateLocationInfo(int loc);
96 
97  int locate(const geom::Coordinate& p, const geom::Point *pt);
98 
99  int locate(const geom::Coordinate& p, const geom::LineString *l);
100 
101  int locateInPolygonRing(const geom::Coordinate& p, const geom::LinearRing *ring);
102 
103  int locate(const geom::Coordinate& p, const geom::Polygon *poly);
104 
105 };
106 
107 } // namespace geos::algorithm
108 } // namespace geos
109 
110 
111 #endif // GEOS_ALGORITHM_POINTLOCATOR_H
112 
bool intersects(const geom::Coordinate &p, const geom::Geometry *geom)
Definition: PointLocator.h:83
Definition: Location.h:63
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:58
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
Definition: LineString.h:70
Represents a linear polygon, which may include holes.
Definition: Polygon.h:66
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Models an OGC SFS LinearRing.
Definition: LinearRing.h:57
Definition: Point.h:67