mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Get closer to vector format
This commit is contained in:
@@ -18,9 +18,12 @@
|
|||||||
#define GEOM_MULTILINESTRING 3 /* array of arrays of arrays of positions */
|
#define GEOM_MULTILINESTRING 3 /* array of arrays of arrays of positions */
|
||||||
#define GEOM_POLYGON 4 /* array of arrays of arrays of positions */
|
#define GEOM_POLYGON 4 /* array of arrays of arrays of positions */
|
||||||
#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 MB_GEOM_POINT 1
|
||||||
|
#define MB_GEOM_LINE 2
|
||||||
|
#define MB_GEOM_POLYGON 3
|
||||||
|
|
||||||
char *geometry_names[GEOM_TYPES] = {
|
char *geometry_names[GEOM_TYPES] = {
|
||||||
"Point",
|
"Point",
|
||||||
"MultiPoint",
|
"MultiPoint",
|
||||||
@@ -39,6 +42,15 @@ int geometry_within[GEOM_TYPES] = {
|
|||||||
GEOM_POLYGON, /* multipolygon */
|
GEOM_POLYGON, /* multipolygon */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int mb_geometry[GEOM_TYPES] = {
|
||||||
|
MB_GEOM_POINT,
|
||||||
|
MB_GEOM_POINT,
|
||||||
|
MB_GEOM_LINE,
|
||||||
|
MB_GEOM_LINE,
|
||||||
|
MB_GEOM_POLYGON,
|
||||||
|
MB_GEOM_POLYGON,
|
||||||
|
};
|
||||||
|
|
||||||
/* XXX */
|
/* XXX */
|
||||||
#define META_STRING JSON_STRING
|
#define META_STRING JSON_STRING
|
||||||
#define META_INTEGER JSON_NUMBER
|
#define META_INTEGER JSON_NUMBER
|
||||||
@@ -55,6 +67,14 @@ void parse_geometry(int t, json_object *j) {
|
|||||||
printf("[");
|
printf("[");
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < j->length; i++) {
|
for (i = 0; i < j->length; i++) {
|
||||||
|
if (within == GEOM_POINT) {
|
||||||
|
if (i == 0) {
|
||||||
|
printf(" moveto ");
|
||||||
|
} else {
|
||||||
|
printf(" lineto ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
parse_geometry(within, j->array[i]);
|
parse_geometry(within, j->array[i]);
|
||||||
}
|
}
|
||||||
printf("]");
|
printf("]");
|
||||||
@@ -65,6 +85,10 @@ void parse_geometry(int t, json_object *j) {
|
|||||||
fprintf(stderr, "malformed point");
|
fprintf(stderr, "malformed point");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (t == GEOM_POLYGON) {
|
||||||
|
printf(" closepath ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_json(FILE *f) {
|
void read_json(FILE *f) {
|
||||||
@@ -152,6 +176,7 @@ void read_json(FILE *f) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("%d: ", mb_geometry[t]);
|
||||||
parse_geometry(t, coordinates);
|
parse_geometry(t, coordinates);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user