PageRenderTime 6ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/geometry/test/algorithms/test_length.hpp

http://hadesmem.googlecode.com/
C++ Header | 48 lines | 30 code | 12 blank | 6 comment | 0 complexity | 647f970fb709b1ca598946ad8a2031a4 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// Use, modification and distribution is subject to the Boost Software License,
 6// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 7// http://www.boost.org/LICENSE_1_0.txt)
 8
 9#ifndef BOOST_GEOMETRY_TEST_LENGTH_HPP
10#define BOOST_GEOMETRY_TEST_LENGTH_HPP
11
12#include <geometry_test_common.hpp>
13
14#include <boost/geometry/algorithms/length.hpp>
15#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
16#include <boost/geometry/strategies/strategies.hpp>
17
18
19template <typename Geometry>
20void test_length(Geometry const& geometry, long double expected_length)
21{
22    typename bg::default_length_result<Geometry>::type length = bg::length(geometry);
23
24#ifdef GEOMETRY_TEST_DEBUG
25    std::ostringstream out;
26    out << typeid(typename bg::coordinate_type<Geometry>::type).name()
27        << std::endl
28        << typeid(typename bg::default_length_result<Geometry>::type).name()
29        << std::endl
30        << "length : " << bg::length(geometry)
31        << std::endl;
32    std::cout << out.str();
33#endif
34
35    BOOST_CHECK_CLOSE(length, expected_length, 0.0001);
36}
37
38
39template <typename Geometry>
40void test_geometry(std::string const& wkt, double expected_length)
41{
42    Geometry geometry;
43    bg::read_wkt(wkt, geometry);
44    test_length(geometry, expected_length);
45}
46
47
48#endif