[geos-commits] [SCM] GEOS branch master updated. 52c516f3682c9ae4effc957aebc89176eacfac49
git at osgeo.org
git at osgeo.org
Sun Sep 23 18:23:25 PDT 2018
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 52c516f3682c9ae4effc957aebc89176eacfac49 (commit)
via 3b745fdb83d8293d998a7b958bbf1adf99ecc0ae (commit)
via 18505af1103cdafb2178f2f0eb8e1a10cfa16d2d (commit)
from b578411ff0434fe0397fe4a0ecad727c5e41e825 (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 52c516f3682c9ae4effc957aebc89176eacfac49
Merge: b578411 3b745fd
Author: Daniel Baston <dbaston at gmail.com>
Date: Sun Sep 23 21:22:57 2018 -0400
Merge branch 'sir-sigurd-empty-crash-interpolate'
commit 3b745fdb83d8293d998a7b958bbf1adf99ecc0ae
Merge: b578411 18505af
Author: Daniel Baston <dbaston at gmail.com>
Date: Sun Sep 23 21:22:31 2018 -0400
Merge branch 'empty-crash-interpolate' of https://github.com/sir-sigurd/libgeos into sir-sigurd-empty-crash-interpolate
commit 18505af1103cdafb2178f2f0eb8e1a10cfa16d2d
Author: Sergey Fedoseev <fedoseev.sergey at gmail.com>
Date: Fri Sep 21 01:34:07 2018 +0500
Fix #926: Fixed crash in GEOSInterpolate() when used with empty LineString.
diff --git a/src/linearref/LinearLocation.cpp b/src/linearref/LinearLocation.cpp
index b413b76..3c1c452 100644
--- a/src/linearref/LinearLocation.cpp
+++ b/src/linearref/LinearLocation.cpp
@@ -194,6 +194,9 @@ LinearLocation::getCoordinate(const Geometry* linearGeom) const
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/Makefile.am b/tests/unit/Makefile.am
index 8f02cc4..3c84675 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -168,7 +168,8 @@ geos_unit_SOURCES = \
capi/GEOSReverseTest.cpp \
capi/GEOSUnaryUnionTest.cpp \
capi/GEOSisValidDetailTest.cpp \
- capi/GEOSisClosedTest.cpp
+ capi/GEOSisClosedTest.cpp \
+ capi/GEOSInterpolateTest.cpp
noinst_HEADERS = \
utility.h
diff --git a/tests/unit/capi/GEOSInterpolateTest.cpp b/tests/unit/capi/GEOSInterpolateTest.cpp
new file mode 100644
index 0000000..b5cacc2
--- /dev/null
+++ b/tests/unit/capi/GEOSInterpolateTest.cpp
@@ -0,0 +1,68 @@
+// Test Suite for C-API LineString interpolate functions
+
+#include <tut/tut.hpp>
+// geos
+#include <geos_c.h>
+// std
+#include <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+#include <cmath>
+
+namespace tut
+{
+ //
+ // Test Group
+ //
+
+ // Common data used in test cases.
+ struct test_capiinterpolate_data
+ {
+ GEOSGeometry* geom1_;
+
+ static void notice(const char *fmt, ...)
+ {
+ std::fprintf( stdout, "NOTICE: ");
+
+ va_list ap;
+ va_start(ap, fmt);
+ std::vfprintf(stdout, fmt, ap);
+ va_end(ap);
+
+ std::fprintf(stdout, "\n");
+ }
+
+ test_capiinterpolate_data()
+ : geom1_(nullptr)
+ {
+ initGEOS(notice, notice);
+ }
+
+ ~test_capiinterpolate_data()
+ {
+ GEOSGeom_destroy(geom1_);
+ geom1_ = nullptr;
+ finishGEOS();
+ }
+
+ };
+
+ typedef test_group<test_capiinterpolate_data> group;
+ typedef group::object object;
+
+ group test_capiinterpolate_group("capi::GEOSInterpolate");
+
+ //
+ // Test Cases
+ //
+
+ template<>
+ template<>
+ void object::test<1>()
+ {
+ geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
+ GEOSGeometry *geom2 = GEOSInterpolate(geom1_, 1);
+ ensure_equals(GEOSisEmpty(geom2), 1);
+ GEOSGeom_destroy(geom2);
+ }
+} // namespace tut
diff --git a/tests/unit/linearref/LengthIndexedLineTest.cpp b/tests/unit/linearref/LengthIndexedLineTest.cpp
index b9aebb6..23c5e3a 100644
--- a/tests/unit/linearref/LengthIndexedLineTest.cpp
+++ b/tests/unit/linearref/LengthIndexedLineTest.cpp
@@ -470,5 +470,15 @@ void object::test<28>()
}
#endif
+template<>
+template<>
+void object::test<29>()
+{
+ GeomPtr linearGeom(reader.read("LINESTRING EMPTY"));
+ LengthIndexedLine indexedLine(linearGeom.get());
+ Coordinate pt = indexedLine.extractPoint(100);
+ ensure(pt.isNull());
+}
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
src/linearref/LinearLocation.cpp | 3 ++
tests/unit/Makefile.am | 3 +-
...EOSSimplifyTest.cpp => GEOSInterpolateTest.cpp} | 34 ++++++++--------------
tests/unit/linearref/LengthIndexedLineTest.cpp | 10 +++++++
4 files changed, 27 insertions(+), 23 deletions(-)
copy tests/unit/capi/{GEOSSimplifyTest.cpp => GEOSInterpolateTest.cpp} (56%)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list