GEOS 3.16.0dev
IndexedFacetDistance.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2016 Daniel Baston
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************
14 *
15 * Last port: operation/distance/IndexedFacetDistance.java (aff11591)
16 *
17 **********************************************************************/
18
19#pragma once
20
21#include <geos/operation/distance/CoordinateSequenceLocation.h>
22#include <geos/operation/distance/FacetSequenceTreeBuilder.h>
23
24namespace geos {
25namespace operation {
26namespace distance {
27
47class GEOS_DLL IndexedFacetDistance {
48public:
49
62 cachedTree(FacetSequenceTreeBuilder::build(g)),
63 baseGeometry(*g)
64 {}
65
74 static double distance(const geom::Geometry* g1, const geom::Geometry* g2);
75
81 static std::unique_ptr<geom::CoordinateSequence> nearestPoints(const geom::Geometry* g1, const geom::Geometry* g2);
82
88 double distance(const geom::Geometry* g) const;
89
96 bool isWithinDistance(const geom::Geometry* g, double maxDistance) const;
97
98 static bool isWithinDistance(const geom::Geometry* g1, const geom::Geometry* g2, double distance);
99
104 std::unique_ptr<geom::CoordinateSequence> nearestPoints(const geom::Geometry* g) const;
105
113 geom::CoordinateXY nearestPoint(const geom::CoordinateXY& p) const;
114
115 double distance(const geom::CoordinateXY& p) const;
116
117 double distance(const geom::CoordinateXY& p0, const geom::CoordinateXY& p1) const;
118
119 CoordinateSequenceLocation nearestLocation(const geom::CoordinateXY& p) const;
120
121
122private:
123 struct FacetDistance {
124 double operator()(const FacetSequence* a, const FacetSequence* b) const
125 {
126 return a->distance(*b);
127 }
128 };
129
130 std::unique_ptr<geos::index::strtree::TemplateSTRtree<const FacetSequence*>> cachedTree;
131 const geom::Geometry& baseGeometry;
132
133};
134}
135}
136}
137
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:201
Definition CoordinateSequenceLocation.h:48
Computes the distance between the facets (segments and vertices) of two Geometrys using a Branch-and-...
Definition IndexedFacetDistance.h:47
std::unique_ptr< geom::CoordinateSequence > nearestPoints(const geom::Geometry *g) const
Computes the nearest points on the base geometry and the given geometry.
static std::unique_ptr< geom::CoordinateSequence > nearestPoints(const geom::Geometry *g1, const geom::Geometry *g2)
Computes the nearest points of the facets of two geometries.
double distance(const geom::Geometry *g) const
Computes the distance from the base geometry to the given geometry.
static double distance(const geom::Geometry *g1, const geom::Geometry *g2)
Computes the distance between facets of two geometries.
geom::CoordinateXY nearestPoint(const geom::CoordinateXY &p) const
bool isWithinDistance(const geom::Geometry *g, double maxDistance) const
Tests whether the base geometry lies within a specified distance of the given geometry.
IndexedFacetDistance(const geom::Geometry *g)
Creates a new distance-finding instance for a given target geom::Geometry.
Definition IndexedFacetDistance.h:61
Basic namespace for all GEOS functionalities.
Definition geos.h:38