@@ -4,6 +4,7 @@ import { useRecTreeStore } from '@/stores/recTreeStore'; // Adjust import path i
44import { useChartStore } from './chartStore' ;
55import { createDuckDbClient } from '@/utils/SrDuckDb' ;
66import { db } from '@/db/SlideRuleDb' ;
7+ import type { SrSvrParmsUsed } from '@/types/SrTypes' ;
78
89const curGedi2apElFieldOptions = ref ( [ 'elevation_lm' , 'elevation_hr' ] ) ;
910const curGedi2apElevationField = ref ( 'elevation_lm' ) ;
@@ -199,7 +200,6 @@ function getDefaultColorEncoding(funcStr: string,parentFuncStr?:string): string
199200
200201interface RecordInfo {
201202 time ?: string ;
202- as_geo ?: boolean ;
203203 x : string ;
204204 y : string ;
205205 z ?: string ;
@@ -211,9 +211,12 @@ export const useFieldNameStore = defineStore('fieldNameStore', () => {
211211 const lonFieldCache = ref < Record < number , string > > ( { } ) ;
212212 const timeFieldCache = ref < Record < number , string > > ( { } ) ;
213213 const recordInfoCache = ref < Record < number , RecordInfo | null > > ( { } ) ;
214+ const asGeoCache = ref < Record < number , boolean > > ( { } ) ;
214215
215216 const recTreeStore = useRecTreeStore ( ) ;
216217
218+
219+
217220 /**
218221 * Fetch recordinfo metadata from parquet file for a given reqId
219222 * This will cache the result to avoid repeated DB queries
@@ -279,7 +282,7 @@ export const useFieldNameStore = defineStore('fieldNameStore', () => {
279282
280283 /**
281284 * Synchronous field name getters - these check recordinfo cache first (if pre-loaded),
282- * then fall back to hardcoded values. Call loadRecordInfoForReqId () first to populate cache.
285+ * then fall back to hardcoded values. Call loadMetaForReqId () first to populate cache.
283286 */
284287 function getHFieldName ( reqId : number ) : string {
285288 // Check if we have recordinfo in cache
@@ -330,22 +333,42 @@ export const useFieldNameStore = defineStore('fieldNameStore', () => {
330333 }
331334
332335 /**
333- * Async function to pre-load recordinfo metadata for a reqId.
334- * Call this early (e.g., after loading a parquet file) to populate the cache,
335- * so that subsequent synchronous getters can use recordinfo values.
336+ * Load as_geo flag from server parameters for a given reqId
337+ * This checks the output.as_geo field from the request's server parameters
336338 */
337- async function loadRecordInfoForReqId ( reqId : number ) : Promise < RecordInfo | null > {
338- return await getRecordInfoForReqId ( reqId ) ;
339+ async function loadAsGeoFromSvrParams ( reqId : number ) : Promise < void > {
340+ try {
341+ const svrParams = await db . getSvrParams ( reqId ) as SrSvrParmsUsed ;
342+ const asGeo = svrParams ?. output ?. as_geo === true ;
343+ asGeoCache . value [ reqId ] = asGeo ;
344+ if ( asGeo ) {
345+ console . log ( `Request ${ reqId } has as_geo=true in server params` ) ;
346+ }
347+ } catch ( error ) {
348+ console . warn ( `Error loading as_geo from server params for reqId ${ reqId } :` , error ) ;
349+ asGeoCache . value [ reqId ] = false ;
350+ }
339351 }
340352
341353 /**
342354 * Check if the parquet file for a given reqId is in GeoParquet format.
343- * This checks the as_geo property from the recordinfo metadata .
344- * Returns false if recordinfo is not cached or as_geo is not set .
355+ * This checks the as_geo property from the server parameters .
356+ * Returns false if not cached.
345357 */
346358 function isGeoParquet ( reqId : number ) : boolean {
347- const recordInfo = recordInfoCache . value [ reqId ] ;
348- return recordInfo ?. as_geo === true ;
359+ return asGeoCache . value [ reqId ] === true ;
360+ }
361+
362+ /**
363+ * Async function to pre-load recordinfo metadata for a reqId.
364+ * Call this early (e.g., after loading a parquet file) to populate the cache,
365+ * so that subsequent synchronous getters can use recordinfo values.
366+ */
367+ async function loadMetaForReqId ( reqId : number ) : Promise < RecordInfo | null > {
368+ const recordInfo = await getRecordInfoForReqId ( reqId ) ;
369+ // Also load as_geo flag from server parameters
370+ await loadAsGeoFromSvrParams ( reqId ) ;
371+ return recordInfo ;
349372 }
350373
351374 return {
@@ -363,13 +386,15 @@ export const useFieldNameStore = defineStore('fieldNameStore', () => {
363386 curGedi2apElFieldOptions,
364387 curGedi2apElevationField,
365388 isGeoParquet,
389+ loadAsGeoFromSvrParams,
366390 // for debugging/testing
367391 hFieldCache,
368392 latFieldCache,
369393 lonFieldCache,
370394 timeFieldCache,
371395 recordInfoCache,
396+ asGeoCache,
372397 getRecordInfoForReqId,
373- loadRecordInfoForReqId ,
398+ loadMetaForReqId ,
374399 } ;
375400} ) ;
0 commit comments