mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-04-01 16:30:35 +00:00
Segment the file into input chunks. Allow commas at the top level.
This commit is contained in:
parent
ed90c7b53a
commit
2159d464d0
26
geojson.c
26
geojson.c
@ -903,10 +903,28 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
||||
}
|
||||
|
||||
if (map != NULL && map != MAP_FAILED) {
|
||||
jp = json_begin_map(map, st.st_size - off);
|
||||
parse_json(jp, reading, &seq, &metapos, &geompos, &indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, maxzoom, basezoom, source, droprate, file_bbox);
|
||||
free(jp->source);
|
||||
json_end(jp);
|
||||
#define THREADS 10
|
||||
long long segs[THREADS + 1];
|
||||
segs[0] = 0;
|
||||
segs[THREADS] = st.st_size - off;
|
||||
|
||||
int i;
|
||||
for (i = 1; i < THREADS; i++) {
|
||||
segs[i] = off + (st.st_size - off) * i / THREADS;
|
||||
|
||||
while (segs[i] < st.st_size && map[segs[i]] != '\n') {
|
||||
segs[i]++;
|
||||
}
|
||||
|
||||
printf("%d %lld\n", i, segs[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < THREADS; i++) {
|
||||
jp = json_begin_map(map + segs[i], segs[i + 1] - segs[i]);
|
||||
parse_json(jp, reading, &seq, &metapos, &geompos, &indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, maxzoom, basezoom, source, droprate, file_bbox);
|
||||
free(jp->source);
|
||||
json_end(jp);
|
||||
}
|
||||
} else {
|
||||
FILE *fp = fdopen(fd, "r");
|
||||
if (fp == NULL) {
|
||||
|
23
jsonpull.c
23
jsonpull.c
@ -332,20 +332,17 @@ again:
|
||||
/////////////////////////// Comma
|
||||
|
||||
if (c == ',') {
|
||||
if (j->container == NULL) {
|
||||
j->error = "Found comma at top level";
|
||||
return NULL;
|
||||
}
|
||||
if (j->container != NULL) {
|
||||
if (j->container->expect != JSON_COMMA) {
|
||||
j->error = "Found unexpected comma";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (j->container->expect != JSON_COMMA) {
|
||||
j->error = "Found unexpected comma";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (j->container->type == JSON_HASH) {
|
||||
j->container->expect = JSON_KEY;
|
||||
} else {
|
||||
j->container->expect = JSON_ITEM;
|
||||
if (j->container->type == JSON_HASH) {
|
||||
j->container->expect = JSON_KEY;
|
||||
} else {
|
||||
j->container->expect = JSON_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
if (cb != NULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user