Index: trunk/Ohana/src/libdvo/include/dvo.h
===================================================================
--- trunk/Ohana/src/libdvo/include/dvo.h	(revision 24975)
+++ trunk/Ohana/src/libdvo/include/dvo.h	(revision 24976)
@@ -442,4 +442,5 @@
 SkyList   *SkyListByBounds     	   PROTO((SkyTable *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax));
 SkyList   *SkyListChildrenByBounds PROTO((SkyTable *table, int No, int depth, double Rmin, double Rmax, double Dmin, double Dmax));
+
 int        SkyListMerge     	   PROTO((SkyList **outlist, SkyList *newlist));
 int        SkyListFree             PROTO((SkyList *list));
@@ -448,4 +449,8 @@
 int        SkyTableSetFilenames    PROTO((SkyTable *sky, char *path, char *ext));
 
+SkyList   *SkyRegionByPoint_List   PROTO((SkyList *inList, int depth, double ra, double dec));
+SkyList   *SkyListByBounds_List    PROTO((SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax));
+SkyList   *SkyListChildrenByBounds_List PROTO((SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax));
+
 /* dvo-specific sorting functions */
 void sortave (Average *ave, int N);
Index: trunk/Ohana/src/libdvo/src/skyregion_ops.c
===================================================================
--- trunk/Ohana/src/libdvo/src/skyregion_ops.c	(revision 24975)
+++ trunk/Ohana/src/libdvo/src/skyregion_ops.c	(revision 24976)
@@ -300,4 +300,128 @@
 	  REALLOCATE (list[0].filename, char *, NNEW);
       }
+    }
+  }
+
+  list[0].Nregions = Nnew;
+  return (list);
+}
+
+/* find region which overlaps c at given depth (-1 : populated ) */
+SkyList *SkyRegionByPoint_List (SkyList *inList, int depth, double ra, double dec) {
+  
+  int i;
+  SkyRegion **region;
+  SkyList *list;
+
+  ALLOCATE (list, SkyList, 1);
+  ALLOCATE (list[0].regions,  SkyRegion *, 1);
+  ALLOCATE (list[0].filename,  char *, 1);
+  list[0].Nregions = 0;
+  list[0].ownElements = FALSE; // this list is only holding a view to the elements
+
+  region = inList[0].regions;
+
+  for (i = 0; i < inList[0].Nregions; i++) {
+
+    // once we pass our desired depth, quit
+    if ((depth > -1) && (depth < region[i][0].depth)) break;
+
+    // skip tables that do not overlap 
+    if (ra  < region[i][0].Rmin) continue;
+    if (ra  > region[i][0].Rmax) continue;
+    if (dec < region[i][0].Dmin) continue;
+    if (dec > region[i][0].Dmax) continue;
+
+    // skip tables that are not at our depth
+    if ((depth >  -1) && (depth > region[i][0].depth)) continue;
+    if ((depth == -1) && (region[i][0].table == FALSE)) continue;
+    
+    list[0].regions[0] = region[i];
+    list[0].filename[0] = inList[0].filename[i];
+    list[0].Nregions = 1;
+    break;
+  }
+  return (list);
+}
+
+SkyList *SkyListByBounds_List (SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax) {
+
+  int i, j, Ns;
+  SkyList *list, *extra;
+
+  Rmin = ohana_normalize_angle (Rmin);
+  Rmax = ohana_normalize_angle (Rmax);
+
+  /* handle 0,360 boundary requests */
+  /* this is probably wrong: I will get duplicates for all Dec bands... */
+  if (Rmin > Rmax) {
+    list = SkyListChildrenByBounds_List (table, depth, 0.0, Rmax, Dmin, Dmax);
+
+    extra = SkyListChildrenByBounds_List (table, depth, Rmin, 360.0, Dmin, Dmax);
+    REALLOCATE (list[0].regions, SkyRegion *, list[0].Nregions + extra[0].Nregions);
+    REALLOCATE (list[0].filename, char *, list[0].Nregions + extra[0].Nregions);
+    Ns = list[0].Nregions;
+    for (i = 0; i < extra[0].Nregions; i++) {
+      // search for pre-existing match
+      for (j = 0; j < list[0].Nregions; j++) {
+	if (list[0].regions[j] == extra[0].regions[i]) {
+	  goto skip;
+	}
+      }
+      list[0].regions[Ns] = extra[0].regions[i];
+      list[0].filename[Ns] = extra[0].filename[i];
+      Ns ++;
+    skip:
+      continue;
+    }
+    list[0].Nregions = Ns;
+    SkyListFree (extra);
+  } else {
+    list = SkyListChildrenByBounds_List (table, depth, Rmin, Rmax, Dmin, Dmax);
+  }
+
+  return (list);
+}
+
+SkyList *SkyListChildrenByBounds_List (SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax) {
+
+  int i, j, Ns, Ne, Nnew, NNEW;
+  int append;
+  SkyList *children;
+  SkyList *list;
+  SkyRegion **region;
+
+  Nnew = 0;
+  NNEW = 50;
+  ALLOCATE (list, SkyList, 1);
+  ALLOCATE (list[0].regions, SkyRegion *, NNEW);
+  ALLOCATE (list[0].filename, char *, NNEW);
+  list[0].ownElements = FALSE; // this list is only holding a view to the elements
+
+  region = table[0].regions;
+
+  // can we assume the skylist is globally sorted by depth?  i think so...
+  for (i = 0; i < table[0].Nregions; i++) {
+    
+    // once we pass our desired depth, quit
+    if ((depth > -1) && (depth < region[i][0].depth)) break;
+
+    // skip tables that do not overlap 
+    if (Rmax <= region[i][0].Rmin) continue;
+    if (Rmin >= region[i][0].Rmax) continue;
+    if (Dmax <= region[i][0].Dmin) continue;
+    if (Dmin >= region[i][0].Dmax) continue;
+
+    // skip tables that are not at our depth
+    if ((depth >  -1) && (depth > region[i][0].depth)) continue;
+    if ((depth == -1) && (region[i][0].table == FALSE)) continue;
+
+    list[0].regions[Nnew] = region[i];
+    list[0].filename[Nnew] = table[0].filename[i];
+    Nnew ++;
+    if (Nnew >= NNEW) {
+      NNEW += 50;
+      REALLOCATE (list[0].regions, SkyRegion *, NNEW);
+      REALLOCATE (list[0].filename, char *, NNEW);
     }
   }
