DistanceOp.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
* Copyright (C) 2006 Refractions Research Inc.
*
* 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/DistanceOp.java r335 (JTS-1.12-)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/algorithm/PointLocator.h> // for composition
#include <geos/operation/distance/GeometryLocation.h>
#include <geos/geom/CoordinateSequence.h>
#include <array>
#include <vector>
#include <memory>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom {
class Coordinate;
class Polygon;
class LineString;
class Point;
class Geometry;
}
}
namespace geos {
namespace operation { // geos::operation
namespace distance { // geos::operation::distance
class GEOS_DLL DistanceOp {
public:
static double distance(const geom::Geometry& g0,
const geom::Geometry& g1);
static double distance(const geom::Geometry* g0,
const geom::Geometry* g1);
static bool isWithinDistance(const geom::Geometry& g0,
const geom::Geometry& g1,
double distance);
static std::unique_ptr<geom::CoordinateSequence> nearestPoints(
const geom::Geometry* g0,
const geom::Geometry* g1);
DistanceOp(const geom::Geometry* g0, const geom::Geometry* g1);
DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1);
DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1,
double terminateDistance);
~DistanceOp() = default;
double distance();
std::unique_ptr<geom::CoordinateSequence> nearestPoints();
private:
// input
std::array<geom::Geometry const*, 2> geom;
double terminateDistance;
// working
algorithm::PointLocator ptLocator;
std::array<GeometryLocation, 2> minDistanceLocation;
double minDistance;
bool computed = false;
void updateMinDistance(std::array<GeometryLocation, 2> & locGeom, bool flip);
void computeMinDistance();
void computeContainmentDistance();
void computeInside(std::vector<GeometryLocation> & locs,
const std::vector<const geom::Polygon*>& polys,
std::array<GeometryLocation, 2> & locPtPoly);
void computeFacetDistance();
void computeMinDistanceLines(
const std::vector<const geom::LineString*>& lines0,
const std::vector<const geom::LineString*>& lines1,
std::array<GeometryLocation, 2> & locGeom);
void computeMinDistancePoints(
const std::vector<const geom::Point*>& points0,
const std::vector<const geom::Point*>& points1,
std::array<GeometryLocation, 2> & locGeom);
void computeMinDistanceLinesPoints(
const std::vector<const geom::LineString*>& lines0,
const std::vector<const geom::Point*>& points1,
std::array<GeometryLocation, 2> & locGeom);
void computeMinDistance(const geom::LineString* line0,
const geom::LineString* line1,
std::array<GeometryLocation, 2> & locGeom);
void computeMinDistance(const geom::LineString* line,
const geom::Point* pt,
std::array<GeometryLocation, 2> & locGeom);
};
} // namespace geos::operation::distance
} // namespace geos::operation
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::algorithm::PointLocator
Computes the topological relationship (Location) of a single point to a Geometry.
Definition PointLocator.h:56
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::LineString
Definition LineString.h:66
geos::geom::Point
Definition Point.h:61
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::operation::distance::DistanceOp::distance
static double distance(const geom::Geometry *g0, const geom::Geometry *g1)
geos::operation::distance::DistanceOp::isWithinDistance
static bool isWithinDistance(const geom::Geometry &g0, const geom::Geometry &g1, double distance)
Test whether two geometries lie within a given distance of each other.
geos::operation::distance::DistanceOp::DistanceOp
DistanceOp(const geom::Geometry &g0, const geom::Geometry &g1)
Constructs a DistanceOp that computes the distance and nearest points between the two specified geome...
geos::operation::distance::DistanceOp::distance
double distance()
geos::operation::distance::DistanceOp::nearestPoints
static std::unique_ptr< geom::CoordinateSequence > nearestPoints(const geom::Geometry *g0, const geom::Geometry *g1)
geos::operation::distance::DistanceOp::DistanceOp
DistanceOp(const geom::Geometry &g0, const geom::Geometry &g1, double terminateDistance)
Constructs a DistanceOp that computes the distance and nearest points between the two specified geome...
geos::operation::distance::DistanceOp::distance
static double distance(const geom::Geometry &g0, const geom::Geometry &g1)
Compute the distance between the nearest points of two geometries.
geos::operation::distance::DistanceOp::DistanceOp
DistanceOp(const geom::Geometry *g0, const geom::Geometry *g1)
geos::operation::distance::DistanceOp::nearestPoints
std::unique_ptr< geom::CoordinateSequence > nearestPoints()
geos::geom
Definition Angle.h:26
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