mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-10 07:34:03 +00:00
Add test with custom points.
This commit is contained in:
parent
b2c3b9721e
commit
c26217e810
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
test-suite boost-geometry-algorithms-relate
|
test-suite boost-geometry-algorithms-relate
|
||||||
:
|
:
|
||||||
[ run relate_const.cpp : : : : algorithms_relate_const ]
|
[ run relate_const_custom.cpp : : : : algorithms_relate_const_custom ]
|
||||||
[ run relate_areal_areal.cpp : : : : algorithms_relate_areal_areal ]
|
[ run relate_areal_areal.cpp : : : : algorithms_relate_areal_areal ]
|
||||||
[ run relate_areal_areal_sph.cpp : : : : algorithms_relate_areal_areal_sph ]
|
[ run relate_areal_areal_sph.cpp : : : : algorithms_relate_areal_areal_sph ]
|
||||||
[ run relate_linear_areal.cpp : : : : algorithms_relate_linear_areal ]
|
[ run relate_linear_areal.cpp : : : : algorithms_relate_linear_areal ]
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <test_geometries/const_point.hpp>
|
#include <test_geometries/const_point.hpp>
|
||||||
|
#include <test_geometries/custom_cartesian_point.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/covered_by.hpp>
|
#include <boost/geometry/algorithms/covered_by.hpp>
|
||||||
#include <boost/geometry/algorithms/crosses.hpp>
|
#include <boost/geometry/algorithms/crosses.hpp>
|
||||||
@ -39,7 +40,6 @@ void test_relate_const(Geometry1 const &geometry1, Geometry2 const &geometry2,
|
|||||||
BOOST_CHECK_EQUAL(exp_within, bg::within(geometry1, geometry2));
|
BOOST_CHECK_EQUAL(exp_within, bg::within(geometry1, geometry2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int test_main(int, char* [])
|
int test_main(int, char* [])
|
||||||
{
|
{
|
||||||
ring_of_const_point const rectangle{{2, 2}, {2, 4}, {4, 4}, {4, 2}, {2, 2}};
|
ring_of_const_point const rectangle{{2, 2}, {2, 4}, {4, 4}, {4, 2}, {2, 2}};
|
||||||
@ -59,5 +59,16 @@ int test_main(int, char* [])
|
|||||||
// linear/linear
|
// linear/linear
|
||||||
test_relate_const(horizontal, diagonal, false, true, false, true, false, false, false, false);
|
test_relate_const(horizontal, diagonal, false, true, false, true, false, false, false, false);
|
||||||
|
|
||||||
|
custom_cartesian_line l;
|
||||||
|
custom_cartesian_polygon poly;
|
||||||
|
bg::covered_by(l, poly);
|
||||||
|
bg::crosses(l, poly);
|
||||||
|
bg::disjoint(l, poly);
|
||||||
|
bg::intersects(l, poly);
|
||||||
|
bg::overlaps(l, poly);
|
||||||
|
bg::touches(l, poly);
|
||||||
|
bg::relate(l, poly, bg::de9im::mask("F0F******"));
|
||||||
|
bg::within(l, poly);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -43,5 +43,4 @@ namespace boost { namespace geometry { namespace traits {
|
|||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
22
test/test_geometries/custom_cartesian_point.hpp
Normal file
22
test/test_geometries/custom_cartesian_point.hpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Boost.Geometry
|
||||||
|
|
||||||
|
// Copyright (c) 2022 Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, 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 <boost/geometry/geometries/geometries.hpp>
|
||||||
|
|
||||||
|
struct custom_cartesian_point {
|
||||||
|
double x, y;
|
||||||
|
custom_cartesian_point(double x = 0, double y = 0) : x(x), y(y) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOST_GEOMETRY_REGISTER_POINT_2D(custom_cartesian_point, double,
|
||||||
|
boost::geometry::cs::cartesian, x, y);
|
||||||
|
|
||||||
|
using custom_cartesian_line = boost::geometry::model::linestring<custom_cartesian_point>;
|
||||||
|
using custom_cartesian_polygon = boost::geometry::model::polygon<custom_cartesian_point>;
|
Loading…
x
Reference in New Issue
Block a user