From 4b171c74b714dd6e2e7c2f36d059cc1936491d58 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Sun, 26 Oct 2014 13:12:29 -0700 Subject: [PATCH] Constrain calculated center point to be within the bounding box It could come out bigger because it is calculated from the center of the densest tile, not actually the centroid. --- geojson.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/geojson.c b/geojson.c index 1c094f82..a2f63dd9 100644 --- a/geojson.c +++ b/geojson.c @@ -468,6 +468,19 @@ next_feature: tile2latlon(file_bbox[0], file_bbox[1], 32, &maxlat, &minlon); tile2latlon(file_bbox[2], file_bbox[3], 32, &minlat, &maxlon); + if (midlat < minlat) { + midlat = minlat; + } + if (midlat > maxlat) { + midlat = maxlat; + } + if (midlon < minlon) { + midlon = minlon; + } + if (midlon > maxlon) { + midlon = maxlon; + } + mbtiles_write_metadata(outdb, fname, layername, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, &file_keys); pool_free_strings(&file_keys);