[geos-commits] r3527 - in branches/3.3: .
include/geos/noding/snapround src/noding/snapround tests/unit
tests/unit/noding tests/unit/noding/snapround
svn_geos at osgeo.org
svn_geos at osgeo.org
Tue Dec 6 12:26:09 EST 2011
Author: strk
Date: 2011-12-06 09:26:09 -0800 (Tue, 06 Dec 2011)
New Revision: 3527
Added:
branches/3.3/tests/unit/noding/snapround/
branches/3.3/tests/unit/noding/snapround/HotPixelTest.cpp
Modified:
branches/3.3/NEWS
branches/3.3/include/geos/noding/snapround/HotPixel.h
branches/3.3/src/noding/snapround/HotPixel.cpp
branches/3.3/tests/unit/Makefile.am
Log:
HotPixel: do not invalidate reference to original point. Fixes #498.
Modified: branches/3.3/NEWS
===================================================================
--- branches/3.3/NEWS 2011-12-02 09:44:40 UTC (rev 3526)
+++ branches/3.3/NEWS 2011-12-06 17:26:09 UTC (rev 3527)
@@ -8,6 +8,7 @@
- Fix handling of collapsed edges skipping in BufferOp (#494)
- Print up to 18 digits of precision for TopologyException points
- Fix noding with reduced precision in Buffer operation (#473)
+ - Fix HotPixel original point invalidation (#498)
Changes in 3.3.1
2011-09-27
Modified: branches/3.3/include/geos/noding/snapround/HotPixel.h
===================================================================
--- branches/3.3/include/geos/noding/snapround/HotPixel.h 2011-12-02 09:44:40 UTC (rev 3526)
+++ branches/3.3/include/geos/noding/snapround/HotPixel.h 2011-12-06 17:26:09 UTC (rev 3527)
@@ -153,7 +153,8 @@
/**
* Creates a new hot pixel.
*
- * @param pt the coordinate at the centre of the pixel
+ * @param pt the coordinate at the centre of the pixel.
+ * Will be kept by reference, so make sure to keep it alive.
* @param scaleFact the scaleFactor determining the pixel size
* @param li the intersector to use for testing intersection with
* line segments
Modified: branches/3.3/src/noding/snapround/HotPixel.cpp
===================================================================
--- branches/3.3/src/noding/snapround/HotPixel.cpp 2011-12-02 09:44:40 UTC (rev 3526)
+++ branches/3.3/src/noding/snapround/HotPixel.cpp 2011-12-06 17:26:09 UTC (rev 3527)
@@ -43,7 +43,7 @@
:
li(newLi),
pt(newPt),
- originalPt(pt),
+ originalPt(newPt),
scaleFactor(newScaleFactor)
{
if (scaleFactor != 1.0) {
Modified: branches/3.3/tests/unit/Makefile.am
===================================================================
--- branches/3.3/tests/unit/Makefile.am 2011-12-02 09:44:40 UTC (rev 3526)
+++ branches/3.3/tests/unit/Makefile.am 2011-12-06 17:26:09 UTC (rev 3527)
@@ -62,7 +62,7 @@
geom/MultiPolygonTest.cpp \
geom/PointTest.cpp \
geom/PolygonTest.cpp \
- geom/PrecisionModelTest.cpp \
+ geom/PrecisionModelTest.cpp \
geom/prep/PreparedGeometryFactoryTest.cpp \
geom/TriangleTest.cpp \
geom/util/GeometryExtracterTest.cpp \
@@ -77,6 +77,7 @@
noding/NodedSegmentStringTest.cpp \
noding/SegmentNodeTest.cpp \
noding/SegmentPointComparatorTest.cpp \
+ noding/snapround/HotPixelTest.cpp \
operation/buffer/BufferOpTest.cpp \
operation/buffer/BufferParametersTest.cpp \
operation/distance/DistanceOpTest.cpp \
Added: branches/3.3/tests/unit/noding/snapround/HotPixelTest.cpp
===================================================================
--- branches/3.3/tests/unit/noding/snapround/HotPixelTest.cpp (rev 0)
+++ branches/3.3/tests/unit/noding/snapround/HotPixelTest.cpp 2011-12-06 17:26:09 UTC (rev 3527)
@@ -0,0 +1,95 @@
+//
+// Test Suite for geos::noding::snapround::HotPixel class.
+
+#include <tut.hpp>
+// geos
+#include <geos/algorithm/LineIntersector.h>
+#include <geos/noding/snapround/HotPixel.h>
+#include <geos/geom/Coordinate.h>
+#include <geos/geom/Envelope.h>
+// std
+#include <memory>
+
+namespace tut
+{
+ //
+ // Test Group
+ //
+
+ // Common data used by all tests
+ struct test_hotpixel_data
+ {
+
+ typedef geos::geom::Coordinate Coordinate;
+ typedef geos::geom::Envelope Envelope;
+ typedef geos::algorithm::LineIntersector LineIntersector;
+ typedef geos::noding::snapround::HotPixel HotPixel;
+
+ test_hotpixel_data() {}
+ };
+
+ typedef test_group<test_hotpixel_data> group;
+ typedef group::object object;
+
+ group test_hotpixel_group("geos::noding::snapround::HotPixel");
+
+ //
+ // Test Cases
+ //
+
+ // Test with scaleFactor=1
+ template<>
+ template<>
+ void object::test<1>()
+ {
+
+ LineIntersector li;
+ Coordinate pt(10, 10);
+ HotPixel hp(pt, 1, li);
+
+ ensure_equals(hp.getCoordinate(), pt);
+
+ const Envelope& env = hp.getSafeEnvelope();
+ ensure_equals(env.toString(), "Env[9.25:10.75,9.25:10.75]");
+
+ Coordinate p0(0, 10);
+ Coordinate p1(20, 10);
+ ensure( "hp.intersects 0 10, 20 10", hp.intersects(p0, p1) );
+
+ p1.y = 11; // intersection point within 0.75 distance
+ ensure( "hp.intersects(0 10, 20 11)", hp.intersects(p0, p1));
+
+ p1.y = 20;
+ ensure_not( "!hp.intersects(0 10, 20 20)", hp.intersects(p0, p1));
+
+ }
+
+ // Test with scaleFactor=10
+ // See http://trac.osgeo.org/geos/ticket/498
+ template<>
+ template<>
+ void object::test<2>()
+ {
+
+ LineIntersector li;
+ Coordinate pt(10, 10);
+ HotPixel hp(pt, 10, li);
+
+ ensure_equals(hp.getCoordinate(), pt);
+
+ const Envelope& env = hp.getSafeEnvelope();
+ ensure_equals(env.toString(), "Env[9.925:10.075,9.925:10.075]");
+
+ Coordinate p0(0, 10);
+ Coordinate p1(20, 10);
+ ensure( "hp.intersects 0 10, 20 10", hp.intersects(p0, p1) );
+
+ p1.y = 11; // intersection point not within 0.075 distance
+ ensure_not( "hp.intersects(0 10, 20 11)", hp.intersects(p0, p1));
+
+ }
+
+ // TODO: test addSnappedNode !
+
+
+} // namespace tut
More information about the geos-commits
mailing list