-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LargestEmptyCircle handling of polygon obstacles (#939)
- Loading branch information
Showing
13 changed files
with
649 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/********************************************************************** | ||
* | ||
* GEOS - Geometry Engine Open Source | ||
* http://geos.osgeo.org | ||
* | ||
* Copyright (C) 2023 Martin Davis <[email protected]> | ||
* | ||
* 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: algorithm/construct/IndexedDistanceToPoint.java | ||
* https://github.com/locationtech/jts/commit/d92f783163d9440fcc10c729143787bf7b9fe8f9 | ||
* | ||
**********************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <geos/geom/CoordinateSequence.h> | ||
#include <geos/geom/Geometry.h> | ||
#include <geos/geom/Point.h> | ||
#include <geos/algorithm/construct/IndexedPointInPolygonsLocator.h> | ||
#include <geos/operation/distance/IndexedFacetDistance.h> | ||
|
||
using geos::geom::Geometry; | ||
using geos::geom::Point; | ||
using geos::operation::distance::IndexedFacetDistance; | ||
|
||
namespace geos { | ||
namespace algorithm { // geos::algorithm | ||
namespace construct { // geos::algorithm::construct | ||
|
||
/** | ||
* \brief Computes the distance between a point and a geometry | ||
* (which may be a collection containing any type of geometry). | ||
* | ||
* Also computes the pair of points containing the input | ||
* point and the nearest point on the geometry. | ||
* | ||
* \author Martin Davis | ||
*/ | ||
class GEOS_DLL IndexedDistanceToPoint { | ||
|
||
public: | ||
/** | ||
* \brief Creates an instance to find the distance from points to a geometry. | ||
* | ||
* \param geom the geometry to compute distances to | ||
*/ | ||
IndexedDistanceToPoint(const Geometry& geom); | ||
|
||
/** | ||
* \brief Computes the distance from the base geometry to the given point. | ||
* | ||
* \param pt the point to compute the distance to | ||
* | ||
* \return the computed distance | ||
*/ | ||
double distance(const Point& pt); | ||
|
||
/** | ||
* \brief Computes the nearest point on the geometry to the point. | ||
* | ||
* The first location lies on the geometry, | ||
* and the second location is the provided point. | ||
* | ||
* \param pt the point to compute the nearest point for | ||
* | ||
* \return the points that are nearest | ||
*/ | ||
std::unique_ptr<geom::CoordinateSequence> nearestPoints(const Point& pt); | ||
|
||
private: | ||
void init(); | ||
|
||
bool isInArea(const Point& pt); | ||
|
||
//-- members | ||
const Geometry& targetGeometry; | ||
std::unique_ptr<operation::distance::IndexedFacetDistance> facetDistance; | ||
std::unique_ptr<IndexedPointInPolygonsLocator> ptLocator; | ||
|
||
}; | ||
|
||
}}} |
79 changes: 79 additions & 0 deletions
79
include/geos/algorithm/construct/IndexedPointInPolygonsLocator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/********************************************************************** | ||
* | ||
* GEOS - Geometry Engine Open Source | ||
* http://geos.osgeo.org | ||
* | ||
* Copyright (C) 2023 Martin Davis <[email protected]> | ||
* | ||
* 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: algorithm/construct/IndexedDistanceToPoint.java | ||
* https://github.com/locationtech/jts/commit/d92f783163d9440fcc10c729143787bf7b9fe8f9 | ||
* | ||
**********************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <geos/geom/Coordinate.h> | ||
#include <geos/geom/Geometry.h> | ||
#include <geos/geom/Location.h> | ||
#include <geos/index/strtree/TemplateSTRtree.h> | ||
#include <geos/algorithm/locate/IndexedPointInAreaLocator.h> | ||
|
||
using geos::geom::Geometry; | ||
using geos::geom::CoordinateXY; | ||
using geos::geom::Location; | ||
using geos::index::strtree::TemplateSTRtree; | ||
using geos::algorithm::locate::IndexedPointInAreaLocator; | ||
|
||
namespace geos { | ||
namespace algorithm { // geos::algorithm | ||
namespace construct { // geos::algorithm::construct | ||
|
||
/** | ||
* \brief Determines the location of a point in the polygonal elements of a geometry. | ||
* | ||
* Uses spatial indexing to provide efficient performance. | ||
* | ||
* \author Martin Davis | ||
*/ | ||
class GEOS_DLL IndexedPointInPolygonsLocator { | ||
|
||
public: | ||
/** | ||
* \brief Creates an instance to locate a point in polygonal elements. | ||
* | ||
* \param geom the geometry to locate in | ||
*/ | ||
IndexedPointInPolygonsLocator(const Geometry& geom); | ||
|
||
/** \brief | ||
* Determines the [Location](@ref geom::Location) of a point in | ||
* the polygonal elements of a | ||
* [Geometry](@ref geom::Geometry). | ||
* | ||
* @param p the point to test | ||
* @return the location of the point in the geometry | ||
*/ | ||
Location locate(const CoordinateXY* /*const*/ p); | ||
|
||
private: | ||
void init(); | ||
|
||
// Declare type as noncopyable | ||
IndexedPointInPolygonsLocator(const IndexedPointInPolygonsLocator& other) = delete; | ||
IndexedPointInPolygonsLocator& operator=(const IndexedPointInPolygonsLocator& rhs) = delete; | ||
|
||
//-- members | ||
const Geometry& geom; | ||
bool isInitialized; | ||
TemplateSTRtree<IndexedPointInAreaLocator*> index; | ||
std::vector<std::unique_ptr<IndexedPointInAreaLocator>> locators; | ||
}; | ||
|
||
}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/********************************************************************** | ||
* | ||
* GEOS - Geometry Engine Open Source | ||
* http://geos.osgeo.org | ||
* | ||
* Copyright (C) 2001-2002 Vivid Solutions Inc. | ||
* 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. | ||
* | ||
**********************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <geos/export.h> | ||
#include <geos/geom/Geometry.h> | ||
#include <vector> | ||
|
||
namespace geos { | ||
namespace geom { // geos.geom | ||
namespace util { // geos.geom.util | ||
|
||
/** | ||
* \brief Extracts the polygonal (Polygon and MultiPolygon) elements from a Geometry. | ||
*/ | ||
class GEOS_DLL PolygonalExtracter { | ||
|
||
public: | ||
|
||
/** | ||
* Pushes the polygonal (Polygon and MultiPolygon) elements from a geometry into | ||
* the provided vector. | ||
* | ||
* @param geom the geometry to extract from | ||
* @param polys the vector to add the polygonal elements to | ||
*/ | ||
static void getPolygonals(const Geometry& geom, std::vector<const Geometry*>& polys); | ||
|
||
private: | ||
|
||
static void getPolygonals(const Geometry* geom, std::vector<const Geometry*>& polys); | ||
|
||
// Declare type as noncopyable | ||
PolygonalExtracter(const PolygonalExtracter& other) = delete; | ||
PolygonalExtracter& operator=(const PolygonalExtracter& rhs) = delete; | ||
}; | ||
|
||
} // namespace geos.geom.util | ||
} // namespace geos.geom | ||
} // namespace geos | ||
|
Oops, something went wrong.