@deck.gl/geo-layers 8.9.11 → 8.9.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/dist.dev.js +33 -44
  2. package/dist.min.js +55 -55
  3. package/package.json +12 -12
  4. package/typed/geo-cell-layer/GeoCellLayer.js +49 -0
  5. package/typed/great-circle-layer/great-circle-layer.js +29 -0
  6. package/typed/h3-layers/h3-cluster-layer.js +33 -0
  7. package/typed/h3-layers/h3-hexagon-layer.js +251 -0
  8. package/typed/imagery-layer/imagery-layer.d.ts +53 -0
  9. package/typed/imagery-layer/imagery-layer.d.ts.map +1 -0
  10. package/typed/index.js +33 -0
  11. package/typed/mesh-layer/mesh-layer-fragment.glsl.js +55 -0
  12. package/typed/mesh-layer/mesh-layer-vertex.glsl.js +80 -0
  13. package/typed/mesh-layer/mesh-layer.js +110 -0
  14. package/typed/mvt-layer/coordinate-transform.js +41 -0
  15. package/typed/mvt-layer/find-index-binary.js +96 -0
  16. package/typed/mvt-layer/mvt-layer.js +297 -0
  17. package/typed/quadkey-layer/quadkey-layer.js +18 -0
  18. package/typed/quadkey-layer/quadkey-utils.js +26 -0
  19. package/typed/s2-layer/s2-geometry.js +123 -0
  20. package/typed/s2-layer/s2-layer.js +37 -0
  21. package/typed/s2-layer/s2-utils.js +88 -0
  22. package/typed/terrain-layer/terrain-layer.js +226 -0
  23. package/typed/tile-3d-layer/tile-3d-layer.js +294 -0
  24. package/typed/tile-layer/tile-2d-header.js +113 -0
  25. package/typed/tile-layer/tile-2d-traversal.js +181 -0
  26. package/typed/tile-layer/tile-layer.js +192 -0
  27. package/typed/tile-layer/tileset-2d.d.ts.map +1 -1
  28. package/typed/tile-layer/tileset-2d.js +399 -0
  29. package/typed/tile-layer/types.js +1 -0
  30. package/typed/tile-layer/utils.d.ts +1 -1
  31. package/typed/tile-layer/utils.d.ts.map +1 -1
  32. package/typed/tile-layer/utils.js +197 -0
  33. package/typed/trips-layer/trips-layer.js +92 -0
  34. package/typed/tile-3d-layer/utils.d.ts +0 -3
  35. package/typed/tile-3d-layer/utils.d.ts.map +0 -1
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@deck.gl/geo-layers",
3
3
  "description": "deck.gl layers supporting geospatial use cases and GIS formats",
4
4
  "license": "MIT",
5
- "version": "8.9.11",
5
+ "version": "8.9.13",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -30,16 +30,16 @@
30
30
  "prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
31
31
  },
32
32
  "dependencies": {
33
- "@loaders.gl/3d-tiles": "^3.3.3",
34
- "@loaders.gl/gis": "^3.3.3",
35
- "@loaders.gl/loader-utils": "^3.3.3",
36
- "@loaders.gl/mvt": "^3.3.3",
37
- "@loaders.gl/schema": "^3.3.3",
38
- "@loaders.gl/terrain": "^3.3.3",
39
- "@loaders.gl/tiles": "^3.3.3",
40
- "@loaders.gl/wms": "^3.3.3",
41
- "@luma.gl/constants": "^8.5.16",
42
- "@luma.gl/experimental": "^8.5.16",
33
+ "@loaders.gl/3d-tiles": "^3.3.4",
34
+ "@loaders.gl/gis": "^3.3.4",
35
+ "@loaders.gl/loader-utils": "^3.3.4",
36
+ "@loaders.gl/mvt": "^3.3.4",
37
+ "@loaders.gl/schema": "^3.3.4",
38
+ "@loaders.gl/terrain": "^3.3.4",
39
+ "@loaders.gl/tiles": "^3.3.4",
40
+ "@loaders.gl/wms": "^3.3.4",
41
+ "@luma.gl/constants": "^8.5.20",
42
+ "@luma.gl/experimental": "^8.5.20",
43
43
  "@math.gl/core": "^3.6.2",
44
44
  "@math.gl/culling": "^3.6.2",
45
45
  "@math.gl/web-mercator": "^3.6.2",
@@ -55,5 +55,5 @@
55
55
  "@loaders.gl/core": "^3.3.0",
56
56
  "@luma.gl/core": "^8.0.0"
57
57
  },
