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
26namespace geos {
27namespace geom {
28class CoordinateXY;
29class Geometry;
30class LinearRing;
31class LineString;
32class Polygon;
33class Point;
34}
35}
36
37namespace geos {
38namespace algorithm { // geos::algorithm
39
56class GEOS_DLL PointLocator {
57public:
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
85private:
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 geos.h:39