PageRenderTime 26ms CodeModel.GetById 11ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/geometry/test/core/coordinate_system.cpp

http://hadesmem.googlecode.com/
C++ | 101 lines | 63 code | 27 blank | 11 comment | 0 complexity | 4a256089e9f7445ee48f4cce77a10528 MD5 | raw file
  1// Boost.Geometry (aka GGL, Generic Geometry Library)
  2// Unit Test
  3
  4// Copyright (c) 2007-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
 11#include <geometry_test_common.hpp>
 12
 13
 14#include <boost/geometry/core/coordinate_system.hpp>
 15
 16
 17#include <boost/geometry/geometries/geometries.hpp>
 18
 19#include <boost/geometry/geometries/adapted/c_array.hpp>
 20#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
 21
 22#include <boost/geometry/geometries/register/linestring.hpp>
 23
 24#include <vector>
 25#include <deque>
 26
 27BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
 28BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
 29
 30BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
 31BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque)
 32
 33
 34template <typename G, typename Expected>
 35void test_geometry()
 36{
 37    BOOST_CHECK_EQUAL(typeid(typename bg::coordinate_system<G>::type).name(),
 38        typeid(Expected).name());
 39}
 40
 41template <typename P, typename Expected>
 42void test_all()
 43{
 44    test_geometry<P, Expected>();
 45    test_geometry<P const, Expected>();
 46    test_geometry<bg::model::linestring<P> , Expected>();
 47    test_geometry<bg::model::ring<P> , Expected>();
 48    test_geometry<bg::model::polygon<P> , Expected>();
 49    test_geometry<bg::model::box<P> , Expected>();
 50    test_geometry<bg::model::segment<P> , Expected>();
 51    test_geometry<bg::model::referring_segment<P const> , Expected>();
 52
 53    test_geometry<std::vector<P>, Expected>();
 54    test_geometry<std::deque<P>, Expected>();
 55}
 56
 57int test_main(int, char* [])
 58{
 59    // Because of the included headerfiles, there are always cartesian
 60    test_geometry<int[2], bg::cs::cartesian>();
 61    test_geometry<float[2], bg::cs::cartesian>();
 62    test_geometry<double[2], bg::cs::cartesian>();
 63
 64    test_geometry<int[3], bg::cs::cartesian>();
 65    test_geometry<float[3], bg::cs::cartesian>();
 66    test_geometry<double[3], bg::cs::cartesian>();
 67
 68    // Because of the included headerfiles, there are always cartesian
 69    test_geometry<boost::tuple<double, double>, bg::cs::cartesian>();
 70    test_geometry<boost::tuple<double, double, double>, bg::cs::cartesian>();
 71
 72
 73    // Test cartesian
 74    test_all<bg::model::point<int, 2, bg::cs::cartesian>, bg::cs::cartesian>();
 75    test_all<bg::model::point<float, 2, bg::cs::cartesian>, bg::cs::cartesian>();
 76    test_all<bg::model::point<double, 2, bg::cs::cartesian>, bg::cs::cartesian>();
 77
 78    // Test spherical
 79    test_all<bg::model::point<int, 2, bg::cs::spherical<bg::degree> >,
 80            bg::cs::spherical<bg::degree> >();
 81    test_all<bg::model::point<float, 2, bg::cs::spherical<bg::degree> >,
 82            bg::cs::spherical<bg::degree> >();
 83    test_all<bg::model::point<double, 2, bg::cs::spherical<bg::degree> >,
 84            bg::cs::spherical<bg::degree> >();
 85
 86    test_all<bg::model::point<int, 2, bg::cs::spherical<bg::radian> >,
 87                bg::cs::spherical<bg::radian> >();
 88    test_all<bg::model::point<float, 2, bg::cs::spherical<bg::radian> >,
 89                bg::cs::spherical<bg::radian> >();
 90    test_all<bg::model::point<double, 2, bg::cs::spherical<bg::radian> >,
 91                bg::cs::spherical<bg::radian> >();
 92
 93    // Test other
 94    test_all<bg::model::point<double, 2, bg::cs::polar<bg::degree> >,
 95            bg::cs::polar<bg::degree> >();
 96
 97    test_all<bg::model::point<double, 2, bg::cs::geographic<bg::degree> >,
 98            bg::cs::geographic<bg::degree> >();
 99
100    return 0;
101}