1 |
|
---|
2 | #include <boost/geometry.hpp>
|
---|
3 | #include <boost/geometry/geometries/geometries.hpp>
|
---|
4 |
|
---|
5 | namespace bg = boost::geometry;
|
---|
6 |
|
---|
7 | typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
|
---|
8 | typedef bg::model::linestring<point_t> linestring_t;
|
---|
9 |
|
---|
10 | int main()
|
---|
11 | {
|
---|
12 | point_t p;
|
---|
13 | bg::read_wkt("POINT(5000000 5000000)", p);
|
---|
14 |
|
---|
15 | linestring_t l1;
|
---|
16 | bg::read_wkt("LINESTRING(5000000 4000000, 4000000 5000000)", l1);
|
---|
17 |
|
---|
18 | linestring_t l2;
|
---|
19 | bg::read_wkt("LINESTRING(5000000 4000000, 4000000 5000000, 0 9000000)", l2);
|
---|
20 |
|
---|
21 | std::cout << bg::distance(p, l1) << std::endl;
|
---|
22 | std::cout << bg::distance(p, l2) << std::endl;
|
---|
23 | }
|
---|
24 |
|
---|