19 #include <boost/geometry.hpp>
20 #include <boost/geometry/geometries/point_xy.hpp>
21 #include <boost/geometry/geometries/polygon.hpp>
23 using namespace boost::geometry;
29 typedef model::d2::point_xy<double>
point_t;
32 void init_from(
const std::vector<double>& x,
const std::vector<double>& y);
33 void get_points(std::vector<double>& xpos, std::vector<double>& ypos);
38 if (x.size() != y.size())
40 "Polygon::Polygon(const std::vector<double>& x, const std::vector<double>& y) "
41 "Error. Sizes of arrays must conincide.");
42 std::vector<point_t> points;
43 for (
size_t i = 0; i < x.size(); ++i)
44 points.push_back(
point_t(x[i], y[i]));
45 assign_points(polygon, points);
53 for (
auto it = polygon.outer().begin(); it != polygon.outer().end(); ++it) {
55 xpos.push_back(boost::geometry::get<0>(*it));
56 ypos.push_back(boost::geometry::get<1>(*it));
80 std::vector<double> x;
81 std::vector<double> y;
82 for (
size_t i = 0; i < points.size(); ++i) {
83 if (points[i].size() != 2)
85 "Polygon(const std::vector<std::vector<double> >& points) -> Error. "
86 " Should be two-dimensional array with second dimension of 2 size.");
87 x.push_back(points[i][0]);
88 y.push_back(points[i][1]);
123 ostr << wkt<PolygonPrivate::polygon_t>(
m_d->
polygon);
Defines structs Bin1D, Bin1DCVector.
Defines many exception classes in namespace Exceptionss.
Basic class for all shapes in 2D.
The private data for polygons to hide boost dependency from the header.
model::polygon< point_t > polygon_t
model::d2::point_xy< double > point_t
void init_from(const std::vector< double > &x, const std::vector< double > &y)
void get_points(std::vector< double > &xpos, std::vector< double > &ypos)
virtual bool contains(double x, double y) const
Returns true if point with given coordinates is inside or on border of the shape.
void getPoints(std::vector< double > &xpos, std::vector< double > &ypos) const
virtual void print(std::ostream &ostr) const
Polygon(const std::vector< double > x, const std::vector< double > y)
double getMidPoint() const