IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 2, 2009, 3:15:42 PM (17 years ago)
Author:
eugene
Message:

various dvo and other improvements from gene@dev branch

Location:
trunk/Ohana/src/libdvo
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libdvo/include/dvo.h

    r24976 r25757  
    325325PhotCodeData *GetPhotcodeTable (void);
    326326
    327 int LoadPhotcodes (char *catdir_file, char *master_file);
     327int LoadPhotcodes (char *catdir_file, char *master_file, int readwrite);
    328328int LoadPhotcodesText (char *filename);
    329329int LoadPhotcodesFITS (char *filename);
     
    432432SkyTable  *SkyTableLoad            PROTO((char *filename, int VERBOSE));
    433433SkyTable  *SkyTableFromGSC         PROTO((char *filename, int depth, int VERBOSE));
    434 SkyTable  *SkyTableLoadOptimal     PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int depth, int VERBOSE));
     434SkyTable  *SkyTableLoadOptimal     PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int readwrite, int depth, int VERBOSE));
    435435int        SkyTableSetDepth        PROTO((SkyTable *sky, int depth));
    436436SkyList   *SkyRegionByPoint        PROTO((SkyTable *table, int depth, double ra, double dec));
  • trunk/Ohana/src/libdvo/src/LoadPhotcodes.c

    r12332 r25757  
    11# include <dvo.h>
    22
    3 int LoadPhotcodes (char *catdir_file, char *master_file) {
     3int LoadPhotcodes (char *catdir_file, char *master_file, int readwrite) {
    44
    55  /* first try to load the photcodes from the specified CATDIR location */
    66  if (LoadPhotcodesFITS (catdir_file)) return TRUE;
    77 
     8  if (!readwrite) {
     9    fprintf (stderr, "db is missing a photcode table & access is read-only -- create one with photcode-table -import\n");
     10    return FALSE;
     11  }
     12
    813  /* next try to load the photcodes from the master text photcode file */
    914  /* automatically (or on demand?) save the text file to the FITS version */
    1015  if (LoadPhotcodesText (master_file)) {
    11       if (!check_file_access (catdir_file, TRUE, TRUE)) return TRUE;
    12       SavePhotcodesFITS (catdir_file);
    13       return TRUE;
     16    if (!check_file_access (catdir_file, TRUE, TRUE, TRUE)) return TRUE;
     17    SavePhotcodesFITS (catdir_file);
     18    return TRUE;
    1419  }
    1520
  • trunk/Ohana/src/libdvo/src/coordops.c

    r19823 r25757  
    163163        return (FALSE);
    164164    }
     165    if (fabs(alpha) >= 180.0) return (FALSE);
    165166    *ra  = alpha + coords[0].crval1;
    166167    *dec = delta + coords[0].crval2;
  • trunk/Ohana/src/libdvo/src/dvo_catalog.c

    r24748 r25757  
    180180
    181181  int Nsecfilt, mode;
     182  int BACKUP, READWRITE;
    182183
    183184  mode = DVO_OPEN_NONE;
     
    192193  dvo_catalog_init (catalog, FALSE);
    193194
     195  // default access control options:
    194196  catalog[0].lockmode  = LCK_XCLD;
    195   if (mode == DVO_OPEN_READ) catalog[0].lockmode  = LCK_SOFT;
     197  BACKUP = TRUE;
     198  READWRITE = TRUE;
     199
     200  // in read-only mode, do not backup or require write access
     201  if (mode == DVO_OPEN_READ) {
     202    catalog[0].lockmode  = LCK_SOFT;
     203    BACKUP = FALSE;
     204    READWRITE = FALSE;
     205  }
    196206 
    197   // XXX make a backup?  always?
    198   if (!check_file_access (catalog[0].filename, TRUE, VERBOSE)) {
     207  if (!check_file_access (catalog[0].filename, BACKUP, READWRITE, VERBOSE)) {
    199208    if (VERBOSE) fprintf (stderr, "no permission to access %s\n", catalog[0].filename);
    200209    return (FALSE);
  • trunk/Ohana/src/libdvo/src/dvo_image.c

    r24748 r25757  
    44int dvo_image_lock (FITS_DB *db, char *filename, double timeout, int lockstate) {
    55
    6   /* lock the image catalog */
    7   if (!check_file_access (filename, FALSE, TRUE)) return (FALSE);
     6  int READWRITE;
     7
     8  // default access control options:
     9  READWRITE = TRUE;
     10
     11  // in read-only mode, do not backup or require write access
     12  if (lockstate == LCK_SOFT) {
     13    READWRITE = FALSE;
     14  }
     15
     16  // do not perform a backup here
     17  if (!check_file_access (filename, FALSE, READWRITE, TRUE)) return (FALSE);
    818
    919  db[0].lockstate = lockstate;
  • trunk/Ohana/src/libdvo/src/skyregion_io.c

    r17000 r25757  
    8484}
    8585
    86 SkyTable *SkyTableLoadOptimal (char *catdir, char *skyfile, char *gscfile, int depth, int verbose) {
     86SkyTable *SkyTableLoadOptimal (char *catdir, char *skyfile, char *gscfile, int readwrite, int depth, int verbose) {
    8787
    8888  char filename[256];
     
    9393  sprintf (filename, "%s/SkyTable.fits", catdir);
    9494  if (stat (filename, &filestat)) goto SKYFILE;
    95   if (!check_file_access (filename, FALSE, verbose)) goto SKYFILE;
     95  if (!check_file_access (filename, FALSE, readwrite, verbose)) goto SKYFILE;
    9696  sky = SkyTableLoad (filename, verbose);
    9797  if (sky == NULL) {
     
    106106  if (skyfile[0] != 0) goto GSCFILE;
    107107  if (stat (skyfile, &filestat)) goto GSCFILE;
    108   if (!check_file_access (skyfile, FALSE, verbose)) goto GSCFILE;
     108  if (!check_file_access (skyfile, FALSE, readwrite, verbose)) goto GSCFILE;
    109109  sky = SkyTableLoad (skyfile, verbose);
    110110  if (sky == NULL) {
     
    117117  /* create CATDIR copy */
    118118  sprintf (filename, "%s/SkyTable.fits", catdir);
    119   check_file_access (filename, FALSE, verbose);
     119  check_file_access (filename, FALSE, readwrite, verbose);
    120120  if (!SkyTableSave (sky, filename)) return NULL;
    121121
     
    134134  /* create CATDIR copy */
    135135  sprintf (filename, "%s/SkyTable.fits", catdir);
    136   check_file_access (filename, FALSE, verbose);
     136  check_file_access (filename, FALSE, readwrite, verbose);
    137137  if (!SkyTableSave (sky, filename)) return NULL;
    138138
Note: See TracChangeset for help on using the changeset viewer.