mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Move attribute type coercion out of parsing and into serialization
This commit is contained in:
+15
-7
@@ -99,7 +99,7 @@ static long long scale_geometry(struct serialization_state *sst, long long *bbox
|
||||
return geom.size();
|
||||
}
|
||||
|
||||
int serialize_geojson_feature(struct serialization_state *sst, json_object *geometry, json_object *properties, json_object *id, int layer, json_object *tippecanoe, json_object *feature, std::string layername, std::map<std::string, int> const *attribute_types) {
|
||||
int serialize_geojson_feature(struct serialization_state *sst, json_object *geometry, json_object *properties, json_object *id, int layer, json_object *tippecanoe, json_object *feature, std::string layername) {
|
||||
json_object *geometry_type = json_hash_get(geometry, "type");
|
||||
if (geometry_type == NULL) {
|
||||
static int warned = 0;
|
||||
@@ -219,7 +219,7 @@ int serialize_geojson_feature(struct serialization_state *sst, json_object *geom
|
||||
|
||||
int type = -1;
|
||||
std::string val;
|
||||
stringify_value(properties->values[i], type, val, sst->fname, sst->line, feature, properties->keys[i]->string, attribute_types);
|
||||
stringify_value(properties->values[i], type, val, sst->fname, sst->line, feature, properties->keys[i]->string);
|
||||
|
||||
if (type >= 0) {
|
||||
metakey[m] = properties->keys[i]->string;
|
||||
@@ -406,10 +406,18 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
|
||||
if (sst->include->count(sf.full_keys[i]) == 0) {
|
||||
sf.full_keys[i] = "";
|
||||
sf.m--;
|
||||
continue;
|
||||
}
|
||||
} else if (sst->exclude->count(sf.full_keys[i]) != 0) {
|
||||
sf.full_keys[i] = "";
|
||||
sf.m--;
|
||||
continue;
|
||||
}
|
||||
|
||||
coerce_value(sf.full_keys[i], sf.full_values[i].type, sf.full_values[i].s, sst->attribute_types);
|
||||
if (sf.full_values[i].type == mvt_null) {
|
||||
sf.full_keys[i] = "";
|
||||
sf.m--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,7 +509,7 @@ void check_crs(json_object *j, const char *reading) {
|
||||
}
|
||||
}
|
||||
|
||||
void parse_json(struct serialization_state *sst, json_pull *jp, int layer, std::string layername, std::map<std::string, int> const *attribute_types) {
|
||||
void parse_json(struct serialization_state *sst, json_pull *jp, int layer, std::string layername) {
|
||||
long long found_hashes = 0;
|
||||
long long found_features = 0;
|
||||
long long found_geometries = 0;
|
||||
@@ -569,7 +577,7 @@ void parse_json(struct serialization_state *sst, json_pull *jp, int layer, std::
|
||||
}
|
||||
found_geometries++;
|
||||
|
||||
serialize_geojson_feature(sst, j, NULL, NULL, layer, NULL, j, layername, attribute_types);
|
||||
serialize_geojson_feature(sst, j, NULL, NULL, layer, NULL, j, layername);
|
||||
json_free(j);
|
||||
continue;
|
||||
}
|
||||
@@ -612,10 +620,10 @@ void parse_json(struct serialization_state *sst, json_pull *jp, int layer, std::
|
||||
if (geometries != NULL) {
|
||||
size_t g;
|
||||
for (g = 0; g < geometries->length; g++) {
|
||||
serialize_geojson_feature(sst, geometries->array[g], properties, id, layer, tippecanoe, j, layername, attribute_types);
|
||||
serialize_geojson_feature(sst, geometries->array[g], properties, id, layer, tippecanoe, j, layername);
|
||||
}
|
||||
} else {
|
||||
serialize_geojson_feature(sst, geometry, properties, id, layer, tippecanoe, j, layername, attribute_types);
|
||||
serialize_geojson_feature(sst, geometry, properties, id, layer, tippecanoe, j, layername);
|
||||
}
|
||||
|
||||
json_free(j);
|
||||
@@ -627,7 +635,7 @@ void parse_json(struct serialization_state *sst, json_pull *jp, int layer, std::
|
||||
void *run_parse_json(void *v) {
|
||||
struct parse_json_args *pja = (struct parse_json_args *) v;
|
||||
|
||||
parse_json(pja->sst, pja->jp, pja->layer, *pja->layername, pja->attribute_types);
|
||||
parse_json(pja->sst, pja->jp, pja->layer, *pja->layername);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user