[geos-commits] [SCM] GEOS branch master updated. 5326316a0daee792def110941c6e656068c8c2bf

git at osgeo.org git at osgeo.org
Fri Jan 8 08:54:52 PST 2021


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  5326316a0daee792def110941c6e656068c8c2bf (commit)
      from  946a75daa4e48b392297e07f45ac0730e2c832e8 (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 5326316a0daee792def110941c6e656068c8c2bf
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Fri Jan 8 08:54:46 2021 -0800

    Fix geosop op help and negative args

diff --git a/util/geosop/GeomFunction.cpp b/util/geosop/GeomFunction.cpp
index 05185b1..9c55d22 100644
--- a/util/geosop/GeomFunction.cpp
+++ b/util/geosop/GeomFunction.cpp
@@ -179,7 +179,7 @@ GeomFunction::init()
             geos::operation::polygonize::Polygonizer p;
             p.add(geom.get());
 
-            auto polys = p.getPolygons();
+            std::vector<std::unique_ptr<Polygon>> polys = p.getPolygons();
             std::vector<std::unique_ptr<const Geometry>> geoms;
             for(unsigned int i = 0; i < polys.size(); i++) {
                 geoms.push_back( std::move(polys[i]) );
diff --git a/util/geosop/GeosOp.cpp b/util/geosop/GeosOp.cpp
index 034312e..5f04bb0 100644
--- a/util/geosop/GeosOp.cpp
+++ b/util/geosop/GeosOp.cpp
@@ -57,6 +57,15 @@ void showHelp() {
     std::cout << "Usage: geosop [wktfile] opname args..." << std::endl;
 }
 
+static bool startsWith(const std::string& s, const std::string& prefix) {
+    return s.size() >= prefix.size() && s.compare(0, prefix.size(), prefix) == 0;
+}
+
+static bool endsWith(const std::string& str, const std::string& suffix)
+{
+    return str.size() >= suffix.size() && 0 == str.compare(str.size()-suffix.size(), suffix.size(), suffix);
+}
+
 int main(int argc, char** argv) {
     GeomFunction::init();
 
@@ -86,9 +95,13 @@ int main(int argc, char** argv) {
         if (result.count("help")) {
             std::cout << "geosop - GEOS v. " << geosversion() << std::endl;
         }
+        options.positional_help("opName opArg");
         std::cout << options.help() << std::endl;
         //showHelp();
         if (result.count("help")) {
+            std::cout << "Notes:" << std::endl;
+            std::cout << "- Negative numeric op arguments can be specified with leading N:  e.g. N-0.1" << std::endl;
+            std::cout << std::endl;
             std::cout << "Operations:" << std::endl;
             std::vector<std::string> ops = GeomFunction::list();
             for (auto opName : ops) {
@@ -122,6 +135,13 @@ int main(int argc, char** argv) {
         auto& v = result["opArgs"].as<std::vector<std::string>>();
         if (v.size() >= 1) {
             auto val = v[0];
+            /**
+             * To get around cmdline parset limitation for parsing neg numbers,
+             * allow syntax "Nnum" as well
+             */
+            if (startsWith(val, "N")) {
+                val = val.substr(1, val.size()-1);
+            }
             cmdArgs.opArg1 = std::stod(val);
         }
     }
@@ -148,15 +168,6 @@ std::string timeFormatted(int n)
     return fmt + " usec";
 }
 
-static bool startsWith(const std::string& s, const std::string& prefix) {
-    return s.size() >= prefix.size() && s.compare(0, prefix.size(), prefix) == 0;
-}
-
-static bool endsWith(const std::string& str, const std::string& suffix)
-{
-    return str.size() >= suffix.size() && 0 == str.compare(str.size()-suffix.size(), suffix.size(), suffix);
-}
-
 std::vector<std::unique_ptr<Geometry>> collect( std::vector<std::unique_ptr<Geometry>>& geoms ) {
     auto gf = GeometryFactory::create();
     auto gc = gf->createGeometryCollection( std::move(geoms) );

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

Summary of changes:
 util/geosop/GeomFunction.cpp |  2 +-
 util/geosop/GeosOp.cpp       | 29 ++++++++++++++++++++---------
 2 files changed, 21 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list