mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-04-27 06:20:04 +00:00
Keep a file bounding box to know the area that needs to be tiled
This commit is contained in:
parent
14e7b648ed
commit
e8adeba40e
15
geojson.c
15
geojson.c
@ -291,6 +291,8 @@ void read_json(FILE *f) {
|
||||
FILE *indexfile = fopen("index.out", "wb");
|
||||
long long fpos = 0;
|
||||
|
||||
unsigned file_bbox[] = { UINT_MAX, UINT_MAX, 0, 0 };
|
||||
|
||||
while (1) {
|
||||
json_object *j = json_read(jp);
|
||||
if (j == NULL) {
|
||||
@ -387,6 +389,17 @@ void read_json(FILE *f) {
|
||||
serialize_int(metafile, t, &fpos);
|
||||
parse_geometry(t, coordinates, bbox, &fpos, metafile, VT_MOVETO);
|
||||
serialize_int(metafile, VT_END, &fpos);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (bbox[i] < file_bbox[i]) {
|
||||
file_bbox[i] = bbox[i];
|
||||
}
|
||||
}
|
||||
for (i = 2; i < 4; i++) {
|
||||
if (bbox[i] > file_bbox[i]) {
|
||||
file_bbox[i] = bbox[i];
|
||||
}
|
||||
}
|
||||
|
||||
// printf("bbox %x %x %x %x\n", bbox[0], bbox[1], bbox[2], bbox[3]);
|
||||
|
||||
@ -402,6 +415,8 @@ next_feature:
|
||||
/* XXX check for any non-features in the outer object */
|
||||
}
|
||||
|
||||
printf("bbox: %x %x %x %x\n", file_bbox[0], file_bbox[1], file_bbox[2], file_bbox[3]);
|
||||
|
||||
json_end(jp);
|
||||
fclose(metafile);
|
||||
fclose(indexfile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user