- Timestamp:
- Jun 24, 2024, 9:16:02 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20230313/ippTools/src/xcstacktool.c
r42541 r42699 139 139 PXOPT_LOOKUP_TIME(registered, config->args, "-set_registered", false, false); 140 140 141 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 142 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 143 144 // we want to be able to queue the same input stacks for multiple output xcstackRuns, 145 // but we do not want to duplicate entries which already exist for the same 146 // label & data_group (or just data_group??). 147 148 // the possible input stacks are matched to already existing xcstacks with the same 149 // label & data_group and only ones which do NOT match (xcstack_id is NULL) are queued. 150 151 // In order to speed the query operations, the possible matched xcstacks are selected 152 // based on the tess_id, skycell_id, data_group restrictions supplied 153 154 // SUBSET TABLE SQL statement: 155 156 psMetadata *where_XC = psMetadataAlloc(); 157 158 // also restrict the possible matched xcstackRuns based on these options: 159 pxAddLabelSearchArgs(config, where_XC, "-select_tess_id", "xcstackRun.tess_id", "=="); 160 pxAddLabelSearchArgs(config, where_XC, "-select_skycell_id", "xcstackRun.skycell_id", "LIKE"); 161 162 // generate the xcstackRun clause 163 if (!psListLength(where_XC->list)) { 164 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required (at least tess_id or skycell_id)"); 165 psFree(where_XC); 166 return false; 167 } 168 169 psString select_XC = pxDataGet("xcstacktool_definebyquery_select_XC.sql"); 170 if (!select_XC) { 171 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 172 psFree(where_XC); 173 return false; 174 } 175 176 psString whereClause_XC = psDBGenerateWhereConditionSQL(where_XC, NULL); 177 psStringAppend(&select_XC, " WHERE (xcstackInputSkyfile.camera_id = %d)\n AND %s", (int) camera_id, whereClause_XC); 178 psFree(whereClause_XC); 179 180 // add restrictions based on the output data_group and label 181 if (label) { psStringAppend(&select_XC, "\n AND (xcstackRun.label LIKE '%s')", label); } 182 if (data_group) { psStringAppend(&select_XC, "\n AND (xcstackRun.data_group LIKE '%s')", data_group); } 183 184 psFree(where_XC); 185 186 // MAIN SQL statement: 187 141 188 psMetadata *where = psMetadataAlloc(); 142 189 143 pxAddLabelSearchArgs (config, where, "-select_stack_id", "stackRun.stack_id", "=="); 190 // restrict the input stackRun based on these options: 191 pxAddLabelSearchArgs(config, where, "-select_stack_id", "stackRun.stack_id", "=="); 144 192 pxAddLabelSearchArgs(config, where, "-select_tess_id", "stackRun.tess_id", "=="); 145 193 pxAddLabelSearchArgs(config, where, "-select_skycell_id", "stackRun.skycell_id", "LIKE"); … … 150 198 PXOPT_COPY_F32(config->args, where, "-select_good_frac_min", "stackSumSkyfile.good_frac", ">="); 151 199 pxAddLabelSearchArgs(config, where, "-select_data_group", "stackRun.data_group", "LIKE"); 152 153 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);154 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false);155 200 156 201 if (!psListLength(where->list)) { 157 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required ");202 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required (at least tess_id or skycell_id)"); 158 203 psFree(where); 159 204 return false; … … 167 212 } 168 213 169 if (psListLength(where->list)) { 170 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 171 psStringAppend(&select, " AND %s", whereClause); 172 psFree(whereClause); 173 } 214 // merge base select and select_XC 215 psStringAppend (&select, "(%s)\n AS xcstackRunData\n ON (stackRun.stack_id = xcstackRunData.stack_id)\n WHERE xcstack_id IS NULL", select_XC); 216 psFree (select_XC); 217 218 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 219 psStringAppend(&select, "\n AND %s", whereClause); 220 psFree(whereClause); 174 221 psFree(where); 175 222 176 223 // camera name is prepended to stackRun and stackSumSkyfile tables in query 177 if (!p_psDBRunQueryF(config->dbh, select, camera, camera , camera_id)) {224 if (!p_psDBRunQueryF(config->dbh, select, camera, camera)) { 178 225 psError(PS_ERR_UNKNOWN, false, "database error"); 179 226 psFree(select); … … 268 315 xcstackRunRow *run = xcstackRunRowAlloc( 269 316 0, // ID 270 " new",// state317 "wait", // state 271 318 workdir, 272 319 label,
Note:
See TracChangeset
for help on using the changeset viewer.
