Index: trunk/ippTools/src/warptool.c
===================================================================
--- trunk/ippTools/src/warptool.c	(revision 20973)
+++ trunk/ippTools/src/warptool.c	(revision 21308)
@@ -681,4 +681,5 @@
 {
     unsigned int nFail = 0;
+    psMetadata *imfiles = psMetadataAlloc();
     psMetadata *skycells = psMetadataConfigRead(NULL, &nFail, mapfile, false);
     if (!skycells) {
@@ -689,4 +690,5 @@
         psError(PS_ERR_UNKNOWN, false, "there were %d errors parsing mapfile: %s", nFail, mapfile);
         psFree(skycells);
+        psFree(imfiles);
         return false;
     }
@@ -699,4 +701,5 @@
             psFree(iter);
             psFree(skycells);
+            psFree(imfiles);
             return false;
         }
@@ -710,6 +713,8 @@
             psFree(iter);
             psFree(skycells);
-            return false;
-        }
+            psFree(imfiles);
+            return false;
+        }
+        psMetadataAddS64(imfiles, PS_LIST_TAIL, row->skycell_id, PS_META_REPLACE, "", row->warp_id);
 
         if (!warpSkyCellMapInsertObject(config->dbh, row)) {
@@ -726,11 +731,27 @@
             psFree(iter);
             psFree(skycells);
+            psFree(imfiles);
             return false;
         }
 
         psFree(row);
+    }
+    psFree(iter);
+
+    // create warp_skyfile_ids for the output skyfiles
+    psString query = "INSERT INTO warpImfile VALUES(%" PRId64 ", '%s', 0)";
+    iter = psMetadataIteratorAlloc(imfiles, 0, NULL);
+    while ((item = psMetadataGetAndIncrement(iter))) {
+        psString skycell_id = item->name;
+        psS64 warp_id = item->data.S64;
+
+        if (!p_psDBRunQuery(config->dbh, query, warp_id, skycell_id)) {
+            psError(PS_ERR_UNKNOWN, false, "database error");
+            return false;
+        }
     }
     psFree(iter);
     psFree(skycells);
+    psFree(imfiles);
 
     return true;
@@ -940,5 +961,4 @@
                            !accept,
                            code,
-                           0,           // warp_image_id
                            0            // magic_ds_id
         )) {
