IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 4, 2007, 10:15:51 AM (19 years ago)
Author:
eugene
Message:

extensive updates to the avextract / mextract / skyregion system

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/dbCmdlineFields.c

    r14191 r14401  
    7070  return (fields);
    7171}
     72
     73char *strfloat (float value) {
     74
     75  int Nbyte;
     76  char *output;
     77  char tmp;
     78
     79  Nbyte = snprintf (&tmp, 0, "%f", value);
     80  ALLOCATE (output, char, Nbyte + 1);
     81  snprintf (output, Nbyte + 1, "%f", value);
     82  return output;
     83}
     84
     85// identify the fields to be extracted (test for where, check syntax)
     86int dbAstroRegionLimits (dbStack **stack, int *nstack, SkyRegionSelection *selection, int table) {
     87 
     88  int N;
     89  double Rmin, Rmax, Dmin, Dmax;
     90  char *Rname, *Dname;
     91
     92  if (!selection->useDisplay && !selection->useSkyregion) return (TRUE);
     93
     94  // get the ra,dec limits...
     95  if (selection->useDisplay) {
     96    return (TRUE);
     97    // XXX fix this: be more careful with the projection & limits
     98
     99    Graphdata graphsky;
     100    if (!GetGraphData (&graphsky, NULL, NULL)) {
     101      gprint (GP_ERR, "region display not available\n");
     102      return (FALSE);
     103    }
     104   
     105    // XXX the ra and dec range depend on the projection.
     106    // XXX this is wrong...
     107    int status;
     108    status = XY_to_RD (&Rmin, &Dmin, graphsky.xmin, graphsky.ymin, &graphsky.coords);
     109    status = XY_to_RD (&Rmax, &Dmax, graphsky.xmax, graphsky.ymax, &graphsky.coords);
     110  }
     111
     112  if (selection->useSkyregion) {
     113    get_skyregion (&Rmin, &Rmax, &Dmin, &Dmax);
     114  }   
     115
     116  N = *nstack;
     117  REALLOCATE (*stack, dbStack, N + 20);
     118
     119  if (table == DVO_TABLE_AVERAGE) {
     120    Rname = strcreate ("RA");
     121    Dname = strcreate ("DEC");
     122  } else {
     123    Rname = strcreate ("RA:AVE");
     124    Dname = strcreate ("DEC:AVE");
     125  }
     126
     127  // add: ((ra > rmin) && (ra < rmax) && (dec > dmin) && (dec < dmax))
     128  // prepend with && if *nstack > 0
     129
     130  stack[0][N +  0].name = strcreate (Rname);
     131  stack[0][N +  0].type = 'X';
     132  stack[0][N +  1].name = strfloat (Rmin);
     133  stack[0][N +  1].type = 'X';
     134  stack[0][N +  2].name = strcreate (">");
     135  stack[0][N +  2].type = 4;
     136  // stack[0][N +  3].name = strcreate ("A");
     137  // stack[0][N +  3].type = 3;
     138
     139  stack[0][N +  3].name = strcreate (Rname);
     140  stack[0][N +  3].type = 'X';
     141  stack[0][N +  4].name = strfloat (Rmax);
     142  stack[0][N +  4].type = 'X';
     143  stack[0][N +  5].name = strcreate ("<");
     144  stack[0][N +  5].type = 4;
     145  stack[0][N +  6].name = strcreate ("A");
     146  stack[0][N +  6].type = 3;
     147
     148  stack[0][N +  7].name = strcreate (Dname);
     149  stack[0][N +  7].type = 'X';
     150  stack[0][N +  8].name = strfloat (Dmin);
     151  stack[0][N +  8].type = 'X';
     152  stack[0][N +  9].name = strcreate (">");
     153  stack[0][N +  9].type = 4;
     154  stack[0][N + 10].name = strcreate ("A");
     155  stack[0][N + 10].type = 3;
     156
     157  stack[0][N + 11].name = strcreate (Dname);
     158  stack[0][N + 11].type = 'X';
     159  stack[0][N + 12].name = strfloat (Dmax);
     160  stack[0][N + 12].type = 'X';
     161  stack[0][N + 13].name = strcreate ("<");
     162  stack[0][N + 13].type = 4;
     163  stack[0][N + 14].name = strcreate ("A");
     164  stack[0][N + 14].type = 3;
     165
     166  if (N == 0) {
     167    N += 15;
     168  } else {
     169    stack[0][N + 15].name = strcreate ("A");
     170    stack[0][N + 15].type = 3;
     171    N += 16;
     172  }   
     173
     174  free (Rname);
     175  free (Dname);
     176
     177  *nstack = N;
     178  return (TRUE);
     179}
     180
Note: See TracChangeset for help on using the changeset viewer.