@@ -119,6 +119,19 @@ class LineString {
119119 Point<double > interpolate (double distance) const ;
120120 Point<double > centroid () const ;
121121 Polygon<double > buffer (double distance) const ;
122+
123+ // -- Boundary (Python: .boundary) --
124+ std::string boundary () const ;
125+
126+ // -- Minimum clearance (Python: .minimum_clearance) --
127+ double minimum_clearance () const ;
128+
129+ // -- Envelope (Python: .envelope) --
130+ Polygon<double > envelope () const ;
131+
132+ // -- Representative point (Python: .representative_point) --
133+ Point<double > representative_point () const ;
134+
122135 void normalize ();
123136
124137 // -- Constructive operations (Python: difference, union, intersection, sym_difference) --
@@ -131,9 +144,9 @@ class LineString {
131144 std::string union_op (const LineString& other) const ;
132145 template <typename U> std::string union_op (const Point<U>& other) const ;
133146 template <typename U> std::string union_op (const Polygon<U>& other) const ;
134- std::string sym_difference (const LineString& other) const ;
135- template <typename U> std::string sym_difference (const Point<U>& other) const ;
136- template <typename U> std::string sym_difference (const Polygon<U>& other) const ;
147+ std::string symmetric_difference (const LineString& other) const ;
148+ template <typename U> std::string symmetric_difference (const Point<U>& other) const ;
149+ template <typename U> std::string symmetric_difference (const Polygon<U>& other) const ;
137150 std::string simplify (double tolerance) const ;
138151 std::string parallel_offset (double distance, int quad_segs = 16 ) const ;
139152 Polygon<double > convex_hull () const ;
@@ -372,7 +385,7 @@ template <typename T> template <typename U> std::string LineString<T>::OP(const
372385LS_CONSTRUCT (difference, geos_difference)
373386LS_CONSTRUCT (intersection, geos_intersection)
374387LS_CONSTRUCT (union_op, geos_union)
375- LS_CONSTRUCT (sym_difference , geos_sym_difference)
388+ LS_CONSTRUCT (symmetric_difference , geos_sym_difference)
376389#undef LS_CONSTRUCT
377390
378391// Python: base.py::simplify:L469
@@ -404,6 +417,44 @@ Polygon<double> LineString<T>::convex_hull() const {
404417 return Polygon<double >(c.data (), n, 2 );
405418}
406419
420+ // Python: shapely/geometry/base.py::boundary:L457
421+ template <typename T>
422+ std::string LineString<T>::boundary() const {
423+ auto res = detail::geos_boundary (geos_linestring_.get ());
424+ return res ? detail::geos_to_wkt (res.get ()) : " GEOMETRYCOLLECTION EMPTY" ;
425+ }
426+
427+ // Python: shapely/geometry/base.py::minimum_clearance:L734
428+ template <typename T>
429+ double LineString<T>::minimum_clearance() const {
430+ return detail::geos_minimum_clearance (geos_linestring_.get ());
431+ }
432+
433+ // Python: shapely/geometry/base.py::envelope:L742
434+ template <typename T>
435+ Polygon<double > LineString<T>::envelope() const {
436+ auto res = detail::geos_envelope (geos_linestring_.get ());
437+ if (!res || res->isEmpty ()) return Polygon<double >();
438+ auto * gp = dynamic_cast <geos::geom::Polygon*>(res.get ());
439+ if (!gp) return Polygon<double >();
440+ auto * cs = gp->getExteriorRing ()->getCoordinatesRO ();
441+ if (!cs || cs->isEmpty ()) return Polygon<double >();
442+ size_t n = cs->getSize ();
443+ std::vector<double > c (n*2 );
444+ for (size_t i = 0 ; i < n; ++i) { c[i*2 ]=cs->getAt (i).x ; c[i*2 +1 ]=cs->getAt (i).y ; }
445+ return Polygon<double >(c.data (), n, 2 );
446+ }
447+
448+ // Python: shapely/geometry/base.py::representative_point:L877
449+ template <typename T>
450+ Point<double > LineString<T>::representative_point() const {
451+ auto res = detail::geos_representative_point (geos_linestring_.get ());
452+ if (!res || res->isEmpty ()) return Point<double >(0 , 0 );
453+ auto * pt = dynamic_cast <geos::geom::Point*>(res.get ());
454+ if (!pt) return Point<double >(0 , 0 );
455+ return Point<double >(pt->getX (), pt->getY ());
456+ }
457+
407458// Python: base.py::normalize:L663
408459template <typename T>
409460void LineString<T>::normalize() { geos_linestring_->normalize (); }
0 commit comments