Skip to content

Commit 4040e80

Browse files
authored
Firefly-1646: Merge pull request #1694 from FIREFLY-1646-moc-loading
Firefly 1646 moc loading
2 parents 0b793e4 + d7d5e0b commit 4040e80

File tree

4 files changed

+59
-29
lines changed

4 files changed

+59
-29
lines changed

src/firefly/js/drawingLayers/HiPSMOC.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,19 @@ function loadMocFitsWatcher(action, cancelSelf, params, dispatch, getState) {
6060
const dl = getDrawLayerById(getDlAry(), tbl_id);
6161
if (!dl) return;
6262
const preloadedTbl= tablePreloaded && getTblById(tbl_id);
63-
64-
const filterObj= dl.maxFetchDepth ? {filters : `"${mocFitsInfo.uniqColName}" < ${4*(4**(dl.maxFetchDepth+1))}`} : {};
63+
let filterObj= {};
64+
let maxDepth= undefined;
65+
if (dl.maxFetchDepth) {
66+
maxDepth= 4*(4**(dl.maxFetchDepth+1));
67+
filterObj= {filters : `"${mocFitsInfo.uniqColName}" < ${maxDepth}`};
68+
}
6569
if (!dl.mocTable) { // moc table is not yet loaded
6670
let tReq;
6771
if (preloadedTbl){ //load by getting the full version of a already loaded table
72+
73+
// in this case we may have 1 test row loaded. test to see if it is greater than the filter
74+
if (preloadedTbl.tableData.data[0][0] > maxDepth) filterObj= {}; //abort filtering
75+
6876
tReq= cloneRequest(preloadedTbl.request,
6977
{ startIdx : 0, pageSize : MAX_ROW, inclCols: mocFitsInfo.uniqColName, ...filterObj});
7078
}

src/firefly/js/ui/dynamic/DLGeneratedDropDown.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {CIRCLE, POINT, POSITION, RANGE} from './DynamicDef.js';
3535
import {convertRequest, findTargetFromRequest} from './DynamicUISearchPanel.jsx';
3636
import {getSpacialSearchType, hasValidSpacialSearch} from './DynComponents.jsx';
3737
import {confirmDLMenuItem} from './FetchDatalinkTable.js';
38-
import {getStandardIdType, ingestInitArgs, makeFieldDefs, makeSearchAreaInfo} from './ServiceDefTools.js';
38+
import { getStandardIdType, ingestInitArgs, makeFieldDefsWithOptions, makeSearchAreaInfo } from './ServiceDefTools.js';
3939

4040

4141
export const DL_UI_LIST= 'DL_UI_LIST';
@@ -128,7 +128,7 @@ export function DLGeneratedDropDown({initArgs={},
128128
const currentIdx= useStoreConnector(() => getTblById(registryTblId)?.highlightedRow ?? -1);
129129
const [url,setUrl]= useState();
130130
const [searchAttributes,setSearchAttributes]= useState({});
131-
const {makeRegistryRequest,findUrlInReg,getCollectionUrl,getCollectionAttributes}=
131+
const {makeRegistryRequest,findUrlInReg,getCollectionUrl,getCollectionAttributes, defaultMaxMOCFetchDepth}=
132132
{ ...defaultRegistrySearchDef, ...registrySearchDef};
133133

134134
registryData[name] ??= { regLoaded: false, hasRegistry:true, regLoading: false, loadedTblIdCache:undefined, savedUrl: undefined};
@@ -192,7 +192,7 @@ export function DLGeneratedDropDown({initArgs={},
192192
}
193193

194194
return (<DLGeneratedDropDownTables {...{registryTblId,regLoaded, loadedTblIds, setLoadedTblIds, url,
195-
searchAttributes, groupKey, slotProps, findUrlInReg, initArgs, hasRegistry}}/>);
195+
searchAttributes, groupKey, slotProps, findUrlInReg, initArgs, hasRegistry,defaultMaxMOCFetchDepth}}/>);
196196
}
197197

198198
DLGeneratedDropDown.propTypes= {
@@ -230,7 +230,8 @@ DLGeneratedDropDown.propTypes= {
230230

231231

232232
function DLGeneratedDropDownTables({registryTblId, regLoaded, loadedTblIds, setLoadedTblIds, url, hasRegistry,
233-
searchAttributes, groupKey, slotProps, findUrlInReg, initArgs}) {
233+
searchAttributes, groupKey, slotProps,
234+
findUrlInReg, initArgs, defaultMaxMOCFetchDepth}) {
234235

235236
const [sideBarShowing, setSideBarShowing]= useState(true);
236237
const currentTblId= loadedTblIds?.[url];
@@ -265,7 +266,9 @@ function DLGeneratedDropDownTables({registryTblId, regLoaded, loadedTblIds, setL
265266
const qAna= analyzeQueries(currentTblId);
266267
return (
267268
<Sheet sx={{display:'flex', flexDirection: 'row', width:1, height:1, minWidth:800, minHeight:400}}>
268-
<DLGeneratedTableSearch {...{currentTblId, qAna, groupKey, initArgs, sideBar, regHasUrl, url, regLoaded,slotProps, sideBarShowing, setSideBarShowing}}/>
269+
<DLGeneratedTableSearch {...{currentTblId, qAna, groupKey, initArgs, sideBar, regHasUrl, url,
270+
regLoaded,slotProps, sideBarShowing,
271+
setSideBarShowing, defaultMaxMOCFetchDepth}}/>
269272
</Sheet>
270273
);
271274
}
@@ -277,7 +280,8 @@ const executeInitTargetOnce= makeSearchOnce(false);
277280

278281

279282
function DLGeneratedTableSearch({currentTblId, qAna, groupKey, initArgs, sideBar, regHasUrl, url,
280-
sideBarShowing, slotProps, regLoaded, setSideBarShowing}) {
283+
sideBarShowing, slotProps, regLoaded,
284+
setSideBarShowing, defaultMaxMOCFetchDepth}) {
281285
const [,setCallId]= useState('none');
282286
const [{onClick},setClickFuncImpl]= useState({});
283287
const tabsKey= 'Tabs-'+currentTblId;
@@ -300,7 +304,7 @@ function DLGeneratedTableSearch({currentTblId, qAna, groupKey, initArgs, sideBar
300304
}
301305
}, [onClick, initArgs?.urlApi?.callId, matchUrl]);
302306

303-
const fdAry= makePrimarySearchFieldDefAry(qAna,initArgs);
307+
const fdAry= makePrimarySearchFieldDefAry(qAna,initArgs,defaultMaxMOCFetchDepth);
304308

305309
const searchObjFds= fdAry
306310
?.map((fds,idx) => {
@@ -404,20 +408,27 @@ function getCisxUI(qAnaOrSd) {
404408
*
405409
* @param {QueryAnalysis} qAna - the description of all the searches to do for this table
406410
* @param {Object} initArgs
411+
* @param {number} defaultMaxMOCFetchDepth
407412
* @return {Array.<Array.<FieldDef>>}
408413
*/
409-
function makePrimarySearchFieldDefAry(qAna, initArgs) {
414+
function makePrimarySearchFieldDefAry(qAna, initArgs, defaultMaxMOCFetchDepth) {
410415
return qAna?.primarySearchDef.map( (fd) => {
411416
const {serviceDef}= fd; //todo handle case with only an access url
412417
if (!serviceDef) return;
413418
const standId= getStandardId(serviceDef);
414419
const utype= getUtype(serviceDef);
415420
let fdEntryAry;
416421
if (utype===cisxAdhocServiceUtype && standId.startsWith(standardIDs.tap) && serviceDef.cisxTokenSub) {
417-
fdEntryAry= makeFieldDefs(serviceDef.cisxTokenSub, undefined, makeSearchAreaInfo(getCisxUI(serviceDef)), false);
422+
fdEntryAry= makeFieldDefsWithOptions({
423+
serDefParams:serviceDef.cisxTokenSub,
424+
searchAreaInfo:makeSearchAreaInfo(getCisxUI(serviceDef), defaultMaxMOCFetchDepth),
425+
hidePredefinedStringFields:false});
418426
}
419427
else {
420-
fdEntryAry= makeFieldDefs(serviceDef.serDefParams, undefined, makeSearchAreaInfo(getCisxUI(serviceDef)), true);
428+
fdEntryAry= makeFieldDefsWithOptions({
429+
serDefParams:serviceDef.serDefParams,
430+
searchAreaInfo:makeSearchAreaInfo(getCisxUI(serviceDef), defaultMaxMOCFetchDepth)
431+
});
421432
}
422433
if (!isEmpty(initArgs.urlApi)) {
423434
const originalWp= fdEntryAry.find((fd) => fd.type===POSITION)?.initValue ?? fdEntryAry.find((fd) => fd.type===CIRCLE)?.targetDetails?.centerPt;

src/firefly/js/ui/dynamic/ServiceDefTools.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,27 +158,35 @@ function makeExamples(inExample) {
158158
* @param {Number} [fovSize]
159159
* @returns {Array.<FieldDef>}
160160
*/
161-
export function makeFieldDefs(serDefParams, sRegion, searchAreaInfo = {}, hidePredefinedStringFields = false, hipsUrl, fovSize) {
161+
export function makeFieldDefsWithOptions({serDefParams, sRegion, searchAreaInfo = {},
162+
hidePredefinedStringFields = true,
163+
hipsUrl, fovSize}) {
162164
const {filteredParams, posDef} = prefilterRADec(serDefParams, searchAreaInfo);
163165
const fdAry = filteredParams
164166
.filter((serDefParam) => !serDefParam.ref)
165-
.map((serDefParam) => makeFieldDef(serDefParam,sRegion,searchAreaInfo,hidePredefinedStringFields,hipsUrl,fovSize) );
167+
.map((serDefParam) => makeFieldDef({serDefParam,sRegion,searchAreaInfo,hidePredefinedStringFields,hipsUrl,fovSize}) );
166168
if (posDef) fdAry.push(posDef);
167169
return fdAry;
168170
}
169171

172+
export function makeFieldDefs(serDefParams) {
173+
return makeFieldDefsWithOptions({serDefParams});
174+
175+
}
176+
170177

171178
/**
172179
*
173-
* @param {ServiceDescriptorInputParam} serDefParam
174-
* @param {String} [sRegion]
175-
* @param {SearchAreaInfo} [searchAreaInfo]
176-
* @param {boolean} [hidePredefinedStringFields]
177-
* @param {String} [hipsUrl]
178-
* @param {Number} [fovSize]
180+
* @param {Object} p
181+
* @param {ServiceDescriptorInputParam} p.serDefParam
182+
* @param {String} [p.sRegion]
183+
* @param {SearchAreaInfo} [p.searchAreaInfo]
184+
* @param {boolean} [p.hidePredefinedStringFields]
185+
* @param {String} [p.hipsUrl]
186+
* @param {Number} [p.fovSize]
179187
* @return {FieldDef}
180188
*/
181-
function makeFieldDef(serDefParam, sRegion, searchAreaInfo, hidePredefinedStringFields, hipsUrl, fovSize) {
189+
function makeFieldDef({serDefParam, sRegion, searchAreaInfo, hidePredefinedStringFields, hipsUrl, fovSize}) {
182190
if (!serDefParam) return;
183191
if (serDefParam.options) {
184192
return doMakeEnumDef(serDefParam);
@@ -219,6 +227,7 @@ function getMOCList(searchAreaInfo) {
219227
mocUrl : searchAreaInfo[k],
220228
title : searchAreaInfo['mocDesc'+cnt] ?? 'MOC'+cnt,
221229
mocColor: searchAreaInfo['mocColor'+cnt],
230+
maxFetchDepth: searchAreaInfo['maxFetchDepth'+cnt]
222231
};
223232
});
224233
return mocAry.length ? mocAry : undefined;
@@ -342,9 +351,10 @@ function doMakeNumberDef(serDefParam) {
342351
/**
343352
*
344353
* @param {Object} cisxUI
354+
* @param {number} defaultMaxMOCFetchDepth
345355
* @return {SearchAreaInfo}
346356
*/
347-
export function makeSearchAreaInfo(cisxUI) {
357+
export function makeSearchAreaInfo(cisxUI, defaultMaxMOCFetchDepth) {
348358
if (!cisxUI) return;
349359
const tmpObj = cisxUI.reduce((obj, {name, value, UCD}) => {
350360
switch (name) {
@@ -368,7 +378,8 @@ export function makeSearchAreaInfo(cisxUI) {
368378
const hipsProjCsys = hips_frame?.trim().toLowerCase()==='galactic' ? CoordinateSys.GALACTIC : CoordinateSys.EQ_J2000;
369379
const ptCsys= ptIsGalactic ? CoordinateSys.GALACTIC : CoordinateSys.EQ_J2000;
370380
const centerWp = makeWorldPt(hips_initial_ra, hips_initial_dec, ptCsys);
371-
return {...tmpObj, ...mocsObj, centerWp, coordinateSys: hipsProjCsys.toString()};
381+
return {...tmpObj, ...mocsObj, centerWp,
382+
coordinateSys: hipsProjCsys.toString(), maxFetchDepth:defaultMaxMOCFetchDepth};
372383
}
373384

374385

src/firefly/js/ui/dynamic/ServiceDescriptorPanel.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
*/
44

55
import {Stack, Typography} from '@mui/joy';
6-
import {arrayOf, func, object, string} from 'prop-types';
6+
import {func, object, string} from 'prop-types';
77
import React, {memo} from 'react';
88
import {getAppOptions} from '../../core/AppDataCntlr.js';
99
import {parseObsCoreRegion} from '../../util/ObsCoreSRegionParser.js';
1010
import {computeCentralPtRadiusAverage} from '../../visualize/VisUtil.js';
11-
import CompleteButton from '../CompleteButton.jsx';
1211
import {FieldGroup} from '../FieldGroup.jsx';
1312
import {convertRequest, DynLayoutPanelTypes} from './DynamicUISearchPanel.jsx';
1413
import {showInfoPopup} from '../PopupUtil.jsx';
15-
import {getStandardIdType, hasAnySpacial, makeFieldDefs} from './ServiceDefTools.js';
14+
import {getStandardIdType, hasAnySpacial, makeFieldDefsWithOptions} from './ServiceDefTools.js';
1615
import ShapeDataObj from '../../visualize/draw/ShapeDataObj.js';
1716

1817
/**
@@ -21,6 +20,7 @@ import ShapeDataObj from '../../visualize/draw/ShapeDataObj.js';
2120
* @prop {String} examples
2221
* @prop {String} moc
2322
* @prop {String} mocDesc
23+
* @prop {number} maxFetchDepth
2424
* @prop {String} HiPS
2525
* @prop {String} hips_initial_fov
2626
* @prop {String} standardID
@@ -44,8 +44,8 @@ export const ServiceDescriptorPanel= memo(({ serviceDefRef='none', serDef, setSe
4444
console.log(wp);
4545
}
4646

47-
const fieldDefAry= makeFieldDefs(serDef?.serDefParams, sRegion, undefined, true,
48-
getAppOptions()?.coverage?.hipsSourceURL, fovSize);
47+
const fieldDefAry= makeFieldDefsWithOptions({
48+
serDefParams:serDef?.serDefParams, sRegion, hipsUrl:getAppOptions()?.coverage?.hipsSourceURL, fovSize });
4949

5050
const submitSearch= (r) => {
5151
const convertedR= convertRequest(r,fieldDefAry,getStandardIdType(standardID));
@@ -88,7 +88,7 @@ export const ServiceDescriptorPanel= memo(({ serviceDefRef='none', serDef, setSe
8888
});
8989

9090
ServiceDescriptorPanel.propTypes= {
91-
serDefParams: arrayOf(object),
91+
serDef: object,
9292
title: string,
9393
serviceDefRef: string,
9494
setSearchParams: func,

0 commit comments

Comments
 (0)