From 78304d638578e3f6251d76dba3e1b09d72cd4739 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 22 Sep 2014 16:50:24 -0700 Subject: [PATCH] Start writing a feature --- tile.cc | 26 +++++++++++++++++++++----- tile.h | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tile.cc b/tile.cc index 899a053..74af4d4 100644 --- a/tile.cc +++ b/tile.cc @@ -57,6 +57,8 @@ void check_range(struct index *start, struct index *end, char *metabase, unsigne struct index *i; printf("tile -----------------------------------------------\n"); for (i = start; i < end; i++) { + mapnik::vector::tile_feature *feature = layer->add_features(); + printf("%llx ", i->index); char *meta = metabase + i->fpos; @@ -65,16 +67,27 @@ void check_range(struct index *start, struct index *end, char *metabase, unsigne deserialize_int(&meta, &t); printf("(%d) ", t); - while (1) { - deserialize_int(&meta, &t); + if (t == VT_POINT) { + feature->set_type(mapnik::vector::tile::Point); + } else if (t == VT_LINE) { + feature->set_type(mapnik::vector::tile::LineString); + } else if (t == VT_POLYGON) { + feature->set_type(mapnik::vector::tile::Polygon); + } else { + feature->set_type(mapnik::vector::tile::Unknown); + } - if (t == VT_END) { + while (1) { + int op; + deserialize_int(&meta, &op); + + if (op == VT_END) { break; } - printf("%d: ", t); + printf("%d: ", op); - if (t == VT_MOVETO || t == VT_LINETO) { + if (op == VT_MOVETO || op == VT_LINETO) { int x, y; deserialize_int(&meta, &x); deserialize_int(&meta, &y); @@ -95,6 +108,9 @@ void check_range(struct index *start, struct index *end, char *metabase, unsigne struct pool_val *key = deserialize_string(&meta, &keys, VT_STRING); struct pool_val *value = deserialize_string(&meta, &keys, t); + feature->add_tags(key->n); + feature->add_tags(value->n); + printf("%s (%d) = %s (%d)\n", key->s, key->n, value->s, value->n); } diff --git a/tile.h b/tile.h index ce25464..29e3ae8 100644 --- a/tile.h +++ b/tile.h @@ -1,8 +1,8 @@ -#define VT_END 0 #define VT_POINT 1 #define VT_LINE 2 #define VT_POLYGON 3 +#define VT_END 0 #define VT_MOVETO 1 #define VT_LINETO 2 #define VT_CLOSEPATH 7