Changeset 24976
- Timestamp:
- Aug 3, 2009, 2:18:40 AM (17 years ago)
- Location:
- trunk/Ohana/src/libdvo
- Files:
-
- 2 edited
-
include/dvo.h (modified) (2 diffs)
-
src/skyregion_ops.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libdvo/include/dvo.h
r24974 r24976 442 442 SkyList *SkyListByBounds PROTO((SkyTable *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax)); 443 443 SkyList *SkyListChildrenByBounds PROTO((SkyTable *table, int No, int depth, double Rmin, double Rmax, double Dmin, double Dmax)); 444 444 445 int SkyListMerge PROTO((SkyList **outlist, SkyList *newlist)); 445 446 int SkyListFree PROTO((SkyList *list)); … … 448 449 int SkyTableSetFilenames PROTO((SkyTable *sky, char *path, char *ext)); 449 450 451 SkyList *SkyRegionByPoint_List PROTO((SkyList *inList, int depth, double ra, double dec)); 452 SkyList *SkyListByBounds_List PROTO((SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax)); 453 SkyList *SkyListChildrenByBounds_List PROTO((SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax)); 454 450 455 /* dvo-specific sorting functions */ 451 456 void sortave (Average *ave, int N); -
trunk/Ohana/src/libdvo/src/skyregion_ops.c
r24747 r24976 300 300 REALLOCATE (list[0].filename, char *, NNEW); 301 301 } 302 } 303 } 304 305 list[0].Nregions = Nnew; 306 return (list); 307 } 308 309 /* find region which overlaps c at given depth (-1 : populated ) */ 310 SkyList *SkyRegionByPoint_List (SkyList *inList, int depth, double ra, double dec) { 311 312 int i; 313 SkyRegion **region; 314 SkyList *list; 315 316 ALLOCATE (list, SkyList, 1); 317 ALLOCATE (list[0].regions, SkyRegion *, 1); 318 ALLOCATE (list[0].filename, char *, 1); 319 list[0].Nregions = 0; 320 list[0].ownElements = FALSE; // this list is only holding a view to the elements 321 322 region = inList[0].regions; 323 324 for (i = 0; i < inList[0].Nregions; i++) { 325 326 // once we pass our desired depth, quit 327 if ((depth > -1) && (depth < region[i][0].depth)) break; 328 329 // skip tables that do not overlap 330 if (ra < region[i][0].Rmin) continue; 331 if (ra > region[i][0].Rmax) continue; 332 if (dec < region[i][0].Dmin) continue; 333 if (dec > region[i][0].Dmax) continue; 334 335 // skip tables that are not at our depth 336 if ((depth > -1) && (depth > region[i][0].depth)) continue; 337 if ((depth == -1) && (region[i][0].table == FALSE)) continue; 338 339 list[0].regions[0] = region[i]; 340 list[0].filename[0] = inList[0].filename[i]; 341 list[0].Nregions = 1; 342 break; 343 } 344 return (list); 345 } 346 347 SkyList *SkyListByBounds_List (SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax) { 348 349 int i, j, Ns; 350 SkyList *list, *extra; 351 352 Rmin = ohana_normalize_angle (Rmin); 353 Rmax = ohana_normalize_angle (Rmax); 354 355 /* handle 0,360 boundary requests */ 356 /* this is probably wrong: I will get duplicates for all Dec bands... */ 357 if (Rmin > Rmax) { 358 list = SkyListChildrenByBounds_List (table, depth, 0.0, Rmax, Dmin, Dmax); 359 360 extra = SkyListChildrenByBounds_List (table, depth, Rmin, 360.0, Dmin, Dmax); 361 REALLOCATE (list[0].regions, SkyRegion *, list[0].Nregions + extra[0].Nregions); 362 REALLOCATE (list[0].filename, char *, list[0].Nregions + extra[0].Nregions); 363 Ns = list[0].Nregions; 364 for (i = 0; i < extra[0].Nregions; i++) { 365 // search for pre-existing match 366 for (j = 0; j < list[0].Nregions; j++) { 367 if (list[0].regions[j] == extra[0].regions[i]) { 368 goto skip; 369 } 370 } 371 list[0].regions[Ns] = extra[0].regions[i]; 372 list[0].filename[Ns] = extra[0].filename[i]; 373 Ns ++; 374 skip: 375 continue; 376 } 377 list[0].Nregions = Ns; 378 SkyListFree (extra); 379 } else { 380 list = SkyListChildrenByBounds_List (table, depth, Rmin, Rmax, Dmin, Dmax); 381 } 382 383 return (list); 384 } 385 386 SkyList *SkyListChildrenByBounds_List (SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax) { 387 388 int i, j, Ns, Ne, Nnew, NNEW; 389 int append; 390 SkyList *children; 391 SkyList *list; 392 SkyRegion **region; 393 394 Nnew = 0; 395 NNEW = 50; 396 ALLOCATE (list, SkyList, 1); 397 ALLOCATE (list[0].regions, SkyRegion *, NNEW); 398 ALLOCATE (list[0].filename, char *, NNEW); 399 list[0].ownElements = FALSE; // this list is only holding a view to the elements 400 401 region = table[0].regions; 402 403 // can we assume the skylist is globally sorted by depth? i think so... 404 for (i = 0; i < table[0].Nregions; i++) { 405 406 // once we pass our desired depth, quit 407 if ((depth > -1) && (depth < region[i][0].depth)) break; 408 409 // skip tables that do not overlap 410 if (Rmax <= region[i][0].Rmin) continue; 411 if (Rmin >= region[i][0].Rmax) continue; 412 if (Dmax <= region[i][0].Dmin) continue; 413 if (Dmin >= region[i][0].Dmax) continue; 414 415 // skip tables that are not at our depth 416 if ((depth > -1) && (depth > region[i][0].depth)) continue; 417 if ((depth == -1) && (region[i][0].table == FALSE)) continue; 418 419 list[0].regions[Nnew] = region[i]; 420 list[0].filename[Nnew] = table[0].filename[i]; 421 Nnew ++; 422 if (Nnew >= NNEW) { 423 NNEW += 50; 424 REALLOCATE (list[0].regions, SkyRegion *, NNEW); 425 REALLOCATE (list[0].filename, char *, NNEW); 302 426 } 303 427 }
Note:
See TracChangeset
for help on using the changeset viewer.
