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

git at osgeo.org git at osgeo.org
Tue Sep 29 16:59:11 PDT 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  fd5f9496f229a489612f0422208dd60d04a77b62 (commit)
      from  f457440f8fb3883546d292f8873cbe67d23a6bef (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 fd5f9496f229a489612f0422208dd60d04a77b62
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Sep 29 16:58:56 2020 -0700

    Improve HotPixel memory usage by dropping some fields https://github.com/locationtech/jts/commit/02f0a258778c840dc257879c18697f2544445f59

diff --git a/include/geos/noding/snapround/HotPixel.h b/include/geos/noding/snapround/HotPixel.h
index 1121419..a694a96 100644
--- a/include/geos/noding/snapround/HotPixel.h
+++ b/include/geos/noding/snapround/HotPixel.h
@@ -71,16 +71,15 @@ private:
     static constexpr int LOWER_LEFT  = 2;
     static constexpr int LOWER_RIGHT = 3;
 
-    geom::Coordinate ptHot;
     geom::Coordinate originalPt;
+    double scaleFactor;
 
+    /* Indicates if this hot pixel must be a node in the output. */
     bool hpIsNode;
-    double scaleFactor;
 
-    double minx;
-    double maxx;
-    double miny;
-    double maxy;
+    /* The scaled ordinates of the hot pixel point */
+    double hpx;
+    double hpy;
 
     double scaleRound(double val) const;
     geom::Coordinate scaleRound(const geom::Coordinate& p) const;
diff --git a/src/noding/snapround/HotPixel.cpp b/src/noding/snapround/HotPixel.cpp
index d0f90cd..c9740e8 100644
--- a/src/noding/snapround/HotPixel.cpp
+++ b/src/noding/snapround/HotPixel.cpp
@@ -40,22 +40,19 @@ namespace noding { // geos.noding
 namespace snapround { // geos.noding.snapround
 
 HotPixel::HotPixel(const Coordinate& newPt, double newScaleFactor)
-    : ptHot(newPt)
-    , originalPt(newPt)
+    : originalPt(newPt)
     , hpIsNode(false)
     , scaleFactor(newScaleFactor)
+    , hpx(newPt.x)
+    , hpy(newPt.y)
 {
     if(scaleFactor <= 0.0) {
         throw util::IllegalArgumentException("Scale factor must be non-zero");
     }
     if(scaleFactor != 1.0) {
-        ptHot = scaleRound(newPt);
+        hpx = scaleRound(newPt.x);
+        hpy = scaleRound(newPt.y);
     }
-
-    minx = ptHot.x - TOLERANCE;
-    maxx = ptHot.x + TOLERANCE;
-    miny = ptHot.y - TOLERANCE;
-    maxy = ptHot.y + TOLERANCE;
 }
 
 /*public*/
@@ -71,13 +68,13 @@ HotPixel::intersects(const Coordinate& p) const
 {
     double x = scale(p.x);
     double y = scale(p.y);
-    if (x >= maxx) return false;
+    if (x >= hpx + TOLERANCE) return false;
     // check Left side
-    if (x < minx) return false;
+    if (x < hpx - TOLERANCE) return false;
     // check Top side
-    if (y >= maxy) return false;
+    if (y >= hpy + TOLERANCE) return false;
     // check Bottom side
-    if (y < miny) return false;
+    if (y < hpy - TOLERANCE) return false;
     // finally
     return true;
 }
@@ -120,15 +117,19 @@ HotPixel::intersectsScaled(double p0x, double p0y, double p1x, double p1y) const
     * are open (not part of the pixel).
     */
     // check Right side
+    double maxx = hpx + TOLERANCE;
     double segMinx = std::min(px, qx);
     if (segMinx >= maxx) return false;
     // check Left side
+    double minx = hpx - TOLERANCE;
     double segMaxx = std::max(px, qx);
     if (segMaxx < minx) return false;
     // check Top side
+    double maxy = hpy + TOLERANCE;
     double segMiny = std::min(py, qy);
     if (segMiny >= maxy) return false;
     // check Bottom side
+    double miny = hpy - TOLERANCE;
     double segMaxy = std::max(py, qy);
     if (segMaxy < miny) return false;
 
@@ -208,6 +209,12 @@ HotPixel::intersectsPixelClosure(const Coordinate& p0, const Coordinate& p1) con
 {
     LineIntersector li;
     std::array<Coordinate, 4> corner;
+
+    double minx = hpx - TOLERANCE;
+    double maxx = hpx + TOLERANCE;
+    double miny = hpy - TOLERANCE;
+    double maxy = hpy + TOLERANCE;
+
     corner[UPPER_RIGHT] = Coordinate(maxx, maxy);
     corner[UPPER_LEFT]  = Coordinate(minx, maxy);
     corner[LOWER_LEFT]  = Coordinate(minx, miny);
@@ -237,7 +244,7 @@ HotPixel::intersectsPixelClosure(const Coordinate& p0, const Coordinate& p1) con
 std::ostream&
 HotPixel::operator<< (std::ostream& os)
 {
-    os << "HP(" << io::WKTWriter::toPoint(ptHot) << ")";
+    os << "HP(" << io::WKTWriter::toPoint(originalPt) << ")";
     return os;
 }
 

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

Summary of changes:
 include/geos/noding/snapround/HotPixel.h | 11 +++++------
 src/noding/snapround/HotPixel.cpp        | 33 +++++++++++++++++++-------------
 2 files changed, 25 insertions(+), 19 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list