58
- "gitHead": "ec059b9b2bde01fecc8017ed39b9898d85794561"
58
+ "gitHead": "6e0fdd9f81c1156103df2701e6688cf0c2fa9320"
59
59
  }
@@ -0,0 +1,49 @@
1
+ import { CompositeLayer } from '@deck.gl/core';
2
+ import { PolygonLayer } from '@deck.gl/layers';
3
+ const defaultProps = {
4
+ ...PolygonLayer.defaultProps
5
+ };
6
+ export default class GeoCellLayer extends CompositeLayer {
7
+ /** Implement to generate props to create geometry. */
8
+ indexToBounds() {
9
+ return null;
10
+ }
11
+ renderLayers() {
12
+ // Rendering props underlying layer
13
+ const { elevationScale, extruded, wireframe, filled, stroked, lineWidthUnits, lineWidthScale, lineWidthMinPixels, lineWidthMaxPixels, lineJointRounded, lineMiterLimit, lineDashJustified, getElevation, getFillColor, getLineColor, getLineWidth } = this.props;
14
+ // Accessor props for underlying layers
15
+ const { updateTriggers, material, transitions } = this.props;
16
+ // Filled Polygon Layer
17
+ const CellLayer = this.getSubLayerClass('cell', PolygonLayer);
18
+ return new CellLayer({
19
+ filled,
20
+ wireframe,
21
+ extruded,
22
+ elevationScale,
23
+ stroked,
24
+ lineWidthUnits,
25
+ lineWidthScale,
26
+ lineWidthMinPixels,
27
+ lineWidthMaxPixels,
28
+ lineJointRounded,
29
+ lineMiterLimit,
30
+ lineDashJustified,
31
+ material,
32
+ transitions,
33
+ getElevation,
34
+ getFillColor,
35
+ getLineColor,
36
+ getLineWidth
37
+ }, this.getSubLayerProps({
38
+ id: 'cell',
39
+ updateTriggers: updateTriggers && {
40
+ getElevation: updateTriggers.getElevation,
41
+ getFillColor: updateTriggers.getFillColor,
42
+ getLineColor: updateTriggers.getLineColor,
43
+ getLineWidth: updateTriggers.getLineWidth
44
+ }
45
+ }), this.indexToBounds());
46
+ }
47
+ }
48
+ GeoCellLayer.layerName = 'GeoCellLayer';
49
+ GeoCellLayer.defaultProps = defaultProps;
@@ -0,0 +1,29 @@
1
+ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ import { ArcLayer } from '@deck.gl/layers';
21
+ // This layer has been merged into the core ArcLayer
22
+ // Keeping for backward-compatibility
23
+ export default class GreatCircleLayer extends ArcLayer {
24
+ }
25
+ GreatCircleLayer.layerName = 'GreatCircleLayer';
26
+ GreatCircleLayer.defaultProps = {
27
+ getHeight: { type: 'accessor', value: 0 },
28
+ greatCircle: true
29
+ };
@@ -0,0 +1,33 @@
1
+ import { h3SetToMultiPolygon } from 'h3-js';
2
+ import { createIterable } from '@deck.gl/core';
3
+ import GeoCellLayer from '../geo-cell-layer/GeoCellLayer';
4
+ const defaultProps = {
5
+ getHexagons: { type: 'accessor', value: d => d.hexagons }
6
+ };
7
+ export default class H3ClusterLayer extends GeoCellLayer {
8
+ updateState({ props, oldProps, changeFlags }) {
9
+ if (changeFlags.dataChanged ||
10
+ (changeFlags.updateTriggers && changeFlags.updateTriggers.getHexagons)) {
11
+ const { data, getHexagons } = props;
12
+ const polygons = [];
13
+ const { iterable, objectInfo } = createIterable(data);
14
+ for (const object of iterable) {
15
+ objectInfo.index++;
16
+ const hexagons = getHexagons(object, objectInfo);
17
+ const multiPolygon = h3SetToMultiPolygon(hexagons, true);
18
+ for (const polygon of multiPolygon) {
19
+ polygons.push(this.getSubLayerRow({ polygon }, object, objectInfo.index));
20
+ }
21
+ }
22
+ this.setState({ polygons });
23
+ }
24
+ }
25
+ indexToBounds() {
26
+ return {
27
+ data: this.state.polygons,
28
+ getPolygon: d => d.polygon
29
+ };
30
+ }
31
+ }
32
+ H3ClusterLayer.defaultProps = defaultProps;
33
+ H3ClusterLayer.layerName = 'H3ClusterLayer';
@@ -0,0 +1,251 @@
1
+ import { h3ToGeoBoundary, h3GetResolution, h3ToGeo, geoToH3, h3IsPentagon, h3Distance, edgeLength, UNITS } from 'h3-js';
2
+ import { lerp } from '@math.gl/core';
3
+ import { CompositeLayer, createIterable } from '@deck.gl/core';
4
+ import { ColumnLayer, PolygonLayer } from '@deck.gl/layers';
5
+ // There is a cost to updating the instanced geometries when using highPrecision: false
6
+ // This constant defines the distance between two hexagons that leads to "significant
7
+ // distortion." Smaller value makes the column layer more sensitive to viewport change.
8
+ const UPDATE_THRESHOLD_KM = 10;
9
+ // normalize longitudes w.r.t center (refLng), when not provided first vertex
10
+ export function normalizeLongitudes(vertices, refLng) {
11
+ refLng = refLng === undefined ? vertices[0][0] : refLng;
12
+ for (const pt of vertices) {
13
+ const deltaLng = pt[0] - refLng;
14
+ if (deltaLng > 180) {
15
+ pt[0] -= 360;
16
+ }
17
+ else if (deltaLng < -180) {
18
+ pt[0] += 360;
19
+ }
20
+ }
21
+ }
22
+ // scale polygon vertices w.r.t center (hexId)
23
+ export function scalePolygon(hexId, vertices, factor) {
24
+ const [lat, lng] = h3ToGeo(hexId);
25
+ const actualCount = vertices.length;
26
+ // normalize with respect to center
27
+ normalizeLongitudes(vertices, lng);
28
+ // `h3ToGeoBoundary` returns same array object for first and last vertex (closed polygon),
29
+ // if so skip scaling the last vertex
30
+ const vertexCount = vertices[0] === vertices[actualCount - 1] ? actualCount - 1 : actualCount;
31
+ for (let i = 0; i < vertexCount; i++) {
32
+ vertices[i][0] = lerp(lng, vertices[i][0], factor);
33
+ vertices[i][1] = lerp(lat, vertices[i][1], factor);
34
+ }
35
+ }
36
+ function getHexagonCentroid(getHexagon, object, objectInfo) {
37
+ const hexagonId = getHexagon(object, objectInfo);
38
+ const [lat, lng] = h3ToGeo(hexagonId);
39
+ return [lng, lat];
40
+ }
41
+ function h3ToPolygon(hexId, coverage = 1, flatten) {
42
+ const vertices = h3ToGeoBoundary(hexId, true);
43
+ if (coverage !== 1) {
44
+ // scale and normalize vertices w.r.t to center
45
+ scalePolygon(hexId, vertices, coverage);
46
+ }
47
+ else {
48
+ // normalize w.r.t to start vertex
49
+ normalizeLongitudes(vertices);
50
+ }
51
+ if (flatten) {
52
+ const positions = new Float64Array(vertices.length * 2);
53
+ let i = 0;
54
+ for (const pt of vertices) {
55
+ positions[i++] = pt[0];
56
+ positions[i++] = pt[1];
57
+ }
58
+ return positions;
59
+ }
60
+ return vertices;
61
+ }
62
+ function mergeTriggers(getHexagon, coverage) {
63
+ let trigger;
64
+ if (getHexagon === undefined || getHexagon === null) {
65
+ trigger = coverage;
66
+ }
67
+ else if (typeof getHexagon === 'object') {
68
+ trigger = { ...getHexagon, coverage };
69
+ }
70
+ else {
71
+ trigger = { getHexagon, coverage };
72
+ }
73
+ return trigger;
74
+ }
75
+ const defaultProps = {
76
+ ...PolygonLayer.defaultProps,
77
+ highPrecision: 'auto',
78
+ coverage: { type: 'number', min: 0, max: 1, value: 1 },
79
+ centerHexagon: null,
80
+ getHexagon: { type: 'accessor', value: x => x.hexagon },
81
+ extruded: true
82
+ };
83
+ // not supported
84
+ delete defaultProps.getLineDashArray;
85
+ /**
86
+ * A subclass of HexagonLayer that uses H3 hexagonIds in data objects
87
+ * rather than centroid lat/longs. The shape of each hexagon is determined
88
+ * based on a single "center" hexagon, which can be selected by passing in
89
+ * a center lat/lon pair. If not provided, the map center will be used.
90
+ *
91
+ * Also sets the `hexagonId` field in the onHover/onClick callback's info
92
+ * objects. Since this is calculated using math, hexagonId will be present
93
+ * even when no corresponding hexagon is in the data set. You can check
94
+ * index !== -1 to see if picking matches an actual object.
95
+ */
96
+ export default class H3HexagonLayer extends CompositeLayer {
97
+ shouldUpdateState({ changeFlags }) {
98
+ return this._shouldUseHighPrecision()
99
+ ? changeFlags.propsOrDataChanged
100
+ : changeFlags.somethingChanged;
101
+ }
102
+ updateState({ props, oldProps, changeFlags }) {
103
+ if (props.highPrecision !== true &&
104
+ (changeFlags.dataChanged ||
105
+ (changeFlags.updateTriggers && changeFlags.updateTriggers.getHexagon))) {
106
+ const dataProps = this._calculateH3DataProps(props);
107
+ this.setState(dataProps);
108
+ }
109
+ this._updateVertices(this.context.viewport);
110
+ }
111
+ _calculateH3DataProps(props) {
112
+ let resolution = -1;
113
+ let hasPentagon = false;
114
+ let hasMultipleRes = false;
115
+ const { iterable, objectInfo } = createIterable(props.data);
116
+ for (const object of iterable) {
117
+ objectInfo.index++;
118
+ const hexId = props.getHexagon(object, objectInfo);
119
+ // Take the resolution of the first hex
120
+ const hexResolution = h3GetResolution(hexId);
121
+ if (resolution < 0) {
122
+ resolution = hexResolution;
123
+ if (!props.highPrecision)
124
+ break;
125
+ }
126
+ else if (resolution !== hexResolution) {
127
+ hasMultipleRes = true;
128
+ break;
129
+ }
130
+ if (h3IsPentagon(hexId)) {
131
+ hasPentagon = true;
132
+ break;
133
+ }
134
+ }
135
+ return {
136
+ resolution,
137
+ edgeLengthKM: resolution >= 0 ? edgeLength(resolution, UNITS.km) : 0,
138
+ hasMultipleRes,
139
+ hasPentagon
140
+ };
141
+ }
142
+ _shouldUseHighPrecision() {
143
+ if (this.props.highPrecision === 'auto') {
144
+ const { resolution, hasPentagon, hasMultipleRes } = this.state;
145
+ const { viewport } = this.context;
146
+ return (viewport.resolution || hasMultipleRes || hasPentagon || (resolution >= 0 && resolution <= 5));
147
+ }
148
+ return this.props.highPrecision;
149
+ }
150
+ _updateVertices(viewport) {
151
+ if (this._shouldUseHighPrecision()) {
152
+ return;
153
+ }
154
+ const { resolution, edgeLengthKM, centerHex } = this.state;
155
+ if (resolution < 0) {
156
+ return;
157
+ }
158
+ const hex = this.props.centerHexagon || geoToH3(viewport.latitude, viewport.longitude, resolution);
159
+ if (centerHex === hex) {
160
+ return;
161
+ }
162
+ if (centerHex) {
163
+ const distance = h3Distance(centerHex, hex);
164
+ // h3Distance returns a negative number if the distance could not be computed
165
+ // due to the two indexes very far apart or on opposite sides of a pentagon.
166
+ if (distance >= 0 && distance * edgeLengthKM < UPDATE_THRESHOLD_KM) {
167
+ return;
168
+ }
169
+ }
170
+ const { unitsPerMeter } = viewport.distanceScales;
171
+ let vertices = h3ToPolygon(hex);
172
+ const [centerLat, centerLng] = h3ToGeo(hex);
173
+ const [centerX, centerY] = viewport.projectFlat([centerLng, centerLat]);
174
+ vertices = vertices.map(p => {
175
+ const worldPosition = viewport.projectFlat(p);
176
+ return [
177
+ (worldPosition[0] - centerX) / unitsPerMeter[0],
178
+ (worldPosition[1] - centerY) / unitsPerMeter[1]
179
+ ];
180
+ });
181
+ this.setState({ centerHex: hex, vertices });
182
+ }
183
+ renderLayers() {
184
+ return this._shouldUseHighPrecision() ? this._renderPolygonLayer() : this._renderColumnLayer();
185
+ }
186
+ _getForwardProps() {
187
+ const { elevationScale, material, coverage, extruded, wireframe, stroked, filled, lineWidthUnits, lineWidthScale, lineWidthMinPixels, lineWidthMaxPixels, getFillColor, getElevation, getLineColor, getLineWidth, transitions, updateTriggers } = this.props;
188
+ return {
189
+ elevationScale,
190
+ extruded,
191
+ coverage,
192
+ wireframe,
193
+ stroked,
194
+ filled,
195
+ lineWidthUnits,
196
+ lineWidthScale,
197
+ lineWidthMinPixels,
198
+ lineWidthMaxPixels,
199
+ material,
200
+ getElevation,
201
+ getFillColor,
202
+ getLineColor,
203
+ getLineWidth,
204
+ transitions,
205
+ updateTriggers: {
206
+ getFillColor: updateTriggers.getFillColor,
207
+ getElevation: updateTriggers.getElevation,
208
+ getLineColor: updateTriggers.getLineColor,
209
+ getLineWidth: updateTriggers.getLineWidth
210
+ }
211
+ };
212
+ }
213
+ _renderPolygonLayer() {
214
+ const { data, getHexagon, updateTriggers, coverage } = this.props;
215
+ const SubLayerClass = this.getSubLayerClass('hexagon-cell-hifi', PolygonLayer);
216
+ const forwardProps = this._getForwardProps();
217
+ forwardProps.updateTriggers.getPolygon = mergeTriggers(updateTriggers.getHexagon, coverage);
218
+ return new SubLayerClass(forwardProps, this.getSubLayerProps({
219
+ id: 'hexagon-cell-hifi',
220
+ updateTriggers: forwardProps.updateTriggers
221
+ }), {
222
+ data,
223
+ _normalize: false,
224
+ _windingOrder: 'CCW',
225
+ positionFormat: 'XY',
226
+ getPolygon: (object, objectInfo) => {
227
+ const hexagonId = getHexagon(object, objectInfo);
228
+ return h3ToPolygon(hexagonId, coverage, true);
229
+ }
230
+ });
231
+ }
232
+ _renderColumnLayer() {
233
+ const { data, getHexagon, updateTriggers } = this.props;
234
+ const SubLayerClass = this.getSubLayerClass('hexagon-cell', ColumnLayer);
235
+ const forwardProps = this._getForwardProps();
236
+ forwardProps.updateTriggers.getPosition = updateTriggers.getHexagon;
237
+ return new SubLayerClass(forwardProps, this.getSubLayerProps({
238
+ id: 'hexagon-cell',
239
+ flatShading: true,
240
+ updateTriggers: forwardProps.updateTriggers
241
+ }), {
242
+ data,
243
+ diskResolution: 6,
244
+ radius: 1,
245
+ vertices: this.state.vertices,
246
+ getPosition: getHexagonCentroid.bind(null, getHexagon)
247
+ });
248
+ }
249
+ }
250
+ H3HexagonLayer.defaultProps = defaultProps;
251
+ H3HexagonLayer.layerName = 'H3HexagonLayer';
@@ -0,0 +1,53 @@
1
+ import { Layer, CompositeLayer, CompositeLayerProps, UpdateParameters, DefaultProps, Viewport } from '@deck.gl/core/typed';
2
+ import type { ImageSourceMetadata, ImageType, ImageServiceType } from '@loaders.gl/wms';
3
+ import { ImageSource } from '@loaders.gl/wms';
4
+ /** All props supported by the TileLayer */
5
+ export declare type ImageryLayerProps = CompositeLayerProps<any> & _ImageryLayerProps;
6
+ /** Props added by the TileLayer */
7
+ declare type _ImageryLayerProps = {
8
+ serviceType?: ImageServiceType | 'auto';
9
+ layers?: string[];
10
+ srs?: 'EPSG:4326' | 'EPSG:3857' | 'auto';
11
+ onMetadataLoadStart?: () => void;
12
+ onMetadataLoadComplete?: (metadata: ImageSourceMetadata) => void;
13
+ onMetadataLoadError?: (error: Error) => void;
14
+ onImageLoadStart?: (requestId: unknown) => void;
15
+ onImageLoadComplete?: (requestId: unknown) => void;
16
+ onImageLoadError?: (requestId: unknown, error: Error) => void;
17
+ };
18
+ /**
19
+ * The layer is used in Hex Tile layer in order to properly discard invisible elements during animation
20
+ */
21
+ export declare class ImageryLayer<ExtraPropsT extends {} = {}> extends CompositeLayer<ExtraPropsT & Required<_ImageryLayerProps>> {
22
+ static layerName: string;
23
+ static defaultProps: DefaultProps;
24
+ state: {
25
+ imageSource: ImageSource;
26
+ image: ImageType;
27
+ srs: 'EPSG:4326' | 'EPSG:3857';
28
+ bounds: [number, number, number, number];
29
+ width: number;
30
+ height: number;
31
+ lastLoadedId: number;
32
+ _nextRequestId: number;
33
+ _timeoutId: any;
34
+ };
35
+ /** Lets deck.gl know that we want viewport change events */
36
+ shouldUpdateState(): boolean;
37
+ initializeState(): void;
38
+ updateState({ changeFlags, props, oldProps }: UpdateParameters<this>): void;
39
+ finalizeState(): void;
40
+ renderLayers(): Layer;
41
+ getFeatureInfoText(x: number, y: number): Promise<string | null>;
42
+ _createImageSource(props: ImageryLayerProps): ImageSource;
43
+ /** Run a getMetadata on the image service */
44
+ _loadMetadata(): Promise<void>;
45
+ /** Load an image */
46
+ loadImage(viewport: Viewport, reason: string): Promise<void>;
47
+ /** Global counter for issuing unique request ids */
48
+ private getRequestId;
49
+ /** Runs an action in the future, cancels it if the new action is issued before it executes */
50
+ private debounce;
51
+ }
52
+ export {};
53
+ //# sourceMappingURL=imagery-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imagery-layer.d.ts","sourceRoot":"","sources":["../../src/imagery-layer/imagery-layer.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,EACL,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EAGT,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAC,mBAAmB,EAAE,SAAS,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAC,WAAW,EAAoB,MAAM,iBAAiB,CAAC;AAG/D,2CAA2C;AAC3C,oBAAY,iBAAiB,GAAG,mBAAmB,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC;AAE9E,mCAAmC;AACnC,aAAK,kBAAkB,GAAG;IACxB,WAAW,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,MAAM,CAAC;IACzC,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,sBAAsB,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACjE,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC7C,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACnD,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/D,CAAC;AAwBF;;GAEG;AACH,qBAAa,YAAY,CAAC,WAAW,SAAS,EAAE,GAAG,EAAE,CAAE,SAAQ,cAAc,CAC3E,WAAW,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CAC3C;IACC,MAAM,CAAC,SAAS,SAAkB;IAClC,MAAM,CAAC,YAAY,EAAE,YAAY,CAAgB;IAEjD,KAAK,EAAG;QACN,WAAW,EAAE,WAAW,CAAC;QACzB,KAAK,EAAE,SAAS,CAAC;QACjB,GAAG,EAAE,WAAW,GAAG,WAAW,CAAC;QAC/B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACzC,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE,MAAM,CAAC;QAErB,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,GAAG,CAAC;KACjB,CAAC;IAEF,4DAA4D;IACnD,iBAAiB,IAAI,OAAO;IAI5B,eAAe,IAAI,IAAI;IAMvB,WAAW,CAAC,EAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI;IAgBzE,aAAa,IAAI,IAAI;IAIrB,YAAY,IAAI,KAAK;IAiBxB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAsBtE,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,WAAW;IAgBzD,6CAA6C;IACvC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAepC,oBAAoB;IACd,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA+ClE,oDAAoD;IACpD,OAAO,CAAC,YAAY;IAIpB,8FAA8F;IAC9F,OAAO,CAAC,QAAQ;CAIjB"}
package/typed/index.js ADDED
@@ -0,0 +1,33 @@
1
+ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ /* eslint-disable max-len */
21
+ export { default as GreatCircleLayer } from './great-circle-layer/great-circle-layer';
22
+ export { default as S2Layer } from './s2-layer/s2-layer';
23
+ export { default as QuadkeyLayer } from './quadkey-layer/quadkey-layer';
24
+ export { default as TileLayer } from './tile-layer/tile-layer';
25
+ export { default as TripsLayer } from './trips-layer/trips-layer';
26
+ export { default as H3ClusterLayer } from './h3-layers/h3-cluster-layer';
27
+ export { default as H3HexagonLayer } from './h3-layers/h3-hexagon-layer';
28
+ export { default as Tile3DLayer } from './tile-3d-layer/tile-3d-layer';
29
+ export { default as TerrainLayer } from './terrain-layer/terrain-layer';
30
+ export { default as MVTLayer } from './mvt-layer/mvt-layer';
31
+ export { getURLFromTemplate as _getURLFromTemplate } from './tile-layer/utils';
32
+ export { default as _Tileset2D } from './tile-layer/tileset-2d';
33
+ export { default as _Tile2DHeader } from './tile-layer/tile-2d-header';
@@ -0,0 +1,55 @@
1
+ export default `#version 300 es
2
+ #define SHADER_NAME simple-mesh-layer-fs
3
+
4
+ precision highp float;
5
+
6
+ uniform bool hasTexture;
7
+ uniform sampler2D sampler;
8
+ uniform bool flatShading;
9
+ uniform float opacity;
10
+
11
+ in vec2 vTexCoord;
12
+ in vec3 cameraPosition;
13
+ in vec3 normals_commonspace;
14
+ in vec4 position_commonspace;
15
+ in vec4 vColor;
16
+
17
+ out vec4 fragColor;
18
+
19
+ void main(void) {
20
+
21
+ #ifdef MODULE_PBR
22
+
23
+ fragColor = vColor * pbr_filterColor(vec4(0));
24
+ geometry.uv = pbr_vUV;
25
+ fragColor.a *= opacity;
26
+
27
+ #else
28
+
29
+ geometry.uv = vTexCoord;
30
+
31
+ vec3 normal;
32
+ if (flatShading) {
33
+
34
+ // NOTE(Tarek): This is necessary because
35
+ // headless.gl reports the extension as
36
+ // available but does not support it in
37
+ // the shader.
38
+ #ifdef DERIVATIVES_AVAILABLE
39
+ normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
40
+ #else
41
+ normal = vec3(0.0, 0.0, 1.0);
42
+ #endif
43
+ } else {
44
+ normal = normals_commonspace;
45
+ }
46
+
47
+ vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;
48
+ vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
49
+ fragColor = vec4(lightColor, color.a * opacity);
50
+
51
+ #endif
52
+
53
+ DECKGL_FILTER_COLOR(fragColor, geometry);
54
+ }
55
+ `;
@@ -0,0 +1,80 @@
1
+ export default `#version 300 es
2
+ #define SHADER_NAME simple-mesh-layer-vs
3
+
4
+ // Scale the model
5
+ uniform float sizeScale;
6
+ uniform bool composeModelMatrix;
7
+ uniform bool u_pickFeatureIds;
8
+
9
+ // Primitive attributes
10
+ in vec3 positions;
11
+ in vec3 normals;
12
+ in vec3 colors;
13
+ in vec2 texCoords;
14
+ in vec4 uvRegions;
15
+ in vec3 featureIdsPickingColors;
16
+
17
+ // Instance attributes
18
+ in vec4 instanceColors;
19
+ in vec3 instancePickingColors;
20
+ in mat3 instanceModelMatrix;
21
+
22
+ // Outputs to fragment shader
23
+ out vec2 vTexCoord;
24
+ out vec3 cameraPosition;
25
+ out vec3 normals_commonspace;
26
+ out vec4 position_commonspace;
27
+ out vec4 vColor;
28
+
29
+ vec2 applyUVRegion(vec2 uv) {
30
+ #ifdef HAS_UV_REGIONS
31
+ // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md
32
+ return fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;
33
+ #else
34
+ return uv;
35
+ #endif
36
+ }
37
+
38
+ void main(void) {
39
+ vec2 uv = applyUVRegion(texCoords);
40
+ geometry.uv = uv;
41
+
42
+ if (u_pickFeatureIds) {
43
+ geometry.pickingColor = featureIdsPickingColors;
44
+ } else {
45
+ geometry.pickingColor = instancePickingColors;
46
+ }
47
+
48
+ vTexCoord = uv;
49
+ cameraPosition = project_uCameraPosition;
50
+ vColor = vec4(colors * instanceColors.rgb, instanceColors.a);
51
+
52
+ vec3 pos = (instanceModelMatrix * positions) * sizeScale;
53
+ vec3 projectedPosition = project_position(positions);
54
+ position_commonspace = vec4(projectedPosition, 1.0);
55
+ gl_Position = project_common_position_to_clipspace(position_commonspace);
56
+
57
+ geometry.position = position_commonspace;
58
+ normals_commonspace = project_normal(instanceModelMatrix * normals);
59
+ geometry.normal = normals_commonspace;
60
+
61
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
62
+
63
+ #ifdef MODULE_PBR
64
+ // set PBR data
65
+ pbr_vPosition = geometry.position.xyz;
66
+ #ifdef HAS_NORMALS
67
+ pbr_vNormal = geometry.normal;
68
+ #endif
69
+
70
+ #ifdef HAS_UV
71
+ pbr_vUV = uv;
72
+ #else
73
+ pbr_vUV = vec2(0., 0.);
74
+ #endif
75
+ geometry.uv = pbr_vUV;
76
+ #endif
77
+
78
+ DECKGL_FILTER_COLOR(vColor, geometry);
79
+ }
80
+ `;