From 00a42796b4e3bf66d267f1a4aa45d6fc18655ed3 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 23 Sep 2014 10:57:01 -0700 Subject: [PATCH] Use lower resolution at lower zooms. Not sure it's worth it. --- geojson.c | 2 +- tile.cc | 12 +++++------- tile.h | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/geojson.c b/geojson.c index 7153784..22d8497 100644 --- a/geojson.c +++ b/geojson.c @@ -334,7 +334,7 @@ void check(struct index *ix, long long n, char *metabase, unsigned *file_bbox) { printf("%d/%u/%u %x %x %lld to %lld\n", z, tx, ty, wx, wy, (long long)(i - ix), (long long)(j - ix)); - write_tile(i, j, metabase, file_bbox, z, tx, ty); + write_tile(i, j, metabase, file_bbox, z, tx, ty, z == 14 ? 12 : 10); } } } diff --git a/tile.cc b/tile.cc index e004d71..76b0848 100644 --- a/tile.cc +++ b/tile.cc @@ -12,9 +12,6 @@ extern "C" { #include "tile.h" } -#define XMAX 4096 -#define YMAX 4096 - #define CMD_BITS 3 // https://github.com/mapbox/mapnik-vector-tile/blob/master/src/vector_tile_compression.hpp @@ -46,7 +43,7 @@ static inline int compress(std::string const& input, std::string& output) { } -void write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty) { +void write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail) { GOOGLE_PROTOBUF_VERIFY_VERSION; mapnik::vector::tile tile; @@ -54,7 +51,8 @@ void write_tile(struct index *start, struct index *end, char *metabase, unsigned layer->set_name("name"); layer->set_version(1); - layer->set_extent(XMAX); + + layer->set_extent(1 << detail); struct pool keys; keys.n = 0; @@ -124,8 +122,8 @@ void write_tile(struct index *start, struct index *end, char *metabase, unsigned wwy -= ty << (32 - z); } - wwx >>= (32 - 12 - z); - wwy >>= (32 - 12 - z); + wwx >>= (32 - detail - z); + wwy >>= (32 - detail - z); int dx = wwx - px; int dy = wwy - py; diff --git a/tile.h b/tile.h index 9d6f077..7c8945d 100644 --- a/tile.h +++ b/tile.h @@ -47,4 +47,4 @@ struct index { }; -void write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned x, unsigned y); +void write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail);