11import { defineStore } from 'pinia' ;
2- import { computed , ref , watch } from 'vue' ;
2+ import { ref , watch } from 'vue' ;
33import { useLayerStore } from './layer' ;
4- import { cloneDeep , map } from 'lodash' ;
4+ import { cloneDeep } from 'lodash' ;
55import { useMapStore } from './map' ;
66import { useStyleStore } from './style' ;
77import type { MapLayerStyleRaw } from './style' ;
@@ -37,10 +37,10 @@ function findSourceDifferences(
3737 if ( ! existingStyle ) {
3838 return { added : Object . keys ( newStyle . sources ) , removed : [ ] } ;
3939 }
40-
40+
4141 const existing = new Set ( Object . keys ( existingStyle . sources ) ) ;
4242 const current = new Set ( Object . keys ( newStyle . sources ) ) ;
43-
43+
4444 return {
4545 added : Array . from ( current ) . filter ( id => ! existing . has ( id ) ) ,
4646 removed : Array . from ( existing ) . filter ( id => ! current . has ( id ) ) ,
@@ -58,10 +58,10 @@ function findLayerDifferences(
5858 if ( ! existingStyle ) {
5959 return { added : newStyle . layers , removed : [ ] } ;
6060 }
61-
61+
6262 const existing = new Set ( existingStyle . layers . map ( ( l : any ) => l . id ) ) ;
6363 const current = new Set ( newStyle . layers . map ( ( l : any ) => l . id ) ) ;
64-
64+
6565 return {
6666 added : newStyle . layers . filter ( ( l : any ) => ! existing . has ( l . id ) ) ,
6767 removed : Array . from ( existing ) . filter ( id => ! current . has ( id ) ) ,
@@ -96,7 +96,7 @@ export const useMapCompareStore = defineStore('mapCompare', () => {
9696 A : { } ,
9797 B : { } ,
9898 } ) ;
99-
99+
100100
101101 const initializeComparing = ( ) => {
102102 const map = mapStore . getMap ( ) ;
@@ -161,7 +161,7 @@ export const useMapCompareStore = defineStore('mapCompare', () => {
161161 mapStats . value . center = event . center ;
162162 mapStats . value . zoom = event . zoom ;
163163 mapStats . value . bearing = event . bearing ;
164- mapStats . value . pitch = event . pitch ;
164+ mapStats . value . pitch = event . pitch ;
165165 }
166166 function updateSlider ( event : { percentage : number , position : number } ) {
167167 sliderEnd . value = event ;
@@ -222,7 +222,7 @@ export const useMapCompareStore = defineStore('mapCompare', () => {
222222 if ( newVal ) {
223223 initializeComparing ( ) ;
224224 }
225- } ) ;
225+ } ) ;
226226
227227 /**
228228 * Reapply stored opacity values to all layers in compare mode
@@ -234,59 +234,59 @@ export const useMapCompareStore = defineStore('mapCompare', () => {
234234 // Process both map A and map B
235235 ( [ 'A' , 'B' ] as const ) . forEach ( ( panel ) => {
236236 const storedStyles = compareLayerStyles . value [ panel ] ;
237-
237+
238238 // Iterate through all stored layer styles
239239 Object . entries ( storedStyles ) . forEach ( ( [ styleKey , storedStyle ] ) => {
240240 // Parse the style key to get layer id and copy_id
241241 const [ layerIdStr , copyIdStr ] = styleKey . split ( '.' ) ;
242242 const layerId = parseInt ( layerIdStr ) ;
243243 const copyId = parseInt ( copyIdStr ) ;
244-
244+
245245 // Find the layer object
246246 const layer = layerStore . selectedLayers . find (
247247 ( l ) => l . id === layerId && l . copy_id === copyId
248248 ) ;
249-
249+
250250 if ( ! layer ) return ;
251-
251+
252252 // Get all map layer IDs for this layer
253253 const mapLayerIds = layerStore . getMapLayersFromLayerObject ( layer ) . flat ( ) ;
254-
254+
255255 // Get the current frame
256256 const frames = layerStore . layerFrames ( layer ) ;
257257 const currentFrame = frames . find (
258258 ( f ) => f . index === layer . current_frame_index
259259 ) ;
260-
260+
261261 if ( ! currentFrame ) return ;
262-
262+
263263 // Get the stored style spec with the stored opacity
264264 const styleSpec = storedStyle . style ?. style_spec ;
265265 if ( ! styleSpec ) return ;
266-
266+
267267 // Update the opacity in the style spec to match stored value
268268 const styleSpecWithOpacity = cloneDeep ( styleSpec ) ;
269269 styleSpecWithOpacity . opacity = storedStyle . opacity ;
270-
270+
271271 // Apply the style to all map layers for this layer
272272 mapLayerIds . forEach ( ( mapLayerId ) => {
273273 // Check if the map layer exists in the main map (required for returnMapLayerStyle)
274274 const mainMap = mapStore . getMap ( ) ;
275275 if ( ! mainMap || ! mainMap . getLayer ( mapLayerId ) ) {
276276 return ;
277277 }
278-
278+
279279 const visibileLayers = panel === 'A' ? mapLayersA . value : mapLayersB . value ;
280280 const visibility = visibileLayers . includes ( mapLayerId ) ? 'visible' : 'none' ;
281-
281+
282282 const result = styleStore . returnMapLayerStyle (
283283 mapLayerId ,
284284 styleSpecWithOpacity ,
285285 currentFrame ,
286286 currentFrame . vector ,
287287 visibility
288288 ) ;
289-
289+
290290 if ( result ) {
291291 updateMapLayerStyle ( panel , mapLayerId , result ) ;
292292 }
@@ -298,19 +298,19 @@ export const useMapCompareStore = defineStore('mapCompare', () => {
298298 function updateCompareLayerStyle ( ) {
299299 const compareMapAddedSources : { sourceId : string , sourceType : SourceSpecification [ 'type' ] } [ ] = [ ] ;
300300 if ( ! isComparing . value ) return compareMapAddedSources ;
301-
301+
302302 const newStyle = mapStore . getMap ( ) ?. getStyle ( ) ;
303303 if ( ! newStyle || ! mapAStyle . value || ! mapBStyle . value ) {
304304 mapAStyle . value = newStyle ;
305305 mapBStyle . value = newStyle ;
306306 return compareMapAddedSources ;
307307 }
308-
308+
309309 // Process both maps
310310 ( [ 'A' , 'B' ] as const ) . forEach ( ( panel ) => {
311311 const mapStyle = panel === 'A' ? mapAStyle . value : mapBStyle . value ;
312312 if ( ! mapStyle ) return ;
313-
313+
314314 // Handle sources
315315 const sourceDiff = findSourceDifferences ( newStyle , mapStyle ) ;
316316 sourceDiff . added . forEach ( ( sourceId ) => {
@@ -325,7 +325,7 @@ export const useMapCompareStore = defineStore('mapCompare', () => {
325325 sourceDiff . removed . forEach ( ( sourceId ) => {
326326 delete mapStyle . sources [ sourceId ] ;
327327 } ) ;
328-
328+
329329 // Handle layers
330330 const layerDiff = findLayerDifferences ( newStyle , mapStyle ) ;
331331 layerDiff . added . forEach ( ( layer ) => {
@@ -335,7 +335,7 @@ export const useMapCompareStore = defineStore('mapCompare', () => {
335335 mapStyle . layers = mapStyle . layers . filter ( ( l : any ) => l . id !== layerId ) ;
336336 } ) ;
337337 } ) ;
338-
338+
339339 generateDisplayLayers ( ) ;
340340 reapplyStoredOpacityValues ( ) ;
341341 return compareMapAddedSources ;
@@ -347,7 +347,7 @@ export const useMapCompareStore = defineStore('mapCompare', () => {
347347 if ( isComparing . value && mapStore . compareMap ) {
348348 if ( sourceType === 'vector' ) {
349349 mapStore . setupVectorLayerClickHandlers ( mapStore . compareMap , sourceId , mapStore . handleCompareLayerClick ) ;
350- }
350+ }
351351 }
352352 } ) ;
353353 } , { deep : true } ) ;
0 commit comments