1 // Boost.Geometry
2
3 // Copyright (c) 2018 Yaghyavardhan Singh Khangarot, Hyderabad, India.
4
5 // Contributed and/or modified by Yaghyavardhan Singh Khangarot, as part of Google Summer of Code 2018 program.
6
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #include <vector>
12
13 #include <boost/geometry/geometries/linestring.hpp>
14 #include <boost/geometry/geometries/point_xy.hpp>
15 #include <boost/geometry/geometries/polygon.hpp>
16
17 #include "test_frechet_distance.hpp"
18
19 template <typename P>
test_all_cartesian()20 void test_all_cartesian()
21 {
22 typedef bg::model::linestring<P> linestring_2d;
23 #ifdef BOOST_GEOMETRY_TEST_DEBUG
24 typedef typename coordinate_system<P>::type CordType;
25 std::cout << typeid(CordType).name() << std::endl;
26 #endif
27
28 test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)", 3);
29 test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)",bg::strategy::distance::pythagoras<>(), 3);
30 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)",0);
31 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(1 1, 0 1, 0 0, 1 0, 1 1)",sqrt(2.0));
32 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 0)",0);
33 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(1 1, 0 0, 1 0, 1 1)",sqrt(2.0));
34 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0)","LINESTRING(0 0, 1 0)",0);
35 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0,3 4,4 3)","LINESTRING(4 3,3 4,0 0)",5);
36
37
38 }
39
40 template <typename P>
test_all_geographic()41 void test_all_geographic()
42 {
43 typedef bg::model::linestring<P> linestring_2d;
44
45 #ifdef BOOST_GEOMETRY_TEST_DEBUG
46 typedef typename coordinate_system<P>::type CordType;
47 std::cout << typeid(CordType).name() << std::endl;
48 #endif
49
50 test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)", 333958);
51 test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)",bg::strategy::distance::geographic<bg::strategy::vincenty>(), 333958.472379679);
52 test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)",bg::strategy::distance::geographic<bg::strategy::thomas>(), 333958.472379679);
53 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)",0);
54 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(1 1, 0 1, 0 0, 1 0, 1 1)",156898);
55 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 0)",0);
56 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(1 1, 0 0, 1 0, 1 1)",156898);
57 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0)","LINESTRING(0 0, 1 0)",0);
58 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0,3 4,4 3)","LINESTRING(4 3,3 4,0 0)",555093);
59
60 }
61
62 template <typename P>
test_all_spherical_equ()63 void test_all_spherical_equ()
64 {
65 typedef bg::model::linestring<P> linestring_2d;
66
67 #ifdef BOOST_GEOMETRY_TEST_DEBUG
68 typedef typename coordinate_system<P>::type CordType;
69 std::cout << typeid(CordType).name() << std::endl;
70 #endif
71
72 test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)", 0.05235987);
73 test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)",bg::strategy::distance::haversine<int>(), 0.05235987);
74 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)",0);
75 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(1 1, 0 1, 0 0, 1 0, 1 1)",0.02468205);
76 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 0)",0);
77 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(1 1, 0 0, 1 0, 1 1)",0.02468205);
78 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0)","LINESTRING(0 0, 1 0)",0);
79 test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0,3 4,4 3)","LINESTRING(4 3,3 4,0 0)",0.0872409);
80
81 }
82
test_main(int,char * [])83 int test_main(int, char* [])
84 {
85 //Cartesian Coordinate System
86 test_all_cartesian<bg::model::d2::point_xy<double,bg::cs::cartesian> >();
87
88 //Geographic Coordinate System
89 test_all_geographic<bg::model::d2::point_xy<double,bg::cs::geographic<bg::degree> > >();
90
91 //Spherical_Equatorial Coordinate System
92 test_all_spherical_equ<bg::model::d2::point_xy<double,bg::cs::spherical_equatorial<bg::degree> > >();
93
94 return 0;
95 }
96