@smartnet360/svelte-components 0.0.130 → 0.0.132
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/core/CellTable/CellHistoryDemo.svelte +106 -65
- package/dist/core/CellTable/column-config.d.ts +12 -0
- package/dist/core/CellTable/column-config.js +79 -2
- package/dist/core/CellTable/history-api-helper.d.ts +79 -0
- package/dist/core/CellTable/history-api-helper.js +83 -0
- package/dist/core/CellTable/index.d.ts +3 -2
- package/dist/core/CellTable/index.js +3 -1
- package/dist/core/CellTable/types.d.ts +26 -0
- package/dist/map-v3/demo/DemoMap.svelte +1 -6
- package/dist/map-v3/features/{cells/custom → custom}/components/CustomCellFilterControl.svelte +11 -4
- package/dist/map-v3/features/custom/components/CustomCellSetManager.svelte +692 -0
- package/dist/map-v3/features/{cells/custom → custom}/index.d.ts +1 -1
- package/dist/map-v3/features/{cells/custom → custom}/index.js +1 -1
- package/dist/map-v3/features/custom/layers/CustomCellsLayer.svelte +399 -0
- package/dist/map-v3/features/{cells/custom → custom}/logic/csv-parser.d.ts +11 -7
- package/dist/map-v3/features/{cells/custom → custom}/logic/csv-parser.js +64 -20
- package/dist/map-v3/features/{cells/custom → custom}/logic/tree-adapter.d.ts +1 -1
- package/dist/map-v3/features/{cells/custom → custom}/stores/custom-cell-sets.svelte.d.ts +4 -3
- package/dist/map-v3/features/{cells/custom → custom}/stores/custom-cell-sets.svelte.js +30 -10
- package/dist/map-v3/features/{cells/custom → custom}/types.d.ts +32 -12
- package/dist/map-v3/features/{cells/custom → custom}/types.js +5 -3
- package/dist/map-v3/index.d.ts +1 -1
- package/dist/map-v3/index.js +1 -1
- package/dist/map-v3/shared/controls/MapControl.svelte +43 -15
- package/dist/map-v3/shared/controls/MapControl.svelte.d.ts +3 -1
- package/package.json +1 -1
- package/dist/map-v3/features/cells/custom/components/CustomCellSetManager.svelte +0 -306
- package/dist/map-v3/features/cells/custom/layers/CustomCellsLayer.svelte +0 -262
- /package/dist/map-v3/features/{cells/custom → custom}/components/CustomCellFilterControl.svelte.d.ts +0 -0
- /package/dist/map-v3/features/{cells/custom → custom}/components/CustomCellSetManager.svelte.d.ts +0 -0
- /package/dist/map-v3/features/{cells/custom → custom}/components/index.d.ts +0 -0
- /package/dist/map-v3/features/{cells/custom → custom}/components/index.js +0 -0
- /package/dist/map-v3/features/{cells/custom → custom}/layers/CustomCellsLayer.svelte.d.ts +0 -0
- /package/dist/map-v3/features/{cells/custom → custom}/layers/index.d.ts +0 -0
- /package/dist/map-v3/features/{cells/custom → custom}/layers/index.js +0 -0
- /package/dist/map-v3/features/{cells/custom → custom}/logic/index.d.ts +0 -0
- /package/dist/map-v3/features/{cells/custom → custom}/logic/index.js +0 -0
- /package/dist/map-v3/features/{cells/custom → custom}/logic/tree-adapter.js +0 -0
- /package/dist/map-v3/features/{cells/custom → custom}/stores/index.d.ts +0 -0
- /package/dist/map-v3/features/{cells/custom → custom}/stores/index.js +0 -0
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* Custom Cells Layer
|
|
4
|
-
*
|
|
5
|
-
* Renders custom cell sets on the map with sizeFactor support.
|
|
6
|
-
* Each set is rendered as a separate layer for independent styling.
|
|
7
|
-
*/
|
|
8
|
-
import { getContext, onMount, onDestroy } from 'svelte';
|
|
9
|
-
import type { MapStore } from '../../../../core/stores/map.store.svelte';
|
|
10
|
-
import type { CustomCellSetsStore } from '../stores/custom-cell-sets.svelte';
|
|
11
|
-
import type { CustomCellSet, CustomCell } from '../types';
|
|
12
|
-
import { generateCellArc, calculateRadiusInMeters } from '../../logic/geometry';
|
|
13
|
-
import type mapboxgl from 'mapbox-gl';
|
|
14
|
-
|
|
15
|
-
interface Props {
|
|
16
|
-
/** The custom cell sets store */
|
|
17
|
-
setsStore: CustomCellSetsStore;
|
|
18
|
-
/** Optional: specific set ID to render (if not provided, renders all) */
|
|
19
|
-
setId?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let { setsStore, setId }: Props = $props();
|
|
23
|
-
|
|
24
|
-
const mapStore = getContext<MapStore>('MAP_CONTEXT');
|
|
25
|
-
|
|
26
|
-
// Track active layer/source IDs for cleanup
|
|
27
|
-
let activeSources = new Set<string>();
|
|
28
|
-
let activeLayers = new Set<string>();
|
|
29
|
-
|
|
30
|
-
// Debounce timer
|
|
31
|
-
let updateTimeout: ReturnType<typeof setTimeout>;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Get source ID for a set
|
|
35
|
-
*/
|
|
36
|
-
function getSourceId(setId: string): string {
|
|
37
|
-
return `custom-cells-${setId}`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Get layer IDs for a set
|
|
42
|
-
*/
|
|
43
|
-
function getLayerIds(setId: string): { fill: string; line: string } {
|
|
44
|
-
return {
|
|
45
|
-
fill: `custom-cells-fill-${setId}`,
|
|
46
|
-
line: `custom-cells-line-${setId}`
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Add source and layers for a set
|
|
52
|
-
*/
|
|
53
|
-
function addSetLayers(map: mapboxgl.Map, set: CustomCellSet) {
|
|
54
|
-
const sourceId = getSourceId(set.id);
|
|
55
|
-
const { fill, line } = getLayerIds(set.id);
|
|
56
|
-
|
|
57
|
-
// Add source if not exists
|
|
58
|
-
if (!map.getSource(sourceId)) {
|
|
59
|
-
map.addSource(sourceId, {
|
|
60
|
-
type: 'geojson',
|
|
61
|
-
data: { type: 'FeatureCollection', features: [] }
|
|
62
|
-
});
|
|
63
|
-
activeSources.add(sourceId);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Add fill layer
|
|
67
|
-
if (!map.getLayer(fill)) {
|
|
68
|
-
map.addLayer({
|
|
69
|
-
id: fill,
|
|
70
|
-
type: 'fill',
|
|
71
|
-
source: sourceId,
|
|
72
|
-
paint: {
|
|
73
|
-
'fill-color': ['get', 'color'],
|
|
74
|
-
'fill-opacity': set.opacity
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
activeLayers.add(fill);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Add line layer
|
|
81
|
-
if (!map.getLayer(line)) {
|
|
82
|
-
map.addLayer({
|
|
83
|
-
id: line,
|
|
84
|
-
type: 'line',
|
|
85
|
-
source: sourceId,
|
|
86
|
-
paint: {
|
|
87
|
-
'line-color': ['get', 'lineColor'],
|
|
88
|
-
'line-width': ['get', 'lineWidth'],
|
|
89
|
-
'line-opacity': ['get', 'lineOpacity']
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
activeLayers.add(line);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Remove layers and source for a set
|
|
98
|
-
*/
|
|
99
|
-
function removeSetLayers(map: mapboxgl.Map, setIdToRemove: string) {
|
|
100
|
-
const sourceId = getSourceId(setIdToRemove);
|
|
101
|
-
const { fill, line } = getLayerIds(setIdToRemove);
|
|
102
|
-
|
|
103
|
-
if (map.getLayer(line)) {
|
|
104
|
-
map.removeLayer(line);
|
|
105
|
-
activeLayers.delete(line);
|
|
106
|
-
}
|
|
107
|
-
if (map.getLayer(fill)) {
|
|
108
|
-
map.removeLayer(fill);
|
|
109
|
-
activeLayers.delete(fill);
|
|
110
|
-
}
|
|
111
|
-
if (map.getSource(sourceId)) {
|
|
112
|
-
map.removeSource(sourceId);
|
|
113
|
-
activeSources.delete(sourceId);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Render cells for a specific set
|
|
119
|
-
*/
|
|
120
|
-
function renderSet(map: mapboxgl.Map, set: CustomCellSet) {
|
|
121
|
-
const bounds = map.getBounds();
|
|
122
|
-
if (!bounds) return;
|
|
123
|
-
|
|
124
|
-
const zoom = map.getZoom();
|
|
125
|
-
const centerLat = map.getCenter().lat;
|
|
126
|
-
|
|
127
|
-
// Calculate base radius from pixel size
|
|
128
|
-
const baseRadiusMeters = calculateRadiusInMeters(centerLat, zoom, set.baseSize);
|
|
129
|
-
|
|
130
|
-
const features: GeoJSON.Feature[] = [];
|
|
131
|
-
|
|
132
|
-
for (const customCell of set.cells) {
|
|
133
|
-
const cell = customCell.resolvedCell;
|
|
134
|
-
if (!cell) continue;
|
|
135
|
-
|
|
136
|
-
// Check group visibility
|
|
137
|
-
if (!set.visibleGroups.has(customCell.customGroup)) continue;
|
|
138
|
-
|
|
139
|
-
// Viewport filter
|
|
140
|
-
if (!bounds.contains([cell.longitude, cell.latitude])) continue;
|
|
141
|
-
|
|
142
|
-
// Get color for this group
|
|
143
|
-
const color = set.groupColors[customCell.customGroup] || set.defaultColor;
|
|
144
|
-
|
|
145
|
-
// Apply size factor
|
|
146
|
-
const radiusMeters = baseRadiusMeters * customCell.sizeFactor;
|
|
147
|
-
|
|
148
|
-
// Generate arc feature
|
|
149
|
-
const feature = generateCellArc(cell, radiusMeters, 50, color);
|
|
150
|
-
|
|
151
|
-
// Add custom properties for tooltips
|
|
152
|
-
if (feature.properties) {
|
|
153
|
-
feature.properties.customGroup = customCell.customGroup;
|
|
154
|
-
feature.properties.sizeFactor = customCell.sizeFactor;
|
|
155
|
-
feature.properties.setName = set.name;
|
|
156
|
-
|
|
157
|
-
// Add extra fields
|
|
158
|
-
for (const [key, value] of Object.entries(customCell.extraFields)) {
|
|
159
|
-
feature.properties[`extra_${key}`] = value;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
features.push(feature);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Update source
|
|
167
|
-
const sourceId = getSourceId(set.id);
|
|
168
|
-
const source = map.getSource(sourceId) as mapboxgl.GeoJSONSource;
|
|
169
|
-
if (source) {
|
|
170
|
-
source.setData({
|
|
171
|
-
type: 'FeatureCollection',
|
|
172
|
-
features: features as any
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Update layer opacity
|
|
177
|
-
const { fill } = getLayerIds(set.id);
|
|
178
|
-
if (map.getLayer(fill)) {
|
|
179
|
-
map.setPaintProperty(fill, 'fill-opacity', set.opacity);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
console.log(`[CustomCellsLayer] Rendered ${features.length} features for set "${set.name}"`);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Main update function
|
|
187
|
-
*/
|
|
188
|
-
function updateLayers() {
|
|
189
|
-
const map = mapStore.map;
|
|
190
|
-
if (!map) return;
|
|
191
|
-
|
|
192
|
-
clearTimeout(updateTimeout);
|
|
193
|
-
updateTimeout = setTimeout(() => {
|
|
194
|
-
const setsToRender = setId
|
|
195
|
-
? setsStore.sets.filter(s => s.id === setId)
|
|
196
|
-
: setsStore.sets;
|
|
197
|
-
|
|
198
|
-
// Track which sets we're rendering
|
|
199
|
-
const activeSetIds = new Set(setsToRender.map(s => s.id));
|
|
200
|
-
|
|
201
|
-
// Remove layers for sets that no longer exist
|
|
202
|
-
for (const sourceId of activeSources) {
|
|
203
|
-
const setIdFromSource = sourceId.replace('custom-cells-', '');
|
|
204
|
-
if (!activeSetIds.has(setIdFromSource)) {
|
|
205
|
-
removeSetLayers(map, setIdFromSource);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Render each set
|
|
210
|
-
for (const set of setsToRender) {
|
|
211
|
-
if (set.visible) {
|
|
212
|
-
addSetLayers(map, set);
|
|
213
|
-
renderSet(map, set);
|
|
214
|
-
} else {
|
|
215
|
-
// Hide by clearing data
|
|
216
|
-
const sourceId = getSourceId(set.id);
|
|
217
|
-
const source = map.getSource(sourceId) as mapboxgl.GeoJSONSource;
|
|
218
|
-
if (source) {
|
|
219
|
-
source.setData({ type: 'FeatureCollection', features: [] });
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}, 100);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Setup and reactive updates
|
|
227
|
-
$effect(() => {
|
|
228
|
-
const map = mapStore.map;
|
|
229
|
-
if (!map) return;
|
|
230
|
-
|
|
231
|
-
const onMapEvent = () => updateLayers();
|
|
232
|
-
|
|
233
|
-
// Initial render
|
|
234
|
-
updateLayers();
|
|
235
|
-
|
|
236
|
-
// Listen to map events
|
|
237
|
-
map.on('moveend', onMapEvent);
|
|
238
|
-
map.on('zoomend', onMapEvent);
|
|
239
|
-
map.on('style.load', onMapEvent);
|
|
240
|
-
|
|
241
|
-
return () => {
|
|
242
|
-
map.off('moveend', onMapEvent);
|
|
243
|
-
map.off('zoomend', onMapEvent);
|
|
244
|
-
map.off('style.load', onMapEvent);
|
|
245
|
-
|
|
246
|
-
// Cleanup all layers
|
|
247
|
-
for (const sourceId of activeSources) {
|
|
248
|
-
const setIdFromSource = sourceId.replace('custom-cells-', '');
|
|
249
|
-
removeSetLayers(map, setIdFromSource);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
// React to store changes
|
|
255
|
-
$effect(() => {
|
|
256
|
-
// Read version to trigger on changes
|
|
257
|
-
const _version = setsStore.version;
|
|
258
|
-
const _sets = setsStore.sets;
|
|
259
|
-
|
|
260
|
-
updateLayers();
|
|
261
|
-
});
|
|
262
|
-
</script>
|
/package/dist/map-v3/features/{cells/custom → custom}/components/CustomCellFilterControl.svelte.d.ts
RENAMED
|
File without changes
|
/package/dist/map-v3/features/{cells/custom → custom}/components/CustomCellSetManager.svelte.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|