Skip to content

Commit

Permalink
Firefly-1646: Merge pull request #1694 from FIREFLY-1646-moc-loading
Browse files Browse the repository at this point in the history
Firefly 1646 moc loading
  • Loading branch information
robyww authored Jan 27, 2025
2 parents 0b793e4 + d7d5e0b commit 4040e80
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 29 deletions.
12 changes: 10 additions & 2 deletions src/firefly/js/drawingLayers/HiPSMOC.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,19 @@ function loadMocFitsWatcher(action, cancelSelf, params, dispatch, getState) {
const dl = getDrawLayerById(getDlAry(), tbl_id);
if (!dl) return;
const preloadedTbl= tablePreloaded && getTblById(tbl_id);

const filterObj= dl.maxFetchDepth ? {filters : `"${mocFitsInfo.uniqColName}" < ${4*(4**(dl.maxFetchDepth+1))}`} : {};
let filterObj= {};
let maxDepth= undefined;
if (dl.maxFetchDepth) {
maxDepth= 4*(4**(dl.maxFetchDepth+1));
filterObj= {filters : `"${mocFitsInfo.uniqColName}" < ${maxDepth}`};
}
if (!dl.mocTable) { // moc table is not yet loaded
let tReq;
if (preloadedTbl){ //load by getting the full version of a already loaded table

// in this case we may have 1 test row loaded. test to see if it is greater than the filter
if (preloadedTbl.tableData.data[0][0] > maxDepth) filterObj= {}; //abort filtering

tReq= cloneRequest(preloadedTbl.request,
{ startIdx : 0, pageSize : MAX_ROW, inclCols: mocFitsInfo.uniqColName, ...filterObj});
}
Expand Down
31 changes: 21 additions & 10 deletions src/firefly/js/ui/dynamic/DLGeneratedDropDown.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {CIRCLE, POINT, POSITION, RANGE} from './DynamicDef.js';
import {convertRequest, findTargetFromRequest} from './DynamicUISearchPanel.jsx';
import {getSpacialSearchType, hasValidSpacialSearch} from './DynComponents.jsx';
import {confirmDLMenuItem} from './FetchDatalinkTable.js';
import {getStandardIdType, ingestInitArgs, makeFieldDefs, makeSearchAreaInfo} from './ServiceDefTools.js';
import { getStandardIdType, ingestInitArgs, makeFieldDefsWithOptions, makeSearchAreaInfo } from './ServiceDefTools.js';


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

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

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

DLGeneratedDropDown.propTypes= {
Expand Down Expand Up @@ -230,7 +230,8 @@ DLGeneratedDropDown.propTypes= {


function DLGeneratedDropDownTables({registryTblId, regLoaded, loadedTblIds, setLoadedTblIds, url, hasRegistry,
searchAttributes, groupKey, slotProps, findUrlInReg, initArgs}) {
searchAttributes, groupKey, slotProps,
findUrlInReg, initArgs, defaultMaxMOCFetchDepth}) {

const [sideBarShowing, setSideBarShowing]= useState(true);
const currentTblId= loadedTblIds?.[url];
Expand Down Expand Up @@ -265,7 +266,9 @@ function DLGeneratedDropDownTables({registryTblId, regLoaded, loadedTblIds, setL
const qAna= analyzeQueries(currentTblId);
return (
<Sheet sx={{display:'flex', flexDirection: 'row', width:1, height:1, minWidth:800, minHeight:400}}>
<DLGeneratedTableSearch {...{currentTblId, qAna, groupKey, initArgs, sideBar, regHasUrl, url, regLoaded,slotProps, sideBarShowing, setSideBarShowing}}/>
<DLGeneratedTableSearch {...{currentTblId, qAna, groupKey, initArgs, sideBar, regHasUrl, url,
regLoaded,slotProps, sideBarShowing,
setSideBarShowing, defaultMaxMOCFetchDepth}}/>
</Sheet>
);
}
Expand All @@ -277,7 +280,8 @@ const executeInitTargetOnce= makeSearchOnce(false);


function DLGeneratedTableSearch({currentTblId, qAna, groupKey, initArgs, sideBar, regHasUrl, url,
sideBarShowing, slotProps, regLoaded, setSideBarShowing}) {
sideBarShowing, slotProps, regLoaded,
setSideBarShowing, defaultMaxMOCFetchDepth}) {
const [,setCallId]= useState('none');
const [{onClick},setClickFuncImpl]= useState({});
const tabsKey= 'Tabs-'+currentTblId;
Expand All @@ -300,7 +304,7 @@ function DLGeneratedTableSearch({currentTblId, qAna, groupKey, initArgs, sideBar
}
}, [onClick, initArgs?.urlApi?.callId, matchUrl]);

const fdAry= makePrimarySearchFieldDefAry(qAna,initArgs);
const fdAry= makePrimarySearchFieldDefAry(qAna,initArgs,defaultMaxMOCFetchDepth);

const searchObjFds= fdAry
?.map((fds,idx) => {
Expand Down Expand Up @@ -404,20 +408,27 @@ function getCisxUI(qAnaOrSd) {
*
* @param {QueryAnalysis} qAna - the description of all the searches to do for this table
* @param {Object} initArgs
* @param {number} defaultMaxMOCFetchDepth
* @return {Array.<Array.<FieldDef>>}
*/
function makePrimarySearchFieldDefAry(qAna, initArgs) {
function makePrimarySearchFieldDefAry(qAna, initArgs, defaultMaxMOCFetchDepth) {
return qAna?.primarySearchDef.map( (fd) => {
const {serviceDef}= fd; //todo handle case with only an access url
if (!serviceDef) return;
const standId= getStandardId(serviceDef);
const utype= getUtype(serviceDef);
let fdEntryAry;
if (utype===cisxAdhocServiceUtype && standId.startsWith(standardIDs.tap) && serviceDef.cisxTokenSub) {
fdEntryAry= makeFieldDefs(serviceDef.cisxTokenSub, undefined, makeSearchAreaInfo(getCisxUI(serviceDef)), false);
fdEntryAry= makeFieldDefsWithOptions({
serDefParams:serviceDef.cisxTokenSub,
searchAreaInfo:makeSearchAreaInfo(getCisxUI(serviceDef), defaultMaxMOCFetchDepth),
hidePredefinedStringFields:false});
}
else {
fdEntryAry= makeFieldDefs(serviceDef.serDefParams, undefined, makeSearchAreaInfo(getCisxUI(serviceDef)), true);
fdEntryAry= makeFieldDefsWithOptions({
serDefParams:serviceDef.serDefParams,
searchAreaInfo:makeSearchAreaInfo(getCisxUI(serviceDef), defaultMaxMOCFetchDepth)
});
}
if (!isEmpty(initArgs.urlApi)) {
const originalWp= fdEntryAry.find((fd) => fd.type===POSITION)?.initValue ?? fdEntryAry.find((fd) => fd.type===CIRCLE)?.targetDetails?.centerPt;
Expand Down
33 changes: 22 additions & 11 deletions src/firefly/js/ui/dynamic/ServiceDefTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,27 +158,35 @@ function makeExamples(inExample) {
* @param {Number} [fovSize]
* @returns {Array.<FieldDef>}
*/
export function makeFieldDefs(serDefParams, sRegion, searchAreaInfo = {}, hidePredefinedStringFields = false, hipsUrl, fovSize) {
export function makeFieldDefsWithOptions({serDefParams, sRegion, searchAreaInfo = {},
hidePredefinedStringFields = true,
hipsUrl, fovSize}) {
const {filteredParams, posDef} = prefilterRADec(serDefParams, searchAreaInfo);
const fdAry = filteredParams
.filter((serDefParam) => !serDefParam.ref)
.map((serDefParam) => makeFieldDef(serDefParam,sRegion,searchAreaInfo,hidePredefinedStringFields,hipsUrl,fovSize) );
.map((serDefParam) => makeFieldDef({serDefParam,sRegion,searchAreaInfo,hidePredefinedStringFields,hipsUrl,fovSize}) );
if (posDef) fdAry.push(posDef);
return fdAry;
}

export function makeFieldDefs(serDefParams) {
return makeFieldDefsWithOptions({serDefParams});

}


/**
*
* @param {ServiceDescriptorInputParam} serDefParam
* @param {String} [sRegion]
* @param {SearchAreaInfo} [searchAreaInfo]
* @param {boolean} [hidePredefinedStringFields]
* @param {String} [hipsUrl]
* @param {Number} [fovSize]
* @param {Object} p
* @param {ServiceDescriptorInputParam} p.serDefParam
* @param {String} [p.sRegion]
* @param {SearchAreaInfo} [p.searchAreaInfo]
* @param {boolean} [p.hidePredefinedStringFields]
* @param {String} [p.hipsUrl]
* @param {Number} [p.fovSize]
* @return {FieldDef}
*/
function makeFieldDef(serDefParam, sRegion, searchAreaInfo, hidePredefinedStringFields, hipsUrl, fovSize) {
function makeFieldDef({serDefParam, sRegion, searchAreaInfo, hidePredefinedStringFields, hipsUrl, fovSize}) {
if (!serDefParam) return;
if (serDefParam.options) {
return doMakeEnumDef(serDefParam);
Expand Down Expand Up @@ -219,6 +227,7 @@ function getMOCList(searchAreaInfo) {
mocUrl : searchAreaInfo[k],
title : searchAreaInfo['mocDesc'+cnt] ?? 'MOC'+cnt,
mocColor: searchAreaInfo['mocColor'+cnt],
maxFetchDepth: searchAreaInfo['maxFetchDepth'+cnt]
};
});
return mocAry.length ? mocAry : undefined;
Expand Down Expand Up @@ -342,9 +351,10 @@ function doMakeNumberDef(serDefParam) {
/**
*
* @param {Object} cisxUI
* @param {number} defaultMaxMOCFetchDepth
* @return {SearchAreaInfo}
*/
export function makeSearchAreaInfo(cisxUI) {
export function makeSearchAreaInfo(cisxUI, defaultMaxMOCFetchDepth) {
if (!cisxUI) return;
const tmpObj = cisxUI.reduce((obj, {name, value, UCD}) => {
switch (name) {
Expand All @@ -368,7 +378,8 @@ export function makeSearchAreaInfo(cisxUI) {
const hipsProjCsys = hips_frame?.trim().toLowerCase()==='galactic' ? CoordinateSys.GALACTIC : CoordinateSys.EQ_J2000;
const ptCsys= ptIsGalactic ? CoordinateSys.GALACTIC : CoordinateSys.EQ_J2000;
const centerWp = makeWorldPt(hips_initial_ra, hips_initial_dec, ptCsys);
return {...tmpObj, ...mocsObj, centerWp, coordinateSys: hipsProjCsys.toString()};
return {...tmpObj, ...mocsObj, centerWp,
coordinateSys: hipsProjCsys.toString(), maxFetchDepth:defaultMaxMOCFetchDepth};
}


Expand Down
12 changes: 6 additions & 6 deletions src/firefly/js/ui/dynamic/ServiceDescriptorPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
*/

import {Stack, Typography} from '@mui/joy';
import {arrayOf, func, object, string} from 'prop-types';
import {func, object, string} from 'prop-types';
import React, {memo} from 'react';
import {getAppOptions} from '../../core/AppDataCntlr.js';
import {parseObsCoreRegion} from '../../util/ObsCoreSRegionParser.js';
import {computeCentralPtRadiusAverage} from '../../visualize/VisUtil.js';
import CompleteButton from '../CompleteButton.jsx';
import {FieldGroup} from '../FieldGroup.jsx';
import {convertRequest, DynLayoutPanelTypes} from './DynamicUISearchPanel.jsx';
import {showInfoPopup} from '../PopupUtil.jsx';
import {getStandardIdType, hasAnySpacial, makeFieldDefs} from './ServiceDefTools.js';
import {getStandardIdType, hasAnySpacial, makeFieldDefsWithOptions} from './ServiceDefTools.js';
import ShapeDataObj from '../../visualize/draw/ShapeDataObj.js';

/**
Expand All @@ -21,6 +20,7 @@ import ShapeDataObj from '../../visualize/draw/ShapeDataObj.js';
* @prop {String} examples
* @prop {String} moc
* @prop {String} mocDesc
* @prop {number} maxFetchDepth
* @prop {String} HiPS
* @prop {String} hips_initial_fov
* @prop {String} standardID
Expand All @@ -44,8 +44,8 @@ export const ServiceDescriptorPanel= memo(({ serviceDefRef='none', serDef, setSe
console.log(wp);
}

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

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

ServiceDescriptorPanel.propTypes= {
serDefParams: arrayOf(object),
serDef: object,
title: string,
serviceDefRef: string,
setSearchParams: func,
Expand Down

0 comments on commit 4040e80

Please sign in to comment.