Index: /trunk/ippToPsps/jython/ipptopspsdb.py
===================================================================
--- /trunk/ippToPsps/jython/ipptopspsdb.py	(revision 35203)
+++ /trunk/ippToPsps/jython/ipptopspsdb.py	(revision 35204)
@@ -1037,11 +1037,19 @@
     def getBoxId(self, ra, dec):
 
+        # for the float comparison, need to use a small window
+        minRA = ra - 0.01
+        maxRA = ra + 0.01
+        minDEC = dec - 0.01
+        maxDEC = dec + 0.01
+
         sql = "SELECT id FROM box \
                WHERE skychunk  = '" + self.skychunk.name + "' \
-               AND ra_center = " + str(ra) + " \
-               AND dec_center = " + str(dec)
+               AND ra_center BETWEEN " + str(minRA) + " AND " + str(maxRA) + " \
+               AND dec_center BETWEEN " + str(minDEC) + " AND " + str(maxDEC)
 
                # AND box_side = " + str(self.skychunk.boxSize)
 
+        # print "sql for boxid: ", sql
+       
         id = -1
         try:
@@ -1140,8 +1148,12 @@
     def insertPending(self, box_id, batchType, ids):
 
+        # print "starting insert pending"
+
         # first delete old pending items
         self.execute("DELETE FROM pending \
                 WHERE box_id = " + str(box_id) + " \
                 AND batch_type = '" + batchType + "'")
+
+        # print "deleted old items"
 
         for id in ids:
@@ -1151,4 +1163,5 @@
                (" + str(box_id) + ", '" + batchType + "', " + str(id) + ")"
 
+            # print "sql: ", sql
             self.execute(sql)
 
