Reputation: 429
In the past, I use library GGL to write some programs. For example, the following code works well with GGL and old version of gcc. Now I update gcc to gcc4.7.1. my program appear errors during compiling. Thus, I update to the latest version of boost 1.52.1. there are still errors related to point_2d, polygon_2d etc. I found that some files like 'cartesian2d.hpp','c_array_cartesian.hpp' are missing in the latest vesion boost.
Could someone help me to analyze the following code and tell me what's the problem? Thanks a lot.
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/algorithms/distance.hpp>
#include <boost/geometry/geometry.hpp>
#include <algorithm> // for reverse, unique
#include <iostream>
#include <string>
typedef boost::geometry::model::d2::point_xy<double,
boost::geometry::cs::cartesian> point_2d;
typedef boost::geometry::model::polygon<point_2d> polygon_2d;
using namespace boost::geometry;
int main() {
std::cout << "!!!Hello World!!!" << std::endl; // prints !!!Hello World!!!
model::d2::point_xy<int> p1(1.0, 1.0), p2(2.0, 2.0);
point_2d x(3.0,3.0);
std::cout << x.x();
std::cout << "Distance p1-p2 is: " << distance(p1, p2) <<std::endl;
float width = 100;
float length = 100;
polygon_2d poly;
{
const float coor[][2] = {
{-350.0,-500.0}, {350,-500}, {350, 0}, {width/2.0, 0}, {width/2.0, length},
{350, length}, {350, 1000}, {-350, 1000}, {-350, length}, {-1*width/2.0, length}, {-1*width/2.0,0},
{-350, 0}, {-350.0,-500.0} // closing point is opening point
};
assign(poly, coor);
}
correct(poly);
return 0;
}
The errors are as following:
c:\program files\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/
../../../../include/boost/geometry/core/point_order.hpp:1
57:12: required from 'const boost::geometry::order_selector
boost::geometry::point_order<float [13][2]>::value'
c:\program files\mingw64\bin\../lib/gcc/x86_64-w64-
mingw32/4.7.1/../../../../include/boost/geometry/algorithms/
assign.hpp:148:70: required from 'void
boost::geometry::assign(Geometry1&, const Geometry2&) [with
Geometry1 =boost::geometry::model::polygon<boost::geometry::model
::d2::point_xy<double, boost::geometry::cs::cartesian> >;
Geometry2 = float [13][2]]'
..\src\test.cpp:47:44: required from here
c:\program files\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/
../../../../include/boost/geometry/core/point_order.hpp:95:5:
error: no matching function for call to
'assertion_failed(mpl_::failed************
(boost::geometry::core_dispatch::point_order<void, float [13]
[2]>::NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE::************)
(mpl_::assert_::types<float [13][2], mpl_::na, mpl_::na,
mpl_::na>))'
Upvotes: 2
Views: 461
Reputation: 1057
Two changes are necessary:
1) include c_array.hpp, to adapt the 2D float array (used inside the const float[][2]) to the Boost.Geometry Point Concept:
#include <boost/geometry/geometries/adapted/c_array.hpp>
2) Use assign_points instead of assign.
assign_points(poly, coor);
Your code then compiles. Background: you were using a pre-release version (of course allowed), at release small changes were made in the interface. assign (with a range) is now called assign_points.
Upvotes: 3