mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-26 04:42:15 +00:00
Merge branch 'develop' into bg-prepare
This commit is contained in:
@@ -390,7 +390,7 @@ public :
|
||||
typedef bg::detail::overlay::turn_info
|
||||
<
|
||||
Point,
|
||||
typename bg::segment_ratio_type<Point, RescalePolicy>::type
|
||||
typename bg::detail::segment_ratio_type<Point, RescalePolicy>::type
|
||||
> turn_info;
|
||||
|
||||
std::vector<turn_info> turns;
|
||||
|
||||
79
test/algorithms/check_validity.hpp
Normal file
79
test/algorithms/check_validity.hpp
Normal file
@@ -0,0 +1,79 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2017 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_TEST_CHECK_VALIDITY_HPP
|
||||
#define BOOST_GEOMETRY_TEST_CHECK_VALIDITY_HPP
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/is_valid.hpp>
|
||||
|
||||
template<typename Geometry, typename G1, typename G2>
|
||||
inline bool is_output_valid(Geometry const& geometry,
|
||||
std::string const& case_id,
|
||||
G1 const& g1, G2 const& g2,
|
||||
std::string& message)
|
||||
{
|
||||
bool const result = bg::is_valid(geometry, message);
|
||||
if (! result)
|
||||
{
|
||||
// Check if input was valid. If not, do not report output validity
|
||||
if (! bg::is_valid(g1) || ! bg::is_valid(g2))
|
||||
{
|
||||
std::cout << "WARNING: Input is not considered as valid; "
|
||||
<< "this can cause that output is invalid: " << case_id
|
||||
<< std::endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Geometry,
|
||||
typename Tag = typename bg::tag<Geometry>::type
|
||||
>
|
||||
struct check_validity
|
||||
{
|
||||
template <typename G1, typename G2>
|
||||
static inline
|
||||
bool apply(Geometry const& geometry,
|
||||
std::string const& case_id,
|
||||
G1 const& g1, G2 const& g2,
|
||||
std::string& message)
|
||||
{
|
||||
return is_output_valid(geometry, case_id, g1, g2, message);
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization for vector of <geometry> (e.g. rings)
|
||||
template <typename Geometry>
|
||||
struct check_validity<Geometry, void>
|
||||
{
|
||||
template <typename G1, typename G2>
|
||||
static inline
|
||||
bool apply(Geometry const& geometry,
|
||||
std::string const& case_id,
|
||||
G1 const& g1, G2 const& g2,
|
||||
std::string& message)
|
||||
{
|
||||
typedef typename boost::range_value<Geometry>::type single_type;
|
||||
BOOST_FOREACH(single_type const& element, geometry)
|
||||
{
|
||||
if (! is_output_valid(element, case_id, g1, g2, message))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_TEST_CHECK_VALIDITY_HPP
|
||||
@@ -4,8 +4,8 @@
|
||||
# Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
# Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
#
|
||||
# This file was modified by Oracle on 2015.
|
||||
# Modifications copyright (c) 2015 Oracle and/or its affiliates.
|
||||
# This file was modified by Oracle on 2015, 2019.
|
||||
# Modifications copyright (c) 2015, 2019 Oracle and/or its affiliates.
|
||||
#
|
||||
# Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
#
|
||||
@@ -15,8 +15,9 @@
|
||||
|
||||
test-suite boost-geometry-algorithms-detail
|
||||
:
|
||||
[ run as_range.cpp : : : : algorithms_as_range ]
|
||||
[ run partition.cpp : : : : algorithms_partition ]
|
||||
[ run as_range.cpp : : : : algorithms_as_range ]
|
||||
[ run calculate_point_order.cpp : : : : algorithms_calculate_point_order ]
|
||||
[ run partition.cpp : : : : algorithms_partition ]
|
||||
;
|
||||
|
||||
build-project sections ;
|
||||
|
||||
148
test/algorithms/detail/calculate_point_order.cpp
Normal file
148
test/algorithms/detail/calculate_point_order.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
// Boost.Geometry
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2019, 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/algorithms/detail/calculate_point_order.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
#include <boost/geometry/geometries/ring.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/point_order.hpp>
|
||||
#include <boost/geometry/strategies/geographic/point_order.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_order.hpp>
|
||||
|
||||
|
||||
inline const char * order_str(bg::order_selector o)
|
||||
{
|
||||
if (o == bg::clockwise)
|
||||
return "clockwise";
|
||||
else if (o == bg::counterclockwise)
|
||||
return "counterclockwise";
|
||||
else
|
||||
return "order_undetermined";
|
||||
}
|
||||
|
||||
inline const char * cs_str(bg::cartesian_tag)
|
||||
{
|
||||
return "cartesian";
|
||||
}
|
||||
|
||||
inline const char * cs_str(bg::spherical_equatorial_tag)
|
||||
{
|
||||
return "spherical_equatorial";
|
||||
}
|
||||
|
||||
inline const char * cs_str(bg::geographic_tag)
|
||||
{
|
||||
return "geographic";
|
||||
}
|
||||
|
||||
template <typename Ring>
|
||||
inline void test_one(Ring const& ring, bg::order_selector expected)
|
||||
{
|
||||
typedef typename bg::cs_tag<Ring>::type cs_tag;
|
||||
|
||||
bg::order_selector result = bg::detail::calculate_point_order(ring);
|
||||
|
||||
BOOST_CHECK_MESSAGE(result == expected, "Expected: " << order_str(expected) << " for " << bg::wkt(ring) << " in " << cs_str(cs_tag()));
|
||||
|
||||
if (expected != bg::order_undetermined && result != bg::order_undetermined)
|
||||
{
|
||||
Ring ring_rev = ring;
|
||||
|
||||
std::reverse(boost::begin(ring_rev), boost::end(ring_rev));
|
||||
|
||||
bg::order_selector result_rev = bg::detail::calculate_point_order(ring_rev);
|
||||
|
||||
BOOST_CHECK_MESSAGE(result != result_rev, "Invalid order of reversed: " << bg::wkt(ring) << " in " << cs_str(cs_tag()));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_one(std::string const& ring_wkt, bg::order_selector expected)
|
||||
{
|
||||
//typedef typename bg::cs_tag<P>::type cs_tag;
|
||||
|
||||
bg::model::ring<P> ring;
|
||||
bg::read_wkt(ring_wkt, ring);
|
||||
|
||||
std::size_t n = boost::size(ring);
|
||||
for (size_t i = 1; i < n; ++i)
|
||||
{
|
||||
test_one(ring, expected);
|
||||
std::rotate(boost::begin(ring), boost::begin(ring) + 1, boost::end(ring));
|
||||
|
||||
// it seems that area method doesn't work for invalid "opened" polygons
|
||||
//if (! boost::is_same<cs_tag, bg::geographic_tag>::value)
|
||||
{
|
||||
P p = bg::range::front(ring);
|
||||
bg::range::push_back(ring, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
// From correct() test, rings rotated and reversed in test_one()
|
||||
test_one<P>("POLYGON((0 0,0 1,1 1,1 0,0 0))", bg::clockwise);
|
||||
test_one<P>("POLYGON((0 0,0 1,1 1,1 0))", bg::clockwise);
|
||||
test_one<P>("POLYGON((0 0,0 4,4 4,4 0,0 0))", bg::clockwise);
|
||||
test_one<P>("POLYGON((1 1,2 1,2 2,1 2,1 1))", bg::counterclockwise);
|
||||
|
||||
test_one<P>("POLYGON((0 5, 5 5, 5 0, 0 0, 0 5))", bg::clockwise);
|
||||
test_one<P>("POLYGON((0 5, 0 5, 0 6, 0 6, 0 4, 0 5, 5 5, 5 0, 0 0, 0 6, 0 5))", bg::clockwise);
|
||||
test_one<P>("POLYGON((2 0, 2 1, 2 -1, 2 0, 1 0, 1 -1, 0 -1, 0 1, 1 1, 1 0, 2 0))", bg::clockwise);
|
||||
test_one<P>("POLYGON((2 0, 2 1, 2 -1, 2 0, 1 0, 1 -1, 0 -1, 0 1, 1 1, 1 0))", bg::clockwise);
|
||||
test_one<P>("POLYGON((2 0, 2 1, 3 1, 3 -1, 2 -1, 2 0, 1 0, 1 -1, 0 -1, 0 1, 1 1, 1 0, 2 0))", bg::clockwise);
|
||||
test_one<P>("POLYGON((0 85, 5 85, 5 84, 0 84, 0 85))", bg::clockwise);
|
||||
test_one<P>("POLYGON((0 2, 170 2, 170 0, 0 0, 0 2))", bg::clockwise);
|
||||
test_one<P>("POLYGON((0 2, 170 2, 170 1, 160 1, 10 1, 0 1, 0 2))", bg::clockwise);
|
||||
test_one<P>("POLYGON((0 2, 170 2, 170 -2, 0 -2, 0 2))", bg::clockwise);
|
||||
test_one<P>("POLYGON((5 5, 6 5, 6 6, 6 4, 6 5, 5 5, 5 4, 4 4, 4 6, 5 6, 5 5))", bg::clockwise);
|
||||
test_one<P>("POLYGON((5 5, 6 5, 6 6, 6 4, 6 5, 5 5, 5 6, 4 6, 4 4, 5 4, 5 5))", bg::counterclockwise);
|
||||
test_one<P>("POLYGON((5 5, 6 5, 6 5, 6 6, 6 5, 6 4, 6 5, 6 5, 5 5, 5 4, 4 4, 4 6, 5 6, 5 5))", bg::clockwise);
|
||||
|
||||
// https://github.com/boostorg/geometry/pull/554
|
||||
test_one<P>("POLYGON((9.8591674311151110 54.602813224425063, 9.8591651519791412 54.602359676428932, 9.8584586199249316 54.602359676428932, 9.8591674311151110 54.602813224425063))",
|
||||
bg::clockwise);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_cartesian()
|
||||
{
|
||||
test_one<P>("POLYGON((0 5, 1 5, 1 6, 1 4, 2 4, 0 4, 0 3, 0 5))", bg::clockwise);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_spheroidal()
|
||||
{
|
||||
test_one<P>("POLYGON((0 5, 1 5, 1 6, 1 4, 0 4, 0 3, 0 5))", bg::clockwise);
|
||||
|
||||
test_one<P>("POLYGON((0 45, 120 45, -120 45, 0 45))", bg::counterclockwise);
|
||||
}
|
||||
|
||||
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> > >();
|
||||
|
||||
test_cartesian<bg::model::point<double, 2, bg::cs::cartesian> >();
|
||||
|
||||
test_spheroidal<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
test_spheroidal<bg::model::point<double, 2, bg::cs::geographic<bg::degree> > >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -11,7 +11,6 @@
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#include <iostream>
|
||||
#define BOOST_GEOMETRY_TEST_DEBUG
|
||||
|
||||
#ifndef BOOST_TEST_MODULE
|
||||
#define BOOST_TEST_MODULE test_distance_spherical_equatorial_pointlike_linear
|
||||
@@ -278,6 +277,18 @@ void test_distance_point_linestring(Strategy const& strategy)
|
||||
0.06146397739758279 * r,
|
||||
0.000944156107132969,
|
||||
strategy);
|
||||
|
||||
//https://github.com/boostorg/geometry/issues/557
|
||||
tester::apply("p-l-issue557",
|
||||
"POINT(51.99999790563572 43.71656981636763)",
|
||||
"LINESTRING(52.0000243071011 43.716569742012496,\
|
||||
52.0000121532845 43.71656942616241,\
|
||||
52.0 43.7165690998572,\
|
||||
51.999987847203 43.7165687638793)",
|
||||
1.35062e-08 * r,
|
||||
4.5604e-17,
|
||||
strategy);
|
||||
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -42,6 +42,18 @@ void test_all()
|
||||
, std::sqrt(2.0)
|
||||
, "LINESTRING(10 1,2 2)"
|
||||
);
|
||||
test_geometry<bg::model::linestring<P> >
|
||||
(
|
||||
"LINESTRING EMPTY"
|
||||
|
||||
, 0
|
||||
, "LINESTRING()"
|
||||
, "LINESTRING()"
|
||||
|
||||
, ""
|
||||
, 0
|
||||
, "LINESTRING()"
|
||||
);
|
||||
test_geometry<bg::model::ring<P> >
|
||||
(
|
||||
"POLYGON((1 1,1 4,4 4,4 1,1 1))"
|
||||
@@ -54,6 +66,18 @@ void test_all()
|
||||
, 4 * 3.0
|
||||
, "POLYGON((10 1,10 4,4 4,4 1,1 1))"
|
||||
);
|
||||
test_geometry<bg::model::ring<P> >
|
||||
(
|
||||
"POLYGON EMPTY"
|
||||
|
||||
, 0
|
||||
, "POLYGON(())"
|
||||
, "POLYGON(())"
|
||||
|
||||
, ""
|
||||
, 0
|
||||
, "POLYGON(())"
|
||||
);
|
||||
test_geometry<bg::model::ring<P, true, false> > // open ring
|
||||
(
|
||||
"POLYGON((1 1,1 4,4 4,4 1))"
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include "test_is_valid.hpp"
|
||||
#include "overlay/overlay_cases.hpp"
|
||||
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
|
||||
@@ -784,6 +785,7 @@ inline void test_open_polygons()
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
template <typename Point>
|
||||
inline void test_doc_example_polygon()
|
||||
{
|
||||
@@ -794,13 +796,16 @@ inline void test_doc_example_polygon()
|
||||
std::cout << "************************************" << std::endl;
|
||||
#endif
|
||||
|
||||
typedef bg::model::polygon<Point> CCW_CG;
|
||||
typedef bg::model::polygon<Point> ClockwiseClosedPolygon;
|
||||
typedef validity_tester_areal<true> tester;
|
||||
typedef test_valid<tester, CCW_CG> test;
|
||||
typedef test_valid<tester, ClockwiseClosedPolygon> test;
|
||||
|
||||
test::apply("pg-doc",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 2,0 0),(0 0,2 9,1 9,0 0),(2 9,9 2,9 9,2 9))",
|
||||
false);
|
||||
|
||||
// Containing a self touching point, which should be valid
|
||||
test::apply("ggl_list_20190307_matthieu_2", ggl_list_20190307_matthieu_2[1], true);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_is_valid_polygon )
|
||||
|
||||
@@ -84,7 +84,7 @@ void test_with_point(std::string const& caseid,
|
||||
typedef bg::detail::overlay::turn_info
|
||||
<
|
||||
P,
|
||||
typename bg::segment_ratio_type<P, rescale_policy_type>::type
|
||||
typename bg::detail::segment_ratio_type<P, rescale_policy_type>::type
|
||||
> turn_info;
|
||||
typedef std::vector<turn_info> tp_vector;
|
||||
turn_info model;
|
||||
|
||||
@@ -80,7 +80,7 @@ struct test_get_turns
|
||||
typedef bg::detail::overlay::turn_info
|
||||
<
|
||||
point_type,
|
||||
typename bg::segment_ratio_type<point_type, rescale_policy_type>::type
|
||||
typename bg::detail::segment_ratio_type<point_type, rescale_policy_type>::type
|
||||
> turn_info;
|
||||
std::vector<turn_info> turns;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#endif
|
||||
|
||||
#include <geometry_test_common.hpp>
|
||||
|
||||
#include <algorithms/check_validity.hpp>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
|
||||
@@ -433,6 +433,12 @@ void test_overlay(std::string const& caseid,
|
||||
overlay::apply(g1, g2, robust_policy, std::back_inserter(result),
|
||||
strategy, visitor);
|
||||
|
||||
std::string message;
|
||||
bool const valid = check_validity<Geometry>::apply(result, caseid, g1, g2, message);
|
||||
BOOST_CHECK_MESSAGE(valid,
|
||||
"overlay: " << caseid << " not valid: " << message
|
||||
<< " type: " << (type_for_assert_message<Geometry, Geometry>()));
|
||||
|
||||
BOOST_CHECK_CLOSE(bg::area(result), expected_area, 0.001);
|
||||
BOOST_CHECK_MESSAGE((bg::num_interior_rings(result) == expected_hole_count),
|
||||
caseid
|
||||
|
||||
@@ -838,6 +838,30 @@ static std::string case_precision_22[2] =
|
||||
"POLYGON((-1 -1,-1 8,8 8,8 -1,-1 -1),(2 7,2 3,4.00000000200000017 2.99999999000000006,4 7,2 7))"
|
||||
};
|
||||
|
||||
static std::string case_precision_23[2] =
|
||||
{
|
||||
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
|
||||
"POLYGON((-1 -1,-1 8,8 8,8 -1,-1 -1),(2 7,2 3,3.99998999999999993 2.99998999999999993,4 7,2 7))"
|
||||
};
|
||||
|
||||
static std::string case_precision_24[2] =
|
||||
{
|
||||
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
|
||||
"POLYGON((2 7,4 7,4 3.000001,2 3,2 7))"
|
||||
};
|
||||
|
||||
static std::string case_precision_25[2] =
|
||||
{
|
||||
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
|
||||
"POLYGON((2 7,4 7,4 3.00001,2 3,2 7))"
|
||||
};
|
||||
|
||||
static std::string case_precision_26[2] =
|
||||
{
|
||||
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
|
||||
"POLYGON((-1 -1,-1 8,8 8,8 -1,-1 -1),(2 7,2 3,3.999991 2.999991,4 7,2 7))"
|
||||
};
|
||||
|
||||
|
||||
// ticket_17 is keyholed, so has a hole formed by an deliberate intersection
|
||||
// This will fail the intersection/traversal process
|
||||
|
||||
@@ -60,22 +60,12 @@ static void test_self_intersection_points(std::string const& case_id,
|
||||
typename bg::cs_tag<Geometry>::type
|
||||
>::type strategy_type;
|
||||
typedef bg::detail::no_rescale_policy rescale_policy_type;
|
||||
typedef bg::detail::overlay::turn_info
|
||||
<
|
||||
point_type,
|
||||
typename bg::segment_ratio_type
|
||||
<
|
||||
point_type, rescale_policy_type
|
||||
>::type
|
||||
> turn_info;
|
||||
typedef bg::detail::overlay::turn_info<point_type> turn_info;
|
||||
|
||||
std::vector<turn_info> turns;
|
||||
|
||||
strategy_type strategy;
|
||||
rescale_policy_type rescale_policy
|
||||
;
|
||||
// = bg::get_rescale_policy<rescale_policy_type>(geometry);
|
||||
///bg::get_intersection_points(geometry, turns);
|
||||
rescale_policy_type rescale_policy;
|
||||
|
||||
bg::detail::self_get_turn_points::no_interrupt_policy policy;
|
||||
bg::self_turns
|
||||
|
||||
@@ -137,7 +137,7 @@ std::vector<std::size_t> apply_overlay(
|
||||
typedef bg::detail::overlay::traversal_turn_info
|
||||
<
|
||||
point_type,
|
||||
typename bg::segment_ratio_type<point_type, RobustPolicy>::type
|
||||
typename bg::detail::segment_ratio_type<point_type, RobustPolicy>::type
|
||||
> turn_info;
|
||||
typedef std::deque<turn_info> turn_container_type;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ std::vector<std::size_t> apply_get_turns(std::string const& case_id,
|
||||
typedef bg::detail::overlay::turn_info
|
||||
<
|
||||
point_type,
|
||||
typename bg::segment_ratio_type<point_type, RobustPolicy>::type
|
||||
typename bg::detail::segment_ratio_type<point_type, RobustPolicy>::type
|
||||
> turn_info;
|
||||
typedef std::deque<turn_info> turn_container_type;
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ void check_geometry_range(Geometry1 const& g1,
|
||||
typedef bg::detail::no_rescale_policy robust_policy_type;
|
||||
typedef typename bg::point_type<Geometry2>::type point_type;
|
||||
|
||||
typedef typename bg::segment_ratio_type
|
||||
typedef typename bg::detail::segment_ratio_type
|
||||
<
|
||||
point_type, robust_policy_type
|
||||
>::type segment_ratio_type;
|
||||
|
||||
@@ -164,7 +164,7 @@ struct test_traverse
|
||||
typedef bg::detail::overlay::traversal_turn_info
|
||||
<
|
||||
point_type,
|
||||
typename bg::segment_ratio_type<point_type, rescale_policy_type>::type
|
||||
typename bg::detail::segment_ratio_type<point_type, rescale_policy_type>::type
|
||||
> turn_info;
|
||||
std::vector<turn_info> turns;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ intersect(Geometry1 const& g1, Geometry2 const& g2, std::string const& name,
|
||||
typedef bg::detail::overlay::traversal_turn_info
|
||||
<
|
||||
point_type,
|
||||
typename bg::segment_ratio_type<point_type, rescale_policy_type>::type
|
||||
typename bg::detail::segment_ratio_type<point_type, rescale_policy_type>::type
|
||||
> turn_info;
|
||||
std::vector<turn_info> turns;
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2017 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_TEST_SETOP_CHECK_VALIDITY_HPP
|
||||
#define BOOST_GEOMETRY_TEST_SETOP_CHECK_VALIDITY_HPP
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/is_valid.hpp>
|
||||
|
||||
template
|
||||
<
|
||||
typename Geometry,
|
||||
typename Tag = typename bg::tag<Geometry>::type
|
||||
>
|
||||
struct check_validity
|
||||
{
|
||||
static inline
|
||||
bool apply(Geometry const& geometry, std::string& message)
|
||||
{
|
||||
return bg::is_valid(geometry, message);
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization for vector of <geometry> (e.g. rings)
|
||||
template <typename Geometry>
|
||||
struct check_validity<Geometry, void>
|
||||
{
|
||||
static inline
|
||||
bool apply(Geometry const& geometry, std::string& message)
|
||||
{
|
||||
typedef typename boost::range_value<Geometry>::type single_type;
|
||||
BOOST_FOREACH(single_type const& element, geometry)
|
||||
{
|
||||
if (! bg::is_valid(element, message))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_TEST_SETOP_CHECK_VALIDITY_HPP
|
||||
@@ -49,9 +49,7 @@
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::box<P> box;
|
||||
typedef bg::model::polygon<P> polygon;
|
||||
typedef bg::model::ring<P> ring;
|
||||
|
||||
typedef typename bg::coordinate_type<P>::type ct;
|
||||
|
||||
@@ -246,6 +244,45 @@ void test_all()
|
||||
TEST_DIFFERENCE(case_106, 1, 17.5, 2, 32.5, 3);
|
||||
TEST_DIFFERENCE(case_107, 2, 18.0, 2, 29.0, 4);
|
||||
|
||||
TEST_DIFFERENCE(case_precision_1, 1, 14.0, 1, BG_IF_RESCALED(8.00001, 8.0), 1);
|
||||
TEST_DIFFERENCE(case_precision_2, 1, 14.0, 1, 8.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_3, 1, 14.0, 1, 8.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_4, 1, 14.0, 1, 8.0, 1);
|
||||
#if ! defined(BOOST_GEOMETRY_USE_KRAMER_RULE)
|
||||
TEST_DIFFERENCE(case_precision_5, 1, 14.0, 1, 8.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_6, 0, 0.0, 1, 57.0, 1);
|
||||
#endif
|
||||
TEST_DIFFERENCE(case_precision_7, 1, 14.0, 1, 8.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_8, 0, 0.0, 1, 59.0, 1);
|
||||
#if ! defined(BOOST_GEOMETRY_USE_KRAMER_RULE)
|
||||
TEST_DIFFERENCE(case_precision_9, 0, 0.0, 1, 59.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_10, 0, 0.0, 1, 59.0, 1);
|
||||
#endif
|
||||
TEST_DIFFERENCE(case_precision_11, 0, 0.0, 1, 59.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_12, 1, 12.0, 0, 0.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_13, 1, BG_IF_RESCALED(12.00002, 12.0), 0, 0.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_14, 1, 14.0, 1, 8.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_15, 0, 0.0, 1, 59.0, 1);
|
||||
#if ! defined(BOOST_GEOMETRY_USE_KRAMER_RULE)
|
||||
TEST_DIFFERENCE(case_precision_16, 0, 0.0, 1, 59.0, 1);
|
||||
#endif
|
||||
TEST_DIFFERENCE(case_precision_17, 0, 0.0, 1, 59.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_18, 0, 0.0, 1, 59.0, 1);
|
||||
#if ! defined(BOOST_GEOMETRY_USE_KRAMER_RULE)
|
||||
TEST_DIFFERENCE(case_precision_19, 0, 0.0, 1, 59.0, 1);
|
||||
#endif
|
||||
TEST_DIFFERENCE(case_precision_20, 1, 14.0, 1, 8.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_21, 1, 14.0, 1, 7.99999, 1);
|
||||
TEST_DIFFERENCE(case_precision_22, 0, 0.0, 1, 59.0, 1);
|
||||
#if ! defined(BOOST_GEOMETRY_USE_KRAMER_RULE)
|
||||
TEST_DIFFERENCE(case_precision_23, 0, 0.0, 1, 59.0, 1);
|
||||
#endif
|
||||
TEST_DIFFERENCE(case_precision_24, 1, 14.0, 1, 8.0, 1);
|
||||
TEST_DIFFERENCE(case_precision_25, 1, 14.0, 1, 7.99999, 1);
|
||||
#if ! defined(BOOST_GEOMETRY_USE_KRAMER_RULE)
|
||||
TEST_DIFFERENCE(case_precision_26, 0, 0.0, 1, 59.0, 1);
|
||||
#endif
|
||||
|
||||
test_one<polygon, polygon, polygon>("winded",
|
||||
winded[0], winded[1],
|
||||
3, 37, 61,
|
||||
@@ -308,19 +345,19 @@ void test_all()
|
||||
settings);
|
||||
}
|
||||
|
||||
#if defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
test_one<polygon, polygon, polygon>("geos_1",
|
||||
geos_1[0], geos_1[1],
|
||||
21, -1, 0.31640625,
|
||||
9, -1, 0.01953125);
|
||||
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.percentage = 0.01;
|
||||
settings.test_validity = false;
|
||||
|
||||
// Excluded this test in the normal suite, it is OK like this for many clang/gcc/msvc
|
||||
// versions, but NOT OK for many other clang/gcc/msvc versions on other platforms
|
||||
// It might depend on partition (order)
|
||||
// 10, -1, 0.02148439); // change in partition might give these results
|
||||
|
||||
// SQL Server gives: 0.28937764436705 and 0.000786406897532288 with 44/35 rings
|
||||
// PostGIS gives: 0.30859375 and 0.033203125 with 35/35 rings
|
||||
// SQL Server gives: 0.28937764436705 and 0.000786406897532288 with 44/35 rings
|
||||
// PostGIS gives: 0.30859375 and 0.033203125 with 35/35 rings
|
||||
TEST_DIFFERENCE_WITH(geos_1,
|
||||
-1, BG_IF_KRAMER(0.29171, 0.189697476),
|
||||
-1, BG_IF_KRAMER(0.00076855, 0.000018266),
|
||||
-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
@@ -367,25 +404,25 @@ void test_all()
|
||||
|
||||
if ( BOOST_GEOMETRY_CONDITION((! boost::is_same<ct, float>::value)) )
|
||||
{
|
||||
test_one<polygon, polygon, polygon>("ggl_list_20110716_enrico",
|
||||
ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1],
|
||||
3, -1, 35723.8506317139,
|
||||
1, -1, 58456.4964294434,
|
||||
1, -1, 35723.8506317139 + 58456.4964294434);
|
||||
TEST_DIFFERENCE(ggl_list_20110716_enrico,
|
||||
3, 35723.8506317139, // TODO FOR GENERIC, misses one of three outputs
|
||||
1, 58456.4964294434,
|
||||
1);
|
||||
}
|
||||
|
||||
#if defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
#if defined(BOOST_GEOMETRY_USE_RESCALING) \
|
||||
|| ! defined(BOOST_GEOMETRY_USE_KRAMER_RULE) \
|
||||
|| defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
{
|
||||
// symmetric difference is not valid due to robustness issue, it has
|
||||
// two turns (touch_only) and a midpoint is located in other polygon
|
||||
ut_settings ignore_validity;
|
||||
ignore_validity.test_validity = false;
|
||||
// Symmetric difference should output one polygon
|
||||
// Using rescaling, it currently outputs two.
|
||||
ut_settings settings;
|
||||
settings.test_validity = false;
|
||||
|
||||
test_one<polygon, polygon, polygon>("ggl_list_20110820_christophe",
|
||||
ggl_list_20110820_christophe[0], ggl_list_20110820_christophe[1],
|
||||
1, -1, 2.8570121719168924,
|
||||
1, -1, 64.498061986388564,
|
||||
ignore_validity);
|
||||
TEST_DIFFERENCE_WITH(ggl_list_20110820_christophe,
|
||||
1, 2.8570121719168924,
|
||||
1, 64.498061986388564,
|
||||
BG_IF_RESCALED(2, 1));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -415,7 +452,10 @@ void test_all()
|
||||
// With rescaling, difference of output a-b and a sym b is invalid
|
||||
ut_settings settings;
|
||||
settings.test_validity = BG_IF_RESCALED(false, true);
|
||||
TEST_DIFFERENCE_WITH(ggl_list_20190307_matthieu_1, 2, 0.18461532, 2, 0.617978, 4);
|
||||
TEST_DIFFERENCE_WITH(ggl_list_20190307_matthieu_1,
|
||||
BG_IF_KRAMER(2, 1), 0.18461532,
|
||||
BG_IF_KRAMER(2, 1), 0.617978,
|
||||
BG_IF_KRAMER(4, 2));
|
||||
TEST_DIFFERENCE_WITH(ggl_list_20190307_matthieu_2, 2, 12.357152, 0, 0.0, 2);
|
||||
}
|
||||
|
||||
@@ -443,12 +483,19 @@ void test_all()
|
||||
2, 12, 0.0451236449624935,
|
||||
0, 0, 0);
|
||||
|
||||
#if defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
test_one<polygon, polygon, polygon>("ticket_9563",
|
||||
ticket_9563[0], ticket_9563[1],
|
||||
0, -1, 0,
|
||||
6, -1, 20.096189);
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.test_validity = BG_IF_RESCALED(true, false);
|
||||
#if !defined(BOOST_GEOMETRY_USE_RESCALING) && defined(BOOST_GEOMETRY_USE_KRAMER_RULE)
|
||||
const int expected_count = 1; // Wrong, considers all consecutive polygons as one
|
||||
#else
|
||||
const int expected_count = 6;
|
||||
#endif
|
||||
TEST_DIFFERENCE_WITH(ticket_9563,
|
||||
0, 0,
|
||||
expected_count, 20.096189,
|
||||
expected_count);
|
||||
}
|
||||
|
||||
test_one<polygon, polygon, polygon>("ticket_10108_a",
|
||||
ticket_10108_a[0], ticket_10108_a[1],
|
||||
@@ -475,7 +522,11 @@ void test_all()
|
||||
2, 23, 62.25,
|
||||
0, 0, 0.0);
|
||||
|
||||
// Other combi's
|
||||
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
|
||||
typedef bg::model::box<P> box;
|
||||
typedef bg::model::ring<P> ring;
|
||||
|
||||
// Other combinations
|
||||
{
|
||||
test_one<polygon, polygon, ring>(
|
||||
"star_ring_ring", example_star, example_ring,
|
||||
@@ -534,32 +585,32 @@ void test_all()
|
||||
3, -1, 8.53333333333, 2, -1, 0.53333333333);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
// Rescaling generates a very small false polygon
|
||||
TEST_DIFFERENCE(issue_566_a, 1, 143.662, BG_IF_RESCALED(1, 0),
|
||||
BG_IF_RESCALED(1.605078e-6, 0.0),
|
||||
BG_IF_RESCALED(2, 1));
|
||||
{
|
||||
ut_settings settings;
|
||||
#if defined(BOOST_GEOMETRY_USE_KRAMER_RULE)
|
||||
settings.test_validity = BG_IF_RESCALED(true, false);
|
||||
#endif
|
||||
TEST_DIFFERENCE_WITH(issue_566_a, 1, 143.662, BG_IF_RESCALED(1, 0),
|
||||
BG_IF_RESCALED(1.605078e-6, 0.0),
|
||||
BG_IF_RESCALED(2, 1));
|
||||
}
|
||||
TEST_DIFFERENCE(issue_566_b, 1, 143.662, BG_IF_RESCALED(1, 0),
|
||||
BG_IF_RESCALED(1.605078e-6, 0.0),
|
||||
BG_IF_RESCALED(2, 1));
|
||||
|
||||
/***
|
||||
Experimental (cut), does not work:
|
||||
test_one<polygon, polygon, polygon>(
|
||||
"polygon_pseudo_line",
|
||||
"POLYGON((0 0,0 4,4 4,4 0,0 0))",
|
||||
"POLYGON((2 -2,2 -1,2 6,2 -2))",
|
||||
5, 22, 1.1901714,
|
||||
5, 27, 1.6701714);
|
||||
***/
|
||||
|
||||
TEST_DIFFERENCE(mysql_21977775, 2, 160.856568913, 2, 92.3565689126, 4);
|
||||
TEST_DIFFERENCE(mysql_21965285, 1, 92.0, 1, 14.0, 1);
|
||||
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);
|
||||
TEST_DIFFERENCE(mysql_23023665_5, 2, 165.23735, 2, 105.73735, 4);
|
||||
#if defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
#if defined(BOOST_GEOMETRY_USE_RESCALING) \
|
||||
|| ! defined(BOOST_GEOMETRY_USE_KRAMER_RULE) \
|
||||
|| defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
// Testcases going wrong with Kramer's rule and no rescaling
|
||||
TEST_DIFFERENCE(mysql_23023665_6, 2, 105.68756, 3, 10.18756, 5);
|
||||
TEST_DIFFERENCE(mysql_23023665_13, 3, 99.74526, 3, 37.74526, 6);
|
||||
#endif
|
||||
@@ -592,7 +643,6 @@ void test_specific()
|
||||
TEST_DIFFERENCE(ticket_11676, 2, 2537992.5, 2, 294963.5, 3);
|
||||
}
|
||||
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_all<bg::model::d2::point_xy<double> >();
|
||||
|
||||
@@ -157,23 +157,25 @@ void test_areal()
|
||||
// output is discarded because of zero (rescaled) area
|
||||
// POSTGIS areas: 3.75893745345145, 2.5810000723917e-15
|
||||
ut_settings settings;
|
||||
settings.sym_difference = false; // Validity problem in sym difference
|
||||
#if defined(BOOST_GEOMETRY_USE_RESCALING)
|
||||
settings.test_validity = false; // Invalid output in A
|
||||
TEST_DIFFERENCE_WITH(0, 1, bug_21155501, 1, 3.758937, 0, 0.0, 2);
|
||||
settings.sym_difference = BG_IF_RESCALED(false, true);
|
||||
settings.test_validity = BG_IF_RESCALED(false, true);
|
||||
#if defined(BOOST_GEOMETRY_USE_RESCALING) || ! defined(BOOST_GEOMETRY_USE_KRAMER_RULE)
|
||||
// No output for B
|
||||
TEST_DIFFERENCE_WITH(0, 1, bug_21155501, 1, 3.758937, 0, 0.0, 1);
|
||||
#else
|
||||
// Very small sliver for B
|
||||
TEST_DIFFERENCE_WITH(0, 1, bug_21155501, 1, 3.758937, 1, 1.7763568394002505e-15, 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
{
|
||||
// Without rescaling, this one misses one of the output polygons
|
||||
// With rescaling, it is complete but invalid
|
||||
ut_settings settings;
|
||||
settings.percentage = 0.001;
|
||||
settings.test_validity = false;
|
||||
TEST_DIFFERENCE_WITH(0, 1, ticket_9081, 2, 0.0907392476356186, 4, 0.126018011439877, 4);
|
||||
settings.test_validity = BG_IF_RESCALED(false, true);
|
||||
TEST_DIFFERENCE_WITH(0, 1, ticket_9081, 2, 0.0907392476356186,
|
||||
4, 0.126018011439877, BG_IF_RESCALED(4, 3));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -317,7 +319,7 @@ void test_areal()
|
||||
TEST_DIFFERENCE(case_recursive_boxes_60, 6, 5.25, 7, 5.25, 11);
|
||||
TEST_DIFFERENCE(case_recursive_boxes_61, 2, 1.5, 6, 2.0, 7);
|
||||
#if defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
// Misses one triangle
|
||||
// Misses one triangle. It is NOT related to rescaling.
|
||||
TEST_DIFFERENCE(case_recursive_boxes_62, 5, 5.0, 11, 5.75, 12);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <iomanip>
|
||||
|
||||
#include <geometry_test_common.hpp>
|
||||
#include <algorithms/check_validity.hpp>
|
||||
#include "../setop_output_type.hpp"
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
@@ -194,8 +195,9 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
|
||||
#endif
|
||||
{
|
||||
// std::cout << bg::dsv(result) << std::endl;
|
||||
typedef bg::model::multi_polygon<OutputType> result_type;
|
||||
std::string message;
|
||||
bool const valid = bg::is_valid(result, message);
|
||||
bool const valid = check_validity<result_type>::apply(result, caseid, g1, g2, message);
|
||||
BOOST_CHECK_MESSAGE(valid,
|
||||
"difference: " << caseid << " not valid " << message
|
||||
<< " type: " << (type_for_assert_message<G1, G2>()));
|
||||
|
||||
@@ -188,10 +188,13 @@ void test_areal()
|
||||
settings);
|
||||
}
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("geos_1",
|
||||
geos_1[0], geos_1[1],
|
||||
1, -1, 3461.12321694, // MSVC 14 reports 3461.025390625
|
||||
ut_settings(0.01, false));
|
||||
if (! BOOST_GEOMETRY_CONDITION((boost::is_same<ct, float>::value)) )
|
||||
{
|
||||
test_one<Polygon, Polygon, Polygon>("geos_1",
|
||||
geos_1[0], geos_1[1],
|
||||
1, -1, 3461.12321694, // MSVC 14 reports 3461.025390625
|
||||
ut_settings(0.01, false));
|
||||
}
|
||||
|
||||
// Expectations:
|
||||
// In most cases: 0 (no intersection)
|
||||
@@ -205,7 +208,7 @@ void test_areal()
|
||||
0, 0, 0.0);
|
||||
test_one<Polygon, Polygon, Polygon>("geos_4",
|
||||
geos_4[0], geos_4[1],
|
||||
1, -1, 0.08368849);
|
||||
1, -1, 0.08368849, ut_settings(0.01));
|
||||
|
||||
|
||||
if ( BOOST_GEOMETRY_CONDITION(! ccw && open) )
|
||||
@@ -253,15 +256,17 @@ void test_areal()
|
||||
TEST_INTERSECTION(ggl_list_20190307_matthieu_1, 2, -1, 0.035136);
|
||||
TEST_INTERSECTION(ggl_list_20190307_matthieu_2, 1, -1, 3.64285);
|
||||
|
||||
#if defined(BOOST_GEOMETRY_USE_RESCALING) || !defined(BOOST_GEOMETRY_USE_KRAMER_RULE)
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_f", buffer_rt_f[0], buffer_rt_f[1],
|
||||
1, 4, 0.00029437899183903937, ut_settings(0.01));
|
||||
#endif
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_rt_g", buffer_rt_g[0], buffer_rt_g[1],
|
||||
1, 0, 2.914213562373);
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("ticket_8254", ticket_8254[0], ticket_8254[1],
|
||||
1, 4, 3.635930e-08, ut_settings(0.01));
|
||||
if_typed<ct, float>(0, 1), -1, if_typed<ct, float>(0.0, 3.635930e-08), ut_settings(0.01));
|
||||
test_one<Polygon, Polygon, Polygon>("ticket_6958", ticket_6958[0], ticket_6958[1],
|
||||
1, 4, 4.34355e-05, ut_settings(0.01));
|
||||
if_typed<ct, float>(0, 1), -1, if_typed<ct, float>(0.0, 4.34355e-05), ut_settings(0.01));
|
||||
test_one<Polygon, Polygon, Polygon>("ticket_8652", ticket_8652[0], ticket_8652[1],
|
||||
1, 4, 0.0003);
|
||||
|
||||
@@ -306,7 +311,7 @@ void test_areal()
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("ticket_11576",
|
||||
ticket_11576[0], ticket_11576[1],
|
||||
1, 0, 5.585617332907136e-07);
|
||||
if_typed<ct, float>(0, 1), -1, if_typed<ct, float>(0.0, 5.585617332907136e-07));
|
||||
|
||||
{
|
||||
// Not yet valid when rescaling is turned off
|
||||
@@ -370,15 +375,8 @@ void test_areal()
|
||||
TEST_INTERSECTION(case_precision_9, 1, -1, 14.0);
|
||||
TEST_INTERSECTION(case_precision_10, 1, -1, 14.0);
|
||||
TEST_INTERSECTION(case_precision_11, 1, -1, 14.0);
|
||||
|
||||
{
|
||||
ut_settings settings(0.01);
|
||||
TEST_INTERSECTION_WITH(case_precision_12, 0, 1, 1, -1, 2.0, settings);
|
||||
TEST_INTERSECTION_WITH(case_precision_13, 0, 1, 1, -1, 2.0, settings);
|
||||
TEST_INTERSECTION_WITH(case_precision_12, 1, 0, 1, -1, 2.0, settings);
|
||||
TEST_INTERSECTION_WITH(case_precision_13, 1, 0, 1, -1, 2.0, settings);
|
||||
}
|
||||
|
||||
TEST_INTERSECTION(case_precision_12, 1, -1, 2.0);
|
||||
TEST_INTERSECTION(case_precision_13, 1, -1, 1.99998);
|
||||
TEST_INTERSECTION(case_precision_14, 0, -1, 0.0);
|
||||
TEST_INTERSECTION(case_precision_15, 1, -1, 14.0);
|
||||
TEST_INTERSECTION(case_precision_16, 1, -1, 14.0);
|
||||
@@ -388,6 +386,10 @@ void test_areal()
|
||||
TEST_INTERSECTION(case_precision_20, 0, 0, 0.0);
|
||||
TEST_INTERSECTION(case_precision_21, 0, 0, 0.0);
|
||||
TEST_INTERSECTION(case_precision_22, 1, -1, 14.0);
|
||||
TEST_INTERSECTION(case_precision_23, 1, -1, 14.0);
|
||||
TEST_INTERSECTION(case_precision_24, 0, 0, 0.0);
|
||||
TEST_INTERSECTION(case_precision_25, 0, 0, 0.0);
|
||||
TEST_INTERSECTION(case_precision_26, 1, -1, 14.0);
|
||||
|
||||
TEST_INTERSECTION_REV(case_precision_1, 0, 0, 0.0);
|
||||
TEST_INTERSECTION_REV(case_precision_2, 0, 0, 0.0);
|
||||
@@ -400,7 +402,8 @@ void test_areal()
|
||||
TEST_INTERSECTION_REV(case_precision_9, 1, -1, 14.0);
|
||||
TEST_INTERSECTION_REV(case_precision_10, 1, -1, 14.0);
|
||||
TEST_INTERSECTION_REV(case_precision_11, 1, -1, 14.0);
|
||||
|
||||
TEST_INTERSECTION_REV(case_precision_12, 1, -1, 2.0);
|
||||
TEST_INTERSECTION_REV(case_precision_13, 1, -1, 1.99998);
|
||||
TEST_INTERSECTION_REV(case_precision_14, 0, -1, 0.0);
|
||||
TEST_INTERSECTION_REV(case_precision_15, 1, -1, 14.0);
|
||||
TEST_INTERSECTION_REV(case_precision_16, 1, -1, 14.0);
|
||||
@@ -410,6 +413,10 @@ void test_areal()
|
||||
TEST_INTERSECTION_REV(case_precision_20, 0, 0, 0.0);
|
||||
TEST_INTERSECTION_REV(case_precision_21, 0, 0, 0.0);
|
||||
TEST_INTERSECTION_REV(case_precision_22, 1, -1, 14.0);
|
||||
TEST_INTERSECTION_REV(case_precision_23, 1, -1, 14.0);
|
||||
TEST_INTERSECTION_REV(case_precision_24, 0, 0, 0.0);
|
||||
TEST_INTERSECTION_REV(case_precision_25, 0, 0, 0.0);
|
||||
TEST_INTERSECTION_REV(case_precision_26, 1, -1, 14.0);
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("mysql_21964049",
|
||||
mysql_21964049[0], mysql_21964049[1],
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
#endif
|
||||
|
||||
#include <geometry_test_common.hpp>
|
||||
#include <algorithms/check_validity.hpp>
|
||||
#include "../setop_output_type.hpp"
|
||||
#include "../check_validity.hpp"
|
||||
|
||||
struct ut_settings
|
||||
{
|
||||
@@ -57,17 +57,10 @@ struct ut_settings
|
||||
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename G1,
|
||||
typename G2,
|
||||
typename ResultType,
|
||||
typename IntersectionOutput
|
||||
>
|
||||
typename bg::default_area_result<G1>::type
|
||||
check_result(
|
||||
IntersectionOutput const& intersection_output,
|
||||
template<typename IntersectionOutput, typename G1, typename G2>
|
||||
void check_result(IntersectionOutput const& intersection_output,
|
||||
std::string const& caseid,
|
||||
G1 const& g1, G2 const& g2,
|
||||
std::size_t expected_count, std::size_t expected_holes_count,
|
||||
int expected_point_count, double expected_length_or_area,
|
||||
ut_settings const& settings)
|
||||
@@ -110,7 +103,9 @@ check_result(
|
||||
#endif
|
||||
{
|
||||
std::string message;
|
||||
bool const valid = check_validity<ResultType>::apply(intersection_output, message);
|
||||
bool const valid = check_validity<IntersectionOutput>
|
||||
::apply(intersection_output, caseid, g1, g2, message);
|
||||
|
||||
BOOST_CHECK_MESSAGE(valid,
|
||||
"intersection: " << caseid << " not valid: " << message
|
||||
<< " type: " << (type_for_assert_message<G1, G2>()));
|
||||
@@ -172,7 +167,6 @@ check_result(
|
||||
}
|
||||
#endif
|
||||
|
||||
return length_or_area;
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +206,7 @@ typename bg::default_area_result<G1>::type test_intersection(std::string const&
|
||||
result_type intersection_output;
|
||||
bg::intersection(g1, g2, intersection_output);
|
||||
|
||||
check_result<G1, G2, result_type>(intersection_output, caseid, expected_count,
|
||||
check_result(intersection_output, caseid, g1, g2, expected_count,
|
||||
expected_holes_count, expected_point_count, expected_length_or_area,
|
||||
settings);
|
||||
|
||||
@@ -221,21 +215,21 @@ typename bg::default_area_result<G1>::type test_intersection(std::string const&
|
||||
intersection_output.clear();
|
||||
bg::intersection(boost::variant<G1>(g1), g2, intersection_output);
|
||||
|
||||
check_result<G1, G2, result_type>(intersection_output, caseid, expected_count,
|
||||
check_result(intersection_output, caseid, g1, g2, expected_count,
|
||||
expected_holes_count, expected_point_count, expected_length_or_area,
|
||||
settings);
|
||||
|
||||
intersection_output.clear();
|
||||
bg::intersection(g1, boost::variant<G2>(g2), intersection_output);
|
||||
|
||||
check_result<G1, G2, result_type>(intersection_output, caseid, expected_count,
|
||||
check_result(intersection_output, caseid, g1, g2, expected_count,
|
||||
expected_holes_count, expected_point_count, expected_length_or_area,
|
||||
settings);
|
||||
|
||||
intersection_output.clear();
|
||||
bg::intersection(boost::variant<G1>(g1), boost::variant<G2>(g2), intersection_output);
|
||||
|
||||
check_result<G1, G2, result_type>(intersection_output, caseid, expected_count,
|
||||
check_result(intersection_output, caseid, g1, g2, expected_count,
|
||||
expected_holes_count, expected_point_count, expected_length_or_area,
|
||||
settings);
|
||||
#endif
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#include <fstream>
|
||||
|
||||
#include <geometry_test_common.hpp>
|
||||
#include <algorithms/check_validity.hpp>
|
||||
#include "../setop_output_type.hpp"
|
||||
#include "../check_validity.hpp"
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
@@ -130,7 +130,7 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
|
||||
#endif
|
||||
{
|
||||
std::string message;
|
||||
bool const valid = check_validity<result_type>::apply(clip, message);
|
||||
bool const valid = check_validity<result_type>::apply(clip, caseid, g1, g2, message);
|
||||
BOOST_CHECK_MESSAGE(valid,
|
||||
"union: " << caseid << " not valid: " << message
|
||||
<< " type: " << (type_for_assert_message<G1, G2>()));
|
||||
|
||||
@@ -279,6 +279,10 @@ void test_areal()
|
||||
#endif
|
||||
TEST_UNION(case_precision_21, 1, 0, -1, 22.0);
|
||||
TEST_UNION(case_precision_22, 1, 1, -1, 73.0);
|
||||
TEST_UNION(case_precision_23, 1, 1, -1, 73.0);
|
||||
TEST_UNION(case_precision_24, 1, 0, -1, 22.0);
|
||||
TEST_UNION(case_precision_25, 1, 0, -1, 22.0);
|
||||
TEST_UNION(case_precision_26, 1, 1, -1, 73.0);
|
||||
|
||||
TEST_UNION_REV(case_precision_1, 1, 0, -1, 22.0);
|
||||
TEST_UNION_REV(case_precision_2, 1, 0, -1, 22.0);
|
||||
@@ -304,6 +308,10 @@ void test_areal()
|
||||
#endif
|
||||
TEST_UNION_REV(case_precision_21, 1, 0, -1, 22.0);
|
||||
TEST_UNION_REV(case_precision_22, 1, 1, -1, 73.0);
|
||||
TEST_UNION_REV(case_precision_23, 1, 1, -1, 73.0);
|
||||
TEST_UNION_REV(case_precision_24, 1, 0, -1, 22.0);
|
||||
TEST_UNION_REV(case_precision_25, 1, 0, -1, 22.0);
|
||||
TEST_UNION_REV(case_precision_26, 1, 1, -1, 73.0);
|
||||
|
||||
/*
|
||||
test_one<Polygon, Polygon, Polygon>(102,
|
||||
@@ -446,6 +454,7 @@ void test_areal()
|
||||
TEST_UNION_REV(issue_566_a, 1, 0, -1, 214.3728);
|
||||
TEST_UNION_REV(issue_566_b, 1, 0, -1, 214.3728);
|
||||
|
||||
if (! BOOST_GEOMETRY_CONDITION((boost::is_same<ct, float>::value)) )
|
||||
{
|
||||
ut_settings ignore_validity;
|
||||
ignore_validity.test_validity = false;
|
||||
@@ -527,7 +536,7 @@ void test_areal()
|
||||
1, 0, if_typed_tt<ct>(93, 91), 22.815);
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("buffer_mp2", buffer_mp2[0], buffer_mp2[1],
|
||||
1, BG_IF_RESCALED(1, 0), 217, 36.752837);
|
||||
1, BG_IF_RESCALED(1, (if_typed<ct, float>(1, 0))), 217, 36.752837);
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("mysql_21964079_1",
|
||||
mysql_21964079_1[0], mysql_21964079_1[1],
|
||||
|
||||
Reference in New Issue
Block a user