GEOS  3.13.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 (f6187ee2 JTS-1.14)
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/operation/distance/FacetSequenceTreeBuilder.h>
22 
23 namespace geos {
24 namespace operation {
25 namespace distance {
26 
46 class GEOS_DLL IndexedFacetDistance {
47 public:
48 
61  cachedTree(FacetSequenceTreeBuilder::build(g)),
62  baseGeometry(*g)
63  {}
64 
73  static double distance(const geom::Geometry* g1, const geom::Geometry* g2);
74 
80  static std::unique_ptr<geom::CoordinateSequence> nearestPoints(const geom::Geometry* g1, const geom::Geometry* g2);
81 
87  double distance(const geom::Geometry* g) const;
88 
95  bool isWithinDistance(const geom::Geometry* g, double maxDistance) const;
96 
101  std::vector<GeometryLocation> nearestLocations(const geom::Geometry* g) const;
102 
107  std::unique_ptr<geom::CoordinateSequence> nearestPoints(const geom::Geometry* g) const;
108 
109 private:
110  struct FacetDistance {
111  double operator()(const FacetSequence* a, const FacetSequence* b) const
112  {
113  return a->distance(*b);
114  }
115  };
116 
117  std::unique_ptr<geos::index::strtree::TemplateSTRtree<const FacetSequence*>> cachedTree;
118  const geom::Geometry& baseGeometry;
119 
120 };
121 }
122 }
123 }
124 
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Computes the distance between the facets (segments and vertices) of two Geometrys using a Branch-and-...
Definition: IndexedFacetDistance.h:46
double distance(const geom::Geometry *g) const
Computes the distance from the base geometry to the given geometry.
std::unique_ptr< geom::CoordinateSequence > nearestPoints(const geom::Geometry *g) const
Compute the nearest locations on the target geometry and the given geometry.
static double distance(const geom::Geometry *g1, const geom::Geometry *g2)
Computes the distance between facets of two geometries.
std::vector< GeometryLocation > nearestLocations(const geom::Geometry *g) const
Computes the nearest locations 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.
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:60
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25