[geos-commits] r2317 - in trunk/source:
headers/geos/noding/snapround noding/snapround
svn_geos at osgeo.org
svn_geos at osgeo.org
Tue Apr 7 07:11:33 EDT 2009
Author: strk
Date: 2009-04-07 07:11:33 -0400 (Tue, 07 Apr 2009)
New Revision: 2317
Modified:
trunk/source/headers/geos/noding/snapround/HotPixel.h
trunk/source/headers/geos/noding/snapround/HotPixel.inl
trunk/source/noding/snapround/HotPixel.cpp
Log:
Sync HotPixel to JTS-1.9 (rev 1.3); fix a few bugs and use standard algorithms for min/max
Modified: trunk/source/headers/geos/noding/snapround/HotPixel.h
===================================================================
--- trunk/source/headers/geos/noding/snapround/HotPixel.h 2009-04-07 10:48:10 UTC (rev 2316)
+++ trunk/source/headers/geos/noding/snapround/HotPixel.h 2009-04-07 11:11:33 UTC (rev 2317)
@@ -13,7 +13,7 @@
*
**********************************************************************
*
- * Last port: noding/snapround/HotPixel.java rev. 1.2 (JTS-1.7)
+ * Last port: noding/snapround/HotPixel.java rev. 1.3 (JTS-1.9)
*
**********************************************************************/
@@ -33,6 +33,9 @@
namespace algorithm {
class LineIntersector;
}
+ namespace noding {
+ class NodedSegmentString;
+ }
}
namespace geos {
@@ -60,6 +63,9 @@
const geom::Coordinate& originalPt;
geom::Coordinate ptScaled;
+ mutable geom::Coordinate p0Scaled;
+ mutable geom::Coordinate p1Scaled;
+
double scaleFactor;
double minx;
@@ -151,6 +157,15 @@
bool intersects(const geom::Coordinate& p0,
const geom::Coordinate& p1) const;
+ /**
+ * Adds a new node (equal to the snap pt) to the specified segment
+ * if the segment passes through the hot pixel
+ *
+ * @param segStr
+ * @param segIndex
+ * @return true if a node was added to the segment
+ */
+ bool addSnappedNode(NodedSegmentString& segStr, size_t segIndex);
};
Modified: trunk/source/headers/geos/noding/snapround/HotPixel.inl
===================================================================
--- trunk/source/headers/geos/noding/snapround/HotPixel.inl 2009-04-07 10:48:10 UTC (rev 2316)
+++ trunk/source/headers/geos/noding/snapround/HotPixel.inl 2009-04-07 11:11:33 UTC (rev 2317)
@@ -11,6 +11,10 @@
* by the Free Software Foundation.
* See the COPYING file for more information.
*
+ **********************************************************************
+ *
+ * Last port: noding/snapround/HotPixel.java rev. 1.3 (JTS-1.9)
+ *
**********************************************************************/
#ifndef GEOS_NODING_SNAPROUND_HOTPIXEL_INL
Modified: trunk/source/noding/snapround/HotPixel.cpp
===================================================================
--- trunk/source/noding/snapround/HotPixel.cpp 2009-04-07 10:48:10 UTC (rev 2316)
+++ trunk/source/noding/snapround/HotPixel.cpp 2009-04-07 11:11:33 UTC (rev 2317)
@@ -13,11 +13,12 @@
*
**********************************************************************
*
- * Last port: noding/snapround/HotPixel.java rev. 1.2 (JTS-1.7)
+ * Last port: noding/snapround/HotPixel.java rev. 1.3 (JTS-1.9)
*
**********************************************************************/
#include <geos/noding/snapround/HotPixel.h>
+#include <geos/noding/NodedSegmentString.h>
#include <geos/algorithm/LineIntersector.h>
#include <geos/geom/Coordinate.h>
@@ -25,6 +26,7 @@
# include "geos/noding/snapround/HotPixel.inl"
#endif
+#include <algorithm> // for std::min and std::max
#include <cassert>
#include <memory>
@@ -74,7 +76,12 @@
maxx = pt.x + tolerance;
miny = pt.y - tolerance;
maxy = pt.y + tolerance;
- corner.assign(4, Coordinate(minx, maxy));
+
+ corner.resize(4);
+ corner[0] = Coordinate(maxx, maxy);
+ corner[1] = Coordinate(minx, maxy);
+ corner[2] = Coordinate(minx, miny);
+ corner[4] = Coordinate(maxx, maxy);
}
bool
@@ -83,9 +90,6 @@
{
if (scaleFactor == 1.0) return intersectsScaled(p0, p1);
- Coordinate p0Scaled;
- Coordinate p1Scaled;
-
copyScaled(p0, p0Scaled);
copyScaled(p1, p1Scaled);
@@ -97,13 +101,11 @@
const Coordinate& p1) const
{
-#define MIN(x,y) (x)<(y)?(x):(y)
+ double segMinx = std::min(p0.x, p1.x);
+ double segMaxx = std::max(p0.x, p1.x);
+ double segMiny = std::min(p0.y, p1.y);
+ double segMaxy = std::max(p0.y, p1.y);
- double segMinx = MIN(p0.x, p1.x);
- double segMaxx = MIN(p0.x, p1.x);
- double segMiny = MIN(p0.y, p1.y);
- double segMaxy = MIN(p0.y, p1.y);
-
bool isOutsidePixelEnv = maxx < segMinx
|| minx > segMaxx
|| maxy < segMiny
@@ -166,7 +168,22 @@
return false;
}
+bool
+HotPixel::addSnappedNode(NodedSegmentString& segStr, size_t segIndex)
+{
+ const Coordinate& p0 = segStr.getCoordinate(segIndex);
+ const Coordinate& p1 = segStr.getCoordinate(segIndex + 1);
+ if (intersects(p0, p1))
+ {
+ //cout << "snapped: " << snapPt << endl;
+ segStr.addIntersection(getCoordinate(), segIndex);
+ return true;
+ }
+ return false;
+}
+
+
} // namespace geos.noding.snapround
} // namespace geos.noding
} // namespace geos
More information about the geos-commits
mailing list