Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to new $type names, take 2 #506

Merged
merged 2 commits into from
Jul 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions debug/style-basic-v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"id": "country_label",
"source": "mapbox.mapbox-streets-v5",
"source-layer": "country_label",
"filter": { "$type": "point" },
"filter": { "$type": "Point" },
"render": {
"type": "text",
"text-field": "{{name}}",
Expand All @@ -150,7 +150,7 @@
"id": "road_label",
"source": "mapbox.mapbox-streets-v5",
"source-layer": "road_label",
"filter": { "$type": "line" },
"filter": { "$type": "LineString" },
"render": {
"type": "text",
"text-field": "{{name}}",
Expand Down
8 changes: 4 additions & 4 deletions debug/style-v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@
"id": "country_label",
"source": "mapbox.mapbox-streets-v5",
"source-layer": "country_label",
"filter": { "$type": "point" },
"filter": { "$type": "Point" },
"render": {
"type": "text",
"text-field": "{{name}}",
Expand All @@ -555,7 +555,7 @@
"id": "place_label",
"source": "mapbox.mapbox-streets-v5",
"source-layer": "place_label",
"filter": { "$type": "point" },
"filter": { "$type": "Point" },
"render": {
"type": "text",
"text-field": "{{name}}",
Expand All @@ -573,7 +573,7 @@
"id": "road_label",
"source": "mapbox.mapbox-streets-v5",
"source-layer": "road_label",
"filter": { "$type": "line" },
"filter": { "$type": "LineString" },
"render": {
"type": "text",
"text-field": "{{name}}",
Expand Down Expand Up @@ -612,7 +612,7 @@
"id": "road_markers",
"source": "mapbox.mapbox-streets-v5",
"source-layer": "road",
"filter": { "oneway": 1, "$type": "line" },
"filter": { "oneway": 1, "$type": "LineString" },
"render": {
"type": "icon",
"icon-image": "bicycle-12",
Expand Down
6 changes: 3 additions & 3 deletions js/style/bucket-filter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

var VectorTileFeature = require('vector-tile').VectorTileFeature;

function infix(operator) {
return function(left, right) { return left + ' ' + operator + ' ' + right; };
}
Expand Down Expand Up @@ -29,8 +31,6 @@ var objOperators = {
'!': not, '$not': not
};

var geometryTypeToName = [null, 'point', 'line', 'polygon'];

module.exports = function (filter) {
// simple key & value comparison
function valueFilter(key, value, operator) {
Expand Down Expand Up @@ -76,7 +76,7 @@ module.exports = function (filter) {
}

function typeFilter(type) {
return 'f._type === ' + geometryTypeToName.indexOf(type);
return 'f.type === ' + VectorTileFeature.types.indexOf(type);
}

function fieldsFilter(obj) {
Expand Down
6 changes: 2 additions & 4 deletions js/worker/workertile.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ WorkerTile.prototype.parse = function(data, callback) {
parseBucket(tile, bucket);
}
}

function dependenciesDone(bucket) {
return function(err) {
bucket.dependenciesLoaded = true;
Expand Down Expand Up @@ -261,13 +261,11 @@ function sortLayerIntoBuckets(layer, mapping, buckets) {
}
}

var geometryTypeToName = [null, 'point', 'line', 'polygon'];

function getGeometry(feature) {
return feature.loadGeometry();
}

function getType(feature) {
return geometryTypeToName[feature._type];
return vt.VectorTileFeature.types[feature.type];
}

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"queue-async": "^1.0.7",
"rbush": "~1.3.2",
"unitbezier": "0.0.0",
"vector-tile": "0.0.5",
"vector-tile": "0.1.1",
"point-geometry": "0.0.0"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions test/bucket-filter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ test('bucketFilter', function(t) {
});

t.test('filters by type', function(t) {
var f = filter({'$type': 'line'});
t.ok(f({_type: 2, properties: {}}));
t.notOk(f({_type: 1, properties: {}}));
var f = filter({'$type': 'LineString'});
t.ok(f({type: 2, properties: {}}));
t.notOk(f({type: 1, properties: {}}));
t.end();
});
});