Skip to content

Commit

Permalink
Merge pull request #748 from mapbox/high-longitude
Browse files Browse the repository at this point in the history
Be more consistent about when longitudes beyond 180 are allowed
  • Loading branch information
e-n-f authored Apr 12, 2019
2 parents b147ff2 + 4d3e307 commit 363d21b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.34.2

* Be more consistent about when longitudes beyond 180 are allowed.
Now if the entire feature is beyond 180, it will still appear.

## 1.34.1

* Don't run shell filters if the current zoom is below the minzoom
Expand Down
11 changes: 8 additions & 3 deletions projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ void lonlat2tile(double lon, double lat, int zoom, long long *x, long long *y) {

int lat_class = fpclassify(lat);
int lon_class = fpclassify(lon);
bool bad_lon = false;

if (lat_class == FP_INFINITE || lat_class == FP_NAN) {
lat = 89.9;
}
if (lon_class == FP_INFINITE || lon_class == FP_NAN) {
lon = 360;
// Keep these far enough from the plane that they don't get
// moved back into it by 360-degree offsetting

lon = 720;
bad_lon = true;
}

// Must limit latitude somewhere to prevent overflow.
Expand All @@ -40,10 +45,10 @@ void lonlat2tile(double lon, double lat, int zoom, long long *x, long long *y) {
lat = 89.9;
}

if (lon < -360) {
if (lon < -360 && !bad_lon) {
lon = -360;
}
if (lon > 360) {
if (lon > 360 && !bad_lon) {
lon = 360;
}

Expand Down
1 change: 1 addition & 0 deletions tests/high-longitude/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "hpa": 103200 }, "geometry": { "type": "MultiLineString", "coordinates": [ [ [254,35], [204,35], [204,30], [254,30], [254,35] ] ] } } ] }
25 changes: 25 additions & 0 deletions tests/high-longitude/out/-z1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ "type": "FeatureCollection", "properties": {
"bounds": "-180.000000,30.000000,180.000000,35.000000",
"center": "-90.000000,35.000000,1",
"description": "tests/high-longitude/out/-z1.json.check.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -a@ -f -o tests/high-longitude/out/-z1.json.check.mbtiles -z1 tests/high-longitude/in.json",
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 1, \"fields\": {\"hpa\": \"Number\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 1,\"geometry\": \"LineString\",\"attributeCount\": 1,\"attributes\": [{\"attribute\": \"hpa\",\"count\": 1,\"type\": \"number\",\"values\": [103200],\"min\": 103200,\"max\": 103200}]}]}}",
"maxzoom": "1",
"minzoom": "0",
"name": "tests/high-longitude/out/-z1.json.check.mbtiles",
"type": "overlay",
"version": "2"
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { "hpa": 103200 }, "geometry": { "type": "LineString", "coordinates": [ [ -106.083984, 35.029996 ], [ -156.005859, 35.029996 ], [ -156.005859, 30.069094 ], [ -106.083984, 30.069094 ], [ -106.083984, 35.029996 ] ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { "hpa": 103200 }, "geometry": { "type": "LineString", "coordinates": [ [ -106.040039, 35.029996 ], [ -156.005859, 35.029996 ], [ -156.005859, 30.031055 ], [ -106.040039, 30.031055 ], [ -106.040039, 35.029996 ] ] } }
] }
] }
] }
7 changes: 4 additions & 3 deletions tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,9 +1214,6 @@ struct write_tile_args {

bool clip_to_tile(serial_feature &sf, int z, long long buffer) {
int quick = quick_check(sf.bbox, z, buffer);
if (quick == 0) {
return true;
}

if (z == 0) {
if (sf.bbox[0] <= (1LL << 32) * buffer / 256 || sf.bbox[2] >= (1LL << 32) - ((1LL << 32) * buffer / 256)) {
Expand Down Expand Up @@ -1244,6 +1241,10 @@ bool clip_to_tile(serial_feature &sf, int z, long long buffer) {
}
}

if (quick == 0) {
return true;
}

// Can't accept the quick check if guaranteeing no duplication, since the
// overlap might have been in the buffer.
if (quick != 1 || prevent[P_DUPLICATION]) {
Expand Down
2 changes: 1 addition & 1 deletion version.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP

#define VERSION "v1.34.1"
#define VERSION "v1.34.2"

#endif

0 comments on commit 363d21b

Please sign in to comment.