Included case sent to list on 2011-06-27 by Phillip in intersection/union/difference testcases.

Added if_typed and if_typed_tt helper functions

[SVN r72857]
This commit is contained in:
Barend Gehrels 2011-07-02 14:58:53 +00:00
parent 7b792b1a73
commit 06e1044fb8
5 changed files with 109 additions and 44 deletions

View File

@ -46,8 +46,7 @@ void test_all()
typedef bg::model::polygon<P> polygon;
typedef bg::model::ring<P> ring;
bool const is_float =
boost::is_same<typename bg::coordinate_type<P>::type, float>::value;
typedef typename bg::coordinate_type<P>::type ct;
test_one<polygon, polygon, polygon>("simplex_normal",
simplex_normal[0], simplex_normal[1],
@ -93,7 +92,7 @@ void test_all()
test_one<polygon, polygon, polygon>("distance_zero",
distance_zero[0], distance_zero[1],
2, 0, 8.7048386,
is_float ? 1 : 2, // The too small one is discarded for floating point
if_typed<ct, float>(1, 2), // The too small one is discarded for floating point
0, 0.0098387);
@ -200,17 +199,42 @@ void test_all()
***/
#ifdef _MSC_VER
{
// Isovist (submitted by Brandon during Formal Review)
std::string tn = string_from_type<typename bg::coordinate_type<polygon>::type>::name();
test_one<polygon, polygon, polygon>("isovist",
isovist1[0], isovist1[1],
4, 0, 0.279121891701124,
4, 0, 224.889211358929,
0.01);
}
#endif
// Isovist (submitted by Brandon during Formal Review)
test_one<polygon, polygon, polygon>("isovist",
isovist1[0], isovist1[1],
4, 0, 0.279121891701124,
4, 0, 224.889211358929,
0.01);
test_one<polygon, polygon, polygon>("ggl_list_20110306_javier",
ggl_list_20110306_javier[0], ggl_list_20110306_javier[1],
1, 0, 71495.3331,
2, 0, 8960.49049);
#endif
test_one<polygon, polygon, polygon>("ggl_list_20110307_javier",
ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
1, 0, 16815.6,
1, 0, 3200.4,
0.01);
// 2011-07-02
// Interesting FP-precision case.
// sql server gives: 6.62295817619452E-05
// PostGIS gives: 0.0 (no output)
// Boost.Geometry gives results depending on FP-type, and compiler, and operating system.
test_one<polygon, polygon, polygon>("ggl_list_20110627_phillip",
ggl_list_20110627_phillip[0], ggl_list_20110627_phillip[1],
if_typed<ct, double>(0, 1), 0,
if_typed<ct, double>(0.0, if_typed<ct, float>(0.000383878,
0.0000000000001105367)),
1, 0, 3577.40960816756
#ifdef _MSC_VER
, 0.01
#else
, if_typed<ct, float>(50.0, 0.01)
#endif
);
// Other combi's
{

View File

@ -23,6 +23,7 @@
#include <algorithms/test_intersection.hpp>
#include <algorithms/test_overlay.hpp>
#include <algorithms/overlay/overlay_cases.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/register/linestring.hpp>
@ -155,19 +156,34 @@ void test_areal()
crossed[0], crossed[1],
3, 0, 1.5);
typedef typename bg::coordinate_type<Polygon>::type ct;
#ifdef _MSC_VER
{
// Isovist (submitted by Brandon during Formal Review)
std::string tn = string_from_type<typename bg::coordinate_type<Polygon>::type>::name();
test_one<Polygon, Polygon, Polygon>("isovist",
isovist1[0], isovist1[1],
1,
tn == std::string("f") ? 19 : tn == std::string("d") ? 22 : 20,
88.19203,
tn == std::string("f") ? 0.5 : tn == std::string("d") ? 0.1 : 0.01);
}
// Isovist (submitted by Brandon during Formal Review)
test_one<Polygon, Polygon, Polygon>("isovist",
isovist1[0], isovist1[1],
1,
if_typed<ct, float>(19, if_typed<ct, double>(22, 20)),
88.19203,
if_typed<ct, float>(0.5, if_typed<ct, double>(0.1, 0.01)));
#endif
//std::cout << typeid(ct).name() << std::endl;
test_one<Polygon, Polygon, Polygon>("ggl_list_20110306_javier",
ggl_list_20110306_javier[0], ggl_list_20110306_javier[1],
1, if_typed_tt<ct>(5, 4),
0.6649875,
if_typed<ct, float>(1.0, 0.01));
test_one<Polygon, Polygon, Polygon>("ggl_list_20110307_javier",
ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
1, 4, 0.4, 0.01);
test_one<Polygon, Polygon, Polygon>("ggl_list_20110627_phillip",
ggl_list_20110627_phillip[0], ggl_list_20110627_phillip[1],
1, if_typed_tt<ct>(6, 5), 11151.6618);
return;

View File

@ -490,6 +490,21 @@ static std::string ggl_list_20110306_javier[2] =
"POLYGON((-2 2,2002 2,2002 -2002,-2 -2002,-2 2),(0 -147.00000000000003,0 -2000,2000 -2000,2000 0,104 0,440 -240,400 -280,0 -147.00000000000003))",
"POLYGON((359.99000000000001 -280,0 -182,0 -147,400.00999999999999 -280,359.99000000000001 -280))"
};
static std::string ggl_list_20110307_javier[2] =
{
"POLYGON((-2 2, 1842 2, 1842 -2362, -2 -2362, -2 2), (0 0, 0 -2360, 1840 -2360, 1840 0, 0 0))",
// "POLYGON((-0.01 -1960, 0 -1960, 0 -1880, 0.01 -1960, -0.01 -1960))"
"POLYGON ((-0.01 -1960, 80.01 -1960, 0 -1880, -0.01 -1960))"
};
static std::string ggl_list_20110627_phillip[2] =
{
"POLYGON((537.99678544791459 124.30517362077681,437.36539413622404 142.02728895075373,456.33031803043468 249.50296671450121,556.96217263181723 231.78347688272990,537.99678544791459 124.30517362077681))",
"POLYGON((437.35 142.03,461.94 281.32,564.5 263.26,539.9 123.97,437.35 142.03))"
};
// GEOS "TestOverlay" test.

