[geos-commits] [SCM] GEOS branch master updated. da0cb7bf9f7d3ce50edace9fa370b22c48e0e685

git at osgeo.org git at osgeo.org
Wed Feb 5 10:40:05 PST 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  da0cb7bf9f7d3ce50edace9fa370b22c48e0e685 (commit)
      from  545f6452bd758fdbdc2e09bf2062da25c58b6462 (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 da0cb7bf9f7d3ce50edace9fa370b22c48e0e685
Author: Dan Baston <dbaston at gmail.com>
Date:   Thu Jan 30 10:32:25 2020 -0500

    Retain component order in MultiLineString::reverse
    
    Updated for consistency with the behavior of other geometry types (as
    changed in https://github.com/locationtech/jts/pull/513)

diff --git a/src/geom/MultiLineString.cpp b/src/geom/MultiLineString.cpp
index 29b158d..901ceef 100644
--- a/src/geom/MultiLineString.cpp
+++ b/src/geom/MultiLineString.cpp
@@ -125,14 +125,16 @@ MultiLineString::reverse() const
         return clone();
     }
 
-    size_t nLines = geometries.size();
-    std::vector<std::unique_ptr<Geometry>> revLines(nLines);
+    std::vector<std::unique_ptr<Geometry>> reversed(geometries.size());
 
-    for(size_t i = 0; i < nLines; ++i) {
-        const LineString* iLS = static_cast<LineString*>(geometries[i].get());
-        revLines[nLines - 1 - i] = iLS->reverse();
-    }
-    return getFactory()->createMultiLineString(std::move(revLines));
+    std::transform(geometries.begin(),
+                   geometries.end(),
+                   reversed.begin(),
+                   [](const std::unique_ptr<Geometry> & g) {
+                       return g->reverse();
+                   });
+
+    return getFactory()->createMultiLineString(std::move(reversed));
 }
 
 const LineString*
diff --git a/tests/unit/capi/GEOSReverseTest.cpp b/tests/unit/capi/GEOSReverseTest.cpp
index 76c60d4..42d218f 100644
--- a/tests/unit/capi/GEOSReverseTest.cpp
+++ b/tests/unit/capi/GEOSReverseTest.cpp
@@ -95,7 +95,7 @@ void object::test<4>
 ()
 {
     testReverse("MULTILINESTRING ((1 1, 2 2), (3 3, 4 4))",
-                "MULTILINESTRING ((4 4, 3 3), (2 2, 1 1))");
+                "MULTILINESTRING ((2 2, 1 1), (4 4, 3 3))");
 }
 
 template<>
diff --git a/tests/unit/linearref/LengthIndexedLineTest.cpp b/tests/unit/linearref/LengthIndexedLineTest.cpp
index 2fd9034..f85dcec 100644
--- a/tests/unit/linearref/LengthIndexedLineTest.cpp
+++ b/tests/unit/linearref/LengthIndexedLineTest.cpp
@@ -331,7 +331,7 @@ void object::test<16>
 ()
 {
     checkExtractLine("MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))",
-                     19, 1, "MULTILINESTRING ((29 0, 25 0, 20 0), (10 0, 1 0))");
+                     19, 1, "MULTILINESTRING ((10 0, 1 0), (29 0, 25 0, 20 0))");
 }
 
 // testExtractLineNegative()

-----------------------------------------------------------------------

Summary of changes:
 src/geom/MultiLineString.cpp                   | 16 +++++++++-------
 tests/unit/capi/GEOSReverseTest.cpp            |  2 +-
 tests/unit/linearref/LengthIndexedLineTest.cpp |  2 +-
 3 files changed, 11 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list