mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-11 11:52:11 +00:00
some tests and optimizations.
[SVN r79107]
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
//
|
||||
// Boost.SpatialIndex - n-dimensional box's content (2d-area/3d-volume/...)
|
||||
//
|
||||
// Copyright 2011 Adam Wulkiewicz.
|
||||
// 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)
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
//
|
||||
// Boost.SpatialIndex - boxes union/intersection area/volume
|
||||
//
|
||||
// Copyright 2011 Adam Wulkiewicz.
|
||||
// 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)
|
||||
@@ -21,14 +22,13 @@ namespace boost { namespace geometry { namespace index {
|
||||
template <typename Box>
|
||||
inline typename default_content_result<Box>::type intersection_content(Box const& box1, Box const& box2)
|
||||
{
|
||||
typename default_content_result<Box>::type result = 0;
|
||||
if ( geometry::intersects(box1, box2) )
|
||||
{
|
||||
Box box_intersection;
|
||||
geometry::intersection(box1, box2, box_intersection);
|
||||
result = index::content(box_intersection);
|
||||
return index::content(box_intersection);
|
||||
}
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}}} // namespace boost::geometry::index
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
//
|
||||
// Boost.Index - minmaxdist used in R-tree k nearest neighbors query
|
||||
//
|
||||
// Copyright 2011 Adam Wulkiewicz.
|
||||
// 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)
|
||||
@@ -10,12 +11,13 @@
|
||||
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_MINMAXDIST_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_MINMAXDIST_HPP
|
||||
|
||||
#include <boost/geometry/algorithms/distance.hpp>
|
||||
#include <boost/geometry/algorithms/comparable_distance.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/algorithms/detail/diff_abs.hpp>
|
||||
#include <boost/geometry/extensions/index/algorithms/detail/sum_for_indexable.hpp>
|
||||
#include <boost/geometry/extensions/index/algorithms/detail/smallest_for_indexable.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/algorithms/maxdist.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index {
|
||||
|
||||
namespace detail {
|
||||
@@ -49,7 +51,7 @@ struct smallest_for_indexable_dimension<Point, BoxIndexable, box_tag, minmaxdist
|
||||
if ( pt_c <= ind_c_avg )
|
||||
closer_comp = detail::diff_abs(pt_c, ind_c_min); // unsigned values protection
|
||||
else
|
||||
closer_comp = detail::diff_abs(pt_c, ind_c_max); // unsigned values protection
|
||||
closer_comp = ind_c_max - pt_c;
|
||||
|
||||
result_type further_comp = 0;
|
||||
if ( ind_c_avg <= pt_c )
|
||||
@@ -88,7 +90,7 @@ struct minmaxdist_impl<Point, Indexable, box_tag>
|
||||
|
||||
inline static result_type apply(Point const& pt, Indexable const& i)
|
||||
{
|
||||
result_type maxd = maxdist(pt, i);
|
||||
result_type maxd = geometry::comparable_distance(pt, i);
|
||||
|
||||
return smallest_for_indexable<
|
||||
Point,
|
||||
@@ -102,6 +104,9 @@ struct minmaxdist_impl<Point, Indexable, box_tag>
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* This is comparable distace.
|
||||
*/
|
||||
template <typename Point, typename Indexable>
|
||||
typename geometry::default_distance_result<Point, Indexable>::type
|
||||
minmaxdist(Point const& pt, Indexable const& i)
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
test-suite boost-geometry-index-algorithms
|
||||
:
|
||||
[ run content.cpp ]
|
||||
[ run intersection_content.cpp ] # this tests overlap() too
|
||||
[ run is_valid.cpp ]
|
||||
[ run margin.cpp ]
|
||||
[ run margin.cpp ]
|
||||
#[ run minmaxdist.cpp ]
|
||||
[ run union_content.cpp ]
|
||||
;
|
||||
|
||||
|
||||
78
test/algorithms/intersection_content.cpp
Normal file
78
test/algorithms/intersection_content.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
// 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_intersection_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_box1, int_box2;
|
||||
bg::model::box<double_point_type> double_box1, double_box2;
|
||||
|
||||
std::string const box_li1 = "POLYGON((1536119 192000, 1872000 528000))";
|
||||
std::string const box_li2 = "POLYGON((1701234 368250, 2673400 777400))";
|
||||
bg::read_wkt(box_li1, int_box1);
|
||||
bg::read_wkt(box_li1, double_box1);
|
||||
bg::read_wkt(box_li2, int_box2);
|
||||
bg::read_wkt(box_li2, double_box2);
|
||||
|
||||
double int_value = bgi::intersection_content(int_box1, int_box2);
|
||||
double double_value = bgi::intersection_content(double_box1, double_box2);
|
||||
|
||||
BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
|
||||
|
||||
// temp
|
||||
BOOST_CHECK_CLOSE(bgi::overlap(int_box1, int_box2), bgi::overlap(double_box1, double_box2), 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))", "POLYGON((1 2,3 5))", 2.0);
|
||||
test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 2.0);
|
||||
test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 2.0);
|
||||
test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 6.0);
|
||||
test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 6.0);
|
||||
test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 6.0);
|
||||
|
||||
test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((2 1,3 4))", 0.0);
|
||||
test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((2 4,3 5))", 0.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))", "POLYGON((1 2,3 5))", 2.0);
|
||||
test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 6.0);
|
||||
#endif
|
||||
|
||||
test_large_integers();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -27,7 +27,20 @@
|
||||
template <typename Geometry>
|
||||
void test(Geometry const& geometry, bool expected_value)
|
||||
{
|
||||
BOOST_CHECK(bgi::is_valid(geometry) == expected_value);
|
||||
bool value = bgi::is_valid(geometry);
|
||||
|
||||
#ifdef GEOMETRY_TEST_DEBUG
|
||||
std::ostringstream out;
|
||||
out << typeid(typename bg::coordinate_type<Geometry>::type).name()
|
||||
<< " "
|
||||
<< typeid(bool).name()
|
||||
<< " "
|
||||
<< "is_valid : " << value
|
||||
<< std::endl;
|
||||
std::cout << out.str();
|
||||
#endif
|
||||
|
||||
BOOST_CHECK(value == expected_value);
|
||||
}
|
||||
|
||||
template <typename Box>
|
||||
|
||||
106
test/algorithms/minmaxdist.cpp
Normal file
106
test/algorithms/minmaxdist.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
// 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/minmaxdist.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 Point, typename Indexable>
|
||||
void test(Point const& pt, Indexable const& indexable,
|
||||
typename bg::default_distance_result<Point, Indexable>::type expected_value)
|
||||
{
|
||||
typename bg::default_distance_result<Point, Indexable>::type value = bgi::minmaxdist(pt, indexable);
|
||||
|
||||
#ifdef GEOMETRY_TEST_DEBUG
|
||||
std::ostringstream out;
|
||||
out << typeid(typename bg::coordinate_type<Point>::type).name()
|
||||
<< " "
|
||||
<< typeid(typename bg::coordinate_type<Indexable>::type).name()
|
||||
<< " "
|
||||
<< typeid(bg::default_distance_result<Point, Indexable>::type).name()
|
||||
<< " "
|
||||
<< "minmaxdist : " << value
|
||||
<< std::endl;
|
||||
std::cout << out.str();
|
||||
#endif
|
||||
|
||||
BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
|
||||
}
|
||||
|
||||
template <typename Indexable, typename Point>
|
||||
void test_indexable(Point const& pt, std::string const& wkt,
|
||||
typename bg::default_distance_result<Point, Indexable>::type expected_value)
|
||||
{
|
||||
Indexable indexable;
|
||||
bg::read_wkt(wkt, indexable);
|
||||
test(pt, indexable, 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;
|
||||
|
||||
int_point_type int_pt(0, 0);
|
||||
double_point_type double_pt(0, 0);
|
||||
|
||||
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::minmaxdist(int_pt, int_box) == bgi::minmaxdist(double_pt, 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_indexable<bg::model::box<P2ic> >(P2ic(1, 2), "POLYGON((0 1,2 4))", 5.0);
|
||||
test_indexable<bg::model::box<P2fc> >(P2fc(1, 2), "POLYGON((0 1,2 4))", 5.0);
|
||||
test_indexable<bg::model::box<P2dc> >(P2dc(1, 2), "POLYGON((0 1,2 4))", 5.0);
|
||||
test_indexable<bg::model::box<P3ic> >(P3ic(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0);
|
||||
test_indexable<bg::model::box<P3fc> >(P3fc(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0);
|
||||
test_indexable<bg::model::box<P3dc> >(P3dc(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0);
|
||||
|
||||
test_indexable<bg::model::box<P2ic> >(P2ic(1, 2), "POLYGON((1 2,3 5))", 4.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_indexable<bg::model::box<P2ttmc> >(P2ttmc(1, 2), "POLYGON((0 1,2 4))", 5.0);
|
||||
test_indexable<bg::model::box<P3ttmc> >(P3ttmc(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0);
|
||||
#endif
|
||||
|
||||
test_large_integers();
|
||||
|
||||
return 0;
|
||||
}
|
||||
52
test/algorithms/test_intersection_content.hpp
Normal file
52
test/algorithms/test_intersection_content.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
// 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_INTERSECTION_CONTENT_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_TEST_INTERSECTION_CONTENT_HPP
|
||||
|
||||
#include <geometry_index_test_common.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/algorithms/intersection_content.hpp>
|
||||
#include <boost/geometry/extensions/index/algorithms/overlap.hpp>
|
||||
|
||||
template <typename Geometry>
|
||||
void test_intersection_content(Geometry const& geometry1, Geometry const& geometry2,
|
||||
typename bgi::default_content_result<Geometry>::type expected_value)
|
||||
{
|
||||
typename bgi::default_content_result<Geometry>::type value = bgi::intersection_content(geometry1, geometry2);
|
||||
|
||||
#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()
|
||||
<< " "
|
||||
<< "intersection_content : " << value
|
||||
<< std::endl;
|
||||
std::cout << out.str();
|
||||
#endif
|
||||
|
||||
BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
|
||||
|
||||
// temp
|
||||
BOOST_CHECK_CLOSE(bgi::overlap(geometry1, geometry2), expected_value, 0.0001);
|
||||
}
|
||||
|
||||
template <typename Geometry>
|
||||
void test_geometry(std::string const& wkt1, std::string const& wkt2,
|
||||
typename bgi::default_content_result<Geometry>::type expected_value)
|
||||
{
|
||||
Geometry geometry1, geometry2;
|
||||
bg::read_wkt(wkt1, geometry1);
|
||||
bg::read_wkt(wkt2, geometry2);
|
||||
test_intersection_content(geometry1, geometry2, expected_value);
|
||||
}
|
||||
|
||||
#endif
|
||||
48
test/algorithms/test_union_content.hpp
Normal file
48
test/algorithms/test_union_content.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
// 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_UNION_CONTENT_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_TEST_UNION_CONTENT_HPP
|
||||
|
||||
#include <geometry_index_test_common.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/index/algorithms/union_content.hpp>
|
||||
|
||||
template <typename Geometry>
|
||||
void test_union_content(Geometry const& geometry1, Geometry const& geometry2,
|
||||
typename bgi::default_content_result<Geometry>::type expected_value)
|
||||
{
|
||||
typename bgi::default_content_result<Geometry>::type value = bgi::union_content(geometry1, geometry2);
|
||||
|
||||
#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()
|
||||
<< " "
|
||||
<< "union_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& wkt1, std::string const& wkt2,
|
||||
typename bgi::default_content_result<Geometry>::type expected_value)
|
||||
{
|
||||
Geometry geometry1, geometry2;
|
||||
bg::read_wkt(wkt1, geometry1);
|
||||
bg::read_wkt(wkt2, geometry2);
|
||||
test_union_content(geometry1, geometry2, expected_value);
|
||||
}
|
||||
|
||||
#endif
|
||||
75
test/algorithms/union_content.cpp
Normal file
75
test/algorithms/union_content.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// 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_union_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_box1, int_box2;
|
||||
bg::model::box<double_point_type> double_box1, double_box2;
|
||||
|
||||
std::string const box_li1 = "POLYGON((1536119 192000, 1872000 528000))";
|
||||
std::string const box_li2 = "POLYGON((1701234 368250, 2673400 777400))";
|
||||
bg::read_wkt(box_li1, int_box1);
|
||||
bg::read_wkt(box_li1, double_box1);
|
||||
bg::read_wkt(box_li2, int_box2);
|
||||
bg::read_wkt(box_li2, double_box2);
|
||||
|
||||
double int_value = bgi::union_content(int_box1, int_box2);
|
||||
double double_value = bgi::union_content(double_box1, double_box2);
|
||||
|
||||
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))", "POLYGON((1 2,3 5))", 12.0);
|
||||
test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 12.0);
|
||||
test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 12.0);
|
||||
test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
|
||||
test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
|
||||
test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
|
||||
|
||||
test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((2 1,3 4))", 9.0);
|
||||
test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((2 4,3 5))", 12.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))", "POLYGON((1 2,3 5))", 12.0);
|
||||
test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
|
||||
#endif
|
||||
|
||||
test_large_integers();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user