mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-20 02:42:10 +00:00
added tests of some index's algorithms + index::margin() optimization.
[SVN r79090]
This commit is contained in:
@@ -76,7 +76,7 @@ struct margin_for_each_dimension
|
||||
static inline typename default_margin_result<Box>::type apply(Box const& b)
|
||||
{
|
||||
return margin_for_each_dimension<Box, CurrentDimension - 1>::apply(b) +
|
||||
2 * margin_for_each_edge<Box, CurrentDimension, traits::dimension<Box>::value>::apply(b);
|
||||
margin_for_each_edge<Box, CurrentDimension, traits::dimension<Box>::value>::apply(b);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ struct margin_for_each_dimension<Box, 1>
|
||||
{
|
||||
static inline typename default_margin_result<Box>::type apply(Box const& b)
|
||||
{
|
||||
return 2 * margin_for_each_edge<Box, 1, traits::dimension<Box>::value>::apply(b);
|
||||
return margin_for_each_edge<Box, 1, traits::dimension<Box>::value>::apply(b);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -94,7 +94,7 @@ struct margin_for_each_dimension<Box, 1>
|
||||
template <typename Box>
|
||||
typename default_margin_result<Box>::type margin(Box const& b)
|
||||
{
|
||||
return detail::margin_for_each_dimension<Box, traits::dimension<Box>::value>::apply(b);
|
||||
return 2 * detail::margin_for_each_dimension<Box, traits::dimension<Box>::value>::apply(b);
|
||||
}
|
||||
|
||||
}}} // namespace boost::geometry::index
|
||||
|
||||
27
test/Jamfile.v2
Normal file
27
test/Jamfile.v2
Normal file
@@ -0,0 +1,27 @@
|
||||
# Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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)
|
||||
|
||||
import testing ;
|
||||
|
||||
project boost-geometry-index-test
|
||||
:
|
||||
requirements
|
||||
<include>.
|
||||
<include>..
|
||||
<include>../..
|
||||
<include>../../..
|
||||
#<include>../../../boost/geometry/extensions/contrib/ttmath
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
;
|
||||
|
||||
build-project algorithms ;
|
||||
#build-project rtree ;
|
||||
#build-project filters ;
|
||||
#build-project translator ;
|
||||
17
test/algorithms/Jamfile.v2
Normal file
17
test/algorithms/Jamfile.v2
Normal file
@@ -0,0 +1,17 @@
|
||||
# Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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)
|
||||
|
||||
test-suite boost-geometry-index-algorithms
|
||||
:
|
||||
[ run content.cpp ]
|
||||
[ run is_valid.cpp ]
|
||||
[ run margin.cpp ]
|
||||
;
|
||||
|
||||
77
test/algorithms/content.cpp
Normal file
77
test/algorithms/content.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
// 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.
|
||||
|
||||
// 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 <algorithms/test_content.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
|
||||
//#define GEOMETRY_TEST_DEBUG
|
||||
|
||||
void test_large_integers()
|
||||
{
|
||||
typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
|
||||
typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
|
||||
|
||||
bg::model::box<int_point_type> int_box;
|
||||
bg::model::box<double_point_type> double_box;
|
||||
|
||||
std::string const box_li = "POLYGON((1536119 192000, 1872000 528000))";
|
||||
bg::read_wkt(box_li, int_box);
|
||||
bg::read_wkt(box_li, double_box);
|
||||
|
||||
double int_value = bgi::content(int_box);
|
||||
double double_value = bgi::content(double_box);
|
||||
|
||||
BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
|
||||
typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
|
||||
typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
|
||||
|
||||
typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
|
||||
typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
|
||||
typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
|
||||
|
||||
test_content(P2ic(0, 0), 0);
|
||||
test_content(P2fc(0, 0), 0);
|
||||
test_content(P2dc(0, 0), 0);
|
||||
test_content(P3ic(0, 0, 0), 0);
|
||||
test_content(P3fc(0, 0, 0), 0);
|
||||
test_content(P3dc(0, 0, 0), 0);
|
||||
|
||||
test_geometry<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", 6.0);
|
||||
test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", 6.0);
|
||||
test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", 6.0);
|
||||
test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", 24.0);
|
||||
test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", 24.0);
|
||||
test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", 24.0);
|
||||
|
||||
#ifdef HAVE_TTMATH
|
||||
typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
|
||||
typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
|
||||
|
||||
test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", 6.0);
|
||||
test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", 24.0);
|
||||
#endif
|
||||
|
||||
test_large_integers();
|
||||
|
||||
return 0;
|
||||
}
|
||||
102
test/algorithms/is_valid.cpp
Normal file
102
test/algorithms/is_valid.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
// 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.
|
||||
|
||||
// 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 <algorithm>
|
||||
|
||||
#include <geometry_index_test_common.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/algorithms/is_valid.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
|
||||
//#define GEOMETRY_TEST_DEBUG
|
||||
|
||||
template <typename Geometry>
|
||||
void test(Geometry const& geometry, bool expected_value)
|
||||
{
|
||||
BOOST_CHECK(bgi::is_valid(geometry) == expected_value);
|
||||
}
|
||||
|
||||
template <typename Box>
|
||||
void test_box(std::string const& wkt, bool expected_value)
|
||||
{
|
||||
Box box;
|
||||
bg::read_wkt(wkt, box);
|
||||
test(box, expected_value);
|
||||
typename bg::point_type<Box>::type temp_pt;
|
||||
temp_pt = box.min_corner();
|
||||
box.min_corner() = box.max_corner();
|
||||
box.max_corner() = temp_pt;
|
||||
test(box, !expected_value);
|
||||
}
|
||||
|
||||
void test_large_integers()
|
||||
{
|
||||
typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
|
||||
typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
|
||||
|
||||
bg::model::box<int_point_type> int_box;
|
||||
bg::model::box<double_point_type> double_box;
|
||||
|
||||
std::string const box_li = "POLYGON((1536119 192000, 1872000 528000))";
|
||||
bg::read_wkt(box_li, int_box);
|
||||
bg::read_wkt(box_li, double_box);
|
||||
|
||||
BOOST_CHECK(bgi::is_valid(int_box) == bgi::is_valid(double_box));
|
||||
|
||||
std::string const box_li2 = "POLYGON((1872000 528000, 1536119 192000))";
|
||||
bg::read_wkt(box_li2, int_box);
|
||||
bg::read_wkt(box_li2, double_box);
|
||||
|
||||
BOOST_CHECK(bgi::is_valid(int_box) == bgi::is_valid(double_box));
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
|
||||
typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
|
||||
typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
|
||||
|
||||
typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
|
||||
typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
|
||||
typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
|
||||
|
||||
test(P2ic(0, 0), true);
|
||||
test(P2fc(0, 0), true);
|
||||
test(P2dc(0, 0), true);
|
||||
test(P3ic(0, 0, 0), true);
|
||||
test(P3fc(0, 0, 0), true);
|
||||
test(P3dc(0, 0, 0), true);
|
||||
|
||||
test_box<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", true);
|
||||
test_box<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", true);
|
||||
test_box<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", true);
|
||||
test_box<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", true);
|
||||
test_box<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", true);
|
||||
test_box<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", true);
|
||||
|
||||
#ifdef HAVE_TTMATH
|
||||
typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
|
||||
typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
|
||||
|
||||
test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", true);
|
||||
test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", true);
|
||||
#endif
|
||||
|
||||
test_large_integers();
|
||||
|
||||
return 0;
|
||||
}
|
||||
72
test/algorithms/margin.cpp
Normal file
72
test/algorithms/margin.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
// 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.
|
||||
|
||||
// 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 <algorithms/test_margin.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
|
||||
//#define GEOMETRY_TEST_DEBUG
|
||||
|
||||
void test_large_integers()
|
||||
{
|
||||
typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
|
||||
typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
|
||||
|
||||
bg::model::box<int_point_type> int_box;
|
||||
bg::model::box<double_point_type> double_box;
|
||||
|
||||
std::string const box_li = "POLYGON((1536119 192000, 1872000 528000))";
|
||||
bg::read_wkt(box_li, int_box);
|
||||
bg::read_wkt(box_li, double_box);
|
||||
|
||||
double int_value = bgi::margin(int_box);
|
||||
double double_value = bgi::margin(double_box);
|
||||
|
||||
BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
|
||||
typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
|
||||
typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
|
||||
|
||||
typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
|
||||
typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
|
||||
typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
|
||||
|
||||
test_geometry<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", 10.0);
|
||||
test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", 10.0);
|
||||
test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", 10.0);
|
||||
test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", 52);
|
||||
test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", 52.0);
|
||||
test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", 52.0);
|
||||
|
||||
#ifdef HAVE_TTMATH
|
||||
typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
|
||||
typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
|
||||
|
||||
test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", 10.0);
|
||||
test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", 52.0);
|
||||
#endif
|
||||
|
||||
test_large_integers();
|
||||
|
||||
// test_empty_input<bg::model::d2::point_xy<int> >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
50
test/algorithms/test_content.hpp
Normal file
50
test/algorithms/test_content.hpp
Normal file
@@ -0,0 +1,50 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2011-2012 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_TEST_CONTENT_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_TEST_CONTENT_HPP
|
||||
|
||||
#include <geometry_index_test_common.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/algorithms/content.hpp>
|
||||
|
||||
//#include <boost/geometry/io/wkt/read.hpp>
|
||||
|
||||
|
||||
template <typename Geometry>
|
||||
void test_content(Geometry const& geometry,
|
||||
typename bgi::default_content_result<Geometry>::type expected_value)
|
||||
{
|
||||
typename bgi::default_content_result<Geometry>::type value = bgi::content(geometry);
|
||||
|
||||
#ifdef GEOMETRY_TEST_DEBUG
|
||||
std::ostringstream out;
|
||||
out << typeid(typename bg::coordinate_type<Geometry>::type).name()
|
||||
<< " "
|
||||
<< typeid(typename bgi::default_content_result<Geometry>::type).name()
|
||||
<< " "
|
||||
<< "content : " << value
|
||||
<< std::endl;
|
||||
std::cout << out.str();
|
||||
#endif
|
||||
|
||||
BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
|
||||
}
|
||||
|
||||
template <typename Geometry>
|
||||
void test_geometry(std::string const& wkt,
|
||||
typename bgi::default_content_result<Geometry>::type expected_value)
|
||||
{
|
||||
Geometry geometry;
|
||||
bg::read_wkt(wkt, geometry);
|
||||
test_content(geometry, expected_value);
|
||||
}
|
||||
|
||||
#endif
|
||||
49
test/algorithms/test_margin.hpp
Normal file
49
test/algorithms/test_margin.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2011-2012 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_TEST_MARGIN_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_TEST_MARGIN_HPP
|
||||
|
||||
#include <geometry_index_test_common.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/algorithms/margin.hpp>
|
||||
|
||||
//#include <boost/geometry/io/wkt/read.hpp>
|
||||
|
||||
template <typename Geometry>
|
||||
void test_margin(Geometry const& geometry,
|
||||
typename bgi::default_margin_result<Geometry>::type expected_value)
|
||||
{
|
||||
typename bgi::default_margin_result<Geometry>::type value = bgi::margin(geometry);
|
||||
|
||||
#ifdef GEOMETRY_TEST_DEBUG
|
||||
std::ostringstream out;
|
||||
out << typeid(typename bg::coordinate_type<Geometry>::type).name()
|
||||
<< " "
|
||||
<< typeid(typename bgi::default_margin_result<Geometry>::type).name()
|
||||
<< " "
|
||||
<< "content : " << value
|
||||
<< std::endl;
|
||||
std::cout << out.str();
|
||||
#endif
|
||||
|
||||
BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
|
||||
}
|
||||
|
||||
template <typename Geometry>
|
||||
void test_geometry(std::string const& wkt,
|
||||
typename bgi::default_margin_result<Geometry>::type expected_value)
|
||||
{
|
||||
Geometry geometry;
|
||||
bg::read_wkt(wkt, geometry);
|
||||
test_margin(geometry, expected_value);
|
||||
}
|
||||
|
||||
#endif
|
||||
25
test/geometry_index_test_common.hpp
Normal file
25
test/geometry_index_test_common.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// 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.
|
||||
|
||||
// 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)
|
||||
|
||||
|
||||
#ifndef GEOMETRY_TEST_GEOMETRY_INDEX_TEST_COMMON_HPP
|
||||
#define GEOMETRY_TEST_GEOMETRY_INDEX_TEST_COMMON_HPP
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/extensions/index/rtree/rtree.hpp>
|
||||
|
||||
#include <geometry_test_common.hpp>
|
||||
|
||||
namespace bgi = boost::geometry::index;
|
||||
|
||||
#endif // GEOMETRY_TEST_GEOMETRY_INDEX_TEST_COMMON_HPP
|
||||
162
test/geometry_test_common.hpp
Normal file
162
test/geometry_test_common.hpp
Normal file
@@ -0,0 +1,162 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// 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.
|
||||
|
||||
// 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)
|
||||
|
||||
|
||||
#ifndef GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP
|
||||
#define GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// We deliberately mix float/double's so turn off warnings
|
||||
#pragma warning( disable : 4244 )
|
||||
// For (new since Boost 1.40) warning in Boost.Test on putenv/posix
|
||||
#pragma warning( disable : 4996 )
|
||||
|
||||
//#pragma warning( disable : 4305 )
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
|
||||
#if defined(BOOST_INTEL_CXX_VERSION)
|
||||
#define BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
|
||||
#endif
|
||||
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
|
||||
// Include some always-included-for-testing files
|
||||
#if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST)
|
||||
|
||||
// Until Boost fixes it, silence warning issued by clang:
|
||||
// warning: unused variable 'check_is_close' [-Wunused-variable]
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
|
||||
# include <boost/test/floating_point_comparison.hpp>
|
||||
# include <boost/test/included/test_exec_monitor.hpp>
|
||||
//# include <boost/test/included/prg_exec_monitor.hpp>
|
||||
# include <boost/test/impl/execution_monitor.ipp>
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
# include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CLN) || defined(HAVE_GMP)
|
||||
# include <boost/numeric_adaptor/numeric_adaptor.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_GMP)
|
||||
# include <boost/numeric_adaptor/gmp_value_type.hpp>
|
||||
#endif
|
||||
#if defined(HAVE_CLN)
|
||||
# include <boost/numeric_adaptor/cln_value_type.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct string_from_type {};
|
||||
|
||||
template <> struct string_from_type<void>
|
||||
{ static std::string name() { return "v"; } };
|
||||
|
||||
template <> struct string_from_type<float>
|
||||
{ static std::string name() { return "f"; } };
|
||||
|
||||
template <> struct string_from_type<double>
|
||||
{ static std::string name() { return "d"; } };
|
||||
|
||||
template <> struct string_from_type<long double>
|
||||
{ static std::string name() { return "e"; } };
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
template <> struct string_from_type<ttmath_big>
|
||||
{ static std::string name() { return "t"; } };
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_RATIONAL_HPP)
|
||||
template <typename T> struct string_from_type<boost::rational<T> >
|
||||
{ static std::string name() { return "r"; } };
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_GMP)
|
||||
template <> struct string_from_type<boost::numeric_adaptor::gmp_value_type>
|
||||
{ static std::string name() { return "g"; } };
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CLN)
|
||||
template <> struct string_from_type<boost::numeric_adaptor::cln_value_type>
|
||||
{ static std::string name() { return "c"; } };
|
||||
#endif
|
||||
|
||||
|
||||
template <typename CoordinateType, typename T1, typename T2>
|
||||
inline T1 if_typed_tt(T1 value_tt, T2 value)
|
||||
{
|
||||
#if defined(HAVE_TTMATH)
|
||||
return boost::is_same<CoordinateType, ttmath_big>::type::value ? value_tt : value;
|
||||
#else
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename CoordinateType, typename Specified, typename T>
|
||||
inline T if_typed(T value_typed, T value)
|
||||
{
|
||||
return boost::is_same<CoordinateType, Specified>::value ? value_typed : value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
struct geographic_policy
|
||||
{
|
||||
template <typename CoordinateType>
|
||||
static inline CoordinateType apply(CoordinateType const& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
struct mathematical_policy
|
||||
{
|
||||
template <typename CoordinateType>
|
||||
static inline CoordinateType apply(CoordinateType const& value)
|
||||
{
|
||||
return 90 - value;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// For all tests:
|
||||
// - do NOT use "using namespace boost::geometry" to make clear what is Boost.Geometry
|
||||
// - use bg:: as short alias
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
namespace bg = boost::geometry;
|
||||
|
||||
|
||||
#endif // GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP
|
||||
Reference in New Issue
Block a user