mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-23 15:52:09 +00:00
Merge remote-tracking branch 'origin/develop' into feature_box_seg
This commit is contained in:
@@ -29,6 +29,7 @@ test-suite boost-geometry-algorithms
|
||||
[ run correct.cpp : : : : algorithms_correct ]
|
||||
[ run correct_multi.cpp : : : : algorithms_correct_multi ]
|
||||
[ run correct_closure.cpp : : : : algorithms_correct_closure ]
|
||||
[ run densify.cpp : : : : algorithms_densify ]
|
||||
[ run for_each.cpp : : : : algorithms_for_each ]
|
||||
[ run for_each_multi.cpp : : : : algorithms_for_each_multi ]
|
||||
[ run is_convex.cpp : : : : algorithms_is_convex ]
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2015, 2016, 2017.
|
||||
// Modifications copyright (c) 2015-2017, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
@@ -26,46 +28,46 @@ void test_geo_strategies()
|
||||
|
||||
typedef bg::model::point<CT, 2, bg::cs::geographic<bg::degree> > pt_geo;
|
||||
|
||||
bg::strategy::area::geographic<pt_geo> geographic_default;
|
||||
bg::strategy::area::geographic<> geographic_default;
|
||||
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::andoyer, 1>
|
||||
bg::strategy::area::geographic<bg::strategy::andoyer, 1>
|
||||
geographic_andoyer1;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::andoyer, 2>
|
||||
bg::strategy::area::geographic<bg::strategy::andoyer, 2>
|
||||
geographic_andoyer2;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::andoyer, 3>
|
||||
bg::strategy::area::geographic<bg::strategy::andoyer, 3>
|
||||
geographic_andoyer3;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::andoyer, 4>
|
||||
bg::strategy::area::geographic<bg::strategy::andoyer, 4>
|
||||
geographic_andoyer4;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::andoyer, 5>
|
||||
bg::strategy::area::geographic<bg::strategy::andoyer, 5>
|
||||
geographic_andoyer5;
|
||||
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::thomas, 1>
|
||||
bg::strategy::area::geographic<bg::strategy::thomas, 1>
|
||||
geographic_thomas1;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::thomas, 2>
|
||||
bg::strategy::area::geographic<bg::strategy::thomas, 2>
|
||||
geographic_thomas2;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::thomas, 3>
|
||||
bg::strategy::area::geographic<bg::strategy::thomas, 3>
|
||||
geographic_thomas3;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::thomas, 4>
|
||||
bg::strategy::area::geographic<bg::strategy::thomas, 4>
|
||||
geographic_thomas4;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::thomas, 5>
|
||||
bg::strategy::area::geographic<bg::strategy::thomas, 5>
|
||||
geographic_thomas5;
|
||||
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::vincenty, 1>
|
||||
bg::strategy::area::geographic<bg::strategy::vincenty, 1>
|
||||
geographic_vincenty1;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::vincenty, 2>
|
||||
bg::strategy::area::geographic<bg::strategy::vincenty, 2>
|
||||
geographic_vincenty2;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::vincenty, 3>
|
||||
bg::strategy::area::geographic<bg::strategy::vincenty, 3>
|
||||
geographic_vincenty3;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::vincenty, 4>
|
||||
bg::strategy::area::geographic<bg::strategy::vincenty, 4>
|
||||
geographic_vincenty4;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::vincenty, 5>
|
||||
bg::strategy::area::geographic<bg::strategy::vincenty, 5>
|
||||
geographic_vincenty5;
|
||||
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::andoyer>
|
||||
bg::strategy::area::geographic<bg::strategy::andoyer>
|
||||
geographic_andoyer_default;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::thomas>
|
||||
bg::strategy::area::geographic<bg::strategy::thomas>
|
||||
geographic_thomas_default;
|
||||
bg::strategy::area::geographic<pt_geo, bg::strategy::vincenty>
|
||||
bg::strategy::area::geographic<bg::strategy::vincenty>
|
||||
geographic_vincenty_default;
|
||||
|
||||
bg::model::polygon<pt_geo> geometry_geo;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// 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.
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2015, 2016, 2017.
|
||||
// Modifications copyright (c) 2015-2017, Oracle and/or its affiliates.
|
||||
@@ -36,11 +37,8 @@ void test_spherical_geo()
|
||||
ct, 2, bg::cs::geographic<bg::degree>
|
||||
> pt_geo;
|
||||
|
||||
typedef typename bg::point_type<pt_geo>::type pt_geo_type;
|
||||
|
||||
bg::strategy::area::geographic
|
||||
<
|
||||
pt_geo_type,
|
||||
bg::strategy::vincenty,
|
||||
5
|
||||
> area_geographic;
|
||||
@@ -61,7 +59,7 @@ void test_spherical_geo()
|
||||
|
||||
bg::strategy::area::spherical
|
||||
<
|
||||
typename bg::point_type<pt>::type
|
||||
ct
|
||||
> strategy_unary(1.0);
|
||||
|
||||
ct const four = 4.0;
|
||||
@@ -74,7 +72,7 @@ void test_spherical_geo()
|
||||
// With strategy, radius 2 -> 4 pi r^2
|
||||
bg::strategy::area::spherical
|
||||
<
|
||||
typename bg::point_type<pt>::type
|
||||
ct
|
||||
> strategy(2.0);
|
||||
|
||||
area = bg::area(geometry, strategy);
|
||||
@@ -96,7 +94,7 @@ void test_spherical_geo()
|
||||
|
||||
bg::strategy::area::spherical
|
||||
<
|
||||
typename bg::point_type<pt>::type
|
||||
ct
|
||||
> spherical_earth(6373);
|
||||
bg::read_wkt(poly, geometry);
|
||||
area = bg::area(geometry, spherical_earth);
|
||||
@@ -376,7 +374,7 @@ void test_spherical_geo()
|
||||
}*/
|
||||
bg::strategy::area::spherical
|
||||
<
|
||||
typename bg::point_type<pt>::type
|
||||
ct
|
||||
> area_spherical(6372.795);
|
||||
area = bg::area(aurha, area_spherical);
|
||||
BOOST_CHECK_CLOSE(area, 1476.645675, 0.0001);
|
||||
@@ -395,13 +393,13 @@ void test_spherical_geo()
|
||||
std::string wkt = "POLYGON((0 0, 5 0, 5 5, 0 5, 0 0))";
|
||||
bg::read_wkt(wkt, geometry_sph);
|
||||
|
||||
area = bg::area(geometry_sph, bg::strategy::area::spherical<pt>(6371228.0));
|
||||
area = bg::area(geometry_sph, bg::strategy::area::spherical<>(6371228.0));
|
||||
BOOST_CHECK_CLOSE(area, 308932296103.83051, 0.0001);
|
||||
|
||||
bg::model::polygon<pt_geo, false> geometry_geo;
|
||||
bg::read_wkt(wkt, geometry_geo);
|
||||
|
||||
area = bg::area(geometry_geo, bg::strategy::area::geographic<pt_geo>(bg::srs::spheroid<double>(6371228.0, 6371228.0)));
|
||||
area = bg::area(geometry_geo, bg::strategy::area::geographic<>(bg::srs::spheroid<double>(6371228.0, 6371228.0)));
|
||||
BOOST_CHECK_CLOSE(area, 308932296103.82574, 0.001);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2017 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
|
||||
@@ -40,16 +41,12 @@ void test_area(Geometry const& geometry,
|
||||
BOOST_CHECK_CLOSE(area, expected_area, 0.0001);
|
||||
|
||||
// Test with explicitly defined strategies
|
||||
bg::strategy::area::surveyor
|
||||
<
|
||||
typename bg::point_type<Geometry>::type
|
||||
> strategy1;
|
||||
bg::strategy::area::cartesian<> strategy1;
|
||||
|
||||
area = bg::area(geometry, strategy1);
|
||||
|
||||
bg::strategy::area::surveyor
|
||||
bg::strategy::area::cartesian
|
||||
<
|
||||
typename bg::point_type<Geometry>::type,
|
||||
typename bg::coordinate_type<Geometry>::type
|
||||
> strategy2;
|
||||
|
||||
|
||||
@@ -44,6 +44,21 @@ static std::string const mysql_23023665_1 = "MULTILINESTRING((-5 15, 7 15, 19 -1
|
||||
static std::string const touching1 = "MULTILINESTRING((-5 15, 9 15),(2 13, 2 0),(-4 14.75,-4 13),(8 15.25,8 13),(1.5 1,-1 1),(2.25 4,5 4))";
|
||||
static std::string const touching2 = "MULTILINESTRING((-5 15, 9 15),(2 13, 2 0),(-11 -2,9 14))";
|
||||
|
||||
static std::string const ticket_13444 = "MULTILINESTRING((-14900.3540680666540 6736752.97813679560,-14903.4321076464080 6736753.66526194570,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.2786583450830 6736754.3021534560,-14906.2786583450830 6736754.3021534560,-14922.5830341660040 6736758.55049021640,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.4931871261580 6736765.77697354280,-14943.4931871261580 6736765.77697354280,-14977.8347379614440 6736783.40904572790,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-15011.938643947820 6736805.44739563390,-15011.4855624884060 6736805.15855005480,-15044.495275804080 6736826.22277528610,-15044.636350994740 6736826.3142731870,-15044.636350994740 6736826.3142731870,-15044.636350994740 6736826.3142731870,-15044.636350994740 6736826.3142731870,-15044.636350994740 6736826.3142731870,-15044.636350994740 6736826.3142731870,-15044.636350994740 6736826.3142731870,-15059.3568953647720 6736834.30329997840,-15068.0541424639030 6736839.02352138140,-15069.4928800905110 6736839.75371170980,-15070.9534140734160 6736840.41931523480,-15087.9426162696510 6736846.96412046530,-15089.5494797231820 6736847.51131521720,-15091.1563320447620 6736848.05671593270,-15094.2349059580680 6736848.97707971370,-15335.9054238793630 6736921.18738844430000000000),"
|
||||
"(-14900.3540680666540 6736752.97813679560,-14903.4321076464080 6736753.66526194570,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.2786583450830 6736754.3021534560,-14906.2786583450830 6736754.3021534560,-14922.5830341660040 6736758.55049021640,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.4931871261580 6736765.77697354280,-14943.4931871261580 6736765.77697354280,-14977.8347379614440 6736783.40904572790,-14978.1533343440550 6736783.59921684120,-14983.6129319775540 6736787.37752308510,-14985.1947819415070 6736788.51675631760,-14986.7766319054570 6736789.65598971210,-14987.9123578781710 6736790.53687736760,-14992.4552617690170 6736794.05684083610,-14998.267508417350 6736798.72501083650,-15010.441029442540 6736809.15394911820,-15011.6583859978380 6736810.19630545840,-15022.6145949955260 6736819.58290076720,-15059.7358046474820 6736849.75929930060,-15061.0431630110740 6736850.7029863410,-15062.3505213746680 6736851.644879410,-15070.4409770615170 6736856.86027784460,-15087.1738995260860 6736866.37430707270,-15088.6108003810950 6736867.09552943430,-15095.9473782124990 6736870.45405826350,-15104.0074102825180 6736873.63317977920,-15116.207314027020 6736878.44671658990,-15123.8358828827350 6736880.87232399170,-15134.5288992083770 6736884.24879940230,-15180.7309406607860 6736898.17991495970000000000),"
|
||||
"(-14900.3540680666540 6736752.97813679560,-14903.4321076464080 6736753.66526194570,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.2786583450830 6736754.3021534560,-14906.2786583450830 6736754.3021534560,-14922.5830341660040 6736758.55049021640,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.4931871261580 6736765.77697354280,-14943.4931871261580 6736765.77697354280,-14977.8347379614440 6736783.40904572790,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-15011.938643947820 6736805.44739563390,-15011.4855624884060 6736805.15855005480,-15044.495275804080 6736826.22277528610,-15044.636350994740 6736826.3142731870,-15045.8532288762310 6736827.08752021570,-15074.3737944831540 6736845.21847973950,-15077.090034585930 6736846.94438557510,-15078.4820514222590 6736847.81092678480,-15078.071961550180 6736847.56872581780,-15087.3648458486150 6736853.06579258570,-15090.2635942565180 6736854.6786728650,-15097.9514630049710 6736858.31707360780,-15103.8265161100060 6736861.09610959050,-15130.264249516680 6736873.60626847480,-15134.7519500720480 6736875.32141580710,-15146.8630765226570 6736879.66849063620,-15194.4412940478560 6736894.61146595520,-15195.9796069589630 6736895.07075342350000000000),"
|
||||
"(-14900.3540680666540 6736752.97813679560,-14903.4321076464080 6736753.66526194570,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.2786583450830 6736754.3021534560,-14906.2786583450830 6736754.3021534560,-14922.5830341660040 6736758.55049021640,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.4931871261580 6736765.77697354280,-14943.4931871261580 6736765.77697354280,-14977.8347379614440 6736783.40904572790,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-15011.938643947820 6736805.44739563390,-15011.4855624884060 6736805.15855005480,-15044.495275804080 6736826.22277528610,-15044.636350994740 6736826.3142731870,-15045.8532288762310 6736827.08752021570,-15074.3737944831540 6736845.21847973950,-15077.090034585930 6736846.94438557510,-15078.4820514222590 6736847.81092678480,-15078.071961550180 6736847.56872581780,-15078.071961550180 6736847.56872581780,-15078.071961550180 6736847.56872581780,-15078.071961550180 6736847.56872581780,-15078.071961550180 6736847.56872581780,-15078.071961550180 6736847.56872581780,-15078.071961550180 6736847.56872581780,-15082.7943681199050 6736849.88488502430,-15097.5442785716020 6736857.11683175990,-15106.6291957973660 6736860.3533587540,-15108.2275099140060 6736860.85390822030,-15125.8089540650780 6736866.36354256610,-15127.375820425570 6736866.840769290,-15215.2540981133260 6736893.00754821770,-15218.3352769027190 6736893.92791708470,-15437.0992937759950 6736959.30128452830,-15461.7487574869660 6736966.66788661480,-15515.650723588680 6736982.80231144560,-15574.1728604397850 6737000.31823665460,-15594.0923367237140 6737006.20472987550,-15710.5446690337120 6737040.61236372680,-15712.0936018242430 6737041.03398283110,-15734.2281022037190 6737046.24412034730,-15742.1332777301140 6737048.10462824910,-15743.8434568030350 6737048.30018792950,-15748.6193127583390 6737048.65262600970000000000),"
|
||||
"(-14900.3540680666540 6736752.97813679560,-14903.4321076464080 6736753.66526194570,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.2786583450830 6736754.3021534560,-14906.2786583450830 6736754.3021534560,-14922.5830341660040 6736758.55049021640,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14943.4931871261580 6736765.77697354280,-14943.4931871261580 6736765.77697354280,-14977.8347379614440 6736783.40904572790,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-14978.1533343440550 6736783.59921684120,-15011.938643947820 6736805.44739563390,-15011.4855624884060 6736805.15855005480,-15011.4855624884060 6736805.15855005480,-15011.4855624884060 6736805.15855005480,-15011.4855624884060 6736805.15855005480,-15011.4855624884060 6736805.15855005480,-15011.4855624884060 6736805.15855005480,-15011.4855624884060 6736805.15855005480,-15024.686885240 6736812.53218883280,-15026.1816388343670 6736813.3144049160,-15030.6658773535710 6736815.65925955030,-15036.7550423671660 6736818.56027804410,-15041.3219133443780 6736820.73649111390,-15048.9609128363750 6736824.08244226970,-15050.4611878774870 6736824.67628146990,-15084.9584078886780 6736837.58108171260,-15086.4811249391280 6736838.09598240720000000000),"
|
||||
"(-14900.3540680666540 6736752.97813679560,-14903.4321076464080 6736753.66526194570,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.2786583450830 6736754.3021534560,-14906.2786583450830 6736754.3021534560,-14922.5830341660040 6736758.55049021640,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-14980.0377729478370 6736780.26763486860,-14980.0377729478370 6736780.26763486860,-14991.6555536792150 6736785.84897732640,-15011.9866671761430 6736795.61588732150,-15012.4519381197970 6736795.86346895620,-15020.770743478080 6736800.37376175450,-15022.2480644401890 6736801.17391738670,-15026.6800384584770 6736803.57797288240,-15038.4986506831680 6736809.98460484760,-15041.4533037393390 6736811.58671214340,-15058.2989705841660 6736819.98118544460,-15081.4365374991940 6736828.96412467860,-15082.9566942013570 6736829.48440706080,-15099.6784290571030 6736835.20392734280,-15104.2978317020080 6736836.58357383120,-15111.9968435314880 6736838.88358319360,-15113.5366592557220 6736839.34286751130,-15175.1290655861190 6736857.7411727840,-15252.1195734991230 6736880.73776734710,-15421.5006278668590 6736931.32583960150,-15423.0404547230450 6736931.78512913550,-15470.7754991468520 6736946.04105874990,-15498.4926942527330 6736954.32084811290,-15500.0325433728140 6736954.78013895270,-15575.3855081806230 6736977.37871549190,-15636.8689327295510 6736995.84730348080,-15638.406032258210 6736996.30839077380,-15730.631692283210 6737024.00955883970,-15733.7340329077980 6737024.91558956820,-15735.3732012775510 6737025.31388429920,-15737.0123696473070 6737025.7121790480,-15740.0858017133340 6737026.31913025120000000000),"
|
||||
"(-14900.3540680666540 6736752.97813679560,-14903.4321076464080 6736753.66526194570,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.2786583450830 6736754.3021534560,-14906.2786583450830 6736754.3021534560,-14922.5830341660040 6736758.55049021640,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-14980.0377729478370 6736780.26763486860,-14980.0377729478370 6736780.26763486860,-14991.6555536792150 6736785.84897732640,-15011.9866671761430 6736795.61588732150,-15012.4519381197970 6736795.86346895620,-15012.4519381197970 6736795.86346895620,-15012.4519381197970 6736795.86346895620,-15012.4519381197970 6736795.86346895620,-15012.4519381197970 6736795.86346895620,-15012.4519381197970 6736795.86346895620,-15012.4519381197970 6736795.86346895620,-15021.625933202080 6736800.2499708710,-15023.1507875867560 6736800.96759922520,-15027.7253396088290 6736803.12227872670,-15042.7733302609810 6736809.10550915170,-15074.0109486029650 6736819.38555251160,-15075.5483598261980 6736819.84483573210,-15089.3850385714010 6736823.99094439390,-15135.5072973447730 6736837.81251791210,-15197.0045366425070 6736856.23952505740,-15275.413533166740 6736879.73487190530000000000),"
|
||||
"(-14900.3540680666540 6736752.97813679560,-14903.4321076464080 6736753.66526194570,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.2786583450830 6736754.3021534560,-14906.2786583450830 6736754.3021534560,-14922.5830341660040 6736758.55049021640,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-15030.7446692891440 6736797.61627536640,-15031.1498499716740 6736797.74544842350,-15038.6298407030480 6736800.08671043440,-15040.2125700909780 6736800.58187397570,-15044.9607693867150 6736802.06915886140,-15048.1262281625750 6736803.05948622340,-15059.2053672739280 6736806.52922108490,-15060.808434732820 6736807.02797317230,-15070.4268283542390 6736810.02228038110,-15090.7124010474890 6736816.33562555160,-15093.7912866553690 6736817.2649561130,-15109.1857035628240 6736821.91519868650,-15121.5012459943460 6736825.63611227830,-15139.9829308673380 6736831.19236878680,-15292.4567809757460 6736877.02759306690,-15297.0794564136850 6736878.40904073880,-15352.5515616689190 6736894.99530161920000000000),"
|
||||
"(-14900.3540680666540 6736752.97813679560,-14903.4321076464080 6736753.66526194570,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.2786583450830 6736754.3021534560,-14906.2786583450830 6736754.3021534560,-14922.5830341660040 6736758.55049021640,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-15030.7446692891440 6736797.61627536640,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15063.4394263695590 6736806.12734892960,-15077.96973686180 6736809.90028341770,-15079.4709581185830 6736810.20886396620,-15112.4978702955780 6736817.01378568450,-15112.4978702955780 6736817.01378568450,-15112.4978702955780 6736817.01378568450,-15112.4978702955780 6736817.01378568450,-15112.4978702955780 6736817.01378568450,-15112.4978702955780 6736817.01378568450,-15111.7280180932050 6736816.8612893540,-15111.7280180932050 6736816.8612893540,-15136.404287537560 6736822.99882040450,-15160.8745380003330 6736830.05133549120,-15177.1880420194980 6736834.75361365080,-15266.4520692562510 6736861.47645545290,-15269.4815178782760 6736862.38605624720,-15320.982200112470 6736877.84569711610,-15416.0519172795560 6736906.38250955010,-15422.1735541886120 6736908.2142799450,-15480.3290491648930 6736925.62239861490,-15523.3135120558580 6736938.44483037390,-15529.4541957297860 6736940.27660798650,-15676.8305371123480 6736984.23760042710,-15684.5052033691940 6736986.53406332340,-15705.9942844730870 6736992.96236877050,-15715.0598543713510 6736996.18818513960,-15722.6144959532430 6736998.8775624940,-15729.8982749501720 6737002.20385167190000000000),"
|
||||
"(-14900.3540680666540 6736752.97813679560,-14903.4321076464080 6736753.66526194570,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.2786583450830 6736754.3021534560,-14906.2786583450830 6736754.3021534560,-14922.5830341660040 6736758.55049021640,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-15030.7446692891440 6736797.61627536640,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15063.4394263695590 6736806.12734892960,-15077.96973686180 6736809.90028341770,-15079.4709581185830 6736810.20886396620,-15112.4978702955780 6736817.01378568450,-15112.4978702955780 6736817.01378568450,-15123.5406969890390 6736819.20973316490,-15126.6957919203090 6736819.83765943070,-15137.7386408776670 6736822.03360766730,-15142.4712888405410 6736822.97549742090,-15186.6427180658250 6736831.75929733830,-15188.2202710974380 6736832.07326094250,-15189.7978241290440 6736832.38722456990,-15190.0044887636720 6736832.42848835510,-15222.1556839025690 6736840.72251470480,-15234.5402332864270 6736844.34835063950,-15269.996782405240 6736854.92625629810,-15379.4496123019090 6736887.58221805560,-15387.1575630864950 6736889.88224184050,-15474.9321578005460 6736916.19621079690,-15481.0917769198550 6736918.0423361780,-15541.148430687430 6736936.04611730850,-15680.1650234030040 6736978.02997740640,-15694.0778224160020 6736982.24254881030,-15695.6236827885860 6736982.71081178360,-15697.0432178030370 6736983.18086888920,-15719.1585489661970 6736991.21490258910,-15720.7032404841320 6736991.83387157130,-15723.554088115150 6736993.14357420990,-15726.4049394568230 6736994.45417464520000000000),"
|
||||
"(-14900.3540680666540 6736752.97813679560,-14903.4321076464080 6736753.66526194570,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.5703376748190 6736754.36135745610,-14906.2786583450830 6736754.3021534560,-14906.2786583450830 6736754.3021534560,-14922.5830341660040 6736758.55049021640,-14943.1461152178110 6736765.65497725270,-14943.1461152178110 6736765.65497725270,-14980.5459018954430 6736780.45959997360,-14980.5459018954430 6736780.45959997360,-15030.7446692891440 6736797.61627536640,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15031.1498499716740 6736797.74544842350,-15063.4394263695590 6736806.12734892960,-15077.96973686180 6736809.90028341770,-15079.4709581185830 6736810.20886396620,-15112.4978702955780 6736817.01378568450,-15112.4978702955780 6736817.01378568450,-15123.5406969890390 6736819.20973316490,-15126.6957919203090 6736819.83765943070,-15137.7386408776670 6736822.03360766730,-15142.4712888405410 6736822.97549742090,-15186.6427180658250 6736831.75929733830,-15188.2202710974380 6736832.07326094250,-15189.7978241290440 6736832.38722456990,-15190.0044887636720 6736832.42848835510,-15190.0044887636720 6736832.42848835510,-15190.0044887636720 6736832.42848835510,-15190.0044887636720 6736832.42848835510,-15190.0044887636720 6736832.42848835510,-15190.0044887636720 6736832.42848835510,-15190.0044887636720 6736832.42848835510,-15221.983183219660 6736838.87281871770,-15268.3061621668480 6736848.24688855470,-15269.855061561530 6736848.63441014480,-15300.8331273788140 6736856.38484578950,-15302.3963647239070 6736856.82798435070,-15308.5770232269750 6736858.67050808390,-15393.5610720781510 6736884.00839143530,-15395.0947874942920 6736884.46947239150,-15454.9098758556520 6736902.42873865920000000000),"
|
||||
"(-15035.8556810692230 6736780.3429856580,-15067.3888192633710 6736786.679630680,-15089.4620493951220 6736791.11456749960,-15098.9220131172680 6736793.01628063250,-15102.0753269366810 6736793.64958708270,-15102.0753269366810 6736793.64958708270,-15105.2380806489130 6736794.28289358780,-15106.8190066610910 6736794.59864982220,-15166.8942062558330 6736806.61713062690,-15195.3829901481420 6736812.31510593650,-15290.2728818098240 6736831.29463120830,-15329.8103366688590 6736839.2029293180,-15347.0557184092210 6736843.2109036660,-15351.6484711680370 6736844.44164282270,-15368.3596751999520 6736850.43566813880,-15371.3980739090370 6736851.52467590480,-15377.4497910459360 6736854.09380189050,-15380.4756551803580 6736855.37657110580,-15413.5284714028580 6736872.262497440,-15414.9655503690590 6736872.99627892490,-15443.2170790306680 6736887.49968991610,-15454.8128073709250 6736892.57876041620,-15456.2628661897430 6736893.2013100730,-15459.1629949593350 6736894.44461543950,-15471.4299019053380 6736898.62305579240,-15486.7635383708280 6736903.84745482360,-15524.6976920000360 6736915.32428000490,-15532.5896984306750 6736917.71222237870,-15543.2866888621390 6736920.94877348280,-15543.2866888621390 6736920.94877348280,-15543.2866888621390 6736920.94877348280,-15543.2866888621390 6736920.94877348280,-15543.2866888621390 6736920.94877348280,-15543.2866888621390 6736920.94877348280,-15543.1144664779570 6736920.89674465540,-15543.1144664779570 6736920.89674465540,-15569.2930703739980 6736931.11772403310000000000),"
|
||||
"(-14999.0450639284860 6736757.94409741740,-14999.0450639284860 6736757.94409741740,-14999.0450639284860 6736757.94409741740,-14999.0450639284860 6736757.94409741740,-14998.3237136282440 6736757.80416062470,-14998.3237136282440 6736757.80416062470,-15074.4307232707360 6736785.59960193090,-15101.5656395162080 6736793.51682595350,-15101.5656395162080 6736793.51682595350,-15102.0753269366810 6736793.64958708270,-15102.0753269366810 6736793.64958708270,-15102.0753269366810 6736793.64958708270,-15102.0753269366810 6736793.64958708270,-15102.0753269366810 6736793.64958708270,-15105.2380806489130 6736794.28289358780,-15106.8190066610910 6736794.59864982220,-15166.8942062558330 6736806.61713062690,-15195.3829901481420 6736812.31510593650,-15290.2728818098240 6736831.29463120830,-15329.8103366688590 6736839.2029293180,-15347.0557184092210 6736843.2109036660,-15351.6484711680370 6736844.44164282270,-15368.3596751999520 6736850.43566813880,-15371.3980739090370 6736851.52467590480,-15377.4497910459360 6736854.09380189050,-15380.4756551803580 6736855.37657110580,-15413.5284714028580 6736872.262497440,-15414.9655503690590 6736872.99627892490,-15443.2170790306680 6736887.49968991610,-15454.8128073709250 6736892.57876041620,-15456.2628661897430 6736893.2013100730,-15459.1629949593350 6736894.44461543950,-15471.4299019053380 6736898.62305579240,-15486.7635383708280 6736903.84745482360,-15524.6976920000360 6736915.32428000490,-15532.5896984306750 6736917.71222237870,-15543.2866888621390 6736920.94877348280,-15543.2866888621390 6736920.94877348280,-15670.4529210342480 6736958.21046822050,-15675.0913147842820 6736959.22952028270,-15689.4798710369670 6736961.8112390470,-15695.8747861639310 6736962.95767313520,-15697.484822222950 6736963.16040719490,-15703.9249664590210 6736963.96775526740000000000),"
|
||||
"(-15024.331987571450 6736740.12011628040,-15043.3966526176450 6736741.54639214930,-15098.6064446248090 6736747.23176345690,-15109.6695982572860 6736748.86256334840,-15114.2194484843550 6736749.66271390670,-15209.0076497912120 6736768.50036193520,-15329.0727003271190 6736792.35965132710,-15330.651878623290 6736792.66464307440,-15351.2999521063080 6736795.90293848980,-15398.9493695778070 6736803.37524280050,-15419.5974430608280 6736806.61354248320,-15424.1870343461050 6736807.59490003720,-15445.5403613309970 6736812.9842953617))";
|
||||
|
||||
template <bool Clockwise, typename P>
|
||||
void test_all()
|
||||
{
|
||||
@@ -157,7 +172,11 @@ void test_all()
|
||||
test_one<multi_linestring_type, polygon>("mysql_23023665_1",
|
||||
mysql_23023665_1, join_round32, end_round32, 1, 1, 186.5504, 1.0);
|
||||
test_one<multi_linestring_type, polygon>("touching1_1",
|
||||
touching1, join_round32, end_round32, 2, 0, 78.70773, 1.0);
|
||||
touching1, join_round32, end_round32, 2, 0, 78.70773, 1.0
|
||||
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
, ut_settings::ignore_validity() // false positive, due to rescaling. As we remove it, it is gone
|
||||
#endif
|
||||
);
|
||||
test_one<multi_linestring_type, polygon>("touching2_1",
|
||||
touching2, join_round32, end_round32, 1, 1, 107.8991, 1.0);
|
||||
test_one<multi_linestring_type, polygon>("mysql_23023665_1_09",
|
||||
@@ -179,6 +198,19 @@ void test_all()
|
||||
mysql_23023665_1, join_round32, end_flat, 1, 0, 197.7607, 1.1);
|
||||
test_one<multi_linestring_type, polygon>("mysql_23023665_1_20",
|
||||
mysql_23023665_1, join_round32, end_flat, 1, 1, 350.1135, 2.0);
|
||||
|
||||
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
{
|
||||
ut_settings settings(10.0);
|
||||
test_one<multi_linestring_type, polygon>("ticket_13444_1",
|
||||
ticket_13444, join_round32, end_round32, 3, 0, 11801.7832, 1.0, settings);
|
||||
test_one<multi_linestring_type, polygon>("ticket_13444_3",
|
||||
ticket_13444, join_round32, end_round32, 3, 1, 34132.0882, 3.0, settings);
|
||||
test_one<multi_linestring_type, polygon>("ticket_13444_5",
|
||||
ticket_13444, join_round32, end_round32, 2, 1, 50525.1110, 5.0, settings);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ void test_many_points_per_circle()
|
||||
"mysql_report_2015_02_25_1_250k",
|
||||
mysql_report_2015_02_25_1, join, end_flat,
|
||||
distance_strategy(6051788), side_strategy, point_circle(250000),
|
||||
115058672879977.0, ut_settings(75.0 * tolerance));
|
||||
115058672879977.0, ut_settings(150.0 * tolerance));
|
||||
|
||||
#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_SLOW_TESTS)
|
||||
// Takes about 110 seconds in release mode
|
||||
@@ -173,7 +173,7 @@ void test_many_points_per_circle()
|
||||
"mysql_report_2015_02_25_2",
|
||||
mysql_report_2015_02_25_2, join, end_flat,
|
||||
distance_strategy(5666962), side_strategy, point_circle(46641),
|
||||
100891031341795.0, ut_settings(3.0 * tolerance));
|
||||
100891031341795.0, ut_settings(200.0 * tolerance));
|
||||
|
||||
// Multipoint b with large distances/many points
|
||||
// Area ~> pi * 10x
|
||||
@@ -187,7 +187,7 @@ void test_many_points_per_circle()
|
||||
"multipoint_b_50k",
|
||||
multipoint_b, join, end_flat,
|
||||
distance_strategy(1000000), side_strategy, point_circle(50000),
|
||||
3141871558227.0, ut_settings(10.0 * tolerance));
|
||||
3141871558227.0, ut_settings(40.0 * tolerance));
|
||||
|
||||
#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_SLOW_TESTS)
|
||||
// Tests optimization min/max radius
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
@@ -37,6 +38,14 @@ void test_2d(bool is_integer = false)
|
||||
std::cout << std::endl << "type: " << typeid(ct).name() << " size: " << sizeof(ct) << std::endl;
|
||||
#endif
|
||||
|
||||
test_centroid<bg::model::multi_point<P> >(
|
||||
"MULTIPOINT((1 1),(3 3))",
|
||||
2.0, 2.0);
|
||||
|
||||
test_centroid<bg::model::multi_point<P> >(
|
||||
"MULTIPOINT((-1 -1),(-3 -3))",
|
||||
-2.0, -2.0);
|
||||
|
||||
if (! is_integer)
|
||||
{
|
||||
// Only working for floating point:
|
||||
|
||||
227
test/algorithms/densify.cpp
Normal file
227
test/algorithms/densify.cpp
Normal file
@@ -0,0 +1,227 @@
|
||||
// Boost.Geometry
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2017-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
|
||||
#include <geometry_test_common.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/densify.hpp>
|
||||
#include <boost/geometry/algorithms/length.hpp>
|
||||
#include <boost/geometry/algorithms/num_points.hpp>
|
||||
#include <boost/geometry/algorithms/perimeter.hpp>
|
||||
|
||||
#include <boost/geometry/iterators/segment_iterator.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/densify.hpp>
|
||||
#include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
|
||||
#include <boost/geometry/strategies/geographic/densify.hpp>
|
||||
#include <boost/geometry/strategies/geographic/distance.hpp>
|
||||
#include <boost/geometry/strategies/spherical/densify.hpp>
|
||||
#include <boost/geometry/strategies/spherical/distance_haversine.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
|
||||
|
||||
struct check_lengths
|
||||
{
|
||||
template <typename G, typename S>
|
||||
void operator()(G const& g, G const& o, S const& s) const
|
||||
{
|
||||
double d1 = bg::length(g, s);
|
||||
double d2 = bg::length(o, s);
|
||||
|
||||
BOOST_CHECK_CLOSE(d1, d2, 0.0001);
|
||||
}
|
||||
};
|
||||
|
||||
struct check_perimeters
|
||||
{
|
||||
template <typename G, typename S>
|
||||
void operator()(G const& g, G const& o, S const& s) const
|
||||
{
|
||||
double d1 = bg::perimeter(g, s);
|
||||
double d2 = bg::perimeter(o, s);
|
||||
|
||||
BOOST_CHECK_CLOSE(d1, d2, 0.0001);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename G, typename DistS>
|
||||
double inline shortest_length(G const& g, DistS const& dist_s)
|
||||
{
|
||||
double min_len = (std::numeric_limits<double>::max)();
|
||||
for (bg::segment_iterator<G const> it = bg::segments_begin(g);
|
||||
it != bg::segments_end(g); ++it)
|
||||
{
|
||||
double len = bg::length(*it, dist_s);
|
||||
min_len = (std::min)(min_len, len);
|
||||
}
|
||||
return min_len;
|
||||
}
|
||||
|
||||
template <typename G, typename DistS>
|
||||
double inline greatest_length(G const& o, DistS const& dist_s)
|
||||
{
|
||||
double max_len = 0.0;
|
||||
for (bg::segment_iterator<G const> it = bg::segments_begin(o);
|
||||
it != bg::segments_end(o); ++it)
|
||||
{
|
||||
double len = bg::length(*it, dist_s);
|
||||
max_len = (std::max)(max_len, len);
|
||||
}
|
||||
return max_len;
|
||||
}
|
||||
|
||||
template <typename G, typename CSTag = typename bg::cs_tag<G>::type>
|
||||
struct cs_data
|
||||
{};
|
||||
|
||||
template <typename G>
|
||||
struct cs_data<G, bg::cartesian_tag>
|
||||
{
|
||||
bg::strategy::densify::cartesian<> compl_s;
|
||||
bg::strategy::distance::pythagoras<> dist_s;
|
||||
};
|
||||
|
||||
template <typename G>
|
||||
struct cs_data<G, bg::spherical_equatorial_tag>
|
||||
{
|
||||
cs_data()
|
||||
: model(6378137.0)
|
||||
, compl_s(model)
|
||||
, dist_s(6378137.0)
|
||||
{}
|
||||
|
||||
bg::srs::sphere<double> model;
|
||||
bg::strategy::densify::spherical<> compl_s;
|
||||
bg::strategy::distance::haversine<double> dist_s;
|
||||
};
|
||||
|
||||
template <typename G>
|
||||
struct cs_data<G, bg::geographic_tag>
|
||||
{
|
||||
cs_data()
|
||||
: model(6378137.0, 6356752.3142451793)
|
||||
, compl_s(model)
|
||||
, dist_s(model)
|
||||
{}
|
||||
|
||||
bg::srs::spheroid<double> model;
|
||||
bg::strategy::densify::geographic<> compl_s;
|
||||
bg::strategy::distance::geographic<> dist_s;
|
||||
};
|
||||
|
||||
template <typename G, typename DistS, typename Check>
|
||||
inline void check_result(G const& g, G const& o, double max_distance,
|
||||
DistS const& dist_s, Check const& check)
|
||||
{
|
||||
// geometry was indeed densified
|
||||
std::size_t g_count = bg::num_points(g);
|
||||
std::size_t o_count = bg::num_points(o);
|
||||
BOOST_CHECK(g_count < o_count);
|
||||
|
||||
// all segments have lengths smaller or equal to max_distance
|
||||
double gr_len = greatest_length(o, dist_s);
|
||||
// NOTE: Currently geographic strategies can generate segments that have
|
||||
// lengths slightly greater than max_distance. In order to change
|
||||
// this the generation of new points should e.g. be recursive with
|
||||
// stop condition comparing the current distance calculated by
|
||||
// inverse strategy.
|
||||
// NOTE: Closeness value tweaked for Andoyer
|
||||
bool is_close = (gr_len - max_distance) / (std::max)(gr_len, max_distance) < 0.0001;
|
||||
BOOST_CHECK(gr_len <= max_distance || is_close);
|
||||
|
||||
// the overall length or perimeter didn't change
|
||||
check(g, o, dist_s);
|
||||
}
|
||||
|
||||
template <typename G, typename Check>
|
||||
inline void test_geometry(std::string const& wkt, Check const& check)
|
||||
{
|
||||
cs_data<G> d;
|
||||
|
||||
G g;
|
||||
bg::read_wkt(wkt, g);
|
||||
|
||||
{
|
||||
bg::default_strategy def_s;
|
||||
double max_distance = shortest_length(g, def_s) / 3.0;
|
||||
|
||||
G o;
|
||||
bg::densify(g, o, max_distance);
|
||||
|
||||
check_result(g, o, max_distance, def_s, check);
|
||||
}
|
||||
|
||||
{
|
||||
double max_distance = shortest_length(g, d.dist_s) / 3.0;
|
||||
|
||||
G o;
|
||||
bg::densify(g, o, max_distance, d.compl_s);
|
||||
|
||||
check_result(g, o, max_distance, d.dist_s, check);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename G>
|
||||
inline void test_linear(std::string const& wkt)
|
||||
{
|
||||
test_geometry<G>(wkt, check_lengths());
|
||||
}
|
||||
|
||||
template <typename G>
|
||||
inline void test_areal(std::string const& wkt)
|
||||
{
|
||||
test_geometry<G>(wkt, check_perimeters());
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls_t;
|
||||
typedef bg::model::multi_linestring<ls_t> mls_t;
|
||||
|
||||
typedef bg::model::ring<P> ring_t;
|
||||
typedef bg::model::polygon<P> poly_t;
|
||||
typedef bg::model::multi_polygon<poly_t> mpoly_t;
|
||||
|
||||
typedef bg::model::ring<P, true, false> oring_t;
|
||||
typedef bg::model::polygon<P, true, false> opoly_t;
|
||||
typedef bg::model::multi_polygon<opoly_t> ompoly_t;
|
||||
|
||||
test_linear<ls_t>("LINESTRING(4 -4, 4 -1)");
|
||||
test_linear<ls_t>("LINESTRING(4 4, 4 1)");
|
||||
test_linear<ls_t>("LINESTRING(0 0, 180 0)");
|
||||
test_linear<ls_t>("LINESTRING(1 1, -179 -1)");
|
||||
|
||||
test_linear<ls_t>("LINESTRING(1 1, 2 2, 4 2)");
|
||||
test_linear<mls_t>("MULTILINESTRING((1 1, 2 2),(2 2, 4 2))");
|
||||
|
||||
test_areal<ring_t>("POLYGON((1 1, 1 2, 2 2, 1 1))");
|
||||
test_areal<poly_t>("POLYGON((1 1, 1 4, 4 4, 4 1, 1 1),(1 1, 2 2, 2 3, 1 1))");
|
||||
test_areal<mpoly_t>("MULTIPOLYGON(((1 1, 1 4, 4 4, 4 1, 1 1),(1 1, 2 2, 2 3, 1 1)),((4 4, 5 5, 5 4, 4 4)))");
|
||||
|
||||
test_areal<oring_t>("POLYGON((1 1, 1 2, 2 2))");
|
||||
test_areal<opoly_t>("POLYGON((1 1, 1 4, 4 4, 4 1),(1 1, 2 2, 2 3))");
|
||||
test_areal<ompoly_t>("MULTIPOLYGON(((1 1, 1 4, 4 4, 4 1),(1 1, 2 2, 2 3)),((4 4, 5 5, 5 4)))");
|
||||
|
||||
test_areal<ring_t>("POLYGON((0 0,0 40,40 40,40 0,0 0))");
|
||||
test_areal<oring_t>("POLYGON((0 0,0 40,40 40,40 0))");
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_all< bg::model::point<double, 2, bg::cs::cartesian> >();
|
||||
test_all< bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
test_all< bg::model::point<double, 2, bg::cs::geographic<bg::degree> > >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
#define BOOST_TEST_MODULE test_distance_geographic_pl_l
|
||||
#endif
|
||||
|
||||
#include <boost/geometry/core/srs.hpp>
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include "test_distance_geo_common.hpp"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#define BOOST_TEST_MODULE test_distance_geographic_pl_l
|
||||
#endif
|
||||
|
||||
#include <boost/geometry/core/srs.hpp>
|
||||
//#include <boost/geometry/core/srs.hpp>
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include "test_distance_geo_common.hpp"
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2014-2017, Oracle and/or its affiliates.
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// Copyright (c) 2014-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
@@ -43,10 +45,8 @@ void test_valid_s(std::string const& wkt,
|
||||
Spheroid const& sph,
|
||||
bool expected_result)
|
||||
{
|
||||
typedef typename bg::point_type<Poly>::type pt;
|
||||
|
||||
bg::strategy::intersection::geographic_segments<> is(sph);
|
||||
bg::strategy::area::geographic<pt> as(sph);
|
||||
bg::strategy::area::geographic<> as(sph);
|
||||
|
||||
Poly p;
|
||||
bg::read_wkt(wkt, p);
|
||||
|
||||
@@ -1236,6 +1236,63 @@ static std::string case_recursive_boxes_80[2] =
|
||||
"MULTIPOLYGON(((1 1,1 2,2 1,1 1)),((3 2,3 3,4 3,3 2)))"
|
||||
};
|
||||
|
||||
static std::string case_recursive_boxes_81[2] =
|
||||
{
|
||||
"MULTIPOLYGON(((3 4,2 4,2 5,3 4)),((3 3,2 3,2 4,3 3)),((3 3,3 4,4 5,5 4,5 3,3 3),(4 4,3.5 3.5,4 3,4 4)),((2 1,2 0,1 0,1 1,0 1,1 2,3 2,4 3,4 1,2 1)))",
|
||||
"MULTIPOLYGON(((2 4,2 2,1 2,0 1,0 3,1 3,1 4,2 4)),((2 4,2 5,3 4,2 4)),((3 4,5 4,5 3,3 3,3 4)),((1 4,0 4,0 5,1 5,1 4)),((2 1,2 0,0 0,0 1,2 1)),((4 2,5 2,4 1,3 1,4 2)),((4 1,5 1,4 0,4 1)))"
|
||||
};
|
||||
|
||||
static std::string case_recursive_boxes_82[2] =
|
||||
{
|
||||
// Contains two outgoing arcs on same ring causing current aggregation implementation to fail.
|
||||
// Fixed by greatly simplifying the code, skipping aggregations and using sbs directly (which is now possible, now that isolation-information is much better)
|
||||
"MULTIPOLYGON(((4 0,5 1,5 0,4 0)),((3 3,3 1,4 1,3 0,0 0,0 5,1 5,1 4,1.5 3.5,2 4,2 3,3 3),(2 2,2 1,3 2,2 2)),((2 4,3 5,4 5,3.5 4.5,5 3,3 3,3 4,2 4)),((4 4,4 5,5 5,4.5 4.5,5 4,4 4)))",
|
||||
"MULTIPOLYGON(((2 4,2 5,4 5,4 4,2 4)),((2 4,2 3,5 3,5 2,4 2,4 1,1 1,1 2,0 2,0 5,1 5,1 4,2 4),(2 2,1 2,1.5 1.5,2 2),(3 2,3.5 1.5,4 2,3 2)),((4 4,5 5,5 4,4 4)))"
|
||||
};
|
||||
|
||||
static std::string case_recursive_boxes_83[2] =
|
||||
{
|
||||
// Needs to select on operation in cluster
|
||||
"MULTIPOLYGON(((2 1,2 0,1 0,1 4,2 4,2 5,3 5,4 4,4 3,5 3,4 2,5 2,5 0,4 0,4 1,3 0,3 1,2 1),(2 3,1 3,2 2,2 3),(3 2,3 3,2 2,3 2)),((0 2,1 1,0 0,0 2)),((0 2,0 3,1 3,0 2)),((4 4,4 5,5 4,4 4)))",
|
||||
"MULTIPOLYGON(((2 0,1 0,1 2,2 2,2 5,3 4,3 5,4 5,4 4,5 5,5 3,4 3,4 1,5 1,5 0,2 0),(2 1,3 2,2 2,2 1)),((0 5,1 5,1 4,0 4,0 5)),((1 1,0 1,0 2,1 1)),((1 2,0 2,1 3,1 2)))"
|
||||
};
|
||||
|
||||
static std::string case_recursive_boxes_84[2] =
|
||||
{
|
||||
// Need to set some ii-turns non-startable
|
||||
"MULTIPOLYGON(((2 4,1 4,1 5,3 5,2 4)),((3 5,4 5,4 4,3 4,3 5)),((3 3,4 3,4 4,5 4,4.5 3.5,5 3,5 2,4 1,3 1,3 2,2 2,2 3,3 3),(4 2,3.5 1.5,4 1,4 2)),((0 3,0 4,1 4,1 3,0 3)))",
|
||||
"MULTIPOLYGON(((4 4,4 5,5 5,5 4,4 4)),((0 5,1 5,1 4,0 4,0 5)),((2 0,1 0,1 1,2 1,2 2,3 2,3 0,2 0)),((2 4,2 3,1 3,2 4)),((2 4,2 5,3 5,2 4)),((2 3,2 2,1 2,2 3)),((1 3,1 1,0 1,0 3,1 3)),((5 1,5 0,4 0,4 1,5 1)))"
|
||||
};
|
||||
|
||||
static std::string case_recursive_boxes_85[2] =
|
||||
{
|
||||
// Contains rescaling problem
|
||||
"MULTIPOLYGON(((5 2,5 3,6 3,6 2,5 2)),((6 5,6 6,7 6,7 5,6 5)),((3 6,1 6,2 7,3 7,3 6)),((3 6,3 5,2 5,2 6,2.5 5.5,3 6)))",
|
||||
"MULTIPOLYGON(((2 5,2 6,3 6,2 5)),((6 1,6 2,7 2,6 1)),((5 4,5 5,6 4,5 4)),((0 6,0 7,1 7,0 6)),((3 3,3 2,2 2,3 3)),((3 3,3 4,4 5,4 4,3 3)),((4 4,5 3,4 3,4 4)))"
|
||||
};
|
||||
|
||||
static std::string case_recursive_boxes_86[2] =
|
||||
{
|
||||
// Positive ring and negative ring have same area. For difference, this
|
||||
// needs to be handled correctly in assign_parents,
|
||||
// skipping the optimization for union
|
||||
"MULTIPOLYGON(((3 4,4 4,4 3,2 3,3 4)))",
|
||||
"MULTIPOLYGON(((4 1,3 1,3 2,4 1)),((4 1,5 1,5 0,4 0,4 1)))"
|
||||
};
|
||||
|
||||
static std::string case_recursive_boxes_87[2] =
|
||||
{
|
||||
// Needs to handle ii-turns for difference like done for intersection
|
||||
"MULTIPOLYGON(((5 2,5 3,6 3,5 2)),((3 4,3 3,2 3,3 4)),((3 4,2 4,3 5,3 4)),((2 4,2 3,1 3,2 4)))",
|
||||
"MULTIPOLYGON(((2 0,3 1,3 0,2 0)),((6 3,6 4,7 4,7 3,6 3)),((3 9,3 10,4 9,3 9)),((8 7,8 8,9 8,8 7)))"
|
||||
};
|
||||
|
||||
static std::string case_recursive_boxes_88[2] =
|
||||
{
|
||||
"MULTIPOLYGON(((1 4,1 5,2 5,2 4,1 4)),((0 2,0 3,1 3,0 2)),((3 5,4 5,4 4,3 4,3 5)),((2 3,4 3,4 2,3 1,2 1,2 3),(3 3,2.5 2.5,3 2,3 3)),((4 1,3 0,3 1,4 1)),((4 2,5 2,5 0,4 0,4 2)))",
|
||||
"MULTIPOLYGON(((4 0,4 1,5 1,5 0,4 0)),((3 4,3 3,1 3,1 5,3 5,2.5 4.5,3 4)),((3 4,3 5,4 5,4 4,3 4)),((1 1,2 0,1 0,1 1)),((1 1,1 2,2 2,2 1,1 1)),((1 2,0 2,0 3,1 3,1 2)),((4 4,5 4,5 2,4 2,4 4)))"
|
||||
};
|
||||
|
||||
static std::string pie_21_7_21_0_3[2] =
|
||||
{
|
||||
"MULTIPOLYGON(((2500 2500,2500 3875,2855 3828,3187 3690,3472 3472,3690 3187,3828 2855,3875 2500,3828 2144,3690 1812,3472 1527,3187 1309,2855 1171,2499 1125,2144 1171,1812 1309,1527 1527,1309 1812,1171 2144,1125 2499,1171 2855,1309 3187,2500 2500)))",
|
||||
|
||||
@@ -272,10 +272,6 @@ struct map_visitor
|
||||
bool lab1 = label_operation(turn, 0, out);
|
||||
out << " / ";
|
||||
bool lab2 = label_operation(turn, 1, out);
|
||||
if (turn.switch_source)
|
||||
{
|
||||
out << "#";
|
||||
}
|
||||
if (turn.discarded)
|
||||
{
|
||||
out << "!";
|
||||
@@ -377,8 +373,8 @@ void test_overlay(std::string const& caseid,
|
||||
<< "_" << string_from_type<typename bg::coordinate_type<Geometry>::type>::name()
|
||||
<< (ccw ? "_ccw" : "")
|
||||
<< (open ? "_open" : "")
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
<< "_self"
|
||||
#if defined(BOOST_GEOMETRY_NO_SELF_TURNS)
|
||||
<< "_no_self"
|
||||
#endif
|
||||
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
<< "_no_rob"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2017.
|
||||
// Modifications copyright (c) 2017, Oracle and/or its affiliates.
|
||||
@@ -46,13 +47,13 @@ template
|
||||
<
|
||||
bool Reverse1, bool Reverse2,
|
||||
bg::overlay_type OverlayType,
|
||||
typename Turns,
|
||||
typename Clusters,
|
||||
typename Turns,
|
||||
typename Geometry1,
|
||||
typename Geometry2,
|
||||
typename SideStrategy
|
||||
>
|
||||
std::vector<std::size_t> test_gather_cluster_properties(std::string const& case_id,
|
||||
std::vector<std::size_t> gather_cluster_properties(
|
||||
Clusters& clusters, Turns& turns,
|
||||
bg::detail::overlay::operation_type for_operation,
|
||||
Geometry1 const& geometry1, Geometry2 const& geometry2,
|
||||
@@ -125,7 +126,7 @@ template
|
||||
typename Geometry1, typename Geometry2,
|
||||
typename RobustPolicy, typename Strategy
|
||||
>
|
||||
std::vector<std::size_t> apply_overlay(std::string const& case_id,
|
||||
std::vector<std::size_t> apply_overlay(
|
||||
Geometry1 const& geometry1, Geometry2 const& geometry2,
|
||||
RobustPolicy const& robust_policy,
|
||||
Strategy const& strategy)
|
||||
@@ -165,7 +166,7 @@ std::vector<std::size_t> apply_overlay(std::string const& case_id,
|
||||
side_strategy);
|
||||
|
||||
// Gather cluster properties, with test option
|
||||
return test_gather_cluster_properties<Reverse1, Reverse2, OverlayType>(case_id,
|
||||
return ::gather_cluster_properties<Reverse1, Reverse2, OverlayType>(
|
||||
clusters, turns, bg::detail::overlay::operation_from_overlay<OverlayType>::value,
|
||||
geometry1, geometry2, strategy.get_side_strategy());
|
||||
}
|
||||
@@ -206,8 +207,10 @@ void test_sort_by_side(std::string const& case_id,
|
||||
|
||||
strategy_type strategy;
|
||||
|
||||
std::vector<std::size_t> result = apply_overlay<OverlayType, false, false, false, geometry_out>(case_id, g1, g2,
|
||||
robust_policy, strategy);
|
||||
std::vector<std::size_t> result = ::apply_overlay
|
||||
<
|
||||
OverlayType, false, false, false, geometry_out
|
||||
>(g1, g2, robust_policy, strategy);
|
||||
|
||||
BOOST_CHECK_MESSAGE(result == expected_open_count,
|
||||
" caseid=" << case_id
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2017 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2017.
|
||||
// Modifications copyright (c) 2017, Oracle and/or its affiliates.
|
||||
@@ -62,7 +63,7 @@ std::vector<std::size_t> apply_get_turns(std::string const& case_id,
|
||||
Strategy const& strategy,
|
||||
std::size_t expected_open_count,
|
||||
std::size_t expected_max_rank,
|
||||
std::vector<int> const& expected_right_count)
|
||||
std::vector<bg::signed_size_type> const& expected_right_count)
|
||||
{
|
||||
using namespace boost::geometry;
|
||||
|
||||
@@ -157,7 +158,7 @@ std::vector<std::size_t> apply_get_turns(std::string const& case_id,
|
||||
|
||||
std::size_t const open_count = sbs.open_count(detail::overlay::operation_union);
|
||||
std::size_t const max_rank = sbs.m_ranked_points.back().rank;
|
||||
std::vector<int> right_count(max_rank + 1, -1);
|
||||
std::vector<bg::signed_size_type> right_count(max_rank + 1, -1);
|
||||
|
||||
int previous_rank = -1;
|
||||
int previous_to_rank = -1;
|
||||
@@ -226,7 +227,7 @@ void test_basic(std::string const& case_id,
|
||||
std::string const& wkt_origin_point,
|
||||
std::size_t expected_open_count,
|
||||
std::size_t expected_max_rank,
|
||||
std::vector<int> const& expected_right_count)
|
||||
std::vector<bg::signed_size_type> const& expected_right_count)
|
||||
{
|
||||
typedef bg::model::point<T, 2, bg::cs::cartesian> point_type;
|
||||
typedef bg::model::polygon<point_type> polygon;
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2014, 2016, 2017.
|
||||
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014, 2016, 2017, 2018.
|
||||
// Modifications copyright (c) 2014-2018 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.
|
||||
@@ -14,8 +15,6 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
#ifndef BOOST_GEOMETRY_TEST_ALGORITHMS_OVERLAY_TEST_GET_TURNS_HPP
|
||||
#define BOOST_GEOMETRY_TEST_ALGORITHMS_OVERLAY_TEST_GET_TURNS_HPP
|
||||
|
||||
@@ -34,27 +33,13 @@
|
||||
#include <boost/geometry/io/wkt/write.hpp>
|
||||
|
||||
struct expected_pusher
|
||||
: std::vector<std::string>
|
||||
{
|
||||
void push_back(std::string const& ex)
|
||||
{
|
||||
vec.push_back(ex);
|
||||
}
|
||||
|
||||
expected_pusher & operator()(std::string const& ex)
|
||||
{
|
||||
push_back(ex);
|
||||
std::vector<std::string>::push_back(ex);
|
||||
return *this;
|
||||
}
|
||||
|
||||
typedef std::vector<std::string>::iterator iterator;
|
||||
typedef std::vector<std::string>::const_iterator const_iterator;
|
||||
|
||||
iterator begin() { return vec.begin(); }
|
||||
iterator end() { return vec.end(); }
|
||||
const_iterator begin() const { return vec.begin(); }
|
||||
const_iterator end() const { return vec.end(); }
|
||||
|
||||
std::vector<std::string> vec;
|
||||
};
|
||||
|
||||
inline expected_pusher expected(std::string const& ex)
|
||||
@@ -86,9 +71,9 @@ struct equal_turn
|
||||
}
|
||||
|
||||
template <typename P, typename R>
|
||||
static bool equal_operations_ex(bg::detail::overlay::turn_operation<P, R> const& op0,
|
||||
bg::detail::overlay::turn_operation<P, R> const& op1,
|
||||
std::string const& s)
|
||||
static bool equal_operations_ex(bg::detail::overlay::turn_operation<P, R> const& /*op0*/,
|
||||
bg::detail::overlay::turn_operation<P, R> const& /*op1*/,
|
||||
std::string const& /*s*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -116,6 +101,65 @@ struct equal_turn
|
||||
const std::string * turn_ptr;
|
||||
};
|
||||
|
||||
template <typename Turns>
|
||||
struct turns_printer
|
||||
{
|
||||
turns_printer(Turns const& t) : turns(t) {}
|
||||
|
||||
friend std::ostream & operator<<(std::ostream & os, turns_printer const& tp)
|
||||
{
|
||||
std::vector<std::string> vec(tp.turns.size());
|
||||
std::transform(tp.turns.begin(), tp.turns.end(), vec.begin(), to_string());
|
||||
std::sort(vec.begin(), vec.end());
|
||||
std::copy(vec.begin(), vec.end(), std::ostream_iterator<std::string>(os, " "));
|
||||
return os;
|
||||
}
|
||||
|
||||
struct to_string
|
||||
{
|
||||
template <typename P, typename R>
|
||||
std::string operator()(bg::detail::overlay::turn_info<P, R, bg::detail::overlay::turn_operation<P, R> > const& t) const
|
||||
{
|
||||
std::string res(3, ' ');
|
||||
res[0] = bg::method_char(t.method);
|
||||
res[1] = bg::operation_char(t.operations[0].operation);
|
||||
res[2] = bg::operation_char(t.operations[1].operation);
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename P, typename R>
|
||||
std::string operator()(bg::detail::overlay::turn_info<P, R, bg::detail::overlay::turn_operation_linear<P, R> > const& t) const
|
||||
{
|
||||
std::string res(5, ' ');
|
||||
res[0] = bg::method_char(t.method);
|
||||
res[1] = bg::operation_char(t.operations[0].operation);
|
||||
res[2] = bg::operation_char(t.operations[1].operation);
|
||||
res[3] = equal_turn::is_colinear_char(t.operations[0].is_collinear);
|
||||
res[4] = equal_turn::is_colinear_char(t.operations[1].is_collinear);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
Turns const& turns;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct turns_printer<expected_pusher>
|
||||
{
|
||||
turns_printer(expected_pusher const& t) : turns(t) {}
|
||||
|
||||
friend std::ostream & operator<<(std::ostream & os, turns_printer const& tp)
|
||||
{
|
||||
std::vector<std::string> vec(tp.turns.size());
|
||||
std::copy(tp.turns.begin(), tp.turns.end(), vec.begin());
|
||||
std::sort(vec.begin(), vec.end());
|
||||
std::copy(vec.begin(), vec.end(), std::ostream_iterator<std::string>(os, " "));
|
||||
return os;
|
||||
}
|
||||
|
||||
expected_pusher const& turns;
|
||||
};
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Expected, typename Strategy>
|
||||
void check_geometry_range(Geometry1 const& g1,
|
||||
Geometry2 const& g2,
|
||||
@@ -146,7 +190,7 @@ void check_geometry_range(Geometry1 const& g1,
|
||||
typedef bg::detail::overlay::assign_null_policy assign_policy_t;
|
||||
typedef bg::detail::get_turns::no_interrupt_policy interrupt_policy_t;
|
||||
|
||||
std::vector<turn_info> turns;
|
||||
std::vector<turn_info> detected;
|
||||
interrupt_policy_t interrupt_policy;
|
||||
robust_policy_type robust_policy;
|
||||
|
||||
@@ -161,65 +205,51 @@ void check_geometry_range(Geometry1 const& g1,
|
||||
typename bg::tag<Geometry1>::type, typename bg::tag<Geometry2>::type,
|
||||
Geometry1, Geometry2, false, false,
|
||||
turn_policy_t
|
||||
>::apply(0, g1, 1, g2, strategy, robust_policy, turns, interrupt_policy);
|
||||
>::apply(0, g1, 1, g2, strategy, robust_policy, detected, interrupt_policy);
|
||||
|
||||
bool ok = boost::size(expected) == turns.size();
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::vector<turn_info> turns_dbg = turns;
|
||||
#endif
|
||||
bool ok = boost::size(expected) == detected.size();
|
||||
|
||||
BOOST_CHECK_MESSAGE(ok,
|
||||
"get_turns: " << wkt1 << " and " << wkt2
|
||||
<< " -> Expected turns #: " << boost::size(expected) << " detected turns #: " << turns.size());
|
||||
<< " -> Expected turns #: " << boost::size(expected) << " detected turns #: " << detected.size());
|
||||
|
||||
for ( typename boost::range_iterator<Expected const>::type sit = boost::begin(expected) ;
|
||||
sit != boost::end(expected) ; ++sit)
|
||||
if (ok)
|
||||
{
|
||||
typename std::vector<turn_info>::iterator
|
||||
it = std::find_if(turns.begin(), turns.end(), equal_turn(*sit));
|
||||
std::vector<turn_info> turns = detected;
|
||||
|
||||
if ( it != turns.end() )
|
||||
turns.erase(it);
|
||||
else
|
||||
for ( typename boost::range_iterator<Expected const>::type sit = boost::begin(expected) ;
|
||||
sit != boost::end(expected) ; ++sit)
|
||||
{
|
||||
ok = false;
|
||||
BOOST_CHECK_MESSAGE(false,
|
||||
"get_turns: " << wkt1 << " and " << wkt2
|
||||
<< " -> Expected turn: " << *sit << " not found");
|
||||
typename std::vector<turn_info>::iterator
|
||||
it = std::find_if(turns.begin(), turns.end(), equal_turn(*sit));
|
||||
|
||||
if ( it != turns.end() )
|
||||
{
|
||||
turns.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
if ( !ok )
|
||||
{
|
||||
BOOST_CHECK_MESSAGE(false,
|
||||
"get_turns: " << wkt1 << " and " << wkt2
|
||||
<< " -> Expected turns: " << turns_printer<Expected>(expected)
|
||||
<< "Detected turns: " << turns_printer<std::vector<turn_info> >(detected));
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << "Coordinates: "
|
||||
<< typeid(typename bg::coordinate_type<Geometry1>::type).name()
|
||||
<< ", "
|
||||
<< typeid(typename bg::coordinate_type<Geometry2>::type).name()
|
||||
<< std::endl;
|
||||
std::cout << "Detected: ";
|
||||
if ( turns_dbg.empty() )
|
||||
{
|
||||
std::cout << "{empty}";
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( typename std::vector<turn_info>::const_iterator it = turns_dbg.begin() ;
|
||||
it != turns_dbg.end() ; ++it )
|
||||
{
|
||||
if ( it != turns_dbg.begin() )
|
||||
std::cout << ", ";
|
||||
std::cout << bg::method_char(it->method);
|
||||
std::cout << bg::operation_char(it->operations[0].operation);
|
||||
std::cout << bg::operation_char(it->operations[1].operation);
|
||||
std::cout << equal_turn<1>::is_colinear_char(it->operations[0].is_collinear);
|
||||
std::cout << equal_turn<1>::is_colinear_char(it->operations[1].is_collinear);
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Expected>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
// Copyright (c) 2013-2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2014, 2015.
|
||||
// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates.
|
||||
@@ -143,6 +143,11 @@ void test_point_order_and_type()
|
||||
test_geometry<cw_open_polygon>("with_hole_cw_open", "POLYGON((0 0,0 9,9 9,9 0),(2 2,7 2,7 7,2 7))", 0, 0);
|
||||
test_geometry<ccw_closed_polygon>("with_hole_ccw_closed", "POLYGON((0 0,9 0,9 9,0 9,0 0),(2 2,2 7,7 7,7 2,2 2))", 0, 0);
|
||||
test_geometry<cw_closed_polygon>("with_hole_cw_closed", "POLYGON((0 0,0 9,9 9,9 0,0 0),(2 2,7 2,7 7,2 7,2 2))", 0, 0);
|
||||
|
||||
test_geometry<cw_closed_polygon>("t1", "POLYGON((0 0,0 10,10 0,0 0))", 0, 0);
|
||||
test_geometry<cw_closed_polygon>("t2", "POLYGON((0 0,10 0,0 -10,0 0))", 0, 0);
|
||||
test_geometry<cw_closed_polygon>("t3", "POLYGON((0 0,0 -10,-10 0,0 0))", 0, 0);
|
||||
test_geometry<cw_closed_polygon>("t4", "POLYGON((0 0,-10 0,0 10,0 0))", 0, 0);
|
||||
}
|
||||
|
||||
template <typename Point>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
( #caseid, caseid[0], caseid[1], clips1, -1, area1, clips2, -1, area2, \
|
||||
clips3, -1, area1 + area2)
|
||||
|
||||
#if !defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS)
|
||||
#if defined(BOOST_GEOMETRY_NO_SELF_TURNS)
|
||||
#define TEST_DIFFERENCE_IGNORE(caseid, clips1, area1, clips2, area2, clips3) \
|
||||
{ ut_settings ignore_validity; ignore_validity.test_validity = false; \
|
||||
(test_one<polygon, polygon, polygon>) \
|
||||
@@ -536,8 +536,7 @@ void test_all()
|
||||
5, 27, 1.6701714);
|
||||
***/
|
||||
|
||||
// Should have 2 outputs
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(mysql_21977775,
|
||||
2, 160.856568913, 2, 92.3565689126, 4);
|
||||
#else
|
||||
@@ -550,7 +549,7 @@ void test_all()
|
||||
TEST_DIFFERENCE(mysql_23023665_1, 1, 92.0, 1, 142.5, 2);
|
||||
TEST_DIFFERENCE(mysql_23023665_2, 1, 96.0, 1, 16.0, 2);
|
||||
TEST_DIFFERENCE(mysql_23023665_3, 1, 225.0, 1, 66.0, 2);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(mysql_23023665_5, 2, 165.23735, 2, 105.73735, 4);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(mysql_23023665_5, 1, 165.23735, 2, 105.73735, 3);
|
||||
@@ -558,7 +557,7 @@ void test_all()
|
||||
|
||||
TEST_DIFFERENCE(mysql_23023665_6, 2, 105.68756, 3, 10.18756, 5);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(mysql_23023665_13, 3, 99.74526, 3, 37.74526, 6);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(mysql_23023665_13, 2, 99.74526, 3, 37.74526, 5);
|
||||
@@ -589,7 +588,7 @@ void test_specific()
|
||||
1, 4, 6731652.0);
|
||||
|
||||
// Generates spikes, both a-b and b-a
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(ticket_11676, 2, 2537992.5, 2, 294963.5, 3);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(ticket_11676, 1, 2537992.5, 2, 294963.5, 2);
|
||||
|
||||
@@ -92,8 +92,8 @@ void test_areal()
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_77_multi",
|
||||
case_77_multi[0], case_77_multi[1],
|
||||
6, 31, 7.0,
|
||||
5, 36, 13.0,
|
||||
5, 43, 7.0 + 13.0);
|
||||
5, 33, 13.0,
|
||||
5, 38, 7.0 + 13.0);
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_78_multi",
|
||||
case_78_multi[0], case_78_multi[1],
|
||||
@@ -104,7 +104,7 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_125_multi, 1, 0.25, 2, 0.400, 3);
|
||||
|
||||
// A should have 3 clips, B should have 5 clips
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_126_multi, 4, 16.0, 5, 27.0, 9);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_126_multi, 3, 16.0, 4, 27.0, 7);
|
||||
@@ -120,7 +120,7 @@ void test_areal()
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_108_multi",
|
||||
case_108_multi[0], case_108_multi[1],
|
||||
7, 32, 5.5,
|
||||
4, 28, 9.75,
|
||||
4, 24, 9.75,
|
||||
7, 45, 15.25,
|
||||
settings);
|
||||
}
|
||||
@@ -156,32 +156,39 @@ void test_areal()
|
||||
settings.percentage = 0.001;
|
||||
|
||||
// This testcase is actually different for all combinations
|
||||
#if (!defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS)) || defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
#if defined(BOOST_GEOMETRY_NO_SELF_TURNS) || defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
settings.test_validity = false;
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS) || defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
#if ! defined(BOOST_GEOMETRY_NO_SELF_TURNS) || defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
TEST_DIFFERENCE_WITH(0, 1, ggl_list_20120221_volker, 2, 7962.66, 2, 2775258.93, 4);
|
||||
#else
|
||||
TEST_DIFFERENCE_WITH(0, 1, ggl_list_20120221_volker, 2, 7962.66, 1, 2775258.93, 3);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.sym_difference = false; // Validity problem in sym difference
|
||||
// POSTGIS areas: 3.75893745345145, 2.5810000723917e-15
|
||||
TEST_DIFFERENCE_WITH(0, 1, bug_21155501, 1, 3.758937, 1, 1.7763568394002505e-15, 2);
|
||||
}
|
||||
#else
|
||||
// With no-robustness this one misses one of the outputs
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_9081",
|
||||
ticket_9081[0], ticket_9081[1],
|
||||
2, 28, 0.0907392476356186, 4, 25, 0.126018011439877,
|
||||
4, 42, 0.0907392476356186 + 0.126018011439877,
|
||||
tolerance(0.001));
|
||||
|
||||
// POSTGIS areas: 3.75893745345145, 2.5810000723917e-15
|
||||
// With rescaling, A is invalid (this is a robustness problem) and the other
|
||||
// output is discarded because of zero (rescaled) area
|
||||
TEST_DIFFERENCE_IGNORE(bug_21155501, 1, 3.758937, 0, 0.0, 1);
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
// The result is valid but wrong, version b includes nearly all area
|
||||
// which was original between all the self-touching polygons
|
||||
// TEST_DIFFERENCE(ticket_12503, 46, 920.625, 41, 497.125, 10);
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(ticket_12503, 46, 920.625, 4, 7.625, 50);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(ticket_12503, 45, 920.625, 3, 7.625, 48);
|
||||
#endif
|
||||
@@ -219,7 +226,7 @@ void test_areal()
|
||||
|
||||
// Areas correspond with POSTGIS,
|
||||
// #clips in PostGIS is 11,11,5 but should most probably be be 12,12,6
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_1, 12, 26.0, 12, 24.0, 6);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_1, 11, 26.0, 12, 24.0, 5);
|
||||
@@ -241,14 +248,13 @@ void test_areal()
|
||||
|
||||
// 4, input is not valid
|
||||
|
||||
// Should have 16,12 clips in a,b
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_5, 16, 22.0, 12, 27.0, 10);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_5, 15, 22.0, 11, 27.0, 8);
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_6, 7, 3.5, 3, 1.5, 9);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_6, 6, 3.5, 3, 1.5, 8);
|
||||
@@ -288,7 +294,7 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_13, 4, 4.75, 3, 5.5, 3);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_14, 3, 2.0, 4, 2.5, 5);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_15, 3, 3.0, 2, 2.5, 3);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_16, 8, 6.5, 3, 5.5, 9);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_17, 10, 7.75, 7, 5.5, 13);
|
||||
#else
|
||||
@@ -313,7 +319,7 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_31, 2, 2.0, 1, 0.5, 2);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_32, 2, 2.75, 2, 1.25, 2);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_33, 4, 3.0, 3, 6.0, 4);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_34, 7, 7.25, 1, 0.5, 8);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_34, 5, 7.25, 1, 0.5, 6);
|
||||
@@ -326,7 +332,7 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_40, 11, 14.0, 9, 13.0, 11);
|
||||
|
||||
TEST_DIFFERENCE(case_recursive_boxes_41, 1, 0.5, 1, 0.5, 2);
|
||||
#ifndef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifdef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
// 42.a Fails with self-turns
|
||||
TEST_DIFFERENCE(case_recursive_boxes_42, 1, 1.0, 4, 4.0, 5);
|
||||
#endif
|
||||
@@ -336,7 +342,7 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_46, 4, 14.0, 5, 12.0, 5);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_47, 4, 10.0, 7, 11.0, 1);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_48, 0, 0.0, 1, 9.0, 1);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_49, 10, 22.0, 10, 17.0, 11);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_49, 9, 22.0, 10, 17.0, 10);
|
||||
@@ -344,7 +350,7 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_50, 14, 21.0, 16, 21.0, 14);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_51, 14, 25.0, 12, 31.0, 7);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_52, 13, 30.0, 15, 25.0, 8);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_52, 13, 30.0, 15, 25.0, 8);
|
||||
@@ -352,20 +358,20 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_53, 6, 3.5, 4, 1.5, 9);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_54, 6, 6.5, 8, 6.0, 7);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_55, 4, 5.5, 6, 7.75, 4);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_56, 4, 4.5, 5, 2.75, 6);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_56, 4, 4.5, 5, 2.75, 6);
|
||||
#endif
|
||||
TEST_DIFFERENCE(case_recursive_boxes_57, 5, 3.75, 9, 6.5, 10);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_58, 4, 2.25, 6, 3.75, 7);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_59, 8, 6.5, 7, 7.0, 12);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_59, 8, 6.5, 6, 7.0, 11);
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_60, 6, 5.25, 7, 5.25, 11);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_60, 5, 5.25, 5, 5.25, 8);
|
||||
@@ -376,7 +382,7 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_62, 5, 5.0, 11, 5.75, 12);
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_63, 9, 10.5, 5, 27.75, 4);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_63, 6, 10.5, 5, 27.75, 2);
|
||||
@@ -384,7 +390,7 @@ void test_areal()
|
||||
|
||||
TEST_DIFFERENCE(case_recursive_boxes_64, 6, 2.75, 7, 4.5, 11);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_65, 6, 4.25, 7, 3.0, 13);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_65, 4, 4.25, 7, 3.0, 11);
|
||||
@@ -394,13 +400,13 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_67, 7, 6.25, 9, 6.0, 10);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_68, 10, 6.5, 9, 6.5, 7);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_69, 5, 6.25, 5, 6.75, 8);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_70, 5, 2.0, 8, 4.5, 11);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_70, 5, 2.0, 6, 4.5, 9);
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_71, 7, 8.25, 7, 5.75, 8);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_71, 6, 8.25, 7, 5.75, 7);
|
||||
@@ -410,7 +416,7 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_73, 4, 1.75, 5, 4.0, 8);
|
||||
|
||||
TEST_DIFFERENCE(case_recursive_boxes_74, 3, 3.00, 3, 1.5, 5);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_75, 7, 4.5, 4, 2.0, 11);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_75, 5, 4.5, 4, 2.0, 9);
|
||||
@@ -419,7 +425,7 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_76, 7, 3.75, 4, 2.5, 9);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_77, 4, 3.75, 7, 6.25, 8);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_78, 11, 5.5, 8, 4.5, 14);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_79, 2, 1.25, 6, 4.5, 8);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_79, 2, 1.25, 5, 4.5, 7);
|
||||
@@ -433,6 +439,23 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_80, 1, 0.5, 2, 0.75, 3);
|
||||
#endif
|
||||
|
||||
TEST_DIFFERENCE(case_recursive_boxes_81, 3, 5.0, 6, 6.75, 6);
|
||||
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_82, 5, 7.25, 7, 4.5, 8);
|
||||
#else
|
||||
TEST_DIFFERENCE_IGNORE(case_recursive_boxes_82, 5, 7.25, 6, 4.5, 7);
|
||||
#endif
|
||||
TEST_DIFFERENCE(case_recursive_boxes_83, 9, 5.25, 8, 5.25, 12);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_84, 4, 8.0, 7, 9.0, 4);
|
||||
#ifdef BOOST_GEOMETRY_NO_ROBUSTNESS
|
||||
TEST_DIFFERENCE(case_recursive_boxes_85, 4, 4.0, 7, 3.75, 9);
|
||||
#endif
|
||||
|
||||
TEST_DIFFERENCE(case_recursive_boxes_86, 1, 1.5, 2, 1.5, 3);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_87, 4, 2.0, 4, 2.5, 8);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_88, 3, 4.75, 5, 6.75, 4);
|
||||
|
||||
{
|
||||
ut_settings sym_settings;
|
||||
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
@@ -446,11 +469,10 @@ void test_areal()
|
||||
sym_settings);
|
||||
}
|
||||
|
||||
#if defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS) && ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
TEST_DIFFERENCE(mysql_regression_1_65_2017_08_31, 1, 4.30697514e-7, 3, 152.0642, 4);
|
||||
#ifdef BOOST_GEOMETRY_NO_ROBUSTNESS
|
||||
TEST_DIFFERENCE(mysql_regression_1_65_2017_08_31, 0, 0.0, 3, 152.0642, 3);
|
||||
#else
|
||||
// Misses one turn which is actually weird because there are no self-turns involved
|
||||
TEST_DIFFERENCE(mysql_regression_1_65_2017_08_31, 0, 0, 3, 152.0642, 3);
|
||||
TEST_DIFFERENCE(mysql_regression_1_65_2017_08_31, 1, 4.30697514e-7, 3, 152.0642, 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -487,7 +509,7 @@ void test_specific_areal()
|
||||
|
||||
ut_settings settings;
|
||||
settings.remove_spikes = true;
|
||||
#if ! defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS)
|
||||
#if defined(BOOST_GEOMETRY_NO_SELF_TURNS)
|
||||
settings.sym_difference = false;
|
||||
settings.test_validity = false;
|
||||
#endif
|
||||
@@ -495,7 +517,7 @@ void test_specific_areal()
|
||||
std::string a_min_b =
|
||||
TEST_DIFFERENCE_WITH(0, 1, ticket_12751, 1, 2781965.0, 1, 597.0, 2);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE_WITH(2, 3, ticket_12751, 2, 2537992.5, 2, 294963.5, 3);
|
||||
#else
|
||||
|
||||
@@ -514,7 +536,7 @@ void test_specific_areal()
|
||||
ut_settings settings;
|
||||
settings.remove_spikes = true;
|
||||
settings.sym_difference = false;
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_DIFFERENCE_WITH(0, 1, ticket_12752, 3, 2776692.0, 3, 7893.0, 2);
|
||||
#else
|
||||
// If self-intersections are not tested, result is not valid
|
||||
@@ -537,7 +559,7 @@ void test_specific_areal()
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.sym_difference = false;
|
||||
#ifndef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifdef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
settings.test_validity = false;
|
||||
TEST_DIFFERENCE_WITH(0, 1, ticket_9942, 3, 7427491.5, 4, 131506, 4);
|
||||
#else
|
||||
|
||||
@@ -55,19 +55,19 @@ void test_spikes_in_ticket_8364()
|
||||
ignore_validity);
|
||||
#endif
|
||||
|
||||
// TODO: behaviour is not good yet. It is changed at introduction of self-turns.
|
||||
test_one<polygon, multi_polygon, multi_polygon>("ticket_8364_step4",
|
||||
"MULTIPOLYGON(((2567 2688,2136 2790,2052 2712,1032 2130,1032 1764,1032 1458,1032 1212,2136 2328,3232 2220,3232 1056,1031 1056,1031 2856,3232 2856,3232 2580,2567 2688)))",
|
||||
"MULTIPOLYGON(((1032 2556,1778 2556,1032 2130,1032 2556)),((3234 2580,3234 2556,1778 2556,2136 2760,3234 2580)))",
|
||||
1,
|
||||
if_typed<ct, int>(20, 20),
|
||||
if_typed<ct, int>(1, 2),
|
||||
if_typed<ct, int>(17, 20),
|
||||
if_typed<ct, int>(2615783.5, 2616029.559567), // SQL Server: 2616029.55616044
|
||||
1,
|
||||
if_typed<ct, int>(9, 11),
|
||||
if_typed<ct, int>(161133.5, 161054.559567), // SQL Server: 161054.560110092
|
||||
if_typed<ct, int>(1, 2),
|
||||
if_typed<ct, int>(28, 31),
|
||||
if_typed<ct, int>(2776875.5, 2616029.559567 + 161054.559567),
|
||||
ignore_validity);
|
||||
if_typed<ct, int>(1, 3),
|
||||
if_typed<ct, int>(25, 31),
|
||||
if_typed<ct, int>(2776875.5, 2616029.559567 + 161054.559567));
|
||||
}
|
||||
|
||||
template <typename P, bool ClockWise, bool Closed>
|
||||
@@ -83,8 +83,8 @@ void test_spikes_in_ticket_8365()
|
||||
test_one<polygon, multi_polygon, multi_polygon>("ticket_8365_step2",
|
||||
"MULTIPOLYGON(((971 2704,971 1402,4640 1402,3912 1722,3180 2376,3912 1884,4643 1402,5395 1402,5395 3353,971 3353,971 2865,1704 3348)))",
|
||||
"MULTIPOLYGON(((5388 1560,4650 1722,3912 1884,4650 1398)),((2442 3186,1704 3348,966 2700,1704 3024)))",
|
||||
if_typed<ct, int>(2, 2),
|
||||
if_typed<ct, int>(21, 21),
|
||||
2,
|
||||
18,
|
||||
if_typed<ct, int>(7975092.5, 7975207.6047877), // SQL Server:
|
||||
2,
|
||||
-1,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2016, 2017.
|
||||
// Modifications copyright (c) 2016-2017, Oracle and/or its affiliates.
|
||||
@@ -104,8 +105,8 @@ void difference_output(std::string const& caseid, G1 const& g1, G2 const& g2, Ou
|
||||
<< string_from_type<coordinate_type>::name()
|
||||
<< (ccw ? "_ccw" : "")
|
||||
<< (open ? "_open" : "")
|
||||
#if defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS)
|
||||
<< "_self"
|
||||
#if defined(BOOST_GEOMETRY_NO_SELF_TURNS)
|
||||
<< "_no_self"
|
||||
#endif
|
||||
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
<< "_no_rob"
|
||||
@@ -253,7 +254,7 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
|
||||
|
||||
if (expected_count >= 0)
|
||||
{
|
||||
BOOST_CHECK_MESSAGE(int(result.size()) == expected_count,
|
||||
BOOST_CHECK_MESSAGE(int(boost::size(result)) == expected_count,
|
||||
"difference: " << caseid
|
||||
<< " #outputs expected: " << expected_count
|
||||
<< " detected: " << result.size()
|
||||
@@ -263,7 +264,7 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
|
||||
|
||||
if (expected_rings_count >= 0)
|
||||
{
|
||||
int nrings = expected_count + bg::num_interior_rings(result);
|
||||
int nrings = int(boost::size(result) + bg::num_interior_rings(result));
|
||||
BOOST_CHECK_MESSAGE(nrings == expected_rings_count,
|
||||
"difference: " << caseid
|
||||
<< " #rings expected: " << expected_rings_count
|
||||
|
||||
@@ -46,7 +46,7 @@ BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
|
||||
(test_one<Polygon, Polygon, Polygon>) \
|
||||
( #caseid, caseid[0], caseid[1], clips, points, area)
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS)
|
||||
#if defined(BOOST_GEOMETRY_NO_SELF_TURNS)
|
||||
#define TEST_INTERSECTION_IGNORE(caseid, clips, points, area) \
|
||||
{ ut_settings ignore_validity; ignore_validity.test_validity = false; \
|
||||
(test_one<Polygon, Polygon, Polygon>) \
|
||||
@@ -355,7 +355,7 @@ void test_areal()
|
||||
|
||||
TEST_INTERSECTION(case_105, 1, 34, 76.0);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_INTERSECTION(case_106, 2, -1, 3.5);
|
||||
TEST_INTERSECTION(case_107, 3, -1, 3.0);
|
||||
#else
|
||||
@@ -378,7 +378,7 @@ void test_areal()
|
||||
2, -1, 183.71376870369406);
|
||||
|
||||
// Needs self-intersections to solve validity
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_INTERSECTION(mysql_23023665_6, 2, 0, 11.812440191387557);
|
||||
#else
|
||||
TEST_INTERSECTION_IGNORE(mysql_23023665_6, 1, -1, 11.812440191387557);
|
||||
|
||||
@@ -111,7 +111,7 @@ void test_areal()
|
||||
3, 16, 6.15);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_77_multi",
|
||||
case_77_multi[0], case_77_multi[1],
|
||||
5, 33, 9.0);
|
||||
5, 27, 9.0);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_78_multi",
|
||||
case_78_multi[0], case_78_multi[1],
|
||||
1, 16, 22.0);
|
||||
@@ -146,7 +146,7 @@ void test_areal()
|
||||
TEST_INTERSECTION(case_123_multi, 3, 13, 1.875);
|
||||
TEST_INTERSECTION(case_124_multi, 2, 13, 2.0625);
|
||||
TEST_INTERSECTION(case_125_multi, 3, 17, 2.1);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_INTERSECTION(case_126_multi, 5, 27, 9.0);
|
||||
#else
|
||||
TEST_INTERSECTION_IGNORE(case_126_multi, 3, 23, 9.0);
|
||||
@@ -158,20 +158,17 @@ void test_areal()
|
||||
|
||||
TEST_INTERSECTION(case_133_multi, 2, 23, 40.625);
|
||||
TEST_INTERSECTION(case_134_multi, 1, 23, 42.0);
|
||||
TEST_INTERSECTION(case_135_multi, 1, 17, 7.0);
|
||||
TEST_INTERSECTION(case_136_multi, 1, 17, 6.5);
|
||||
TEST_INTERSECTION(case_137_multi, 1, 17, 6.5);
|
||||
TEST_INTERSECTION(case_135_multi, 1, 12, 7.0);
|
||||
TEST_INTERSECTION(case_136_multi, 1, 12, 6.5);
|
||||
TEST_INTERSECTION(case_137_multi, 1, 12, 6.5);
|
||||
|
||||
TEST_INTERSECTION(case_138_multi, 2, 23, 40.4);
|
||||
TEST_INTERSECTION(case_139_multi, 2, 23, 40.546875);
|
||||
TEST_INTERSECTION(case_140_multi, 2, 23, 40.546875);
|
||||
TEST_INTERSECTION(case_141_multi, 3, -1, 74.5);
|
||||
|
||||
// TODO: isolated region with multiple connection should be handled
|
||||
// differently
|
||||
TEST_INTERSECTION_IGNORE(case_141_multi, 2, -1, 74.5);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
TEST_INTERSECTION(case_recursive_boxes_1, 10, 97, 47.0);
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_INTERSECTION(case_recursive_boxes_1, 10, 89, 47.0);
|
||||
#else
|
||||
TEST_INTERSECTION_IGNORE(case_recursive_boxes_1, 8, 97, 47.0);
|
||||
#endif
|
||||
@@ -181,10 +178,10 @@ void test_areal()
|
||||
1, 50, 90.0); // Area from SQL Server
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_3",
|
||||
case_recursive_boxes_3[0], case_recursive_boxes_3[1],
|
||||
19, 87, 12.5); // Area from SQL Server
|
||||
19, 84, 12.5); // Area from SQL Server
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
TEST_INTERSECTION_IGNORE(case_recursive_boxes_4, 13, 169, 67.0);
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_INTERSECTION_IGNORE(case_recursive_boxes_4, 13, 158, 67.0);
|
||||
#else
|
||||
TEST_INTERSECTION_IGNORE(case_recursive_boxes_4, 8, 178, 67.0);
|
||||
#endif
|
||||
@@ -193,7 +190,7 @@ void test_areal()
|
||||
// Should contain 6 output polygons
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_6",
|
||||
case_recursive_boxes_6[0], case_recursive_boxes_6[1],
|
||||
6, 47, 19.0);
|
||||
6, 42, 19.0);
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_7",
|
||||
case_recursive_boxes_7[0], case_recursive_boxes_7[1],
|
||||
@@ -302,8 +299,8 @@ void test_areal()
|
||||
TEST_INTERSECTION(case_recursive_boxes_47, 1, 5, 1.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_48, 1, 5, 1.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_49, 7, 57, 20.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_50, 9, 71, 26.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_51, 14, 79, 19.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_50, 9, 62, 26.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_51, 14, 74, 19.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_52, 8, -1, 22.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_53, 1, -1, 19.75);
|
||||
TEST_INTERSECTION(case_recursive_boxes_54, 3, -1, 10.0);
|
||||
@@ -317,14 +314,14 @@ void test_areal()
|
||||
TEST_INTERSECTION(case_recursive_boxes_62, 9, -1, 10.5);
|
||||
|
||||
TEST_INTERSECTION(case_recursive_boxes_63, 11, -1, 5.75);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_INTERSECTION(case_recursive_boxes_64, 5, -1, 17.25);
|
||||
#else
|
||||
TEST_INTERSECTION_IGNORE(case_recursive_boxes_64, 4, -1, 17.25);
|
||||
#endif
|
||||
TEST_INTERSECTION(case_recursive_boxes_65, 3, -1, 17.25);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_INTERSECTION(case_recursive_boxes_66, 4, -1, 16.0);
|
||||
#else
|
||||
TEST_INTERSECTION_IGNORE(case_recursive_boxes_66, 2, -1, 16.0);
|
||||
@@ -333,7 +330,7 @@ void test_areal()
|
||||
TEST_INTERSECTION(case_recursive_boxes_67, 5, -1, 2.5);
|
||||
TEST_INTERSECTION(case_recursive_boxes_68, 8, -1, 9.5);
|
||||
TEST_INTERSECTION(case_recursive_boxes_69, 6, -1, 3.25);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_INTERSECTION(case_recursive_boxes_70, 6, -1, 18.5);
|
||||
#else
|
||||
// Misses a necessary self-turn and therefore a ring
|
||||
@@ -343,7 +340,7 @@ void test_areal()
|
||||
TEST_INTERSECTION(case_recursive_boxes_71, 3, -1, 1.75);
|
||||
TEST_INTERSECTION(case_recursive_boxes_72, 8, -1, 4.5);
|
||||
TEST_INTERSECTION(case_recursive_boxes_73, 3, -1, 18.5);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_INTERSECTION(case_recursive_boxes_74, 3, -1, 20.25);
|
||||
#else
|
||||
TEST_INTERSECTION_IGNORE(case_recursive_boxes_74, 2, -1, 20.25);
|
||||
@@ -355,6 +352,21 @@ void test_areal()
|
||||
TEST_INTERSECTION(case_recursive_boxes_78, 9, -1, 8.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_79, 5, -1, 9.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_80, 1, -1, 0.25);
|
||||
TEST_INTERSECTION(case_recursive_boxes_81, 5, -1, 3.75);
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_INTERSECTION(case_recursive_boxes_82, 5, -1, 8.5);
|
||||
#else
|
||||
TEST_INTERSECTION_IGNORE(case_recursive_boxes_82, 3, -1, 8.5);
|
||||
#endif
|
||||
|
||||
TEST_INTERSECTION(case_recursive_boxes_83, 5, -1, 10.25);
|
||||
TEST_INTERSECTION(case_recursive_boxes_84, 1, -1, 0.5);
|
||||
#ifdef BOOST_GEOMETRY_NO_ROBUSTNESS
|
||||
TEST_INTERSECTION(case_recursive_boxes_85, 1, -1, 0.25);
|
||||
#endif
|
||||
TEST_INTERSECTION(case_recursive_boxes_86, 0, -1, 0.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_87, 0, -1, 0.0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_88, 4, -1, 3.5);
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a",
|
||||
ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],
|
||||
@@ -385,7 +397,7 @@ void test_areal()
|
||||
mysql_23023665_7[0], mysql_23023665_7[1],
|
||||
2, 11, 9.80505786783);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_INTERSECTION(mysql_23023665_12, 2, 0, 11.812440191387557);
|
||||
#else
|
||||
TEST_INTERSECTION_IGNORE(mysql_23023665_12, 1, -1, 11.812440191387557);
|
||||
|
||||
@@ -248,8 +248,8 @@ typename bg::default_area_result<G1>::type test_intersection(std::string const&
|
||||
<< string_from_type<CalculationType>::name()
|
||||
<< (ccw ? "_ccw" : "")
|
||||
<< (open ? "_open" : "")
|
||||
#if defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS)
|
||||
<< "_self"
|
||||
#if defined(BOOST_GEOMETRY_NO_SELF_TURNS)
|
||||
<< "_no_self"
|
||||
#endif
|
||||
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
<< "_no_rob"
|
||||
|
||||
@@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE( test_sym_difference_polygon_multipolygon )
|
||||
from_wkt<MPG>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),\
|
||||
((20 0,20 10,30 10,30 0,20 0)))"),
|
||||
1,
|
||||
9,
|
||||
6,
|
||||
300);
|
||||
}
|
||||
|
||||
|
||||
@@ -223,8 +223,8 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
|
||||
<< string_from_type<coordinate_type>::name()
|
||||
<< (ccw ? "_ccw" : "")
|
||||
<< (open ? "_open" : "")
|
||||
#if defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS)
|
||||
<< "_self"
|
||||
#if defined(BOOST_GEOMETRY_NO_SELF_TURNS)
|
||||
<< "_no_self"
|
||||
#endif
|
||||
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
<< "_no_rob"
|
||||
|
||||
@@ -145,7 +145,7 @@ void test_areal()
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("distance_zero",
|
||||
distance_zero[0], distance_zero[1],
|
||||
1, 0, if_typed<ct, float>(9, 11), 9.0098387);
|
||||
1, 0, 8, 9.0098387);
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("wrapped_a",
|
||||
wrapped[0], wrapped[1],
|
||||
@@ -398,15 +398,15 @@ void test_areal()
|
||||
// Robustness issues, followed out buffer-robustness-tests, test them also reverse
|
||||
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_f", buffer_rt_f[0], buffer_rt_f[1],
|
||||
1, 0, 23, 4.60853);
|
||||
1, 0, 15, 4.60853);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_f_rev", buffer_rt_f[1], buffer_rt_f[0],
|
||||
1, 0, 23, 4.60853);
|
||||
1, 0, 15, 4.60853);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_g", buffer_rt_g[0], buffer_rt_g[1],
|
||||
1, 0, if_typed<ct, float>(18, 17), 16.571);
|
||||
1, 0, if_typed<ct, float>(16, 11), 16.571);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_g_rev", buffer_rt_g[1], buffer_rt_g[0],
|
||||
1, 0, if_typed<ct, float>(18, 17), 16.571);
|
||||
1, 0, if_typed<ct, float>(16, 11), 16.571);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_i", buffer_rt_i[0], buffer_rt_i[1],
|
||||
1, 0, if_typed<ct, float>(14, 13), 13.6569);
|
||||
1, 0, if_typed<ct, float>(11, 13), 13.6569);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_i_rev", buffer_rt_i[1], buffer_rt_i[0],
|
||||
1, 0, 13, 13.6569);
|
||||
#endif
|
||||
@@ -424,31 +424,28 @@ void test_areal()
|
||||
#endif
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_m1", buffer_rt_m1[0], buffer_rt_m1[1],
|
||||
1, 0, if_typed_tt<ct>(14, 13), 19.4852);
|
||||
1, 0, 9, 19.4852);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_m1_rev", buffer_rt_m1[1], buffer_rt_m1[0],
|
||||
1, 0, if_typed_tt<ct>(14, 13), 19.4852);
|
||||
1, 0, 9, 19.4852);
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_m2", buffer_rt_m2[0], buffer_rt_m2[1],
|
||||
1, 0, if_typed_tt<ct>(20, 19), 21.4853);
|
||||
1, 0, 12, 21.4853);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_m2_rev", buffer_rt_m2[1], buffer_rt_m2[0],
|
||||
1, 0, if_typed_tt<ct>(20, 19), 21.4853);
|
||||
1, 0, 15, 21.4853);
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_q", buffer_rt_q[0], buffer_rt_q[1],
|
||||
1, 0, 18, 18.5710);
|
||||
1, 0, if_typed<ct, float>(16, 12), 18.5710);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_q_rev", buffer_rt_q[1], buffer_rt_q[0],
|
||||
1, 0, 18, 18.5710);
|
||||
1, 0, if_typed<ct, float>(16, 12), 18.5710);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_r", buffer_rt_r[0], buffer_rt_r[1],
|
||||
1, 0, 19, 21.07612);
|
||||
1, 0, if_typed<ct, float>(18, 14), 21.07612);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_r_rev", buffer_rt_r[1], buffer_rt_r[0],
|
||||
1, 0, if_typed_tt<ct>(20, 19), 21.07612);
|
||||
#endif
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
1, 0, if_typed<ct, float>(18, 14), 21.07612);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_t", buffer_rt_t[0], buffer_rt_t[1],
|
||||
1, 0, if_typed_tt<ct>(16, 14), 15.6569);
|
||||
1, 0, 9, 15.6569);
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_t_rev", buffer_rt_t[1], buffer_rt_t[0],
|
||||
1, 0, if_typed_tt<ct>(16, if_typed<ct, float>(15, 14)), 15.6569);
|
||||
1, 0, 10, 15.6569);
|
||||
#endif
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_mp1", buffer_mp1[0], buffer_mp1[1],
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Boost.Geometry
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// Copyright (c) 2017, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@@ -50,7 +52,7 @@ void test_geographic_one(std::string const& wkt1, std::string const& wkt2,
|
||||
bg::srs::spheroid<double> sph(6378137.0000000000, 6356752.3142451793);
|
||||
|
||||
bg::strategy::intersection::geographic_segments<> is(sph);
|
||||
bg::strategy::area::geographic<point> as(sph);
|
||||
bg::strategy::area::geographic<> as(sph);
|
||||
|
||||
polygon p1, p2;
|
||||
|
||||
@@ -98,8 +100,8 @@ void test_geographic_one(std::string const& wkt1, std::string const& wkt2,
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_CHECK_EQUAL(result_count, 0);
|
||||
BOOST_CHECK_EQUAL(result_area, 0);
|
||||
BOOST_CHECK_EQUAL(result_count, 0u);
|
||||
BOOST_CHECK_EQUAL(result_area, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ void test_areal()
|
||||
1, 0, 13, 6);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_101_multi",
|
||||
case_101_multi[0], case_101_multi[1],
|
||||
1, 3, 35, 22.25);
|
||||
1, 3, 32, 22.25);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_103_multi",
|
||||
case_103_multi[0], case_103_multi[1],
|
||||
1, 0, 7, 25);
|
||||
@@ -122,7 +122,7 @@ void test_areal()
|
||||
1, 0, 5, 25);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_106_multi",
|
||||
case_106_multi[0], case_106_multi[1],
|
||||
1, 0, 12, 25);
|
||||
1, 0, 5, 25);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_107_multi",
|
||||
case_107_multi[0], case_107_multi[1],
|
||||
1, 0, 15, 6.75);
|
||||
@@ -130,8 +130,7 @@ void test_areal()
|
||||
case_108_multi[0], case_108_multi[1],
|
||||
1, 1, 20, 22.75);
|
||||
|
||||
// Should have 2 holes. Needs self turns
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_UNION(case_109_multi, 1, 2, 14, 1400);
|
||||
#else
|
||||
TEST_UNION_IGNORE(case_109_multi, 1, 1, 14, 1400);
|
||||
@@ -171,21 +170,20 @@ void test_areal()
|
||||
2, 0, 26, 44);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_120_multi",
|
||||
case_120_multi[0], case_120_multi[1],
|
||||
1, 1, 20, 35);
|
||||
1, 1, 17, 35);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_121_multi",
|
||||
case_121_multi[0], case_121_multi[1],
|
||||
1, 1, 21, 25.5);
|
||||
1, 1, 14, 25.5);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_122_multi",
|
||||
case_122_multi[0], case_122_multi[1],
|
||||
1, 1, 28, 29.5);
|
||||
1, 1, 14, 29.5);
|
||||
|
||||
TEST_UNION(case_123_multi, 1, 0, 11, 2.75);
|
||||
TEST_UNION(case_124_multi, 1, 0, 9, 2.75);
|
||||
TEST_UNION(case_125_multi, 1, 0, 9, 2.75);
|
||||
TEST_UNION(case_126_multi, 1, 2, 27, 52.0);
|
||||
|
||||
// Should have 2 holes. Needs self turns
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_UNION(case_131_multi, 1, 2, 15, 14.0);
|
||||
#else
|
||||
TEST_UNION_IGNORE(case_131_multi, 1, 1, 15, 14.0);
|
||||
@@ -211,28 +209,27 @@ void test_areal()
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_1",
|
||||
case_recursive_boxes_1[0], case_recursive_boxes_1[1],
|
||||
1, 1, 36, 97.0);
|
||||
1, 1, 16, 97.0);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_2",
|
||||
case_recursive_boxes_2[0], case_recursive_boxes_2[1],
|
||||
1, 0, 14, 100.0); // Area from SQL Server
|
||||
1, 0, 5, 100.0); // Area from SQL Server
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_3",
|
||||
case_recursive_boxes_3[0], case_recursive_boxes_3[1],
|
||||
17, 6, 166, 56.5); // Area from SQL Server
|
||||
17, 6, 154, 56.5); // Area from SQL Server
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_4",
|
||||
case_recursive_boxes_4[0], case_recursive_boxes_4[1],
|
||||
1, 2, 42, 96.75);
|
||||
1, 2, 26, 96.75);
|
||||
|
||||
// Should have 10 holes. Needs self turns
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
TEST_UNION(case_recursive_boxes_5, 3, 10, 118, 70.0);
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_UNION(case_recursive_boxes_5, 3, 10, 98, 70.0);
|
||||
#else
|
||||
TEST_UNION_IGNORE(case_recursive_boxes_5, 3, 9, 115, 70.0);
|
||||
#endif
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_6",
|
||||
case_recursive_boxes_6[0], case_recursive_boxes_6[1],
|
||||
1, 3, 25, 24.0);
|
||||
1, 3, 17, 24.0);
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_7",
|
||||
case_recursive_boxes_7[0], case_recursive_boxes_7[1],
|
||||
@@ -244,7 +241,7 @@ void test_areal()
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_9",
|
||||
case_recursive_boxes_9[0], case_recursive_boxes_9[1],
|
||||
1, 1, 16, 8.25);
|
||||
1, 1, 11, 8.25);
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_10",
|
||||
case_recursive_boxes_10[0], case_recursive_boxes_10[1],
|
||||
@@ -267,8 +264,8 @@ void test_areal()
|
||||
// to break regions at self-intersection points (postponed)
|
||||
|
||||
TEST_UNION_IGNORE(case_recursive_boxes_12_invalid, 5, 0, -1, 6.0);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
// Without self-turns, a whole part is missed
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
// Only apply it with self-turns. Without them a whole part is missed
|
||||
TEST_UNION_IGNORE(case_recursive_boxes_13_invalid, 2, 0, -1, 10.25);
|
||||
#endif
|
||||
TEST_UNION_IGNORE(case_recursive_boxes_14_invalid, 4, 0, -1, 4.5);
|
||||
@@ -349,7 +346,7 @@ void test_areal()
|
||||
TEST_UNION(case_recursive_boxes_46, 1, 4, 51, 33.0);
|
||||
TEST_UNION(case_recursive_boxes_47, 1, 0, -1, 22.0);
|
||||
TEST_UNION(case_recursive_boxes_48, 1, 1, -1, 10.0);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_UNION(case_recursive_boxes_49, 1, 3, -1, 59.0);
|
||||
#else
|
||||
TEST_UNION_IGNORE(case_recursive_boxes_49, 1, 2, -1, 59.0);
|
||||
@@ -357,7 +354,7 @@ void test_areal()
|
||||
|
||||
TEST_UNION(case_recursive_boxes_50, 7, 4, -1, 68.0);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_UNION(case_recursive_boxes_51, 2, 6, -1, 75.0);
|
||||
#else
|
||||
TEST_UNION_IGNORE(case_recursive_boxes_51, 2, 5, -1, 75.0);
|
||||
@@ -365,14 +362,14 @@ void test_areal()
|
||||
|
||||
TEST_UNION(case_recursive_boxes_52, 2, 6, -1, 77.0);
|
||||
TEST_UNION(case_recursive_boxes_53, 1, 1, -1, 24.75);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_UNION(case_recursive_boxes_54, 1, 2, -1, 22.5);
|
||||
#else
|
||||
TEST_UNION_IGNORE(case_recursive_boxes_54, 1, 1, -1, 22.5);
|
||||
#endif
|
||||
|
||||
TEST_UNION(case_recursive_boxes_55, 3, 1, -1, 15.5);
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_UNION(case_recursive_boxes_56, 5, 1, -1, 7.75);
|
||||
#else
|
||||
TEST_UNION_IGNORE(case_recursive_boxes_56, 5, 0, -1, 7.75);
|
||||
@@ -380,7 +377,7 @@ void test_areal()
|
||||
TEST_UNION(case_recursive_boxes_57, 3, 4, -1, 19.75);
|
||||
TEST_UNION(case_recursive_boxes_58, 6, 1, -1, 6.25);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
// If there are no self-turns, an interior ring is missed
|
||||
TEST_UNION(case_recursive_boxes_59, 1, 3, -1, 21.75);
|
||||
#endif
|
||||
@@ -414,6 +411,15 @@ void test_areal()
|
||||
TEST_UNION(case_recursive_boxes_80, 2, 1, -1, 1.5);
|
||||
#endif
|
||||
|
||||
TEST_UNION(case_recursive_boxes_81, 5, 0, -1, 15.5);
|
||||
TEST_UNION(case_recursive_boxes_82, 2, 2, -1, 20.25);
|
||||
TEST_UNION(case_recursive_boxes_83, 3, 1, -1, 20.75);
|
||||
TEST_UNION(case_recursive_boxes_84, 4, 1, -1, 17.5);
|
||||
TEST_UNION(case_recursive_boxes_85, 9, 0, -1, 8.0);
|
||||
TEST_UNION(case_recursive_boxes_86, 3, 0, -1, 3.0);
|
||||
TEST_UNION(case_recursive_boxes_87, 8, 0, -1, 4.5);
|
||||
TEST_UNION(case_recursive_boxes_88, 5, 1, -1, 15.0);
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a",
|
||||
ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],
|
||||
1, 0, 12, 23.0); // Area from SQL Server
|
||||
@@ -454,15 +460,13 @@ void test_areal()
|
||||
|
||||
TEST_UNION(ticket_12503, 42, 1, -1, 945.625);
|
||||
|
||||
// Should have 1 hole. Needs self turns.
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_UNION(mysql_23023665_7, 1, 1, -1, 99.19494);
|
||||
#else
|
||||
TEST_UNION_IGNORE(mysql_23023665_7, 1, 0, -1, 99.19494);
|
||||
#endif
|
||||
|
||||
// Should have 2 holes. Needs self turns.
|
||||
#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
|
||||
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
|
||||
TEST_UNION(mysql_23023665_8, 1, 2, -1, 1400.0);
|
||||
#else
|
||||
TEST_UNION_IGNORE(mysql_23023665_8, 1, 1, -1, 1400.0);
|
||||
|
||||
@@ -84,11 +84,17 @@ void test_all()
|
||||
test_geometry<bg::model::linestring<P> >(
|
||||
"LINESTRING(0 0,120 6,80 10,200 0)",
|
||||
"LINESTRING(0 0,120 6,80 10,200 0)", 7);
|
||||
|
||||
// Same which reordered coordinates
|
||||
test_geometry<bg::model::linestring<P> >(
|
||||
"LINESTRING(0 0,80 10,120 6,200 0)",
|
||||
"LINESTRING(0 0,80 10,200 0)", 7);
|
||||
|
||||
// Duplicate point is removed
|
||||
test_geometry<bg::model::linestring<P> >(
|
||||
"LINESTRING(0 0,0 0)",
|
||||
"LINESTRING(0 0)", 1.0);
|
||||
|
||||
// Mail 2013-10-07, real-life test, piece of River Leine
|
||||
// PostGIS returns exactly the same result
|
||||
test_geometry<bg::model::linestring<P> >(
|
||||
@@ -110,9 +116,15 @@ void test_all()
|
||||
"LINESTRING(0 0,5 5,7 5,10 10)", 1.0);
|
||||
*/
|
||||
|
||||
test_geometry<bg::model::ring<P> >(
|
||||
"POLYGON((4 0,8 2,8 7,4 9,0 7,0 2,2 1,4 0))",
|
||||
"POLYGON((4 0,8 2,8 7,4 9,0 7,0 2,4 0))", 1.0);
|
||||
/*
|
||||
|
||||
Above can be checked in PostGIS by:
|
||||
|
||||
select astext(ST_Simplify(geomfromtext('LINESTRING(0 0, 5 5, 10 10)'),1.0)) as simplified
|
||||
union all select astext(ST_Simplify(geomfromtext('LINESTRING(0 0, 5 5, 6 5, 10 10)'),1.0))
|
||||
etc
|
||||
*/
|
||||
|
||||
|
||||
test_geometry<bg::model::polygon<P> >(
|
||||
"POLYGON((4 0,8 2,8 7,4 9,0 7,0 2,2 1,4 0))",
|
||||
@@ -122,14 +134,73 @@ void test_all()
|
||||
"POLYGON((4 0,8 2,8 7,4 9,0 7,0 2,2 1,4 0),(7 3,7 6,1 6,1 3,4 3,7 3))",
|
||||
"POLYGON((4 0,8 2,8 7,4 9,0 7,0 2,4 0),(7 3,7 6,1 6,1 3,7 3))", 1.0);
|
||||
|
||||
/*
|
||||
// Closing point should be simplified away
|
||||
test_geometry<bg::model::polygon<P> >(
|
||||
"POLYGON((1 0,0 0,0 4,4 4,4 0,1 0))",
|
||||
"POLYGON((0 0,0 4,4 4,4 0,0 0))", 0.1);
|
||||
|
||||
Above can be checked in PostGIS by:
|
||||
// Section around closing point should be simplified away
|
||||
test_geometry<bg::model::polygon<P> >(
|
||||
"POLYGON((5 0,4 0,3 0,2 0,1 0,0 0,0 5,5 5,5 0))",
|
||||
"POLYGON((5 0,0 0,0 5,5 5,5 0))", 0.1);
|
||||
|
||||
// Manually rotate this WKT over all the 5 redundant points at closing area
|
||||
test_geometry<bg::model::polygon<P> >(
|
||||
"POLYGON((4 0,3 0,2 0,1 0,0 0,0 5,5 5,5 0,4 0))",
|
||||
"POLYGON((0 0,0 5,5 5,5 0,0 0))", 0.1);
|
||||
test_geometry<bg::model::polygon<P> >(
|
||||
"POLYGON((3 0,2 0,1 0,0 0,0 5,5 5,5 0,4 0,3 0))",
|
||||
"POLYGON((0 0,0 5,5 5,5 0,0 0))", 0.1);
|
||||
test_geometry<bg::model::polygon<P> >(
|
||||
"POLYGON((2 0,1 0,0 0,0 5,5 5,5 0,4 0,3 0,2 0))",
|
||||
"POLYGON((0 0,0 5,5 5,5 0,0 0))", 0.1);
|
||||
test_geometry<bg::model::polygon<P> >(
|
||||
"POLYGON((1 0,0 0,0 5,5 5,5 0,4 0,3 0,2 0,1 0))",
|
||||
"POLYGON((0 0,0 5,5 5,5 0,0 0))", 0.1);
|
||||
test_geometry<bg::model::polygon<P> >(
|
||||
"POLYGON((0 0,0 5,5 5,5 0,4 0,3 0,2 0,1 0,0 0))",
|
||||
"POLYGON((0 0,0 5,5 5,5 0,0 0))", 0.1);
|
||||
|
||||
// Test wither all collinear points in between are simplified away
|
||||
// First approach did select one of them because it was the end of the
|
||||
// "closing area". Now the opposite is taken, which is farthest and never
|
||||
// collinear
|
||||
test_geometry<bg::model::polygon<P> >(
|
||||
"POLYGON((2 0,1 0,0 0,0 1,0 2,0 3,0 4,1 4,2 4,3 4,4 4,4 3,4 2,4 1,4 0,3 0,2 0))",
|
||||
"POLYGON((0 0,0 4,4 4,4 0,0 0))", 1.0);
|
||||
|
||||
// Test simplifying away one of the sides (collinear), then closing point
|
||||
// and finally the whole polygon
|
||||
std::string const near_triangle = "POLYGON((0.55 0.55,1 0,0.5 0,0 0,0 1,0.55 0.55))";
|
||||
test_geometry<bg::model::polygon<P> >(near_triangle,
|
||||
"POLYGON((0.55 0.55,1 0,0 0,0 1,0.55 0.55))", 0.01);
|
||||
test_geometry<bg::model::polygon<P> >(near_triangle,
|
||||
"POLYGON((1 0,0 0,0 1,1 0))", 0.1);
|
||||
// 0.9 should still result in a simplified polygon
|
||||
test_geometry<bg::model::polygon<P> >(near_triangle,
|
||||
"POLYGON((1 0,0 0,0 1,1 0))", 0.9);
|
||||
test_geometry<bg::model::polygon<P> >(near_triangle,
|
||||
"POLYGON(())", 1.1);
|
||||
|
||||
// Test simplifying away the closing point, and closing it explicitly
|
||||
std::string const salamina = "POLYGON((2616131.59828 4579307.29099,2616687.86177 4579151.05325,2618172.52982 4578718.79836,2618728.79332 4578522.73574,2620336.91468 4577424.54293,2620522.48427 4576992.50129,2621264.76264 4569815.3917,2621140.75272 4569502.07546,2620491.53745 4568208.96982,2620151.34509 4567855.90928,2612606.55528 4562800.36094,2611833.3301 4562291.50023,2611369.5731 4562174.16117,2610225.54269 4562408.69959,2605896.21638 4564367.29512,2605494.13038 4564641.6634,2605277.94792 4566288.44857,2606019.89233 4569423.46562,2609050.12019 4577424.54293,2614337.90732 4579347.12775,2615296.7021 4579543.34723,2616131.59828 4579307.29099))";
|
||||
test_geometry<bg::model::polygon<P> >(salamina, 196318951.5097456, 100);
|
||||
test_geometry<bg::model::polygon<P> >(salamina, 194471472.35804176, 200);
|
||||
test_geometry<bg::model::polygon<P> >(salamina, 191735337.33374023, 500);
|
||||
test_geometry<bg::model::polygon<P> >(salamina, 186593693.18401337, 1000);
|
||||
test_geometry<bg::model::polygon<P> >(salamina, 181448561.04094696, 2000);
|
||||
test_geometry<bg::model::polygon<P> >(salamina, 141965392.92240524, 5000);
|
||||
|
||||
// Interior ring (sized ~ 1) should be simplified away (distance 5)
|
||||
test_geometry<bg::model::polygon<P> >(
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(5 5,6 6,5 6,5 5))",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0))", 5.0);
|
||||
|
||||
// // Non-closed version
|
||||
// test_geometry<bg::model::polygon<P, true, false> >(
|
||||
// "POLYGON((1 0,0 0,0 4,4 4,4 0))",
|
||||
// "POLYGON((0 0,0 4,4 4,4 0))", 0.1);
|
||||
|
||||
select astext(ST_Simplify(geomfromtext('LINESTRING(0 0, 5 5, 10 10)'),1.0)) as simplified
|
||||
union all select astext(ST_Simplify(geomfromtext('LINESTRING(0 0, 5 5, 6 5, 10 10)'),1.0))
|
||||
etc
|
||||
*/
|
||||
|
||||
{
|
||||
// Test with explicit strategy
|
||||
@@ -217,9 +288,12 @@ int test_main(int, char* [])
|
||||
// Integer compiles, but simplify-process fails (due to distances)
|
||||
//test_all<bg::model::d2::point_xy<int> >();
|
||||
|
||||
test_all<bg::model::d2::point_xy<float> >();
|
||||
test_all<bg::model::d2::point_xy<double> >();
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
|
||||
|
||||
test_all<bg::model::d2::point_xy<float> >();
|
||||
|
||||
test_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
|
||||
|
||||
test_spherical<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
@@ -230,7 +304,7 @@ int test_main(int, char* [])
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
test_spherical<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
188
test/algorithms/simplify_countries.cpp
Normal file
188
test/algorithms/simplify_countries.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// (Unit) Test
|
||||
|
||||
// Copyright (c) 2018 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
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <geometry_test_common.hpp>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
#if defined(TEST_WITH_SVG)
|
||||
# include <boost/geometry/io/svg/svg_mapper.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
template <typename MultiPolygon>
|
||||
std::string read_from_file(std::string const& filename)
|
||||
{
|
||||
MultiPolygon mp;
|
||||
std::ifstream in(filename.c_str());
|
||||
while (in.good())
|
||||
{
|
||||
std::string line;
|
||||
std::getline(in, line);
|
||||
if (! line.empty())
|
||||
{
|
||||
typename boost::range_value<MultiPolygon>::type pol;
|
||||
bg::read_wkt(line, pol);
|
||||
mp.push_back(pol);
|
||||
}
|
||||
}
|
||||
std::ostringstream out;
|
||||
if (! mp.empty())
|
||||
{
|
||||
out << std::fixed << std::setprecision(19) << bg::wkt(mp);
|
||||
}
|
||||
|
||||
BOOST_CHECK(! out.str().empty());
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
||||
template <typename MultiPolygon>
|
||||
void test_one(std::string const& caseid, std::string const& wkt,
|
||||
double distance_in_meters,
|
||||
double expected_area_ratio, double expected_perimeter_ratio,
|
||||
std::size_t expected_polygon_count = 0,
|
||||
std::size_t expected_interior_count = 0,
|
||||
std::size_t expected_point_count = 0)
|
||||
{
|
||||
boost::ignore_unused(caseid);
|
||||
|
||||
MultiPolygon geometry, simplified;
|
||||
bg::read_wkt(wkt, geometry);
|
||||
bg::correct(geometry);
|
||||
bg::simplify(geometry, simplified, distance_in_meters);
|
||||
|
||||
double const area_ratio = bg::area(simplified) / bg::area(geometry);
|
||||
double const perimeter_ratio = bg::perimeter(simplified) / bg::perimeter(geometry);
|
||||
|
||||
BOOST_CHECK_CLOSE(perimeter_ratio, expected_perimeter_ratio, 0.01);
|
||||
BOOST_CHECK_CLOSE(area_ratio, expected_area_ratio, 0.01);
|
||||
BOOST_CHECK_EQUAL(expected_polygon_count, boost::size(simplified));
|
||||
BOOST_CHECK_EQUAL(expected_interior_count, bg::num_interior_rings(simplified));
|
||||
BOOST_CHECK_EQUAL(expected_point_count, bg::num_points(simplified));
|
||||
|
||||
// To add new tests, this is convenient and write the test itself:
|
||||
// std::cout << "test_one<mp>(\"" << caseid << "\", " << caseid
|
||||
// << ", " << distance_in_meters
|
||||
// << std::setprecision(6)
|
||||
// << ", " << area_ratio
|
||||
// << ", " << perimeter_ratio
|
||||
// << ", " << boost::size(simplified)
|
||||
// << ", " << bg::num_interior_rings(simplified)
|
||||
// << ", " << bg::num_points(simplified)
|
||||
// << ");"
|
||||
// << std::endl;
|
||||
|
||||
#if defined(TEST_WITH_SVG)
|
||||
{
|
||||
typedef typename boost::range_value<MultiPolygon>::type polygon;
|
||||
|
||||
std::ostringstream filename;
|
||||
filename << "simplify_" << caseid << "_" << distance_in_meters << ".svg";
|
||||
|
||||
std::ofstream svg(filename.str().c_str());
|
||||
|
||||
bg::svg_mapper
|
||||
<
|
||||
typename bg::point_type<MultiPolygon>::type
|
||||
> mapper(svg, 1200, 800);
|
||||
mapper.add(geometry);
|
||||
mapper.add(simplified);
|
||||
|
||||
mapper.map(geometry, "fill-opacity:0.5;fill:rgb(153,204,0);"
|
||||
"stroke:rgb(153,204,0);stroke-width:1");
|
||||
BOOST_FOREACH(polygon const& pol, simplified)
|
||||
{
|
||||
mapper.map(pol,
|
||||
bg::area(pol) > 0 ? "fill:none;stroke:rgb(255,0,0);stroke-width:1"
|
||||
: "fill:none;stroke:rgb(255,0,255);stroke-width:1");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template <bool Clockwise, typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::polygon<P, Clockwise> polygon;
|
||||
typedef bg::model::multi_polygon<polygon> mp;
|
||||
|
||||
// The unit test uses countries originally added for buffer unit test
|
||||
std::string base_folder = "buffer/data/";
|
||||
|
||||
// Verify for Greece, Italy, Netherlands, Norway and UK
|
||||
std::string gr = read_from_file<mp>(base_folder + "gr.wkt");
|
||||
std::string it = read_from_file<mp>(base_folder + "it.wkt");
|
||||
std::string nl = read_from_file<mp>(base_folder + "nl.wkt");
|
||||
std::string no = read_from_file<mp>(base_folder + "no.wkt");
|
||||
std::string uk = read_from_file<mp>(base_folder + "uk.wkt");
|
||||
|
||||
// Gradually simplify more aggresively.
|
||||
// Area ratio (first) can increase or decrease
|
||||
// Perimeter ratio (second) should decrease.
|
||||
// Polygons, interior rings, points should decrease
|
||||
test_one<mp>("gr", gr, 100, 0.999905, 0.999758, 68, 0, 2520);
|
||||
test_one<mp>("gr", gr, 200, 0.999773, 0.998865, 68, 0, 2019);
|
||||
test_one<mp>("gr", gr, 500, 0.999026, 0.995931, 68, 0, 1468);
|
||||
test_one<mp>("gr", gr, 1000, 0.997782, 0.991475, 68, 0, 1132);
|
||||
test_one<mp>("gr", gr, 2000, 0.994448, 0.9793, 65, 0, 854);
|
||||
test_one<mp>("gr", gr, 5000, 0.979743, 0.910266, 50, 0, 471);
|
||||
test_one<mp>("gr", gr, 10000, 0.968349, 0.778863, 28, 0, 245);
|
||||
test_one<mp>("gr", gr, 20000, 0.961943, 0.607009, 10, 0, 97); // Many islands disappear
|
||||
|
||||
test_one<mp>("it", it, 100, 1.00001, 0.999813, 22, 1, 1783);
|
||||
test_one<mp>("it", it, 200, 1.00009, 0.9991, 22, 1, 1406);
|
||||
test_one<mp>("it", it, 500, 1.00019, 0.996848, 22, 1, 1011);
|
||||
test_one<mp>("it", it, 1000, 1.00041, 0.99294, 22, 1, 749);
|
||||
test_one<mp>("it", it, 2000, 1.00086, 0.985144, 22, 1, 546);
|
||||
test_one<mp>("it", it, 5000, 1.00147, 0.93927, 11, 1, 283);
|
||||
test_one<mp>("it", it, 10000, 1.01089, 0.882198, 4, 1, 153);
|
||||
test_one<mp>("it", it, 20000, 1.00893, 0.828774, 4, 0, 86); // San Marino disappears
|
||||
|
||||
test_one<mp>("nl", nl, 100, 0.999896, 0.999804, 8, 0, 789);
|
||||
test_one<mp>("nl", nl, 200, 0.999733, 0.999095, 8, 0, 633);
|
||||
test_one<mp>("nl", nl, 500, 0.999423, 0.996313, 8, 0, 436);
|
||||
test_one<mp>("nl", nl, 1000, 0.997893, 0.991951, 8, 0, 331);
|
||||
test_one<mp>("nl", nl, 2000, 0.996129, 0.981998, 8, 0, 234);
|
||||
test_one<mp>("nl", nl, 5000, 0.986128, 0.896, 5, 0, 132);
|
||||
test_one<mp>("nl", nl, 10000, 0.973917, 0.832522, 4, 0, 75);
|
||||
test_one<mp>("nl", nl, 20000, 0.970675, 0.739275, 3, 0, 40);
|
||||
|
||||
test_one<mp>("no", no, 100, 0.999966, 0.999975, 95, 0, 7650);
|
||||
test_one<mp>("no", no, 200, 0.999812, 0.999731, 95, 0, 6518);
|
||||
test_one<mp>("no", no, 500, 0.99929, 0.998092, 95, 0, 4728);
|
||||
test_one<mp>("no", no, 1000, 0.998473, 0.994075, 95, 0, 3524);
|
||||
test_one<mp>("no", no, 2000, 0.996674, 0.985863, 92, 0, 2576);
|
||||
test_one<mp>("no", no, 5000, 0.99098, 0.965689, 87, 0, 1667);
|
||||
test_one<mp>("no", no, 10000, 0.978207, 0.906525, 69, 0, 1059);
|
||||
test_one<mp>("no", no, 20000, 0.955223, 0.786546, 38, 0, 593);
|
||||
|
||||
test_one<mp>("uk", uk, 100, 0.999942, 0.999878, 48, 0, 3208);
|
||||
test_one<mp>("uk", uk, 200, 0.999843, 0.999291, 48, 0, 2615);
|
||||
test_one<mp>("uk", uk, 500, 0.999522, 0.996888, 48, 0, 1885);
|
||||
test_one<mp>("uk", uk, 1000, 0.999027, 0.992306, 48, 0, 1396);
|
||||
test_one<mp>("uk", uk, 2000, 0.998074, 0.983839, 47, 0, 1032);
|
||||
test_one<mp>("uk", uk, 5000, 0.991901, 0.943496, 35, 0, 611);
|
||||
test_one<mp>("uk", uk, 10000, 0.990039, 0.871969, 23, 0, 359);
|
||||
test_one<mp>("uk", uk, 20000, 0.979171, 0.737577, 11, 0, 193);
|
||||
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_all<true, bg::model::point<double, 2, bg::cs::cartesian> >();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -44,10 +44,12 @@ void test_all()
|
||||
// Ticket 5954 https://svn.boost.org/trac/boost/ticket/5954
|
||||
test_geometry<mp>(
|
||||
"MULTIPOLYGON(((0.561648 1,1 1,1 0,0.468083 0,0.52758 0.00800554,0.599683 0.0280924,0.601611 0.265374,0.622693 0.316765,0.69507 0.357497,0.695623 0.429711,0.655111 0.502298,0.696467 0.543147,0.840712 0.593546,0.882583 0.66546,0.852357 0.748213,0.84264 0.789567,0.832667 0.841202,0.832667 0.841202,0.740538 0.873004,0.617349 0.905045,0.566576 0.977697,0.561648 1)),((0 0.801979,0.0308575 0.786234,0.0705513 0.631135,0.141616 0.527248,0.233985 0.505872,0.264777 0.526263,0.336631 0.505009,0.356603 0.422321,0.355803 0.350038,0.375252 0.205364,0.415206 0.0709182,0.45479 0,0 0,0 0,0 0.801979)))",
|
||||
"MULTIPOLYGON(((0.561648 1,1 1,1 0,0.468083 0,0.52758 0.00800554,0.599683 0.0280924,0.601611 0.265374,0.622693 0.316765,0.69507 0.357497,0.695623 0.429711,0.655111 0.502298,0.696467 0.543147,0.840712 0.593546,0.882583 0.66546,0.852357 0.748213,0.84264 0.789567,0.832667 0.841202,0.740538 0.873004,0.617349 0.905045,0.566576 0.977697,0.561648 1)),((0 0.801979,0.0308575 0.786234,0.0705513 0.631135,0.141616 0.527248,0.233985 0.505872,0.264777 0.526263,0.336631 0.505009,0.356603 0.422321,0.355803 0.350038,0.375252 0.205364,0.415206 0.0709182,0.45479 0,0 0,0 0.801979)))", 1.0 / 2048.0);
|
||||
0.51961289352, 1.0 / 2048.0);
|
||||
|
||||
// Same polygon but multiplied with 2047.0
|
||||
test_geometry<mp>(
|
||||
"MULTIPOLYGON(((1149.69 2047,2047 2047,2047 0,958.166 0,1079.96 16.3873,1227.55 57.5051,1231.5 543.221,1274.65 648.418,1422.81 731.796,1423.94 879.618,1341.01 1028.2,1425.67 1111.82,1720.94 1214.99,1806.65 1362.2,1744.77 1531.59,1724.88 1616.24,1704.47 1721.94,1704.47 1721.94,1515.88 1787.04,1263.71 1852.63,1159.78 2001.35,1149.69 2047)),((0 1641.65,63.1653 1609.42,144.419 1291.93,289.888 1079.28,478.967 1035.52,541.999 1077.26,689.084 1033.75,729.966 864.491,728.329 716.528,768.141 420.38,849.927 145.17,930.955 0,0 0,0 0,0 1641.65)))",
|
||||
"MULTIPOLYGON(((1149.69 2047,2047 2047,2047 0,958.166 0,1079.96 16.3873,1227.55 57.5051,1231.5 543.221,1274.65 648.418,1422.81 731.796,1423.94 879.618,1341.01 1028.2,1425.67 1111.82,1720.94 1214.99,1806.65 1362.2,1744.77 1531.59,1724.88 1616.24,1704.47 1721.94,1515.88 1787.04,1263.71 1852.63,1159.78 2001.35,1149.69 2047)),((0 1641.65,63.1653 1609.42,144.419 1291.93,289.888 1079.28,478.967 1035.52,541.999 1077.26,689.084 1033.75,729.966 864.491,728.329 716.528,768.141 420.38,849.927 145.17,930.955 0,0 0,0 1641.65)))", 1.0);
|
||||
0.51961289352 * (2047.0 * 2047.0), 1.0);
|
||||
// End ticket 5954
|
||||
}
|
||||
|
||||
|
||||
@@ -14,25 +14,70 @@
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <geometry_test_common.hpp>
|
||||
#include <boost/geometry/algorithms/correct_closure.hpp>
|
||||
#include <boost/geometry/algorithms/equals.hpp>
|
||||
#include <boost/geometry/algorithms/simplify.hpp>
|
||||
#include <boost/geometry/algorithms/distance.hpp>
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
#include <boost/variant/variant.hpp>
|
||||
|
||||
template <typename Tag, typename Geometry>
|
||||
|
||||
template
|
||||
<
|
||||
typename GeometryForTag,
|
||||
typename Tag = typename bg::tag<GeometryForTag>::type
|
||||
>
|
||||
struct test_equality
|
||||
{
|
||||
template <typename Geometry, typename Expected>
|
||||
static void apply(Geometry const& geometry, Expected const& expected)
|
||||
{
|
||||
// Verify both spatially equal AND number of points, because several
|
||||
// of the tests only check explicitly on collinear points being
|
||||
// simplified away
|
||||
bool const result
|
||||
= bg::equals(geometry, expected)
|
||||
&& bg::num_points(geometry) == bg::num_points(expected);
|
||||
|
||||
BOOST_CHECK_MESSAGE(result,
|
||||
" result: " << bg::wkt(geometry) << " " << bg::area(geometry)
|
||||
<< " expected: " << bg::wkt(expected) << " " << bg::area(expected));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Linestring does NOT yet have "geometry::equals" implemented
|
||||
// Until then, WKT's are compared (which is acceptable for linestrings, but not
|
||||
// for polygons, because simplify might rotate them)
|
||||
template <typename GeometryForTag>
|
||||
struct test_equality<GeometryForTag, bg::linestring_tag>
|
||||
{
|
||||
template <typename Geometry, typename Expected>
|
||||
static void apply(Geometry const& geometry, Expected const& expected)
|
||||
{
|
||||
std::ostringstream out1, out2;
|
||||
out1 << bg::wkt(geometry);
|
||||
out2 << bg::wkt(expected);
|
||||
BOOST_CHECK_EQUAL(out1.str(), out2.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Tag>
|
||||
struct test_inserter
|
||||
{
|
||||
static void apply(Geometry& , std::string const& , double )
|
||||
template <typename Geometry, typename Expected>
|
||||
static void apply(Geometry& , Expected const& , double )
|
||||
{}
|
||||
};
|
||||
|
||||
template <typename Geometry>
|
||||
struct test_inserter<bg::linestring_tag, Geometry>
|
||||
template <>
|
||||
struct test_inserter<bg::linestring_tag>
|
||||
{
|
||||
template <typename DistanceMeasure>
|
||||
template <typename Geometry, typename Expected, typename DistanceMeasure>
|
||||
static void apply(Geometry& geometry,
|
||||
std::string const& expected,
|
||||
Expected const& expected,
|
||||
DistanceMeasure const& distance)
|
||||
{
|
||||
{
|
||||
@@ -40,11 +85,7 @@ struct test_inserter<bg::linestring_tag, Geometry>
|
||||
bg::detail::simplify::simplify_insert(geometry,
|
||||
std::back_inserter(simplified), distance);
|
||||
|
||||
std::ostringstream out;
|
||||
// TODO: instead of comparing the full string (with more or less decimal digits),
|
||||
// we should call something more robust to check the test for example geometry::equals
|
||||
out << std::setprecision(12) << bg::wkt(simplified);
|
||||
BOOST_CHECK_EQUAL(out.str(), expected);
|
||||
test_equality<Geometry>::apply(simplified, expected);
|
||||
}
|
||||
|
||||
#ifdef TEST_PULL89
|
||||
@@ -67,54 +108,56 @@ struct test_inserter<bg::linestring_tag, Geometry>
|
||||
bg::detail::simplify::simplify_insert(geometry,
|
||||
std::back_inserter(simplified), max_distance, strategy);
|
||||
|
||||
std::ostringstream out;
|
||||
// TODO: instead of comparing the full string (with more or less decimal digits),
|
||||
// we should call something more robust to check the test for example geometry::equals
|
||||
out << std::setprecision(12) << bg::wkt(simplified);
|
||||
BOOST_CHECK_EQUAL(out.str(), expected);
|
||||
test_equality<Geometry>::apply(simplified, expected);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Geometry, typename DistanceMeasure>
|
||||
template <typename Geometry, typename Expected, typename DistanceMeasure>
|
||||
void check_geometry(Geometry const& geometry,
|
||||
std::string const& expected,
|
||||
DistanceMeasure const& distance)
|
||||
Expected const& expected,
|
||||
DistanceMeasure const& distance)
|
||||
{
|
||||
Geometry simplified;
|
||||
bg::simplify(geometry, simplified, distance);
|
||||
|
||||
std::ostringstream out;
|
||||
out << std::setprecision(12) << bg::wkt(simplified);
|
||||
BOOST_CHECK_EQUAL(out.str(), expected);
|
||||
test_equality<Expected>::apply(simplified, expected);
|
||||
}
|
||||
|
||||
template <typename Geometry, typename Strategy, typename DistanceMeasure>
|
||||
template <typename Geometry, typename Expected, typename Strategy, typename DistanceMeasure>
|
||||
void check_geometry(Geometry const& geometry,
|
||||
std::string const& expected,
|
||||
Expected const& expected,
|
||||
DistanceMeasure const& distance,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
Geometry simplified;
|
||||
bg::simplify(geometry, simplified, distance, strategy);
|
||||
test_equality<Expected>::apply(simplified, expected);
|
||||
}
|
||||
|
||||
std::ostringstream out;
|
||||
out << std::setprecision(12) << bg::wkt(simplified);
|
||||
BOOST_CHECK_EQUAL(out.str(), expected);
|
||||
template <typename Geometry, typename DistanceMeasure>
|
||||
void check_geometry_with_area(Geometry const& geometry,
|
||||
double expected_area,
|
||||
DistanceMeasure const& distance)
|
||||
{
|
||||
Geometry simplified;
|
||||
bg::simplify(geometry, simplified, distance);
|
||||
BOOST_CHECK_CLOSE(bg::area(simplified), expected_area, 0.01);
|
||||
}
|
||||
|
||||
|
||||
template <typename Geometry, typename DistanceMeasure>
|
||||
void test_geometry(std::string const& wkt,
|
||||
std::string const& expected,
|
||||
std::string const& expected_wkt,
|
||||
DistanceMeasure distance)
|
||||
{
|
||||
typedef typename bg::point_type<Geometry>::type point_type;
|
||||
|
||||
Geometry geometry;
|
||||
Geometry geometry, expected;
|
||||
|
||||
bg::read_wkt(wkt, geometry);
|
||||
bg::read_wkt(expected_wkt, expected);
|
||||
|
||||
boost::variant<Geometry> v(geometry);
|
||||
|
||||
// Define default strategy for testing
|
||||
@@ -136,8 +179,7 @@ void test_geometry(std::string const& wkt,
|
||||
// Check inserter (if applicable)
|
||||
test_inserter
|
||||
<
|
||||
typename bg::tag<Geometry>::type,
|
||||
Geometry
|
||||
typename bg::tag<Geometry>::type
|
||||
>::apply(geometry, expected, distance);
|
||||
|
||||
#ifdef TEST_PULL89
|
||||
@@ -164,12 +206,17 @@ void test_geometry(std::string const& wkt,
|
||||
|
||||
template <typename Geometry, typename Strategy, typename DistanceMeasure>
|
||||
void test_geometry(std::string const& wkt,
|
||||
std::string const& expected,
|
||||
std::string const& expected_wkt,
|
||||
DistanceMeasure const& distance,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
Geometry geometry;
|
||||
Geometry geometry, expected;
|
||||
|
||||
bg::read_wkt(wkt, geometry);
|
||||
bg::read_wkt(expected_wkt, expected);
|
||||
bg::correct_closure(geometry);
|
||||
bg::correct_closure(expected);
|
||||
|
||||
boost::variant<Geometry> v(geometry);
|
||||
|
||||
BOOST_CONCEPT_ASSERT( (bg::concepts::SimplifyStrategy<Strategy,
|
||||
@@ -179,4 +226,16 @@ void test_geometry(std::string const& wkt,
|
||||
check_geometry(v, expected, distance, strategy);
|
||||
}
|
||||
|
||||
template <typename Geometry, typename DistanceMeasure>
|
||||
void test_geometry(std::string const& wkt,
|
||||
double expected_area,
|
||||
DistanceMeasure const& distance)
|
||||
{
|
||||
Geometry geometry;
|
||||
bg::read_wkt(wkt, geometry);
|
||||
bg::correct_closure(geometry);
|
||||
|
||||
check_geometry_with_area(geometry, expected_area, distance);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user