From 2e3f03172e2749a1fba5909cb60300192c2a9fea Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 20 Aug 2015 15:01:34 -0700 Subject: [PATCH] Write out the JSON part of the metadata --- Makefile | 2 +- tile-join.cc | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f181e63..0538346 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ enumerate: enumerate.o decode: decode.o vector_tile.pb.o projection.o g++ $(PG) $(LIBS) -O3 -g -Wall -o $@ $^ -lm -lz -lprotobuf-lite -lsqlite3 -tile-join: tile-join.o vector_tile.pb.o projection.o pool.o +tile-join: tile-join.o vector_tile.pb.o projection.o pool.o mbtiles.o g++ $(PG) $(LIBS) -O3 -g -Wall -o $@ $^ -lm -lz -lprotobuf-lite -lsqlite3 libjsonpull.a: jsonpull.o diff --git a/tile-join.cc b/tile-join.cc index 89f9e8c..71ff9fc 100644 --- a/tile-join.cc +++ b/tile-join.cc @@ -14,6 +14,7 @@ extern "C" { #include "projection.h" #include "pool.h" +#include "mbtiles.h" } // https://github.com/mapbox/mapnik-vector-tile/blob/master/src/vector_tile_compression.hpp @@ -170,8 +171,6 @@ void handle(std::string message, int z, unsigned x, unsigned y, struct pool **fi outfeature->add_tags(k->n); outfeature->add_tags(v->n); - - printf("%d: %s=%s %d=%d\n", type, key, value, k->n, v->n); free(value); } } @@ -205,7 +204,7 @@ void decode(char *fname, char *map, struct pool **file_keys, char ***layernames, int len = sqlite3_column_bytes(stmt, 3); const char *s = (const char *) sqlite3_column_blob(stmt, 3); - printf("found %lld/%lld/%lld\n", zoom, x, y); + printf("%lld/%lld/%lld \r", zoom, x, y); handle(std::string(s, len), zoom, x, y, file_keys, layernames, nlayers); } @@ -250,6 +249,12 @@ int main(int argc, char **argv) { usage(argv); } + if (force) { + unlink(outfile); + } + + sqlite3 *outdb = mbtiles_open(outfile, argv); + struct pool *file_keys = NULL; char **layernames = NULL; int nlayers = 0; @@ -260,5 +265,8 @@ int main(int argc, char **argv) { printf("%s\n", layernames[i]); } + mbtiles_write_metadata(outdb, outfile, layernames, 0, 0, 0, 0, 0, 0, 0, 0, &file_keys, nlayers); + mbtiles_close(outdb, argv); + return 0; }