Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add vector style fixtures and unit tests

ZachTRice64f187966526
diff --git a/web/js/fixtures.js b/web/js/fixtures.js
index c79eefd46..541de10ab 100644
--- a/web/js/fixtures.js
+++ b/web/js/fixtures.js
@@ -66,6 +66,114 @@ fixtures.getState = function() {
colors: [fixtures.light_red, fixtures.red, fixtures.dark_red]
}
}
+ },
+ vectorStyles: {
+ custom: {
+ OrbitTracks_Aura_Ascending: {
+ 'version': 8,
+ 'name': 'Orbit Tracks',
+ 'sources': {
+ 'OrbitTracks_Aqua_Ascending': {
+ 'type': 'vector',
+ 'tiles': [
+ 'https://gibs.earthdata.nasa.gov/wmts/epsg4326/nrt/OrbitTracks_Aqua_Ascending/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.mvt'
+ ]
+ },
+ 'yellow1': {
+ 'type': 'vector',
+ 'tiles': [
+ 'https://gibs.earthdata.nasa.gov/wmts/epsg4326/nrt/OrbitTracks_Aqua_Ascending/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.mvt'
+ ]
+ }
+ },
+ 'layers': [
+ {
+ 'id': 'OrbitTracks_Aqua_Ascending',
+ 'source': 'OrbitTracks_Aqua_Ascending',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Default',
+ 'type': 'line',
+ 'paint': {
+ 'line-color': 'rgb(21, 192, 230)',
+ 'line-width': 2
+ }
+ },
+ {
+ 'id': 'OrbitTracks_Aqua_Ascending',
+ 'source': 'OrbitTracks_Aqua_Ascending',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Default',
+ 'type': 'circle',
+ 'paint': {
+ 'circle-radius': '5',
+ 'circle-color': 'rgb(21, 192, 230)'
+ }
+ },
+ {
+ 'id': 'OrbitTracks_Aqua_Ascending',
+ 'source': 'OrbitTracks_Aqua_Ascending',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Default',
+ 'type': 'symbol',
+ 'layout': {
+ 'text-field': ['get', 'label'],
+ 'text-font': ['Open Sans Bold', 'Arial Unicode MS Bold'],
+ 'text-size': 10,
+ 'text-transform': 'uppercase',
+ 'text-letter-spacing': 0.05,
+ 'text-offset': [-2.5, 0]
+ },
+ 'paint': {
+ 'text-color': '#fff',
+ 'text-halo-color': '#999',
+ 'text-halo-width': 1
+ }
+ },
+ {
+ 'id': 'yellow1',
+ 'source': 'yellow1',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Yellow 1',
+ 'type': 'line',
+ 'paint': {
+ 'line-color': 'rgb(204, 255, 51)',
+ 'line-width': 2
+ }
+ },
+ {
+ 'id': 'yellow1',
+ 'source': 'yellow1',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Yellow 1',
+ 'type': 'circle',
+ 'paint': {
+ 'circle-radius': '5',
+ 'circle-color': 'rgb(204, 255, 51)'
+ }
+ },
+ {
+ 'id': 'yellow1',
+ 'source': 'yellow1',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Yellow 1',
+ 'type': 'symbol',
+ 'layout': {
+ 'text-field': ['get', 'label'],
+ 'text-font': ['Open Sans Bold', 'Arial Unicode MS Bold'],
+ 'text-size': 10,
+ 'text-transform': 'uppercase',
+ 'text-letter-spacing': 0.05,
+ 'text-offset': [-2.5, 0]
+ },
+ 'paint': {
+ 'text-color': '#fff',
+ 'text-halo-color': '#999',
+ 'text-halo-width': 1
+ }
+ }
+ ]
+ }
+ }
}
};
};
@@ -172,6 +280,23 @@ fixtures.config = function() {
projections: {
geographic: {}
}
+ },
+ OrbitTracks_Aqua_Ascending: {
+ id: 'OrbitTracks_Aqua_Ascending',
+ title: 'Orbit Tracks (Ascending, Points, Aqua)',
+ subtitle: '',
+ description: 'vector/OrbitTracks_Aqua_Ascending',
+ type: 'vector',
+ tags: 'vector vectors',
+ group: 'overlays',
+ layergroup: [
+ 'vector'
+ ],
+ inactive: true,
+ vectorStyle: {
+ id: 'OrbitTracks_Aqua_Ascending'
+ },
+ period: 'daily'
}
},
features: {
@@ -271,6 +396,169 @@ fixtures.config = function() {
colors: [fixtures.light_red, fixtures.red, fixtures.dark_red]
}
}
+ },
+ vectorData: {
+ OrbitTracks: {
+ id: 'Orbit_Tracks',
+ mvt_properties: [
+ {
+ Function: 'Style',
+ Description: 'Up/Down/Both',
+ IsOptional: 'False',
+ Title: 'Direction of travel',
+ DataType: 'string',
+ ValueList: [
+ 'Ascending',
+ 'Descending',
+ 'Transitional'
+ ],
+ Identifier: 'direction'
+ },
+ {
+ Function: 'Describe',
+ Description: 'The datetime, in UTC.',
+ IsOptional: 'False',
+ Title: 'Datetime',
+ DataType: 'datetime',
+ Identifier: 'datetime'
+ },
+ {
+ Function: 'Describe',
+ Description: 'Was it day or night?',
+ IsOptional: 'False',
+ Title: 'Day/Night Flag',
+ DataType: 'string',
+ ValueList: [
+ 'Day',
+ 'Night',
+ 'Both'
+ ],
+ Identifier: 'day_night'
+ },
+ {
+ Function: 'Describe',
+ Description: 'Just an ID',
+ IsOptional: 'False',
+ Title: 'Identifier',
+ DataType: 'int',
+ Identifier: 'id'
+ },
+ {
+ Function: 'Identify',
+ Description: 'Default time (hh:mm:ss).',
+ IsOptional: 'False',
+ Title: 'Label for default display',
+ DataType: 'string',
+ Identifier: 'label'
+ }
+ ]
+ }
+ },
+ vectorStyles: {
+ OrbitTracks_Aura_Ascending: {
+ 'version': 8,
+ 'name': 'Orbit Tracks',
+ 'sources': {
+ 'OrbitTracks_Aqua_Ascending': {
+ 'type': 'vector',
+ 'tiles': [
+ 'https://gibs.earthdata.nasa.gov/wmts/epsg4326/nrt/OrbitTracks_Aqua_Ascending/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.mvt'
+ ]
+ },
+ 'yellow1': {
+ 'type': 'vector',
+ 'tiles': [
+ 'https://gibs.earthdata.nasa.gov/wmts/epsg4326/nrt/OrbitTracks_Aqua_Ascending/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.mvt'
+ ]
+ }
+ },
+ 'layers': [
+ {
+ 'id': 'OrbitTracks_Aqua_Ascending',
+ 'source': 'OrbitTracks_Aqua_Ascending',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Default',
+ 'type': 'line',
+ 'paint': {
+ 'line-color': 'rgb(21, 192, 230)',
+ 'line-width': 2
+ }
+ },
+ {
+ 'id': 'OrbitTracks_Aqua_Ascending',
+ 'source': 'OrbitTracks_Aqua_Ascending',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Default',
+ 'type': 'circle',
+ 'paint': {
+ 'circle-radius': '5',
+ 'circle-color': 'rgb(21, 192, 230)'
+ }
+ },
+ {
+ 'id': 'OrbitTracks_Aqua_Ascending',
+ 'source': 'OrbitTracks_Aqua_Ascending',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Default',
+ 'type': 'symbol',
+ 'layout': {
+ 'text-field': ['get', 'label'],
+ 'text-font': ['Open Sans Bold', 'Arial Unicode MS Bold'],
+ 'text-size': 10,
+ 'text-transform': 'uppercase',
+ 'text-letter-spacing': 0.05,
+ 'text-offset': [-2.5, 0]
+ },
+ 'paint': {
+ 'text-color': '#fff',
+ 'text-halo-color': '#999',
+ 'text-halo-width': 1
+ }
+ },
+ {
+ 'id': 'yellow1',
+ 'source': 'yellow1',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Yellow 1',
+ 'type': 'line',
+ 'paint': {
+ 'line-color': 'rgb(204, 255, 51)',
+ 'line-width': 2
+ }
+ },
+ {
+ 'id': 'yellow1',
+ 'source': 'yellow1',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Yellow 1',
+ 'type': 'circle',
+ 'paint': {
+ 'circle-radius': '5',
+ 'circle-color': 'rgb(204, 255, 51)'
+ }
+ },
+ {
+ 'id': 'yellow1',
+ 'source': 'yellow1',
+ 'source-layer': 'OrbitTracks_Aqua_Ascending',
+ 'source-description': 'Yellow 1',
+ 'type': 'symbol',
+ 'layout': {
+ 'text-field': ['get', 'label'],
+ 'text-font': ['Open Sans Bold', 'Arial Unicode MS Bold'],
+ 'text-size': 10,
+ 'text-transform': 'uppercase',
+ 'text-letter-spacing': 0.05,
+ 'text-offset': [-2.5, 0]
+ },
+ 'paint': {
+ 'text-color': '#fff',
+ 'text-halo-color': '#999',
+ 'text-halo-width': 1
+ }
+ }
+ ]
+ }
}
};
};
diff --git a/web/js/modules/layers/util.test.js b/web/js/modules/layers/util.test.js
index 7f656a826..36af503b2 100644
--- a/web/js/modules/layers/util.test.js
+++ b/web/js/modules/layers/util.test.js
@@ -8,48 +8,69 @@ import { initialState } from './reducers';
import fixtures from '../../fixtures';
import { assign } from 'lodash';
const config = fixtures.config();
-const LAYER_STRING =
+const PALETTE_LAYER_STRING =
'AMSRE_Brightness_Temp_89H_Night(hidden,opacity=0.54,palette=red_2,min=224,225,max=294,295,squash=true),mask';
+const VECTOR_LAYER_STRING =
+ 'OrbitTracks_Aqua_Ascending(hidden,opacity=0.46,style=yellow1),mask';
-test('Layer parser, retrieves correct number of layers from permalink string', () => {
- const layers = layersParse12(LAYER_STRING, config);
+test('Layer parser, retrieves correct number of palette layers from permalink string', () => {
+ const layers = layersParse12(PALETTE_LAYER_STRING, config);
expect(layers.length).toBe(2);
});
-test('Layer parser, gets correct ID', () => {
- const layers = layersParse12(LAYER_STRING, config);
+test('Layer parser, gets correct palette layer ID', () => {
+ const layers = layersParse12(PALETTE_LAYER_STRING, config);
const layer = layers[0];
expect(layer.id).toBe('AMSRE_Brightness_Temp_89H_Night');
});
test('Layer parser, gets correct custom palette id from permalink string', () => {
- const layers = layersParse12(LAYER_STRING, config);
+ const layers = layersParse12(PALETTE_LAYER_STRING, config);
const layer = layers[0];
expect(layer.custom[0]).toBe('red_2');
});
test('Layer parser, gets squashed boolean from permalink string', () => {
- const layers = layersParse12(LAYER_STRING, config);
+ const layers = layersParse12(PALETTE_LAYER_STRING, config);
const layer = layers[0];
expect(layer.squash[0]).toBe(true);
});
test('Layer parser, gets correct min value from permalink string', () => {
- const layers = layersParse12(LAYER_STRING, config);
+ const layers = layersParse12(PALETTE_LAYER_STRING, config);
const layer = layers[0];
expect(layer.min[0]).toBe(224);
});
test('Layer parser, gets correct max value from permalink string', () => {
- const layers = layersParse12(LAYER_STRING, config);
+ const layers = layersParse12(PALETTE_LAYER_STRING, config);
const layer = layers[0];
expect(layer.max[0]).toBe(294);
});
test('Layer parser, gets correct max value from permalink string', () => {
- const layers = layersParse12(LAYER_STRING, config);
+ const layers = layersParse12(PALETTE_LAYER_STRING, config);
const layer = layers[0];
expect(layer.opacity).toBe(0.54);
});
-test('Layer parser, retrieves hidden layer from permalink string', () => {
- const layers = layersParse12(LAYER_STRING, config);
+test('Layer parser, retrieves hidden palette layer from permalink string', () => {
+ const layers = layersParse12(PALETTE_LAYER_STRING, config);
const layer = layers[0];
expect(layer.opacity).toBe(0.54);
});
+test('Layer parser, retrieves correct number of vector layers from permalink string', () => {
+ const layers = layersParse12(VECTOR_LAYER_STRING, config);
+ expect(layers.length).toBe(2);
+});
+test('Layer parser, gets correct vector layer ID', () => {
+ const layers = layersParse12(VECTOR_LAYER_STRING, config);
+ const layer = layers[0];
+ expect(layer.id).toBe('OrbitTracks_Aqua_Ascending');
+});
+test('Layer parser, gets correct custom vector style id from permalink string', () => {
+ const layers = layersParse12(VECTOR_LAYER_STRING, config);
+ const layer = layers[0];
+ expect(layer.custom[0]).toBe('yellow1');
+});
+test('Layer parser, retrieves hidden vector layer from permalink string', () => {
+ const layers = layersParse12(VECTOR_LAYER_STRING, config);
+ const layer = layers[0];
+ expect(layer.opacity).toBe(0.46);
+});
test('serialize layers and palettes', () => {
let terraAodLayer = config.layers['terra-aod'];
const paletteState = {
diff --git a/web/js/modules/vector-styles/selectors.js b/web/js/modules/vector-styles/selectors.js
index 7df71c699..fc83a56c0 100644
--- a/web/js/modules/vector-styles/selectors.js
+++ b/web/js/modules/vector-styles/selectors.js
@@ -135,7 +135,7 @@ export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state)
}
});
}
- return glStyle; // this is wrong
+ return vectorStyleId;
}
export function getKey(layerId, groupStr, state) {