Skip to content

Commit f307760

Browse files
committed
Reformat with prettier
1 parent 7af0cd2 commit f307760

28 files changed

+250
-244
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ insert_final_newline = true
1010
indent_style = space
1111
charset = utf-8
1212
indent_size = 2
13+
trim_trailing_whitespace = true
1314

1415
# Matches multiple files with brace expansion notation
1516
# Set default charset

docs/webgl-modules/custom-modules.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ float average_calc(vec4 image) {
2727
`;
2828

2929
export default {
30-
name: "average",
30+
name: 'average',
3131
fs,
3232
inject: {
33-
"fs:DECKGL_MUTATE_COLOR": `
33+
'fs:DECKGL_MUTATE_COLOR': `
3434
image = vec4(average_calc(image), 0., 0., 0.);
3535
`,
3636
},

docs/webgl-modules/spectral-indices.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ normalized_difference = (x - y) / (x + y)
1313
```
1414

1515
`normalized_difference` always uses the _first two_ bands in the pre-assembled
16-
image as `x` and `y` respectively.
16+
image as `x` and `y` respectively.
1717

1818
To create the [Normalized difference vegetation index (NDVI)][ndvi], for
1919
example, you would pass the near-infrared band and the red band as the first two
2020
images to the `imageBands` prop in the [`combineBands` module][combine-bands].
2121

2222
## `enhancedVegetationIndex`
2323

24-
Computes the [Enhanced Vegetation Index (EVI)][evi].
24+
Computes the [Enhanced Vegetation Index (EVI)][evi].
2525

2626
Layers are expected to exist as **near-infrared, red, and blue** bands on the
2727
input image, respectively. For example, with Landsat 8 data, you would pass
@@ -30,7 +30,7 @@ module][combine-bands] in that order.
3030

3131
## `soilAdjustedVegetationIndex`
3232

33-
Computes the [Soil Adjusted Vegetation Index (SAVI)][savi].
33+
Computes the [Soil Adjusted Vegetation Index (SAVI)][savi].
3434

3535
Layers are expected to exist as **near-infrared and red** bands on the input
3636
image, respectively. For example, with Landsat 8 data, you would pass bands 5
@@ -39,17 +39,15 @@ that order.
3939

4040
## `modifiedSoilAdjustedVegetationIndex`
4141

42-
Computes the [Modified Soil Adjusted Vegetation Index (MSAVI)][msavi].
42+
Computes the [Modified Soil Adjusted Vegetation Index (MSAVI)][msavi].
4343

4444
Layers are expected to exist as **near-infrared and red** bands on the input
4545
image, respectively. For example, with Landsat 8 data, you would pass bands 5
4646
and 4 to the `imageBands` prop in the [`combineBands` module][combine-bands] in
4747
that order.
4848

49-
5049
[ndvi]: https://en.wikipedia.org/wiki/Normalized_difference_vegetation_index
5150
[evi]: https://www.usgs.gov/land-resources/nli/landsat/landsat-enhanced-vegetation-index-evi
5251
[savi]: https://www.usgs.gov/land-resources/nli/landsat/landsat-soil-adjusted-vegetation-index-savi
5352
[msavi]: https://www.usgs.gov/land-resources/nli/landsat/landsat-modified-soil-adjusted-vegetation-index-msavi
54-
5553
[combine-bands]: create-image.md#combinebands

examples/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33
### Developing
44

5-
Run `yarn link` in the root directory, and then `yarn link
6-
"@kylebarron/deck.gl-raster"` in each example directory in order to link to the
5+
Run `yarn link` in the root directory, and then `yarn link "@kylebarron/deck.gl-raster"` in each example directory in order to link to the
76
most recent changes locally.

examples/raster-layer/src/App.js

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React from "react";
2-
import DeckGL from "@deck.gl/react";
1+
import React from 'react';
2+
import DeckGL from '@deck.gl/react';
33

4-
import { PostProcessEffect } from "@deck.gl/core";
5-
import { TileLayer } from "@deck.gl/geo-layers";
4+
import {PostProcessEffect} from '@deck.gl/core';
5+
import {TileLayer} from '@deck.gl/geo-layers';
66

77
import {
88
RasterLayer,
@@ -11,40 +11,45 @@ import {
1111
modifiedSoilAdjustedVegetationIndex,
1212
normalizedDifference,
1313
colormap,
14-
} from "@kylebarron/deck.gl-raster";
14+
} from '@kylebarron/deck.gl-raster';
1515

16-
import { load } from "@loaders.gl/core";
17-
import { ImageLoader } from "@loaders.gl/images";
16+
import {load} from '@loaders.gl/core';
17+
import {ImageLoader} from '@loaders.gl/images';
1818

19-
import { vibrance } from "@luma.gl/shadertools";
20-
import GL from "@luma.gl/constants";
19+
import {vibrance} from '@luma.gl/shadertools';
20+
import GL from '@luma.gl/constants';
2121

2222
const initialViewState = {
2323
longitude: -112.1861,
2424
latitude: 36.1284,
2525
zoom: 11.5,
2626
pitch: 0,
2727
bearing: 0,
28+
// My landsat tile server doesn't support very low zooms
29+
minZoom: 6,
2830
};
2931

30-
const MOSAIC_URL = "dynamodb://us-west-2/landsat8-2019-spring";
32+
// NOTE: others should change this URL
33+
// Refer to `cogeo-mosaic` documentation for more information on mosaic backends
34+
// https://github.com/developmentseed/cogeo-mosaic
35+
const MOSAIC_URL = 'dynamodb://us-west-2/landsat8-2019-spring';
3136

3237
function colorStr(nBands) {
33-
const colorBands = "RGB".slice(0, nBands);
38+
const colorBands = 'RGB'.slice(0, nBands);
3439
let colorStr = `gamma ${colorBands} 3.5, sigmoidal ${colorBands} 15 0.35`;
3540

3641
if (nBands === 3) {
37-
colorStr += ", saturation 1.7";
42+
colorStr += ', saturation 1.7';
3843
}
3944
return colorStr;
4045
}
4146

4247
function landsatUrl(options) {
43-
const { bands, url, x, y, z } = options;
48+
const {bands, url, x, y, z} = options;
4449
const bandsArray = Array.isArray(bands) ? bands : [bands];
4550
const params = {
4651
url,
47-
bands: bandsArray.join(","),
52+
bands: bandsArray.join(','),
4853
color_ops: colorStr(bandsArray.length),
4954
};
5055
const searchParams = new URLSearchParams(params);
@@ -61,15 +66,15 @@ export default class App extends React.Component {
6166
render() {
6267
const layers = [
6368
new TileLayer({
64-
minZoom: 0,
69+
minZoom: 7,
6570
maxZoom: 12,
6671
tileSize: 256,
6772
getTileData,
6873
renderSubLayers: (props) => {
6974
const {
70-
bbox: { west, south, east, north },
75+
bbox: {west, south, east, north},
7176
} = props.tile;
72-
const { modules, images, ...moduleProps } = props.data;
77+
const {modules, images, ...moduleProps} = props.data;
7378
return new RasterLayer(props, {
7479
images,
7580
modules,
@@ -88,35 +93,37 @@ export default class App extends React.Component {
8893
controller
8994
glOptions={{
9095
// Tell browser to use discrete GPU if available
91-
powerPreference: "high-performance",
96+
powerPreference: 'high-performance',
9297
}}
9398
/>
9499
);
95100
}
96101
}
97102

98-
async function getTileData({ x, y, z }) {
99-
// BAND CONFIGURATION
100-
// In a real application the following would come from props
101-
const landsatBands = [5, 4];
103+
async function getTileData({
104+
x,
105+
y,
106+
z,
107+
landsatBands = [5, 4],
108+
useColormap = true,
109+
}) {
102110
const usePan =
103111
z >= 12 &&
104112
landsatBands[0] === 4 &&
105113
landsatBands[1] === 3 &&
106114
landsatBands[2] === 2;
107-
const useColormap = true;
108115
const colormapUrl =
109-
"https://cdn.jsdelivr.net/gh/kylebarron/deck.gl-raster/assets/colormaps/cfastie.png";
116+
'https://cdn.jsdelivr.net/gh/kylebarron/deck.gl-raster/assets/colormaps/cfastie.png';
110117
const modules = [combineBands, normalizedDifference];
111118

112119
const bandsUrls = landsatBands.map((band) =>
113-
landsatUrl({ x, y, z, bands: band, url: MOSAIC_URL })
120+
landsatUrl({x, y, z, bands: band, url: MOSAIC_URL})
114121
);
115122
const imageBands = bandsUrls.map((url) => loadImage(url));
116123

117124
let imagePan;
118125
if (usePan) {
119-
const panUrl = landsatUrl({ x, y, z, bands: 8, url: MOSAIC_URL });
126+
const panUrl = landsatUrl({x, y, z, bands: 8, url: MOSAIC_URL});
120127
imagePan = loadImage(panUrl);
121128
modules.push(pansharpenBrovey);
122129
}

examples/raster-layer/src/App.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
2-
import { render } from '@testing-library/react';
2+
import {render} from '@testing-library/react';
33
import App from './App';
44

55
test('renders learn react link', () => {
6-
const { getByText } = render(<App />);
6+
const {getByText} = render(<App />);
77
const linkElement = getByText(/learn react/i);
88
expect(linkElement).toBeInTheDocument();
99
});

examples/raster-layer/src/serviceWorker.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function register(config) {
5757
function registerValidSW(swUrl, config) {
5858
navigator.serviceWorker
5959
.register(swUrl)
60-
.then(registration => {
60+
.then((registration) => {
6161
registration.onupdatefound = () => {
6262
const installingWorker = registration.installing;
6363
if (installingWorker == null) {
@@ -93,25 +93,25 @@ function registerValidSW(swUrl, config) {
9393
};
9494
};
9595
})
96-
.catch(error => {
96+
.catch((error) => {
9797
console.error('Error during service worker registration:', error);
9898
});
9999
}
100100

101101
function checkValidServiceWorker(swUrl, config) {
102102
// Check if the service worker can be found. If it can't reload the page.
103103
fetch(swUrl, {
104-
headers: { 'Service-Worker': 'script' },
104+
headers: {'Service-Worker': 'script'},
105105
})
106-
.then(response => {
106+
.then((response) => {
107107
// Ensure service worker exists, and that we really are getting a JS file.
108108
const contentType = response.headers.get('content-type');
109109
if (
110110
response.status === 404 ||
111111
(contentType != null && contentType.indexOf('javascript') === -1)
112112
) {
113113
// No service worker found. Probably a different app. Reload the page.
114-
navigator.serviceWorker.ready.then(registration => {
114+
navigator.serviceWorker.ready.then((registration) => {
115115
registration.unregister().then(() => {
116116
window.location.reload();
117117
});
@@ -131,10 +131,10 @@ function checkValidServiceWorker(swUrl, config) {
131131
export function unregister() {
132132
if ('serviceWorker' in navigator) {
133133
navigator.serviceWorker.ready
134-
.then(registration => {
134+
.then((registration) => {
135135
registration.unregister();
136136
})
137-
.catch(error => {
137+
.catch((error) => {
138138
console.error(error.message);
139139
});
140140
}

examples/raster-mesh-layer/src/App.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
import React from "react";
2-
import DeckGL from "@deck.gl/react";
3-
import { TerrainTileLayer } from "./terrain-tile-layer";
1+
import React from 'react';
2+
import DeckGL from '@deck.gl/react';
3+
import {TerrainTileLayer} from './terrain-tile-layer';
44

55
const INITIAL_VIEW_STATE = {
66
latitude: 46.21,
77
longitude: -122.18,
88
zoom: 11.5,
99
bearing: 140,
1010
pitch: 60,
11+
// My landsat tile server doesn't support very low zooms
12+
minZoom: 6,
1113
maxPitch: 80,
1214
};
1315

1416
export default class App extends React.Component {
1517
render() {
16-
const layers = TerrainTileLayer({ minZoom: 7, maxZoom: 12 });
18+
const layers = TerrainTileLayer({minZoom: 7, maxZoom: 12});
1719

1820
return (
1921
<DeckGL
@@ -22,7 +24,7 @@ export default class App extends React.Component {
2224
layers={layers}
2325
glOptions={{
2426
// Tell browser to use discrete GPU if available
25-
powerPreference: "high-performance",
27+
powerPreference: 'high-performance',
2628
}}
2729
/>
2830
);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
2-
import { render } from '@testing-library/react';
2+
import {render} from '@testing-library/react';
33
import App from './App';
44

55
test('renders learn react link', () => {
6-
const { getByText } = render(<App />);
6+
const {getByText} = render(<App />);
77
const linkElement = getByText(/learn react/i);
88
expect(linkElement).toBeInTheDocument();
99
});

examples/raster-mesh-layer/src/serviceWorker.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function register(config) {
5757
function registerValidSW(swUrl, config) {
5858
navigator.serviceWorker
5959
.register(swUrl)
60-
.then(registration => {
60+
.then((registration) => {
6161
registration.onupdatefound = () => {
6262
const installingWorker = registration.installing;
6363
if (installingWorker == null) {
@@ -93,25 +93,25 @@ function registerValidSW(swUrl, config) {
9393
};
9494
};
9595
})
96-
.catch(error => {
96+
.catch((error) => {
9797
console.error('Error during service worker registration:', error);
9898
});
9999
}
100100

101101
function checkValidServiceWorker(swUrl, config) {
102102
// Check if the service worker can be found. If it can't reload the page.
103103
fetch(swUrl, {
104-
headers: { 'Service-Worker': 'script' },
104+
headers: {'Service-Worker': 'script'},
105105
})
106-
.then(response => {
106+
.then((response) => {
107107
// Ensure service worker exists, and that we really are getting a JS file.
108108
const contentType = response.headers.get('content-type');
109109
if (
110110
response.status === 404 ||
111111
(contentType != null && contentType.indexOf('javascript') === -1)
112112
) {
113113
// No service worker found. Probably a different app. Reload the page.
114-
navigator.serviceWorker.ready.then(registration => {
114+
navigator.serviceWorker.ready.then((registration) => {
115115
registration.unregister().then(() => {
116116
window.location.reload();
117117
});
@@ -131,10 +131,10 @@ function checkValidServiceWorker(swUrl, config) {
131131
export function unregister() {
132132
if ('serviceWorker' in navigator) {
133133
navigator.serviceWorker.ready
134-
.then(registration => {
134+
.then((registration) => {
135135
registration.unregister();
136136
})
137-
.catch(error => {
137+
.catch((error) => {
138138
console.error(error.message);
139139
});
140140
}

0 commit comments

Comments
 (0)