/Src/Dependencies/Boost/libs/geometry/doc/src/examples/algorithms/intersects_linestring.cpp

http://hadesmem.googlecode.com/ · C++ · 46 lines · 15 code · 13 blank · 18 comment · 0 complexity · e889b4a22961a34873d40ec667eb856b MD5 · raw file

  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // QuickBook Example
  3. // Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //[intersects_linestring
  8. //` Check if two linestrings intersect each other
  9. #include <iostream>
  10. #include <boost/geometry.hpp>
  11. #include <boost/geometry/geometries/linestring.hpp>
  12. #include <boost/geometry/geometries/point_xy.hpp>
  13. #include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
  14. int main()
  15. {
  16. // Calculate the intersects of a cartesian polygon
  17. typedef boost::geometry::model::d2::point_xy<double> P;
  18. boost::geometry::model::linestring<P> line1, line2;
  19. boost::geometry::read_wkt("linestring(1 1,2 2,3 3)", line1);
  20. boost::geometry::read_wkt("linestring(2 1,1 2,4 0)", line2);
  21. bool b = boost::geometry::intersects(line1, line2);
  22. std::cout << "Intersects: " << (b ? "YES" : "NO") << std::endl;
  23. return 0;
  24. }
  25. //]
  26. //[intersects_linestring_output
  27. /*`
  28. Output:
  29. [pre
  30. Intersects: YES
  31. ]
  32. */
  33. //]