Skip to content

Commit

Permalink
Merge branch 'master' into felix/mask-extension-wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored Jan 25, 2022
2 parents bb04560 + 29373c6 commit 603ffa0
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 96 deletions.
2 changes: 1 addition & 1 deletion docs/api-reference/google-maps/google-maps-overlay.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GoogleMapsOverlay

This class implements the [OverlayView](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#OverlayView)/[WebglOverlayView](https://developers.google.com/maps/documentation/javascript/reference/webgl#WebglOverlayView) (depending on map rendering type) interface and can be used as any other Google Maps overlay.
This class implements the [OverlayView](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#OverlayView)/[WebGLOverlayView](https://developers.google.com/maps/documentation/javascript/reference/webgl#WebGLOverlayView) (depending on map rendering type) interface and can be used as any other Google Maps overlay.

## Vector/Raster maps

Expand Down
37 changes: 21 additions & 16 deletions modules/carto/src/api/parseMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,28 @@ export function parseMap(json) {
initialViewState: mapState,
mapStyle,
layers: extractTextLayers(layers.reverse()).map(({id, type, config, visualChannels}) => {
log.assert(type in LAYER_MAP, `Unsupported layer type: ${type}`);
const {Layer, propMap, defaultProps} = LAYER_MAP[type];
try {
log.assert(type in LAYER_MAP, `Unsupported layer type: ${type}`);
const {Layer, propMap, defaultProps} = LAYER_MAP[type];

const {dataId} = config;
const dataset = datasets.find(d => d.id === dataId);
log.assert(dataset, `No dataset matching dataId: ${dataId}`);
const {data} = dataset;
log.assert(data, `No data loaded for dataId: ${dataId}`);
return new Layer({
id,
data,
...defaultProps,
...createBlendingProps(layerBlending),
...(!config.textLabel && createInteractionProps(interactionConfig)),
...createStyleProps(config, propMap),
...createChannelProps(visualChannels, type, config, data) // Must come after style
});
const {dataId} = config;
const dataset = datasets.find(d => d.id === dataId);
log.assert(dataset, `No dataset matching dataId: ${dataId}`);
const {data} = dataset;
log.assert(data, `No data loaded for dataId: ${dataId}`);
return new Layer({
id,
data,
...defaultProps,
...createBlendingProps(layerBlending),
...(!config.textLabel && createInteractionProps(interactionConfig)),
...createStyleProps(config, propMap),
...createChannelProps(visualChannels, type, config, data) // Must come after style
});
} catch (e) {
log.error(e.message)();
return undefined;
}
})
};
}
Expand Down
6 changes: 3 additions & 3 deletions modules/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"@luma.gl/core": "^8.5.10",
"@math.gl/core": "^3.5.6",
"@math.gl/web-mercator": "^3.5.6",
"@probe.gl/env": "^3.5.0-alpha.4",
"@probe.gl/log": "^3.5.0-alpha.4",
"@probe.gl/stats": "^3.5.0-alpha.4",
"@probe.gl/env": "^3.5.0",
"@probe.gl/log": "^3.5.0",
"@probe.gl/stats": "^3.5.0",
"gl-matrix": "^3.0.0",
"math.gl": "^3.5.6",
"mjolnir.js": "^2.5.0"
Expand Down
10 changes: 5 additions & 5 deletions modules/google-maps/src/google-maps-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export default class GoogleMapsOverlay {
if (renderingType === UNINITIALIZED) {
return;
}
const isVectorMap = renderingType === VECTOR && google.maps.WebglOverlayView;
const OverlayView = isVectorMap ? google.maps.WebglOverlayView : google.maps.OverlayView;
const isVectorMap = renderingType === VECTOR && google.maps.WebGLOverlayView;
const OverlayView = isVectorMap ? google.maps.WebGLOverlayView : google.maps.OverlayView;
const overlay = new OverlayView();

// Lifecycle methods are different depending on map type
Expand All @@ -110,7 +110,7 @@ export default class GoogleMapsOverlay {
this._deck = createDeckInstance(this._map, this._overlay, this._deck, this.props);
}

_onContextRestored(gl) {
_onContextRestored({gl}) {
const _customRender = () => {
this._overlay.requestRedraw();
};
Expand Down Expand Up @@ -171,15 +171,15 @@ export default class GoogleMapsOverlay {
}

// Vector code path
_onDrawVector(gl, coordinateTransformer) {
_onDrawVector({gl, transformer}) {
if (!this._deck || !this._map) {
return;
}

const deck = this._deck;

deck.setProps({
...getViewPropsFromCoordinateTransformer(this._map, coordinateTransformer)
...getViewPropsFromCoordinateTransformer(this._map, transformer)
});

if (deck.layerManager) {
Expand Down
16 changes: 5 additions & 11 deletions modules/google-maps/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,11 @@ export function getViewPropsFromOverlay(map, overlay) {
/**
* Get the current view state
* @param map (google.maps.Map) - The parent Map instance
* @param coordinateTransformer (google.maps.CoordinateTransformer) - A CoordinateTransformer instance
* @param transformer (google.maps.CoordinateTransformer) - A CoordinateTransformer instance
*/
export function getViewPropsFromCoordinateTransformer(map, coordinateTransformer) {
export function getViewPropsFromCoordinateTransformer(map, transformer) {
const {width, height} = getMapSize(map);
const {
lat: latitude,
lng: longitude,
heading: bearing,
tilt: pitch,
zoom
} = coordinateTransformer.getCameraParams();
const {center, heading: bearing, tilt: pitch, zoom} = transformer.getCameraParams();

// Match Google projection matrix
const fovy = 25;
Expand All @@ -191,8 +185,8 @@ export function getViewPropsFromCoordinateTransformer(map, coordinateTransformer
viewState: {
altitude: focalDistance,
bearing,
latitude,
longitude,
latitude: center.lat(),
longitude: center.lng(),
pitch,
projectionMatrix,
repeat: true,
Expand Down
2 changes: 1 addition & 1 deletion modules/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@deck.gl/core": "^8.0.0",
"@luma.gl/test-utils": "^8.5.0",
"@luma.gl/webgl": "^8.5.0",
"@probe.gl/test-utils": "3.5.0-alpha.4"
"@probe.gl/test-utils": "^3.5.0"
},
"scripts": {}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"@loaders.gl/csv": "^3.1.5",
"@loaders.gl/polyfills": "^3.1.5",
"@luma.gl/test-utils": "^8.5.10",
"@probe.gl/bench": "3.5.0-alpha.4",
"@probe.gl/test-utils": "3.5.0-alpha.4",
"@probe.gl/bench": "^3.5.0",
"@probe.gl/test-utils": "^3.5.0",
"abortcontroller-polyfill": "^1.5.0",
"babel-loader": "^8.0.0",
"babel-plugin-inline-webgl-constants": "^1.0.3",
Expand Down
12 changes: 12 additions & 0 deletions test/modules/carto/api/parseMap.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from 'tape-catch';
import VISSTATE_DATA from '../data/visState.json';
import UNSUPPORTED_LAYER_TYPE_VISSTATE_DATA from '../data/unsupportedLayerTypeVisState.json';
import {parseMap} from '@deck.gl/carto/api/parseMap';

const METADATA = {
Expand Down Expand Up @@ -119,4 +120,15 @@ for (const {title, visState, layers} of VISSTATE_DATA) {
});
}

test('parseMap#unsupported layer type', t => {
const json = {
...METADATA,
datasets: DATASETS,
keplerMapConfig: {version: 'v1', config: {visState: UNSUPPORTED_LAYER_TYPE_VISSTATE_DATA}}
};
const {layers} = parseMap(json);
t.deepEquals(layers, [undefined]);
t.end();
});

// TODO test for no matching dataId
48 changes: 48 additions & 0 deletions test/modules/carto/data/unsupportedLayerTypeVisState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"layers": [
{
"id": "vlu4f7d",
"type": "unsupported",
"config": {
"color": [18, 147, 154],
"label": "Stores",
"dataId": "DATA_ID",
"hidden": false,
"columns": {"lat": "latitude", "lng": "longitude", "altitude": null},
"isVisible": true,
"textLabel": [],
"visConfig": {
"filled": true,
"radius": 20.2,
"opacity": 0.42,
"outline": true,
"thickness": 4.5,
"colorRange": {
"name": "Global Warming",
"type": "sequential",
"colors": ["#5A1846", "#900C3F", "#C70039", "#E3611C", "#F1920E", "#FFC300"],
"category": "Uber"
},
"fixedRadius": false,
"radiusRange": [0, 50],
"strokeColor": [232, 250, 250],
"strokeColorRange": {
"name": "Global Warming",
"type": "sequential",
"colors": ["#5A1846", "#900C3F", "#C70039", "#E3611C", "#F1920E", "#FFC300"],
"category": "Uber"
}
},
"highlightColor": [252, 242, 26, 255]
},
"visualChannels": {
"sizeField": null,
"sizeScale": "linear",
"colorField": null,
"colorScale": "quantile",
"strokeColorField": {"name": "size_m2", "type": "integer"},
"strokeColorScale": "quantile"
}
}
]
}
14 changes: 8 additions & 6 deletions test/modules/google-maps/mock-maps-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ export class Map {
this._callbacks = {};

this.projection = new Projection(opts);
this.coordinateTransformer = {
this.transformer = {
getCameraParams: () => {
return {
lat: this.opts.latitude,
lng: this.opts.longitude,
center: {
lat: () => this.opts.latitude,
lng: () => this.opts.longitude
},
heading: this.getHeading(),
tilt: this.getTilt(),
zoom: this.getZoom()
Expand Down Expand Up @@ -119,7 +121,7 @@ export class Map {
if (this.getRenderingType() === RenderingType.RASTER) {
overlay.draw();
} else {
overlay.onDraw(undefined, this.coordinateTransformer);
overlay.onDraw({transformer: this.transformer});
}
}
}
Expand Down Expand Up @@ -161,7 +163,7 @@ export class Map {
this._overlays.add(overlay);
overlay.onAdd();
if (this.getRenderingType() === RenderingType.VECTOR) {
overlay.onContextRestored();
overlay.onContextRestored({});
}
}

Expand Down Expand Up @@ -198,7 +200,7 @@ export class OverlayView {
}
}

export class WebglOverlayView {
export class WebGLOverlayView {
constructor() {
this.map = null;
this._container = document.createElement('div');
Expand Down
70 changes: 19 additions & 51 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2802,28 +2802,28 @@
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.9.3.tgz#8b68da1ebd7fc603999cf6ebee34a4899a14b88e"
integrity sha512-xDu17cEfh7Kid/d95kB6tZsLOmSWKCZKtprnhVepjsSaCij+lM3mItSJDuuHDMbCWTh8Ejmebwb+KONcCJ0eXQ==

"@probe.gl/[email protected]-alpha.4":
version "3.5.0-alpha.4"
resolved "https://registry.yarnpkg.com/@probe.gl/bench/-/bench-3.5.0-alpha.4.tgz#50573e2f8bd347ee3ff931619ce31df91fc24a53"
integrity sha512-N70nDI/Cd71Q9v9p8Dyli0totCcZAwG+GiAPMluRmYLO5L5bGts4loeSXlvsa0ylMvBFwqabGhNB+jE3xyF+ew==
"@probe.gl/bench@^3.5.0":
version "3.5.0"
resolved "https://registry.yarnpkg.com/@probe.gl/bench/-/bench-3.5.0.tgz#54b0a3fe3912c4ad0f9c962daacf4a40f8c0075e"
integrity sha512-7E5UHxOAGxmwO446kpcVQeiXe+4ddODuFTgZ+svDkJMR3X2EltPuMsROfuKoSXz3RcLhoiyiK3PfvY65VvXGpQ==
dependencies:
"@babel/runtime" "^7.0.0"
"@probe.gl/log" "3.5.0-alpha.4"
"@probe.gl/log" "3.5.0"

"@probe.gl/[email protected]-alpha.4", "@probe.gl/env@^3.5.0-alpha.4":
version "3.5.0-alpha.4"
resolved "https://registry.yarnpkg.com/@probe.gl/env/-/env-3.5.0-alpha.4.tgz#7b902a16eff84f67a729960a28cff75636c66c2f"
integrity sha512-8QWv17Cb0xMCXMMyrFyVO2Bz2JPWGl59TU6+nzAk+LASkR9+bVAXbHt9Iq3BxznItJUyFj6uJUo4hDlq3YT3pA==
"@probe.gl/[email protected]", "@probe.gl/env@^3.5.0":
version "3.5.0"
resolved "https://registry.yarnpkg.com/@probe.gl/env/-/env-3.5.0.tgz#c6d8fbf414fda3eba7b3813cc274e76245216fe0"
integrity sha512-YdlpZZshhyYxvWDBmZ5RIW2pTR14Pw4p9czMlt/v7F6HbFzWfAdmH7q6xVwFRYxUpQLwhWensWyv4aFysiWl4g==
dependencies:
"@babel/runtime" "^7.0.0"

"@probe.gl/[email protected]-alpha.4", "@probe.gl/log@^3.5.0-alpha.4":
version "3.5.0-alpha.4"
resolved "https://registry.yarnpkg.com/@probe.gl/log/-/log-3.5.0-alpha.4.tgz#0c7c2a1412e8d3641739d03b00fd8cd7bfc27ec3"
integrity sha512-bqrma+KDrfubmPznWEtHGfjECkqoNg1CCEQrfSFzqWswkvJ6s40zoxZGh44n0OUOzMon8O83pXxBK2SC8seFEg==
"@probe.gl/[email protected]", "@probe.gl/log@^3.5.0":
version "3.5.0"
resolved "https://registry.yarnpkg.com/@probe.gl/log/-/log-3.5.0.tgz#6589822ab771eadf77787ffc6ecf73e59d181c64"
integrity sha512-nW/qz2X1xY08WU/TsmJP6/6IPNcaY5fS/vLjpC4ahJuE2Mezga4hGM/R2X5JWE/nkPc+BsC5GnAnD13rwAxS7g==
dependencies:
"@babel/runtime" "^7.0.0"
"@probe.gl/env" "3.5.0-alpha.4"
"@probe.gl/env" "3.5.0"

"@probe.gl/[email protected]":
version "3.4.0"
Expand All @@ -2832,45 +2832,21 @@
dependencies:
"@babel/runtime" "^7.0.0"

"@probe.gl/[email protected]":
version "3.4.1"
resolved "https://registry.yarnpkg.com/@probe.gl/stats/-/stats-3.4.1.tgz#5bc0ec5f87ae3195c22a98363e9c15031fbfe8e8"
integrity sha512-1Ol5cH8MQqIrGNgU4NCBj2cw1qiXYfHP1QCFX+u/xyrvgwLkPrOGkdSYMzw4VKTjJzNae4i7urOTf2m2hduZzQ==
dependencies:
"@babel/runtime" "^7.0.0"

"@probe.gl/stats@^3.5.0":
version "3.5.0"
resolved "https://registry.yarnpkg.com/@probe.gl/stats/-/stats-3.5.0.tgz#774495772f06e898aae28c1d315c9edac07f3425"
integrity sha512-IH2M+F3c8HR1DTroBARePUFG7wIewumtKA0UFqx51Z7S4hKrD60wFbpMmg0AcF4FvHAXMBoC+kYi1UKW9XbAOw==
dependencies:
"@babel/runtime" "^7.0.0"

"@probe.gl/stats@^3.5.0-alpha.4":
version "3.5.0-alpha.4"
resolved "https://registry.yarnpkg.com/@probe.gl/stats/-/stats-3.5.0-alpha.4.tgz#699d5487b17e0a52006cf726f7ee3a6ebbaae055"
integrity sha512-7F9arpLIoT1MJjah1XB5dUwKOGUwdoJJWdTZpkbOOZk4UyPkgvcg2TNAI49QLz0hupGpk6jDXML7GS8dgDZ8Tg==
dependencies:
"@babel/runtime" "^7.0.0"

"@probe.gl/[email protected]":
version "3.5.0-alpha.4"
resolved "https://registry.yarnpkg.com/@probe.gl/test-utils/-/test-utils-3.5.0-alpha.4.tgz#34d21648cf33ded712e438b1a6accd7e750be808"
integrity sha512-OIzvFHkfbu6C+Tnbzvm55wIWWzYaW2OGAwYoPdFGnIJdX6Nq68VpTyvHOaE1StrPuP9sh1gCe4QmTN0TnipeTw==
dependencies:
"@babel/runtime" "^7.0.0"
"@probe.gl/log" "3.5.0-alpha.4"
pixelmatch "^4.0.2"
puppeteer "*"

"@probe.gl/test-utils@^3.0.2":
version "3.4.1"
resolved "https://registry.yarnpkg.com/@probe.gl/test-utils/-/test-utils-3.4.1.tgz#d82d9e345945f8d361bc4460fb18a7844877b43c"
integrity sha512-Ur2w/Kb7NChNZTVks9J2xRr82FNnMkuSM9knyIP5ceY0l0kffmvOloE6Bnw1craCbH6oEuCakYm3SOh38tKKMQ==
"@probe.gl/test-utils@^3.0.2", "@probe.gl/test-utils@^3.5.0":
version "3.5.0"
resolved "https://registry.yarnpkg.com/@probe.gl/test-utils/-/test-utils-3.5.0.tgz#7a9335fd3f82fae38260063241f9de813f39640a"
integrity sha512-BBt1u7rcHvYkoMzQ6CMrJbKlKtl1mWNQ0ejcCkmL7r03rqCT7Qm04BfI+AJBaJLvNpCXNnC6W5yPhLRJLTzRwA==
dependencies:
"@babel/runtime" "^7.0.0"
"@probe.gl/log" "3.5.0"
pixelmatch "^4.0.2"
probe.gl "3.4.1"
puppeteer "*"

"@stencil/[email protected]":
Expand Down Expand Up @@ -10588,14 +10564,6 @@ pretty-error@^2.0.2:
renderkid "^2.0.1"
utila "~0.4"

[email protected]:
version "3.4.1"
resolved "https://registry.yarnpkg.com/probe.gl/-/probe.gl-3.4.1.tgz#88d8629fbac5a627049d6fdc6b8c364d56f00815"
integrity sha512-k/6YoZr6cBwnFpQLs/s4yZ8cCxapQzRrxl16EQg1b2wYXLlerDJ4PkNoQ3YDN9yu3Jcipipr+Avy1GRpyBF6ZA==
dependencies:
"@babel/runtime" "^7.0.0"
"@probe.gl/stats" "3.4.1"

probe.gl@^3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/probe.gl/-/probe.gl-3.4.0.tgz#f35029b0041fb909caff493ab23feae53339261e"
Expand Down

0 comments on commit 603ffa0

Please sign in to comment.