Merge branch 'develop' into bg-prepare

Conflicts:
	test/algorithms/buffer/multi_point_buffer.cpp
This commit is contained in:
Barend Gehrels
2015-03-04 13:21:20 +01:00
20 changed files with 507 additions and 247 deletions

View File

@@ -59,6 +59,10 @@ static std::string const crossing = "LINESTRING(0 0,10 10,10 0,0 10)";
// Simplified cases from multi_linestring tesets:
static std::string const mikado1 = "LINESTRING(11.406143344709896325639419956133 0.75426621160409546007485914742574,12 1,11.403846153846153299582510953769 0.75)";
static std::string const mysql_report_2015_03_02a = "LINESTRING(0 0,0 5,5 5,5 0,0 0)"; // closed
static std::string const mysql_report_2015_03_02b = "LINESTRING(0 1,0 5,5 5,5 0,1 0)"; // not closed, 1 difference
static std::string const mysql_report_2015_03_02c = "LINESTRING(0 2,0 5,5 5,5 0,2 0)"; // not closed, 2 difference
template <bool Clockwise, typename P>
void test_all()
@@ -166,6 +170,40 @@ void test_all()
test_one<linestring, polygon>("degenerate4", degenerate4, join_round, end_round, 36.7410, 3.0);
test_one<linestring, polygon>("degenerate4", degenerate4, join_round, end_flat, 8.4853, 3.0);
{
// These tests do test behaviour in end_round strategy:
// -> it should generate closed pieces, also for an odd number of points.
// It also tests behaviour in join_round strategy:
// -> it should generate e.g. 4 points for a full circle,
// so a quarter circle does not get points in between
using bg::strategy::buffer::join_round;
using bg::strategy::buffer::end_round;
double const d10 = 1.0;
test_one<linestring, polygon>("mysql_report_2015_03_02a_3", mysql_report_2015_03_02a, join_round(3), end_round(3), 38.000, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02a_4", mysql_report_2015_03_02a, join_round(4), end_round(4), 38.000, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02a_5", mysql_report_2015_03_02a, join_round(5), end_round(5), 38.169, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02a_6", mysql_report_2015_03_02a, join_round(6), end_round(6), 38.196, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02a_7", mysql_report_2015_03_02a, join_round(7), end_round(7), 38.230, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02b_3", mysql_report_2015_03_02b, join_round(3), end_round(3), 36.500, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02b_4", mysql_report_2015_03_02b, join_round(4), end_round(4), 36.500, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02b_5", mysql_report_2015_03_02b, join_round(5), end_round(5), 36.724, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02b_6", mysql_report_2015_03_02b, join_round(6), end_round(6), 36.781, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02b_7", mysql_report_2015_03_02b, join_round(7), end_round(7), 36.884, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02c_3", mysql_report_2015_03_02c, join_round(2), end_round(3), 32.500, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02c_4", mysql_report_2015_03_02c, join_round(4), end_round(4), 32.500, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02c_5", mysql_report_2015_03_02c, join_round(5), end_round(5), 32.990, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02c_6", mysql_report_2015_03_02c, join_round(6), end_round(6), 33.098, d10);
test_one<linestring, polygon>("mysql_report_2015_03_02c_7", mysql_report_2015_03_02c, join_round(7), end_round(7), 33.279, d10);
// Testing the asymmetric end caps with odd number of points
double const d15 = 1.5;
test_one<linestring, polygon>("mysql_report_2015_03_02c_asym1", mysql_report_2015_03_02c, join_round(7), end_round(7), 39.093, d10, d15);
test_one<linestring, polygon>("mysql_report_2015_03_02c_asym2", mysql_report_2015_03_02c, join_round(7), end_round(7), 44.718, d15, d10);
}
{
double tolerance = 1.0e-10;

View File

@@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2012-2015 Barend Gehrels, 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
@@ -73,44 +73,74 @@ void test_all()
distance_strategy(0.54), side_strategy, point_strategy, 99);
#endif
}
test_with_custom_strategies<multi_point_type, polygon>("mysql_report_2015_02_25_1_800",
mysql_report_2015_02_25_1, join_miter, end_flat,
distance_strategy(6051788), side_strategy,
bg::strategy::buffer::point_circle(800), 115057490003226.125, 1.0);
}
template <typename P>
void test_many_points_per_circle()
{
// Tests for large distances / many points in circles.
// Before Boost 1.58, this would (seem to) hang. It is solved by using monotonic sections in get_turns for buffer
// This is more time consuming, only calculate this for counter clockwise
if (! BOOST_GEOMETRY_CONDITION(Clockwise))
{
// Reported by MySQL 2015-02-25
// SELECT ST_ASTEXT(ST_BUFFER(ST_GEOMFROMTEXT(''), 6051788, ST_BUFFER_STRATEGY('point_circle', 83585)));
// SELECT ST_ASTEXT(ST_BUFFER(ST_GEOMFROMTEXT(''), 5666962, ST_BUFFER_STRATEGY('point_circle', 46641))) ;
// Reported by MySQL 2015-02-25
// SELECT ST_ASTEXT(ST_BUFFER(ST_GEOMFROMTEXT(''), 6051788, ST_BUFFER_STRATEGY('point_circle', 83585)));
// SELECT ST_ASTEXT(ST_BUFFER(ST_GEOMFROMTEXT(''), 5666962, ST_BUFFER_STRATEGY('point_circle', 46641))) ;
using bg::strategy::buffer::point_circle;
test_with_custom_strategies<multi_point_type, polygon>("mysql_report_2015_02_25_1_800",
mysql_report_2015_02_25_1, join_miter, end_flat,
distance_strategy(6051788), side_strategy, point_circle(800), 115057490003226.125, 1.0);
typedef bg::model::polygon<P, false> polygon;
typedef bg::model::multi_point<P> multi_point_type;
test_with_custom_strategies<multi_point_type, polygon>("mysql_report_2015_02_25_1_8000",
mysql_report_2015_02_25_1, join_miter, end_flat,
distance_strategy(6051788), side_strategy, point_circle(8000), 115058661065242.812, 1.0);
bg::strategy::buffer::join_miter join_miter;
bg::strategy::buffer::end_flat end_flat;
typedef bg::strategy::buffer::distance_symmetric
<
typename bg::coordinate_type<P>::type
> distance_strategy;
bg::strategy::buffer::side_straight side_strategy;
test_with_custom_strategies<multi_point_type, polygon>("mysql_report_2015_02_25_1",
mysql_report_2015_02_25_1, join_miter, end_flat,
distance_strategy(6051788), side_strategy, point_circle(83585), 115058672785611.219, 1.0);
using bg::strategy::buffer::point_circle;
double const tolerance = 1.0;
// Strategies with many points, which are (very) slow in debug mode
test_with_custom_strategies<multi_point_type, polygon>(
"mysql_report_2015_02_25_1_8000",
mysql_report_2015_02_25_1, join_miter, end_flat,
distance_strategy(6051788), side_strategy, point_circle(8000),
115058661065242.812, tolerance);
test_with_custom_strategies<multi_point_type, polygon>(
"mysql_report_2015_02_25_1",
mysql_report_2015_02_25_1, join_miter, end_flat,
distance_strategy(6051788), side_strategy, point_circle(83585),
115058672785611.219, tolerance);
// Takes about 20 seconds in release mode
test_with_custom_strategies<multi_point_type, polygon>(
"mysql_report_2015_02_25_1_250k",
mysql_report_2015_02_25_1, join_miter, end_flat,
distance_strategy(6051788), side_strategy, point_circle(250000),
115058672880671.531, tolerance);
#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS)
// Try to specify even more points per circle
// Turns are calculated in 23 seconds
// But the follow-up still takes too long (there are 63409 turns), this might be improved too
test_with_custom_strategies<multi_point_type, polygon>("mysql_report_2015_02_25_1",
mysql_report_2015_02_25_1, join_miter, end_flat,
distance_strategy(6051788), side_strategy, point_circle(800000), 115058672799999.999, 1.0); // area to be determined
// Takes too long, TODO improve turn_in_piece_visitor
test_with_custom_strategies<multi_point_type, polygon>(
"mysql_report_2015_02_25_1",
mysql_report_2015_02_25_1, join_miter, end_flat,
distance_strategy(6051788), side_strategy, point_circle(800000),
115058672799999.999, tolerance); // area to be determined
#endif
test_with_custom_strategies<multi_point_type, polygon>("mysql_report_2015_02_25_2",
mysql_report_2015_02_25_2, join_miter, end_flat,
distance_strategy(5666962), side_strategy, point_circle(46641), 100891031341757.344, 1.0);
}
test_with_custom_strategies<multi_point_type, polygon>(
"mysql_report_2015_02_25_2",
mysql_report_2015_02_25_2, join_miter, end_flat,
distance_strategy(5666962), side_strategy, point_circle(46641),
100891031341757.344, tolerance);
}
int test_main(int, char* [])
@@ -118,5 +148,11 @@ int test_main(int, char* [])
test_all<true, bg::model::point<double, 2, bg::cs::cartesian> >();
test_all<false, bg::model::point<double, 2, bg::cs::cartesian> >();
#if defined(BOOST_GEOMETRY_COMPILER_MODE_RELEASE) && ! defined(BOOST_GEOMETRY_COMPILER_MODE_DEBUG)
test_many_points_per_circle<bg::model::point<double, 2, bg::cs::cartesian> >();
#else
std::cout << "Skipping some tests in debug or unknown mode" << std::endl;
#endif
return 0;
}

