13#include <boost/geometry.hpp>
14#include <boost/geometry/geometries/point_xy.hpp>
15#include <boost/geometry/geometries/linestring.hpp>
16#include <boost/geometry/geometries/polygon.hpp>
17#include <boost/geometry/geometries/multi_polygon.hpp>
18#include <boost/geometry/index/rtree.hpp>
23 namespace bg = boost::geometry;
24 namespace bgi = boost::geometry::index;
26 using Point = bg::model::d2::point_xy<double>;
28 using Ring = bg::model::ring<Point, true, true>;
29 using Polygon = bg::model::polygon<Point, true, true>;
31 using Box = bg::model::box<Point>;
41 using Line3 = std::vector<Point3>;
49 out.reserve(line.size());
50 for (
const auto &p : line) {
51 bg::append(out,
To2D(p));
57 return bg::length(line);
78 std::vector<Polygon>
Polygonize(
const std::vector<LineString> &edges);
87 bg::centroid(polygon, c);
92 return std::hypot(bg::get<0>(b) - bg::get<0>(a), bg::get<1>(b) - bg::get<1>(a));
97 while (angle <= -M_PI) angle += 2.0 * M_PI;
98 while (angle > M_PI) angle -= 2.0 * M_PI;
LineString Substring(const LineString &line, double from, double to)
The piece of line between distances from and to, shapely's substring: endpoints are inserted so the c...
double Length(const LineString &line)
LineString OffsetLine(const LineString &line, double offset)
Offset line sideways by offset metres, positive to the left.
bg::model::ring< Point, true, true > Ring
Point Centroid(const Polygon &polygon)
Point Interpolate(const LineString &line, double s)
Point at distance s along line, shapely's LineString.interpolate.
std::vector< Polygon > Polygonize(const std::vector< LineString > &edges)
Build polygons from a set of noded edges, shapely's polygonize.
double HeadingAt(const LineString &line, double s)
Heading of line at distance s, in radians.
std::vector< Point3 > Line3
bg::model::linestring< Point > LineString
MultiPolygon UnaryUnion(const std::vector< Polygon > &polygons)
double NormalizeAngle(double angle)
Signed angle in (-pi, pi] that turns heading from into heading to.
double Hypot(const Point &a, const Point &b)
bg::model::multi_polygon< Polygon > MultiPolygon
bg::model::d2::point_xy< double > Point
bg::model::polygon< Point, true, true > Polygon
bg::model::box< Point > Box
Point To2D(const Point3 &p)
double Project(const LineString &line, const Point &p)
Distance along line of the projection of p, shapely's LineString.project.
Polygon MakeValid(const Polygon &polygon)
bg::is_valid plus a correction pass, shapely's make_valid.