Add the feature ID filter tests

This commit is contained in:
Eric Fischer 2017-09-01 16:53:19 -07:00
parent 8d502eb805
commit 681907e88d
3 changed files with 30 additions and 1 deletions

View File

@ -30,6 +30,10 @@
{ "type": "Feature", "tippecanoe": { "layer": "notlayer220442869" }, "properties": {"foo": null, "rule": "\"properties\": {\"foo\": null}, [\"==\", \"foo\", null]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } } { "type": "Feature", "tippecanoe": { "layer": "notlayer220442869" }, "properties": {"foo": null, "rule": "\"properties\": {\"foo\": null}, [\"==\", \"foo\", null]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer220442869" }, "properties": { "rule": "not \"properties\": {}, [\"==\", \"foo\", null]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } } { "type": "Feature", "tippecanoe": { "layer": "notlayer220442869" }, "properties": { "rule": "not \"properties\": {}, [\"==\", \"foo\", null]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer220442869" }, "properties": { "rule": "not \"properties\": {}, [\"==\", \"foo\", null]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } } { "type": "Feature", "tippecanoe": { "layer": "layer220442869" }, "properties": { "rule": "not \"properties\": {}, [\"==\", \"foo\", null]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer827905613" }, "id": 1234, "properties": { "rule": "\"id\": 1234, [\"==\", \"$id\", 1234]" }, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer827905613" }, "id": 1234, "properties": { "rule": "\"id\": 1234, [\"==\", \"$id\", 1234]" }, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer827905613" }, "id": "1234", "properties": { "rule": "not \"id\": \"1234\", [\"==\", \"$id\", 1234]" }, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer827905613" }, "id": "1234", "properties": { "rule": "not \"id\": \"1234\", [\"==\", \"$id\", 1234]" }, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer827905613" }, "properties": {"id": 1234, "rule": "not \"properties\": {\"id\": 1234}, [\"==\", \"$id\", 1234]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } } { "type": "Feature", "tippecanoe": { "layer": "notlayer827905613" }, "properties": {"id": 1234, "rule": "not \"properties\": {\"id\": 1234}, [\"==\", \"$id\", 1234]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer827905613" }, "properties": {"id": 1234, "rule": "not \"properties\": {\"id\": 1234}, [\"==\", \"$id\", 1234]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } } { "type": "Feature", "tippecanoe": { "layer": "layer827905613" }, "properties": {"id": 1234, "rule": "not \"properties\": {\"id\": 1234}, [\"==\", \"$id\", 1234]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer442294443" }, "properties": {"foo": "bar", "rule": "not \"properties\": {\"foo\": \"bar\"}, [\"!=\", \"foo\", \"bar\"]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } } { "type": "Feature", "tippecanoe": { "layer": "notlayer442294443" }, "properties": {"foo": "bar", "rule": "not \"properties\": {\"foo\": \"bar\"}, [\"!=\", \"foo\", \"bar\"]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }

File diff suppressed because one or more lines are too long

View File

@ -69,6 +69,25 @@ while (<IN>) {
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"not$hash\" }, $prop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ 0, 0 ] } }\n"; print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"not$hash\" }, $prop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ 0, 0 ] } }\n";
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"$hash\" }, $prop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -100, 0 ] } }\n"; print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"$hash\" }, $prop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -100, 0 ] } }\n";
} }
} elsif ($prop =~ /id/) {
$prop =~ s/id/"id"/g;
$prop =~ s/'/"/g;
my $qprop = "$prop, $filter";
$qprop =~ s/"/\\"/g;
if ($matched eq "true") {
$qprop = "\"properties\": { \"rule\": \"$qprop\" }";
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"$hash\" }, $prop, $qprop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ 0, 0 ] } }\n";
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"not$hash\" }, $prop, $qprop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -100, 0 ] } }\n";
} else {
$qprop = "\"properties\": { \"rule\": \"not $qprop\" }";
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"not$hash\" }, $prop, $qprop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ 0, 0 ] } }\n";
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"$hash\" }, $prop, $qprop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -100, 0 ] } }\n";
}
} }
} }
} }