@@ -1455,11 +1468,12 @@
     Gets all items in the all_pending temporary table within the bounds of this box
     '''
-    def getItemsInThisThisBox(self, ra, dec):
-
-        halfSide = self.skychunk.boxSize/2.0
-        minRa =  ra-halfSide
-        maxRa = ra+halfSide
-        minDec = dec-halfSide
-        maxDec = dec+halfSide
+    def getItemsInThisBox(self, minRA, maxRA, minDEC, maxDEC):
+
+        # the old linear size is ill-conceived
+        ## XX halfSide = self.skychunk.boxSize/2.0
+        ## XX minRa =  ra-halfSide
+        ## XX maxRa = ra+halfSide
+        ## XX minDec = dec-halfSide
+        ## XX maxDec = dec+halfSide
 
         ids = []
@@ -1467,6 +1481,6 @@
         sql = "SELECT DISTINCT stage_id \
                FROM all_pending \
-               WHERE ra_bore BETWEEN " + str(minRa) + " AND " + str(maxRa) + " \
-               AND dec_bore BETWEEN " + str(minDec) + " AND " + str(maxDec)
+               WHERE ra_bore BETWEEN " + str(minRA) + " AND " + str(maxRA) + " \
+               AND dec_bore BETWEEN " + str(minDEC) + " AND " + str(maxDEC)
 
         try:
Index: /trunk/ippToPsps/jython/queue.py
===================================================================
--- /trunk/ippToPsps/jython/queue.py	(revision 35203)
+++ /trunk/ippToPsps/jython/queue.py	(revision 35204)
@@ -8,4 +8,5 @@
 import sys
 import os
+import math
 import logging.config
 
@@ -117,16 +118,18 @@
                     # starting positions
 
-                    dD = 0.5*skychunk.boxSize
+                    dD = 0.5*self.skychunk.boxSize
                     dec = self.skychunk.minDec + dD
+                    if (dec > 85): raise
+
+                    # print "dec, dD: ", dec, dD
 
                     # a given box centered at RA,DEC with (linear) size of SIDE has the following bounds
-                    dR = 0.5*skychunk.boxSize / math.cos(math.radians(dec))
+                    dR = 0.5*self.skychunk.boxSize / math.cos(math.radians(dec))
                     ra = self.skychunk.minRa + dR
                     
+                    # print "ra, dR: ", ra, dR
+
+                    # XXX not sure why this is not done with a for-loop...
                     while dec <= self.skychunk.maxDec:
-                        
-                        # XXX EAM : need to do something special at the poles...
-                        if (dec > 85): raise
-
                         while ra <= self.skychunk.maxRa:
             
@@ -137,9 +140,8 @@
                            maxDEC = dec + dD
 
-                           XXX EAM:
+                           # this function inserts the box with given center and (linear) skychunk.boxSize 
                            box_id = self.ippToPspsDb.insertBox(ra, dec)
             
-                           XXX EAM:
-                           ids = self.ippToPspsDb.getItemsInThisThisBox(ra, dec)
+                           ids = self.ippToPspsDb.getItemsInThisBox(minRA, maxRA, minDEC, maxDEC)
     
                            self.logger.info("|    %5.1f    |    %5.1f    |  %9d  |  %9d  |" % (
@@ -149,11 +151,16 @@
                                        len(ids)))
                 
+                           # print "box_id: ", box_id
+
                            if len(ids) > 0: self.ippToPspsDb.insertPending(box_id, batchType, ids)
+                           # print "inserted pending"
                            ra = ra + 2*dR
-
-                         dec = dec + 2*dD
-
-                         dR = 0.5*skychunk.boxSize / math.cos(math.radians(dec))
-                         ra = self.skychunk.minRa + dR
+                           # print "new ra: ", ra
+
+                        dec = dec + 2*dD
+                        if (dec > 85): raise
+
+                        dR = 0.5*self.skychunk.boxSize / math.cos(math.radians(dec))
+                        ra = self.skychunk.minRa + dR
 
                 self.logger.info("+-------------+-------------+-------------+-------------+")
Index: /trunk/ippToPsps/test/fulltest.sh
===================================================================
--- /trunk/ippToPsps/test/fulltest.sh	(revision 35203)
+++ /trunk/ippToPsps/test/fulltest.sh	(revision 35204)
@@ -26,9 +26,9 @@
 
 set mkgpc1       = 0
-set initdb       = 1
-set initscratch  = 1
+set initdb       = 0
+set initscratch  = 0
 set camqueue     = 1
-set initbatch    = 1
-set cambatch     = 1
+set initbatch    = 0
+set cambatch     = 0
 set stackqueue   = 0
 set stackbatch   = 0
Index: /trunk/ippToPsps/test/widetest.sh
===================================================================
--- /trunk/ippToPsps/test/widetest.sh	(revision 35204)
+++ /trunk/ippToPsps/test/widetest.sh	(revision 35204)
@@ -0,0 +1,191 @@
+#!/bin/csh -f
+
+set stackqueuename = 0
+if ($#argv > 0) then
+  set stackqueuename = $1
+  echo "stackqueue: $stackqueuename"
+endif
+
+set objectqueuename = 0
+if ($#argv > 0) then
+  set stackqueuename = $1
+  echo "stackqueue: $stackqueuename"
+endif
+
+# a bit crude : get the datadir path by interpollation of the PATH element for psconfig
+foreach f ( `echo $PATH | tr : ' '` )
+  echo $f | grep $PSCONFDIR > /dev/null
+  if ($status) continue
+  set datadir = `echo $f | sed s/bin\$/share/`
+  break
+end
+setenv IPPTOPSPS_DATA $datadir/ipptopsps
+
+# before running this test, you must have a mysql user:
+# mkgpc1.sh user localhost eam eam
+
+set mkgpc1       = 0
+set initdb       = 0
+set initscratch  = 0
+set camqueue     = 1
+set initbatch    = 0
+set cambatch     = 0
+set stackqueue   = 0
+set stackbatch   = 0
+set objectqueue  = 0
+set objectbatch  = 0
+
+set OUTDIR = "testdata"
+set queuename = "test2"
+
+if ($mkgpc1) then
+  mkgpc1data.dvo
+endif
+
+# create the ipptopsps database
+if ($initdb) then 
+
+  # does the database already exist?
+  # XXX this command will blow away an existing database!!
+  mysql -h localhost -u dvo -pdvo -e "create database ipptopsps_test"
+  mysql -h localhost -u dvo -pdvo ipptopsps_test < $IPPTOPSPS_DATA/ippToPspsDbSchema.sql
+
+endif
+
+# re-create the ipptopsps database
+if ($initscratch) then 
+
+  # create the database (ignore failure if it already exists)
+  mysql -h localhost -u dvo -pdvo -e "drop database ipptopsps_test_scratch"
+  mysql -h localhost -u dvo -pdvo -e "create database ipptopsps_test_scratch"
+  ippjython setupScratchDb.py -test
+endif
+
+# this code is sensitive to a previously existing database?
+if ($camqueue) then
+  ippjython queue.py -test edit <<EOF
+$queuename
+test_ds
+IPP_PSPS
+0
+catdir.cam
+$OUTDIR/catdir.cam
+5
+25
+15
+75
+5
+$OUTDIR
+0
+0
+1
+1
+2012-12-10 00:00:00.0
+3PI
+3PI
+1
+0
+0
+1
+0
+y
+y
+EOF
+endif
+
+if ($initbatch) then
+  rm -rf $OUTDIR/IN
+  ippjython loader.py -test $queuename init
+endif
+
+if ($cambatch) then
+  rm -rf $OUTDIR/P2
+  ippjython loader.py -test $queuename once
+endif
+
+# this code is sensitive to a previously existing database?
+if ($stackqueue) then
+  if ($stackqueuename == 0) then
+    set stackqueuename = $queuename\_stk
+  endif
+  ippjython queue.py -test edit <<EOF
+$stackqueuename
+test_ds
+IPP_PSPS
+0
+catdir.stk
+$OUTDIR/catdir.stk
+9
+11
+19
+21
+2
+$OUTDIR
+0
+0
+1
+1
+2012-12-10 00:00:00.0
+3PI
+3PI
+0
+1
+0
+1
+0
+y
+y
+EOF
+endif
+
+if ($stackbatch) then
+  if ($stackqueuename == 0) then
+    set stackqueuename = $queuename\_stk
+  endif
+  rm -rf $OUTDIR/ST
+  ippjython loader.py -test $stackqueuename once
+endif
+
+# this code is sensitive to a previously existing database?
+if ($objectqueue) then
+  if ($objectqueuename == 0) then
+    set objectqueuename = $queuename\_obj
+  endif
+  ippjython queue.py -test edit <<EOF
+$objectqueuename
+test_ds
+IPP_PSPS
+0
+catdir.stk
+$OUTDIR/catdir.stk
+9
+11
+19
+21
+2
+$OUTDIR
+0
+0
+1
+1
+2012-12-10 00:00:00.0
+3PI
+3PI
+0
+0
+1
+1
+0
+y
+y
+EOF
+endif
+
+if ($objectbatch) then
+  if ($objectqueuename == 0) then
+    set objectqueuename = $queuename\_obj
+  endif
+  rm -rf $OUTDIR/OB
+   ippjython loader.py -test $objectqueuename once
+endif
+
