Hardcode layer name a little less.

This commit is contained in:
Eric Fischer 2014-09-24 23:22:14 -07:00
parent dc7c58169f
commit 0b23e65803
3 changed files with 9 additions and 7 deletions

View File

@ -323,7 +323,7 @@ void range_search(struct index *ix, long long n, unsigned long long start, unsig
}
}
void check(struct index *ix, long long n, char *metabase, unsigned *file_bbox, struct pool *file_keys, unsigned *midx, unsigned *midy) {
void check(struct index *ix, long long n, char *metabase, unsigned *file_bbox, struct pool *file_keys, unsigned *midx, unsigned *midy, char *layername) {
fprintf(stderr, "\n");
long long most = 0;
@ -359,7 +359,7 @@ void check(struct index *ix, long long n, char *metabase, unsigned *file_bbox, s
printf("%d/%u/%u %x %x %lld to %lld\n", z, tx, ty, wx, wy, (long long)(i - ix), (long long)(j - ix));
long long len = write_tile(i, j, metabase, file_bbox, z, tx, ty, z == BASE_ZOOM ? 12 : 10, BASE_ZOOM, file_keys);
long long len = write_tile(i, j, metabase, file_bbox, z, tx, ty, z == BASE_ZOOM ? 12 : 10, BASE_ZOOM, file_keys, layername);
if (z == BASE_ZOOM && len > most) {
*midx = tx;
@ -578,8 +578,10 @@ next_feature:
file_keys.head = NULL;
file_keys.tail = NULL;
char *layername = "name";
qsort(index, indexst.st_size / sizeof(struct index), sizeof(struct index), indexcmp);
check(index, indexst.st_size / sizeof(struct index), meta, file_bbox, &file_keys, &midx, &midy);
check(index, indexst.st_size / sizeof(struct index), meta, file_bbox, &file_keys, &midx, &midy, layername);
munmap(index, indexst.st_size);
munmap(meta, metast.st_size);
@ -621,7 +623,7 @@ next_feature:
fprintf(fp, "\"json\": \"{");
fprintf(fp, "\\\"vector_layers\\\": [ { \\\"id\\\": \\\"");
quote(fp, "name");
quote(fp, layername);
fprintf(fp, "\\\", \\\"description\\\": \\\"\\\", \\\"minzoom\\\": %d, \\\"maxzoom\\\": %d, \\\"fields\\\": {", MIN_ZOOM, BASE_ZOOM);
struct pool_val *pv;

View File

@ -380,13 +380,13 @@ int simplify_lines(struct draw *geom, int n, int z, int detail) {
return out;
}
long long write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail, int basezoom, struct pool *file_keys) {
long long write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail, int basezoom, struct pool *file_keys, char *layername) {
GOOGLE_PROTOBUF_VERIFY_VERSION;
mapnik::vector::tile tile;
mapnik::vector::tile_layer *layer = tile.add_layers();
layer->set_name("name");
layer->set_name(layername);
layer->set_version(1);
layer->set_extent(1 << detail);

2
tile.h
View File

@ -49,4 +49,4 @@ struct index {
};
long long write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail, int basezoom, struct pool *file_keys);
long long write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail, int basezoom, struct pool *file_keys, char *layername);