mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Write string pool to tile
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "jsonpull.h"
|
#include "jsonpull.h"
|
||||||
|
#include "tile.h"
|
||||||
|
|
||||||
#define GEOM_POINT 0 /* array of positions */
|
#define GEOM_POINT 0 /* array of positions */
|
||||||
#define GEOM_MULTIPOINT 1 /* array of arrays of positions */
|
#define GEOM_MULTIPOINT 1 /* array of arrays of positions */
|
||||||
@@ -21,19 +22,6 @@
|
|||||||
#define GEOM_MULTIPOLYGON 5 /* array of arrays of arrays of arrays of positions */
|
#define GEOM_MULTIPOLYGON 5 /* array of arrays of arrays of arrays of positions */
|
||||||
#define GEOM_TYPES 6
|
#define GEOM_TYPES 6
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
char *geometry_names[GEOM_TYPES] = {
|
char *geometry_names[GEOM_TYPES] = {
|
||||||
"Point",
|
"Point",
|
||||||
"MultiPoint",
|
"MultiPoint",
|
||||||
@@ -146,19 +134,6 @@ int indexcmp(const void *v1, const void *v2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pool_val {
|
|
||||||
char *s;
|
|
||||||
int type;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
struct pool_val *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pool {
|
|
||||||
struct pool_val *vals;
|
|
||||||
int n;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pool_val *pool(struct pool *p, char *s, int type) {
|
struct pool_val *pool(struct pool *p, char *s, int type) {
|
||||||
struct pool_val **v = &(p->vals);
|
struct pool_val **v = &(p->vals);
|
||||||
|
|
||||||
@@ -315,9 +290,9 @@ 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) {
|
void check_range(struct index *start, struct index *end, char *metabase, unsigned *file_bbox) {
|
||||||
struct pool keys, values;
|
struct pool keys;
|
||||||
keys.n = values.n = 0;
|
keys.n = 0;
|
||||||
keys.vals = values.vals = NULL;
|
keys.vals = NULL;
|
||||||
|
|
||||||
struct index *i;
|
struct index *i;
|
||||||
printf("tile -----------------------------------------------\n");
|
printf("tile -----------------------------------------------\n");
|
||||||
@@ -334,7 +309,7 @@ void check_range(struct index *start, struct index *end, char *metabase, unsigne
|
|||||||
int t;
|
int t;
|
||||||
deserialize_int(&meta, &t);
|
deserialize_int(&meta, &t);
|
||||||
struct pool_val *key = deserialize_string(&meta, &keys, VT_STRING);
|
struct pool_val *key = deserialize_string(&meta, &keys, VT_STRING);
|
||||||
struct pool_val *value = deserialize_string(&meta, &values, t);
|
struct pool_val *value = deserialize_string(&meta, &keys, t);
|
||||||
|
|
||||||
printf("%s (%d) = %s (%d)\n", key->s, key->n, value->s, value->n);
|
printf("%s (%d) = %s (%d)\n", key->s, key->n, value->s, value->n);
|
||||||
}
|
}
|
||||||
@@ -366,8 +341,8 @@ void check_range(struct index *start, struct index *end, char *metabase, unsigne
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_tile("layer", &keys);
|
||||||
pool_free(&keys);
|
pool_free(&keys);
|
||||||
pool_free(&values);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include "vector_tile.pb.h"
|
#include "vector_tile.pb.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "tile.h"
|
||||||
|
}
|
||||||
|
|
||||||
#define XMAX 4096
|
#define XMAX 4096
|
||||||
#define YMAX 4096
|
#define YMAX 4096
|
||||||
|
|
||||||
@@ -35,7 +39,7 @@ static inline int compress(std::string const& input, std::string& output) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_tile(char *name) {
|
void write_tile(char *name, struct pool *keys) {
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||||
|
|
||||||
mapnik::vector::tile tile;
|
mapnik::vector::tile tile;
|
||||||
@@ -45,6 +49,10 @@ void write_tile(char *name) {
|
|||||||
layer->set_version(1);
|
layer->set_version(1);
|
||||||
layer->set_extent(XMAX);
|
layer->set_extent(XMAX);
|
||||||
|
|
||||||
|
struct pool_val *pv;
|
||||||
|
for (pv = keys->vals; pv != NULL; pv = pv->next) {
|
||||||
|
layer->add_keys(pv->s, strlen(pv->s));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -53,7 +61,10 @@ void write_tile(char *name) {
|
|||||||
std::string compressed;
|
std::string compressed;
|
||||||
|
|
||||||
tile.SerializeToString(&s);
|
tile.SerializeToString(&s);
|
||||||
|
std::cout << s;
|
||||||
|
#if 0
|
||||||
compress(s, compressed);
|
compress(s, compressed);
|
||||||
std::cout << compressed;
|
std::cout << compressed;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user