Index: trunk/Ohana/src/addstar/src/FilterStars.c
===================================================================
--- trunk/Ohana/src/addstar/src/FilterStars.c	(revision 39160)
+++ trunk/Ohana/src/addstar/src/FilterStars.c	(revision 39161)
@@ -10,5 +10,5 @@
 // the imageID supplied here is the sequence **within this set**
 // this value is updated based on the image table later (in UpdateImageIDs)
-Catalog *FilterStars (Catalog *newcat, Image *image, unsigned int imageID, const AddstarClientOptions *options) {
+Catalog *FilterStars (Catalog *newcat, Image *image, unsigned int imageID, SkyRegion *region, const AddstarClientOptions *options) {
 
   int j, N;
@@ -182,4 +182,13 @@
   if (VERBOSE) fprintf (stderr, "stars cover region %f,%f - %f,%f\n", RMIN, DMIN, RMAX, DMAX);
 
+  float dR = RMAX - RMIN;
+  float dD = DMAX - DMIN;
+
+  // define containing region a bit generously
+  region->Rmin = RMIN - 0.1*dR;
+  region->Rmax = RMAX + 0.1*dR;
+  region->Dmin = DMIN - 0.1*dD;
+  region->Dmax = DMAX + 0.1*dD;
+
   return (outcat);
 }
Index: trunk/Ohana/src/addstar/src/LoadData.c
===================================================================
--- trunk/Ohana/src/addstar/src/LoadData.c	(revision 39160)
+++ trunk/Ohana/src/addstar/src/LoadData.c	(revision 39161)
@@ -3,5 +3,5 @@
 // load photometry data from psphot, sextractor, and a few other formats
 // examine the header sets and set the Image entries for the the valid images
-Catalog *LoadData (FILE *f, AddstarFile *file, Image **images, off_t *nvalid, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) {
+Catalog *LoadData (FILE *f, AddstarFile *file, Image **images, off_t *nvalid, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, SkyRegion *region, AddstarClientOptions *options) {
 
   off_t Nskip, Nvalid, NVALID;
@@ -101,14 +101,6 @@
 
     // replace full input catalog newcat with subset version
-    newcat = FilterStars (newcat, &images[0][Nvalid], Nvalid, options);
+    newcat = FilterStars (newcat, &images[0][Nvalid], Nvalid, region, options);
 
-    double Rref, Dref;
-    XY_to_RD (&Rref, &Dref, 0.0, 0.0, &images[0][Nvalid].coords);
-    SkyRegion region;
-    region.Rmin = Rref - 180.0;
-    region.Rmax = Rref + 180.0;
-    region.Dmin = Dref -  90.0;
-    region.Dmax = Dref +  90.0;
-    
     AddstarClientOptions matchOptions = *options;
     matchOptions.radius = 0.4; // tight radius at this stage
@@ -118,5 +110,5 @@
     matchOptions.photcode = 0; // use an invalid photcode to avoid touching secfilt
 
-    find_matches_closest (&region, newcat, catalog, matchOptions);
+    find_matches_closest (region, newcat, catalog, matchOptions);
     dvo_catalog_free (newcat);
     free (newcat);
Index: trunk/Ohana/src/addstar/src/LoadStars.c
===================================================================
--- trunk/Ohana/src/addstar/src/LoadStars.c	(revision 39160)
+++ trunk/Ohana/src/addstar/src/LoadStars.c	(revision 39161)
@@ -75,5 +75,6 @@
     }
 
-    newcat = LoadData (f, &file[i], images, Nimages, headers, extsize, headerSets, NheaderSets, options);
+    SkyRegion region;
+    newcat = LoadData (f, &file[i], images, Nimages, headers, extsize, headerSets, NheaderSets, &region, options);
 
   next_file:
@@ -81,12 +82,4 @@
     // if we added data from an image, then we can merge it in
     if (*Nimages > NimagesStart) {
-      double Rref, Dref;
-      XY_to_RD (&Rref, &Dref, 0.0, 0.0, &images[0][*Nimages-1].coords);
-      SkyRegion region;
-      region.Rmin = Rref - 180.0;
-      region.Rmax = Rref + 180.0;
-      region.Dmin = Dref -  90.0;
-      region.Dmax = Dref +  90.0;
-      
       AddstarClientOptions matchOptions = *options;
       matchOptions.radius = 0.4; // tight radius at this stage
Index: trunk/Ohana/src/addstar/src/ReadStarsSDSS.c
===================================================================
--- trunk/Ohana/src/addstar/src/ReadStarsSDSS.c	(revision 39160)
+++ trunk/Ohana/src/addstar/src/ReadStarsSDSS.c	(revision 39161)
@@ -47,4 +47,6 @@
   int Ncol; // used in the GET_COLUMN_1,5 macros above
   
+  myAbort("need to save the RA,DEC range in a returned SkyRegion (see LoadData)");
+
   if (in_theader == NULL) {
     table.header = &theader;
Index: trunk/Ohana/src/addstar/src/ReadStarsUKIRT.c
===================================================================
--- trunk/Ohana/src/addstar/src/ReadStarsUKIRT.c	(revision 39160)
+++ trunk/Ohana/src/addstar/src/ReadStarsUKIRT.c	(revision 39161)
@@ -15,4 +15,6 @@
   FTable table;
   
+  myAbort("need to save the RA,DEC range in a returned SkyRegion (see LoadData)");
+
   // the FITS binary table header is the same as the image header
   table.header = header;