View File

@ -25,26 +25,12 @@
#include <algorithms/overlay/overlay_cases.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
static std::string javier4[2] =
{
"POLYGON((-2 2, 1842 2, 1842 -2362, -2 -2362, -2 2), (0 0, 0 -2360, 1840 -2360, 1840 0, 0 0))",
// "POLYGON((-0.01 -1960, 0 -1960, 0 -1880, 0.01 -1960, -0.01 -1960))"
"POLYGON ((-0.01 -1960, 80.01 -1960, 0 -1880, -0.01 -1960))"
};
template <typename Ring, typename Polygon>
void test_areal()
{
test_one<Polygon, Polygon, Polygon>("javier4",
javier4[0], javier4[1],
1, 1, 13, 20016.4);
typedef typename bg::coordinate_type<Polygon>::type ct;
test_one<Polygon, Polygon, Polygon>("simplex_normal",
simplex_normal[0], simplex_normal[1],
@ -63,12 +49,7 @@ void test_areal()
// This sample was selected because of the border case, and ttmath generates one point more.
test_one<Polygon, Polygon, Polygon>("star_poly", example_star, example_polygon,
1, 1,
#if defined(HAVE_TTMATH)
boost::is_same<typename bg::coordinate_type<Ring>::type, ttmath_big>::value ? 28 : 27,
#else
27,
#endif
5.647949);
if_typed_tt<ct>(28, 27), 5.647949);
// Pseudo-box as Polygon
// (note, internally, the intersection points is different, so yes,
@ -237,6 +218,17 @@ void test_areal()
test_one<Polygon, Polygon, Polygon>("ggl_list_20110306_javier",
ggl_list_20110306_javier[0], ggl_list_20110306_javier[1],
1, 1, 16, 80456.4904910401);
test_one<Polygon, Polygon, Polygon>("ggl_list_20110307_javier",
ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
1, 1, 13, 20016.4);
test_one<Polygon, Polygon, Polygon>("ggl_list_20110627_phillip",
ggl_list_20110627_phillip[0], ggl_list_20110627_phillip[1],
1, 0,
if_typed<ct, double>(5, if_typed_tt<ct>(8, 7)),
14729.07145);
#ifdef _MSC_VER
{

View File

@ -94,6 +94,24 @@ template <> struct string_from_type<long double>
#endif
template <typename CoordinateType, typename T>
inline T if_typed_tt(T value_tt, T value)
{
#if defined(HAVE_TTMATH)
return boost::is_same<CoordinateType, ttmath_big>::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
{