From 454a5dd3c7233b850000c04bbb5800ec06a1896d Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 23 Sep 2014 13:33:40 -0700 Subject: [PATCH] Index anything that entirely fits within the tile by its centroid --- geojson.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/geojson.c b/geojson.c index 22d8497..9621a17 100644 --- a/geojson.c +++ b/geojson.c @@ -456,10 +456,13 @@ void read_json(FILE *f) { int z = 14; + unsigned cx = bbox[0] / 2 + bbox[2] / 2; + unsigned cy = bbox[1] / 2 + bbox[3] / 2; + /* XXX do proper overlap instead of whole bounding box */ if (z == 0) { struct index ix; - ix.index = encode(0, 0); + ix.index = encode(cx, cy); ix.fpos = start; fwrite_check(&ix, sizeof(struct index), 1, indexfile); } else { @@ -467,7 +470,12 @@ void read_json(FILE *f) { for (x = bbox[0] >> (32 - z); x <= bbox[2] >> (32 - z); x++) { for (y = bbox[1] >> (32 - z); y <= bbox[3] >> (32 - z); y++) { struct index ix; - ix.index = encode(x << (32 - z), y << (32 - z)); + + if (x == cx >> (32 - z) && y == cy >> (32 - z)) { + ix.index = encode(cx, cy); + } else { + ix.index = encode(x << (32 - z), y << (32 - z)); + } ix.fpos = start; fwrite_check(&ix, sizeof(struct index), 1, indexfile); }