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  int 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(int loc);
95 
96  int locate(const geom::Coordinate& p, const geom::Point* pt);
97 
98  int locate(const geom::Coordinate& p, const geom::LineString* l);
99 
100  int locateInPolygonRing(const geom::Coordinate& p, const geom::LinearRing* ring);
101 
102  int 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
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:57
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:187
Definition: LineString.h:69
Represents a linear polygon, which may include holes.
Definition: Polygon.h:65
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Models an OGC SFS LinearRing.
Definition: LinearRing.h:56
Definition: Point.h:66