mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-03-25 05:15:16 +00:00
Don't accept features or geometries inside another object's properties
This commit is contained in:
parent
ba8966a4ae
commit
98cf4d94aa
@ -1,3 +1,8 @@
|
||||
## 1.31.2
|
||||
|
||||
* Don't accept anything inside another JSON object's properties as a
|
||||
feature or geometry of its own.
|
||||
|
||||
## 1.31.1
|
||||
|
||||
* Add --exclude-all to tile-join
|
||||
|
@ -93,6 +93,20 @@ void parse_json(json_feature_action *jfa, json_pull *jp) {
|
||||
}
|
||||
}
|
||||
|
||||
if (is_geometry) {
|
||||
json_object *jo = j;
|
||||
while (jo != NULL) {
|
||||
if (jo->parent != NULL && jo->parent->type == JSON_HASH) {
|
||||
if (json_hash_get(jo->parent, "properties") == jo) {
|
||||
// Ancestor is the value corresponding to a properties key
|
||||
is_geometry = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
jo = jo->parent;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_geometry) {
|
||||
if (found_features != 0 && found_geometries == 0) {
|
||||
fprintf(stderr, "%s:%d: Warning: found a mixture of features and bare geometries\n", jfa->fname.c_str(), jp->line);
|
||||
@ -135,6 +149,24 @@ void parse_json(json_feature_action *jfa, json_pull *jp) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool is_feature = true;
|
||||
{
|
||||
json_object *jo = j;
|
||||
while (jo != NULL) {
|
||||
if (jo->parent != NULL && jo->parent->type == JSON_HASH) {
|
||||
if (json_hash_get(jo->parent, "properties") == jo) {
|
||||
// Ancestor is the value corresponding to a properties key
|
||||
is_feature = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
jo = jo->parent;
|
||||
}
|
||||
}
|
||||
if (!is_feature) {
|
||||
continue;
|
||||
}
|
||||
|
||||
json_object *tippecanoe = json_hash_get(j, "tippecanoe");
|
||||
json_object *id = json_hash_get(j, "id");
|
||||
|
||||
|
@ -364,7 +364,7 @@ void join_csv(json_object *j) {
|
||||
}
|
||||
|
||||
struct json_join_action : json_feature_action {
|
||||
int add_feature(json_object *geometry, bool geometrycollection, json_object *properties, json_object *id, json_object *tippecanoe, json_object *feature) {
|
||||
int add_feature(json_object *geometry, bool, json_object *, json_object *, json_object *, json_object *feature) {
|
||||
if (feature != NULL) {
|
||||
if (csvfile != NULL) {
|
||||
join_csv(feature);
|
||||
@ -382,7 +382,7 @@ struct json_join_action : json_feature_action {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void check_crs(json_object *j) {
|
||||
void check_crs(json_object *) {
|
||||
}
|
||||
};
|
||||
|
||||
@ -390,6 +390,7 @@ void process(FILE *fp, const char *fname) {
|
||||
json_pull *jp = json_begin_file(fp);
|
||||
|
||||
json_join_action jja;
|
||||
jja.fname = fname;
|
||||
parse_json(&jja, jp);
|
||||
json_end(jp);
|
||||
}
|
||||
|
9
tests/nested/in.json
Normal file
9
tests/nested/in.json
Normal file
@ -0,0 +1,9 @@
|
||||
{"type":"Feature","properties":{"nested2":{"type":"Point","coordinates":[2,2]}},"geometry":{"type":"LineString","coordinates":[[0,0],[1,1]]}}
|
||||
{"type":"Feature","properties":{"deeper2":[{"type":"Point","coordinates":[2,2]}]},"geometry":{"type":"LineString","coordinates":[[0,0],[1,1]]}}
|
||||
{"type":"Feature","properties":{"more2":{"something":{"type":"Point","coordinates":[2,2]}}},"geometry":{"type":"LineString","coordinates":[[0,0],[1,1]]}}
|
||||
|
||||
{"type":"Feature","properties":{"nested":{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[2,2]}}},"geometry":{"type":"LineString","coordinates":[[0,0],[1,1]]}}
|
||||
{"type":"Feature","properties":{"deeper":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[2,2]}}]},"geometry":{"type":"LineString","coordinates":[[0,0],[1,1]]}}
|
||||
{"type":"Feature","properties":{"more":{"something":{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[2,2]}}}},"geometry":{"type":"LineString","coordinates":[[0,0],[1,1]]}}
|
||||
|
||||
{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[0,0],[1,1]]}}
|
30
tests/nested/out/-z0_--preserve-input-order.json
Normal file
30
tests/nested/out/-z0_--preserve-input-order.json
Normal file
@ -0,0 +1,30 @@
|
||||
{ "type": "FeatureCollection", "properties": {
|
||||
"bounds": "0.000000,0.000000,1.000000,1.000000",
|
||||
"center": "0.000000,0.000000,0",
|
||||
"description": "tests/nested/out/-z0_--preserve-input-order.json.check.mbtiles",
|
||||
"format": "pbf",
|
||||
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"deeper\": \"String\", \"deeper2\": \"String\", \"more\": \"String\", \"more2\": \"String\", \"nested\": \"String\", \"nested2\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 7,\"geometry\": \"LineString\",\"attributeCount\": 6,\"attributes\": [{\"attribute\": \"deeper\",\"count\": 1,\"type\": \"string\",\"values\": [\"[{\\\"type\\\":\\\"Feature\\\",\\\"properties\\\":{},\\\"geometry\\\":{\\\"type\\\":\\\"Point\\\",\\\"coordinates\\\":[2,2]}}]\"]},{\"attribute\": \"deeper2\",\"count\": 1,\"type\": \"string\",\"values\": [\"[{\\\"type\\\":\\\"Point\\\",\\\"coordinates\\\":[2,2]}]\"]},{\"attribute\": \"more\",\"count\": 1,\"type\": \"string\",\"values\": [\"{\\\"something\\\":{\\\"type\\\":\\\"Feature\\\",\\\"properties\\\":{},\\\"geometry\\\":{\\\"type\\\":\\\"Point\\\",\\\"coordinates\\\":[2,2]}}}\"]},{\"attribute\": \"more2\",\"count\": 1,\"type\": \"string\",\"values\": [\"{\\\"something\\\":{\\\"type\\\":\\\"Point\\\",\\\"coordinates\\\":[2,2]}}\"]},{\"attribute\": \"nested\",\"count\": 1,\"type\": \"string\",\"values\": [\"{\\\"type\\\":\\\"Feature\\\",\\\"properties\\\":{},\\\"geometry\\\":{\\\"type\\\":\\\"Point\\\",\\\"coordinates\\\":[2,2]}}\"]},{\"attribute\": \"nested2\",\"count\": 1,\"type\": \"string\",\"values\": [\"{\\\"type\\\":\\\"Point\\\",\\\"coordinates\\\":[2,2]}\"]}]}]}}",
|
||||
"maxzoom": "0",
|
||||
"minzoom": "0",
|
||||
"name": "tests/nested/out/-z0_--preserve-input-order.json.check.mbtiles",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
|
||||
{ "type": "Feature", "properties": { "nested2": "{\"type\":\"Point\",\"coordinates\":[2,2]}" }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.966797, 1.054628 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "deeper2": "[{\"type\":\"Point\",\"coordinates\":[2,2]}]" }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.966797, 1.054628 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "more2": "{\"something\":{\"type\":\"Point\",\"coordinates\":[2,2]}}" }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.966797, 1.054628 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "nested": "{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[2,2]}}" }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.966797, 1.054628 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "deeper": "[{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[2,2]}}]" }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.966797, 1.054628 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "more": "{\"something\":{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[2,2]}}}" }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.966797, 1.054628 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.966797, 1.054628 ] ] } }
|
||||
] }
|
||||
] }
|
||||
] }
|
@ -1,6 +1,6 @@
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#define VERSION "v1.31.1"
|
||||
#define VERSION "v1.31.2"
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user