Changeset 24174 for trunk/ippTools/src/difftool.c
- Timestamp:
- May 13, 2009, 12:37:33 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippTools/src/difftool.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/pap_magic (added) merged: 24120,24132-24136,24145,24147-24154,24156-24164,24168-24173
- Property svn:mergeinfo changed
-
trunk/ippTools/src/difftool.c
r24059 r24174 40 40 static bool revertdiffskyfileMode(pxConfig *config); 41 41 static bool definepoprunMode(pxConfig *config); 42 static bool define byqueryMode(pxConfig *config);42 static bool definewarpstackMode(pxConfig *config); 43 43 static bool definewarpwarpMode(pxConfig *config); 44 44 static bool pendingcleanuprunMode(pxConfig *config); … … 79 79 MODECASE(DIFFTOOL_MODE_REVERTDIFFSKYFILE, revertdiffskyfileMode); 80 80 MODECASE(DIFFTOOL_MODE_DEFINEPOPRUN, definepoprunMode); 81 MODECASE(DIFFTOOL_MODE_DEFINE BYQUERY, definebyqueryMode);81 MODECASE(DIFFTOOL_MODE_DEFINEWARPSTACK, definewarpstackMode); 82 82 MODECASE(DIFFTOOL_MODE_DEFINEWARPWARP, definewarpwarpMode); 83 83 MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); … … 116 116 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 117 117 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); 118 PXOPT_LOOKUP_BOOL(bothways, config->args, "-bothways", false); 119 PXOPT_LOOKUP_BOOL(exposure, config->args, "-exposure", false); 118 120 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 119 121 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 120 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false);121 122 122 123 // default … … 133 134 registered, 134 135 tess_id, 135 exp_id, 136 bothways, 137 exposure, 136 138 false 137 139 ); … … 487 489 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 488 490 PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false); 489 PXOPT_LOOKUP_STR(uri, config->args, "-uri", (fault == 0), false);490 491 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", (fault == 0), false); 491 492 … … 521 522 diff_id, 522 523 skycell_id, 523 uri,524 524 path_base, 525 525 "full", … … 771 771 psS64 template_warp_id, // Warp identifier for template image, PS_MAX_S64 for none 772 772 psS64 template_stack_id, // Stack identifier for template image, PS_MAX_S64 for none 773 psS64 exp_id, // exposure id for input_warp_id (if defined)774 773 pxConfig *config // Configuration 775 774 ) … … 802 801 registered, 803 802 tess_id, 804 exp_id, 803 false, 804 false, 805 805 false // magicked 806 806 ); … … 882 882 PXOPT_LOOKUP_S64(input_warp_id, config->args, "-input_warp_id", false, false); 883 883 PXOPT_LOOKUP_S64(input_stack_id, config->args, "-input_stack_id", false, false); 884 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false);885 884 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 886 885 … … 902 901 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 903 902 "No input has been defined (-input_stack_id or -input_warp_id)"); 904 return false;905 }906 if (input_warp_id && !exp_id) {907 psError(PS_ERR_BAD_PARAMETER_VALUE, true,908 "-exp_id is required with -input_warp_id.");909 903 return false; 910 904 } … … 917 911 template_warp_id ? template_warp_id : PS_MAX_S64, 918 912 template_stack_id ? template_stack_id : PS_MAX_S64, 919 exp_id ? exp_id : PS_MAX_S64,920 913 config)) { 921 914 psError(PS_ERR_UNKNOWN, false, "failed to create populated diffRun"); … … 935 928 936 929 937 static bool define byqueryMode(pxConfig *config)930 static bool definewarpstackMode(pxConfig *config) 938 931 { 939 932 PS_ASSERT_PTR_NON_NULL(config, false); … … 960 953 PXOPT_LOOKUP_BOOL(reRun, config->args, "-rerun", false); 961 954 PXOPT_LOOKUP_BOOL(available, config->args, "-available", false); 955 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 962 956 963 957 // find all things to queue 964 psString query = pxDataGet("difftool_define byquery_part1.sql");958 psString query = pxDataGet("difftool_definewarpstack_part1.sql"); 965 959 if (!query) { 966 960 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); … … 1057 1051 } 1058 1052 1053 if (pretend) { 1054 // negative simple so the default is true 1055 if (!ippdbPrintMetadatas(stdout, output, "diffRun", !simple)) { 1056 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1057 psFree(output); 1058 return false; 1059 } 1060 psFree(output); 1061 return true; 1062 } 1063 1059 1064 // create temporary table 1060 query = pxDataGet("difftool_define byquery_temp_create.sql");1065 query = pxDataGet("difftool_definewarpstack_temp_create.sql"); 1061 1066 if (!p_psDBRunQuery(config->dbh, query)) { 1062 1067 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1070 1075 query = NULL; 1071 1076 1072 psString skycell_query = pxDataGet("difftool_define byquery_part2.sql");1077 psString skycell_query = pxDataGet("difftool_definewarpstack_part2.sql"); 1073 1078 1074 1079 psArray *list = psArrayAllocEmpty(16); // List of runs, to print … … 1183 1188 registered, 1184 1189 tess_id, 1185 exp_id, 1190 true, 1191 false, 1186 1192 false // magicked 1187 1193 ); … … 1284 1290 // Haversine formula for great circle distance 1285 1291 PXOPT_COPY_F32(config->args, selectWhere, "-distance", 1286 "DEGREES(2*ASIN(SQRT(POW(SIN(inputRawExp.decl - templateRawExp.decl),2) + COS(inputRawExp.decl)*COS(templateRawExp.decl)*POW(SIN(inputRawExp.ra - templateRawExp.ra),2))))", "<="); 1292 "DEGREES(2*ASIN(SQRT(POW(SIN(inputRawExp.decl - templateRawExp.decl),2) + " 1293 "COS(inputRawExp.decl)*COS(templateRawExp.decl)*" 1294 "POW(SIN(inputRawExp.ra - templateRawExp.ra),2))))", "<="); 1287 1295 1288 1296 PXOPT_LOOKUP_BOOL(backwards, config->args, "-backwards", false); … … 1308 1316 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 1309 1317 1318 if (!psDBTransaction(config->dbh)) { 1319 psError(PS_ERR_UNKNOWN, false, "database error"); 1320 psFree(selectWhere); 1321 psFree(insertWhere); 1322 return false; 1323 } 1324 1325 if (!rerun) { 1326 // Need to build table of exposures with diffs 1327 psString tempCreate = pxDataGet("difftool_definewarpwarp_temp_create.sql"); // Create temp table SQL 1328 if (!tempCreate) { 1329 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1330 psFree(selectWhere); 1331 psFree(insertWhere); 1332 if (!psDBRollback(config->dbh)) { 1333 psError(PS_ERR_UNKNOWN, false, "database error"); 1334 } 1335 return false; 1336 } 1337 1338 if (!p_psDBRunQuery(config->dbh, tempCreate)) { 1339 psError(PS_ERR_UNKNOWN, false, "Unable to create temp table: %s", tempCreate); 1340 psFree(tempCreate); 1341 psFree(selectWhere); 1342 psFree(insertWhere); 1343 if (!psDBRollback(config->dbh)) { 1344 psError(PS_ERR_UNKNOWN, false, "database error"); 1345 } 1346 return false; 1347 } 1348 psFree(tempCreate); 1349 1350 psString tempInsert = pxDataGet("difftool_definewarpwarp_temp_insert.sql"); // Insert to temp table 1351 if (!tempInsert) { 1352 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1353 psFree(selectWhere); 1354 psFree(insertWhere); 1355 if (!psDBRollback(config->dbh)) { 1356 psError(PS_ERR_UNKNOWN, false, "database error"); 1357 } 1358 return false; 1359 } 1360 1361 psString where = psStringCopy(""); // WHERE for insertion 1362 if (label) { 1363 psStringAppend(&where, "\nAND diffRun.label = '%s'", label); 1364 } 1365 1366 if (!p_psDBRunQueryF(config->dbh, tempInsert, where, where)) { 1367 psError(PS_ERR_UNKNOWN, false, "Unable to insert into temp table: %s", tempInsert); 1368 psFree(tempInsert); 1369 psFree(where); 1370 psFree(selectWhere); 1371 psFree(insertWhere); 1372 if (!psDBRollback(config->dbh)) { 1373 psError(PS_ERR_UNKNOWN, false, "database error"); 1374 } 1375 return false; 1376 } 1377 psFree(where); 1378 psFree(tempInsert); 1379 } 1380 1381 // Get list of warps to diff 1310 1382 psString select = pxDataGet("difftool_definewarpwarp_select.sql"); 1311 1383 if (!select) { 1312 1384 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1385 psFree(selectWhere); 1386 psFree(insertWhere); 1387 if (!psDBRollback(config->dbh)) { 1388 psError(PS_ERR_UNKNOWN, false, "database error"); 1389 } 1313 1390 return false; 1314 1391 } … … 1323 1400 psFree(selectWhere); 1324 1401 1325 if (!rerun) {1326 psStringAppend(&whereClause, "\n%s (diffRun.diff_id IS NULL", whereClause ? "AND" : "WHERE");1327 if (label) {1328 psStringAppend(&whereClause, " OR diffRun.label != '%s'", label);1329 }1330 psStringAppend(&whereClause, ")");1331 }1332 1333 1402 if (!available) { 1334 1403 psStringAppend(&whereClause, "\n%s inputWarpRun.state = 'full'", whereClause ? "AND" : "WHERE"); 1335 1404 } 1336 1405 1337 if (!psDBTransaction(config->dbh)) { 1338 psError(PS_ERR_UNKNOWN, false, "database error"); 1339 psFree(select); 1340 psFree(whereClause); 1341 psFree(insertWhere); 1342 return false; 1406 if (!rerun) { 1407 psStringAppend(&whereClause, "\n%s diffs.diff_id IS NULL", whereClause ? "AND" : "WHERE"); 1343 1408 } 1344 1409 1345 1410 if (!p_psDBRunQueryF(config->dbh, select, 1346 !rerun ? "\n" : "", // Activate LEFT JOIN against diff Run?1411 !rerun ? "\n" : "", // Activate LEFT JOIN against diffs? 1347 1412 whereClause)) { 1348 1413 psError(PS_ERR_UNKNOWN, false, "Unable to run query: %s [WITH] %s", select, whereClause); … … 1414 1479 psMetadata *row = results->data[i]; // Result row from query 1415 1480 1416 psS64 exp_id = psMetadataLookupS64(NULL, row, "input_exp_id");1417 1481 psS64 input_id = psMetadataLookupS64(NULL, row, "input_warp_id"); 1418 1482 const char *template = psMetadataLookupStr(NULL, row, "template_warp_id"); 1419 1483 const char *tess_id = psMetadataLookupStr(NULL, row, "tess_id"); 1420 if (! exp_id || !input_id || !template || !tess_id) {1484 if (!input_id || !template || !tess_id) { 1421 1485 psError(PXTOOLS_ERR_PROG, false, "Identifiers not found"); 1422 1486 psFree(list); … … 1430 1494 1431 1495 diffRunRow *run = diffRunRowAlloc(0, "reg", workdir, label, reduction, NULL, registered, 1432 tess_id, exp_id, false); // Run to insert1496 tess_id, true, true, false); // Run to insert 1433 1497 if (!diffRunInsertObject(config->dbh, run)) { 1434 1498 psError(PS_ERR_UNKNOWN, false, "database error");
Note:
See TracChangeset
for help on using the changeset viewer.
