Skip to content

Commit

Permalink
Merge branch 'style-spec-master' into merge-style-spec3
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
#	.npmignore
#	package.json
  • Loading branch information
Lucas Wojciechowski committed Feb 1, 2017
2 parents 5199aaf + 9de1e40 commit d92eb6e
Show file tree
Hide file tree
Showing 138 changed files with 16,813 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/docs/api/index.html
/docs/style-spec/index.html
/_site
/dist/mapbox-gl-dev.js
/dist/mapbox-gl.js
Expand Down
6 changes: 6 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

### `undefined`




47 changes: 47 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
ISC License

Copyright (c) 2016, Mapbox

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

--------------------------------------------------------------------------------

Contains a portion of d3-color https://github.com/d3/d3-color

Copyright 2010-2016 Mike Bostock
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Binary file added bench/unit/feature_filter/785.vector.pbf
Binary file not shown.
59 changes: 59 additions & 0 deletions bench/unit/feature_filter/bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use strict';

var VectorTile = require('vector-tile').VectorTile;
var Pbf = require('pbf');
var fs = require('fs');
var createFilter = require('../../../js/style-spec').featureFilter;
var filters = require('./filters.json');
var path = require('path');

var tile = new VectorTile(new Pbf(fs.readFileSync(path.join(__dirname, './785.vector.pbf'))));

var layers = [];
for (var name in tile.layers) {
var layer = tile.layers[name];
if (!layer.length) continue;

var features = [];
for (var j = 0; j < layer.length; j++) {
features.push(layer.feature(j));
}

var layerFilters = [];
for (j = 0; j < filters.length; j++) {
if (filters[j].layer === name) layerFilters.push(filters[j].filter);
}

layers.push({
name: name,
features: features,
rawFilters: layerFilters
});
}

console.time('create filters');
for (var m = 0; m < 100; m++) {
for (var i = 0; i < layers.length; i++) {
var layer = layers[i];
layer.filters = [];
for (j = 0; j < layer.rawFilters.length; j++) {
layer.filters.push(createFilter(layer.rawFilters[j]));
}
}
}
console.timeEnd('create filters');

console.time('apply filters');
for (var m = 0; m < 100; m++) {
for (var i = 0; i < layers.length; i++) {
var layer = layers[i];
for (j = 0; j < layer.features.length; j++) {
var feature = layer.features[j];
for (var k = 0; k < layer.filters.length; k++) {
var filter = layer.filters[k];
filter(feature);
}
}
}
}
console.timeEnd('apply filters');
21 changes: 21 additions & 0 deletions bench/unit/feature_filter/big.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

var filter = require('../../../js/style-spec').featureFilter;

var N = 64000;

var arr = ['in', 'foo'];
for (var i = 0; i < N; i++) arr.push(i);

console.time('create ' + N + '-item filter');
var f = filter(arr);
console.timeEnd('create ' + N + '-item filter');

var feature = {properties: {foo: 0}};

console.time('filter 1 million times');
for (var i = 0; i < 1000000; i++) {
feature.properties.foo = Math.floor(Math.random() * N * 2);
f(feature);
}
console.timeEnd('filter 1 million times');
Loading

0 comments on commit d92eb6e

Please sign in to comment.