Advertisement
obernardovieira

Point in Polygin (boost) (simple test)

Oct 3rd, 2013
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3.  
  4. #include <thread>
  5. #include <chrono>
  6.  
  7. #include <boost/geometry.hpp>
  8. #include <boost/geometry/geometries/point_xy.hpp>
  9. #include <boost/geometry/geometries/polygon.hpp>
  10.  
  11. //#include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
  12.  
  13. long long timestamp()
  14. {
  15.     return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
  16. }
  17.  
  18. int main()
  19. {
  20.     typedef boost::geometry::model::d2::point_xy<double> point_type;
  21.     typedef boost::geometry::model::polygon<point_type> polygon_type;
  22.  
  23.     long long time_sleep_um = timestamp();
  24.  
  25.     std::cout << time_sleep_um << std::endl;
  26.  
  27.     polygon_type poly;
  28.     boost::geometry::read_wkt(
  29.         "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
  30.             "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", poly);
  31.  
  32.     point_type p(40, 1);
  33.  
  34.     std::cout << "within: " << (boost::geometry::within(p, poly) ? "yes" : "no") << std::endl;
  35.  
  36.     //std::this_thread::sleep_for(std::chrono::milliseconds(500));
  37.     //--------------
  38.     long long time_sleep_dois = timestamp();
  39.  
  40.     std::cout << time_sleep_dois << std::endl;
  41.     std::cout << "Tempo de execucao " << time_sleep_dois - time_sleep_um << " milisegundos" << std::endl;
  42.    
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement