Skip to content

Commit

Permalink
Merge pull request #1091 from vissarion/fix/custom_point_issue
Browse files Browse the repository at this point in the history
Fix mutable point issue and typos in boundary_checker.
  • Loading branch information
vissarion authored Nov 16, 2022
2 parents f046734 + c26217e commit e933682
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ inline void copy_boundary_points(Point const& front_pt, Point const& back_pt,
{
mutable_point_type pt;
geometry::convert(front_pt, pt);
boundary_points.push_back(front_pt);
boundary_points.push_back(pt);
}
if (! geometry::has_nan_coordinate(back_pt))
{
mutable_point_type pt;
geometry::convert(back_pt, pt);
boundary_points.push_back(back_pt);
boundary_points.push_back(pt);
}
}
}
Expand Down Expand Up @@ -178,9 +178,11 @@ class boundary_checker<Geometry, Strategy, multi_linestring_tag>
m_is_filled = true;
}

mutable_point_type mpt;
geometry::convert(pt, mpt);
auto const equal_range = std::equal_range(m_boundary_points.begin(),
m_boundary_points.end(),
pt,
mpt,
less_type());

std::size_t const equal_points_count = boost::size(equal_range);
Expand Down
2 changes: 1 addition & 1 deletion test/algorithms/relate/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

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_sph.cpp : : : : algorithms_relate_areal_areal_sph ]
[ run relate_linear_areal.cpp : : : : algorithms_relate_linear_areal ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt)

#include <test_geometries/const_point.hpp>
#include <test_geometries/custom_cartesian_point.hpp>

#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/crosses.hpp>
Expand Down Expand Up @@ -39,7 +40,6 @@ void test_relate_const(Geometry1 const &geometry1, Geometry2 const &geometry2,
BOOST_CHECK_EQUAL(exp_within, bg::within(geometry1, geometry2));
}


int test_main(int, char* [])
{
ring_of_const_point const rectangle{{2, 2}, {2, 4}, {4, 4}, {4, 2}, {2, 2}};
Expand All @@ -59,5 +59,16 @@ int test_main(int, char* [])
// linear/linear
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;
}
1 change: 0 additions & 1 deletion test/test_geometries/const_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ namespace boost { namespace geometry { namespace traits {

}}}


#endif
22 changes: 22 additions & 0 deletions test/test_geometries/custom_cartesian_point.hpp
Original file line number Diff line number Diff line change
@@ -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>;

0 comments on commit e933682

Please sign in to comment.