Skip to content

Commit

Permalink
Make sure NO_INDEX is always used with size_t types
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Dec 4, 2023
1 parent e70050e commit 126c2ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/utils/polygonUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class PolygonUtils
* \param max_dist2 The squared maximal allowed distance from the point to the nearest polygon.
* \return The index to the polygon onto which we have moved the point.
*/
static unsigned int moveInside(const Polygons& polygons, Point2LL& from, int distance = 0, int64_t max_dist2 = std::numeric_limits<int64_t>::max());
static size_t moveInside(const Polygons& polygons, Point2LL& from, int distance = 0, int64_t max_dist2 = std::numeric_limits<int64_t>::max());

/**
* \brief Moves the point \p from onto the nearest polygon or leaves the
Expand Down
6 changes: 3 additions & 3 deletions src/utils/polygonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ ClosestPolygonPoint PolygonUtils::_moveInside2(const ClosestPolygonPoint& closes
/*
* Implementation assumes moving inside, but moving outside should just as well be possible.
*/
unsigned int PolygonUtils::moveInside(const Polygons& polygons, Point2LL& from, int distance, int64_t maxDist2)
size_t PolygonUtils::moveInside(const Polygons& polygons, Point2LL& from, int distance, int64_t maxDist2)
{
Point2LL ret = from;
int64_t bestDist2 = std::numeric_limits<int64_t>::max();
unsigned int bestPoly = NO_INDEX;
size_t bestPoly = NO_INDEX;
bool is_already_on_correct_side_of_boundary = false; // whether [from] is already on the right side of the boundary
for (unsigned int poly_idx = 0; poly_idx < polygons.size(); poly_idx++)
for (size_t poly_idx = 0; poly_idx < polygons.size(); poly_idx++)
{
ConstPolygonRef poly = polygons[poly_idx];
if (poly.size() < 2)
Expand Down

0 comments on commit 126c2ea

Please sign in to comment.