Skip to content

Commit bdef327

Browse files
authored
Fix withinDistance with negative distance value
Closes #1277 Negative values are now treated as zero.
1 parent 29d4f5d commit bdef327

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ capi/geos_c.h
3737
.project
3838
.ccache/
3939
web/public/
40+
*.code-workspace

src/operation/distance/DistanceOp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ DistanceOp::DistanceOp(const Geometry& g0, const Geometry& g1):
9090
DistanceOp::DistanceOp(const Geometry& g0, const Geometry& g1, double tdist)
9191
:
9292
geom{{&g0, &g1}},
93-
terminateDistance(tdist),
93+
terminateDistance(tdist < 0.0 ? 0.0 : tdist),
9494
minDistance(DoubleInfinity)
9595
{}
9696

src/operation/distance/IndexedFacetDistance.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ IndexedFacetDistance::distance(const Geometry* g) const
5959
bool
6060
IndexedFacetDistance::isWithinDistance(const Geometry* g, double maxDistance) const
6161
{
62+
if (maxDistance < 0.0) maxDistance = 0.0;
6263
// short-circuit check
6364
double envDist = baseGeometry.getEnvelopeInternal()->distance(*g->getEnvelopeInternal());
6465
if (envDist > maxDistance) {

0 commit comments

Comments
 (0)