@focusbc/bbs-lib 0.0.2
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.
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/overlay/index.d.ts +2 -0
- package/dist/overlay/index.d.ts.map +1 -0
- package/dist/overlay/index.js +2 -0
- package/dist/overlay/index.js.map +1 -0
- package/dist/overlay/map-object-to-shape-instance.mapper.d.ts +9 -0
- package/dist/overlay/map-object-to-shape-instance.mapper.d.ts.map +1 -0
- package/dist/overlay/map-object-to-shape-instance.mapper.js +75 -0
- package/dist/overlay/map-object-to-shape-instance.mapper.js.map +1 -0
- package/dist/overlay/map-overlay.d.ts +86 -0
- package/dist/overlay/map-overlay.d.ts.map +1 -0
- package/dist/overlay/map-overlay.js +289 -0
- package/dist/overlay/map-overlay.js.map +1 -0
- package/dist/overlay/overlay-dynamic-layer.builder.d.ts +16 -0
- package/dist/overlay/overlay-dynamic-layer.builder.d.ts.map +1 -0
- package/dist/overlay/overlay-dynamic-layer.builder.js +202 -0
- package/dist/overlay/overlay-dynamic-layer.builder.js.map +1 -0
- package/dist/overlay/overlay-static-layer.builder.d.ts +20 -0
- package/dist/overlay/overlay-static-layer.builder.d.ts.map +1 -0
- package/dist/overlay/overlay-static-layer.builder.js +97 -0
- package/dist/overlay/overlay-static-layer.builder.js.map +1 -0
- package/dist/types/events.d.ts +9 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +2 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/overlay-options.d.ts +25 -0
- package/dist/types/overlay-options.d.ts.map +1 -0
- package/dist/types/overlay-options.js +2 -0
- package/dist/types/overlay-options.js.map +1 -0
- package/dist/types/shape-instance.d.ts +15 -0
- package/dist/types/shape-instance.d.ts.map +1 -0
- package/dist/types/shape-instance.js +2 -0
- package/dist/types/shape-instance.js.map +1 -0
- package/dist/types/shape-style.d.ts +16 -0
- package/dist/types/shape-style.d.ts.map +1 -0
- package/dist/types/shape-style.js +2 -0
- package/dist/types/shape-style.js.map +1 -0
- package/dist/types/shape-type.d.ts +35 -0
- package/dist/types/shape-type.d.ts.map +1 -0
- package/dist/types/shape-type.js +2 -0
- package/dist/types/shape-type.js.map +1 -0
- package/dist/utils/rotation.utils.d.ts +18 -0
- package/dist/utils/rotation.utils.d.ts.map +1 -0
- package/dist/utils/rotation.utils.js +27 -0
- package/dist/utils/rotation.utils.js.map +1 -0
- package/package.json +50 -0
- package/readme.md +154 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { FbcEditableDynamicLayer, LayerObjectLabelFamily, LayerObjectPolygonPattern, ModeType, ObjectType, } from '@focusbc/map-rendering';
|
|
2
|
+
import { default as destination } from '@turf/destination';
|
|
3
|
+
import { point, polygon } from '@turf/helpers';
|
|
4
|
+
import turfTransformRotate from '@turf/transform-rotate';
|
|
5
|
+
import { RotationUtils } from '../utils/rotation.utils';
|
|
6
|
+
const SHAPES_LAYER_ID = 'bbs-shapes';
|
|
7
|
+
export class OverlayDynamicLayerBuilder {
|
|
8
|
+
constructor(_shapes) {
|
|
9
|
+
this._shapes = _shapes;
|
|
10
|
+
this._selectedShapeId = null;
|
|
11
|
+
this._edit = false;
|
|
12
|
+
this._onSelect = () => { };
|
|
13
|
+
this._onEdit = () => { };
|
|
14
|
+
}
|
|
15
|
+
setSelectedShapeId(shapeId) {
|
|
16
|
+
this._selectedShapeId = shapeId;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
setEdit(edit) {
|
|
20
|
+
this._edit = edit;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
setOnSelect(onSelect) {
|
|
24
|
+
this._onSelect = onSelect;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
setOnEdit(onEdit) {
|
|
28
|
+
this._onEdit = onEdit;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
build() {
|
|
32
|
+
const mapPolygon = (polygon) => {
|
|
33
|
+
return [...polygon.map((point) => [point[0], point[1]]), [polygon[0][0], polygon[0][1]]];
|
|
34
|
+
};
|
|
35
|
+
const objects = [];
|
|
36
|
+
for (const shape of this._shapes) {
|
|
37
|
+
const segments = ShapeInstanceToShapeSegmentsMapper.map(shape);
|
|
38
|
+
for (const segment of segments) {
|
|
39
|
+
objects.push({
|
|
40
|
+
id: segment.shapeId + Math.random(),
|
|
41
|
+
groupId: segment.shapeId,
|
|
42
|
+
geometry: {
|
|
43
|
+
type: 'MultiPolygon',
|
|
44
|
+
coordinates: [[mapPolygon(segment.polygon)]],
|
|
45
|
+
style: segment.style,
|
|
46
|
+
},
|
|
47
|
+
type: ObjectType.POLYGON,
|
|
48
|
+
visible: true,
|
|
49
|
+
selectable: true,
|
|
50
|
+
rotatable: true,
|
|
51
|
+
scalable: true,
|
|
52
|
+
config: {
|
|
53
|
+
shape: 'Polygon',
|
|
54
|
+
},
|
|
55
|
+
editable: true,
|
|
56
|
+
style: {
|
|
57
|
+
pattern: LayerObjectPolygonPattern.NONE,
|
|
58
|
+
label: {
|
|
59
|
+
size: 10,
|
|
60
|
+
color: segment.style?.textColorHex ?? '#000000',
|
|
61
|
+
family: LayerObjectLabelFamily.ARIAL,
|
|
62
|
+
weight: 400,
|
|
63
|
+
opacity: 100,
|
|
64
|
+
},
|
|
65
|
+
borderFormat: {
|
|
66
|
+
gap: 0,
|
|
67
|
+
width: 1,
|
|
68
|
+
},
|
|
69
|
+
fillColor: segment.style?.backgroundColorHex ?? '#000000',
|
|
70
|
+
fillOpacity: 100,
|
|
71
|
+
borderColor: segment.style?.borderColorHex,
|
|
72
|
+
borderOpacity: 100,
|
|
73
|
+
borderSize: segment.style?.borderWidth ?? 1,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return new FbcEditableDynamicLayer({
|
|
79
|
+
selectedIndexes: this._selectedShapeId
|
|
80
|
+
? objects.flatMap((object, index) => (object.groupId === this._selectedShapeId ? [index] : []))
|
|
81
|
+
: undefined,
|
|
82
|
+
id: SHAPES_LAYER_ID,
|
|
83
|
+
data: objects,
|
|
84
|
+
mode: this._edit ? ModeType.TRANSFORM : ModeType.VIEW,
|
|
85
|
+
pickable: true,
|
|
86
|
+
modeConfig: {
|
|
87
|
+
onSelect: (result) => {
|
|
88
|
+
this._onSelect(result);
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
onEdit: (result) => {
|
|
92
|
+
this._onEdit(result);
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//#region Shape Segment
|
|
98
|
+
const DEFAULT_WIDTH_METERS = 6;
|
|
99
|
+
class ShapeInstanceToShapeSegmentsMapper {
|
|
100
|
+
static map(shape) {
|
|
101
|
+
const widthMeters = shape.type.widthInMeters || DEFAULT_WIDTH_METERS;
|
|
102
|
+
const ratio = shape.type.ratio > 0 ? shape.type.ratio : 1;
|
|
103
|
+
const heightMeters = widthMeters * ratio;
|
|
104
|
+
if (widthMeters <= 0 || heightMeters <= 0) {
|
|
105
|
+
console.warn(`[bbs-lib] Shape "${shape.id}" skipped: missing dimensions`);
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
const size = { widthMeters, heightMeters };
|
|
109
|
+
const halfWidth = widthMeters / 2;
|
|
110
|
+
const halfHeight = heightMeters / 2;
|
|
111
|
+
const rotationRadians = shape.rotationRadians ?? 0;
|
|
112
|
+
const rows = shape.type.rows ?? [];
|
|
113
|
+
const hasGrid = rows.length > 0 && rows.some((row) => row.columns.length > 0);
|
|
114
|
+
const toSegment = (minEast, maxEast, minNorth, maxNorth, segmentIndex) => ({
|
|
115
|
+
shapeId: shape.id,
|
|
116
|
+
segmentIndex,
|
|
117
|
+
polygon: this.localPointsToPolygon([
|
|
118
|
+
{ east: minEast, north: minNorth },
|
|
119
|
+
{ east: maxEast, north: minNorth },
|
|
120
|
+
{ east: maxEast, north: maxNorth },
|
|
121
|
+
{ east: minEast, north: maxNorth },
|
|
122
|
+
], shape.center, rotationRadians),
|
|
123
|
+
style: shape.styling?.[segmentIndex],
|
|
124
|
+
shape,
|
|
125
|
+
size,
|
|
126
|
+
});
|
|
127
|
+
if (!hasGrid) {
|
|
128
|
+
return [toSegment(-halfWidth, halfWidth, -halfHeight, halfHeight, 0)];
|
|
129
|
+
}
|
|
130
|
+
const rowWeights = this.normalizeWeights(rows.map((row) => row.height));
|
|
131
|
+
const segments = [];
|
|
132
|
+
let segmentIndex = 0;
|
|
133
|
+
let north = -halfHeight;
|
|
134
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
135
|
+
const row = rows[rowIndex];
|
|
136
|
+
const rowHeight = heightMeters * rowWeights[rowIndex];
|
|
137
|
+
const rowMinNorth = north;
|
|
138
|
+
const rowMaxNorth = north + rowHeight;
|
|
139
|
+
north = rowMaxNorth;
|
|
140
|
+
const columns = row.columns ?? [];
|
|
141
|
+
if (columns.length === 0) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const columnWeights = this.normalizeWeights(columns.map((column) => column.width));
|
|
145
|
+
let east = -halfWidth;
|
|
146
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex++) {
|
|
147
|
+
const columnWidth = widthMeters * columnWeights[columnIndex];
|
|
148
|
+
const colMinEast = east;
|
|
149
|
+
const colMaxEast = east + columnWidth;
|
|
150
|
+
east = colMaxEast;
|
|
151
|
+
segments.push(toSegment(colMinEast, colMaxEast, rowMinNorth, rowMaxNorth, segmentIndex));
|
|
152
|
+
segmentIndex++;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (segments.length === 0) {
|
|
156
|
+
return [toSegment(-halfWidth, halfWidth, -halfHeight, halfHeight, 0)];
|
|
157
|
+
}
|
|
158
|
+
return segments;
|
|
159
|
+
}
|
|
160
|
+
static normalizeWeights(weights) {
|
|
161
|
+
const total = weights.reduce((sum, w) => sum + w, 0);
|
|
162
|
+
if (total <= 0) {
|
|
163
|
+
return weights.map(() => 1 / weights.length);
|
|
164
|
+
}
|
|
165
|
+
return weights.map((w) => w / total);
|
|
166
|
+
}
|
|
167
|
+
static metersToLngLatDelta(eastMeters, northMeters, centerLat, centerLng) {
|
|
168
|
+
const from = point([centerLng, centerLat]);
|
|
169
|
+
let dLng = 0;
|
|
170
|
+
let dLat = 0;
|
|
171
|
+
if (eastMeters !== 0) {
|
|
172
|
+
const east = destination(from, Math.abs(eastMeters), eastMeters >= 0 ? 90 : 270, {
|
|
173
|
+
units: 'meters',
|
|
174
|
+
});
|
|
175
|
+
dLng = east.geometry.coordinates[0] - from.geometry.coordinates[0];
|
|
176
|
+
}
|
|
177
|
+
if (northMeters !== 0) {
|
|
178
|
+
const north = destination(from, Math.abs(northMeters), northMeters >= 0 ? 0 : 180, {
|
|
179
|
+
units: 'meters',
|
|
180
|
+
});
|
|
181
|
+
dLat = north.geometry.coordinates[1] - from.geometry.coordinates[1];
|
|
182
|
+
}
|
|
183
|
+
return { dLng, dLat };
|
|
184
|
+
}
|
|
185
|
+
static localPointsToPolygon(points, center, rotationRadians) {
|
|
186
|
+
const coords = points.map((local) => {
|
|
187
|
+
const delta = this.metersToLngLatDelta(local.east, local.north, center.lat, center.lng);
|
|
188
|
+
return [center.lng + delta.dLng, center.lat + delta.dLat];
|
|
189
|
+
});
|
|
190
|
+
if (!rotationRadians) {
|
|
191
|
+
return coords;
|
|
192
|
+
}
|
|
193
|
+
const closed = [...coords, coords[0]];
|
|
194
|
+
const rotated = turfTransformRotate(polygon([closed]), RotationUtils.radiansToDegrees(rotationRadians), {
|
|
195
|
+
pivot: [center.lng, center.lat],
|
|
196
|
+
});
|
|
197
|
+
const rotatedRing = rotated.geometry.coordinates[0];
|
|
198
|
+
return rotatedRing.slice(0, -1);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
//# sourceMappingURL=overlay-dynamic-layer.builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-dynamic-layer.builder.js","sourceRoot":"","sources":["../../src/overlay/overlay-dynamic-layer.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EAEzB,QAAQ,EACR,UAAU,GAIX,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,mBAAmB,MAAM,wBAAwB,CAAA;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAEvD,MAAM,eAAe,GAAG,YAAY,CAAA;AAEpC,MAAM,OAAO,0BAA0B;IAMrC,YAAoC,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;QALpD,qBAAgB,GAAkB,IAAI,CAAA;QACtC,UAAK,GAAY,KAAK,CAAA;QACtB,cAAS,GAAqC,GAAG,EAAE,GAAE,CAAC,CAAA;QACtD,YAAO,GAAiC,GAAG,EAAE,GAAE,CAAC,CAAA;IAEO,CAAC;IAEzD,kBAAkB,CAAC,OAAsB;QAC9C,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAA;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,OAAO,CAAC,IAAa;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,WAAW,CAAC,QAA0C;QAC3D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,SAAS,CAAC,MAAoC;QACnD,IAAI,CAAC,OAAO,GAAG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B,CACjC,MAAoB,EACpB,MAAoC,EACpC,eAAuB;QAEvB,MAAM,MAAM,GAAuB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACtD,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAA;YACvF,OAAO,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;QAC3D,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,OAAO,MAAM,CAAA;QACf,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;QACrC,MAAM,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,eAAe,CAAC,EAAE;YACtG,KAAK,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC;SAChC,CAAC,CAAA;QACF,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAuB,CAAA;QACzE,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACjC,CAAC;CACF;AAED,YAAY"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Layer } from '@deck.gl/core';
|
|
2
|
+
import type { MapContextStaticLayer } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Class to build overlay layers.
|
|
5
|
+
*/
|
|
6
|
+
export declare class OverlayStaticLayerBuilder {
|
|
7
|
+
private readonly _apiUrl;
|
|
8
|
+
private readonly _apiKey;
|
|
9
|
+
private readonly _levelId;
|
|
10
|
+
private _layers;
|
|
11
|
+
private _surroundings;
|
|
12
|
+
constructor(_apiUrl: string, _apiKey: string, _levelId: string | null);
|
|
13
|
+
setLayers(layers: MapContextStaticLayer[]): OverlayStaticLayerBuilder;
|
|
14
|
+
setSurroundings(surroundings: boolean): OverlayStaticLayerBuilder;
|
|
15
|
+
build(): Layer[];
|
|
16
|
+
private hexToRgba;
|
|
17
|
+
private createVectorTileLayer;
|
|
18
|
+
private createRasterTileLayer;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=overlay-static-layer.builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-static-layer.builder.d.ts","sourceRoot":"","sources":["../../src/overlay/overlay-static-layer.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAGrC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD;;GAEG;AACH,qBAAa,yBAAyB;IAKlC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAN3B,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,aAAa,CAAiB;gBAGnB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,IAAI;IAGnC,SAAS,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,yBAAyB;IAKrE,eAAe,CAAC,YAAY,EAAE,OAAO,GAAG,yBAAyB;IAKjE,KAAK,IAAI,KAAK,EAAE;IAavB,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,qBAAqB;IA8B7B,OAAO,CAAC,qBAAqB;CA0B9B"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { MVTLayer, TileLayer } from '@deck.gl/geo-layers';
|
|
2
|
+
import { BitmapLayer } from '@deck.gl/layers';
|
|
3
|
+
/**
|
|
4
|
+
* Class to build overlay layers.
|
|
5
|
+
*/
|
|
6
|
+
export class OverlayStaticLayerBuilder {
|
|
7
|
+
constructor(_apiUrl, _apiKey, _levelId) {
|
|
8
|
+
this._apiUrl = _apiUrl;
|
|
9
|
+
this._apiKey = _apiKey;
|
|
10
|
+
this._levelId = _levelId;
|
|
11
|
+
this._layers = [];
|
|
12
|
+
this._surroundings = false;
|
|
13
|
+
}
|
|
14
|
+
setLayers(layers) {
|
|
15
|
+
this._layers = layers;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
setSurroundings(surroundings) {
|
|
19
|
+
this._surroundings = surroundings;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
build() {
|
|
23
|
+
const validTypes = ['vector', 'raster'];
|
|
24
|
+
return this._layers
|
|
25
|
+
.filter((layer) => validTypes.includes(layer.type) && ((this._surroundings && !layer.levelId) || layer.levelId === this._levelId))
|
|
26
|
+
.map((layer, index) => {
|
|
27
|
+
if (layer.type === 'vector') {
|
|
28
|
+
return this.createVectorTileLayer(layer, index);
|
|
29
|
+
}
|
|
30
|
+
return this.createRasterTileLayer(layer, index);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
hexToRgba(hex, opacity) {
|
|
34
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{0,2})$/i.exec(hex);
|
|
35
|
+
if (!result?.length || result.length < 3) {
|
|
36
|
+
return [0, 0, 0, 0];
|
|
37
|
+
}
|
|
38
|
+
let alpha = result[4] ? parseInt(result[4], 16) : 255;
|
|
39
|
+
if (opacity !== null && opacity !== undefined) {
|
|
40
|
+
alpha = Math.round((opacity / 100) * 255);
|
|
41
|
+
}
|
|
42
|
+
return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), alpha];
|
|
43
|
+
}
|
|
44
|
+
createVectorTileLayer(layer, index) {
|
|
45
|
+
const id = layer.id;
|
|
46
|
+
const version = layer.version;
|
|
47
|
+
const minZoom = layer.minZoom;
|
|
48
|
+
const maxZoom = layer.maxZoom;
|
|
49
|
+
const tileUrl = `${this._apiUrl}/bbs/map/get-map-vector-tile/?layerId=${id}&x={x}&y={y}&z={z}&version=${version}`;
|
|
50
|
+
const hexColor = layer.lineColor ?? '#000000';
|
|
51
|
+
const lineColor = this.hexToRgba(hexColor);
|
|
52
|
+
return new MVTLayer({
|
|
53
|
+
id: id,
|
|
54
|
+
index: index,
|
|
55
|
+
pointRadiusUnits: 'pixels',
|
|
56
|
+
lineWidthUnits: 'pixels',
|
|
57
|
+
minZoom: minZoom,
|
|
58
|
+
maxZoom: maxZoom,
|
|
59
|
+
getLineColor: lineColor,
|
|
60
|
+
getFillColor: [0, 0, 0, 0],
|
|
61
|
+
data: tileUrl,
|
|
62
|
+
loadOptions: {
|
|
63
|
+
fetch: {
|
|
64
|
+
headers: {
|
|
65
|
+
'x-api-key': this._apiKey,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
createRasterTileLayer(layer, index) {
|
|
72
|
+
const id = layer.id;
|
|
73
|
+
const version = layer.version;
|
|
74
|
+
return new TileLayer({
|
|
75
|
+
id: layer.id,
|
|
76
|
+
data: `${this._apiUrl}/bbs/map/get-map-raster-tile/?layerId=${id}&x={x}&y={y}&z={z}&version=${version}`,
|
|
77
|
+
tileSize: 256,
|
|
78
|
+
index: index,
|
|
79
|
+
loadOptions: {
|
|
80
|
+
fetch: {
|
|
81
|
+
headers: {
|
|
82
|
+
'x-api-key': this._apiKey,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
renderSubLayers: (props) => {
|
|
87
|
+
const { west, south, east, north } = props.tile.bbox;
|
|
88
|
+
return new BitmapLayer({
|
|
89
|
+
id: `${props.id}-sub`,
|
|
90
|
+
image: props.data,
|
|
91
|
+
bounds: [west, south, east, north],
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=overlay-static-layer.builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-static-layer.builder.js","sourceRoot":"","sources":["../../src/overlay/overlay-static-layer.builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAG7C;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAIpC,YACmB,OAAe,EACf,OAAe,EACf,QAAuB;QAFvB,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAe;QANlC,YAAO,GAA4B,EAAE,CAAA;QACrC,kBAAa,GAAY,KAAK,CAAA;IAMnC,CAAC;IAEG,SAAS,CAAC,MAA+B;QAC9C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QACrB,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,eAAe,CAAC,YAAqB;QAC1C,IAAI,CAAC,aAAa,GAAG,YAAY,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,KAAK;QACV,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QACvC,OAAO,IAAI,CAAC,OAAO;aAChB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;aACjI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YACpB,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,E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E,KAAK,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAsB,CAAA;gBAEtE,OAAO,IAAI,WAAW,CAAC;oBACrB,EAAE,EAAE,GAAG,KAAK,CAAC,EAAE,MAAM;oBACrB,KAAK,EAAE,KAAK,CAAC,IAAI;oBACjB,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;iBACnC,CAAC,CAAA;YACJ,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,MAAM,MAAM,UAAU,GAAG;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,KAAK,CAAC,EAAE,aAAa,CAAA;CACxB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type InitializeOptions = {
|
|
2
|
+
zoom?: number;
|
|
3
|
+
heading?: number;
|
|
4
|
+
tilt?: number;
|
|
5
|
+
};
|
|
6
|
+
export type MapContext = {
|
|
7
|
+
apiUrl: string;
|
|
8
|
+
apiKey: string;
|
|
9
|
+
center: {
|
|
10
|
+
lat: number;
|
|
11
|
+
lng: number;
|
|
12
|
+
};
|
|
13
|
+
staticLayers: MapContextStaticLayer[];
|
|
14
|
+
defaultLevelId: string | null;
|
|
15
|
+
};
|
|
16
|
+
export type MapContextStaticLayer = {
|
|
17
|
+
id: string;
|
|
18
|
+
type: 'vector' | 'raster';
|
|
19
|
+
levelId: string | null;
|
|
20
|
+
version: string;
|
|
21
|
+
lineColor?: string;
|
|
22
|
+
minZoom?: number;
|
|
23
|
+
maxZoom?: number;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=overlay-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-options.d.ts","sourceRoot":"","sources":["../../src/types/overlay-options.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE;QACJ,GAAG,EAAE,MAAM,CAAA;QACX,GAAG,EAAE,MAAM,CAAA;KACd,CAAA;IACD,YAAY,EAAE,qBAAqB,EAAE,CAAA;IACrC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAA;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-options.js","sourceRoot":"","sources":["../../src/types/overlay-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SegmentsStyling } from './shape-style';
|
|
2
|
+
import { ShapeType } from './shape-type';
|
|
3
|
+
export type LatLng = {
|
|
4
|
+
lat: number;
|
|
5
|
+
lng: number;
|
|
6
|
+
};
|
|
7
|
+
export type ShapeInstance = {
|
|
8
|
+
id: string;
|
|
9
|
+
styling?: SegmentsStyling;
|
|
10
|
+
metadata?: object;
|
|
11
|
+
type: ShapeType;
|
|
12
|
+
rotationRadians?: number;
|
|
13
|
+
center: LatLng;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=shape-instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-instance.d.ts","sourceRoot":"","sources":["../../src/types/shape-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,MAAM,GAAG;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,CAAC,EAAE,eAAe,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,SAAS,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-instance.js","sourceRoot":"","sources":["../../src/types/shape-instance.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @segmentIndex Index of each Segment in the Shape. Starts at 0.
|
|
3
|
+
*/
|
|
4
|
+
export type SegmentsStyling = {
|
|
5
|
+
[segmentIndex: number]: ShapeStyle;
|
|
6
|
+
};
|
|
7
|
+
export type ShapeStyle = {
|
|
8
|
+
textColorHex?: string;
|
|
9
|
+
text?: string;
|
|
10
|
+
backgroundColorHex?: string;
|
|
11
|
+
textSize?: 'small' | 'medium' | 'large' | number;
|
|
12
|
+
borderColorHex?: string;
|
|
13
|
+
borderWidth?: number;
|
|
14
|
+
textPosition?: 'center' | 'left' | 'right';
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=shape-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-style.d.ts","sourceRoot":"","sources":["../../src/types/shape-style.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAAE,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAA;AAEpE,MAAM,MAAM,UAAU,GAAG;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IAChD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;CAC7C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-style.js","sourceRoot":"","sources":["../../src/types/shape-style.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** A column within a shape row. */
|
|
2
|
+
export type ShapeColumn = {
|
|
3
|
+
/** Relative horizontal weight used to split the row width among columns (not meters). */
|
|
4
|
+
width: number;
|
|
5
|
+
};
|
|
6
|
+
/** A horizontal band of the shape grid. */
|
|
7
|
+
export type ShapeRow = {
|
|
8
|
+
/** Relative vertical weight used to split the total shape height among rows (not meters). */
|
|
9
|
+
height: number;
|
|
10
|
+
/** Columns laid out left-to-right within this row. */
|
|
11
|
+
columns: ShapeColumn[];
|
|
12
|
+
};
|
|
13
|
+
/** Defines the geometry grid and real-world size of a {@link ShapeInstance}. */
|
|
14
|
+
export type ShapeType = {
|
|
15
|
+
/**
|
|
16
|
+
* Height-to-width ratio: `heightInMeters = widthInMeters × ratio`.
|
|
17
|
+
* Example: `ratio: 0.5` → half as tall as wide; `ratio: 2` → twice as tall as wide.
|
|
18
|
+
*/
|
|
19
|
+
ratio: number;
|
|
20
|
+
/**
|
|
21
|
+
* When `true`, map resize keeps `ratio` and only updates `widthInMeters`.
|
|
22
|
+
* When `false`, map resize updates `widthInMeters` from the edited geometry; `ratio` is
|
|
23
|
+
* recomputed from the preserved height when only width changes (and vice versa), or from
|
|
24
|
+
* both measured sides when both change.
|
|
25
|
+
*/
|
|
26
|
+
lockRatio: boolean;
|
|
27
|
+
/** Segment grid; row/column weights divide the overall rectangle into styled cells. */
|
|
28
|
+
rows: ShapeRow[];
|
|
29
|
+
/**
|
|
30
|
+
* Overall shape width in meters. Defaults to 6 m when omitted.
|
|
31
|
+
* Height is always derived from `ratio`, never stored separately.
|
|
32
|
+
*/
|
|
33
|
+
widthInMeters?: number;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=shape-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-type.d.ts","sourceRoot":"","sources":["../../src/types/shape-type.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,MAAM,MAAM,WAAW,GAAG;IACtB,yFAAyF;IACzF,KAAK,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,2CAA2C;AAC3C,MAAM,MAAM,QAAQ,GAAG;IACnB,6FAA6F;IAC7F,MAAM,EAAE,MAAM,CAAA;IACd,sDAAsD;IACtD,OAAO,EAAE,WAAW,EAAE,CAAA;CACzB,CAAA;AAED,gFAAgF;AAChF,MAAM,MAAM,SAAS,GAAG;IACpB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,SAAS,EAAE,OAAO,CAAA;IAClB,uFAAuF;IACvF,IAAI,EAAE,QAAQ,EAAE,CAAA;IAChB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACzB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-type.js","sourceRoot":"","sources":["../../src/types/shape-type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rotation helpers for {@link ShapeInstance.rotationRadians}.
|
|
3
|
+
*
|
|
4
|
+
* Shapes store rotation in radians on `[0, 2π)`. Use these utilities at library
|
|
5
|
+
* boundaries (e.g. when mapping edited geometry or normalizing shape state) so
|
|
6
|
+
* equivalent angles such as `-45°` and `315°` always collapse to one value.
|
|
7
|
+
*/
|
|
8
|
+
export declare class RotationUtils {
|
|
9
|
+
/** Wraps a radian angle into the canonical range `[0, 2π)`. */
|
|
10
|
+
static normalizeRadians(radians: number): number;
|
|
11
|
+
/** Wraps a degree angle into the canonical range `[0, 360)`. */
|
|
12
|
+
static normalizeDegrees(degrees: number): number;
|
|
13
|
+
/** Converts degrees to radians after normalizing to `[0, 360)`. */
|
|
14
|
+
static degreesToRadians(degrees: number): number;
|
|
15
|
+
/** Converts radians to degrees after normalizing to `[0, 2π)`. */
|
|
16
|
+
static radiansToDegrees(radians: number): number;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=rotation.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotation.utils.d.ts","sourceRoot":"","sources":["../../src/utils/rotation.utils.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,qBAAa,aAAa;IACtB,+DAA+D;WACjD,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAIvD,gEAAgE;WAClD,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAIvD,mEAAmE;WACrD,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAIvD,kEAAkE;WACpD,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAG1D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const TWO_PI = Math.PI * 2;
|
|
2
|
+
/**
|
|
3
|
+
* Rotation helpers for {@link ShapeInstance.rotationRadians}.
|
|
4
|
+
*
|
|
5
|
+
* Shapes store rotation in radians on `[0, 2π)`. Use these utilities at library
|
|
6
|
+
* boundaries (e.g. when mapping edited geometry or normalizing shape state) so
|
|
7
|
+
* equivalent angles such as `-45°` and `315°` always collapse to one value.
|
|
8
|
+
*/
|
|
9
|
+
export class RotationUtils {
|
|
10
|
+
/** Wraps a radian angle into the canonical range `[0, 2π)`. */
|
|
11
|
+
static normalizeRadians(radians) {
|
|
12
|
+
return ((radians % TWO_PI) + TWO_PI) % TWO_PI;
|
|
13
|
+
}
|
|
14
|
+
/** Wraps a degree angle into the canonical range `[0, 360)`. */
|
|
15
|
+
static normalizeDegrees(degrees) {
|
|
16
|
+
return ((degrees % 360) + 360) % 360;
|
|
17
|
+
}
|
|
18
|
+
/** Converts degrees to radians after normalizing to `[0, 360)`. */
|
|
19
|
+
static degreesToRadians(degrees) {
|
|
20
|
+
return (RotationUtils.normalizeDegrees(degrees) * Math.PI) / 180;
|
|
21
|
+
}
|
|
22
|
+
/** Converts radians to degrees after normalizing to `[0, 2π)`. */
|
|
23
|
+
static radiansToDegrees(radians) {
|
|
24
|
+
return (RotationUtils.normalizeRadians(radians) * 180) / Math.PI;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=rotation.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotation.utils.js","sourceRoot":"","sources":["../../src/utils/rotation.utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA;AAE1B;;;;;;GAMG;AACH,MAAM,OAAO,aAAa;IACtB,+DAA+D;IACxD,MAAM,CAAC,gBAAgB,CAAC,OAAe;QAC1C,OAAO,CAAC,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAA;IACjD,CAAC;IAED,gEAAgE;IACzD,MAAM,CAAC,gBAAgB,CAAC,OAAe;QAC1C,OAAO,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;IACxC,CAAC;IAED,mEAAmE;IAC5D,MAAM,CAAC,gBAAgB,CAAC,OAAe;QAC1C,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAA;IACpE,CAAC;IAED,kEAAkE;IAC3D,MAAM,CAAC,gBAAgB,CAAC,OAAe;QAC1C,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAA;IACpE,CAAC;CACJ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@focusbc/bbs-lib",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "BBS map rendering library (deck.gl + @focusbc/map-rendering)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"clean": "rm -rf dist",
|
|
17
|
+
"sandbox:build": "esbuild sandbox/main.ts --bundle --format=esm --outfile=sandbox/app.js --platform=browser",
|
|
18
|
+
"sandbox:watch": "esbuild sandbox/main.ts --bundle --format=esm --outfile=sandbox/app.js --platform=browser --watch",
|
|
19
|
+
"sandbox:serve": "npx --yes serve sandbox -p 5173",
|
|
20
|
+
"prebuild": "npm run clean",
|
|
21
|
+
"release:lib": "bash scripts/release-lib.sh"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"bbs",
|
|
25
|
+
"map",
|
|
26
|
+
"rendering",
|
|
27
|
+
"deck.gl",
|
|
28
|
+
"focusbc"
|
|
29
|
+
],
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@deck.gl/core": "9.1.14",
|
|
34
|
+
"@deck.gl/extensions": "9.1.14",
|
|
35
|
+
"@deck.gl/geo-layers": "9.1.14",
|
|
36
|
+
"@deck.gl/layers": "9.1.14",
|
|
37
|
+
"@deck.gl/mesh-layers": "9.1.14",
|
|
38
|
+
"@focusbc/map-rendering": "0.2.17",
|
|
39
|
+
"@turf/turf": "^7.3.5"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"esbuild": "^0.25.0",
|
|
43
|
+
"typescript": "^5.3.3"
|
|
44
|
+
},
|
|
45
|
+
"packageManager": "yarn@4.11.0",
|
|
46
|
+
"files": [
|
|
47
|
+
"dist/**/*",
|
|
48
|
+
"readme.md"
|
|
49
|
+
]
|
|
50
|
+
}
|