Index: /trunk/Ohana/src/addstar/doc/notes.txt
===================================================================
--- /trunk/Ohana/src/addstar/doc/notes.txt	(revision 5438)
+++ /trunk/Ohana/src/addstar/doc/notes.txt	(revision 5439)
@@ -1,4 +1,20 @@
 
-todo goals:
+todo:
+
+  * sky db tools 
+  * parallel servers
+  * threaded addstard
+  * dvo_load daemon
+  * getstar (program and c-client)
+  * parallal / proper-motion data
+  * other additional Average / Measure columns
+  * deal with Myyyy as sky value
+  * better way to interpret flips header info for sky?
+  * fix unlink empty file problem
+  * programs like relphot and dvo need to be provided 
+    with sorted measure tables; add this as a feature 
+    of the load_catalog API?
+
+done:
 
   o move addstar/gstars to AddstarClientOptions
@@ -9,11 +25,4 @@
   o address the cat & ref modes in client/server
   o add airmass quality to options
-
-  * deal with Myyyy as sky value
-  * better way to interpret flips header info for sky?
-  * fix unlink empty file problem
-  * programs like relphot and dvo need to be provided 
-    with sorted measure tables; add this as a feature 
-    of the load_catalog API?
 
 2005.10.19
Index: /trunk/Ohana/src/libautocode/Makefile
===================================================================
--- /trunk/Ohana/src/libautocode/Makefile	(revision 5438)
+++ /trunk/Ohana/src/libautocode/Makefile	(revision 5439)
@@ -51,5 +51,6 @@
 $(SRC)/Stars.$(ARCH).o \
 $(SRC)/GSCRegion.$(ARCH).o \
-$(SRC)/AddstarClientOptions.$(ARCH).o
+$(SRC)/AddstarClientOptions.$(ARCH).o \
+$(SRC)/SkyRegion.$(ARCH).o
 
 LIBINC = \
@@ -82,5 +83,6 @@
 $(INC)/Stars.h \
 $(INC)/GSCRegion.h \
-$(INC)/AddstarClientOptions.h
+$(INC)/AddstarClientOptions.h \
+$(INC)/SkyRegion.h
 
 objects: $(LIBOBJ)
Index: /trunk/Ohana/src/libdvo/Makefile
===================================================================
--- /trunk/Ohana/src/libdvo/Makefile	(revision 5438)
+++ /trunk/Ohana/src/libdvo/Makefile	(revision 5439)
@@ -71,5 +71,6 @@
 $(ASRC)/Stars.$(ARCH).o \
 $(ASRC)/GSCRegion.$(ARCH).o \
-$(ASRC)/AddstarClientOptions.$(ARCH).o
+$(ASRC)/AddstarClientOptions.$(ARCH).o \
+$(ASRC)/SkyRegion.$(ARCH).o
 
 ACOM = $(ADEF)/autocode.c $(ADEF)/autocode.h $(ADEF)/common.h
Index: /trunk/Ohana/src/opihi/dvo/find_regions.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/find_regions.c	(revision 5438)
+++ /trunk/Ohana/src/opihi/dvo/find_regions.c	(revision 5439)
@@ -15,5 +15,5 @@
   int NLINES, done, NREGIONS, nregion;
   
-  VarConfig ("GSCFILE", "%s", filename);
+  VarConfig ("SKYFILE", "%s", filename);
   f = fopen (filename, "r");
   if (f == NULL) {
Index: /trunk/Ohana/src/opihi/dvo2/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/dvo2/Makefile	(revision 5438)
+++ /trunk/Ohana/src/opihi/dvo2/Makefile	(revision 5439)
@@ -17,5 +17,5 @@
 INCS    =       -I$(INC) -I$(LINC) -I$(XINC)
 LFLAGS  =       -L$(LLIB) -L$(LIB)
-LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -lFITS -lohana -lm
+LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -ldvo -lFITS -lohana -lm
 LIBS2   =       -lbasiccmd -ldatacmd -lastrocmd -lshell -ldata 
 LIBS    =       $(LIBS2) $(LIBS1) 
@@ -47,79 +47,16 @@
 install: $(DESTBIN)/dvo2
 
-# utilities #################################################
-$(BIN)/%.$(ARCH):
-	@if [ ! -d $(BIN) ]; then mkdir -p $(BIN); fi
-	$(CC) $^ -o $@ $(LFLAGS) $(LIBS)
-	@echo "compiled $*"
-	@echo ""
+mkst = \
+$(SDIR)/mkskytable.$(ARCH).o \
+$(SDIR)/skydbutils.$(ARCH).o
 
-$(DESTBIN)/%: $(BIN)/%.$(ARCH) 
-	@if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN); fi
-	rm -f $(DESTBIN)/$*
-	cp $(BIN)/$*.$(ARCH) $(DESTBIN)/$*
-	@echo "installed $*"
-	@echo ""
+$(BIN)/mkskytable.$(ARCH): $(mkst)
+mkskytable: $(BIN)/mkskytable.$(ARCH)
+mkskytable.install: $(DESTBIN)/mkskytable
 
