[geos-commits] r4151 - in branches/3.4: . 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:51:00 PST 2016
Author: strk
Date: 2016-02-24 03:51:00 -0800 (Wed, 24 Feb 2016)
New Revision: 4151
Modified:
branches/3.4/NEWS
branches/3.4/include/geos/algorithm/PointLocator.h
branches/3.4/src/algorithm/PointLocator.cpp
branches/3.4/src/geom/prep/PreparedPoint.cpp
branches/3.4/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
Closes #764 (3.4 branch)
Reverts r4132
Modified: branches/3.4/NEWS
===================================================================
--- branches/3.4/NEWS 2016-02-24 11:50:47 UTC (rev 4150)
+++ branches/3.4/NEWS 2016-02-24 11:51:00 UTC (rev 4151)
@@ -18,6 +18,7 @@
- Update for Microsoft NMAKE (r4063)
- Fix compilation issues while building with Visual C++ (#701)
- Fix support of PHP bindings for version < 5.4.0 (#709)
+ - Fix incorrect return from prepared multipoint intersects (#764)
Changes in 3.4.2
2013-08-25
Modified: branches/3.4/include/geos/algorithm/PointLocator.h
===================================================================
--- branches/3.4/include/geos/algorithm/PointLocator.h 2016-02-24 11:50:47 UTC (rev 4150)
+++ branches/3.4/include/geos/algorithm/PointLocator.h 2016-02-24 11:51:00 UTC (rev 4151)
@@ -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.4/src/algorithm/PointLocator.cpp
===================================================================
--- branches/3.4/src/algorithm/PointLocator.cpp 2016-02-24 11:50:47 UTC (rev 4150)
+++ branches/3.4/src/algorithm/PointLocator.cpp 2016-02-24 11:51:00 UTC (rev 4151)
@@ -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.4/src/geom/prep/PreparedPoint.cpp
===================================================================
--- branches/3.4/src/geom/prep/PreparedPoint.cpp 2016-02-24 11:50:47 UTC (rev 4150)
+++ branches/3.4/src/geom/prep/PreparedPoint.cpp 2016-02-24 11:51:00 UTC (rev 4151)
@@ -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.4/tests/unit/algorithm/PointLocatorTest.cpp
===================================================================
--- branches/3.4/tests/unit/algorithm/PointLocatorTest.cpp 2016-02-24 11:50:47 UTC (rev 4150)
+++ branches/3.4/tests/unit/algorithm/PointLocatorTest.cpp 2016-02-24 11:51:00 UTC (rev 4151)
@@ -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