Fix the major bug: forgetting to offset back to world coordinates

This commit is contained in:
Eric Fischer 2014-12-04 14:08:36 -08:00
parent b7b476b36c
commit 028fef470e
2 changed files with 11 additions and 4 deletions

View File

@ -212,7 +212,7 @@ struct pool_val *deserialize_string(char **f, struct pool *p, int type) {
void check(int geomfd, off_t geom_size, char *metabase, unsigned *file_bbox, struct pool *file_keys, unsigned *midx, unsigned *midy, const char *layername, int maxzoom, int minzoom, sqlite3 *outdb, double droprate, int buffer, const char *fname, struct json_pull *jp, const char *tmpdir) {
int i;
for (i = 0; i < maxzoom; i++) {
for (i = 0; i <= maxzoom; i++) {
fprintf(stderr, "\n");
long long most = 0;

13
tile.cc
View File

@ -370,7 +370,6 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u
while (1) {
int t;
deserialize_int(geoms, &t);
printf("geometry %d\n", t);
if (t < 0) {
break;
}
@ -420,6 +419,13 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u
within = 1;
}
// Offset from tile coordinates back to world coordinates
unsigned sx = 0, sy = 0;
if (z != 0) {
sx = tx << (32 - z);
sy = ty << (32 - z);
}
//printf("type %d, meta %lld\n", t, metastart);
serialize_int(geomfile, t, &geompos, fname, jp);
serialize_long_long(geomfile, metastart, &geompos, fname, jp);
@ -428,8 +434,8 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u
serialize_byte(geomfile, geom[u].op, &geompos, fname, jp);
if (geom[u].op != VT_CLOSEPATH) {
serialize_uint(geomfile, geom[u].x, &geompos, fname, jp);
serialize_uint(geomfile, geom[u].y, &geompos, fname, jp);
serialize_uint(geomfile, geom[u].x + sx, &geompos, fname, jp);
serialize_uint(geomfile, geom[u].y + sy, &geompos, fname, jp);
}
}
@ -548,6 +554,7 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u
evaluate(features, metabase, file_keys, layername, line_detail, compressed.size());
}
} else {
printf("output %d/%u/%u\n", z, tx, ty);
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
return count;
}