[geos-commits] [SCM] GEOS branch master updated. 27516e0bdb7526699c00fef328c61561ab7a4b47
git at osgeo.org
git at osgeo.org
Tue Oct 13 12:30:36 PDT 2020
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".
The branch, master has been updated
via 27516e0bdb7526699c00fef328c61561ab7a4b47 (commit)
from 7657bc03d6a587ef02caa689068b130d56ba45e1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 27516e0bdb7526699c00fef328c61561ab7a4b47
Author: Sandro Santilli <strk at kbt.io>
Date: Tue Oct 13 21:29:32 2020 +0200
Surivive empty collection from GEOSInterpolate
References #1055 in master branch (3.9.0dev)
diff --git a/src/linearref/LinearLocation.cpp b/src/linearref/LinearLocation.cpp
index ce93cb3..7d929cf 100644
--- a/src/linearref/LinearLocation.cpp
+++ b/src/linearref/LinearLocation.cpp
@@ -151,7 +151,14 @@ LinearLocation::getSegmentLength(const Geometry* linearGeom) const
void
LinearLocation::setToEnd(const Geometry* linear)
{
- componentIndex = linear->getNumGeometries() - 1;
+ componentIndex = linear->getNumGeometries();
+ if ( componentIndex == 0 )
+ {
+ segmentIndex = 0;
+ segmentFraction = 0;
+ return;
+ }
+ componentIndex--;
const LineString* lastLine = dynamic_cast<const LineString*>(linear->getGeometryN(componentIndex));
segmentIndex = lastLine->getNumPoints() - 1;
segmentFraction = 1.0;
@@ -189,13 +196,13 @@ LinearLocation::isVertex() const
Coordinate
LinearLocation::getCoordinate(const Geometry* linearGeom) const
{
+ if(linearGeom->isEmpty()) {
+ return Coordinate::getNull();
+ }
const LineString* lineComp = dynamic_cast<const LineString*>(linearGeom->getGeometryN(componentIndex));
if(! lineComp) {
throw util::IllegalArgumentException("LinearLocation::getCoordinate only works with LineString geometries");
}
- if(linearGeom->isEmpty()) {
- return Coordinate::getNull();
- }
Coordinate p0 = lineComp->getCoordinateN(segmentIndex);
if(segmentIndex >= lineComp->getNumPoints() - 1) {
return p0;
diff --git a/tests/unit/capi/GEOSInterpolateTest.cpp b/tests/unit/capi/GEOSInterpolateTest.cpp
index c51c905..b2d22ae 100644
--- a/tests/unit/capi/GEOSInterpolateTest.cpp
+++ b/tests/unit/capi/GEOSInterpolateTest.cpp
@@ -65,4 +65,16 @@ void object::test<1>
ensure_equals(GEOSisEmpty(geom2), 1);
GEOSGeom_destroy(geom2);
}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+ geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION EMPTY");
+ GEOSGeometry* geom2 = GEOSInterpolate(geom1_, 1);
+ ensure_equals(GEOSisEmpty(geom2), 1);
+ GEOSGeom_destroy(geom2);
+}
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
src/linearref/LinearLocation.cpp | 15 +++++++++++----
tests/unit/capi/GEOSInterpolateTest.cpp | 12 ++++++++++++
2 files changed, 23 insertions(+), 4 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list