IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6643


Ignore:
Timestamp:
Mar 18, 2006, 5:26:41 PM (20 years ago)
Author:
eugene
Message:

some minor skyregion bugs

Location:
trunk/Ohana/src/libdvo
Files:
2 edited

Legend:

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

    r6235 r6643  
    344344SkyTable  *SkyTableLoadOptimal     PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int depth, int VERBOSE));
    345345int        SkyTableSetDepth        PROTO((SkyTable *sky, int depth));
    346 SkyRegion *SkyRegionByPoint        PROTO((SkyTable *table, int depth, double ra, double dec));
     346SkyList  *SkyRegionByPoint        PROTO((SkyTable *table, int depth, double ra, double dec));
    347347SkyList   *SkyListByPoint          PROTO((SkyTable *table, double ra, double dec));
    348348SkyList   *SkyListByRadius         PROTO((SkyTable *table, int depth, double RA, double DEC, double radius));
  • trunk/Ohana/src/libdvo/src/skyregion_ops.c

    r5956 r6643  
    99
    1010/* find region which overlaps c at given depth (-1 : populated ) */
    11 SkyRegion *SkyRegionByPoint (SkyTable *table, int depth, double ra, double dec) {
     11SkyList *SkyRegionByPoint (SkyTable *table, int depth, double ra, double dec) {
    1212 
    1313  int i, Ns, Ne, No;
    1414  SkyRegion *region;
     15  SkyList *list;
     16
     17  ALLOCATE (list, SkyList, 1);
     18  ALLOCATE (list[0].regions,  SkyRegion *, 1);
     19  ALLOCATE (list[0].filename,  char *, 1);
     20  list[0].Nregions = 0;
    1521
    1622  region = table[0].regions;
     
    2935      break;
    3036    }
    31     if (No == -1) return (NULL);
    32     if ((depth == -1) && (region[No].table)) return (&region[No]);
    33     if (depth == region[No].depth) return (&region[No]);
    34     if ((depth > region[No].depth) && !region[No].child) return (NULL);
     37    if (No == -1) return (list);
     38    if ((depth == -1) && (region[No].table)) break;
     39    if (depth == region[No].depth) break;
     40    if ((depth > region[No].depth) && !region[No].child) return (list);
    3541
    3642    /* need to check Ns, Ne, or guarantee valid range */
     
    3844    Ne = region[No].childE;
    3945  }
     46
     47  list[0].regions[0] = &region[No];
     48  list[0].filename[0] = table[0].filename[No];
     49  list[0].Nregions = 1;
     50  return (list);
    4051}
    4152
     
    7485    list[0].filename[N] = table[0].filename[No];
    7586    N++;
    76     CHECK_REALLOCATE (list[0].regions, SkyRegion *, NREGIONS, N, 10);
    77     CHECK_REALLOCATE (list[0].filename, char *, NREGIONS, N, 10);
     87    if (N >= NREGIONS) {
     88        NREGIONS += 10;
     89        REALLOCATE (list[0].regions, SkyRegion *, NREGIONS);
     90        REALLOCATE (list[0].filename, char *, NREGIONS);
     91    }
    7892    list[0].Nregions = N;
    7993
     
    236250      list[0].filename[Nnew] = table[0].filename[i];
    237251      Nnew ++;
    238       CHECK_REALLOCATE (list[0].regions, SkyRegion *, NNEW, Nnew, 50);
    239       CHECK_REALLOCATE (list[0].filename, char *, NNEW, Nnew, 50);
     252      if (Nnew >= NNEW) {
     253          NNEW += 50;
     254          REALLOCATE (list[0].regions, SkyRegion *, NNEW);
     255          REALLOCATE (list[0].filename, char *, NNEW);
     256      }
    240257    }
    241258  }
Note: See TracChangeset for help on using the changeset viewer.