Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Address review finding
Browse files Browse the repository at this point in the history
Remove unncessary condition check
  • Loading branch information
zmiao committed Mar 25, 2020
1 parent bdbfe71 commit f764219
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions src/mbgl/style/expression/within.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,19 @@ MultiPolygon<int64_t> getTilePolygons(const Feature::geometry_type& polygonGeoSe
}

void updatePoint(Point<int64_t>& p, WithinBBox& bbox, const WithinBBox& polyBBox, const int64_t worldSize) {
if (p.x <= polyBBox[0] || p.x >= polyBBox[2]) {
int64_t shift = 0;
shift = (p.x - polyBBox[0] > worldSize / 2) ? -worldSize : (polyBBox[0] - p.x > worldSize / 2) ? worldSize : 0;
if (shift == 0) {
shift =
(p.x - polyBBox[2] > worldSize / 2) ? -worldSize : (polyBBox[2] - p.x > worldSize / 2) ? worldSize : 0;
}
if (p.x < polyBBox[0] || p.x > polyBBox[2]) {
const auto getShift = [](Point<int64_t>& point, const int64_t polygonSide, const int64_t size) -> int64_t {
if (point.x - polygonSide > size / 2) {
return -size;
}
if (polygonSide - point.x > size / 2) {
return size;
}
return 0;
};

int64_t shift = getShift(p, polyBBox[0], worldSize);
if (shift == 0) shift = getShift(p, polyBBox[2], worldSize);
p.x += shift;
}
updateBBox(bbox, p);
Expand Down
2 changes: 1 addition & 1 deletion test/style/property_expression.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ TEST(PropertyExpression, WithinExpression) {
}
}

TEST(PropertyExpression, WithinExpressionAntiMeridain) {
TEST(PropertyExpression, WithinExpressionAntiMeridian) {
CanonicalTileID canonicalTileID(0, 0, 0);

// evaluation test with line geometries
Expand Down

0 comments on commit f764219

Please sign in to comment.