Skip to content

Commit

Permalink
Merge pull request #100 from mapbox/multithread
Browse files Browse the repository at this point in the history
Multithreaded tile generation
  • Loading branch information
e-n-f committed Oct 20, 2015
2 parents 89e1640 + e554a12 commit 3fbd0d6
Show file tree
Hide file tree
Showing 9 changed files with 325 additions and 158 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 1.3.0

* Tile generation is multithreaded to take advantage of multiple CPUs
* More compact data representation reduces memory usage and improves speed
* Polygon clipping uses [Clipper](http://www.angusj.com/delphi/clipper/documentation/Docs/_Body.htm)
and makes sure interior and exterior rings are distinguished by winding order
* Individual GeoJSON features can specify their own minzoom and maxzoom
* New `tile-join` utility can add new properties from a CSV file to an existing tileset
* Feature coalescing, line-reversing, and reordering by attribute are now options, not defaults
* Output of `decode` utility is now in GeoJSON format
* Tile generation with a minzoom spends less time on unused lower zoom levels
* Bare geometries without a Feature wrapper are accepted

## 1.2.0

* Switched to top-down rendering, yielding performance improvements
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ INCLUDES = -I/usr/local/include
LIBS = -L/usr/local/lib

tippecanoe: geojson.o jsonpull.o vector_tile.pb.o tile.o clip.o pool.o mbtiles.o geometry.o projection.o memfile.o clipper/clipper.o
g++ $(PG) $(LIBS) -O3 -g -Wall -o $@ $^ -lm -lz -lprotobuf-lite -lsqlite3
g++ $(PG) $(LIBS) -O3 -g -Wall -o $@ $^ -lm -lz -lprotobuf-lite -lsqlite3 -lpthread

enumerate: enumerate.o
gcc $(PG) $(LIBS) -O3 -g -Wall -o $@ $^ -lsqlite3
Expand Down
1 change: 0 additions & 1 deletion decode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,5 @@ int main(int argc, char **argv) {
usage(argv);
}


return 0;
}
8 changes: 4 additions & 4 deletions geojson.c
Original file line number Diff line number Diff line change
Expand Up @@ -1073,14 +1073,14 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
exit(EXIT_FAILURE);
}

int fd[(1 << MAX_ZOOM_INCREMENT) * (1 << MAX_ZOOM_INCREMENT)];
off_t size[(1 << MAX_ZOOM_INCREMENT) * (1 << MAX_ZOOM_INCREMENT)];
int fd[TEMP_FILES];
off_t size[TEMP_FILES];

fd[0] = geomfd;
size[0] = geomst.st_size;

int j;
for (j = 1; j < (1 << MAX_ZOOM_INCREMENT) * (1 << MAX_ZOOM_INCREMENT); j++) {
for (j = 1; j < TEMP_FILES; j++) {
fd[j] = -1;
size[j] = 0;
}
Expand All @@ -1089,7 +1089,7 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
fprintf(stderr, "%lld features, %lld bytes of geometry, %lld bytes of metadata, %lld bytes of string pool\n", seq, (long long) geomst.st_size, (long long) metast.st_size, poolfile->off);
}

int written = traverse_zooms(fd, size, meta, stringpool, file_bbox, file_keys, &midx, &midy, layernames, maxzoom, minzoom, outdb, droprate, buffer, fname, tmpdir, gamma, nlayers, prevent, additional, full_detail, low_detail, min_detail);
int written = traverse_zooms(fd, size, meta, stringpool, file_keys, &midx, &midy, layernames, maxzoom, minzoom, outdb, droprate, buffer, fname, tmpdir, gamma, nlayers, prevent, additional, full_detail, low_detail, min_detail);

if (maxzoom != written) {
fprintf(stderr, "\n\n\n*** NOTE TILES ONLY COMPLETE THROUGH ZOOM %d ***\n\n\n", written);
Expand Down
10 changes: 5 additions & 5 deletions geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double
if (*accum_area > pixel * pixel) {
// XXX use centroid;

out.push_back(draw(VT_MOVETO, geom[i].x - pixel/2, geom[i].y - pixel/2));
out.push_back(draw(VT_LINETO, geom[i].x + pixel/2, geom[i].y - pixel/2));
out.push_back(draw(VT_LINETO, geom[i].x + pixel/2, geom[i].y + pixel/2));
out.push_back(draw(VT_LINETO, geom[i].x - pixel/2, geom[i].y + pixel/2));
out.push_back(draw(VT_LINETO, geom[i].x - pixel/2, geom[i].y - pixel/2));
out.push_back(draw(VT_MOVETO, geom[i].x - pixel / 2, geom[i].y - pixel / 2));
out.push_back(draw(VT_LINETO, geom[i].x + pixel / 2, geom[i].y - pixel / 2));
out.push_back(draw(VT_LINETO, geom[i].x + pixel / 2, geom[i].y + pixel / 2));
out.push_back(draw(VT_LINETO, geom[i].x - pixel / 2, geom[i].y + pixel / 2));
out.push_back(draw(VT_LINETO, geom[i].x - pixel / 2, geom[i].y - pixel / 2));

*accum_area -= pixel * pixel;
}
Expand Down
23 changes: 12 additions & 11 deletions pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,27 @@ struct pool_val *pool(struct pool *p, const char *s, int type) {
}
}

*v = malloc(sizeof(struct pool_val));
if (*v == NULL) {
struct pool_val *nv = malloc(sizeof(struct pool_val));
if (nv == NULL) {
fprintf(stderr, "out of memory making string pool\n");
exit(EXIT_FAILURE);
}
(*v)->left = NULL;
(*v)->right = NULL;
(*v)->next = NULL;
(*v)->s = s;
(*v)->type = type;
(*v)->n = p->n++;
nv->left = NULL;
nv->right = NULL;
nv->next = NULL;
nv->s = s;
nv->type = type;
nv->n = p->n++;

if (p->tail != NULL) {
p->tail->next = *v;
p->tail->next = nv;
}
p->tail = *v;
p->tail = nv;
if (p->head == NULL) {
p->head = *v;
p->head = nv;
}

*v = nv;
return *v;
}

Expand Down
Loading

0 comments on commit 3fbd0d6

Please sign in to comment.