[GRASS-dev] small bug in i.ortho.photo/photo.rectify

hello

recently I orthorectified some photos using i.ortho.photo. the source images are true-colour thus I had three "sub-images" in the imegary-group. in the final step I selected all three to rectify them.

after the rectification of the first image the following error occurred:
"ERROR: error while writing to temp file: No such file or directory"
and the second and third images were not rectified.

checking out the cvs-version I found the corresponding bug in imagery/i.ortho.photo/photo.rectify/write.c

in function "write_map" (line 63) the temp file-descriptor gets closed but not "uninitialized". thus for the second image the check in "write_matrix" line 15 finds a non-zero temp_fd which is connected to a closed and deleted file. the reuse of this file-descriptor causes the error.

I solved this problem using the following patch:
--- grass6/imagery/i.ortho.photo/photo.rectify/write.c.orig
+++ grass6/imagery/i.ortho.photo/photo.rectify/write.c
@@ -60,7 +60,7 @@
            unlink(temp_name);
         }
     }
- close(temp_fd);
+ close(temp_fd); temp_fd = 0;
     unlink(temp_name);
     G_close_cell(fd);

it sets the file-descriptor to 0 after closing it in order to make the check in line 15 work for any following iterations. probably not the best solution as 0 is a valid value for a file-descriptor (normally stdin iirc)?

regards
hermann

Fix committed to SVN (temp_fd = NULL).

On Wed, 2007-12-12 at 22:17 +0100, hermann schwaerzler wrote:

hello

recently I orthorectified some photos using i.ortho.photo. the source
images are true-colour thus I had three "sub-images" in the
imegary-group. in the final step I selected all three to rectify them.

after the rectification of the first image the following error occurred:
"ERROR: error while writing to temp file: No such file or directory"
and the second and third images were not rectified.

checking out the cvs-version I found the corresponding bug in
imagery/i.ortho.photo/photo.rectify/write.c

in function "write_map" (line 63) the temp file-descriptor gets closed
but not "uninitialized". thus for the second image the check in
"write_matrix" line 15 finds a non-zero temp_fd which is connected to a
closed and deleted file. the reuse of this file-descriptor causes the error.

I solved this problem using the following patch:
--- grass6/imagery/i.ortho.photo/photo.rectify/write.c.orig
+++ grass6/imagery/i.ortho.photo/photo.rectify/write.c
@@ -60,7 +60,7 @@
            unlink(temp_name);
         }
     }
- close(temp_fd);
+ close(temp_fd); temp_fd = 0;
     unlink(temp_name);
     G_close_cell(fd);

it sets the file-descriptor to 0 after closing it in order to make the
check in line 15 work for any following iterations. probably not the
best solution as 0 is a valid value for a file-descriptor (normally
stdin iirc)?

--
73, de Brad KB8UYR/6 <rez touchofmadness com>