View File

@@ -532,18 +532,65 @@ void test_all()
{
bg::strategy::buffer::join_round join_round12(12);
buffer_custom_side_strategy side_strategy;
using bg::strategy::buffer::join_round;
using bg::strategy::buffer::join_miter;
bg::strategy::buffer::side_straight side_strategy;
bg::strategy::buffer::point_circle point_strategy;
bg::strategy::buffer::distance_symmetric
typedef bg::strategy::buffer::distance_symmetric
<
typename bg::coordinate_type<P>::type
> distance_strategy(1.0);
> distance;
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle",
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle_j12",
sharp_triangle,
join_round12, end_flat, distance_strategy, side_strategy, point_strategy,
31.0721);
join_round(12), end_flat, distance(1.0), side_strategy, point_strategy,
29.0980);
// Test very various number of points (min is 3)
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle_j2",
sharp_triangle,
join_round(2), end_flat, distance(1.0), side_strategy, point_strategy,
27.2399);
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle_j5",
sharp_triangle,
join_round(5), end_flat, distance(1.0), side_strategy, point_strategy,
28.1091);
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle_j36",
sharp_triangle,
join_round(36), end_flat, distance(1.0), side_strategy, point_strategy,
29.2482);
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle_j360",
sharp_triangle,
join_round(360), end_flat, distance(1.0), side_strategy, point_strategy,
29.2659);
// Test with various miter limits
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle_m2",
sharp_triangle,
join_miter(2), end_flat, distance(4.0), side_strategy, point_strategy,
148.500);
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle_m3",
sharp_triangle,
join_miter(3), end_flat, distance(4.0), side_strategy, point_strategy,
164.376);
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle_m4",
sharp_triangle,
join_miter(4), end_flat, distance(4.0), side_strategy, point_strategy,
180.2529);
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle_m5",
sharp_triangle,
join_miter(5), end_flat, distance(4.0), side_strategy, point_strategy,
196.1293);
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle_m25",
sharp_triangle,
join_miter(25), end_flat, distance(4.0), side_strategy, point_strategy,
244.7471);
buffer_custom_side_strategy custom_side_strategy;
test_with_custom_strategies<polygon_type, polygon_type>("sharp_triangle_custom_side",
sharp_triangle,
join_round(49), end_flat, distance(1.0), custom_side_strategy, point_strategy,
31.1087);
}
}

View File

@@ -688,7 +688,10 @@ void test_one(std::string const& caseid, std::string const& wkt,
check_self_intersections, expected_area,
tolerance, NULL);
#if !defined(BOOST_GEOMETRY_COMPILER_MODE_DEBUG) && defined(BOOST_GEOMETRY_COMPILER_MODE_RELEASE)
// Also test symmetric distance strategy if right-distance is not specified
// (only in release mode)
if (bg::math::equals(distance_right, -999))
{
bg::strategy::buffer::distance_symmetric
@@ -704,6 +707,7 @@ void test_one(std::string const& caseid, std::string const& wkt,
tolerance, NULL);
}
#endif
}
// Version (currently for the Aimes test) counting self-ip's instead of checking