- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/Ohana/src/opihi/dvo/skyregion.c
r14402 r27840 44 44 return TRUE; 45 45 } 46 47 /* find region which overlaps c at given depth (-1 : populated ) */ 48 int SkyRegionByPoint_r (SkyTable *table, SkyList *list, int depth, double ra, double dec) { 49 50 int i, Ns, Ne, No; 51 SkyRegion *skyregion; 52 53 list[0].Nregions = 0; 54 list[0].ownElements = FALSE; // this list is only holding a view to the elements 55 56 skyregion = table[0].regions; 57 58 Ns = 0; 59 Ne = 1; 60 61 while (1) { 62 No = -1; 63 for (i = Ns; (i < Ne) && (i < table[0].Nregions); i++) { 64 if (ra < skyregion[i].Rmin) continue; 65 if (ra > skyregion[i].Rmax) continue; 66 if (dec < skyregion[i].Dmin) continue; 67 if (dec > skyregion[i].Dmax) continue; 68 No = i; 69 break; 70 } 71 if (No == -1) return (FALSE); 72 if ((depth == -1) && (skyregion[No].table)) break; 73 if (depth == skyregion[No].depth) break; 74 if ((depth > skyregion[No].depth) && !skyregion[No].child) return (FALSE); 75 76 /* need to check Ns, Ne, or guarantee valid range */ 77 Ns = skyregion[No].childS; 78 Ne = skyregion[No].childE; 79 } 80 81 list[0].regions[0] = &skyregion[No]; 82 list[0].filename[0] = table[0].filename[No]; 83 list[0].Nregions = 1; 84 return (TRUE); 85 } 86 87 SkyList *SelectRegionsByCoordVectors (Vector *RA, Vector *DEC) { 88 89 int i, j, Npts, Nout, NOUT, *found; 90 double ra, dec; 91 SkyList *new, *list; 92 SkyTable *sky; 93 94 sky = GetSkyTable (); 95 96 Npts = RA->Nelements; 97 ALLOCATE (found, int, Npts); 98 memset (found, 0, Npts*sizeof(int)); 99 100 ALLOCATE (new, SkyList, 1); 101 ALLOCATE (new[0].regions, SkyRegion *, 1); 102 ALLOCATE (new[0].filename, char *, 1); 103 104 // output list 105 Nout = 0; 106 NOUT = 100; 107 ALLOCATE (list, SkyList, 1); 108 ALLOCATE (list[0].regions, SkyRegion *, NOUT); 109 ALLOCATE (list[0].filename, char *, NOUT); 110 list[0].Nregions = 0; 111 list[0].ownElements = FALSE; // this list is only holding a view to the elements 112 113 for (i = 0; i < Npts; i++) { 114 if (found[i]) continue; 115 116 SkyRegionByPoint_r (sky, new, -1, RA->elements.Flt[i], DEC->elements.Flt[i]); 117 if (new->Nregions == 0) continue; 118 assert (new->Nregions == 1); 119 // append new region to output list 120 list[0].regions[Nout] = new[0].regions[0]; 121 list[0].filename[Nout] = new[0].filename[0]; 122 Nout ++; 123 if (Nout >= NOUT) { 124 NOUT += 100; 125 REALLOCATE (list[0].regions, SkyRegion *, NOUT); 126 REALLOCATE (list[0].filename, char *, NOUT); 127 } 128 found[i] = TRUE; 129 130 // scan over the remaining points to find any that lie within this region 131 // if we sorted the ra,dec inputs we could break out of this more quickly 132 for (j = i + 1; j < Npts; j++) { 133 ra = RA->elements.Flt[j]; 134 dec = DEC->elements.Flt[j]; 135 if (ra < new[0].regions[0][0].Rmin) continue; 136 if (ra > new[0].regions[0][0].Rmax) continue; 137 if (dec < new[0].regions[0][0].Dmin) continue; 138 if (dec > new[0].regions[0][0].Dmax) continue; 139 found[j] = TRUE; 140 } 141 } 142 list[0].Nregions = Nout; 143 144 free (found); 145 SkyListFree (new); 146 147 return (list); 148 } 149
Note:
See TracChangeset
for help on using the changeset viewer.
