Add --detect-longitude-wraparound option

This commit is contained in:
Eric Fischer
2017-03-15 13:37:50 -07:00
parent bbf9716361
commit ea77e3db6f
8 changed files with 116 additions and 4 deletions
+4
View File
@@ -1,3 +1,7 @@
## 1.16.13
* Add --detect-longitude-wraparound option
## 1.16.12 ## 1.16.12
* Stop processing higher zooms when a feature reaches its explicit maxzoom tag * Stop processing higher zooms when a feature reaches its explicit maxzoom tag
+1
View File
@@ -132,6 +132,7 @@ resolution is obtained than by using a smaller _maxzoom_ or _detail_.
* -ad or --drop-fraction-as-needed: Dynamically drop some fraction of features from each zoom level to keep large tiles under the 500K size limit. (This is like `-pd` but applies to the entire zoom level, not to each tile.) * -ad or --drop-fraction-as-needed: Dynamically drop some fraction of features from each zoom level to keep large tiles under the 500K size limit. (This is like `-pd` but applies to the entire zoom level, not to each tile.)
* -an or --drop-smallest-as-needed: Dynamically drop the smallest features (physically smallest: the shortest lines or the smallest polygons) from each zoom level to keep large tiles under the 500K size limit. This option will not work for point features. * -an or --drop-smallest-as-needed: Dynamically drop the smallest features (physically smallest: the shortest lines or the smallest polygons) from each zoom level to keep large tiles under the 500K size limit. This option will not work for point features.
* -aL or --grid-low-zooms: At all zoom levels below _maxzoom_, snap all lines and polygons to a stairstep grid instead of allowing diagonals. You will also want to specify a tile resolution, probably `-D8`. This option provides a way to display continuous parcel, gridded, or binned data at low zooms without overwhelming the tiles with tiny polygons, since features will either get stretched out to the grid unit or lost entirely, depending on how they happened to be aligned in the original data. * -aL or --grid-low-zooms: At all zoom levels below _maxzoom_, snap all lines and polygons to a stairstep grid instead of allowing diagonals. You will also want to specify a tile resolution, probably `-D8`. This option provides a way to display continuous parcel, gridded, or binned data at low zooms without overwhelming the tiles with tiny polygons, since features will either get stretched out to the grid unit or lost entirely, depending on how they happened to be aligned in the original data.
* -aw or --detect-longitude-wraparound: Detect when adjacent points within a feature jump to the other side of the world, and try to fix the geometry.
### Doing less ### Doing less
+23 -3
View File
@@ -75,7 +75,7 @@ void json_context(json_object *j) {
free(s); // stringify free(s); // stringify
} }
long long parse_geometry(int t, json_object *j, long long *bbox, drawvec &out, int op, const char *fname, int line, int *initialized, unsigned *initial_x, unsigned *initial_y, json_object *feature) { long long parse_geometry(int t, json_object *j, long long *bbox, drawvec &out, int op, const char *fname, int line, int *initialized, unsigned *initial_x, unsigned *initial_y, json_object *feature, long long &prev, long long &offset, bool &has_prev) {
long long g = 0; long long g = 0;
if (j == NULL || j->type != JSON_ARRAY) { if (j == NULL || j->type != JSON_ARRAY) {
@@ -96,7 +96,7 @@ long long parse_geometry(int t, json_object *j, long long *bbox, drawvec &out, i
} }
} }
g += parse_geometry(within, j->array[i], bbox, out, op, fname, line, initialized, initial_x, initial_y, feature); g += parse_geometry(within, j->array[i], bbox, out, op, fname, line, initialized, initial_x, initial_y, feature, prev, offset, has_prev);
} }
} else { } else {
if (j->length >= 2 && j->array[0]->type == JSON_NUMBER && j->array[1]->type == JSON_NUMBER) { if (j->length >= 2 && j->array[0]->type == JSON_NUMBER && j->array[1]->type == JSON_NUMBER) {
@@ -116,6 +116,22 @@ long long parse_geometry(int t, json_object *j, long long *bbox, drawvec &out, i
} }
} }
if (additional[A_DETECT_WRAPAROUND]) {
x += offset;
if (has_prev) {
if (x - prev > (1LL << 31)) {
offset -= 1LL << 32;
x -= 1LL << 32;
} else if (prev - x > (1LL << 31)) {
offset += 1LL << 32;
x += 1LL << 32;
}
}
has_prev = true;
prev = x;
}
if (x < bbox[0]) { if (x < bbox[0]) {
bbox[0] = x; bbox[0] = x;
} }
@@ -351,8 +367,12 @@ int serialize_geometry(json_object *geometry, json_object *properties, json_obje
} }
} }
bool has_prev = false;
long long prev = 0;
long long offset = 0;
drawvec dv; drawvec dv;
long long g = parse_geometry(t, coordinates, bbox, dv, VT_MOVETO, fname, line, initialized, initial_x, initial_y, feature); long long g = parse_geometry(t, coordinates, bbox, dv, VT_MOVETO, fname, line, initialized, initial_x, initial_y, feature, prev, offset, has_prev);
if (mb_geometry[t] == VT_POLYGON) { if (mb_geometry[t] == VT_POLYGON) {
dv = fix_polygon(dv); dv = fix_polygon(dv);
} }
+1
View File
@@ -1940,6 +1940,7 @@ int main(int argc, char **argv) {
{"drop-fraction-as-needed", no_argument, &additional[A_DROP_FRACTION_AS_NEEDED], 1}, {"drop-fraction-as-needed", no_argument, &additional[A_DROP_FRACTION_AS_NEEDED], 1},
{"drop-smallest-as-needed", no_argument, &additional[A_DROP_SMALLEST_AS_NEEDED], 1}, {"drop-smallest-as-needed", no_argument, &additional[A_DROP_SMALLEST_AS_NEEDED], 1},
{"grid-low-zooms", no_argument, &additional[A_GRID_LOW_ZOOMS], 1}, {"grid-low-zooms", no_argument, &additional[A_GRID_LOW_ZOOMS], 1},
{"detect-longitude-wraparound", no_argument, &additional[A_DETECT_WRAPAROUND], 1},
{"no-line-simplification", no_argument, &prevent[P_SIMPLIFY], 1}, {"no-line-simplification", no_argument, &prevent[P_SIMPLIFY], 1},
{"simplify-only-low-zooms", no_argument, &prevent[P_SIMPLIFY_LOW], 1}, {"simplify-only-low-zooms", no_argument, &prevent[P_SIMPLIFY_LOW], 1},
+1
View File
@@ -13,6 +13,7 @@
#define A_DROP_FRACTION_AS_NEEDED ((int) 'd') #define A_DROP_FRACTION_AS_NEEDED ((int) 'd')
#define A_DROP_SMALLEST_AS_NEEDED ((int) 'n') #define A_DROP_SMALLEST_AS_NEEDED ((int) 'n')
#define A_GRID_LOW_ZOOMS ((int) 'L') #define A_GRID_LOW_ZOOMS ((int) 'L')
#define A_DETECT_WRAPAROUND ((int) 'w')
#define P_SIMPLIFY ((int) 's') #define P_SIMPLIFY ((int) 's')
#define P_SIMPLIFY_LOW ((int) 'S') #define P_SIMPLIFY_LOW ((int) 'S')
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
#define VERSION "tippecanoe v1.16.12\n" #define VERSION "tippecanoe v1.16.13\n"