Skip to content

Commit

Permalink
Fix accidental inclusion of the top left of the tile in the bbox
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Dec 20, 2024
1 parent 632d031 commit b87d8e4
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 33 deletions.
4 changes: 2 additions & 2 deletions tests/feature-filter/out/filtered.json.standard
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-180.000000,0.000000,0.966797,85.051129",
"bounds": "-180.000000,0.000000,0.966797,85.051129",
"antimeridian_adjusted_bounds": "-100.019531,0.000000,0.966797,0.966751",
"bounds": "-100.019531,0.000000,0.966797,0.966751",
"center": "0.000000,0.000000,0",
"description": "tests/feature-filter/out/all.mbtiles",
"format": "pbf",
Expand Down
4 changes: 2 additions & 2 deletions tests/join-population/joined-i.mbtiles.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-135.000000,37.881357,-122.280579,40.979898",
"bounds": "-135.000000,37.881357,-122.280579,40.979898",
"antimeridian_adjusted_bounds": "-122.309418,37.881357,-122.280579,37.900865",
"bounds": "-122.309418,37.881357,-122.280579,37.900865",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",
Expand Down
4 changes: 2 additions & 2 deletions tests/join-population/joined-no-tile-stats.mbtiles.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-135.000000,37.874853,-122.280579,40.979898",
"bounds": "-135.000000,37.874853,-122.280579,40.979898",
"antimeridian_adjusted_bounds": "-122.343750,37.874853,-122.280579,37.900865",
"bounds": "-122.343750,37.874853,-122.280579,37.900865",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",
Expand Down
4 changes: 2 additions & 2 deletions tests/join-population/joined-null.mbtiles.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-135.000000,37.874853,-122.280579,40.979898",
"bounds": "-135.000000,37.874853,-122.280579,40.979898",
"antimeridian_adjusted_bounds": "-122.343750,37.874853,-122.280579,37.900865",
"bounds": "-122.343750,37.874853,-122.280579,37.900865",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-135.000000,37.874853,-122.280579,40.979898",
"bounds": "-135.000000,37.874853,-122.280579,40.979898",
"antimeridian_adjusted_bounds": "-122.343750,37.874853,-122.280579,37.900865",
"bounds": "-122.343750,37.874853,-122.280579,37.900865",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-135.000000,37.874853,-122.280579,40.979898",
"bounds": "-135.000000,37.874853,-122.280579,40.979898",
"antimeridian_adjusted_bounds": "-122.343750,37.874853,-122.280579,37.900865",
"bounds": "-122.343750,37.874853,-122.280579,37.900865",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-135.000000,37.874853,-122.280579,40.979898",
"bounds": "-135.000000,37.874853,-122.280579,40.979898",
"antimeridian_adjusted_bounds": "-122.343750,37.874853,-122.280579,37.900865",
"bounds": "-122.343750,37.874853,-122.280579,37.900865",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",
Expand Down
4 changes: 2 additions & 2 deletions tests/join-population/joined.mbtiles.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-135.000000,37.874853,-122.280579,40.979898",
"bounds": "-135.000000,37.874853,-122.280579,40.979898",
"antimeridian_adjusted_bounds": "-122.343750,37.874853,-122.280579,37.900865",
"bounds": "-122.343750,37.874853,-122.280579,37.900865",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",
Expand Down
4 changes: 2 additions & 2 deletions tests/join-population/merged-folder.mbtiles.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-135.000000,37.694688,-122.103424,40.979898",
"bounds": "-135.000000,37.694688,-122.103424,40.979898",
"antimeridian_adjusted_bounds": "-122.343750,37.694688,-122.103424,37.900865",
"bounds": "-122.343750,37.694688,-122.103424,37.900865",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420-folder",
"format": "pbf",
Expand Down
4 changes: 2 additions & 2 deletions tests/join-population/merged.mbtiles.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-135.000000,37.694688,-122.103424,40.979898",
"bounds": "-135.000000,37.694688,-122.103424,40.979898",
"antimeridian_adjusted_bounds": "-122.343750,37.694688,-122.103424,37.900865",
"bounds": "-122.343750,37.694688,-122.103424,37.900865",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",
Expand Down
4 changes: 2 additions & 2 deletions tests/join-population/no-macarthur.mbtiles.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-135.000000,37.874853,-122.280579,40.979898",
"bounds": "-135.000000,37.874853,-122.280579,40.979898",
"antimeridian_adjusted_bounds": "-122.343750,37.874853,-122.280579,37.900865",
"bounds": "-122.343750,37.874853,-122.280579,37.900865",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",
Expand Down
4 changes: 2 additions & 2 deletions tests/join-population/raw-merged-folder.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-135.000000,37.694688,-122.103424,40.979898",
"bounds": "-135.000000,37.694688,-122.103424,40.979898",
"antimeridian_adjusted_bounds": "-122.343750,37.694688,-122.103424,37.900865",
"bounds": "-122.343750,37.694688,-122.103424,37.900865",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",
Expand Down
20 changes: 11 additions & 9 deletions tile-join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,17 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
}

for (auto const &g : outfeature.geometry) {
// pin to the tile extent, since we don't want bounds bigger than the earth
long long gx = std::min((long long) outlayer.extent, std::max(0LL, g.x));
long long gy = std::min((long long) outlayer.extent, std::max(0LL, g.y));

// initially keep bounds in tile coordinates
minx = std::min(minx, gx);
miny = std::min(miny, gy);
maxx = std::max(maxx, gx);
maxy = std::max(maxy, gy);
if (g.op == mvt_moveto || g.op == mvt_lineto) {
// pin to the tile extent, since we don't want bounds bigger than the earth
long long gx = std::min((long long) outlayer.extent, std::max(0LL, g.x));
long long gy = std::min((long long) outlayer.extent, std::max(0LL, g.y));

// initially keep bounds in tile coordinates
minx = std::min(minx, gx);
miny = std::min(miny, gy);
maxx = std::max(maxx, gx);
maxy = std::max(maxy, gy);
}
}

features_added++;
Expand Down

0 comments on commit b87d8e4

Please sign in to comment.