[geos-commits] [SCM] GEOS branch main updated. c693615c05bb473a4640c95e0203b8e0a81a2134

git at osgeo.org git at osgeo.org
Thu Oct 28 16:33:28 PDT 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, main has been updated
       via  c693615c05bb473a4640c95e0203b8e0a81a2134 (commit)
       via  89397ea6a812095f30c512ebf12b5136b7d40e3c (commit)
      from  befc941dc739f78148b643b3e184a55384dfae99 (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 c693615c05bb473a4640c95e0203b8e0a81a2134
Merge: befc941dc 89397ea6a
Author: mdavis <mtnclimb at gmail.com>
Date:   Thu Oct 28 16:33:26 2021 -0700

    Merge pull request 'Add SnappingNoder seeding' (!116) from mdavis/geos:add-snappingnoder-seeding into main
    
    Reviewed-on: https://git.osgeo.org/gitea/geos/geos/pulls/116


commit 89397ea6a812095f30c512ebf12b5136b7d40e3c
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Mon Oct 18 14:59:57 2021 -0700

    Add SnappingNoder seeding

diff --git a/include/geos/noding/snap/SnappingNoder.h b/include/geos/noding/snap/SnappingNoder.h
index 71662b71f..b55a35053 100644
--- a/include/geos/noding/snap/SnappingNoder.h
+++ b/include/geos/noding/snap/SnappingNoder.h
@@ -73,6 +73,9 @@ private:
     std::vector<SegmentString*>* nodedResult;
 
     // Methods
+
+    void seedSnapIndex(std::vector<SegmentString*>& segStrings);
+
     void snapVertices(std::vector<SegmentString*>& segStrings, std::vector<SegmentString*>& nodedStrings);
 
     SegmentString* snapVertices(SegmentString* ss);
@@ -115,6 +118,3 @@ public:
 } // namespace geos::noding::snap
 } // namespace geos::noding
 } // namespace geos
-
-
-
diff --git a/src/noding/snap/SnappingNoder.cpp b/src/noding/snap/SnappingNoder.cpp
index bf3a84270..451cd11cd 100644
--- a/src/noding/snap/SnappingNoder.cpp
+++ b/src/noding/snap/SnappingNoder.cpp
@@ -24,6 +24,8 @@
 #include <geos/noding/snap/SnappingNoder.h>
 #include <geos/noding/snap/SnappingIntersectionAdder.h>
 
+//#include <geos/profiler.h>
+
 #include <algorithm> // for std::min and std::max
 #include <memory>
 
@@ -53,13 +55,44 @@ SnappingNoder::computeNodes(std::vector<SegmentString*>* inputSegStrings)
 void
 SnappingNoder::snapVertices(std::vector<SegmentString*>& segStrings, std::vector<SegmentString*>& nodedStrings)
 {
+    //geos::util::Profiler* profiler = geos::util::Profiler::instance();
+    //auto sw = profiler->get(std::string("SnappingNoder::snapVertices"));
+    //sw->start();
+
+    seedSnapIndex(segStrings);
     for (SegmentString* ss: segStrings) {
         nodedStrings.push_back(snapVertices(ss));
     }
+
+    //sw->stop();
+    //std::cout << sw->name << " - " << sw->getTotFormatted() << std::endl;
 }
 
 
 /*private*/
+void
+SnappingNoder::seedSnapIndex(std::vector<SegmentString*>& segStrings)
+{
+    double PHI_INV = (sqrt(5) - 1.0) / 2.0;
+
+    for (SegmentString* ss: segStrings) {
+        CoordinateSequence* cs = ss->getCoordinates();
+        int numPts = (int) cs->size();
+        int numPtsToLoad = numPts / 100;
+        double rand = 0.0;
+
+        for (int i = 0; i < numPtsToLoad; i++) {
+            // quasi-random sequennce generated by additive recurrence with irrational constant
+            rand = rand + PHI_INV;
+            if (rand > 1) rand = rand - floor(rand);
+
+            int index = (int) (numPts * rand);
+            snapIndex.snap(cs->getAt(index));
+        }
+    }
+}
+
+/*private*/
 SegmentString*
 SnappingNoder::snapVertices(SegmentString* ss)
 {

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

Summary of changes:
 include/geos/noding/snap/SnappingNoder.h |  6 +++---
 src/noding/snap/SnappingNoder.cpp        | 33 ++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list