[geos-commits] r4150 - in branches/3.5: . include/geos/algorithm src/algorithm src/geom/prep tests/unit/algorithm
svn_geos at osgeo.org
svn_geos at osgeo.org
Wed Feb 24 03:50:47 PST 2016
Author: strk
Date: 2016-02-24 03:50:47 -0800 (Wed, 24 Feb 2016)
New Revision: 4150
Modified:
branches/3.5/NEWS
branches/3.5/include/geos/algorithm/PointLocator.h
branches/3.5/src/algorithm/PointLocator.cpp
branches/3.5/src/geom/prep/PreparedPoint.cpp
branches/3.5/tests/unit/algorithm/PointLocatorTest.cpp
Log:
Fix incorrect return from PreparedPoint::intersects
Includes unit test
Patch by Daniel Baston via
https://github.com/libgeos/libgeos/pull/60
See #764 (for 3.5 branch)
Reverts r4081
Modified: branches/3.5/NEWS
===================================================================
--- branches/3.5/NEWS 2016-02-24 11:39:07 UTC (rev 4149)
+++ branches/3.5/NEWS 2016-02-24 11:50:47 UTC (rev 4150)
@@ -8,6 +8,7 @@
- Fix snapping of last segment of a closed linestring (#758)
- Fix memory exhaustion case in isvalid (#757)
- Fix Windows build with Visual Studio 2008 (#766)
+ - Fix incorrect return from prepared multipoint intersects (#764)
Changes in 3.5.0
2015-08-15
Modified: branches/3.5/include/geos/algorithm/PointLocator.h
===================================================================
--- branches/3.5/include/geos/algorithm/PointLocator.h 2016-02-24 11:39:07 UTC (rev 4149)
+++ branches/3.5/include/geos/algorithm/PointLocator.h 2016-02-24 11:50:47 UTC (rev 4150)
@@ -31,6 +31,7 @@
class LinearRing;
class LineString;
class Polygon;
+ class Point;
}
}
@@ -93,6 +94,8 @@
void updateLocationInfo(int loc);
+ int locate(const geom::Coordinate& p, const geom::Point *pt);
+
int locate(const geom::Coordinate& p, const geom::LineString *l);
int locateInPolygonRing(const geom::Coordinate& p, const geom::LinearRing *ring);
Modified: branches/3.5/src/algorithm/PointLocator.cpp
===================================================================
--- branches/3.5/src/algorithm/PointLocator.cpp 2016-02-24 11:39:07 UTC (rev 4149)
+++ branches/3.5/src/algorithm/PointLocator.cpp 2016-02-24 11:50:47 UTC (rev 4150)
@@ -20,6 +20,7 @@
#include <geos/algorithm/PointLocator.h>
#include <geos/algorithm/CGAlgorithms.h>
#include <geos/geom/Geometry.h>
+#include <geos/geom/Point.h>
#include <geos/geom/LineString.h>
#include <geos/geom/LinearRing.h>
#include <geos/geom/MultiLineString.h>
@@ -61,9 +62,12 @@
void
PointLocator::computeLocation(const Coordinate& p, const Geometry *geom)
{
-
- if (const LineString *ls=dynamic_cast<const LineString*>(geom))
+ if (const Point *pt=dynamic_cast<const Point*>(geom))
{
+ updateLocationInfo(locate(p, pt));
+ }
+ else if (const LineString *ls=dynamic_cast<const LineString*>(geom))
+ {
updateLocationInfo(locate(p, ls));
}
else if (const Polygon *po=dynamic_cast<const Polygon*>(geom))
@@ -111,6 +115,17 @@
/* private */
int
+PointLocator::locate(const Coordinate& p, const Point *pt)
+{
+ // no point in doing envelope test, since equality test is just as fast
+ const Coordinate *ptCoord = pt->getCoordinate();
+ if (ptCoord->equals2D(p))
+ return Location::INTERIOR;
+ return Location::EXTERIOR;
+}
+
+/* private */
+int
PointLocator::locate(const Coordinate& p, const LineString *l)
{
const CoordinateSequence* pt=l->getCoordinatesRO();
Modified: branches/3.5/src/geom/prep/PreparedPoint.cpp
===================================================================
--- branches/3.5/src/geom/prep/PreparedPoint.cpp 2016-02-24 11:39:07 UTC (rev 4149)
+++ branches/3.5/src/geom/prep/PreparedPoint.cpp 2016-02-24 11:50:47 UTC (rev 4150)
@@ -18,7 +18,6 @@
#include <geos/geom/prep/PreparedPoint.h>
-#include <geos/geom/Point.h>
namespace geos {
namespace geom { // geos.geom
@@ -29,10 +28,6 @@
{
if (! envelopesIntersect( g)) return false;
- const Point *pt_geom = dynamic_cast<const Point *>(g);
- if (pt_geom)
- return getGeometry().equals(g);
-
// This avoids computing topology for the test geometry
return isAnyTargetComponentInTest( g);
}
Modified: branches/3.5/tests/unit/algorithm/PointLocatorTest.cpp
===================================================================
--- branches/3.5/tests/unit/algorithm/PointLocatorTest.cpp 2016-02-24 11:39:07 UTC (rev 4149)
+++ branches/3.5/tests/unit/algorithm/PointLocatorTest.cpp 2016-02-24 11:50:47 UTC (rev 4150)
@@ -96,8 +96,15 @@
runPtLocator(Location::EXTERIOR, Coordinate(11, 11),
"LINEARRING(10 10, 10 20, 20 10, 10 10)");
}
-
+ // 5 - TestPointLocator Point inside MultiPoint
+ template<>
+ template<>
+ void object::test<5>()
+ {
+ runPtLocator(Location::INTERIOR, Coordinate(0, 0),
+ "MULTIPOINT ((1 1), (0 0))");
+ }
} // namespace tut
More information about the geos-commits
mailing list