From 91eefcbd168d7128c5f75c0485e9c16c3c994d8a Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 23 Sep 2014 14:42:17 -0700 Subject: [PATCH] Drop more points at each lower zoom level --- geojson.c | 6 ++++-- tile.cc | 20 +++++++++++++++++++- tile.h | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/geojson.c b/geojson.c index d8cf465..8d02bc3 100644 --- a/geojson.c +++ b/geojson.c @@ -14,6 +14,8 @@ #include "jsonpull.h" #include "tile.h" +#define BASE_ZOOM 14 + #define GEOM_POINT 0 /* array of positions */ #define GEOM_MULTIPOINT 1 /* array of arrays of positions */ #define GEOM_LINESTRING 2 /* array of arrays of positions */ @@ -303,7 +305,7 @@ void check(struct index *ix, long long n, char *metabase, unsigned *file_bbox) { fprintf(stderr, "\n"); int z; - for (z = 14; z >= 0; z--) { + for (z = BASE_ZOOM; z >= 0; z--) { struct index *i, *j = NULL; for (i = ix; i < ix + n && i != NULL; i = j) { unsigned wx, wy; @@ -334,7 +336,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, z == 14 ? 12 : 10); + write_tile(i, j, metabase, file_bbox, z, tx, ty, z == BASE_ZOOM ? 12 : 10, BASE_ZOOM); } } } diff --git a/tile.cc b/tile.cc index 3a30cb0..9d28229 100644 --- a/tile.cc +++ b/tile.cc @@ -6,6 +6,7 @@ #include #include #include +#include #include "vector_tile.pb.h" extern "C" { @@ -121,7 +122,7 @@ int draw(char **meta, mapnik::vector::tile_feature *feature, int z, unsigned tx, } -void write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail) { +void write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail, int basezoom) { GOOGLE_PROTOBUF_VERIFY_VERSION; mapnik::vector::tile tile; @@ -144,6 +145,13 @@ void write_tile(struct index *start, struct index *end, char *metabase, unsigned values.head = NULL; values.tail = NULL; + double interval = 1; + double seq = 0; + + if (z < basezoom) { + interval = exp(log(2.5) * (basezoom - z)); + } + struct index *i; for (i = start; i < end; i++) { int t; @@ -151,6 +159,16 @@ void write_tile(struct index *start, struct index *end, char *metabase, unsigned char *meta = metabase + i->fpos; deserialize_int(&meta, &t); + if (t == VT_POINT) { + seq++; + + if (seq >= 0) { + seq -= interval; + } else { + continue; + } + } + if (t == VT_POINT || draw(&meta, NULL, z, tx, ty, detail)) { meta = metabase + i->fpos; deserialize_int(&meta, &t); diff --git a/tile.h b/tile.h index 7c8945d..5ecd231 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, int detail); +void write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail, int basezoom);