Index: trunk/pswarp/src/pswarpMapGrid.c
===================================================================
--- trunk/pswarp/src/pswarpMapGrid.c	(revision 12523)
+++ trunk/pswarp/src/pswarpMapGrid.c	(revision 18839)
@@ -4,5 +4,5 @@
 // coordinates (src) to destination coordinates (dest).  we construct a grid with superpixel
 // spacing of nXpix, nYpix.  The transformation for each grid cell is valid for the superpixel.
-// The grid over-fills the source image so ever source image pixel is guaranteed to have a map.
+// The grid over-fills the source image so every source image pixel is guaranteed to have a map.
 pswarpMapGrid *pswarpMapGridFromImage (pmReadout *dest, pmReadout *src, int nXpix, int nYpix) {
 
@@ -11,6 +11,6 @@
 
     // start counting from the center of the superpixels
-    int xMin = 0.5*nXpix;
-    int yMin = 0.5*nYpix;
+    double xMin = 0.5*nXpix;
+    double yMin = 0.5*nYpix;
 
     // the map is defined for coordinates in the image parent frame.
@@ -42,8 +42,22 @@
 
 // set the grid coordinate (gridX,gridY) for the given source image coordinate (ix,iy)
+// XXX return true if the result is on the src image, false otherwise (???)
 bool pswarpMapGridSetGrid (pswarpMapGrid *grid, int ix, int iy, int *gridX, int *gridY) {
 
     *gridX = 0.5 + (ix - grid->xMin) / (double) grid->nXpix;
     *gridY = 0.5 + (iy - grid->yMin) / (double) grid->nYpix;
+
+    return true;
+}
+
+// given the specified grid coordinate (gridX, gridY), return the min and max coordinates for the tile
+bool pswarpMapGridCoordRange (pswarpMapGrid *grid, int gridX, int gridY, psPlane *min, psPlane *max) {
+
+    min->x = (gridX - 0.5)*grid->nXpix + grid->xMin;
+    min->y = (gridY - 0.5)*grid->nYpix + grid->yMin;
+
+    max->x = min->x + grid->nXpix;
+    max->y = min->y + grid->nYpix;
+
     return true;
 }
