[geos-commits] [SCM] GEOS branch 3.8 updated. c01c8c1c30091d655ba888790c2daeec1f33bae3

git at osgeo.org git at osgeo.org
Wed Feb 5 10:43:35 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, 3.8 has been updated
       via  c01c8c1c30091d655ba888790c2daeec1f33bae3 (commit)
      from  c2a683d19b72d092f11f59e6063dfdf1cb739d9a (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 c01c8c1c30091d655ba888790c2daeec1f33bae3
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)
    
    Fixes #1013

diff --git a/NEWS b/NEWS
index 440d266..b634f11 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ Changes in 3.8.1
   - Avoid assertion failure with MSVC 2017 / 2019 (#1002, Dan Baston)
   - Remove whitespace from end of GEOSversion() output (azhi)
   - Improve performance of GEOSisValid (#1008, Dan Baston)
+  - Avoid changing MultiLineString component order in GEOSReverse
+    (#1013, Dan Baston)
 
 Changes in 3.8.0
 2019-10-10
diff --git a/src/geom/MultiLineString.cpp b/src/geom/MultiLineString.cpp
index 592f38a..3b6991c 100644
--- a/src/geom/MultiLineString.cpp
+++ b/src/geom/MultiLineString.cpp
@@ -126,14 +126,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));
 }
 
 } // namespace geos::geom
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:
 NEWS                                           |  2 ++
 src/geom/MultiLineString.cpp                   | 16 +++++++++-------
 tests/unit/capi/GEOSReverseTest.cpp            |  2 +-
 tests/unit/linearref/LengthIndexedLineTest.cpp |  2 +-
 4 files changed, 13 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list