IndexedFacetDistance.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2016 Daniel Baston
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: operation/distance/IndexedFacetDistance.java (f6187ee2 JTS-1.14)
*
**********************************************************************/
#pragma once
#include <geos/operation/distance/FacetSequenceTreeBuilder.h>
namespace geos {
namespace operation {
namespace distance {
class GEOS_DLL IndexedFacetDistance {
public:
IndexedFacetDistance(const geom::Geometry* g) :
cachedTree(FacetSequenceTreeBuilder::build(g)),
baseGeometry(*g)
{}
static double distance(const geom::Geometry* g1, const geom::Geometry* g2);
static std::unique_ptr<geom::CoordinateSequence> nearestPoints(const geom::Geometry* g1, const geom::Geometry* g2);
double distance(const geom::Geometry* g) const;
bool isWithinDistance(const geom::Geometry* g, double maxDistance) const;
std::vector<GeometryLocation> nearestLocations(const geom::Geometry* g) const;
std::unique_ptr<geom::CoordinateSequence> nearestPoints(const geom::Geometry* g) const;
private:
struct FacetDistance {
double operator()(const FacetSequence* a, const FacetSequence* b) const
{
return a->distance(*b);
}
};
std::unique_ptr<geos::index::strtree::TemplateSTRtree<const FacetSequence*>> cachedTree;
const geom::Geometry& baseGeometry;
};
}
}
}
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::operation::distance::IndexedFacetDistance::nearestPoints
std::unique_ptr< geom::CoordinateSequence > nearestPoints(const geom::Geometry *g) const
Compute the nearest locations on the target geometry and the given geometry.
geos::operation::distance::IndexedFacetDistance::nearestPoints
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.
geos::operation::distance::IndexedFacetDistance::distance
double distance(const geom::Geometry *g) const
Computes the distance from the base geometry to the given geometry.
geos::operation::distance::IndexedFacetDistance::distance
static double distance(const geom::Geometry *g1, const geom::Geometry *g2)
Computes the distance between facets of two geometries.
geos::operation::distance::IndexedFacetDistance::nearestLocations
std::vector< GeometryLocation > nearestLocations(const geom::Geometry *g) const
Computes the nearest locations on the base geometry and the given geometry.
geos::operation::distance::IndexedFacetDistance::isWithinDistance
bool isWithinDistance(const geom::Geometry *g, double maxDistance) const
Tests whether the base geometry lies within a specified distance of the given geometry.
geos::operation::distance::IndexedFacetDistance::IndexedFacetDistance
IndexedFacetDistance(const geom::Geometry *g)
Creates a new distance-finding instance for a given target geom::Geometry.
Definition IndexedFacetDistance.h:60
geos::operation::distance
Provides classes for computing the distance between geometries.
Definition namespaces.h:185
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38