GEOS  3.14.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 #pragma once
21 
22 #include <geos/export.h>
23 #include <geos/geom/Location.h> // for inlines
24 
25 // Forward declarations
26 namespace geos {
27 namespace geom {
28 class CoordinateXY;
29 class Geometry;
30 class LinearRing;
31 class LineString;
32 class Polygon;
33 class Point;
34 }
35 }
36 
37 namespace geos {
38 namespace algorithm { // geos::algorithm
39 
56 class GEOS_DLL PointLocator {
57 public:
58  PointLocator() {}
59  ~PointLocator() {}
60 
69  geom::Location locate(const geom::CoordinateXY& p, const geom::Geometry* geom);
70 
79  bool
80  intersects(const geom::CoordinateXY& p, const geom::Geometry* geom)
81  {
82  return locate(p, geom) != geom::Location::EXTERIOR;
83  }
84 
85 private:
86 
87  bool isIn; // true if the point lies in or on any Geometry element
88 
89  int numBoundaries; // the number of sub-elements whose boundaries the point lies in
90 
91  void computeLocation(const geom::CoordinateXY& p, const geom::Geometry* geom);
92 
93  void updateLocationInfo(geom::Location loc);
94 
95  geom::Location locate(const geom::CoordinateXY& p, const geom::Point* pt);
96 
97  geom::Location locate(const geom::CoordinateXY& p, const geom::LineString* l);
98 
99  geom::Location locateInPolygonRing(const geom::CoordinateXY& p, const geom::LinearRing* ring);
100 
101  geom::Location locate(const geom::CoordinateXY& p, const geom::Polygon* poly);
102 
103 };
104 
105 } // namespace geos::algorithm
106 } // namespace geos
107 
108 
Computes the topological relationship (Location) of a single point to a Geometry.
Definition: PointLocator.h:56
bool intersects(const geom::CoordinateXY &p, const geom::Geometry *geom)
Definition: PointLocator.h:80
geom::Location locate(const geom::CoordinateXY &p, const geom::Geometry *geom)
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:197
Definition: LineString.h:66
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition: LinearRing.h:54
Definition: Point.h:61
Represents a linear polygon, which may include holes.
Definition: Polygon.h:61
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:32
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25