PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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