DECKGL integration - Phase 1 (#3771)

* DECKGL integration

Adding a new set of geospatial visualizations building on top of the
awesome deck.gl library. https://github.com/uber/deck.gl

While the end goal it to expose all types of layers and let users bind
their data to control most props exposed by the deck.gl API, this
PR focusses on a first set of visualizations and props:

* ScatterLayer
* HexagonLayer
* GridLayer
* ScreenGridLayer

* Addressing comments

* lint

* Linting

* Addressing chri's comments
This commit is contained in:
Maxime Beauchemin
2017-11-16 00:30:02 -08:00
committed by Grace Guo
parent 1c545d3a2d
commit 3a8af5d0b0
31 changed files with 1308 additions and 11 deletions

View File

@@ -142,3 +142,13 @@ export const colorScalerFactory = function (colors, data, accessor, extents) {
const points = colors.map((col, i) => ext[0] + (i * chunkSize));
return d3.scale.linear().domain(points).range(colors).clamp(true);
};
export function hexToRGB(hex, alpha = 255) {
if (!hex) {
return [0, 0, 0, alpha];
}
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return [r, g, b, alpha];
}

View File

@@ -0,0 +1,25 @@
export const defaultViewport = {
longitude: 6.85236157047845,
latitude: 31.222656842808707,
zoom: 1,
bearing: 0,
pitch: 0,
};
const METER_TO_MILE = 1609.34;
export function unitToRadius(unit, num) {
if (unit === 'square_m') {
return Math.sqrt(num / Math.PI);
} else if (unit === 'radius_m') {
return num;
} else if (unit === 'radius_km') {
return num * 1000;
} else if (unit === 'radius_miles') {
return num * METER_TO_MILE;
} else if (unit === 'square_km') {
return Math.sqrt(num / Math.PI) * 1000;
} else if (unit === 'square_miles') {
return Math.sqrt(num / Math.PI) * METER_TO_MILE;
}
return null;
}