1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
// 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.
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// 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 <geometry_test_common.hpp>
#include <boost/geometry/algorithms/make.hpp>
#include <boost/geometry/io/wkt/write.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/adapted/c_array.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#include <test_common/test_point.hpp>
BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
template <typename T, typename P>
void test_point_2d()
{
P p = bg::make<P>((T) 123, (T) 456);
BOOST_CHECK_CLOSE(bg::get<0>(p), 123.0, 1.0e-6);
BOOST_CHECK_CLOSE(bg::get<1>(p), 456.0, 1.0e-6);
}
template <typename T, typename P>
void test_point_3d()
{
P p = bg::make<P>((T) 123, (T) 456, (T) 789);
BOOST_CHECK_CLOSE( bg::get<0>(p), 123.0, 1.0e-6);
BOOST_CHECK_CLOSE( bg::get<1>(p), 456.0, 1.0e-6);
BOOST_CHECK_CLOSE( bg::get<2>(p), 789.0, 1.0e-6);
}
template <typename T, typename P>
void test_box_2d()
{
typedef bg::model::box<P> B;
B b = bg::make<B>((T) 123, (T) 456, (T) 789, (T) 1011);
BOOST_CHECK_CLOSE( (bg::get<bg::min_corner, 0>(b)), 123.0, 1.0e-6);
BOOST_CHECK_CLOSE( (bg::get<bg::min_corner, 1>(b)), 456.0, 1.0e-6);
BOOST_CHECK_CLOSE( (bg::get<bg::max_corner, 0>(b)), 789.0, 1.0e-6);
BOOST_CHECK_CLOSE( (bg::get<bg::max_corner, 1>(b)), 1011.0, 1.0e-6);
b = bg::make_inverse<B>();
}
template <typename T, typename P>
void test_linestring_2d()
{
typedef bg::model::linestring<P> L;
T coors[][2] = {{1,2}, {3,4}};
L line = bg::detail::make::make_points<L>(coors);
BOOST_CHECK_EQUAL(line.size(), 2u);
}
template <typename T, typename P>
void test_linestring_3d()
{
typedef bg::model::linestring<P> L;
T coors[][3] = {{1,2,3}, {4,5,6}};
L line = bg::detail::make::make_points<L>(coors);
BOOST_CHECK_EQUAL(line.size(), 2u);
//std::cout << dsv(line) << std::endl;
}
template <typename T, typename P>
void test_2d_t()
{
test_point_2d<T, P>();
test_box_2d<T, P>();
test_linestring_2d<T, P>();
}
template <typename P>
void test_2d()
{
test_2d_t<int, P>();
test_2d_t<float, P>();
test_2d_t<double, P>();
}
template <typename T, typename P>
void test_3d_t()
{
test_linestring_3d<T, P>();
// test_point_3d<T, test_point>();
}
template <typename P>
void test_3d()
{
test_3d_t<int, P>();
test_3d_t<float, P>();
test_3d_t<double, P>();
}
template <typename P>
void test_2d_constexpr()
{
constexpr P p = bg::make<P>(1, 2);
BOOST_CHECK_EQUAL((bg::get<0>(p)), 1);
BOOST_CHECK_EQUAL((bg::get<1>(p)), 2);
}
template <typename P>
void test_3d_constexpr()
{
constexpr P p = bg::make<P>(1, 2, 3);
BOOST_CHECK_EQUAL((bg::get<0>(p)), 1);
BOOST_CHECK_EQUAL((bg::get<1>(p)), 2);
BOOST_CHECK_EQUAL((bg::get<2>(p)), 3);
}
int test_main(int, char* [])
{
//test_2d<int[2]>();
//test_2d<float[2]>();
//test_2d<double[2]>();
test_2d<bg::model::point<int, 2, bg::cs::cartesian> >();
test_2d<bg::model::point<float, 2, bg::cs::cartesian> >();
test_2d<bg::model::point<double, 2, bg::cs::cartesian> >();
test_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
test_2d_constexpr<bg::model::point<double, 2, bg::cs::cartesian> >();
test_3d_constexpr<bg::model::point<double, 3, bg::cs::cartesian> >();
return 0;
}
|