GEOS 3.15.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
26namespace geos {
27namespace geom {
28class CoordinateXY;
29class Curve;
30class Geometry;
31class LinearRing;
32class LineString;
33class Polygon;
34class Point;
35class Surface;
36}
37}
38
39namespace geos {
40namespace algorithm { // geos::algorithm
41
58class GEOS_DLL PointLocator {
59public:
60 PointLocator() {}
61 ~PointLocator() {}
62
71 geom::Location locate(const geom::CoordinateXY& p, const geom::Geometry* geom);
72
81 bool
82 intersects(const geom::CoordinateXY& p, const geom::Geometry* geom)
83 {
84 return locate(p, geom) != geom::Location::EXTERIOR;
85 }
86
87private:
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::CoordinateXY& p, const geom::Geometry* geom);
94
95 void updateLocationInfo(geom::Location loc);
96
97 geom::Location locate(const geom::CoordinateXY& p, const geom::Point* pt);
98
99 geom::Location locate(const geom::CoordinateXY& p, const geom::LineString* l);
100
101 static geom::Location locateInPolygonRing(const geom::CoordinateXY& p, const geom::Curve* ring);
102
103 static geom::Location locate(const geom::CoordinateXY& p, const geom::Surface* poly);
104
105};
106
107} // namespace geos::algorithm
108} // namespace geos
109
110
Computes the topological relationship (Location) of a single point to a Geometry.
Definition PointLocator.h:58
bool intersects(const geom::CoordinateXY &p, const geom::Geometry *geom)
Definition PointLocator.h:82
geom::Location locate(const geom::CoordinateXY &p, const geom::Geometry *geom)
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
Definition LineString.h:66
Definition Point.h:61
Definition Surface.h:27
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:32
Basic namespace for all GEOS functionalities.
Definition geos.h:38