// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // This file was modified by Oracle on 2014. // Modifications copyright (c) 2014 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include #include #ifdef HAVE_TTMATH # include #endif template void test_andoyer(double lon1, double lat1, double lon2, double lat2, double expected_km) { // Set radius type, but for integer coordinates we want to have floating point radius type typedef typename bg::promote_floating_point < typename bg::coordinate_type::type >::type rtype; typedef bg::srs::spheroid stype; typedef bg::strategy::distance::andoyer andoyer_type; BOOST_CONCEPT_ASSERT ( (bg::concept::PointDistanceStrategy) ); andoyer_type andoyer; typedef typename bg::strategy::distance ::services::return_type::type return_type; P1 p1, p2; bg::assign_values(p1, lon1, lat1); bg::assign_values(p2, lon2, lat2); BOOST_CHECK_CLOSE(andoyer.apply(p1, p2), return_type(1000.0 * expected_km), 0.001); BOOST_CHECK_CLOSE(bg::distance(p1, p2, andoyer), return_type(1000.0 * expected_km), 0.001); } template void test_all() { test_andoyer(0, 90, 1, 80, 1116.814237); // polar test_andoyer(4, 52, 4, 52, 0.0); // no point difference test_andoyer(4, 52, 3, 40, 1336.039890); // normal case /* SQL Server gives: 1116.82586908528, 0, 1336.02721932545 with: SELECT 0.001 * geography::STGeomFromText('POINT(0 90)', 4326).STDistance(geography::STGeomFromText('POINT(1 80)', 4326)) union SELECT 0.001 * geography::STGeomFromText('POINT(4 52)', 4326).STDistance(geography::STGeomFromText('POINT(4 52)', 4326)) union SELECT 0.001 * geography::STGeomFromText('POINT(4 52)', 4326).STDistance(geography::STGeomFromText('POINT(3 40)', 4326)) */ } template void test_all() { test_all(); } int test_main(int, char* []) { //test_all(); //test_all(); test_all > >(); test_all > >(); test_all > >(); #if defined(HAVE_TTMATH) test_all, 2, bg::cs::geographic > >(); test_all > >(); #endif return 0; }