[geos-commits] [SCM] GEOS branch main updated. 152e6f7cd1a17aa565ae3c44c6a42310e8496845
git at osgeo.org
git at osgeo.org
Wed May 22 21:17:22 PDT 2024
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, main has been updated
via 152e6f7cd1a17aa565ae3c44c6a42310e8496845 (commit)
from 147616518549be54b318b3987a6ca329bac9781e (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 152e6f7cd1a17aa565ae3c44c6a42310e8496845
Author: Martin Davis <mtnclimb at gmail.com>
Date: Wed May 22 21:17:04 2024 -0700
Add GeosOp options --select and --selectNot (#1100)
diff --git a/util/geosop/GeometryOp.cpp b/util/geosop/GeometryOp.cpp
index f5fa28b91..37085bf29 100644
--- a/util/geosop/GeometryOp.cpp
+++ b/util/geosop/GeometryOp.cpp
@@ -1082,6 +1082,18 @@ Result::isGeometry() {
return typeCode == typeGeometry;
}
+bool
+Result::isBool() {
+ return typeCode == typeBool;
+}
+
+bool
+Result::toBool() {
+ if (typeCode == typeBool)
+ return valBool;
+ return false;
+}
+
bool
Result::isGeometryList() {
return typeCode == typeGeomList;
diff --git a/util/geosop/GeometryOp.h b/util/geosop/GeometryOp.h
index 1dad1016a..9ffc7f853 100644
--- a/util/geosop/GeometryOp.h
+++ b/util/geosop/GeometryOp.h
@@ -46,6 +46,9 @@ public:
static std::string code(int typeCode);
+ bool isBool();
+ bool toBool();
+
bool isGeometry();
bool isGeometryList();
std::string metadata();
diff --git a/util/geosop/GeosOp.cpp b/util/geosop/GeosOp.cpp
index 4e50cdc7d..5774d7a77 100644
--- a/util/geosop/GeosOp.cpp
+++ b/util/geosop/GeosOp.cpp
@@ -89,6 +89,8 @@ int main(int argc, char** argv) {
("p,precision", "Set number of decimal places in output coordinates", cxxopts::value<int>( cmdArgs.precision ) )
("q,quiet", "Disable result output", cxxopts::value<bool>( cmdArgs.isQuiet ) )
("r,repeat", "Repeat operation N times", cxxopts::value<int>( cmdArgs.repeatNum ) )
+ ("select", "Select geometries where op result is true", cxxopts::value<bool>( cmdArgs.isSelect ) )
+ ("selectNot", "Select geometries where op result is false", cxxopts::value<bool>( cmdArgs.isSelectNot ) )
("t,time", "Print execution time", cxxopts::value<bool>( cmdArgs.isShowTime ) )
("v,verbose", "Verbose output", cxxopts::value<bool>( cmdArgs.isVerbose )->default_value("false"))
("h,help", "Print help")
@@ -439,8 +441,7 @@ void GeosOp::executeUnary(GeometryOp * op, OpArguments& opArgs) {
for (unsigned i = 0; i < geomA.size(); i++) {
vertexCount += geomA[i]->getNumPoints();
Result* result = executeOpRepeat(op, i, geomA[i], 0, nullptr, opArgs);
-
- output(result);
+ output(result, geomA[i].get());
delete result;
}
}
@@ -452,7 +453,7 @@ void GeosOp::executeBinary(GeometryOp * op, OpArguments& opArgs) {
vertexCount += geomB[ib]->getNumPoints();
Result* result = executeOpRepeat(op, ia, geomA[ia], ib, geomB[ib], opArgs);
- output(result);
+ output(result, geomA[ia].get());
delete result;
}
}
@@ -512,7 +513,7 @@ Result* GeosOp::executeOp(GeometryOp * op,
return result;
}
-void GeosOp::output(Result* result) {
+void GeosOp::output(Result* result, Geometry* geom) {
//---- print result if format specified
if (args.isQuiet)
return;
@@ -528,6 +529,18 @@ void GeosOp::output(Result* result) {
else if (result->isGeometryList() ) {
outputGeometryList( result->valGeomList );
}
+ else if (result->isBool() ) {
+ if (args.isSelect || args.isSelectNot) {
+ bool isSelected = (args.isSelect && result->toBool())
+ || (args.isSelectNot && ! result->toBool());
+ if (isSelected) {
+ outputGeometry( geom );
+ }
+ }
+ else {
+ std::cout << result->toString() << std::endl;
+ }
+ }
else {
// output as text/WKT
std::cout << result->toString() << std::endl;
diff --git a/util/geosop/GeosOp.h b/util/geosop/GeosOp.h
index 3fe373700..3bfd16cb1 100644
--- a/util/geosop/GeosOp.h
+++ b/util/geosop/GeosOp.h
@@ -50,6 +50,8 @@ public:
int offsetA = -1;
bool isCollect = true;
bool isExplode = false;
+ bool isSelect = false;
+ bool isSelectNot = false;
std::string srcB;
@@ -91,7 +93,7 @@ private:
unsigned int indexA, const std::unique_ptr<Geometry>& geomA,
unsigned int indexB, const std::unique_ptr<Geometry>& geomB,
OpArguments& opArgs);
- void output(Result* result);
+ void output(Result* result, Geometry* geom);
void outputExplode(std::unique_ptr<Geometry>& geom);
void outputGeometry( const Geometry* geom);
void outputGeometryList(std::vector<std::unique_ptr<const Geometry>> & val);
-----------------------------------------------------------------------
Summary of changes:
util/geosop/GeometryOp.cpp | 12 ++++++++++++
util/geosop/GeometryOp.h | 3 +++
util/geosop/GeosOp.cpp | 21 +++++++++++++++++----
util/geosop/GeosOp.h | 4 +++-
4 files changed, 35 insertions(+), 5 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list