Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement GEOSMinimumClearance and GEOSMinimumClearanceLine
Includes tests and C-API exposure. Patch by Daniel Baston <dbaston@maponics.com> via #65 Closes #776 git-svn-id: http://svn.osgeo.org/geos/trunk@4203 5242fede-7e19-0410-aef8-94bd7d2200fb
- Loading branch information
Sandro Santilli
committed
Apr 25, 2016
1 parent
e2fd09a
commit 6741c5e
Showing
20 changed files
with
841 additions
and
19 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
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
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
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,66 @@ | ||
/********************************************************************** | ||
* | ||
* 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/FacetSequence.java (JTS-1.14) | ||
* | ||
**********************************************************************/ | ||
|
||
#ifndef GEOS_OPERATION_DISTANCE_FACETSEQUENCE_H | ||
#define GEOS_OPERATION_DISTANCE_FACETSEQUENCE_H | ||
|
||
#include <geos/geom/CoordinateSequence.h> | ||
#include <geos/geom/Envelope.h> | ||
#include <geos/geom/Coordinate.h> | ||
|
||
using namespace geos::geom; | ||
|
||
namespace geos { | ||
namespace operation { | ||
namespace distance { | ||
class FacetSequence { | ||
private: | ||
const CoordinateSequence *pts; | ||
const size_t start; | ||
const size_t end; | ||
|
||
/* Unlike JTS, we store the envelope in the FacetSequence so that it has a clear owner. This is | ||
* helpful when making a tree of FacetSequence objects (FacetSequenceTreeBuilder) | ||
* */ | ||
Envelope env; | ||
|
||
double computeLineLineDistance(const FacetSequence & facetSeq) const; | ||
|
||
double computePointLineDistance(const Coordinate & pt, const FacetSequence & facetSeq) const; | ||
|
||
void computeEnvelope(); | ||
|
||
public: | ||
const Envelope * getEnvelope() const; | ||
|
||
const Coordinate * getCoordinate(size_t index) const; | ||
|
||
size_t size() const; | ||
|
||
bool isPoint() const; | ||
|
||
double distance(const FacetSequence & facetSeq); | ||
|
||
FacetSequence(const CoordinateSequence *pts, size_t start, size_t end); | ||
}; | ||
|
||
} | ||
} | ||
} | ||
|
||
#endif //GEOS_OPERATION_DISTANCE_FACETSEQUENCE_H |
52 changes: 52 additions & 0 deletions
52
include/geos/operation/distance/FacetSequenceTreeBuilder.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,52 @@ | ||
/********************************************************************** | ||
* | ||
* 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/FacetSequenceTreeBuilder.java (JTS-1.14) | ||
* | ||
**********************************************************************/ | ||
|
||
#ifndef GEOS_OPERATION_DISTANCE_FACETSEQUENCETREEBUILDER_H | ||
#define GEOS_OPERATION_DISTANCE_FACETSEQUENCETREEBUILDER_H | ||
|
||
#include <geos/index/strtree/STRtree.h> | ||
#include <geos/geom/Geometry.h> | ||
#include <geos/geom/CoordinateSequence.h> | ||
#include <geos/operation/distance/FacetSequence.h> | ||
|
||
using namespace geos::geom; | ||
using namespace geos::index::strtree; | ||
using namespace geos::operation::distance; | ||
|
||
namespace geos { | ||
namespace operation { | ||
namespace distance { | ||
class FacetSequenceTreeBuilder { | ||
private: | ||
// 6 seems to be a good facet sequence size | ||
static const int FACET_SEQUENCE_SIZE = 6; | ||
|
||
// Seems to be better to use a minimum node capacity | ||
static const int STR_TREE_NODE_CAPACITY = 4; | ||
|
||
static void addFacetSequences(const CoordinateSequence* pts, std::vector<FacetSequence*> & sections); | ||
static std::vector<FacetSequence*> * computeFacetSequences(const Geometry* g); | ||
|
||
public: | ||
static STRtree* build(const Geometry* g); | ||
}; | ||
} | ||
} | ||
} | ||
|
||
#endif //GEOS_FACETSEQUENCETREEBUILDER_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
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,60 @@ | ||
/********************************************************************** | ||
* | ||
* 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: precision/MinimumClearance.java (JTS-1.14) | ||
* | ||
**********************************************************************/ | ||
|
||
#ifndef GEOS_PRECISION_MINIMUMCLEARANCE_H | ||
#define GEOS_PRECISION_MINIMUMCLEARANCE_H | ||
|
||
#include <geos/geom/Geometry.h> | ||
#include <geos/geom/LineString.h> | ||
#include <geos/geom/CoordinateSequence.h> | ||
|
||
namespace geos { | ||
namespace precision { | ||
class MinimumClearance { | ||
private: | ||
const geom::Geometry* inputGeom; | ||
double minClearance; | ||
std::auto_ptr<geom::CoordinateSequence> minClearancePts; | ||
|
||
void compute(); | ||
public: | ||
MinimumClearance(const geom::Geometry* g); | ||
|
||
/** | ||
* Gets the Minimum Clearance distance. | ||
* | ||
* @return the value of the minimum clearance distance | ||
* or <tt>DBL_MAX</tt> if no Minimum Clearance distance exists | ||
*/ | ||
double getDistance(); | ||
|
||
/** | ||
* Gets a LineString containing two points | ||
* which are at the Minimum Clearance distance. | ||
* | ||
* @return the value of the minimum clearance distance | ||
* or <tt>LINESTRING EMPTY</tt> if no Minimum Clearance distance exists | ||
*/ | ||
std::auto_ptr<geom::LineString> getLine(); | ||
}; | ||
} | ||
} | ||
|
||
#endif | ||
|
||
|
Oops, something went wrong.