Changeset 36057 for trunk/Ohana/src/getstar
- Timestamp:
- Aug 30, 2013, 1:00:26 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/getstar/src/dvoImagesAtCoords.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/getstar/src/dvoImagesAtCoords.c
r33658 r36057 9 9 static int makePoint(double ra, double dec, Point **pointsOut); 10 10 static int ListImagesAtCoords (Image *dbImages, Point *points, int Npoints); 11 static int readPointFromFile(FILE *f, Point *pt); 11 12 12 13 int main (int argc, char **argv) { … … 23 24 24 25 Point *points; 26 int readStdin = 0; 25 27 if (coordsFile) { 26 Npoints = readPoints(coordsFile, &points); 28 if (strcmp(coordsFile, "-") == 0) { 29 readStdin = 1; 30 } else { 31 Npoints = readPoints(coordsFile, &points); 32 } 27 33 } else { 28 34 Npoints = makePoint(cmd_line_ra, cmd_line_dec, &points); 29 35 } 30 if (!Npoints ) {36 if (!Npoints && !readStdin) { 31 37 exit(1); 32 38 } … … 61 67 } 62 68 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 } 66 89 } 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 99 static 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 } 69 117 } 70 118
Note:
See TracChangeset
for help on using the changeset viewer.
