Skip to content

Commit 0b13ab6

Browse files
committed
remove coordinate_type from closest_point_info as we'd expect closest_point to be represented using FP even when input geometries are defined using integer coordinate_type (e.g std::int64_t)
1 parent 208629c commit 0b13ab6

File tree

5 files changed

+28
-29
lines changed

5 files changed

+28
-29
lines changed

include/boost/geometry/extensions/strategies/cartesian/closest_point.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,14 @@ public :
127127
if (c1 < zero)
128128
{
129129
result.distance = apply_point_point(p, p1);
130-
result.closest_point = p1;
130+
result.closest_point.x = p1.x;
131+
result.closest_point.y = p1.y;
131132
}
132133
else if(c1 > c2)
133134
{
134135
result.distance = apply_point_point(p, p2);
135-
result.closest_point = p2;
136+
result.closest_point.x = p2.x;
137+
result.closest_point.y = p2.y;
136138
}
137139
else
138140
{

include/mapbox/geometry/algorithms/closest_point.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@
22

33
namespace mapbox { namespace geometry { namespace algorithms {
44

5-
template <typename T>
65
struct closest_point_info
76
{
8-
using coordinate_type = T;
97
closest_point_info()
10-
: x(),y(),distance(-1) {}
11-
closest_point_info(coordinate_type x_, coordinate_type y_, double distance_)
8+
: x(), y(), distance(-1) {}
9+
closest_point_info(double x_, double y_, double distance_)
1210
: x(x_),
1311
y(y_),
1412
distance(distance_) {}
15-
coordinate_type x;
16-
coordinate_type y;
13+
double x;
14+
double y;
1715
double distance;
1816
};
1917

2018
template <typename T1, typename T2>
21-
auto closest_point(T1 const& geom, mapbox::geometry::point<T2> const& pt)->closest_point_info<T2>;
22-
19+
closest_point_info closest_point(T1 const& geom, mapbox::geometry::point<T2> const& pt);
2320
}}}

include/mapbox/geometry/algorithms/closest_point_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ template <typename T>
1111
struct closest_point
1212
{
1313
using coordinate_type = T;
14-
using info_type = boost::geometry::closest_point_result<mapbox::geometry::point<coordinate_type>>;
15-
using result_type = closest_point_info<coordinate_type>;
14+
using info_type = boost::geometry::closest_point_result<mapbox::geometry::point<double>>;
15+
using result_type = closest_point_info;
1616
closest_point(mapbox::geometry::point<coordinate_type> const& pt)
1717
: pt_(pt) {}
1818

@@ -90,7 +90,7 @@ struct closest_point
9090
}
9191

9292
template <typename T1, typename T2>
93-
auto closest_point(T1 const& geom, mapbox::geometry::point<T2> const& pt)->closest_point_info<T2>
93+
closest_point_info closest_point(T1 const& geom, mapbox::geometry::point<T2> const& pt)
9494
{
9595
return detail::closest_point<T2>(pt)(geom);
9696
}

src/closest_point_d.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
namespace mapbox { namespace geometry { namespace algorithms {
66

7-
template closest_point_info<double> closest_point(geometry<double> const&, point<double> const&);
8-
template closest_point_info<double> closest_point(point<double> const&, point<double> const&);
9-
template closest_point_info<double> closest_point(line_string<double> const&, point<double> const&);
10-
template closest_point_info<double> closest_point(polygon<double>const&, point<double> const&);
11-
template closest_point_info<double> closest_point(multi_point<double>const&, point<double> const&);
12-
template closest_point_info<double> closest_point(multi_line_string<double>const&, point<double> const&);
13-
template closest_point_info<double> closest_point(multi_polygon<double>const&, point<double> const&);
14-
template closest_point_info<double> closest_point(geometry_collection<double> const&, point<double> const&);
7+
template closest_point_info closest_point(geometry<double> const&, point<double> const&);
8+
template closest_point_info closest_point(point<double> const&, point<double> const&);
9+
template closest_point_info closest_point(line_string<double> const&, point<double> const&);
10+
template closest_point_info closest_point(polygon<double>const&, point<double> const&);
11+
template closest_point_info closest_point(multi_point<double>const&, point<double> const&);
12+
template closest_point_info closest_point(multi_line_string<double>const&, point<double> const&);
13+
template closest_point_info closest_point(multi_polygon<double>const&, point<double> const&);
14+
template closest_point_info closest_point(geometry_collection<double> const&, point<double> const&);
1515

1616
}}}

src/closest_point_i64.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
namespace mapbox { namespace geometry { namespace algorithms {
66

7-
template closest_point_info<std::int64_t> closest_point(geometry<std::int64_t> const&, point<std::int64_t> const&);
8-
template closest_point_info<std::int64_t> closest_point(point<std::int64_t> const&, point<std::int64_t> const&);
9-
template closest_point_info<std::int64_t> closest_point(line_string<std::int64_t> const&, point<std::int64_t> const&);
10-
template closest_point_info<std::int64_t> closest_point(polygon<std::int64_t>const&, point<std::int64_t> const&);
11-
template closest_point_info<std::int64_t> closest_point(multi_point<std::int64_t>const&, point<std::int64_t> const&);
12-
template closest_point_info<std::int64_t> closest_point(multi_line_string<std::int64_t>const&, point<std::int64_t> const&);
13-
template closest_point_info<std::int64_t> closest_point(multi_polygon<std::int64_t>const&, point<std::int64_t> const&);
14-
template closest_point_info<std::int64_t> closest_point(geometry_collection<std::int64_t> const&, point<std::int64_t> const&);
7+
template closest_point_info closest_point(geometry<std::int64_t> const&, point<std::int64_t> const&);
8+
template closest_point_info closest_point(point<std::int64_t> const&, point<std::int64_t> const&);
9+
template closest_point_info closest_point(line_string<std::int64_t> const&, point<std::int64_t> const&);
10+
template closest_point_info closest_point(polygon<std::int64_t>const&, point<std::int64_t> const&);
11+
template closest_point_info closest_point(multi_point<std::int64_t>const&, point<std::int64_t> const&);
12+
template closest_point_info closest_point(multi_line_string<std::int64_t>const&, point<std::int64_t> const&);
13+
template closest_point_info closest_point(multi_polygon<std::int64_t>const&, point<std::int64_t> const&);
14+
template closest_point_info closest_point(geometry_collection<std::int64_t> const&, point<std::int64_t> const&);
1515

1616
}}}

0 commit comments

Comments
 (0)