Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //bad code for StackOverflow question (http://goo.gl/Szsa5) DO NOT USE IT!
- #include <vector>
- #include <boost/range.hpp>
- #include <boost/geometry.hpp>
- #include <boost/geometry/geometries/polygon.hpp>
- using namespace boost::geometry;
- typedef boost::geometry::model::point
- <
- double, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree>
- > spherical_point;
- //[in] resultVector: this should be the result of an intersection
- //[out] x, y: these arrays contain the result coordinates
- //[out] count: this should be the length of the arrays
- void PolygonToArrays(std::vector<model::polygon<spherical_point> > resultVector, double x[], double y[], int *count)
- {
- *count = resultVector.size();
- x = (double*) malloc(sizeof(double) * *count);
- y = (double*) malloc(sizeof(double) * *count);
- int i = 0;
- for (std::vector<model::polygon<spherical_point> >::iterator it = resultVector.begin(); it != resultVector.end(); ++it)
- {
- if (boost::size(*it) >= 2)
- {
- //and here comes the problematic part...
- typedef typename boost::range_iterator<model::ring<spherical_point> >::type iterator;
- for (iterator current = boost::begin(*it); current != boost::end(*it); ++current)
- {
- x[i] = get<0>(current);
- y[i] = get<1>(current);
- i++;
- }
- //I only need the first polygon, so let's break here
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement