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

Add runtime-styling tests for 'smart setStyle' #170

Merged
merged 12 commits into from
Nov 22, 2016
29 changes: 18 additions & 11 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,32 @@ module.exports = function () {
}
}

// localize the source, glyphs, and sprite URLs in the given style JSON
function localizeStyleURLs (style) {
for (var k in style.sources) {
localizeSourceURLs(style.sources[k]);
}

if (style.sprite) {
style.sprite = localURL(style.sprite);
}

if (style.glyphs) {
style.glyphs = localURL(style.glyphs);
}
}

if (style.metadata && style.metadata.test && style.metadata.test.operations) {
style.metadata.test.operations.forEach(function (op) {
if (op[0] === 'addSource') {
localizeSourceURLs(op[2]);
} else if (op[0] === 'setStyle' && op[1]) {
localizeStyleURLs(op[1])
}
});
}

for (var k in style.sources) {
localizeSourceURLs(style.sources[k]);
}

if (style.sprite) {
style.sprite = localURL(style.sprite);
}

if (style.glyphs) {
style.glyphs = localURL(style.glyphs);
}
localizeStyleURLs(style)
}
};
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"version": 8,
"metadata": {
"ignored": {
"js": "https://github.com/mapbox/mapbox-gl-js/issues/3633"
},
"test": {
"width": 64,
"height": 64,
"operations": [
[ "removeLayer", "circle" ],
[
"addLayer",
{
"id": "circle",
"type": "circle",
"source": "geojson"
}
],
[
"wait"
]
]
}
},
"transition": {
"duration": 0
},
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
},
"sprite": "local://sprites/sprite",
"layers": [{
"id": "circle",
"type": "symbol",
"source": "geojson",
"layout": {
"icon-image": "dot.sdf"
},
"paint": {
"icon-color": "red"
}
}]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"version": 8,
"metadata": {
"test": {
"width": 64,
"height": 64,
"operations": [
[
"setStyle",
{
"version": 8,
"transition": {
"duration": 0
},
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "Feature",
"properties": {
"property": "a"
},
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
}
},
"sprite": "local://sprites/sprite",
"layers": [
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"layout": {
"icon-image": "circle-12"
},
"filter": [
"==",
"property",
"b"
]
}
]
}
],
[
"wait"
]
]
},
"ignored": {
"native": "https://github.com/mapbox/mapbox-gl-native/issues/2445"
}
},
"transition": {
"duration": 0
},
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "Feature",
"properties": {
"property": "a"
},
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
}
},
"sprite": "local://sprites/sprite",
"layers": [
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"layout": {
"icon-image": "circle-12"
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"version": 8,
"metadata": {
"test": {
"width": 64,
"height": 64,
"operations": [
[
"setStyle",
{
"version": 8,
"transition": {
"duration": 0
},
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "Feature",
"properties": {
"property": "a"
},
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
}
},
"sprite": "local://sprites/sprite",
"layers": [
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"layout": {
"icon-image": "circle-12"
},
"filter": [
"==",
"property",
"a"
]
}
]
}
],
[
"wait"
]
]
},
"ignored": {
"native": "https://github.com/mapbox/mapbox-gl-native/issues/2445"
}
},
"transition": {
"duration": 0
},
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "Feature",
"properties": {
"property": "a"
},
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
}
},
"sprite": "local://sprites/sprite",
"layers": [
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"layout": {
"icon-image": "circle-12"
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"version": 8,
"metadata": {
"test": {
"width": 64,
"height": 64,
"operations": [
[
"setStyle",
{
"version": 8,
"transition": {
"duration": 0
},
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "Feature",
"properties": {
"property": "a"
},
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
}
},
"sprite": "local://sprites/sprite",
"layers": [
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"layout": {
"icon-image": "circle-12"
}
}
]
}
],
[
"wait"
]
]
},
"ignored": {
"native": "https://github.com/mapbox/mapbox-gl-native/issues/2445"
}
},
"transition": {
"duration": 0
},
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "Feature",
"properties": {
"property": "a"
},
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
}
},
"sprite": "local://sprites/sprite",
"layers": [
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"layout": {
"icon-image": "circle-12"
},
"filter": [
"==",
"property",
false
]
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading