Add the tests for filtering for feature type

This commit is contained in:
Eric Fischer 2017-09-05 12:17:23 -07:00
parent 7b71f41e43
commit d349b7700d
3 changed files with 110 additions and 2 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": { "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": "notlayer1675768827" }, "properties": { "rule": "not type: 1, [\"==\", \"$type\", \"LineString\"]" }, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer1675768827" }, "properties": { "rule": "not type: 1, [\"==\", \"$type\", \"LineString\"]" }, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer1675768827" }, "properties": { "rule": "type: 2, [\"==\", \"$type\", \"LineString\"]" }, "geometry": { "type": "LineString", "coordinates": [ [ 0, 0 ], [ 1, 1 ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer1675768827" }, "properties": { "rule": "type: 2, [\"==\", \"$type\", \"LineString\"]" }, "geometry": { "type": "LineString", "coordinates": [ [ -100, 0 ], [ -101, 1 ] ] } }
{ "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 ] } }
@ -68,6 +72,10 @@
{ "type": "Feature", "tippecanoe": { "layer": "layer1780490201" }, "properties": {"foo": null, "rule": "not \"properties\": {\"foo\": null}, [\"!=\", \"foo\", null]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer1780490201" }, "properties": { "rule": "\"properties\": {}, [\"!=\", \"foo\", null]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer1780490201" }, "properties": { "rule": "\"properties\": {}, [\"!=\", \"foo\", null]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer1549998271" }, "properties": { "rule": "type: 1, [\"!=\", \"$type\", \"LineString\"]" }, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer1549998271" }, "properties": { "rule": "type: 1, [\"!=\", \"$type\", \"LineString\"]" }, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer1549998271" }, "properties": { "rule": "not type: 2, [\"!=\", \"$type\", \"LineString\"]" }, "geometry": { "type": "LineString", "coordinates": [ [ 0, 0 ], [ 1, 1 ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer1549998271" }, "properties": { "rule": "not type: 2, [\"!=\", \"$type\", \"LineString\"]" }, "geometry": { "type": "LineString", "coordinates": [ [ -100, 0 ], [ -101, 1 ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer2624681884" }, "properties": {"foo": 1, "rule": "not \"properties\": {\"foo\": 1}, [\"<\", \"foo\", 0]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer2624681884" }, "properties": {"foo": 1, "rule": "not \"properties\": {\"foo\": 1}, [\"<\", \"foo\", 0]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer2624681884" }, "properties": {"foo": 0, "rule": "not \"properties\": {\"foo\": 0}, [\"<\", \"foo\", 0]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
@ -260,6 +268,18 @@
{ "type": "Feature", "tippecanoe": { "layer": "notlayer464719784" }, "properties": {"foo": 1, "rule": "\"properties\": {\"foo\": 1}, [\"in\", \"foo\", 0, 1]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer464719784" }, "properties": {"foo": 3, "rule": "not \"properties\": {\"foo\": 3}, [\"in\", \"foo\", 0, 1]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer464719784" }, "properties": {"foo": 3, "rule": "not \"properties\": {\"foo\": 3}, [\"in\", \"foo\", 0, 1]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer1359089124" }, "properties": { "rule": "not type: 1, [\"in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer1359089124" }, "properties": { "rule": "not type: 1, [\"in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer1359089124" }, "properties": { "rule": "type: 2, [\"in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "LineString", "coordinates": [ [ 0, 0 ], [ 1, 1 ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer1359089124" }, "properties": { "rule": "type: 2, [\"in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "LineString", "coordinates": [ [ -100, 0 ], [ -101, 1 ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer1359089124" }, "properties": { "rule": "type: 3, [\"in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0, 0 ], [ 1, 1 ], [ 1, 0 ], [ 0, 0 ] ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer1359089124" }, "properties": { "rule": "type: 3, [\"in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -100, 0 ], [ -101, 1 ], [ -101, 0 ], [-100, 0 ] ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer3115744778" }, "properties": { "rule": "type: 1, [\"in\", \"$type\", \"Polygon\", \"LineString\", \"Point\"]" }, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer3115744778" }, "properties": { "rule": "type: 1, [\"in\", \"$type\", \"Polygon\", \"LineString\", \"Point\"]" }, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer3115744778" }, "properties": { "rule": "type: 2, [\"in\", \"$type\", \"Polygon\", \"LineString\", \"Point\"]" }, "geometry": { "type": "LineString", "coordinates": [ [ 0, 0 ], [ 1, 1 ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer3115744778" }, "properties": { "rule": "type: 2, [\"in\", \"$type\", \"Polygon\", \"LineString\", \"Point\"]" }, "geometry": { "type": "LineString", "coordinates": [ [ -100, 0 ], [ -101, 1 ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer3115744778" }, "properties": { "rule": "type: 3, [\"in\", \"$type\", \"Polygon\", \"LineString\", \"Point\"]" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0, 0 ], [ 1, 1 ], [ 1, 0 ], [ 0, 0 ] ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer3115744778" }, "properties": { "rule": "type: 3, [\"in\", \"$type\", \"Polygon\", \"LineString\", \"Point\"]" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -100, 0 ], [ -101, 1 ], [ -101, 0 ], [-100, 0 ] ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer262236988" }, "properties": {"foo": 1, "rule": "\"properties\": {\"foo\": 1}, [\"!in\", \"foo\"]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer262236988" }, "properties": {"foo": 1, "rule": "\"properties\": {\"foo\": 1}, [\"!in\", \"foo\"]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer3444677016" }, "properties": {"foo": 0, "rule": "\"properties\": {\"foo\": 0}, [\"!in\", \"foo\", \"0\"]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
@ -288,6 +308,12 @@
{ "type": "Feature", "tippecanoe": { "layer": "layer2925029377" }, "properties": {"foo": 1, "rule": "not \"properties\": {\"foo\": 1}, [\"!in\", \"foo\", 0, 1]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer2925029377" }, "properties": {"foo": 3, "rule": "\"properties\": {\"foo\": 3}, [\"!in\", \"foo\", 0, 1]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer2925029377" }, "properties": {"foo": 3, "rule": "\"properties\": {\"foo\": 3}, [\"!in\", \"foo\", 0, 1]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer2275670193" }, "properties": { "rule": "type: 1, [\"!in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer2275670193" }, "properties": { "rule": "type: 1, [\"!in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer2275670193" }, "properties": { "rule": "not type: 2, [\"!in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "LineString", "coordinates": [ [ 0, 0 ], [ 1, 1 ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer2275670193" }, "properties": { "rule": "not type: 2, [\"!in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "LineString", "coordinates": [ [ -100, 0 ], [ -101, 1 ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer2275670193" }, "properties": { "rule": "not type: 3, [\"!in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0, 0 ], [ 1, 1 ], [ 1, 0 ], [ 0, 0 ] ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer2275670193" }, "properties": { "rule": "not type: 3, [\"!in\", \"$type\", \"LineString\", \"Polygon\"]" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -100, 0 ], [ -101, 1 ], [ -101, 0 ], [-100, 0 ] ] ] } }
{ "type": "Feature", "tippecanoe": { "layer": "notlayer4098096220" }, "properties": {"foo": 1, "rule": "not \"properties\": {\"foo\": 1}, [\"any\"]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer4098096220" }, "properties": {"foo": 1, "rule": "not \"properties\": {\"foo\": 1}, [\"any\"]"}, "geometry": { "type": "Point", "coordinates": [ -100, 0 ] } }
{ "type": "Feature", "tippecanoe": { "layer": "layer3603116915" }, "properties": {"foo": 1, "rule": "\"properties\": {\"foo\": 1}, [\"any\", [\"==\", \"foo\", 1]]"}, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }

File diff suppressed because one or more lines are too long

View File

@ -87,7 +87,45 @@ while (<IN>) {
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";
}
} elsif ($prop =~ /type: (.)/) {
my $type = $1;
my $qprop = "$prop, $filter";
$qprop =~ s/"/\\"/g;
if ($matched eq "true") {
$qprop = "\"properties\": { \"rule\": \"$qprop\" }";
} else {
$qprop = "\"properties\": { \"rule\": \"not $qprop\" }";
}
if ($type == 1) {
if ($matched eq "true") {
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"$hash\" }, $qprop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ 0, 0 ] } }\n";
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"not$hash\" }, $qprop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -100, 0 ] } }\n";
} else {
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"not$hash\" }, $qprop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ 0, 0 ] } }\n";
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"$hash\" }, $qprop, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -100, 0 ] } }\n";
}
} elsif ($type == 2) {
if ($matched eq "true") {
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"$hash\" }, $qprop, \"geometry\": { \"type\": \"LineString\", \"coordinates\": [ [ 0, 0 ], [ 1, 1 ] ] } }\n";
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"not$hash\" }, $qprop, \"geometry\": { \"type\": \"LineString\", \"coordinates\": [ [ -100, 0 ], [ -101, 1 ] ] } }\n";
} else {
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"not$hash\" }, $qprop, \"geometry\": { \"type\": \"LineString\", \"coordinates\": [ [ 0, 0 ], [ 1, 1 ] ] } }\n";
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"$hash\" }, $qprop, \"geometry\": { \"type\": \"LineString\", \"coordinates\": [ [ -100, 0 ], [ -101, 1 ] ] } }\n";
}
} else {
if ($matched eq "true") {
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"$hash\" }, $qprop, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [ [ [ 0, 0 ], [ 1, 1 ], [ 1, 0 ], [ 0, 0 ] ] ] } }\n";
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"not$hash\" }, $qprop, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [ [ [ -100, 0 ], [ -101, 1 ], [ -101, 0 ], [-100, 0 ] ] ] } }\n";
} else {
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"not$hash\" }, $qprop, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [ [ [ 0, 0 ], [ 1, 1 ], [ 1, 0 ], [ 0, 0 ] ] ] } }\n";
print GEOJSON "{ \"type\": \"Feature\", \"tippecanoe\": { \"layer\": \"$hash\" }, $qprop, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [ [ [ -100, 0 ], [ -101, 1 ], [ -101, 0 ], [-100, 0 ] ] ] } }\n";
}
}
} else {
print "$prop\n";
}
}
}