Advertisement
Guest User

pointinpoly.cxx

a guest
Mar 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #include <boost/geometry.hpp>
  2. #include <boost/geometry/geometries/point_xy.hpp>
  3. #include <boost/geometry/geometries/polygon.hpp>
  4. #include <iostream>
  5.  
  6. using namespace boost::geometry;
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     typedef model::d2::point_xy<double> pointtype;
  12.     pointtype point1(3, 3);
  13.     pointtype point2(2, 12.1);
  14.  
  15.     model::polygon<pointtype> poly;
  16.     pointtype points[] = {pointtype(0, 0), pointtype(0, 10), pointtype(5, 15),
  17.                           pointtype(10, 10), pointtype(10, 0), pointtype(0, 0)};
  18.     append(poly, points);
  19.  
  20.     cout << wkt(point1) << " is "
  21.          << (within(point1, poly) ? "inside" : "outside of") << " the "
  22.          << wkt(poly) << endl;
  23.     cout << wkt(point2) << " is "
  24.          << (within(point2, poly) ? "inside" : "outside of") << " the "
  25.          << wkt(poly) << endl;
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement