[DEV] add v1.76.0

This commit is contained in:
2021-10-05 21:37:46 +02:00
parent a97e9ae7d4
commit d0115b733d
45133 changed files with 4744437 additions and 1026325 deletions

View File

@@ -0,0 +1,22 @@
# Boost.Geometry (aka GGL, Generic Geometry Library)
#
# 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.
#
# This file was modified by Oracle on 2014, 2015, 2016.
# Modifications copyright (c) 2014-2016, 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
#
# 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)
test-suite boost-geometry-algorithms-equals
:
[ run equals.cpp : : : : algorithms_equals ]
[ run equals_multi.cpp : : : : algorithms_equals_multi ]
[ run equals_on_spheroid.cpp : : : : algorithms_equals_on_spheroid ]
;

View File

@@ -0,0 +1,318 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013-2020.
// Modifications copyright (c) 2013-2020 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// 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 "test_equals.hpp"
#include <boost/type_traits/is_floating_point.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
namespace bgm = bg::model;
template <typename P>
void test_pointlike()
{
typedef bgm::multi_point<P> mpt;
test_geometry<P, P>("ptpt2d_1", "POINT(0 0)", "POINT(0 0)", true);
test_geometry<P, P>("ptpt2d_2", "POINT(0 0)", "POINT(1 1)", false);
test_geometry<P, mpt>("ptmpt2d_1", "POINT(0 0)", "MULTIPOINT(0 0)", true);
test_geometry<P, mpt>("ptmpt2d_1", "POINT(0 0)", "MULTIPOINT(0 0, 1 1)", false);
test_geometry<mpt, P>("mptpt2d_1", "MULTIPOINT(0 0)", "POINT(0 0)", true);
test_geometry<mpt, P>("mptpt2d_1", "MULTIPOINT(0 0, 1 1)", "POINT(0 0)", false);
test_geometry<mpt, mpt>("mptmpt2d_1", "MULTIPOINT(0 0, 1 1)", "MULTIPOINT(0 0, 1 1)", true);
test_geometry<mpt, mpt>("mptmpt2d_1", "MULTIPOINT(0 0, 1 1)", "MULTIPOINT(0 0, 2 2)", false);
test_geometry<mpt, mpt>("mptmpt2d_1", "MULTIPOINT(0 0, 1 1)", "MULTIPOINT(2 2, 3 3)", false);
}
template <typename P>
void test_segment_segment()
{
typedef bgm::segment<P> seg;
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(0 0, 3 3)", true);
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(3 3, 0 0)", true);
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(0 0, 1 1)", false);
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(3 3, 2 2)", false);
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(1 1, 4 4)", false);
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(1 0, 2 0)", false);
}
template <typename P>
void test_linestring_linestring()
{
typedef bgm::linestring<P> ls;
test_geometry<ls, ls>("ls2d_1", "LINESTRING(1 1, 3 3)", "LINESTRING(3 3, 1 1)", true);
test_geometry<ls, ls>("ls2d_2", "LINESTRING(1 1, 3 3, 2 5)", "LINESTRING(1 1, 2 2, 3 3, 2 5)", true);
test_geometry<ls, ls>("ls2d_3", "LINESTRING(1 0, 3 3, 2 5)", "LINESTRING(1 1, 2 2, 3 3, 2 5)", false);
test_geometry<ls, ls>("ls2d_4", "LINESTRING(1 0, 3 3, 2 5)", "LINESTRING(1 1, 3 3, 2 5)", false);
test_geometry<ls, ls>("ls2d_5", "LINESTRING(0 5,5 5,10 5,10 0,5 0,5 5,5 10,10 10,15 10,15 5,10 5,10 10,10 15)",
"LINESTRING(0 5,15 5,15 10,5 10,5 0,10 0,10 15)", true);
test_geometry<ls, ls>("ls2d_6", "LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,5 0)", "LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", true);
test_geometry<ls, ls>("ls2d_7", "LINESTRING(0 5,10 5,10 10,5 10,5 0)", "LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", true);
test_geometry<ls, ls>("ls2d_8", "LINESTRING(0 0,5 0,5 0,6 0)", "LINESTRING(0 0,6 0)", true);
test_geometry<ls, ls>("ls2d_seg", "LINESTRING(1 1,2 2)", "LINESTRING(1 1,2 2)", true);
test_geometry<ls, ls>("ls2d_rev", "LINESTRING(1 1,2 2)", "LINESTRING(2 2,1 1)", true);
test_geometry<ls, ls>("ls2d_spike", "LINESTRING(0 0,5 0,3 0,6 0)", "LINESTRING(0 0,6 0)", true);
test_geometry<ls, ls>("ls2d_ring1", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "LINESTRING(5 5,0 5,0 0,5 0,5 5)", true);
test_geometry<ls, ls>("ls2d_ring2", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "LINESTRING(5 5,5 0,0 0,0 5,5 5)", true);
test_geometry<ls, ls>("ls2d_overl_ring1", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "LINESTRING(5 5,0 5,0 0,5 0,5 5,0 5)", true);
test_geometry<ls, ls>("ls2d_overl_ring2", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "LINESTRING(5 5,5 0,0 0,0 5,5 5,5 0)", true);
// https://svn.boost.org/trac/boost/ticket/10904
if ( BOOST_GEOMETRY_CONDITION(
boost::is_floating_point<typename bg::coordinate_type<ls>::type>::value ) )
{
test_geometry<ls, ls>("ls2d_small1",
"LINESTRING(5.6956521739130430148634331999347 -0.60869565217391330413931882503675,5.5 -0.50000000000000066613381477509392)",
"LINESTRING(5.5 -0.50000000000000066613381477509392,5.5 -0.5)",
false);
test_geometry<ls, ls>("ls2d_small2",
"LINESTRING(-3.2333333333333333925452279800083 5.5999999999999978683717927196994,-3.2333333333333333925452279800083 5.5999999999999996447286321199499)",
"LINESTRING(-3.2333333333333325043668082798831 5.5999999999999996447286321199499,-3.2333333333333333925452279800083 5.5999999999999996447286321199499)",
false);
}
}
template <typename P>
void test_linestring_multilinestring()
{
typedef bgm::linestring<P> ls;
typedef bgm::multi_linestring<ls> mls;
test_geometry<ls, mls>("ls_mls_1", "LINESTRING(0 0,1 0,2 0)", "MULTILINESTRING((0 0,2 0))", true);
test_geometry<ls, mls>("ls_mls_1", "LINESTRING(0 0,1 0,2 0)", "MULTILINESTRING((0 0,1 0),(1 0,2 0))", true);
test_geometry<ls, mls>("ls_mls_1", "LINESTRING(0 0,2 0,4 0)", "MULTILINESTRING((0 0,2 0),(2 0,3 0),(3 0,4 0))", true);
test_geometry<ls, mls>("ls_mls_1", "LINESTRING(0 0,2 0,4 0)", "MULTILINESTRING((0 0,2 0),(2 0,3 0),(2 0,3 0),(3 0,4 0))", true);
test_geometry<ls, mls>("ls_mls_1", "LINESTRING(0 0,2 0,4 0)", "MULTILINESTRING((0 0,2 0),(3 0,4 0))", false);
test_geometry<ls, mls>("ls_mls_spike", "LINESTRING(0 0,2 0,2 2,2 0,4 0)", "MULTILINESTRING((0 0,4 0),(2 2,2 0))", true);
test_geometry<ls, mls>("ls_mls_spike", "LINESTRING(0 0,2 0,2 2,2 0,4 0)", "MULTILINESTRING((0 0,4 0),(2 2,2 -1))", false);
test_geometry<ls, mls>("ls_mls_ring1", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5))", true);
test_geometry<ls, mls>("ls_mls_ring2", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "MULTILINESTRING((5 5,5 0,0 0),(0 0,0 5,5 5))", true);
test_geometry<ls, mls>("ls_mls_overl_ring1", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5,0 5))", true);
test_geometry<ls, mls>("ls_mls_overl_ring2", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "MULTILINESTRING((5 5,5 0,0 0),(0 0,0 5,5 5,5 0))", true);
}
template <typename P>
void test_multilinestring_multilinestring()
{
typedef bgm::linestring<P> ls;
typedef bgm::multi_linestring<ls> mls;
test_geometry<mls, mls>("ls_mls_mls",
"MULTILINESTRING((0 5,10 5,10 10,5 10),(5 10,5 0,5 2),(5 2,5 5,0 5))",
"MULTILINESTRING((5 5,0 5),(5 5,5 0),(10 10,10 5,5 5,5 10,10 10))",
true);
}
template <typename P>
void test_polygons()
{
typedef bg::model::polygon<P, true, true> poly_cw_c;
typedef bg::model::polygon<P, true, false> poly_cw_o;
typedef bg::model::polygon<P, false, true> poly_ccw_c;
typedef bg::model::polygon<P, false, false> poly_ccw_o;
typedef bg::model::box<P> box;
std::string wkt1 = "POLYGON((-18 1, -23 1, -23 -3, -18 -3))";
std::string wkt2 = "POLYGON((-23 1, -23 -3, -18 -3, -18 1))";
test_geometry<poly_cw_c, poly_cw_c>("polys_cw_c_cw_c", wkt1, wkt2, true, true);
test_geometry<poly_cw_c, poly_cw_o>("polys_cw_c_cw_o", wkt1, wkt2, true, true);
test_geometry<poly_cw_c, poly_ccw_c>("polys_cw_c_ccw_c", wkt1, wkt2, true, true);
test_geometry<poly_cw_c, poly_ccw_o>("polys_cw_c_ccw_o", wkt1, wkt2, true, true);
test_geometry<poly_cw_c, box>("polys_cw_c_box", wkt1, wkt2, true, true);
test_geometry<poly_cw_o, poly_cw_c>("polys_cw_o_cw_c", wkt1, wkt2, true, true);
test_geometry<poly_cw_o, poly_cw_o>("polys_cw_o_cw_o", wkt1, wkt2, true, true);
test_geometry<poly_cw_o, poly_ccw_c>("polys_cw_o_ccw_c", wkt1, wkt2, true, true);
test_geometry<poly_cw_o, poly_ccw_o>("polys_cw_o_ccw_o", wkt1, wkt2, true, true);
test_geometry<poly_cw_o, box>("polys_cw_o_box", wkt1, wkt2, true, true);
test_geometry<poly_ccw_c, poly_cw_c>("polys_ccw_c_cw_c", wkt1, wkt2, true, true);
test_geometry<poly_ccw_c, poly_cw_o>("polys_ccw_c_cw_o", wkt1, wkt2, true, true);
test_geometry<poly_ccw_c, poly_ccw_c>("polys_ccw_c_ccw_c", wkt1, wkt2, true, true);
test_geometry<poly_ccw_c, poly_ccw_o>("polys_ccw_c_ccw_o", wkt1, wkt2, true, true);
test_geometry<poly_ccw_c, box>("polys_cw_o_box", wkt1, wkt2, true, true);
test_geometry<poly_ccw_o, poly_cw_c>("polys_ccw_o_cw_c", wkt1, wkt2, true, true);
test_geometry<poly_ccw_o, poly_cw_o>("polys_ccw_o_cw_o", wkt1, wkt2, true, true);
test_geometry<poly_ccw_o, poly_ccw_c>("polys_ccw_o_ccw_c", wkt1, wkt2, true, true);
test_geometry<poly_ccw_o, poly_ccw_o>("polys_ccw_o_ccw_o", wkt1, wkt2, true, true);
test_geometry<poly_ccw_o, box>("polys_ccw_o_box", wkt1, wkt2, true, true);
}
template <typename P>
void test_all()
{
typedef bg::model::box<P> box;
typedef bg::model::ring<P> ring;
typedef bg::model::polygon<P> polygon;
//typedef bg::model::linestring<P> linestring;
std::string case_p1 = "POLYGON((0 0,0 2,2 2,0 0))";
test_geometry<P, P>("p1", "POINT(1 1)", "POINT(1 1)", true);
test_geometry<P, P>("p2", "POINT(1 1)", "POINT(1 2)", false);
test_geometry<box, box>("b1", "BOX(1 1,2 2)", "BOX(1 2,2 2)", false);
test_geometry<box, box>("b1", "BOX(1 2,3 4)", "BOX(1 2,3 4)", true);
// Completely equal
test_geometry<ring, ring>("poly_eq", case_p1, case_p1, true);
// Shifted
test_geometry<ring, ring>("poly_sh", "POLYGON((2 2,0 0,0 2,2 2))", case_p1, true);
test_geometry<polygon, polygon>("poly_sh2", case_p1, "POLYGON((0 2,2 2,0 0,0 2))", true);
// Extra coordinate
test_geometry<ring, ring>("poly_extra", case_p1, "POLYGON((0 0,0 2,2 2,1 1,0 0))", true);
// Shifted + extra (redundant) coordinate
test_geometry<ring, ring>("poly_shifted_extra1", "POLYGON((2 2,1 1,0 0,0 2,2 2))", case_p1, true);
// Shifted + extra (redundant) coordinate being first/last point
test_geometry<ring, ring>("poly_shifted_extra2", "POLYGON((1 1,0 0,0 2,2 2,1 1))", case_p1, true);
// Degenerate (duplicate) points
test_geometry<ring, ring>("poly_degenerate", "POLYGON((0 0,0 2,2 2,2 2,0 0))", "POLYGON((0 0,0 2,0 2,2 2,0 0))", true);
// Two different bends, same area, unequal
test_geometry<ring, ring>("poly_bends",
"POLYGON((4 0,5 3,8 4,7 7,4 8,0 4,4 0))",
"POLYGON((4 0,7 1,8 4,5 5,4 8,0 4,4 0))", false);
// Unequal (but same area)
test_geometry<ring, ring>("poly_uneq", case_p1, "POLYGON((1 1,1 3,3 3,1 1))", false);
// Note that POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))
// below is invalid. equals() returns different result than
// relate() with equals mask in this case because for areal
// geometries different algorithms is used, i.e. collect_vectors.
// One having hole
test_geometry<polygon, polygon>("poly_hole",
"POLYGON((0 0,0 4,4 4,0 0))",
"POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))", false);
// Both having holes
test_geometry<polygon, polygon>("poly_holes",
"POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))",
"POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))", true);
// Both having holes, outer equal, inner not equal
test_geometry<polygon, polygon>("poly_uneq_holes",
"POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))",
"POLYGON((0 0,0 4,4 4,0 0),(2 2,3 2,3 3,2 3,2 2))", false);
// Both having 2 holes, equal but in different order
test_geometry<polygon, polygon>("poly_holes_diff_order",
"POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1),(2 2,3 2,3 3,2 3,2 2))",
"POLYGON((0 0,0 4,4 4,0 0),(2 2,3 2,3 3,2 3,2 2),(1 1,2 1,2 2,1 2,1 1))", true);
// Both having 3 holes, equal but in different order
test_geometry<polygon, polygon>("poly_holes_diff_order_3",
"POLYGON((0 0,0 10,10 10,0 0),(1 1,2 1,2 2,1 2,1 1),(4 1,5 1,5 2,4 2,4 1),(2 2,3 2,3 3,2 3,2 2))",
"POLYGON((0 0,0 10,10 10,0 0),(4 1,5 1,5 2,4 2,4 1),(2 2,3 2,3 3,2 3,2 2),(1 1,2 1,2 2,1 2,1 1))", true);
// polygon/ring vv
test_geometry<polygon, ring>("poly_sh2_pr", case_p1, case_p1, true);
test_geometry<ring, polygon>("poly_sh2_rp", case_p1, case_p1, true);
// box/ring/poly
test_geometry<box, ring>("boxring1", "BOX(1 1,2 2)", "POLYGON((1 1,1 2,2 2,2 1,1 1))", true);
test_geometry<ring, box>("boxring2", "POLYGON((1 1,1 2,2 2,2 1,1 1))", "BOX(1 1,2 2)", true);
test_geometry<box, polygon>("boxpoly1", "BOX(1 1,2 2)", "POLYGON((1 1,1 2,2 2,2 1,1 1))", true);
test_geometry<polygon, box>("boxpoly2", "POLYGON((1 1,1 2,2 2,2 1,1 1))", "BOX(1 1,2 2)", true);
test_geometry<polygon, box>("boxpoly2", "POLYGON((1 1,1 2,2 2,2 1,1 1))", "BOX(1 1,2 3)", false);
test_geometry<polygon, polygon>("poly_holes_shifted_points",
"POLYGON((0 0,0 3,3 3,3 0,0 0),(1 1,2 1,2 2,1 2,1 1))",
"POLYGON((0 0,0 3,3 3,3 0,0 0),(2 2,1 2,1 1,2 1,2 2))", true);
test_pointlike<P>();
test_segment_segment<P>();
test_linestring_linestring<P>();
test_linestring_multilinestring<P>();
test_multilinestring_multilinestring<P>();
test_polygons<P>();
}
template <typename T>
void verify()
{
T dxn1, dyn1, dxn2, dyn2;
{
T x1 = "0", y1 = "0", x2 = "3", y2 = "3";
T dx = x2 - x1, dy = y2 - y1;
T mag = sqrt(dx * dx + dy * dy);
dxn1 = dx / mag;
dyn1 = dy / mag;
}
{
T x1 = "0", y1 = "0", x2 = "1", y2 = "1";
T dx = x2 - x1, dy = y2 - y1;
T mag = sqrt(dx * dx + dy * dy);
dxn2 = dx / mag;
dyn2 = dy / mag;
}
if (dxn1 == dxn2 && dyn1 == dyn2)
{
//std::cout << "vectors are equal, using ==" << std::endl;
}
if (boost::geometry::math::equals(dxn1, dxn2)
&& boost::geometry::math::equals(dyn1, dyn2))
{
//std::cout << "vectors are equal, using bg::math::equals" << std::endl;
}
bool equals = boost::geometry::math::equals_with_epsilon(dxn1, dxn2)
&& boost::geometry::math::equals_with_epsilon(dyn1, dyn2);
if (equals)
{
//std::cout << "vectors are equal, using bg::math::equals_with_epsilon" << std::endl;
}
BOOST_CHECK_EQUAL(equals, true);
}
int test_main( int , char* [] )
{
//verify<double>();
test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
return 0;
}

View File

@@ -0,0 +1,48 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright (c) 2010-2015 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "test_equals.hpp"
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
template <typename P>
void test_all()
{
std::string case1 = "MULTIPOLYGON(((0 0,0 7,4 2,2 0,0 0)))";
std::string case1_p = "POLYGON((0 0,0 7,4 2,2 0,0 0))";
typedef bg::model::polygon<P> polygon;
typedef bg::model::multi_polygon<polygon> mp;
test_geometry<mp, mp>("c1", case1, case1, true);
test_geometry<mp, mp>("c2",
"MULTIPOLYGON(((0 0,0 7.01,4 2,2 0,0 0)))",
case1, false);
// Different order == equal
test_geometry<mp, mp>("c3",
"MULTIPOLYGON(((0 0,0 7,4 2,2 0,0 0)),((10 10,10 12,12 10,10 10)))",
"MULTIPOLYGON(((10 10,10 12,12 10,10 10)),((0 0,0 7,4 2,2 0,0 0)))",
true);
// check different types
test_geometry<polygon, mp>("c1_p_mp", case1_p, case1, true);
test_geometry<mp, polygon>("c1_mp_p", case1, case1_p, true);
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<double> >();
return 0;
}

View File

@@ -0,0 +1,235 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit test
// Copyright (c) 2015, Oracle and/or its affiliates.
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
#ifndef BOOST_TEST_MODULE
#define BOOST_TEST_MODULE test_equals_on_spheroid
#endif
#include <iostream>
#include <boost/test/included/unit_test.hpp>
#include "test_equals.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/core/cs.hpp>
namespace bgm = bg::model;
template <typename P1, typename P2 = P1>
struct test_point_point
{
static inline void apply(std::string const& header)
{
std::string const str = header + "-";
test_geometry<P1, P2>(str + "pp_01", "POINT(0 0)", "POINT(0 0)", true);
test_geometry<P1, P2>(str + "pp_02", "POINT(0 0)", "POINT(10 0)", false);
// points whose longitudes differ by 360 degrees
test_geometry<P1, P2>(str + "pp_03", "POINT(0 0)", "POINT(360 0)", true);
test_geometry<P1, P2>(str + "pp_04", "POINT(10 0)", "POINT(370 0)", true);
test_geometry<P1, P2>(str + "pp_05", "POINT(10 0)", "POINT(-350 0)", true);
test_geometry<P1, P2>(str + "pp_06", "POINT(180 10)", "POINT(-180 10)", true);
test_geometry<P1, P2>(str + "pp_06a", "POINT(540 10)", "POINT(-540 10)", true);
#ifdef BOOST_GEOMETRY_NORMALIZE_LATITUDE
test_geometry<P1, P2>(str + "pp_06b", "POINT(540 370)", "POINT(-540 -350)", true);
test_geometry<P1, P2>(str + "pp_06c", "POINT(1260 370)", "POINT(-1260 -350)", true);
test_geometry<P1, P2>(str + "pp_06d", "POINT(2340 370)", "POINT(-2340 -350)", true);
#endif
test_geometry<P1, P2>(str + "pp_06e", "POINT(-180 10)", "POINT(-540 10)", true);
test_geometry<P1, P2>(str + "pp_06f", "POINT(180 10)", "POINT(-540 10)", true);
// north & south pole
test_geometry<P1, P2>(str + "pp_07", "POINT(0 90)", "POINT(0 90)", true);
#ifdef BOOST_GEOMETRY_NORMALIZE_LATITUDE
test_geometry<P1, P2>(str + "pp_07a", "POINT(0 450)", "POINT(10 -270)", true);
test_geometry<P1, P2>(str + "pp_07b", "POINT(0 270)", "POINT(10 90)", false);
test_geometry<P1, P2>(str + "pp_07c", "POINT(0 -450)", "POINT(10 90)", false);
#endif
test_geometry<P1, P2>(str + "pp_08", "POINT(0 90)", "POINT(10 90)", true);
test_geometry<P1, P2>(str + "pp_09", "POINT(0 90)", "POINT(0 -90)", false);
test_geometry<P1, P2>(str + "pp_10", "POINT(0 -90)", "POINT(0 -90)", true);
test_geometry<P1, P2>(str + "pp_11", "POINT(0 -90)", "POINT(10 -90)", true);
test_geometry<P1, P2>(str + "pp_11a", "POINT(0 -90)", "POINT(10 90)", false);
test_geometry<P1, P2>(str + "pp_12", "POINT(0 -90)", "POINT(0 -85)", false);
test_geometry<P1, P2>(str + "pp_13", "POINT(0 90)", "POINT(0 85)", false);
test_geometry<P1, P2>(str + "pp_14", "POINT(0 90)", "POINT(10 85)", false);
// symmetric wrt prime meridian
test_geometry<P1, P2>(str + "pp_15", "POINT(-10 45)", "POINT(10 45)", false);
test_geometry<P1, P2>(str + "pp_16", "POINT(-170 45)", "POINT(170 45)", false);
// other points
test_geometry<P1, P2>(str + "pp_17", "POINT(-10 45)", "POINT(10 -45)", false);
test_geometry<P1, P2>(str + "pp_18", "POINT(-10 -45)", "POINT(10 45)", false);
test_geometry<P1, P2>(str + "pp_19", "POINT(10 -135)", "POINT(10 45)", false);
#ifdef BOOST_GEOMETRY_NORMALIZE_LATITUDE
test_geometry<P1, P2>(str + "pp_20", "POINT(190 135)", "POINT(10 45)", true);
test_geometry<P1, P2>(str + "pp_21", "POINT(190 150)", "POINT(10 30)", true);
test_geometry<P1, P2>(str + "pp_21a", "POINT(-170 150)", "POINT(10 30)", true);
test_geometry<P1, P2>(str + "pp_22", "POINT(190 -135)", "POINT(10 -45)", true);
test_geometry<P1, P2>(str + "pp_23", "POINT(190 -150)", "POINT(10 -30)", true);
test_geometry<P1, P2>(str + "pp_23a", "POINT(-170 -150)", "POINT(10 -30)", true);
#endif
}
};
template <typename P1, typename P2 = P1>
struct test_point_point_with_height
{
static inline void apply(std::string const& header)
{
std::string const str = header + "-";
test_geometry<P1, P2>(str + "pp_01",
"POINT(0 0 10)",
"POINT(0 0 20)",
true);
test_geometry<P1, P2>(str + "pp_02",
"POINT(0 0 10)",
"POINT(10 0 10)",
false);
// points whose longitudes differ by 360 degrees
test_geometry<P1, P2>(str + "pp_03",
"POINT(0 0 10)",
"POINT(360 0 10)",
true);
// points whose longitudes differ by 360 degrees
test_geometry<P1, P2>(str + "pp_04",
"POINT(10 0 10)",
"POINT(370 0 10)",
true);
test_geometry<P1, P2>(str + "pp_05",
"POINT(10 0 10)",
"POINT(10 0 370)",
false);
}
};
template <typename P>
void test_segment_segment(std::string const& header)
{
typedef bgm::segment<P> seg;
std::string const str = header + "-";
test_geometry<seg, seg>(str + "ss_01",
"SEGMENT(10 0,180 0)",
"SEGMENT(10 0,-180 0)",
true);
test_geometry<seg, seg>(str + "ss_02",
"SEGMENT(0 90,180 0)",
"SEGMENT(10 90,-180 0)",
true);
test_geometry<seg, seg>(str + "ss_03",
"SEGMENT(0 90,0 -90)",
"SEGMENT(10 90,20 -90)",
true);
test_geometry<seg, seg>(str + "ss_04",
"SEGMENT(10 80,10 -80)",
"SEGMENT(10 80,20 -80)",
false);
test_geometry<seg, seg>(str + "ss_05",
"SEGMENT(170 10,-170 10)",
"SEGMENT(170 10,350 10)",
false);
}
BOOST_AUTO_TEST_CASE( equals_point_point_se )
{
typedef bg::cs::spherical_equatorial<bg::degree> cs_type;
test_point_point<bgm::point<int, 2, cs_type> >::apply("se");
test_point_point<bgm::point<double, 2, cs_type> >::apply("se");
test_point_point<bgm::point<long double, 2, cs_type> >::apply("se");
// mixed point types
test_point_point
<
bgm::point<double, 2, cs_type>, bgm::point<int, 2, cs_type>
>::apply("se");
test_point_point
<
bgm::point<double, 2, cs_type>, bgm::point<long double, 2, cs_type>
>::apply("se");
}
BOOST_AUTO_TEST_CASE( equals_point_point_with_height_se )
{
typedef bg::cs::spherical_equatorial<bg::degree> cs_type;
test_point_point<bgm::point<int, 3, cs_type> >::apply("seh");
test_point_point<bgm::point<double, 3, cs_type> >::apply("seh");
test_point_point<bgm::point<long double, 3, cs_type> >::apply("seh");
// mixed point types
test_point_point
<
bgm::point<double, 3, cs_type>, bgm::point<int, 3, cs_type>
>::apply("seh");
test_point_point
<
bgm::point<double, 3, cs_type>, bgm::point<long double, 3, cs_type>
>::apply("seh");
}
BOOST_AUTO_TEST_CASE( equals_point_point_geo )
{
typedef bg::cs::geographic<bg::degree> cs_type;
test_point_point<bgm::point<int, 2, cs_type> >::apply("geo");
test_point_point<bgm::point<double, 2, cs_type> >::apply("geo");
test_point_point<bgm::point<long double, 2, cs_type> >::apply("geo");
// mixed point types
test_point_point
<
bgm::point<double, 2, cs_type>, bgm::point<int, 2, cs_type>
>::apply("se");
test_point_point
<
bgm::point<double, 2, cs_type>, bgm::point<long double, 2, cs_type>
>::apply("se");
}
BOOST_AUTO_TEST_CASE( equals_segment_segment_se )
{
typedef bg::cs::spherical_equatorial<bg::degree> cs_type;
test_segment_segment<bgm::point<int, 2, cs_type> >("se");
test_segment_segment<bgm::point<double, 2, cs_type> >("se");
test_segment_segment<bgm::point<long double, 2, cs_type> >("se");
}
BOOST_AUTO_TEST_CASE( equals_segment_segment_geo )
{
typedef bg::cs::geographic<bg::degree> cs_type;
test_segment_segment<bgm::point<int, 2, cs_type> >("geo");
test_segment_segment<bgm::point<double, 2, cs_type> >("geo");
test_segment_segment<bgm::point<long double, 2, cs_type> >("geo");
}

View File

@@ -0,0 +1,151 @@
// Boost.Geometry
// Copyright (c) 2016 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// 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 "test_equals.hpp"
#include <algorithms/overlay/overlay_cases.hpp>
#include <algorithms/overlay/multi_overlay_cases.hpp>
#include <boost/geometry/geometries/geometries.hpp>
template <typename P>
void test_polygon_polygon()
{
typedef bg::model::polygon<P> poly;
typedef bg::model::ring<P> ring;
test_geometry<poly, ring>(case_1[0], case_1[0],
true);
test_geometry<ring, ring>(case_1[0], case_1[1],
false);
test_geometry<ring, poly>(case_1[0], case_1[1],
false);
test_geometry<poly, poly>(case_1[0], case_1[1],
false);
test_geometry<poly, poly>(case_2[0], case_2[1],
false);
test_geometry<poly, poly>(case_3_sph[0], case_3_sph[1],
false);
test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1],
true);
test_geometry<poly, poly>(case_4[0], case_4[1],
false);
test_geometry<poly, poly>(case_5[0], case_5[1],
false);
test_geometry<poly, poly>(case_6_sph[0], case_6_sph[1],
false);
test_geometry<poly, poly>(case_7[0], case_7[1],
false);
test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1],
false);
test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1],
false);
test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1],
false);
test_geometry<poly, poly>(case_11_sph[0], case_11_sph[1],
false);
test_geometry<poly, poly>(case_12[0], case_12[1],
false);
test_geometry<poly, poly>(case_13_sph[0], case_13_sph[1],
false);
test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1],
false);
test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1],
false);
test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1],
false);
test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1],
false);
test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1],
false);
}
template <typename P>
void test_polygon_multi_polygon()
{
typedef bg::model::polygon<P> poly;
typedef bg::model::ring<P> ring;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<ring, mpoly>(case_1[0], case_multi_2[0],
false);
test_geometry<poly, mpoly>(case_2[0], case_multi_2[0],
false);
}
template <typename P>
void test_multi_polygon_multi_polygon()
{
typedef bg::model::polygon<P> poly;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<mpoly, mpoly>(case_multi_2[0], case_multi_2[1],
false);
}
template <typename P>
void test_linestring_linestring()
{
typedef bg::model::linestring<P> ls;
test_geometry<ls, ls>("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true);
test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", false);
}
template <typename P>
void test_linestring_multi_linestring()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
test_geometry<ls, mls>("LINESTRING(0 0,10 0)",
"MULTILINESTRING((1 0,2 0),(1 1,2 1))",
false);
test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)",
"MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5))",
true);
}
template <typename P>
void test_multi_linestring_multi_linestring()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
test_geometry<mls, mls>("MULTILINESTRING((0 0,0 0,18 0,18 0,19 0,19 0,19 0,30 0,30 0))",
"MULTILINESTRING((0 10,5 0,20 0,20 0,30 0))",
false);
}
template <typename P>
void test_all()
{
test_polygon_polygon<P>();
test_polygon_multi_polygon<P>();
test_multi_polygon_multi_polygon<P>();
test_linestring_linestring<P>();
test_linestring_multi_linestring<P>();
test_multi_linestring_multi_linestring<P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
return 0;
}

View File

@@ -0,0 +1,115 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2014-2017 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2016-2017.
// Modifications copyright (c) 2016-2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// 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_EQUALS_HPP
#define BOOST_GEOMETRY_TEST_EQUALS_HPP
#include <geometry_test_common.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/algorithms/correct.hpp>
#include <boost/geometry/algorithms/equals.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/io/wkt/read.hpp>
#include <boost/variant/variant.hpp>
struct no_strategy {};
template <typename Geometry1, typename Geometry2, typename Strategy>
bool call_equals(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return bg::equals(geometry1, geometry2, strategy);
}
template <typename Geometry1, typename Geometry2>
bool call_equals(Geometry1 const& geometry1,
Geometry2 const& geometry2,
no_strategy)
{
return bg::equals(geometry1, geometry2);
}
template <typename Geometry1, typename Geometry2, typename Strategy>
void check_geometry(Geometry1 const& geometry1,
Geometry2 const& geometry2,
std::string const& caseid,
std::string const& wkt1,
std::string const& wkt2,
bool expected,
Strategy const& strategy)
{
bool detected = call_equals(geometry1, geometry2, strategy);
BOOST_CHECK_MESSAGE(detected == expected,
"case: " << caseid
<< " equals: " << wkt1
<< " to " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
detected = call_equals(geometry2, geometry1, strategy);
BOOST_CHECK_MESSAGE(detected == expected,
"case: " << caseid
<< " equals: " << wkt2
<< " to " << wkt1
<< " -> Expected: " << expected
<< " detected: " << detected);
}
template <typename Geometry1, typename Geometry2>
void test_geometry(std::string const& caseid,
std::string const& wkt1,
std::string const& wkt2,
bool expected,
bool correct_geometries = false)
{
Geometry1 geometry1;
Geometry2 geometry2;
bg::read_wkt(wkt1, geometry1);
bg::read_wkt(wkt2, geometry2);
if (correct_geometries)
{
bg::correct(geometry1);
bg::correct(geometry2);
}
typedef typename bg::strategy::relate::services::default_strategy
<
Geometry1, Geometry2
>::type strategy_type;
check_geometry(geometry1, geometry2, caseid, wkt1, wkt2, expected, no_strategy());
check_geometry(geometry1, geometry2, caseid, wkt1, wkt2, expected, strategy_type());
check_geometry(boost::variant<Geometry1>(geometry1), geometry2, caseid, wkt1, wkt2, expected, no_strategy());
check_geometry(geometry1, boost::variant<Geometry2>(geometry2), caseid, wkt1, wkt2, expected, no_strategy());
check_geometry(boost::variant<Geometry1>(geometry1), boost::variant<Geometry2>(geometry2), caseid, wkt1, wkt2, expected, no_strategy());
}
template <typename Geometry1, typename Geometry2>
void test_geometry(std::string const& wkt1,
std::string const& wkt2,
bool expected)
{
test_geometry<Geometry1, Geometry2>("", wkt1, wkt2, expected);
}
#endif