File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/XS/libgeos.x/i/geos/algorithm/PointLocator.h
Criterion Covered Total %
statement 4 4 100.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
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
24             #include // 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              
41             /**
42             * \class PointLocator geosAlgorithm.h geos/geosAlgorithm.h
43             *
44             * \brief
45             * Computes the topological relationship (Location)
46             * of a single point to a Geometry.
47             *
48             * The algorithm obeys the SFS boundaryDetermination rule to correctly determine
49             * whether the point lies on the boundary or not.
50             *
51             * Notes:
52             * - instances of this class are not reentrant.
53             * - LinearRing objects do not enclose any area
54             * (points inside the ring are still in the EXTERIOR of the ring.)
55             *
56             */
57             class GEOS_DLL PointLocator {
58             public:
59 2           PointLocator() {}
60 2           ~PointLocator() {}
61              
62             /**
63             * Computes the topological relationship (Location) of a single point
64             * to a Geometry. It handles both single-element and multi-element Geometries.
65             * The algorithm for multi-part Geometriestakes into account the SFS
66             * Boundary Determination rule.
67             *
68             * @return the Location of the point relative to the input Geometry
69             */
70             int locate(const geom::Coordinate& p, const geom::Geometry *geom);
71              
72             /**
73             * Convenience method to test a point for intersection with
74             * a Geometry
75             *
76             * @param p the coordinate to test
77             * @param geom the Geometry to test
78             * @return true if the point is in the interior or boundary of the Geometry
79             */
80 1           bool intersects(const geom::Coordinate& p, const geom::Geometry *geom) {
81 1           return locate(p, geom) != geom::Location::EXTERIOR;
82             }
83              
84             private:
85              
86             bool isIn; // true if the point lies in or on any Geometry element
87              
88             int numBoundaries; // the number of sub-elements whose boundaries the point lies in
89              
90             void computeLocation(const geom::Coordinate& p, const geom::Geometry *geom);
91              
92             void updateLocationInfo(int loc);
93              
94             int locate(const geom::Coordinate& p, const geom::Point *pt);
95              
96             int locate(const geom::Coordinate& p, const geom::LineString *l);
97              
98             int locateInPolygonRing(const geom::Coordinate& p, const geom::LinearRing *ring);
99              
100             int locate(const geom::Coordinate& p, const geom::Polygon *poly);
101              
102             };
103              
104             } // namespace geos::algorithm
105             } // namespace geos
106              
107              
108             #endif // GEOS_ALGORITHM_POINTLOCATOR_H
109