IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 30, 2013, 1:00:26 PM (13 years ago)
Author:
bills
Message:

If request specifies the tess_id set up a "skycell server" process and
and send lookups to it. This speeds up parsing of bycoord requests by about
a factor of three by avoiding repeated invocations of dvoImagesAtCoords each
of which needs to read the entire tessellation directory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/getstar/src/dvoImagesAtCoords.c

    r33658 r36057  
    99static int makePoint(double ra, double dec, Point **pointsOut);
    1010static int ListImagesAtCoords (Image *dbImages, Point *points, int Npoints);
     11static int readPointFromFile(FILE *f, Point *pt);
    1112
    1213int main (int argc, char **argv) {
     
    2324 
    2425  Point *points;
     26  int readStdin = 0;
    2527  if (coordsFile) {
    26       Npoints = readPoints(coordsFile, &points);
     28      if (strcmp(coordsFile, "-") == 0) {
     29        readStdin = 1;
     30      } else {
     31        Npoints = readPoints(coordsFile, &points);
     32      }
    2733  } else {
    2834      Npoints = makePoint(cmd_line_ra, cmd_line_dec, &points);
    2935  }
    30   if (!Npoints) {
     36  if (!Npoints && !readStdin) {
    3137    exit(1);
    3238  }
     
    6167  }
    6268 
    63   if (MatchCoords (dbImages, NdbImages, points, Npoints)) {
    64     ListImagesAtCoords(dbImages, points, Npoints);
    65     exit(0);
     69  if (readStdin) {
     70    Point pt;
     71    memset(&pt, 0, sizeof(pt));
     72    pt.Nmatches = 0;
     73    ALLOCATE(pt.matches, Match, 20);
     74    pt.arrayLength = 20;
     75
     76    int status;
     77    while ((status = readPointFromFile(stdin, &pt))) {
     78      if (status < 0) {
     79        fprintf(stdout, "ERROR malformed input line\n");
     80        exit(1);
     81      }
     82      if (MatchCoords (dbImages, NdbImages, &pt, 1)) {
     83        ListImagesAtCoords(dbImages, &pt, 1);
     84      }
     85      fprintf(stdout, "DONE\n");
     86      fflush(stdout);
     87      pt.Nmatches = 0;
     88    }
    6689  } else {
    67     exit(PSTAMP_NO_OVERLAP);
    68   }
     90    if (MatchCoords (dbImages, NdbImages, points, Npoints)) {
     91      ListImagesAtCoords(dbImages, points, Npoints);
     92    } else {
     93      exit(PSTAMP_NO_OVERLAP);
     94    }
     95  }
     96  exit(0);
     97}
     98
     99static int readPointFromFile(FILE *f, Point *pt) {
     100    char buf[80];
     101    char *good = fgets(buf, 80, f);
     102    if (!good) {
     103        return 0;
     104    }
     105    // fprintf(stderr, "READ: %s\n", buf);
     106    int Nread = sscanf(buf, "%d %lf %lf\n", &pt->id, &pt->ra, &pt->dec);
     107    if (Nread == 3) {
     108        // got one
     109        return 1;
     110    } else if (Nread == -1) {
     111        // all done time to go
     112        return 0;
     113    } else {
     114        // fprintf(stderr, "malformed input line: %d\n", Nread);
     115        return -1;
     116    }
    69117}
    70118
Note: See TracChangeset for help on using the changeset viewer.