mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-10 23:42:12 +00:00
Merged Boost.Geometry from revision 71123 to 71336
[SVN r71339]
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <geometry_test_common.hpp>
|
||||
|
||||
#include <boost/geometry/arithmetic/arithmetic.hpp>
|
||||
#include <boost/geometry/algorithms/assign.hpp>
|
||||
#include <boost/geometry/algorithms/num_points.hpp>
|
||||
|
||||
@@ -48,25 +49,25 @@ void test_assign_linestring_2d()
|
||||
{
|
||||
bg::model::linestring<Point> line;
|
||||
|
||||
// Test assignment of plain array (note that this is only possible if adapted c-array is included!
|
||||
// Test assignment of plain array (note that this is only possible if adapted c-array is included!)
|
||||
const double coors[3][2] = { {1, 2}, {3, 4}, {5, 6} };
|
||||
bg::assign(line, coors);
|
||||
bg::assign_points(line, coors);
|
||||
check_linestring_2d(line);
|
||||
|
||||
// Test assignment of point array
|
||||
Point points[3];
|
||||
bg::assign(points[0], 1, 2);
|
||||
bg::assign(points[1], 3, 4);
|
||||
bg::assign(points[2], 5, 6);
|
||||
bg::assign(line, points);
|
||||
bg::assign_values(points[0], 1, 2);
|
||||
bg::assign_values(points[1], 3, 4);
|
||||
bg::assign_values(points[2], 5, 6);
|
||||
bg::assign_points(line, points);
|
||||
check_linestring_2d(line);
|
||||
|
||||
// Test assignment of array with different point-type
|
||||
// Test assignment of array with different point-type (tuple adaption should be included)
|
||||
boost::tuple<float, float> tuples[3];
|
||||
tuples[0] = boost::make_tuple(1, 2);
|
||||
tuples[1] = boost::make_tuple(3, 4);
|
||||
tuples[2] = boost::make_tuple(5, 6);
|
||||
bg::assign(line, tuples);
|
||||
bg::assign_points(line, tuples);
|
||||
check_linestring_2d(line);
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ namespace detail
|
||||
void test_assign_box_or_segment_2d()
|
||||
{
|
||||
BoxOrSegment geometry;
|
||||
bg::assign(geometry, 1, 2, 3, 4);
|
||||
bg::assign_values(geometry, 1, 2, 3, 4);
|
||||
BOOST_CHECK((bg::get<bg::min_corner, 0>(geometry) == 1));
|
||||
BOOST_CHECK((bg::get<bg::min_corner, 1>(geometry) == 2));
|
||||
BOOST_CHECK((bg::get<bg::max_corner, 0>(geometry) == 3));
|
||||
@@ -114,12 +115,12 @@ template <typename Point>
|
||||
void test_assign_point_3d()
|
||||
{
|
||||
Point p;
|
||||
bg::assign(p, 1, 2, 3);
|
||||
bg::assign_values(p, 1, 2, 3);
|
||||
BOOST_CHECK(bg::get<0>(p) == 1);
|
||||
BOOST_CHECK(bg::get<1>(p) == 2);
|
||||
BOOST_CHECK(bg::get<2>(p) == 3);
|
||||
|
||||
bg::detail::assign::assign_value(p, 123);
|
||||
bg::assign_value(p, 123);
|
||||
BOOST_CHECK(bg::get<0>(p) == 123);
|
||||
BOOST_CHECK(bg::get<1>(p) == 123);
|
||||
BOOST_CHECK(bg::get<2>(p) == 123);
|
||||
@@ -131,15 +132,75 @@ void test_assign_point_3d()
|
||||
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_assign_conversion()
|
||||
{
|
||||
typedef bg::model::box<P> box_type;
|
||||
typedef bg::model::ring<P> ring_type;
|
||||
typedef bg::model::polygon<P> polygon_type;
|
||||
|
||||
P p;
|
||||
bg::assign_values(p, 1, 2);
|
||||
|
||||
box_type b;
|
||||
bg::assign(b, p);
|
||||
|
||||
BOOST_CHECK_CLOSE((bg::get<0, 0>(b)), 1.0, 0.001);
|
||||
BOOST_CHECK_CLOSE((bg::get<0, 1>(b)), 2.0, 0.001);
|
||||
BOOST_CHECK_CLOSE((bg::get<1, 0>(b)), 1.0, 0.001);
|
||||
BOOST_CHECK_CLOSE((bg::get<1, 1>(b)), 2.0, 0.001);
|
||||
|
||||
|
||||
bg::set<bg::min_corner, 0>(b, 1);
|
||||
bg::set<bg::min_corner, 1>(b, 2);
|
||||
bg::set<bg::max_corner, 0>(b, 3);
|
||||
bg::set<bg::max_corner, 1>(b, 4);
|
||||
|
||||
ring_type ring;
|
||||
bg::assign(ring, b);
|
||||
|
||||
//std::cout << bg::wkt(b) << std::endl;
|
||||
//std::cout << bg::wkt(ring) << std::endl;
|
||||
|
||||
typename boost::range_const_iterator<ring_type>::type it = ring.begin();
|
||||
BOOST_CHECK_CLOSE(bg::get<0>(*it), 1.0, 0.001);
|
||||
BOOST_CHECK_CLOSE(bg::get<1>(*it), 2.0, 0.001);
|
||||
it++;
|
||||
BOOST_CHECK_CLOSE(bg::get<0>(*it), 1.0, 0.001);
|
||||
BOOST_CHECK_CLOSE(bg::get<1>(*it), 4.0, 0.001);
|
||||
it++;
|
||||
BOOST_CHECK_CLOSE(bg::get<0>(*it), 3.0, 0.001);
|
||||
BOOST_CHECK_CLOSE(bg::get<1>(*it), 4.0, 0.001);
|
||||
it++;
|
||||
BOOST_CHECK_CLOSE(bg::get<0>(*it), 3.0, 0.001);
|
||||
BOOST_CHECK_CLOSE(bg::get<1>(*it), 2.0, 0.001);
|
||||
it++;
|
||||
BOOST_CHECK_CLOSE(bg::get<0>(*it), 1.0, 0.001);
|
||||
BOOST_CHECK_CLOSE(bg::get<1>(*it), 2.0, 0.001);
|
||||
|
||||
BOOST_CHECK_EQUAL(ring.size(), 5u);
|
||||
|
||||
|
||||
polygon_type polygon;
|
||||
|
||||
bg::assign(polygon, ring);
|
||||
BOOST_CHECK_EQUAL(bg::num_points(polygon), 5u);
|
||||
|
||||
ring_type ring2;
|
||||
bg::assign(ring2, polygon);
|
||||
BOOST_CHECK_EQUAL(bg::num_points(ring2), 5u);
|
||||
}
|
||||
|
||||
|
||||
template <typename Point>
|
||||
void test_assign_point_2d()
|
||||
{
|
||||
Point p;
|
||||
bg::assign(p, 1, 2);
|
||||
bg::assign_values(p, 1, 2);
|
||||
BOOST_CHECK(bg::get<0>(p) == 1);
|
||||
BOOST_CHECK(bg::get<1>(p) == 2);
|
||||
|
||||
bg::detail::assign::assign_value(p, 123);
|
||||
bg::assign_value(p, 123);
|
||||
BOOST_CHECK(bg::get<0>(p) == 123);
|
||||
BOOST_CHECK(bg::get<1>(p) == 123);
|
||||
|
||||
@@ -148,6 +209,10 @@ void test_assign_point_2d()
|
||||
BOOST_CHECK(bg::get<1>(p) == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_assign_point_3d<int[3]>();
|
||||
@@ -165,6 +230,9 @@ int test_main(int, char* [])
|
||||
test_assign_point_2d<bg::model::point<float, 2, bg::cs::cartesian> >();
|
||||
test_assign_point_2d<bg::model::point<double, 2, bg::cs::cartesian> >();
|
||||
|
||||
test_assign_conversion<bg::model::point<double, 2, bg::cs::cartesian> >();
|
||||
|
||||
|
||||
// Segment (currently) cannot handle array's because derived from std::pair
|
||||
test_assign_box_2d<int[2]>();
|
||||
test_assign_box_2d<float[2]>();
|
||||
|
||||
Reference in New Issue
Block a user