[geos-commits] r4149 - in trunk: 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:39:07 PST 2016
Author: strk
Date: 2016-02-24 03:39:07 -0800 (Wed, 24 Feb 2016)
New Revision: 4149
Modified:
trunk/include/geos/algorithm/PointLocator.h
trunk/src/algorithm/PointLocator.cpp
trunk/src/geom/prep/PreparedPoint.cpp
trunk/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
Reverts r4081
Modified: trunk/include/geos/algorithm/PointLocator.h
===================================================================
--- trunk/include/geos/algorithm/PointLocator.h 2016-02-22 17:24:16 UTC (rev 4148)
+++ trunk/include/geos/algorithm/PointLocator.h 2016-02-24 11:39:07 UTC (rev 4149)
@@ -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: trunk/src/algorithm/PointLocator.cpp
===================================================================
--- trunk/src/algorithm/PointLocator.cpp 2016-02-22 17:24:16 UTC (rev 4148)
+++ trunk/src/algorithm/PointLocator.cpp 2016-02-24 11:39:07 UTC (rev 4149)
@@ -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: trunk/src/geom/prep/PreparedPoint.cpp
===================================================================
--- trunk/src/geom/prep/PreparedPoint.cpp 2016-02-22 17:24:16 UTC (rev 4148)
+++ trunk/src/geom/prep/PreparedPoint.cpp 2016-02-24 11:39:07 UTC (rev 4149)
@@ -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: trunk/tests/unit/algorithm/PointLocatorTest.cpp
===================================================================
--- trunk/tests/unit/algorithm/PointLocatorTest.cpp 2016-02-22 17:24:16 UTC (rev 4148)
+++ trunk/tests/unit/algorithm/PointLocatorTest.cpp 2016-02-24 11:39:07 UTC (rev 4149)
@@ -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