@@ -24,6 +24,12 @@ template <typename T> class LineString;
2424#ifndef SHAPELY_GEOMETRY_POINT_DEFINED
2525template <typename T> class Point ;
2626#endif
27+ #ifndef SHAPELY_GEOMETRY_POLYGON_DEFINED
28+ template <typename T> class Polygon ;
29+ #endif
30+ #ifndef SHAPELY_GEOMETRY_MULTIPOLYGON_DEFINED
31+ template <typename T> class MultiPolygon ;
32+ #endif
2733
2834template <typename T = double >
2935class MultiLineString {
@@ -43,6 +49,8 @@ class MultiLineString {
4349 // -- Distance --
4450 template <typename U> double distance (const Point<U>& other) const ;
4551 template <typename U> double distance (const LineString<U>& other) const ;
52+ template <typename U> double distance (const Polygon<U>& other) const ;
53+ template <typename U> double distance (const MultiPolygon<U>& other) const ;
4654 double distance (const MultiLineString& other) const ;
4755
4856 // -- Predicates --
@@ -125,6 +133,7 @@ class MultiLineString {
125133 template <typename U> friend class Point ;
126134 template <typename U> friend class LineString ;
127135 template <typename U> friend class Polygon ;
136+ template <typename U> friend class MultiPolygon ;
128137 std::unique_ptr<geos::geom::MultiLineString> geos_mls_;
129138 geos::geom::GeometryFactory::Ptr factory_;
130139};
@@ -140,6 +149,8 @@ class MultiLineString {
140149
141150#include " shapely/geometry/point.h"
142151#include " shapely/geometry/linestring.h"
152+ #include " shapely/geometry/polygon.h"
153+ #include " shapely/geometry/multipolygon.h"
143154#include " shapely/geometry/base.h"
144155#include < geos/geom/Point.h>
145156#include < geos/geom/LineString.h>
@@ -200,6 +211,14 @@ template <typename T>
200211double MultiLineString<T>::distance(const MultiLineString& o) const {
201212 geos::operation::distance::DistanceOp op (geos_mls_.get (), o.geos_mls_ .get ()); return op.distance ();
202213}
214+ template <typename T> template <typename U>
215+ double MultiLineString<T>::distance(const Polygon<U>& o) const {
216+ geos::operation::distance::DistanceOp op (geos_mls_.get (), o.geos_polygon_ .get ()); return op.distance ();
217+ }
218+ template <typename T> template <typename U>
219+ double MultiLineString<T>::distance(const MultiPolygon<U>& o) const {
220+ geos::operation::distance::DistanceOp op (geos_mls_.get (), o.geos_mp_ .get ()); return op.distance ();
221+ }
203222
204223// -- Predicates (macros) ----------------------------------------------------
205224#define MLS_PRED_PT (METHOD, GEOS_FN ) \
0 commit comments