Index: trunk/Ohana/src/libdvo/include/ps1_dev_3_defs.h
===================================================================
--- trunk/Ohana/src/libdvo/include/ps1_dev_3_defs.h	(revision 19823)
+++ trunk/Ohana/src/libdvo/include/ps1_dev_3_defs.h	(revision 20936)
@@ -1,2 +1,5 @@
+Image 		       	*Image_PS1_DEV_3_ToInternal (Image_PS1_DEV_3 *in, int Nvalues);
+Image_PS1_DEV_3  	*ImageInternalTo_PS1_DEV_3 (Image *in, int Nvalues);
+
 PhotCode *PhotCode_PS1_DEV_3_To_Internal (PhotCode_PS1_DEV_3 *in, int Nvalues);
 PhotCode_PS1_DEV_3 *PhotCode_Internal_To_PS1_DEV_3 (PhotCode *in, int Nvalues);
Index: trunk/Ohana/src/libdvo/src/dvo_catalog.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog.c	(revision 19823)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog.c	(revision 20936)
@@ -88,4 +88,7 @@
   catalog[0].secfilt = NULL;
   
+  catalog[0].objID = 0;
+  catalog[0].catID = 0;
+
   catalog[0].Naverage = 0;
   catalog[0].Nmeasure = 0;
Index: trunk/Ohana/src/libdvo/src/dvo_catalog_create.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog_create.c	(revision 19823)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog_create.c	(revision 20936)
@@ -94,4 +94,7 @@
     gfits_modify (&catalog[0].header, "RA1",  "%lf", 1, region[0].Rmax);
     gfits_modify (&catalog[0].header, "DEC1", "%lf", 1, region[0].Dmax);
+    
+    catalog[0].catID = region[0].index;
+    gfits_modify (&catalog[0].header, "CATID", "%d", 1, catalog[0].catID);
   }
 
Index: trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c	(revision 19823)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c	(revision 20936)
@@ -27,4 +27,10 @@
   if (!gfits_scan (&catalog[0].header, "NMISS",    "%d", 1, &Nmissing)) return (FALSE);
   if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0;
+
+  /* the OBJID is a counter that uniquely defines an average entry and never changes.  if
+     it is not defined for a legacy database, we can generate them using the existing index values.
+     XXX if it is missing, give an error and require the user to upgrade the DB? */
+  if (!gfits_scan (&catalog[0].header, "OBJID",    "%d", 1, &catalog[0].objID)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "CATID",    "%d", 1, &catalog[0].catID)) return (FALSE);
 
   /* save the current number so we can do partial updates */
@@ -228,4 +234,5 @@
   gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt);
   gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
+  gfits_modify (&catalog[0].header, "OBJID",    "%d", 1, catalog[0].objID);
 
   f = catalog[0].f;
Index: trunk/Ohana/src/libdvo/src/dvo_catalog_raw.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog_raw.c	(revision 19823)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog_raw.c	(revision 20936)
@@ -25,4 +25,10 @@
   if (!gfits_scan (&catalog[0].header, "NMISS",    "%d", 1, &catalog[0].Nmissing)) return (FALSE);
   if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &catalog[0].Nsecfilt)) catalog[0].Nsecfilt = 0;
+
+  /* the OBJID is a counter that uniquely defines an average entry and never changes.  if
+     it is not defined for a legacy database, we can generate them using the existing index values.
+     XXX if it is missing, give an error and require the user to upgrade the DB? */
+  if (!gfits_scan (&catalog[0].header, "OBJID",    "%d", 1, &catalog[0].objID)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "CATID",    "%d", 1, &catalog[0].catID)) return (FALSE);
 
   /* determine catalog format */
@@ -249,4 +255,5 @@
   gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, catalog[0].Nmissing);
   gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt);
+  gfits_modify (&catalog[0].header, "OBJID",    "%d", 1, catalog[0].objID);
 
   /* specify the appropriate data format */
Index: trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 19823)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 20936)
@@ -174,4 +174,10 @@
   if (!gfits_scan (&catalog[0].header, "NMISS",    "%d", 1, &Nmissing)) return (FALSE);
   if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0;
+
+  /* the OBJID is a counter that uniquely defines an average entry and never changes.  if
+     it is not defined for a legacy database, we can generate them using the existing index values.
+     XXX if it is missing, give an error and require the user to upgrade the DB? */
+  if (!gfits_scan (&catalog[0].header, "OBJID",    "%d", 1, &catalog[0].objID)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "CATID",    "%d", 1, &catalog[0].catID)) return (FALSE);
 
   /* save the current number so we can do partial updates */
@@ -512,4 +518,5 @@
   gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt);
   gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
+  gfits_modify (&catalog[0].header, "OBJID",    "%d", 1, catalog[0].objID);
 
   /* in split mode, we can save only part of the data */ 
@@ -712,4 +719,5 @@
   gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt);
   gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
+  gfits_modify (&catalog[0].header, "OBJID",    "%d", 1, catalog[0].objID);
 
   /* in split mode, we can save only part of the data */ 
@@ -890,4 +898,5 @@
   gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt);
   gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
+  gfits_modify (&catalog[0].header, "OBJID",    "%d", 1, catalog[0].objID);
 
   /* in split mode, we can save only part of the data */ 
Index: trunk/Ohana/src/libdvo/src/skyregion_gsc.c
===================================================================
--- trunk/Ohana/src/libdvo/src/skyregion_gsc.c	(revision 19823)
+++ trunk/Ohana/src/libdvo/src/skyregion_gsc.c	(revision 20936)
@@ -153,4 +153,8 @@
   skytable[0].Nregions = 0;
 
+  // L0, L1, L2, L3, L4 all have index ranges of 0 -> Nregions and parent values pointing
+  // at the index of the parent.  SkyTableAppend updates these values based on the
+  // cumulative count
+
   SkyTableAppend (skytable, &L0, 0);
   SkyTableAppend (skytable, &L1, skytable[0].Nregions - L0.Nregions);
@@ -539,5 +543,6 @@
   for (i = 0; i < new[0].Nregions; i++) {
     old[0].regions[i + Nold] = new[0].regions[i];
-    old[0].regions[i + Nold].parent += Nprev;
+    old[0].regions[i + Nold].parent += Nold;
+    old[0].regions[i + Nold].index += Nold;
   }
   return;
@@ -560,5 +565,3 @@
     notes and questions:
     1) is the regions.index value used?
-
-
 ***/
