mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Move whole tile-producing function onto the C++ side
This commit is contained in:
@@ -114,13 +114,6 @@ void *search(const void *key, const void *base, size_t nel, size_t width,
|
|||||||
return ((char *) base) + low * width;
|
return ((char *) base) + low * width;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct index {
|
|
||||||
unsigned long long index;
|
|
||||||
long long fpos;
|
|
||||||
|
|
||||||
struct index *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
int indexcmp(const void *v1, const void *v2) {
|
int indexcmp(const void *v1, const void *v2) {
|
||||||
const struct index *i1 = v1;
|
const struct index *i1 = v1;
|
||||||
const struct index *i2 = v2;
|
const struct index *i2 = v2;
|
||||||
@@ -289,62 +282,6 @@ void range_search(struct index *ix, long long n, unsigned long long start, unsig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_range(struct index *start, struct index *end, char *metabase, unsigned *file_bbox) {
|
|
||||||
struct pool keys;
|
|
||||||
keys.n = 0;
|
|
||||||
keys.vals = NULL;
|
|
||||||
|
|
||||||
struct index *i;
|
|
||||||
printf("tile -----------------------------------------------\n");
|
|
||||||
for (i = start; i < end; i++) {
|
|
||||||
printf("%llx ", i->index);
|
|
||||||
|
|
||||||
char *meta = metabase + i->fpos;
|
|
||||||
|
|
||||||
int t;
|
|
||||||
deserialize_int(&meta, &t);
|
|
||||||
printf("(%d) ", t);
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
deserialize_int(&meta, &t);
|
|
||||||
|
|
||||||
if (t == VT_END) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("%d: ", t);
|
|
||||||
|
|
||||||
if (t == VT_MOVETO || t == VT_LINETO) {
|
|
||||||
int x, y;
|
|
||||||
deserialize_int(&meta, &x);
|
|
||||||
deserialize_int(&meta, &y);
|
|
||||||
|
|
||||||
double lat, lon;
|
|
||||||
tile2latlon(x, y, 32, &lat,&lon);
|
|
||||||
printf("%f,%f (%x/%x) ", lat, lon, x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int m;
|
|
||||||
deserialize_int(&meta, &m);
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < m; i++) {
|
|
||||||
int t;
|
|
||||||
deserialize_int(&meta, &t);
|
|
||||||
struct pool_val *key = deserialize_string(&meta, &keys, VT_STRING);
|
|
||||||
struct pool_val *value = deserialize_string(&meta, &keys, t);
|
|
||||||
|
|
||||||
printf("%s (%d) = %s (%d)\n", key->s, key->n, value->s, value->n);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
write_tile("layer", &keys);
|
|
||||||
pool_free(&keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
void check(struct index *ix, long long n, char *metabase, unsigned *file_bbox) {
|
void check(struct index *ix, long long n, char *metabase, unsigned *file_bbox) {
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
|
|||||||
@@ -39,13 +39,13 @@ static inline int compress(std::string const& input, std::string& output) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_tile(char *name, struct pool *keys) {
|
void write_tile(const char *name, struct pool *keys) {
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||||
|
|
||||||
mapnik::vector::tile tile;
|
mapnik::vector::tile tile;
|
||||||
mapnik::vector::tile_layer *layer = tile.add_layers();
|
mapnik::vector::tile_layer *layer = tile.add_layers();
|
||||||
|
|
||||||
layer->set_name("name");
|
layer->set_name(name);
|
||||||
layer->set_version(1);
|
layer->set_version(1);
|
||||||
layer->set_extent(XMAX);
|
layer->set_extent(XMAX);
|
||||||
|
|
||||||
@@ -68,3 +68,60 @@ void write_tile(char *name, struct pool *keys) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void check_range(struct index *start, struct index *end, char *metabase, unsigned *file_bbox) {
|
||||||
|
struct pool keys;
|
||||||
|
keys.n = 0;
|
||||||
|
keys.vals = NULL;
|
||||||
|
|
||||||
|
struct index *i;
|
||||||
|
printf("tile -----------------------------------------------\n");
|
||||||
|
for (i = start; i < end; i++) {
|
||||||
|
printf("%llx ", i->index);
|
||||||
|
|
||||||
|
char *meta = metabase + i->fpos;
|
||||||
|
|
||||||
|
int t;
|
||||||
|
deserialize_int(&meta, &t);
|
||||||
|
printf("(%d) ", t);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
deserialize_int(&meta, &t);
|
||||||
|
|
||||||
|
if (t == VT_END) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d: ", t);
|
||||||
|
|
||||||
|
if (t == VT_MOVETO || t == VT_LINETO) {
|
||||||
|
int x, y;
|
||||||
|
deserialize_int(&meta, &x);
|
||||||
|
deserialize_int(&meta, &y);
|
||||||
|
|
||||||
|
//double lat, lon;
|
||||||
|
//tile2latlon(x, y, 32, &lat,&lon);
|
||||||
|
//printf("%f,%f (%x/%x) ", lat, lon, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int m;
|
||||||
|
deserialize_int(&meta, &m);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < m; i++) {
|
||||||
|
int t;
|
||||||
|
deserialize_int(&meta, &t);
|
||||||
|
struct pool_val *key = deserialize_string(&meta, &keys, VT_STRING);
|
||||||
|
struct pool_val *value = deserialize_string(&meta, &keys, t);
|
||||||
|
|
||||||
|
printf("%s (%d) = %s (%d)\n", key->s, key->n, value->s, value->n);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
write_tile("layer", &keys);
|
||||||
|
pool_free(&keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#define VT_END 0
|
||||||
|
#define VT_POINT 1
|
||||||
|
#define VT_LINE 2
|
||||||
|
#define VT_POLYGON 3
|
||||||
|
|
||||||
|
#define VT_MOVETO 1
|
||||||
|
#define VT_LINETO 2
|
||||||
|
#define VT_CLOSEPATH 7
|
||||||
|
|
||||||
|
#define VT_STRING 1
|
||||||
|
#define VT_NUMBER 2
|
||||||
|
#define VT_BOOLEAN 7
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct pool_val {
|
||||||
|
char *s;
|
||||||
|
int type;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
struct pool_val *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pool {
|
||||||
|
struct pool_val *vals;
|
||||||
|
int n;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void deserialize_int(char **f, int *n);
|
||||||
|
struct pool_val *deserialize_string(char **f, struct pool *p, int type);
|
||||||
|
void pool_free(struct pool *p);
|
||||||
|
|
||||||
|
|
||||||
|
struct index {
|
||||||
|
unsigned long long index;
|
||||||
|
long long fpos;
|
||||||
|
|
||||||
|
struct index *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void write_tile(char *name, struct pool *keys);
|
||||||
|
void check_range(struct index *start, struct index *end, char *metabase, unsigned *file_bbox);
|
||||||
Reference in New Issue
Block a user