Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / geometry / test / algorithms / distance.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
7
8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14
15
16 #include <string>
17 #include <sstream>
18
19 #include <algorithms/test_distance.hpp>
20
21 #include <boost/mpl/if.hpp>
22 #include <boost/array.hpp>
23
24 #include <boost/geometry/geometries/geometries.hpp>
25 #include <boost/geometry/geometries/point_xy.hpp>
26 #include <boost/geometry/geometries/adapted/c_array.hpp>
27 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
28
29 #include <test_common/test_point.hpp>
30 #include <test_geometries/custom_segment.hpp>
31 #include <test_geometries/wrapped_boost_array.hpp>
32
33 // includes for multi-geometries
34 #include <boost/geometry/multi/geometries/multi_point.hpp>
35 #include <boost/geometry/multi/geometries/multi_linestring.hpp>
36 #include <boost/geometry/multi/geometries/multi_polygon.hpp>
37 #include <boost/geometry/multi/io/wkt/read.hpp>
38
39 #include <boost/variant/variant.hpp>
40
41 BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
42 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
43
44 // Register boost array as a linestring
45 namespace boost { namespace geometry { namespace traits
46 {
47 template <typename Point, std::size_t PointCount>
48 struct tag< boost::array<Point, PointCount> >
49 {
50     typedef linestring_tag type;
51 };
52
53 }}}
54
55 template <typename P>
56 void test_distance_point()
57 {
58     namespace services = bg::strategy::distance::services;
59     typedef typename bg::default_distance_result<P>::type return_type;
60
61     // Basic, trivial test
62
63     P p1;
64     bg::set<0>(p1, 1);
65     bg::set<1>(p1, 1);
66
67     P p2;
68     bg::set<0>(p2, 2);
69     bg::set<1>(p2, 2);
70
71     return_type d = bg::distance(p1, p2);
72     BOOST_CHECK_CLOSE(d, return_type(1.4142135), 0.001);
73
74     // Test specifying strategy manually
75     typename services::default_strategy
76         <
77             bg::point_tag, bg::point_tag, P
78         >::type strategy;
79
80     d = bg::distance(p1, p2, strategy);
81     BOOST_CHECK_CLOSE(d, return_type(1.4142135), 0.001);
82
83     {
84         // Test custom strategy
85         BOOST_CONCEPT_ASSERT( (bg::concept::PointDistanceStrategy<taxicab_distance, P, P>) );
86
87         typedef typename services::return_type<taxicab_distance, P, P>::type cab_return_type;
88         BOOST_MPL_ASSERT((boost::is_same<cab_return_type, typename bg::coordinate_type<P>::type>));
89
90         taxicab_distance tcd;
91         cab_return_type d = bg::distance(p1, p2, tcd);
92
93         BOOST_CHECK( bg::math::abs(d - cab_return_type(2)) <= cab_return_type(0.01) );
94     }
95
96     {
97         // test comparability
98
99         typedef typename services::default_strategy
100             <
101                 bg::point_tag, bg::point_tag, P
102             >::type strategy_type;
103         typedef typename services::comparable_type<strategy_type>::type comparable_strategy_type;
104
105         strategy_type strategy;
106         comparable_strategy_type comparable_strategy = services::get_comparable<strategy_type>::apply(strategy);
107         return_type comparable = services::result_from_distance<comparable_strategy_type, P, P>::apply(comparable_strategy, 3);
108
109         BOOST_CHECK_CLOSE(comparable, return_type(9), 0.001);
110     }
111 }
112
113 template <typename P>
114 void test_distance_segment()
115 {
116     typedef typename bg::default_distance_result<P>::type return_type;
117
118     P s1; bg::set<0>(s1, 1); bg::set<1>(s1, 1);
119     P s2; bg::set<0>(s2, 4); bg::set<1>(s2, 4);
120
121     // Check points left, right, projected-left, projected-right, on segment
122     P p1; bg::set<0>(p1, 0); bg::set<1>(p1, 1);
123     P p2; bg::set<0>(p2, 1); bg::set<1>(p2, 0);
124     P p3; bg::set<0>(p3, 3); bg::set<1>(p3, 1);
125     P p4; bg::set<0>(p4, 1); bg::set<1>(p4, 3);
126     P p5; bg::set<0>(p5, 3); bg::set<1>(p5, 3);
127
128     bg::model::referring_segment<P const> const seg(s1, s2);
129
130     return_type d1 = bg::distance(p1, seg);
131     return_type d2 = bg::distance(p2, seg);
132     return_type d3 = bg::distance(p3, seg);
133     return_type d4 = bg::distance(p4, seg);
134     return_type d5 = bg::distance(p5, seg);
135
136     BOOST_CHECK_CLOSE(d1, return_type(1), 0.001);
137     BOOST_CHECK_CLOSE(d2, return_type(1), 0.001);
138     BOOST_CHECK_CLOSE(d3, return_type(1.4142135), 0.001);
139     BOOST_CHECK_CLOSE(d4, return_type(1.4142135), 0.001);
140     BOOST_CHECK_CLOSE(d5, return_type(0), 0.001);
141
142     // Reverse case: segment/point instead of point/segment
143     return_type dr1 = bg::distance(seg, p1);
144     return_type dr2 = bg::distance(seg, p2);
145
146     BOOST_CHECK_CLOSE(dr1, d1, 0.001);
147     BOOST_CHECK_CLOSE(dr2, d2, 0.001);
148
149     // Test specifying strategy manually:
150     // 1) point-point-distance
151     typename bg::strategy::distance::services::default_strategy
152         <
153             bg::point_tag, bg::point_tag, P
154         >::type pp_strategy;
155     d1 = bg::distance(p1, seg, pp_strategy);
156     BOOST_CHECK_CLOSE(d1, return_type(1), 0.001);
157
158     // 2) point-segment-distance
159     typename bg::strategy::distance::services::default_strategy
160         <
161             bg::point_tag, bg::segment_tag, P
162         >::type ps_strategy;
163     d1 = bg::distance(p1, seg, ps_strategy);
164     BOOST_CHECK_CLOSE(d1, return_type(1), 0.001);
165
166     // 3) custom point strategy
167     taxicab_distance tcd;
168     d1 = bg::distance(p1, seg, tcd);
169     BOOST_CHECK_CLOSE(d1, return_type(1), 0.001);
170 }
171
172 template <typename Point, typename Geometry, typename T>
173 void test_distance_linear(std::string const& wkt_point, std::string const& wkt_geometry, T const& expected)
174 {
175     Point p;
176     bg::read_wkt(wkt_point, p);
177
178     Geometry g;
179     bg::read_wkt(wkt_geometry, g);
180
181     typedef typename bg::default_distance_result<Point>::type return_type;
182     return_type d = bg::distance(p, g);
183
184     // For point-to-linestring (or point-to-polygon), both a point-strategy and a point-segment-strategy can be specified.
185     // Test this.
186     return_type ds1 = bg::distance(p, g, bg::strategy::distance::pythagoras<>());
187     return_type ds2 = bg::distance(p, g, bg::strategy::distance::projected_point<>());
188
189     BOOST_CHECK_CLOSE(d, return_type(expected), 0.001);
190     BOOST_CHECK_CLOSE(ds1, return_type(expected), 0.001);
191     BOOST_CHECK_CLOSE(ds2, return_type(expected), 0.001);
192 }
193
194 template <typename P>
195 void test_distance_array_as_linestring()
196 {
197     typedef typename bg::default_distance_result<P>::type return_type;
198
199     // Normal array does not have
200     boost::array<P, 2> points;
201     bg::set<0>(points[0], 1);
202     bg::set<1>(points[0], 1);
203     bg::set<0>(points[1], 3);
204     bg::set<1>(points[1], 3);
205
206     P p;
207     bg::set<0>(p, 2);
208     bg::set<1>(p, 1);
209
210     return_type d = bg::distance(p, points);
211     BOOST_CHECK_CLOSE(d, return_type(0.70710678), 0.001);
212
213     bg::set<0>(p, 5); bg::set<1>(p, 5);
214     d = bg::distance(p, points);
215     BOOST_CHECK_CLOSE(d, return_type(2.828427), 0.001);
216 }
217
218
219 // code moved from the distance unit test in multi/algorithms -- start
220 template <typename Geometry1, typename Geometry2>
221 void test_distance(std::string const& wkt1, std::string const& wkt2, double expected)
222 {
223     Geometry1 g1;
224     Geometry2 g2;
225     bg::read_wkt(wkt1, g1);
226     bg::read_wkt(wkt2, g2);
227     typename bg::default_distance_result<Geometry1, Geometry2>::type d = bg::distance(g1, g2);
228
229     BOOST_CHECK_CLOSE(d, expected, 0.0001);
230 }
231
232 template <typename Geometry1, typename Geometry2, typename Strategy>
233 void test_distance(Strategy const& strategy, std::string const& wkt1,
234                    std::string const& wkt2, double expected)
235 {
236     Geometry1 g1;
237     Geometry2 g2;
238     bg::read_wkt(wkt1, g1);
239     bg::read_wkt(wkt2, g2);
240     typename bg::default_distance_result<Geometry1, Geometry2>::type d = bg::distance(g1, g2, strategy);
241
242     BOOST_CHECK_CLOSE(d, expected, 0.0001);
243 }
244
245
246 template <typename P>
247 void test_2d()
248 {
249     typedef bg::model::multi_point<P> mp;
250     typedef bg::model::multi_linestring<bg::model::linestring<P> > ml;
251     test_distance<P, P>("POINT(0 0)", "POINT(1 1)", sqrt(2.0));
252     test_distance<P, mp>("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0);
253     test_distance<mp, P>("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0);
254     test_distance<mp, mp>("MULTIPOINT((1 1),(1 0),(0 2))", "MULTIPOINT((2 2),(2 3))", sqrt(2.0));
255     test_distance<P, ml>("POINT(0 0)", "MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", 1.0);
256     test_distance<ml, P>("MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", "POINT(0 0)", 1.0);
257     test_distance<ml, mp>("MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", "MULTIPOINT((0 0),(1 1))", 0.0);
258
259     // Test with a strategy
260     bg::strategy::distance::pythagoras<> pyth;
261     test_distance<P, P>(pyth, "POINT(0 0)", "POINT(1 1)", sqrt(2.0));
262     test_distance<P, mp>(pyth, "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0);
263     test_distance<mp, P>(pyth, "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0);
264 }
265
266
267 template <typename P>
268 void test_3d()
269 {
270     typedef bg::model::multi_point<P> mp;
271     test_distance<P, P>("POINT(0 0 0)", "POINT(1 1 1)", sqrt(3.0));
272     test_distance<P, mp>("POINT(0 0 0)", "MULTIPOINT((1 1 1),(1 0 0),(0 1 2))", 1.0);
273     test_distance<mp, mp>("MULTIPOINT((1 1 1),(1 0 0),(0 0 2))", "MULTIPOINT((2 2 2),(2 3 4))", sqrt(3.0));
274 }
275
276
277 template <typename P1, typename P2>
278 void test_mixed()
279 {
280     typedef bg::model::multi_point<P1> mp1;
281     typedef bg::model::multi_point<P2> mp2;
282
283     test_distance<P1, P2>("POINT(0 0)", "POINT(1 1)", sqrt(2.0));
284
285     test_distance<P1, mp1>("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0);
286     test_distance<P1, mp2>("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0);
287     test_distance<P2, mp1>("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0);
288     test_distance<P2, mp2>("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0);
289
290     // Test automatic reversal
291     test_distance<mp1, P1>("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0);
292     test_distance<mp1, P2>("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0);
293     test_distance<mp2, P1>("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0);
294     test_distance<mp2, P2>("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0);
295
296     // Test multi-multi using different point types for each
297     test_distance<mp1, mp2>("MULTIPOINT((1 1),(1 0),(0 2))", "MULTIPOINT((2 2),(2 3))", sqrt(2.0));
298
299     // Test with a strategy
300     using namespace bg::strategy::distance;
301
302     test_distance<P1, P2>(pythagoras<>(), "POINT(0 0)", "POINT(1 1)", sqrt(2.0));
303
304     test_distance<P1, mp1>(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0);
305     test_distance<P1, mp2>(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0);
306     test_distance<P2, mp1>(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0);
307     test_distance<P2, mp2>(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0);
308
309     // Most interesting: reversal AND a strategy (note that the stategy must be reversed automatically
310     test_distance<mp1, P1>(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0);
311     test_distance<mp1, P2>(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0);
312     test_distance<mp2, P1>(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0);
313     test_distance<mp2, P2>(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0);
314 }
315 // code moved from the distance unit test in multi/algorithms -- end
316
317
318
319
320 template <typename P>
321 void test_all()
322 {
323     test_distance_point<P>();
324     test_distance_segment<P>();
325     test_distance_array_as_linestring<P>();
326
327     test_geometry<P, bg::model::segment<P> >("POINT(1 3)", "LINESTRING(1 1,4 4)", sqrt(2.0));
328     test_geometry<P, bg::model::segment<P> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
329
330     test_geometry<P, P>("POINT(1 1)", "POINT(2 2)", sqrt(2.0));
331     test_geometry<P, P>("POINT(0 0)", "POINT(0 3)", 3.0);
332     test_geometry<P, P>("POINT(0 0)", "POINT(4 0)", 4.0);
333     test_geometry<P, P>("POINT(0 3)", "POINT(4 0)", 5.0);
334     test_geometry<P, bg::model::linestring<P> >("POINT(1 3)", "LINESTRING(1 1,4 4)", sqrt(2.0));
335     test_geometry<P, bg::model::linestring<P> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
336     test_geometry<P, bg::model::linestring<P> >("POINT(50 50)", "LINESTRING(50 40, 40 50)", sqrt(50.0));
337     test_geometry<P, bg::model::linestring<P> >("POINT(50 50)", "LINESTRING(50 40, 40 50, 0 90)", sqrt(50.0));
338     test_geometry<bg::model::linestring<P>, P>("LINESTRING(1 1,4 4)", "POINT(1 3)", sqrt(2.0));
339     test_geometry<bg::model::linestring<P>, P>("LINESTRING(50 40, 40 50)", "POINT(50 50)", sqrt(50.0));
340     test_geometry<bg::model::linestring<P>, P>("LINESTRING(50 40, 40 50, 0 90)", "POINT(50 50)", sqrt(50.0));
341
342     // Rings
343     test_geometry<P, bg::model::ring<P> >("POINT(1 3)", "POLYGON((1 1,4 4,5 0,1 1))", sqrt(2.0));
344     test_geometry<P, bg::model::ring<P> >("POINT(3 1)", "POLYGON((1 1,4 4,5 0,1 1))", 0.0);
345     // other way round
346     test_geometry<bg::model::ring<P>, P>("POLYGON((1 1,4 4,5 0,1 1))", "POINT(3 1)", 0.0);
347     // open ring
348     test_geometry<P, bg::model::ring<P, true, false> >("POINT(1 3)", "POLYGON((4 4,5 0,1 1))", sqrt(2.0));
349
350     // Polygons
351     test_geometry<P, bg::model::polygon<P> >("POINT(1 3)", "POLYGON((1 1,4 4,5 0,1 1))", sqrt(2.0));
352     test_geometry<P, bg::model::polygon<P> >("POINT(3 1)", "POLYGON((1 1,4 4,5 0,1 1))", 0.0);
353     // other way round
354     test_geometry<bg::model::polygon<P>, P>("POLYGON((1 1,4 4,5 0,1 1))", "POINT(3 1)", 0.0);
355     // open polygon
356     test_geometry<P, bg::model::polygon<P, true, false> >("POINT(1 3)", "POLYGON((4 4,5 0,1 1))", sqrt(2.0));
357
358     // Polygons with holes
359     std::string donut = "POLYGON ((0 0,1 9,8 1,0 0),(1 1,4 1,1 4,1 1))";
360     test_geometry<P, bg::model::polygon<P> >("POINT(2 2)", donut, 0.5 * sqrt(2.0));
361     test_geometry<P, bg::model::polygon<P> >("POINT(3 3)", donut, 0.0);
362     // other way round
363     test_geometry<bg::model::polygon<P>, P>(donut, "POINT(2 2)", 0.5 * sqrt(2.0));
364     // open
365     test_geometry<P, bg::model::polygon<P, true, false> >("POINT(2 2)", "POLYGON ((0 0,1 9,8 1),(1 1,4 1,1 4))", 0.5 * sqrt(2.0));
366
367     // Should (currently) give compiler assertion
368     // test_geometry<bg::model::polygon<P>, bg::model::polygon<P> >(donut, donut, 0.5 * sqrt(2.0));
369
370     // DOES NOT COMPILE - cannot do read_wkt (because boost::array is not variably sized)
371     // test_geometry<P, boost::array<P, 2> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
372
373     test_geometry<P, test::wrapped_boost_array<P, 2> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
374
375     test_distance_linear<P, bg::model::linestring<P> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
376 }
377
378 template <typename P>
379 void test_empty_input()
380 {
381     P p;
382     bg::model::linestring<P> line_empty;
383     bg::model::polygon<P> poly_empty;
384     bg::model::ring<P> ring_empty;
385     bg::model::multi_point<P> mp_empty;
386     bg::model::multi_linestring<bg::model::linestring<P> > ml_empty;
387
388     test_empty_input(p, line_empty);
389     test_empty_input(p, poly_empty);
390     test_empty_input(p, ring_empty);
391
392     test_empty_input(p, mp_empty);
393     test_empty_input(p, ml_empty);
394     test_empty_input(mp_empty, mp_empty);
395
396     // Test behaviour if one of the inputs is empty
397     bg::model::multi_point<P> mp;
398     mp.push_back(p);
399     test_empty_input(mp_empty, mp);
400     test_empty_input(mp, mp_empty);
401 }
402
403 void test_large_integers()
404 {
405     typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
406     typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
407
408     // point-point
409     {
410         std::string const a = "POINT(2544000 528000)";
411         std::string const b = "POINT(2768040 528000)";
412         int_point_type ia, ib;
413         double_point_type da, db;
414         bg::read_wkt(a, ia);
415         bg::read_wkt(b, ib);
416         bg::read_wkt(a, da);
417         bg::read_wkt(b, db);
418
419         BOOST_AUTO(idist, bg::distance(ia, ib));
420         BOOST_AUTO(ddist, bg::distance(da, db));
421
422         BOOST_CHECK_MESSAGE(std::abs(idist - ddist) < 0.1,
423                 "within<a double> different from within<an int>");
424     }
425     // Point-segment
426     {
427         std::string const a = "POINT(2600000 529000)";
428         std::string const b = "LINESTRING(2544000 528000, 2768040 528000)";
429         int_point_type ia;
430         double_point_type da;
431         bg::model::segment<int_point_type> ib;
432         bg::model::segment<double_point_type> db;
433         bg::read_wkt(a, ia);
434         bg::read_wkt(b, ib);
435         bg::read_wkt(a, da);
436         bg::read_wkt(b, db);
437
438         BOOST_AUTO(idist, bg::distance(ia, ib));
439         BOOST_AUTO(ddist, bg::distance(da, db));
440
441         BOOST_CHECK_MESSAGE(std::abs(idist - ddist) < 0.1,
442                 "within<a double> different from within<an int>");
443     }
444 }
445
446 template <typename T>
447 void test_variant()
448 {
449     typedef bg::model::point<T, 2, bg::cs::cartesian> point_type;
450     typedef bg::model::segment<point_type> segment_type;
451     typedef bg::model::box<point_type> box_type;
452     typedef boost::variant<point_type, segment_type, box_type> variant_type;
453
454     point_type point;
455     std::string const point_li = "POINT(1 3)";
456     bg::read_wkt(point_li, point);
457
458     segment_type seg;
459     std::string const seg_li = "LINESTRING(1 1,4 4)";
460     bg::read_wkt(seg_li, seg);
461
462     variant_type v1, v2;
463     
464     BOOST_MPL_ASSERT((
465         boost::is_same
466             <
467                 typename bg::distance_result
468                     <
469                         variant_type, variant_type, bg::default_strategy
470                     >::type,
471                 double
472             >
473     ));
474
475     // Default strategy
476     v1 = point;
477     v2 = point;
478     BOOST_CHECK_CLOSE(bg::distance(v1, v2), bg::distance(point, point), 0.0001);
479     BOOST_CHECK_CLOSE(bg::distance(v1, point), bg::distance(point, point), 0.0001);
480     BOOST_CHECK_CLOSE(bg::distance(point, v2), bg::distance(point, point), 0.0001);
481     v1 = point;
482     v2 = seg;
483     BOOST_CHECK_CLOSE(bg::distance(v1, v2), bg::distance(point, seg), 0.0001);
484     BOOST_CHECK_CLOSE(bg::distance(v1, seg), bg::distance(point, seg), 0.0001);
485     BOOST_CHECK_CLOSE(bg::distance(point, v2), bg::distance(point, seg), 0.0001);
486
487     // User defined strategy
488     v1 = point;
489     v2 = point;
490     bg::strategy::distance::haversine<double> s;
491     //BOOST_CHECK_CLOSE(bg::distance(v1, v2, s), bg::distance(point, point, s), 0.0001);
492     //BOOST_CHECK_CLOSE(bg::distance(v1, point, s), bg::distance(point, point, s), 0.0001);
493     //BOOST_CHECK_CLOSE(bg::distance(point, v2, s), bg::distance(point, point, s), 0.0001);
494 }
495
496 int test_main(int, char* [])
497 {
498 #ifdef TEST_ARRAY
499     //test_all<int[2]>();
500     //test_all<float[2]>();
501     //test_all<double[2]>();
502     //test_all<test::test_point>(); // located here because of 3D
503 #endif
504
505     test_large_integers();
506
507     test_all<bg::model::d2::point_xy<int> >();
508     test_all<boost::tuple<float, float> >();
509     test_all<bg::model::d2::point_xy<float> >();
510     test_all<bg::model::d2::point_xy<double> >();
511
512 #ifdef HAVE_TTMATH
513     test_all<bg::model::d2::point_xy<ttmath_big> >();
514 #endif
515
516     test_empty_input<bg::model::d2::point_xy<int> >();
517
518     // below are the test cases moved here from the distance unit test
519     // in test/multi/algorithms
520     test_2d<boost::tuple<float, float> >();
521     test_2d<bg::model::d2::point_xy<float> >();
522     test_2d<bg::model::d2::point_xy<double> >();
523
524     test_3d<boost::tuple<float, float, float> >();
525     test_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
526
527     test_mixed<bg::model::d2::point_xy<float>, bg::model::d2::point_xy<double> >();
528
529 #ifdef HAVE_TTMATH
530     test_2d<bg::model::d2::point_xy<ttmath_big> >();
531     test_mixed<bg::model::d2::point_xy<ttmath_big>, bg::model::d2::point_xy<double> >();
532 #endif
533
534     test_empty_input<bg::model::d2::point_xy<int> >();
535
536     test_variant<double>();
537     test_variant<int>();
538
539     return 0;
540 }