-$(LIB)/%.$(ARCH).a:
-	@if [ ! -d $(LIB) ]; then mkdir -p $(LIB); fi
-	rm -f $@
-	ar rcv $@ $^ 
-	$(RANLIB) $@
-	@echo "compiled library $*"
-	@echo ""
+.PHONY: dvo
+.PHONY: mkskytable
 
-$(DESTLIB)/%.a: $(LIB)/%.$(ARCH).a
-	@if [ ! -d $(DESTLIB) ]; then mkdir -p $(DESTLIB); fi
-	@echo ""
-	rm -f $@
-	cp $^ $@
-
-clean:
-	rm -f $(BIN)/*.$(ARCH)
-	rm -f $(LIB)/*.$(ARCH).a
-	rm -f `find . -name "*.o"`
-	rm -f `find . -name "*~"`
-	rm -f `find . -name "#*"`
-
-dist: clean
-	rm -f $(BIN)/*
-	rm -f $(LIB)/*
-
-lib%.clean:
-	rm -f $(LIB)/lib$*.$(ARCH).a
-	rm -f $($*)
-	@echo ""
-
-%.clean:
-	rm -f $(BIN)/$*.$(ARCH)
-	@echo ""
-
-%.$(ARCH).o : %.c
-	$(CC) $(CFLAGS) -c $*.c -o $@
+include ../Makefile.Common
 
 
-
-## -*- makefile -*- 
-# deprecated functions: verify & delete
-#$(SDIR)/abszero.$(ARCH).o \
-#$(SDIR)/cals.$(ARCH).o \
-#$(SDIR)/dumpmags.$(ARCH).o \
-#$(SDIR)/extract.$(ARCH).o \
-#$(SDIR)/gtypes.$(ARCH).o \
-#$(SDIR)/photresid.$(ARCH).o \
-#$(SDIR)/resid.$(ARCH).o \
-#$(SDIR)/zeropts.$(ARCH).o
-#$(SDIR)/objload.$(ARCH).o \ - make sure we have vect to tv
-#$(SDIR)/ccdextract.$(ARCH).o \
-#$(SDIR)/cmdextract.$(ARCH).o \
-#$(SDIR)/dmagextract.$(ARCH).o \
-#$(SDIR)/ddmagextract.$(ARCH).o \
-
-# future functions, not fully implemented
-#$(SDIR)/detrend.$(ARCH).o \
-#$(SDIR)/getxtra.$(ARCH).o \
-#$(SDIR)/addxtra.$(ARCH).o \
-
-# functions that need to be updated
-#$(SDIR)/gregions.$(ARCH).o \
-
Index: /trunk/Ohana/src/opihi/dvo2/skydbsearch.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo2/skydbsearch.c	(revision 5438)
+++ /trunk/Ohana/src/opihi/dvo2/skydbsearch.c	(revision 5439)
@@ -181,195 +181,4 @@
 }
 
-SkyRegion *SkyBuildTable (SkyRegion *seed, int Nseed, int level, int depth) {
-
-  /* given a table of Rmin, Dmin, Rmax, Dmax, name, at level 3, generate
-     all higher levels and 'depth' extra levels */
-
-  /* levels:
-     0 - fullsky.cpt
-     1 - n????.cpt, s????.cpt
-     2 - r????.cpt
-     3 - ????.cpt
-     4 - ????.??.cpt
-  */
-  
-  SkyRegion *db;
-
-  /* allocate at least 30 for levels 0 & 1 */
-  NREGION = 100;
-  ALLOCATE (db, SkyRegion, NREGION);
-
-  /* full sky */
-  strcpy (region[0].name, "fullsky.cpt");
-  region[0].Rmin =   0; region[0].Rmax = 360;
-  region[0].Dmin = -90; region[0].Dmax =  90;
-  region[0].depth = 0;
-  region[0].child = FALSE;
-  N = 1;
-
-  region[0].childS = N;
-  /* north dec bands */
-  for (dec = 0; dec < 90; dec += 7.5) {
-    sprintf (region[N].name, "n%04d.cpt", (int) 100*dec);
-    region[N].Rmin =   0; region[N].Rmax = 360;
-    region[N].Dmin = dec; region[N].Dmax = dec + 7.5;
-    region[N].depth = 1;
-    region[N].child = FALSE;
-    N++;
-  }
-  /* south dec bands */
-  for (dec = 0; dec > -90; dec -= 7.5) {
-    sprintf (region[N].name, "s%04d.cpt", (int) 100*dec);
-    region[N].Rmin =   0;       region[N].Rmax = 360;
-    region[N].Dmin = dec - 7.5; region[N].Dmax = dec;
-    region[N].depth = 1;
-    region[N].child = FALSE;
-    N++;
-  }
-  region[0].childE = N;
-
-  /* subdivide dec bands based on seed */
-  Rnumber = 0;
-  childS = region[0].childS;
-  childE = region[0].childE;
-  for (i = childS; i < childE; i++) {
-
-    Nnew = 0;
-    NNEW = 100;
-    ALLOCATE (new, SkyRegion, NNEW);
-
-    for (j = 0; j < Nseed; j++) {
-      /* skip seeds outside of parent bound */
-      if (seed[j].Rmin > region[i].Rmax) continue;
-      if (seed[j].Rmax < region[i].Rmin) continue;
-      if (seed[j].Dmin > region[i].Dmax) continue;
-      if (seed[j].Dmax < region[i].Dmin) continue;
-      
-      for (k = 0; k < Nnew; k++) {
-	if ((seed[j].Rmin == new[k].Rmin) && 
-	    (seed[j].Rmax == new[k].Rmax)) { 
-	  goto next_seed;
-	}
-	if ((seed[j].Rmin == new[k].Rmin) ^^ 
-	    (seed[j].Rmax != new[k].Rmax)) { 
-	  fprintf (stderr, "inconsistent blocks in seed file\n");
-	  return (NULL);
-	}
-      }	
-      /* new region spans full DEC band.  */
-      new[Nnew].Dmin = region[i].Dmin;
-      new[Nnew].Dmax = region[i].Dmax;
-      
-      Ntall = (region[i].Dmax - region[i].Dmin) / (seed[j].Dmax - seed[j].Dmin);
-      
-      /* fi
-
-      new[Nnew].Rmin = seed[j].Rmin;
-      new[Nnew].Rmax = seed[j].Rmax;
-      new[Nnew].depth = 2;
-      new[Nnew].child = FALSE;
-      strncpy (root, region[i].name, 5); root[5] = 0;
-      sprintf (new[Nnew].name, "%s/r%04d.cpt", root, Rnumber);
-      Rnumber ++;      
-      Nnew ++;
-      if (Nnew == NNEW) {
-	NNEW += 100;
-	REALLOCATE (new, SkyRegion, NNEW);
-      }
-    next_seed:
-    }
-    /* update db list */
-    region[i].childS = N;
-    region[i].childE = N + Nnew;
-    NREGION = N + Nnew + 100;
-    REALLOCATE (db, SkyRegion, NREGION);
-    memcpy (&region[N], new, Nnew*sizeof(SkyRegion));
-    free (new);
-    N += Nnew;
-  }
-
-  /* subdivide ra strips based on seed */
-  childS = region[region[0].childS].childS;
-  childE = region[region[0].childE - 1].childE;
-  nextS = N;
-  for (i = childS; i < childE; i++) {
-
-    Nnew = 0;
-    NNEW = 100;
-    ALLOCATE (new, SkyRegion, NNEW);
-
-    for (j = 0; j < Nseed; j++) {
-      if (seed[j].Rmin > region[i].Rmax) continue;
-      if (seed[j].Rmax < region[i].Rmin) continue;
-      if (seed[j].Dmin > region[i].Dmax) continue;
-      if (seed[j].Dmax < region[i].Dmin) continue;
-      
-      for (k = 0; k < Nnew; k++) {
-	if ((seed[j].Dmin == new[k].Dmin) && 
-	    (seed[j].Dmax == new[k].Dmax)) { 
-	  goto next_seed;
-	}
-	if ((seed[j].Dmin == new[k].Dmin) ^^ 
-	    (seed[j].Dmax != new[k].Dmax)) { 
-	  fprintf (stderr, "inconsistent blocks in seed file\n");
-	  return (NULL);
-	}
-      }	
-      new[Nnew].Dmin = seed[j].Dmin;
-      new[Nnew].Dmax = seed[j].Dmax;
-      new[Nnew].Rmin = region[i].Rmin;
-      new[Nnew].Rmax = region[i].Rmax;
-      new[Nnew].depth = 3;
-      new[Nnew].child = FALSE;
-      strcpy (new[Nnew].name, seed[j].name);
-      Nnew ++;
-      if (Nnew == NNEW) {
-	NNEW += 100;
-	REALLOCATE (new, SkyRegion, NNEW);
-      }
-    next_seed:
-    }
-    
-    /* update db list */
-    region[i].childS = N;
-    region[i].childE = N + Nnew;
-    NREGION = N + Nnew + 100;
-    REALLOCATE (db, SkyRegion, NREGION);
-    memcpy (&region[N], new, Nnew*sizeof(SkyRegion));
-    free (new);
-    N += Nnew;
-  }
-  nextE = N;
-
-  /* subdivide entries once more */
-  childS = nextS;
-  childE = nextE;
-  for (i = childS; i < childE; i++) {
-    Rnumber = 0;
-    region[i].childS = N;
-    dDec = (region[i].Dmax - region[i].Dmin) / 5.0;
-    dRa  = (region[i].Rmax - region[i].Rmin) / 5.0;
-    for (nx = 0; nx < 5; nx++) {
-      for (ny = 0; ny < 5; ny++) {
-	region[N].Dmin = region[i].Dmin + dDec * (nx + 0);
-	region[N].Dmax = region[i].Dmax + dDec * (nx + 1);
-	region[N].Rmin = region[i].Rmin + dDec * (nx + 0);
-	region[N].Rmax = region[i].Rmax + dDec * (nx + 1);
-	region[N].depth = 3;
-	region[N].child = FALSE;
-	strncpy (root, region[i].name, 10); root[10] = 0;
-	sprintf (region[N].name, "%s.%02d.cpt", root, Rnumber);
-	Rnumber ++;
-	N ++;
-	if (N == NREGION) {
-	  NREGION += 100;
-	  REALLOCATE (new, SkyRegion, NREGION);
-	}
-      }
-    }
-  }
-
-}
-
 /* region is pointer to entry in db */
 SkyRegion *SkyExtend (SkyRegion *db, SkyRegion *region) {
Index: /trunk/Ohana/src/opihi/include/dvo2.h
===================================================================
--- /trunk/Ohana/src/opihi/include/dvo2.h	(revision 5438)
+++ /trunk/Ohana/src/opihi/include/dvo2.h	(revision 5439)
@@ -1,8 +1,3 @@
-# include "external.h"
-# include "shell.h"
-# include "dvomath.h"
-# include "convert.h"
-# include "display.h"
-# include "data.h"
+# include "astro.h"
 
 # ifndef DVO2_H
@@ -23,4 +18,5 @@
 } SkyRegionList;
 
+# if (0)
 typedef struct {
   float Rmin, Rmax;
@@ -31,4 +27,5 @@
   char  name[24];
 } SkyRegion; /* 48 bytes */ 
+# endif
 
 SkyRegion *SkyFindPoint (SkyRegion *db, SkyCoord c, int depth);
@@ -36,5 +33,4 @@
 SkyRegion **SkyFindArea (SkyRegion *db, SkyCoord c1, SkyCoord c2, int *nlist);
 SkyRegion *SkyFindAreaDB (SkyRegion *db, SkyRegion *ref, SkyCoord c1, SkyCoord c2, int *Nregion);
-SkyRegion *SkyBuildTable (SkyRegion *seed, int Nseed, int level, int depth);
 
 SkyRegion *SkyMakeRegions (int Nlevels, int *nlist);
@@ -43,3 +39,7 @@
 SkyRegion *SkyDivide (SkyRegion *in);
 
+SkyRegionTable *SkyBuildTable (SkyRegion *seed, int Nseed);
+SkyRegion *SkyRegionsFromGSC (char *filename, int *nregions);
+int FindDecBand (double dec, double *DEC0, double *DEC1);
+
 # endif
