[GRASS-SVN] r34271 - in grass/trunk/imagery/i.ortho.photo: . libes

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 13 03:24:53 EST 2008


Author: hamish
Date: 2008-11-13 03:24:51 -0500 (Thu, 13 Nov 2008)
New Revision: 34271

Added:
   grass/trunk/imagery/i.ortho.photo/libes/
   grass/trunk/imagery/i.ortho.photo/libes/Makefile
   grass/trunk/imagery/i.ortho.photo/libes/ask_camera.c
   grass/trunk/imagery/i.ortho.photo/libes/cam.c
   grass/trunk/imagery/i.ortho.photo/libes/cam_info.c
   grass/trunk/imagery/i.ortho.photo/libes/camera.c
   grass/trunk/imagery/i.ortho.photo/libes/conz_points.c
   grass/trunk/imagery/i.ortho.photo/libes/elev.c
   grass/trunk/imagery/i.ortho.photo/libes/error.c
   grass/trunk/imagery/i.ortho.photo/libes/find_camera.c
   grass/trunk/imagery/i.ortho.photo/libes/find_init.c
   grass/trunk/imagery/i.ortho.photo/libes/fopen_camera.c
   grass/trunk/imagery/i.ortho.photo/libes/funcdefs.h
   grass/trunk/imagery/i.ortho.photo/libes/georef.c
   grass/trunk/imagery/i.ortho.photo/libes/group_elev.c
   grass/trunk/imagery/i.ortho.photo/libes/init.c
   grass/trunk/imagery/i.ortho.photo/libes/init_info.c
   grass/trunk/imagery/i.ortho.photo/libes/isnull.c
   grass/trunk/imagery/i.ortho.photo/libes/local_proto.h
   grass/trunk/imagery/i.ortho.photo/libes/ls_cameras.c
   grass/trunk/imagery/i.ortho.photo/libes/ls_elev.c
   grass/trunk/imagery/i.ortho.photo/libes/m_add.c
   grass/trunk/imagery/i.ortho.photo/libes/m_copy.c
   grass/trunk/imagery/i.ortho.photo/libes/m_inverse.c
   grass/trunk/imagery/i.ortho.photo/libes/m_mult.c
   grass/trunk/imagery/i.ortho.photo/libes/m_transpose.c
   grass/trunk/imagery/i.ortho.photo/libes/m_zero.c
   grass/trunk/imagery/i.ortho.photo/libes/mat.h
   grass/trunk/imagery/i.ortho.photo/libes/matrixdefs.h
   grass/trunk/imagery/i.ortho.photo/libes/open_camera.c
   grass/trunk/imagery/i.ortho.photo/libes/orthophoto.h
   grass/trunk/imagery/i.ortho.photo/libes/orthoref.c
   grass/trunk/imagery/i.ortho.photo/libes/ref_points.c
   grass/trunk/imagery/i.ortho.photo/libes/title_camera.c
Removed:
   grass/trunk/imagery/i.ortho.photo/libes/Makefile
   grass/trunk/imagery/i.ortho.photo/libes/ask_camera.c
   grass/trunk/imagery/i.ortho.photo/libes/cam.c
   grass/trunk/imagery/i.ortho.photo/libes/cam_info.c
   grass/trunk/imagery/i.ortho.photo/libes/camera.c
   grass/trunk/imagery/i.ortho.photo/libes/conz_points.c
   grass/trunk/imagery/i.ortho.photo/libes/elev.c
   grass/trunk/imagery/i.ortho.photo/libes/error.c
   grass/trunk/imagery/i.ortho.photo/libes/find_camera.c
   grass/trunk/imagery/i.ortho.photo/libes/find_init.c
   grass/trunk/imagery/i.ortho.photo/libes/fopen_camera.c
   grass/trunk/imagery/i.ortho.photo/libes/funcdefs.h
   grass/trunk/imagery/i.ortho.photo/libes/georef.c
   grass/trunk/imagery/i.ortho.photo/libes/group_elev.c
   grass/trunk/imagery/i.ortho.photo/libes/init.c
   grass/trunk/imagery/i.ortho.photo/libes/init_info.c
   grass/trunk/imagery/i.ortho.photo/libes/isnull.c
   grass/trunk/imagery/i.ortho.photo/libes/local_proto.h
   grass/trunk/imagery/i.ortho.photo/libes/ls_cameras.c
   grass/trunk/imagery/i.ortho.photo/libes/ls_elev.c
   grass/trunk/imagery/i.ortho.photo/libes/m_add.c
   grass/trunk/imagery/i.ortho.photo/libes/m_copy.c
   grass/trunk/imagery/i.ortho.photo/libes/m_inverse.c
   grass/trunk/imagery/i.ortho.photo/libes/m_mult.c
   grass/trunk/imagery/i.ortho.photo/libes/m_transpose.c
   grass/trunk/imagery/i.ortho.photo/libes/m_zero.c
   grass/trunk/imagery/i.ortho.photo/libes/mat.h
   grass/trunk/imagery/i.ortho.photo/libes/matrixdefs.h
   grass/trunk/imagery/i.ortho.photo/libes/open_camera.c
   grass/trunk/imagery/i.ortho.photo/libes/orthophoto.h
   grass/trunk/imagery/i.ortho.photo/libes/orthoref.c
   grass/trunk/imagery/i.ortho.photo/libes/ref_points.c
   grass/trunk/imagery/i.ortho.photo/libes/title_camera.c
Log:
reinstate lib fns removed in r33944

Copied: grass/trunk/imagery/i.ortho.photo/libes (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes)

Deleted: grass/trunk/imagery/i.ortho.photo/libes/Makefile
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/Makefile	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/Makefile	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,9 +0,0 @@
-MODULE_TOPDIR = ../../..
-
-EXTRA_LIBS=$(GISLIB) $(IMAGERYLIB)
-
-LIB_NAME = $(IORTHO_LIBNAME)
-
-include $(MODULE_TOPDIR)/include/Make/Lib.make
-
-default: lib

Copied: grass/trunk/imagery/i.ortho.photo/libes/Makefile (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/Makefile)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/Makefile	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/Makefile	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,9 @@
+MODULE_TOPDIR = ../../..
+
+EXTRA_LIBS=$(GISLIB) $(IMAGERYLIB)
+
+LIB_NAME = $(IORTHO_LIBNAME)
+
+include $(MODULE_TOPDIR)/include/Make/Lib.make
+
+default: lib

Deleted: grass/trunk/imagery/i.ortho.photo/libes/ask_camera.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/ask_camera.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/ask_camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,78 +0,0 @@
-
-/*************************************************************
-* I_ask_camera_old (prompt,camera)
-* I_ask_camera_new (prompt,camera)
-* I_ask_camera_any (prompt,camera)
-*
-* prompt the user for an camera reference file name
-*************************************************************/
-#include <string.h>
-#include "orthophoto.h"
-#include <grass/ortholib.h>
-
-static int ask_camera(char *, char *);
-
-int I_ask_camera_old(char *prompt, char *camera)
-{
-    while (1) {
-	if (*prompt == 0)
-	    prompt = "Select an camera reference file";
-	if (!ask_camera(prompt, camera))
-	    return 0;
-	if (I_find_camera(camera))
-	    return 1;
-	fprintf(stderr, "\n** %s - not found **\n\n", camera);
-    }
-}
-
-int I_ask_camera_new(char *prompt, char *camera)
-{
-    while (1) {
-	if (*prompt == 0)
-	    prompt = "Enter a new camera reference file name";
-	if (!ask_camera(prompt, camera))
-	    return 0;
-	if (!I_find_camera(camera))
-	    return 1;
-	fprintf(stderr, "\n** %s - exists, select another name **\n\n",
-		camera);
-    }
-}
-
-int I_ask_camera_any(char *prompt, char *camera)
-{
-    if (*prompt == 0)
-	prompt = "Enter a new or existing camera reference file";
-    return ask_camera(prompt, camera);
-}
-
-static int ask_camera(char *prompt, char *camera)
-{
-    char buf[1024];
-
-    while (1) {
-	fprintf(stderr, "\n%s\n", prompt);
-	fprintf(stderr, "Enter 'list' for a list of existing camera files\n");
-	fprintf(stderr, "Enter 'list -f' for a verbose listing\n");
-	fprintf(stderr, "Hit RETURN %s\n", G_get_ask_return_msg());
-	fprintf(stderr, "> ");
-	if (!G_gets(buf))
-	    continue;
-
-	G_squeeze(buf);
-	fprintf(stderr, "<%s>\n", buf);
-	if (*buf == 0)
-	    return 0;
-
-	if (strcmp(buf, "list") == 0)
-	    I_list_cameras(0);
-	else if (strcmp(buf, "list -f") == 0)
-	    I_list_cameras(1);
-	else if (G_legal_filename(buf) < 0)
-	    fprintf(stderr, "\n** <%s> - illegal name **\n\n", buf);
-	else
-	    break;
-    }
-    strcpy(camera, buf);
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/ask_camera.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/ask_camera.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/ask_camera.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/ask_camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,78 @@
+
+/*************************************************************
+* I_ask_camera_old (prompt,camera)
+* I_ask_camera_new (prompt,camera)
+* I_ask_camera_any (prompt,camera)
+*
+* prompt the user for an camera reference file name
+*************************************************************/
+#include <string.h>
+#include "orthophoto.h"
+#include <grass/ortholib.h>
+
+static int ask_camera(char *, char *);
+
+int I_ask_camera_old(char *prompt, char *camera)
+{
+    while (1) {
+	if (*prompt == 0)
+	    prompt = "Select an camera reference file";
+	if (!ask_camera(prompt, camera))
+	    return 0;
+	if (I_find_camera(camera))
+	    return 1;
+	fprintf(stderr, "\n** %s - not found **\n\n", camera);
+    }
+}
+
+int I_ask_camera_new(char *prompt, char *camera)
+{
+    while (1) {
+	if (*prompt == 0)
+	    prompt = "Enter a new camera reference file name";
+	if (!ask_camera(prompt, camera))
+	    return 0;
+	if (!I_find_camera(camera))
+	    return 1;
+	fprintf(stderr, "\n** %s - exists, select another name **\n\n",
+		camera);
+    }
+}
+
+int I_ask_camera_any(char *prompt, char *camera)
+{
+    if (*prompt == 0)
+	prompt = "Enter a new or existing camera reference file";
+    return ask_camera(prompt, camera);
+}
+
+static int ask_camera(char *prompt, char *camera)
+{
+    char buf[1024];
+
+    while (1) {
+	fprintf(stderr, "\n%s\n", prompt);
+	fprintf(stderr, "Enter 'list' for a list of existing camera files\n");
+	fprintf(stderr, "Enter 'list -f' for a verbose listing\n");
+	fprintf(stderr, "Hit RETURN %s\n", G_get_ask_return_msg());
+	fprintf(stderr, "> ");
+	if (!G_gets(buf))
+	    continue;
+
+	G_squeeze(buf);
+	fprintf(stderr, "<%s>\n", buf);
+	if (*buf == 0)
+	    return 0;
+
+	if (strcmp(buf, "list") == 0)
+	    I_list_cameras(0);
+	else if (strcmp(buf, "list -f") == 0)
+	    I_list_cameras(1);
+	else if (G_legal_filename(buf) < 0)
+	    fprintf(stderr, "\n** <%s> - illegal name **\n\n", buf);
+	else
+	    break;
+    }
+    strcpy(camera, buf);
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/cam.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/cam.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/cam.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,21 +0,0 @@
-
-/***********************************************************
-* I_fopen_group_camera_new (group)
-* I_fopen_group_camera_old (group)
-*
-* fopen() the imagery group camera reference file "CAMERA"
-* (containing the name of the camera associated with the group)
-**********************************************************/
-#include <grass/imagery.h>
-#include "orthophoto.h"
-#include <grass/ortholib.h>
-
-FILE *I_fopen_group_camera_new(char *group)
-{
-    return I_fopen_group_file_new(group, "CAMERA");
-}
-
-FILE *I_fopen_group_camera_old(char *group)
-{
-    return I_fopen_group_file_old(group, "CAMERA");
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/cam.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/cam.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/cam.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/cam.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,21 @@
+
+/***********************************************************
+* I_fopen_group_camera_new (group)
+* I_fopen_group_camera_old (group)
+*
+* fopen() the imagery group camera reference file "CAMERA"
+* (containing the name of the camera associated with the group)
+**********************************************************/
+#include <grass/imagery.h>
+#include "orthophoto.h"
+#include <grass/ortholib.h>
+
+FILE *I_fopen_group_camera_new(char *group)
+{
+    return I_fopen_group_file_new(group, "CAMERA");
+}
+
+FILE *I_fopen_group_camera_old(char *group)
+{
+    return I_fopen_group_file_old(group, "CAMERA");
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/cam_info.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/cam_info.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/cam_info.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,130 +0,0 @@
-#include <string.h>
-#include "orthophoto.h"
-#include <grass/ortholib.h>
-
-#define IN_BUF 100
-#define CAMERA_FILE "CAMERA"
-
-
-int I_read_cam_info(FILE * fd, struct Ortho_Camera_File_Ref *cam_info)
-{
-    int n;
-    char buf[IN_BUF];
-    char cam_name[30];
-    char cam_id[30];
-    double Xp, Yp, CFL;
-    int num_fid;
-    char fid_id[30];
-    double Xf, Yf;
-
-    G_getl(buf, IN_BUF, fd);
-    G_strip(buf);
-    if (sscanf(buf, "CAMERA NAME   %s \n", cam_name) == 1)
-	strcpy(cam_info->cam_name, cam_name);
-
-    G_getl(buf, IN_BUF, fd);
-    G_strip(buf);
-    if (sscanf(buf, "CAMERA ID     %s \n", cam_id) == 1)
-	strcpy(cam_info->cam_id, cam_id);
-
-    G_getl(buf, IN_BUF, fd);
-    G_strip(buf);
-    if (sscanf(buf, "CAMERA XP     %lf \n", &Xp) == 1)
-	cam_info->Xp = Xp;
-
-    G_getl(buf, IN_BUF, fd);
-    G_strip(buf);
-    if (sscanf(buf, "CAMERA YP     %lf \n", &Yp) == 1)
-	cam_info->Yp = Yp;
-
-    G_getl(buf, IN_BUF, fd);
-    G_strip(buf);
-    if (sscanf(buf, "CAMERA CFL    %lf \n", &CFL) == 1)
-	cam_info->CFL = CFL;
-
-    G_getl(buf, IN_BUF, fd);
-    G_strip(buf);
-    if (sscanf(buf, "NUM FID       %d \n", &num_fid) == 1)
-	cam_info->num_fid = num_fid;
-
-    for (n = 0; n < cam_info->num_fid; n++) {
-	G_getl(buf, IN_BUF, fd);
-	G_strip(buf);
-	if (sscanf(buf, "%s %lf %lf", fid_id, &Xf, &Yf) == 3) {
-	    strcpy(cam_info->fiducials[n].fid_id, fid_id);
-	    cam_info->fiducials[n].Xf = Xf;
-	    cam_info->fiducials[n].Yf = Yf;
-	}
-    }
-
-    return 1;
-}
-
-
-int I_new_fid_point(struct Ortho_Camera_File_Ref *cam_info,
-		    char fid_id[30], double Xf, double Yf)
-{
-    return 0;
-}
-
-
-int I_write_cam_info(FILE * fd, struct Ortho_Camera_File_Ref *cam_info)
-{
-    int i;
-
-    fprintf(fd, "CAMERA NAME   %s \n", cam_info->cam_name);
-    fprintf(fd, "CAMERA ID     %s \n", cam_info->cam_id);
-    fprintf(fd, "CAMERA XP     %f \n", cam_info->Xp);
-    fprintf(fd, "CAMERA YP     %f \n", cam_info->Yp);
-    fprintf(fd, "CAMERA CFL    %f \n", cam_info->CFL);
-    fprintf(fd, "NUM FID       %d \n", cam_info->num_fid);
-
-    for (i = 0; i < cam_info->num_fid; i++)
-	fprintf(fd, "  %5s %15f %15f \n",
-		cam_info->fiducials[i].fid_id,
-		cam_info->fiducials[i].Xf, cam_info->fiducials[i].Yf);
-
-    return 0;
-}
-
-
-int I_get_cam_info(char *camera, struct Ortho_Camera_File_Ref *cam_info)
-{
-    FILE *fd;
-    int stat;
-
-    fd = I_fopen_cam_file_old(camera);
-    if (fd == NULL) {
-	G_warning("unable to open camera file %s in %s", camera, G_mapset());
-
-	return 0;
-    }
-
-    stat = I_read_cam_info(fd, cam_info);
-    fclose(fd);
-    if (stat < 0) {
-	G_warning("bad format in camera file %s in %s", camera, G_mapset());
-
-	return 0;
-    }
-
-    return 1;
-}
-
-
-int I_put_cam_info(char *camera, struct Ortho_Camera_File_Ref *cam_info)
-{
-    FILE *fd;
-
-    fd = I_fopen_cam_file_new(camera);
-    if (fd == NULL) {
-	G_warning("unable to open camera file %s in %s", camera, G_mapset());
-
-	return 0;
-    }
-
-    I_write_cam_info(fd, cam_info);
-    fclose(fd);
-
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/cam_info.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/cam_info.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/cam_info.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/cam_info.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,130 @@
+#include <string.h>
+#include "orthophoto.h"
+#include <grass/ortholib.h>
+
+#define IN_BUF 100
+#define CAMERA_FILE "CAMERA"
+
+
+int I_read_cam_info(FILE * fd, struct Ortho_Camera_File_Ref *cam_info)
+{
+    int n;
+    char buf[IN_BUF];
+    char cam_name[30];
+    char cam_id[30];
+    double Xp, Yp, CFL;
+    int num_fid;
+    char fid_id[30];
+    double Xf, Yf;
+
+    G_getl(buf, IN_BUF, fd);
+    G_strip(buf);
+    if (sscanf(buf, "CAMERA NAME   %s \n", cam_name) == 1)
+	strcpy(cam_info->cam_name, cam_name);
+
+    G_getl(buf, IN_BUF, fd);
+    G_strip(buf);
+    if (sscanf(buf, "CAMERA ID     %s \n", cam_id) == 1)
+	strcpy(cam_info->cam_id, cam_id);
+
+    G_getl(buf, IN_BUF, fd);
+    G_strip(buf);
+    if (sscanf(buf, "CAMERA XP     %lf \n", &Xp) == 1)
+	cam_info->Xp = Xp;
+
+    G_getl(buf, IN_BUF, fd);
+    G_strip(buf);
+    if (sscanf(buf, "CAMERA YP     %lf \n", &Yp) == 1)
+	cam_info->Yp = Yp;
+
+    G_getl(buf, IN_BUF, fd);
+    G_strip(buf);
+    if (sscanf(buf, "CAMERA CFL    %lf \n", &CFL) == 1)
+	cam_info->CFL = CFL;
+
+    G_getl(buf, IN_BUF, fd);
+    G_strip(buf);
+    if (sscanf(buf, "NUM FID       %d \n", &num_fid) == 1)
+	cam_info->num_fid = num_fid;
+
+    for (n = 0; n < cam_info->num_fid; n++) {
+	G_getl(buf, IN_BUF, fd);
+	G_strip(buf);
+	if (sscanf(buf, "%s %lf %lf", fid_id, &Xf, &Yf) == 3) {
+	    strcpy(cam_info->fiducials[n].fid_id, fid_id);
+	    cam_info->fiducials[n].Xf = Xf;
+	    cam_info->fiducials[n].Yf = Yf;
+	}
+    }
+
+    return 1;
+}
+
+
+int I_new_fid_point(struct Ortho_Camera_File_Ref *cam_info,
+		    char fid_id[30], double Xf, double Yf)
+{
+    return 0;
+}
+
+
+int I_write_cam_info(FILE * fd, struct Ortho_Camera_File_Ref *cam_info)
+{
+    int i;
+
+    fprintf(fd, "CAMERA NAME   %s \n", cam_info->cam_name);
+    fprintf(fd, "CAMERA ID     %s \n", cam_info->cam_id);
+    fprintf(fd, "CAMERA XP     %f \n", cam_info->Xp);
+    fprintf(fd, "CAMERA YP     %f \n", cam_info->Yp);
+    fprintf(fd, "CAMERA CFL    %f \n", cam_info->CFL);
+    fprintf(fd, "NUM FID       %d \n", cam_info->num_fid);
+
+    for (i = 0; i < cam_info->num_fid; i++)
+	fprintf(fd, "  %5s %15f %15f \n",
+		cam_info->fiducials[i].fid_id,
+		cam_info->fiducials[i].Xf, cam_info->fiducials[i].Yf);
+
+    return 0;
+}
+
+
+int I_get_cam_info(char *camera, struct Ortho_Camera_File_Ref *cam_info)
+{
+    FILE *fd;
+    int stat;
+
+    fd = I_fopen_cam_file_old(camera);
+    if (fd == NULL) {
+	G_warning("unable to open camera file %s in %s", camera, G_mapset());
+
+	return 0;
+    }
+
+    stat = I_read_cam_info(fd, cam_info);
+    fclose(fd);
+    if (stat < 0) {
+	G_warning("bad format in camera file %s in %s", camera, G_mapset());
+
+	return 0;
+    }
+
+    return 1;
+}
+
+
+int I_put_cam_info(char *camera, struct Ortho_Camera_File_Ref *cam_info)
+{
+    FILE *fd;
+
+    fd = I_fopen_cam_file_new(camera);
+    if (fd == NULL) {
+	G_warning("unable to open camera file %s in %s", camera, G_mapset());
+
+	return 0;
+    }
+
+    I_write_cam_info(fd, cam_info);
+    fclose(fd);
+
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/camera.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/camera.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,44 +0,0 @@
-
-/**********************************************************
-* I_get_group_camera (group, &Cam_Ref);
-* I_put_group_camera (group, &Cam_Ref);
-**********************************************************/
-#include "orthophoto.h"
-#include <grass/ortholib.h>
-
-/* Put the "camera" name into the group file "CAMERA" */
-int I_put_group_camera(char *group, char *camera)
-{
-    FILE *fd;
-
-    G_suppress_warnings(1);
-    fd = I_fopen_group_camera_new(group);
-    G_suppress_warnings(0);
-    if (!fd)
-	return 0;
-
-    fprintf(fd, "%s", camera);
-
-    return 0;
-}
-
-/* Return the camera name from the group file CAMERA */
-int I_get_group_camera(char *group, char *camera)
-{
-    char buf[200];
-    FILE *fd;
-
-    G_suppress_warnings(1);
-    fd = I_fopen_group_camera_old(group);
-    G_suppress_warnings(0);
-    if (!fd) {
-	sprintf(buf,
-		"unable to open camera file for group [%s] in mapset [%s]",
-		group, G_mapset());
-	G_warning(buf);
-	return 0;
-    }
-    fgets(buf, sizeof buf, fd);
-    sscanf(buf, "%s", camera);
-    return (1);
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/camera.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/camera.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/camera.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,44 @@
+
+/**********************************************************
+* I_get_group_camera (group, &Cam_Ref);
+* I_put_group_camera (group, &Cam_Ref);
+**********************************************************/
+#include "orthophoto.h"
+#include <grass/ortholib.h>
+
+/* Put the "camera" name into the group file "CAMERA" */
+int I_put_group_camera(char *group, char *camera)
+{
+    FILE *fd;
+
+    G_suppress_warnings(1);
+    fd = I_fopen_group_camera_new(group);
+    G_suppress_warnings(0);
+    if (!fd)
+	return 0;
+
+    fprintf(fd, "%s", camera);
+
+    return 0;
+}
+
+/* Return the camera name from the group file CAMERA */
+int I_get_group_camera(char *group, char *camera)
+{
+    char buf[200];
+    FILE *fd;
+
+    G_suppress_warnings(1);
+    fd = I_fopen_group_camera_old(group);
+    G_suppress_warnings(0);
+    if (!fd) {
+	sprintf(buf,
+		"unable to open camera file for group [%s] in mapset [%s]",
+		group, G_mapset());
+	G_warning(buf);
+	return 0;
+    }
+    fgets(buf, sizeof buf, fd);
+    sscanf(buf, "%s", camera);
+    return (1);
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/conz_points.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/conz_points.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/conz_points.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,191 +0,0 @@
-#include <unistd.h>
-#include <grass/imagery.h>
-#include "orthophoto.h"
-#include <grass/gis.h>
-
-#define POINT_FILE "CONTROL_POINTS"
-
-/* read the control points from group file "Con_POINTS" into */
-/* the struct Con_Points */
-int I_read_con_points(FILE * fd, struct Ortho_Control_Points *cp)
-{
-    char buf[300];
-    double e1, e2, n1, n2, z1, z2;
-    int status;
-
-    cp->count = 0;
-
-    /* read the control point lines. format is (on one line):
-       photo_x        photo_y         -CFL 
-       control_east control_north  control_elev  status(1=ok)
-     */
-    cp->e1 = NULL;
-    cp->e2 = NULL;
-    cp->n1 = NULL;
-    cp->n2 = NULL;
-    cp->z1 = NULL;
-    cp->z2 = NULL;
-
-    cp->status = NULL;
-
-    while (G_getl(buf, sizeof(buf), fd)) {
-	G_strip(buf);
-	if (*buf == '#' || *buf == 0)
-	    continue;
-	if (sscanf(buf, "%lf%lf%lf%lf%lf%lf%d",
-		   &e1, &n1, &z1, &e2, &n2, &z2, &status) == 7)
-	    I_new_con_point(cp, e1, n1, z1, e2, n2, z2, status);
-	else
-	    return -4;
-    }
-
-    return 1;
-}
-
-int I_new_con_point(struct Ortho_Control_Points *cp,
-		    double e1, double n1, double z1,
-		    double e2, double n2, double z2, int status)
-{
-    int i;
-    size_t size;
-
-    if (status < 0)
-	return 1;
-    i = (cp->count)++;
-    size = cp->count * sizeof(double);
-    cp->e1 = (double *)G_realloc(cp->e1, size);
-    cp->e2 = (double *)G_realloc(cp->e2, size);
-    cp->n1 = (double *)G_realloc(cp->n1, size);
-    cp->n2 = (double *)G_realloc(cp->n2, size);
-    cp->z1 = (double *)G_realloc(cp->z1, size);
-    cp->z2 = (double *)G_realloc(cp->z2, size);
-
-    size = cp->count * sizeof(int);
-    cp->status = (int *)G_realloc(cp->status, size);
-
-    cp->e1[i] = e1;
-    cp->e2[i] = e2;
-    cp->n1[i] = n1;
-    cp->n2[i] = n2;
-    cp->z1[i] = z1;
-    cp->z2[i] = z2;
-
-    cp->status[i] = status;
-
-    return 0;
-}
-
-int I_write_con_points(FILE * fd, struct Ortho_Control_Points *cp)
-{
-    int i;
-
-    fprintf(fd, "# %7s %15s %30s %15s %9s status\n", "", "photo", "",
-	    "control", "");
-    fprintf(fd, "# %15s %15s  %15s %15s %15s %15s   (1=ok)\n", "x", "y",
-	    "-cfl", "east", "north", "elev.");
-    fprintf(fd, "#\n");
-    for (i = 0; i < cp->count; i++)
-	if (cp->status[i] >= 0)
-	    fprintf(fd, "  %15f %15f %15f %15f %15f %15f %4d\n",
-		    cp->e1[i], cp->n1[i], cp->z1[i],
-		    cp->e2[i], cp->n2[i], cp->z2[i], cp->status[i]);
-
-    return 0;
-}
-
-int I_get_con_points(char *group, struct Ortho_Control_Points *cp)
-{
-    FILE *fd;
-    char msg[100];
-    int stat;
-
-    fd = I_fopen_group_file_old(group, POINT_FILE);
-    if (fd == NULL) {
-	sprintf(msg,
-		"unable to open control point (Z) file for group [%s in %s]",
-		group, G_mapset());
-	G_warning(msg);
-	G_sleep(4);
-	return 0;
-    }
-
-    stat = I_read_con_points(fd, cp);
-    fclose(fd);
-    if (stat < 0) {
-	sprintf(msg, "bad format in control point file for group [%s in %s]",
-		group, G_mapset());
-	G_warning(msg);
-	G_sleep(4);
-	return 0;
-    }
-    return 1;
-}
-
-int I_put_con_points(char *group, struct Ortho_Control_Points *cp)
-{
-    FILE *fd;
-    char msg[100];
-
-    fd = I_fopen_group_file_new(group, POINT_FILE);
-    if (fd == NULL) {
-	sprintf(msg,
-		"unable to create control point file for group [%s in %s]",
-		group, G_mapset());
-	G_warning(msg);
-	G_sleep(4);
-	return 0;
-    }
-
-    I_write_con_points(fd, cp);
-    fclose(fd);
-    return 1;
-}
-
-int I_convert_con_points(char *group, struct Ortho_Control_Points *con_cp,
-			 struct Ortho_Control_Points *photo_cp, double E12[3],
-			 double N12[3])
-{
-    FILE *fd;
-    char msg[100];
-    int i, stat, status;
-    double e1, e2, n1, n2, z1, z2, e0, n0;
-
-
-    fd = I_fopen_group_file_old(group, POINT_FILE);
-    if (fd == NULL) {
-	sprintf(msg,
-		"unable to open control point (Z) file for group [%s in %s]",
-		group, G_mapset());
-	G_warning(msg);
-	G_sleep(4);
-	return 0;
-    }
-
-    stat = I_read_con_points(fd, con_cp);
-    fclose(fd);
-    if (stat < 0) {
-	sprintf(msg, "bad format in control point file for group [%s in %s]",
-		group, G_mapset());
-	G_warning(msg);
-	G_sleep(4);
-	return 0;
-    }
-
-    /* convert to photo coordinates, given E12, N12 */
-    photo_cp->count = 0;
-    for (i = 0; i < con_cp->count; i++) {
-	status = con_cp->status[i];
-	e1 = con_cp->e1[i];
-	n1 = con_cp->n1[i];
-	z1 = con_cp->z1[i];
-	e2 = con_cp->e2[i];
-	n2 = con_cp->n2[i];
-	z2 = con_cp->z2[i];
-
-	I_georef(e1, n1, &e0, &n0, E12, N12);
-	/* I_new_con_point (photo_cp, e0,n0,z1,e2,n2,z2,status); */
-	I_new_con_point(photo_cp, e0, n0, z1, e2, n2, z2, status);
-    }
-
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/conz_points.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/conz_points.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/conz_points.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/conz_points.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,191 @@
+#include <unistd.h>
+#include <grass/imagery.h>
+#include "orthophoto.h"
+#include <grass/gis.h>
+
+#define POINT_FILE "CONTROL_POINTS"
+
+/* read the control points from group file "Con_POINTS" into */
+/* the struct Con_Points */
+int I_read_con_points(FILE * fd, struct Ortho_Control_Points *cp)
+{
+    char buf[300];
+    double e1, e2, n1, n2, z1, z2;
+    int status;
+
+    cp->count = 0;
+
+    /* read the control point lines. format is (on one line):
+       photo_x        photo_y         -CFL 
+       control_east control_north  control_elev  status(1=ok)
+     */
+    cp->e1 = NULL;
+    cp->e2 = NULL;
+    cp->n1 = NULL;
+    cp->n2 = NULL;
+    cp->z1 = NULL;
+    cp->z2 = NULL;
+
+    cp->status = NULL;
+
+    while (G_getl(buf, sizeof(buf), fd)) {
+	G_strip(buf);
+	if (*buf == '#' || *buf == 0)
+	    continue;
+	if (sscanf(buf, "%lf%lf%lf%lf%lf%lf%d",
+		   &e1, &n1, &z1, &e2, &n2, &z2, &status) == 7)
+	    I_new_con_point(cp, e1, n1, z1, e2, n2, z2, status);
+	else
+	    return -4;
+    }
+
+    return 1;
+}
+
+int I_new_con_point(struct Ortho_Control_Points *cp,
+		    double e1, double n1, double z1,
+		    double e2, double n2, double z2, int status)
+{
+    int i;
+    size_t size;
+
+    if (status < 0)
+	return 1;
+    i = (cp->count)++;
+    size = cp->count * sizeof(double);
+    cp->e1 = (double *)G_realloc(cp->e1, size);
+    cp->e2 = (double *)G_realloc(cp->e2, size);
+    cp->n1 = (double *)G_realloc(cp->n1, size);
+    cp->n2 = (double *)G_realloc(cp->n2, size);
+    cp->z1 = (double *)G_realloc(cp->z1, size);
+    cp->z2 = (double *)G_realloc(cp->z2, size);
+
+    size = cp->count * sizeof(int);
+    cp->status = (int *)G_realloc(cp->status, size);
+
+    cp->e1[i] = e1;
+    cp->e2[i] = e2;
+    cp->n1[i] = n1;
+    cp->n2[i] = n2;
+    cp->z1[i] = z1;
+    cp->z2[i] = z2;
+
+    cp->status[i] = status;
+
+    return 0;
+}
+
+int I_write_con_points(FILE * fd, struct Ortho_Control_Points *cp)
+{
+    int i;
+
+    fprintf(fd, "# %7s %15s %30s %15s %9s status\n", "", "photo", "",
+	    "control", "");
+    fprintf(fd, "# %15s %15s  %15s %15s %15s %15s   (1=ok)\n", "x", "y",
+	    "-cfl", "east", "north", "elev.");
+    fprintf(fd, "#\n");
+    for (i = 0; i < cp->count; i++)
+	if (cp->status[i] >= 0)
+	    fprintf(fd, "  %15f %15f %15f %15f %15f %15f %4d\n",
+		    cp->e1[i], cp->n1[i], cp->z1[i],
+		    cp->e2[i], cp->n2[i], cp->z2[i], cp->status[i]);
+
+    return 0;
+}
+
+int I_get_con_points(char *group, struct Ortho_Control_Points *cp)
+{
+    FILE *fd;
+    char msg[100];
+    int stat;
+
+    fd = I_fopen_group_file_old(group, POINT_FILE);
+    if (fd == NULL) {
+	sprintf(msg,
+		"unable to open control point (Z) file for group [%s in %s]",
+		group, G_mapset());
+	G_warning(msg);
+	G_sleep(4);
+	return 0;
+    }
+
+    stat = I_read_con_points(fd, cp);
+    fclose(fd);
+    if (stat < 0) {
+	sprintf(msg, "bad format in control point file for group [%s in %s]",
+		group, G_mapset());
+	G_warning(msg);
+	G_sleep(4);
+	return 0;
+    }
+    return 1;
+}
+
+int I_put_con_points(char *group, struct Ortho_Control_Points *cp)
+{
+    FILE *fd;
+    char msg[100];
+
+    fd = I_fopen_group_file_new(group, POINT_FILE);
+    if (fd == NULL) {
+	sprintf(msg,
+		"unable to create control point file for group [%s in %s]",
+		group, G_mapset());
+	G_warning(msg);
+	G_sleep(4);
+	return 0;
+    }
+
+    I_write_con_points(fd, cp);
+    fclose(fd);
+    return 1;
+}
+
+int I_convert_con_points(char *group, struct Ortho_Control_Points *con_cp,
+			 struct Ortho_Control_Points *photo_cp, double E12[3],
+			 double N12[3])
+{
+    FILE *fd;
+    char msg[100];
+    int i, stat, status;
+    double e1, e2, n1, n2, z1, z2, e0, n0;
+
+
+    fd = I_fopen_group_file_old(group, POINT_FILE);
+    if (fd == NULL) {
+	sprintf(msg,
+		"unable to open control point (Z) file for group [%s in %s]",
+		group, G_mapset());
+	G_warning(msg);
+	G_sleep(4);
+	return 0;
+    }
+
+    stat = I_read_con_points(fd, con_cp);
+    fclose(fd);
+    if (stat < 0) {
+	sprintf(msg, "bad format in control point file for group [%s in %s]",
+		group, G_mapset());
+	G_warning(msg);
+	G_sleep(4);
+	return 0;
+    }
+
+    /* convert to photo coordinates, given E12, N12 */
+    photo_cp->count = 0;
+    for (i = 0; i < con_cp->count; i++) {
+	status = con_cp->status[i];
+	e1 = con_cp->e1[i];
+	n1 = con_cp->n1[i];
+	z1 = con_cp->z1[i];
+	e2 = con_cp->e2[i];
+	n2 = con_cp->n2[i];
+	z2 = con_cp->z2[i];
+
+	I_georef(e1, n1, &e0, &n0, E12, N12);
+	/* I_new_con_point (photo_cp, e0,n0,z1,e2,n2,z2,status); */
+	I_new_con_point(photo_cp, e0, n0, z1, e2, n2, z2, status);
+    }
+
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/elev.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/elev.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/elev.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,77 +0,0 @@
-
-/**********************************************************
-* I_get_group_elev (group, elev_layer, mapset_elev, tl, math_exp, units, nd);
-* I_put_group_elev (group, elev_layer, mapset_elev, tl, math_exp, units, nd);
-**********************************************************/
-#include <stdio.h>
-#include <unistd.h>
-#include "orthophoto.h"
-#include <grass/ortholib.h>
-#include <grass/gis.h>
-
-#define IN_BUF 200
-
-
-/* Put the "elev" name into the block file "ELEV" */
-int
-I_put_group_elev(char *group, char *elev, char *mapset_elev, char *tl,
-		 char *math_exp, char *units, char *nd)
-{
-    FILE *fd;
-
-    /*    G_suppress_warnings(1); */
-    fd = (FILE *) I_fopen_group_elev_new(group);
-    /*    G_suppress_warnings(0); */
-    if (fd == NULL)
-	return 0;
-
-    fprintf(fd, "elevation layer :%s\n", elev);
-    fprintf(fd, "mapset elevation:%s\n", mapset_elev);
-    fprintf(fd, "location        :%s\n", tl);
-    fprintf(fd, "math expresion  :%s\n", math_exp);
-    fprintf(fd, "units           :%s\n", units);
-    fprintf(fd, "no data values  :%s\n", nd);
-
-    return 0;
-}
-
-
-/* Return the elev name from the block file ELEV */
-int
-I_get_group_elev(char *group, char *elev, char *mapset_elev, char *tl,
-		 char *math_exp, char *units, char *nd)
-{
-    char buf[IN_BUF];
-    FILE *fd;
-
-    if (!I_find_group_elev_file(group))
-	return 0;
-
-    G_suppress_warnings(1);
-    fd = I_fopen_group_elev_old(group);
-    G_suppress_warnings(0);
-    if (!fd) {
-	G_warning
-	    ("unable to open elevation file for group [%s] in mapset [%s]",
-	     group, G_mapset());
-	G_sleep(3);
-
-	return 0;
-    }
-
-    fgets(buf, IN_BUF, fd);
-    sscanf(buf, "elevation layer :%s\n", elev);
-    fgets(buf, IN_BUF, fd);
-    sscanf(buf, "mapset elevation:%s\n", mapset_elev);
-    fgets(buf, IN_BUF, fd);
-    sscanf(buf, "location        :%s\n", tl);
-    fgets(buf, IN_BUF, fd);
-    sscanf(buf, "math expresion  :%s\n", math_exp);
-    fgets(buf, IN_BUF, fd);
-    sscanf(buf, "units           :%s\n", units);
-    fgets(buf, IN_BUF, fd);
-    sscanf(buf, "no data values  :%s\n", nd);
-    fclose(fd);
-
-    return (1);
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/elev.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/elev.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/elev.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/elev.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,77 @@
+
+/**********************************************************
+* I_get_group_elev (group, elev_layer, mapset_elev, tl, math_exp, units, nd);
+* I_put_group_elev (group, elev_layer, mapset_elev, tl, math_exp, units, nd);
+**********************************************************/
+#include <stdio.h>
+#include <unistd.h>
+#include "orthophoto.h"
+#include <grass/ortholib.h>
+#include <grass/gis.h>
+
+#define IN_BUF 200
+
+
+/* Put the "elev" name into the block file "ELEV" */
+int
+I_put_group_elev(char *group, char *elev, char *mapset_elev, char *tl,
+		 char *math_exp, char *units, char *nd)
+{
+    FILE *fd;
+
+    /*    G_suppress_warnings(1); */
+    fd = (FILE *) I_fopen_group_elev_new(group);
+    /*    G_suppress_warnings(0); */
+    if (fd == NULL)
+	return 0;
+
+    fprintf(fd, "elevation layer :%s\n", elev);
+    fprintf(fd, "mapset elevation:%s\n", mapset_elev);
+    fprintf(fd, "location        :%s\n", tl);
+    fprintf(fd, "math expresion  :%s\n", math_exp);
+    fprintf(fd, "units           :%s\n", units);
+    fprintf(fd, "no data values  :%s\n", nd);
+
+    return 0;
+}
+
+
+/* Return the elev name from the block file ELEV */
+int
+I_get_group_elev(char *group, char *elev, char *mapset_elev, char *tl,
+		 char *math_exp, char *units, char *nd)
+{
+    char buf[IN_BUF];
+    FILE *fd;
+
+    if (!I_find_group_elev_file(group))
+	return 0;
+
+    G_suppress_warnings(1);
+    fd = I_fopen_group_elev_old(group);
+    G_suppress_warnings(0);
+    if (!fd) {
+	G_warning
+	    ("unable to open elevation file for group [%s] in mapset [%s]",
+	     group, G_mapset());
+	G_sleep(3);
+
+	return 0;
+    }
+
+    fgets(buf, IN_BUF, fd);
+    sscanf(buf, "elevation layer :%s\n", elev);
+    fgets(buf, IN_BUF, fd);
+    sscanf(buf, "mapset elevation:%s\n", mapset_elev);
+    fgets(buf, IN_BUF, fd);
+    sscanf(buf, "location        :%s\n", tl);
+    fgets(buf, IN_BUF, fd);
+    sscanf(buf, "math expresion  :%s\n", math_exp);
+    fgets(buf, IN_BUF, fd);
+    sscanf(buf, "units           :%s\n", units);
+    fgets(buf, IN_BUF, fd);
+    sscanf(buf, "no data values  :%s\n", nd);
+    fclose(fd);
+
+    return (1);
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/error.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/error.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/error.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,14 +0,0 @@
-#include <stdio.h>
-
-/*
- * error: print error message and return 0
- */
-
-FILE *Bugs2;
-
-int error(char *s)
-{
-    fprintf(stderr, "%s library error routine!", s);
-    fclose(Bugs2);
-    return 0;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/error.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/error.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/error.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/error.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+/*
+ * error: print error message and return 0
+ */
+
+FILE *Bugs2;
+
+int error(char *s)
+{
+    fprintf(stderr, "%s library error routine!", s);
+    fclose(Bugs2);
+    return 0;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/find_camera.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/find_camera.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/find_camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,29 +0,0 @@
-
-/**************************************************************
-* I_find_camera (camera)
-*
-* Look for the named camera reference file in the current mapset
-**************************************************************/
-#include <grass/gis.h>
-
-int I_find_camera(char *camera)
-{
-    if (camera == NULL || *camera == 0)
-	return 0;
-
-    return G_find_file("camera", camera, G_mapset()) != NULL;
-}
-
-int I_find_camera_file(char *camera, char *file)
-{
-    char element[100];
-
-    if (camera == NULL || *camera == 0)
-	return 0;
-    if (file == NULL || *file == 0)
-	return 0;
-
-    sprintf(element, "camera");
-
-    return G_find_file(element, camera, G_mapset()) != NULL;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/find_camera.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/find_camera.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/find_camera.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/find_camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,29 @@
+
+/**************************************************************
+* I_find_camera (camera)
+*
+* Look for the named camera reference file in the current mapset
+**************************************************************/
+#include <grass/gis.h>
+
+int I_find_camera(char *camera)
+{
+    if (camera == NULL || *camera == 0)
+	return 0;
+
+    return G_find_file("camera", camera, G_mapset()) != NULL;
+}
+
+int I_find_camera_file(char *camera, char *file)
+{
+    char element[100];
+
+    if (camera == NULL || *camera == 0)
+	return 0;
+    if (file == NULL || *file == 0)
+	return 0;
+
+    sprintf(element, "camera");
+
+    return G_find_file(element, camera, G_mapset()) != NULL;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/find_init.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/find_init.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/find_init.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,18 +0,0 @@
-
-/**************************************************************
-* I_find_init (group)
-*
-* Find the a camera initial file in the current group (if it exists)
-**************************************************************/
-#include <grass/gis.h>
-
-int I_find_initial(char *group)
-{
-    char *element;
-    element = (char *)G_malloc(80 * sizeof(char));
-
-    if (group == NULL || *group == 0)
-	return 0;
-    sprintf(element, "group/%s", group);
-    return G_find_file(element, "INIT_EXP", G_mapset()) != NULL;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/find_init.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/find_init.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/find_init.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/find_init.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,18 @@
+
+/**************************************************************
+* I_find_init (group)
+*
+* Find the a camera initial file in the current group (if it exists)
+**************************************************************/
+#include <grass/gis.h>
+
+int I_find_initial(char *group)
+{
+    char *element;
+    element = (char *)G_malloc(80 * sizeof(char));
+
+    if (group == NULL || *group == 0)
+	return 0;
+    sprintf(element, "group/%s", group);
+    return G_find_file(element, "INIT_EXP", G_mapset()) != NULL;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/fopen_camera.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/fopen_camera.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/fopen_camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,64 +0,0 @@
-#include <grass/gis.h>
-
-/******************************************************
-* I_fopen_cam_file_new()
-* I_fopen_cam_file_append()
-* I_fopen_cam_file_old()
-*
-* fopen new camera files in the current mapset
-* fopen old camera files anywhere
-*******************************************************/
-static int error(char *, char *, char *);
-
-FILE *I_fopen_cam_file_new(char *camera)
-{
-    FILE *fd;
-    char element[100];
-
-    /* get group element name */
-    sprintf(element, "camera");
-
-    fd = G_fopen_new(element, camera);
-    if (!fd)
-	error(camera, "can't create ", "");
-    return fd;
-}
-
-FILE *I_fopen_cam_file_append(char *camera)
-{
-    FILE *fd;
-    char element[100];
-
-    /* get group element name */
-    sprintf(element, "camera/%s", camera);
-
-    fd = G_fopen_append(element, camera);
-    if (!fd)
-	error(camera, "unable to open ", "");
-    return fd;
-}
-
-FILE *I_fopen_cam_file_old(char *camera)
-{
-    FILE *fd;
-    char element[100];
-
-    /* get group element name */
-    sprintf(element, "camera");
-
-    fd = G_fopen_old(element, camera, G_mapset());
-    if (!fd)
-	error(camera, "can't open ", "");
-    return fd;
-}
-
-static int error(char *camera, char *msga, char *msgb)
-{
-    char buf[100];
-
-    sprintf(buf, "%s camera file [%s] in [%s %s] %s",
-	    msga, camera, G_location(), G_mapset(), msgb);
-    G_warning(buf);
-
-    return 0;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/fopen_camera.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/fopen_camera.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/fopen_camera.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/fopen_camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,64 @@
+#include <grass/gis.h>
+
+/******************************************************
+* I_fopen_cam_file_new()
+* I_fopen_cam_file_append()
+* I_fopen_cam_file_old()
+*
+* fopen new camera files in the current mapset
+* fopen old camera files anywhere
+*******************************************************/
+static int error(char *, char *, char *);
+
+FILE *I_fopen_cam_file_new(char *camera)
+{
+    FILE *fd;
+    char element[100];
+
+    /* get group element name */
+    sprintf(element, "camera");
+
+    fd = G_fopen_new(element, camera);
+    if (!fd)
+	error(camera, "can't create ", "");
+    return fd;
+}
+
+FILE *I_fopen_cam_file_append(char *camera)
+{
+    FILE *fd;
+    char element[100];
+
+    /* get group element name */
+    sprintf(element, "camera/%s", camera);
+
+    fd = G_fopen_append(element, camera);
+    if (!fd)
+	error(camera, "unable to open ", "");
+    return fd;
+}
+
+FILE *I_fopen_cam_file_old(char *camera)
+{
+    FILE *fd;
+    char element[100];
+
+    /* get group element name */
+    sprintf(element, "camera");
+
+    fd = G_fopen_old(element, camera, G_mapset());
+    if (!fd)
+	error(camera, "can't open ", "");
+    return fd;
+}
+
+static int error(char *camera, char *msga, char *msgb)
+{
+    char buf[100];
+
+    sprintf(buf, "%s camera file [%s] in [%s %s] %s",
+	    msga, camera, G_location(), G_mapset(), msgb);
+    G_warning(buf);
+
+    return 0;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/funcdefs.h
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/funcdefs.h	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/funcdefs.h	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,53 +0,0 @@
-/* funcdefs.h */
-
-/*
- * Important:  New function names should have at least 2 lower case letters.
- */
-
-int colappend(), m_extract(), m_replace(), csum(), diag();
-int identity(), inverse(), issymmetric(), leontief();
-int m_abs(), m_exp(), m_putf(), m_read(), m_log(), m_log10(), m_int();
-int m_put(), m_recip(), m_sqrt(), modify(), psa(), rowappend();
-int rsum(), quit(), unity();
-int m_emult();
-
-double determinant(), element(), m_max(), m_min(), norm(), trace();
-
-static struct			/* functions returning doubles */
-{
-    char *name;
-    double (*func) ();
-} d_funcs[] = {
-"det", determinant,
-	"el", element,
-	"max", m_max, "min", m_min, "norm", norm, "tr", trace, "\0", 0};
-
-static struct			/* functions returning ints */
-{
-    char *name;
-    int (*func) ();
-} m_funcs[] = {
-"abs", m_abs,
-	"ac", colappend,
-	"ar", rowappend,
-	"csum", csum,
-	"diag", diag,
-	"em", m_emult,
-	"exp", m_exp,
-	"id", identity,
-	"int", m_int,
-	"inv", inverse,
-	"isym", issymmetric,
-	"linv", leontief,
-	"log", m_log,
-	"log10", m_log10,
-	"mod", modify,
-	"psa", psa,
-	"put", m_put,
-	"putf", m_putf,
-	"quit", quit,
-	"read", m_read,
-	"recip", m_recip,
-	"rsum", rsum,
-	"sqrt", m_sqrt,
-	"uv", unity, "xm", m_extract, "rm", m_replace, "\0", 0};

Copied: grass/trunk/imagery/i.ortho.photo/libes/funcdefs.h (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/funcdefs.h)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/funcdefs.h	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/funcdefs.h	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,53 @@
+/* funcdefs.h */
+
+/*
+ * Important:  New function names should have at least 2 lower case letters.
+ */
+
+int colappend(), m_extract(), m_replace(), csum(), diag();
+int identity(), inverse(), issymmetric(), leontief();
+int m_abs(), m_exp(), m_putf(), m_read(), m_log(), m_log10(), m_int();
+int m_put(), m_recip(), m_sqrt(), modify(), psa(), rowappend();
+int rsum(), quit(), unity();
+int m_emult();
+
+double determinant(), element(), m_max(), m_min(), norm(), trace();
+
+static struct			/* functions returning doubles */
+{
+    char *name;
+    double (*func) ();
+} d_funcs[] = {
+"det", determinant,
+	"el", element,
+	"max", m_max, "min", m_min, "norm", norm, "tr", trace, "\0", 0};
+
+static struct			/* functions returning ints */
+{
+    char *name;
+    int (*func) ();
+} m_funcs[] = {
+"abs", m_abs,
+	"ac", colappend,
+	"ar", rowappend,
+	"csum", csum,
+	"diag", diag,
+	"em", m_emult,
+	"exp", m_exp,
+	"id", identity,
+	"int", m_int,
+	"inv", inverse,
+	"isym", issymmetric,
+	"linv", leontief,
+	"log", m_log,
+	"log10", m_log10,
+	"mod", modify,
+	"psa", psa,
+	"put", m_put,
+	"putf", m_putf,
+	"quit", quit,
+	"read", m_read,
+	"recip", m_recip,
+	"rsum", rsum,
+	"sqrt", m_sqrt,
+	"uv", unity, "xm", m_extract, "rm", m_replace, "\0", 0};

Deleted: grass/trunk/imagery/i.ortho.photo/libes/georef.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/georef.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/georef.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,174 +0,0 @@
-#include <stdlib.h>
-#include <signal.h>
-#include "orthophoto.h"
-
-static int floating_exception;
-static void catch(int);
-static double determinant(double, double, double, double, double,
-			  double, double, double, double);
-
-/* find coefficients A,B,C for e2 = A + B*e1 + C*n1
- * also compute the reverse equations
- *
- * return 0 if no points
- *       -1 if not solvable
- *        1 if ok
- *
- * method is least squares.
- * the least squares problem reduces to solving the following
- * system of equations for A,B,C
- *
- *   s0*A + s1*B + s2*C = x0
- *   s1*A + s3*B + s4*C = x1
- *   s2*A + s4*B + s5*C = x2
- *
- * use Cramer's rule
- *
- *     | x0 s1 s2 |      | s0 x0 s2 |      | s0 s1 x0 |
- *     | x1 s3 s4 |      | s1 x1 s4 |      | s1 s3 x1 |
- *     | x2 s4 s5 |      | s2 x2 s5 |      | s2 s4 x2 |
- * A = ------------  B = ------------  C = ------------ 
- *     | s0 s1 s2 |      | s0 s1 s2 |      | s0 s1 s2 |
- *     | s1 s3 s4 |      | s1 s3 s4 |      | s1 s3 s4 |
- *     | s2 s4 s5 |      | s2 s4 s5 |      | s2 s4 s5 |
- *
- */
-
-int
-I_compute_ref_equations(struct Ortho_Photo_Points *cp, double E12[3],
-			double N12[3], double E21[3], double N21[3])
-{
-    double s0, s1, s2, s3, s4, s5;
-    double x0, x1, x2;
-    double det;
-    void (*sigfpe) ();
-    int i;
-
-
-    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
-    for (i = 0; i < cp->count; i++) {
-	if (cp->status[i] <= 0)
-	    continue;
-	s0 += 1.0;
-	s1 += cp->e1[i];
-	s2 += cp->n1[i];
-	s3 += cp->e1[i] * cp->e1[i];
-	s4 += cp->e1[i] * cp->n1[i];
-	s5 += cp->n1[i] * cp->n1[i];
-    }
-    if (s0 < 0.5)
-	return 0;
-
-    floating_exception = 0;
-    sigfpe = signal(SIGFPE, catch);
-
-    /* eastings */
-    x0 = x1 = x2 = 0.0;
-    for (i = 0; i < cp->count; i++) {
-	if (cp->status[i] <= 0)
-	    continue;
-	x0 += cp->e2[i];
-	x1 += cp->e1[i] * cp->e2[i];
-	x2 += cp->n1[i] * cp->e2[i];
-    }
-
-    det = determinant(s0, s1, s2, s1, s3, s4, s2, s4, s5);
-    if (det == 0.0) {
-	signal(SIGFPE, sigfpe);
-	return -1;
-    }
-    E12[0] = determinant(x0, s1, s2, x1, s3, s4, x2, s4, s5) / det;
-    E12[1] = determinant(s0, x0, s2, s1, x1, s4, s2, x2, s5) / det;
-    E12[2] = determinant(s0, s1, x0, s1, s3, x1, s2, s4, x2) / det;
-
-    /* northings */
-    x0 = x1 = x2 = 0.0;
-    for (i = 0; i < cp->count; i++) {
-	if (cp->status[i] <= 0)
-	    continue;
-	x0 += cp->n2[i];
-	x1 += cp->e1[i] * cp->n2[i];
-	x2 += cp->n1[i] * cp->n2[i];
-    }
-
-    det = determinant(s0, s1, s2, s1, s3, s4, s2, s4, s5);
-    if (det == 0.0) {
-	signal(SIGFPE, sigfpe);
-	return -1;
-    }
-    N12[0] = determinant(x0, s1, s2, x1, s3, s4, x2, s4, s5) / det;
-    N12[1] = determinant(s0, x0, s2, s1, x1, s4, s2, x2, s5) / det;
-    N12[2] = determinant(s0, s1, x0, s1, s3, x1, s2, s4, x2) / det;
-
-    /* the inverse equations */
-
-    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
-    for (i = 0; i < cp->count; i++) {
-	if (cp->status[i] <= 0)
-	    continue;
-	s0 += 1.0;
-	s1 += cp->e2[i];
-	s2 += cp->n2[i];
-	s3 += cp->e2[i] * cp->e2[i];
-	s4 += cp->e2[i] * cp->n2[i];
-	s5 += cp->n2[i] * cp->n2[i];
-    }
-
-    /* eastings */
-    x0 = x1 = x2 = 0.0;
-    for (i = 0; i < cp->count; i++) {
-	if (cp->status[i] <= 0)
-	    continue;
-	x0 += cp->e1[i];
-	x1 += cp->e2[i] * cp->e1[i];
-	x2 += cp->n2[i] * cp->e1[i];
-    }
-
-    det = determinant(s0, s1, s2, s1, s3, s4, s2, s4, s5);
-    if (det == 0.0) {
-	signal(SIGFPE, sigfpe);
-	return -1;
-    }
-    E21[0] = determinant(x0, s1, s2, x1, s3, s4, x2, s4, s5) / det;
-    E21[1] = determinant(s0, x0, s2, s1, x1, s4, s2, x2, s5) / det;
-    E21[2] = determinant(s0, s1, x0, s1, s3, x1, s2, s4, x2) / det;
-
-    /* northings */
-    x0 = x1 = x2 = 0.0;
-    for (i = 0; i < cp->count; i++) {
-	if (cp->status[i] <= 0)
-	    continue;
-	x0 += cp->n1[i];
-	x1 += cp->e2[i] * cp->n1[i];
-	x2 += cp->n2[i] * cp->n1[i];
-    }
-
-    det = determinant(s0, s1, s2, s1, s3, s4, s2, s4, s5);
-    if (det == 0.0) {
-	signal(SIGFPE, sigfpe);
-	return -1;
-    }
-    N21[0] = determinant(x0, s1, s2, x1, s3, s4, x2, s4, s5) / det;
-    N21[1] = determinant(s0, x0, s2, s1, x1, s4, s2, x2, s5) / det;
-    N21[2] = determinant(s0, s1, x0, s1, s3, x1, s2, s4, x2) / det;
-
-    signal(SIGFPE, sigfpe);
-    return floating_exception ? -1 : 1;
-}
-
-static double determinant(double a, double b, double c, double d,
-			  double e, double f, double g, double h, double i)
-{
-    /* compute determinant of 3x3 matrix
-     *     | a b c |
-     *     | d e f |
-     *     | g h i |
-     */
-    return a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g);
-}
-
-static void catch(int n)
-{
-    floating_exception = 1;
-    signal(n, catch);
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/georef.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/georef.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/georef.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/georef.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,174 @@
+#include <stdlib.h>
+#include <signal.h>
+#include "orthophoto.h"
+
+static int floating_exception;
+static void catch(int);
+static double determinant(double, double, double, double, double,
+			  double, double, double, double);
+
+/* find coefficients A,B,C for e2 = A + B*e1 + C*n1
+ * also compute the reverse equations
+ *
+ * return 0 if no points
+ *       -1 if not solvable
+ *        1 if ok
+ *
+ * method is least squares.
+ * the least squares problem reduces to solving the following
+ * system of equations for A,B,C
+ *
+ *   s0*A + s1*B + s2*C = x0
+ *   s1*A + s3*B + s4*C = x1
+ *   s2*A + s4*B + s5*C = x2
+ *
+ * use Cramer's rule
+ *
+ *     | x0 s1 s2 |      | s0 x0 s2 |      | s0 s1 x0 |
+ *     | x1 s3 s4 |      | s1 x1 s4 |      | s1 s3 x1 |
+ *     | x2 s4 s5 |      | s2 x2 s5 |      | s2 s4 x2 |
+ * A = ------------  B = ------------  C = ------------ 
+ *     | s0 s1 s2 |      | s0 s1 s2 |      | s0 s1 s2 |
+ *     | s1 s3 s4 |      | s1 s3 s4 |      | s1 s3 s4 |
+ *     | s2 s4 s5 |      | s2 s4 s5 |      | s2 s4 s5 |
+ *
+ */
+
+int
+I_compute_ref_equations(struct Ortho_Photo_Points *cp, double E12[3],
+			double N12[3], double E21[3], double N21[3])
+{
+    double s0, s1, s2, s3, s4, s5;
+    double x0, x1, x2;
+    double det;
+    void (*sigfpe) ();
+    int i;
+
+
+    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
+    for (i = 0; i < cp->count; i++) {
+	if (cp->status[i] <= 0)
+	    continue;
+	s0 += 1.0;
+	s1 += cp->e1[i];
+	s2 += cp->n1[i];
+	s3 += cp->e1[i] * cp->e1[i];
+	s4 += cp->e1[i] * cp->n1[i];
+	s5 += cp->n1[i] * cp->n1[i];
+    }
+    if (s0 < 0.5)
+	return 0;
+
+    floating_exception = 0;
+    sigfpe = signal(SIGFPE, catch);
+
+    /* eastings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < cp->count; i++) {
+	if (cp->status[i] <= 0)
+	    continue;
+	x0 += cp->e2[i];
+	x1 += cp->e1[i] * cp->e2[i];
+	x2 += cp->n1[i] * cp->e2[i];
+    }
+
+    det = determinant(s0, s1, s2, s1, s3, s4, s2, s4, s5);
+    if (det == 0.0) {
+	signal(SIGFPE, sigfpe);
+	return -1;
+    }
+    E12[0] = determinant(x0, s1, s2, x1, s3, s4, x2, s4, s5) / det;
+    E12[1] = determinant(s0, x0, s2, s1, x1, s4, s2, x2, s5) / det;
+    E12[2] = determinant(s0, s1, x0, s1, s3, x1, s2, s4, x2) / det;
+
+    /* northings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < cp->count; i++) {
+	if (cp->status[i] <= 0)
+	    continue;
+	x0 += cp->n2[i];
+	x1 += cp->e1[i] * cp->n2[i];
+	x2 += cp->n1[i] * cp->n2[i];
+    }
+
+    det = determinant(s0, s1, s2, s1, s3, s4, s2, s4, s5);
+    if (det == 0.0) {
+	signal(SIGFPE, sigfpe);
+	return -1;
+    }
+    N12[0] = determinant(x0, s1, s2, x1, s3, s4, x2, s4, s5) / det;
+    N12[1] = determinant(s0, x0, s2, s1, x1, s4, s2, x2, s5) / det;
+    N12[2] = determinant(s0, s1, x0, s1, s3, x1, s2, s4, x2) / det;
+
+    /* the inverse equations */
+
+    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
+    for (i = 0; i < cp->count; i++) {
+	if (cp->status[i] <= 0)
+	    continue;
+	s0 += 1.0;
+	s1 += cp->e2[i];
+	s2 += cp->n2[i];
+	s3 += cp->e2[i] * cp->e2[i];
+	s4 += cp->e2[i] * cp->n2[i];
+	s5 += cp->n2[i] * cp->n2[i];
+    }
+
+    /* eastings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < cp->count; i++) {
+	if (cp->status[i] <= 0)
+	    continue;
+	x0 += cp->e1[i];
+	x1 += cp->e2[i] * cp->e1[i];
+	x2 += cp->n2[i] * cp->e1[i];
+    }
+
+    det = determinant(s0, s1, s2, s1, s3, s4, s2, s4, s5);
+    if (det == 0.0) {
+	signal(SIGFPE, sigfpe);
+	return -1;
+    }
+    E21[0] = determinant(x0, s1, s2, x1, s3, s4, x2, s4, s5) / det;
+    E21[1] = determinant(s0, x0, s2, s1, x1, s4, s2, x2, s5) / det;
+    E21[2] = determinant(s0, s1, x0, s1, s3, x1, s2, s4, x2) / det;
+
+    /* northings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < cp->count; i++) {
+	if (cp->status[i] <= 0)
+	    continue;
+	x0 += cp->n1[i];
+	x1 += cp->e2[i] * cp->n1[i];
+	x2 += cp->n2[i] * cp->n1[i];
+    }
+
+    det = determinant(s0, s1, s2, s1, s3, s4, s2, s4, s5);
+    if (det == 0.0) {
+	signal(SIGFPE, sigfpe);
+	return -1;
+    }
+    N21[0] = determinant(x0, s1, s2, x1, s3, s4, x2, s4, s5) / det;
+    N21[1] = determinant(s0, x0, s2, s1, x1, s4, s2, x2, s5) / det;
+    N21[2] = determinant(s0, s1, x0, s1, s3, x1, s2, s4, x2) / det;
+
+    signal(SIGFPE, sigfpe);
+    return floating_exception ? -1 : 1;
+}
+
+static double determinant(double a, double b, double c, double d,
+			  double e, double f, double g, double h, double i)
+{
+    /* compute determinant of 3x3 matrix
+     *     | a b c |
+     *     | d e f |
+     *     | g h i |
+     */
+    return a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g);
+}
+
+static void catch(int n)
+{
+    floating_exception = 1;
+    signal(n, catch);
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/group_elev.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/group_elev.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/group_elev.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,25 +0,0 @@
-
-/***********************************************************
-* I_fopen_group_elev_new (group)
-* I_fopen_group_elev_old (group)
-*
-* fopen() the imagery group elev reference file "ELEVATION"
-* (containing the name of the elev associated with the block)
-**********************************************************/
-#include <grass/imagery.h>
-#include "orthophoto.h"
-
-FILE *I_fopen_group_elev_new(char *group)
-{
-    return ((FILE *) I_fopen_group_file_new(group, "ELEVATION"));
-}
-
-FILE *I_fopen_group_elev_old(char *group)
-{
-    return ((FILE *) I_fopen_group_file_old(group, "ELEVATION"));
-}
-
-int I_find_group_elev_file(char *group)
-{
-    return I_find_group_file(group, "ELEVATION");
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/group_elev.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/group_elev.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/group_elev.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/group_elev.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,25 @@
+
+/***********************************************************
+* I_fopen_group_elev_new (group)
+* I_fopen_group_elev_old (group)
+*
+* fopen() the imagery group elev reference file "ELEVATION"
+* (containing the name of the elev associated with the block)
+**********************************************************/
+#include <grass/imagery.h>
+#include "orthophoto.h"
+
+FILE *I_fopen_group_elev_new(char *group)
+{
+    return ((FILE *) I_fopen_group_file_new(group, "ELEVATION"));
+}
+
+FILE *I_fopen_group_elev_old(char *group)
+{
+    return ((FILE *) I_fopen_group_file_old(group, "ELEVATION"));
+}
+
+int I_find_group_elev_file(char *group)
+{
+    return I_find_group_file(group, "ELEVATION");
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/init.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/init.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/init.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,20 +0,0 @@
-
-/***********************************************************
-* I_fopen_group_init_new (group)
-* I_fopen_group_init_old (group)
-*
-* fopen() the imagery group reference file (containing the number
-* of files and the names of the raster maps which comprise
-* the group)
-**********************************************************/
-#include <grass/imagery.h>
-
-FILE *I_fopen_group_init_new(char *group)
-{
-    return I_fopen_group_file_new(group, "INIT_EXP");
-}
-
-FILE *I_fopen_group_init_old(char *group)
-{
-    return I_fopen_group_file_old(group, "INIT_EXP");
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/init.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/init.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/init.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/init.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,20 @@
+
+/***********************************************************
+* I_fopen_group_init_new (group)
+* I_fopen_group_init_old (group)
+*
+* fopen() the imagery group reference file (containing the number
+* of files and the names of the raster maps which comprise
+* the group)
+**********************************************************/
+#include <grass/imagery.h>
+
+FILE *I_fopen_group_init_new(char *group)
+{
+    return I_fopen_group_file_new(group, "INIT_EXP");
+}
+
+FILE *I_fopen_group_init_old(char *group)
+{
+    return I_fopen_group_file_old(group, "INIT_EXP");
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/init_info.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/init_info.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/init_info.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,135 +0,0 @@
-/* init_info.c */
-
-#include "orthophoto.h"
-
-
-FILE *I_fopen_group_init_old();
-FILE *I_fopen_group_init_new();
-
-#define INITIAL_FILE "INIT_EXP"
-
-int I_read_init_info(FILE * fd, struct Ortho_Camera_Exp_Init *init_info)
-{
-    char buf[100];
-    double XC, YC, ZC, omega, phi, kappa;
-    double XCv, YCv, ZCv, omegav, phiv, kappav;
-    int status;
-
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "INITIAL XC %lf \n", &XC) == 1)
-	init_info->XC_init = XC;
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "INITIAL YC %lf \n", &YC) == 1)
-	init_info->YC_init = YC;
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "INITIAL ZC %lf \n", &ZC) == 1)
-	init_info->ZC_init = ZC;
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "INITIAL OMEGA %lf \n", &omega) == 1)
-	init_info->omega_init = omega;
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "INITIAL PHI %lf \n", &phi) == 1)
-	init_info->phi_init = phi;
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "INITIAL KAPPA %lf \n", &kappa) == 1)
-	init_info->kappa_init = kappa;
-
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "VARIANCE XC %lf \n", &XCv) == 1)
-	init_info->XC_var = XCv;
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "VARIANCE YC %lf \n", &YCv) == 1)
-	init_info->YC_var = YCv;
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "VARIANCE ZC %lf \n", &ZCv) == 1)
-	init_info->ZC_var = ZCv;
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "VARIANCE OMEGA %lf \n", &omegav) == 1)
-	init_info->omega_var = omegav;
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "VARIANCE PHI %lf \n", &phiv) == 1)
-	init_info->phi_var = phiv;
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "VARIANCE KAPPA %lf \n", &kappav) == 1)
-	init_info->kappa_var = kappav;
-    G_getl(buf, sizeof buf, fd);
-    G_strip(buf);
-    if (sscanf(buf, "STATUS (1=OK, 0=NOT OK) %d \n", &status) == 1)
-	init_info->status = status;
-    return 1;
-}
-
-int I_write_init_info(FILE * fd, struct Ortho_Camera_Exp_Init *init_info)
-{
-    fprintf(fd, "INITIAL XC    %f \n", init_info->XC_init);
-    fprintf(fd, "INITIAL YC    %f \n", init_info->YC_init);
-    fprintf(fd, "INITIAL ZC    %f \n", init_info->ZC_init);
-    fprintf(fd, "INITIAL OMEGA %f \n", init_info->omega_init);
-    fprintf(fd, "INITIAL PHI   %f \n", init_info->phi_init);
-    fprintf(fd, "INITIAL KAPPA %f \n", init_info->kappa_init);
-
-    fprintf(fd, "VARIANCE XC    %f \n", init_info->XC_var);
-    fprintf(fd, "VARIANCE YC    %f \n", init_info->YC_var);
-    fprintf(fd, "VARIANCE ZC    %f \n", init_info->ZC_var);
-    fprintf(fd, "VARIANCE OMEGA %f \n", init_info->omega_var);
-    fprintf(fd, "VARIANCE PHI   %f \n", init_info->phi_var);
-    fprintf(fd, "VARIANCE KAPPA %f \n", init_info->kappa_var);
-    fprintf(fd, "STATUS (1=OK, 0=NOT OK) %d \n", init_info->status);
-
-    return 0;
-}
-
-int I_get_init_info(char *group, struct Ortho_Camera_Exp_Init *init_info)
-{
-    FILE *fd;
-    char msg[100];
-    int stat;
-
-    fd = I_fopen_group_init_old(group);
-    if (fd == NULL) {
-	sprintf(msg, "unable to open camera initial file %s in %s",
-		group, G_mapset());
-	G_warning(msg);
-	return 0;
-    }
-
-    stat = I_read_init_info(fd, init_info);
-    fclose(fd);
-    if (stat < 0) {
-	sprintf(msg, "bad format in camera initial file %s in %s",
-		group, G_mapset());
-	G_warning(msg);
-	return 0;
-    }
-    return 1;
-}
-
-int I_put_init_info(char *group, struct Ortho_Camera_Exp_Init *init_info)
-{
-    FILE *fd;
-    char msg[100];
-
-    fd = I_fopen_group_init_new(group);
-    if (fd == NULL) {
-	sprintf(msg, "unable to open camera initial file %s in %s",
-		group, G_mapset());
-	G_warning(msg);
-	return 0;
-    }
-
-    I_write_init_info(fd, init_info);
-    fclose(fd);
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/init_info.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/init_info.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/init_info.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/init_info.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,135 @@
+/* init_info.c */
+
+#include "orthophoto.h"
+
+
+FILE *I_fopen_group_init_old();
+FILE *I_fopen_group_init_new();
+
+#define INITIAL_FILE "INIT_EXP"
+
+int I_read_init_info(FILE * fd, struct Ortho_Camera_Exp_Init *init_info)
+{
+    char buf[100];
+    double XC, YC, ZC, omega, phi, kappa;
+    double XCv, YCv, ZCv, omegav, phiv, kappav;
+    int status;
+
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "INITIAL XC %lf \n", &XC) == 1)
+	init_info->XC_init = XC;
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "INITIAL YC %lf \n", &YC) == 1)
+	init_info->YC_init = YC;
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "INITIAL ZC %lf \n", &ZC) == 1)
+	init_info->ZC_init = ZC;
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "INITIAL OMEGA %lf \n", &omega) == 1)
+	init_info->omega_init = omega;
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "INITIAL PHI %lf \n", &phi) == 1)
+	init_info->phi_init = phi;
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "INITIAL KAPPA %lf \n", &kappa) == 1)
+	init_info->kappa_init = kappa;
+
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "VARIANCE XC %lf \n", &XCv) == 1)
+	init_info->XC_var = XCv;
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "VARIANCE YC %lf \n", &YCv) == 1)
+	init_info->YC_var = YCv;
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "VARIANCE ZC %lf \n", &ZCv) == 1)
+	init_info->ZC_var = ZCv;
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "VARIANCE OMEGA %lf \n", &omegav) == 1)
+	init_info->omega_var = omegav;
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "VARIANCE PHI %lf \n", &phiv) == 1)
+	init_info->phi_var = phiv;
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "VARIANCE KAPPA %lf \n", &kappav) == 1)
+	init_info->kappa_var = kappav;
+    G_getl(buf, sizeof buf, fd);
+    G_strip(buf);
+    if (sscanf(buf, "STATUS (1=OK, 0=NOT OK) %d \n", &status) == 1)
+	init_info->status = status;
+    return 1;
+}
+
+int I_write_init_info(FILE * fd, struct Ortho_Camera_Exp_Init *init_info)
+{
+    fprintf(fd, "INITIAL XC    %f \n", init_info->XC_init);
+    fprintf(fd, "INITIAL YC    %f \n", init_info->YC_init);
+    fprintf(fd, "INITIAL ZC    %f \n", init_info->ZC_init);
+    fprintf(fd, "INITIAL OMEGA %f \n", init_info->omega_init);
+    fprintf(fd, "INITIAL PHI   %f \n", init_info->phi_init);
+    fprintf(fd, "INITIAL KAPPA %f \n", init_info->kappa_init);
+
+    fprintf(fd, "VARIANCE XC    %f \n", init_info->XC_var);
+    fprintf(fd, "VARIANCE YC    %f \n", init_info->YC_var);
+    fprintf(fd, "VARIANCE ZC    %f \n", init_info->ZC_var);
+    fprintf(fd, "VARIANCE OMEGA %f \n", init_info->omega_var);
+    fprintf(fd, "VARIANCE PHI   %f \n", init_info->phi_var);
+    fprintf(fd, "VARIANCE KAPPA %f \n", init_info->kappa_var);
+    fprintf(fd, "STATUS (1=OK, 0=NOT OK) %d \n", init_info->status);
+
+    return 0;
+}
+
+int I_get_init_info(char *group, struct Ortho_Camera_Exp_Init *init_info)
+{
+    FILE *fd;
+    char msg[100];
+    int stat;
+
+    fd = I_fopen_group_init_old(group);
+    if (fd == NULL) {
+	sprintf(msg, "unable to open camera initial file %s in %s",
+		group, G_mapset());
+	G_warning(msg);
+	return 0;
+    }
+
+    stat = I_read_init_info(fd, init_info);
+    fclose(fd);
+    if (stat < 0) {
+	sprintf(msg, "bad format in camera initial file %s in %s",
+		group, G_mapset());
+	G_warning(msg);
+	return 0;
+    }
+    return 1;
+}
+
+int I_put_init_info(char *group, struct Ortho_Camera_Exp_Init *init_info)
+{
+    FILE *fd;
+    char msg[100];
+
+    fd = I_fopen_group_init_new(group);
+    if (fd == NULL) {
+	sprintf(msg, "unable to open camera initial file %s in %s",
+		group, G_mapset());
+	G_warning(msg);
+	return 0;
+    }
+
+    I_write_init_info(fd, init_info);
+    fclose(fd);
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/isnull.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/isnull.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/isnull.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,28 +0,0 @@
-#include <math.h>
-#include <grass/imagery.h>
-#include "mat.h"
-#include "local_proto.h"
-
-#define ZERO 1.0e-8
-
-/*
- * isnull: returns 1 if matrix is null, else 0.
- */
-
-int isnull(MATRIX * a)
-{
-    register int i, j, rows, cols;
-
-    if (a->nrows == 0)
-	return error("isnull: argument not defined.\n");
-
-    rows = a->nrows;
-    cols = a->ncols;
-
-    for (i = 0; i < rows; i++)
-	for (j = 0; j < cols; j++)
-	    if ((fabs(a->x[i][j]) - ZERO) > ZERO)
-		return 0;
-
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/isnull.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/isnull.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/isnull.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/isnull.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,28 @@
+#include <math.h>
+#include <grass/imagery.h>
+#include "mat.h"
+#include "local_proto.h"
+
+#define ZERO 1.0e-8
+
+/*
+ * isnull: returns 1 if matrix is null, else 0.
+ */
+
+int isnull(MATRIX * a)
+{
+    register int i, j, rows, cols;
+
+    if (a->nrows == 0)
+	return error("isnull: argument not defined.\n");
+
+    rows = a->nrows;
+    cols = a->ncols;
+
+    for (i = 0; i < rows; i++)
+	for (j = 0; j < cols; j++)
+	    if ((fabs(a->x[i][j]) - ZERO) > ZERO)
+		return 0;
+
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/local_proto.h
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/local_proto.h	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/local_proto.h	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,5 +0,0 @@
-/* error.c */
-int error(char *);
-
-/* orthoref.c */
-int matrix_error(char *);

Copied: grass/trunk/imagery/i.ortho.photo/libes/local_proto.h (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/local_proto.h)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/local_proto.h	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/local_proto.h	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,5 @@
+/* error.c */
+int error(char *);
+
+/* orthoref.c */
+int matrix_error(char *);

Deleted: grass/trunk/imagery/i.ortho.photo/libes/ls_cameras.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/ls_cameras.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/ls_cameras.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,65 +0,0 @@
-
-/*************************************************************
-* I_list_cameras (full)
-*************************************************************/
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <grass/imagery.h>
-#include <grass/ortholib.h>
-
-static char *tempfile = NULL;
-
-int I_list_cameras(int full)
-{
-    char *element;
-    char buf[1024];
-    char title[50];
-    FILE *ls, *temp;
-    int any;
-
-    if (tempfile == NULL)
-	tempfile = G_tempfile();
-
-    element = "camera";
-    G__make_mapset_element(element);
-
-    temp = fopen(tempfile, "w");
-    if (temp == NULL)
-	G_fatal_error("can't open any temp files");
-    fprintf(temp, "Available cameras\n");
-    fprintf(temp, "---------------------------------\n");
-
-    any = 0;
-    strcpy(buf, "cd ");
-    G__file_name(buf + strlen(buf), element, "", G_mapset());
-    strcat(buf, ";ls");
-    if (!full)
-	strcat(buf, " -C");
-    if (ls = popen(buf, "r")) {
-	while (G_getl(buf, sizeof buf, ls)) {
-	    any = 1;
-	    fprintf(temp, "%s", buf);
-	    if (full) {
-		I_get_cam_title(buf, title, sizeof title);
-		if (*title)
-		    fprintf(temp, " (%s)", title);
-		fprintf(temp, "\n");
-	    }
-	    else
-		fprintf(temp, "\n");
-	}
-	pclose(ls);
-    }
-    if (!any)
-	fprintf(temp, "no camera files available\n");
-    fprintf(temp, "---------------------------------\n");
-    fclose(temp);
-    sprintf(buf, "$GRASS_PAGER %s", tempfile);
-    G_system(buf);
-    unlink(tempfile);
-    fprintf(stderr, "hit RETURN to continue -->");
-    G_gets(buf);
-
-    return 0;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/ls_cameras.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/ls_cameras.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/ls_cameras.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/ls_cameras.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,65 @@
+
+/*************************************************************
+* I_list_cameras (full)
+*************************************************************/
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <grass/imagery.h>
+#include <grass/ortholib.h>
+
+static char *tempfile = NULL;
+
+int I_list_cameras(int full)
+{
+    char *element;
+    char buf[1024];
+    char title[50];
+    FILE *ls, *temp;
+    int any;
+
+    if (tempfile == NULL)
+	tempfile = G_tempfile();
+
+    element = "camera";
+    G__make_mapset_element(element);
+
+    temp = fopen(tempfile, "w");
+    if (temp == NULL)
+	G_fatal_error("can't open any temp files");
+    fprintf(temp, "Available cameras\n");
+    fprintf(temp, "---------------------------------\n");
+
+    any = 0;
+    strcpy(buf, "cd ");
+    G__file_name(buf + strlen(buf), element, "", G_mapset());
+    strcat(buf, ";ls");
+    if (!full)
+	strcat(buf, " -C");
+    if (ls = popen(buf, "r")) {
+	while (G_getl(buf, sizeof buf, ls)) {
+	    any = 1;
+	    fprintf(temp, "%s", buf);
+	    if (full) {
+		I_get_cam_title(buf, title, sizeof title);
+		if (*title)
+		    fprintf(temp, " (%s)", title);
+		fprintf(temp, "\n");
+	    }
+	    else
+		fprintf(temp, "\n");
+	}
+	pclose(ls);
+    }
+    if (!any)
+	fprintf(temp, "no camera files available\n");
+    fprintf(temp, "---------------------------------\n");
+    fclose(temp);
+    sprintf(buf, "$GRASS_PAGER %s", tempfile);
+    G_system(buf);
+    unlink(tempfile);
+    fprintf(stderr, "hit RETURN to continue -->");
+    G_gets(buf);
+
+    return 0;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/ls_elev.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/ls_elev.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/ls_elev.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,59 +0,0 @@
-
-/*************************************************************
-* I_list_elev (full)
-*************************************************************/
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <grass/imagery.h>
-
-static char *tempfile = NULL;
-
-int I_list_elev(int full)
-{
-    char *element;
-    char buf[1024];
-    FILE *ls, *temp;
-    int any;
-
-    if (tempfile == NULL)
-	tempfile = G_tempfile();
-
-    element = "cell";
-    G__make_mapset_element(element);
-
-    temp = fopen(tempfile, "w");
-    if (temp == NULL)
-	G_fatal_error("can't open any temp files");
-    fprintf(temp, "Available raster maps:\n");
-    fprintf(temp, "---------------------------------\n");
-
-    any = 0;
-    strcpy(buf, "cd ");
-    G__file_name(buf + strlen(buf), element, " ", " ");
-    strcat(buf, ";ls");
-    strcat(buf, " -C");
-    if (ls = popen(buf, "r")) {
-	while (G_getl(buf, sizeof buf, ls)) {
-	    any = 1;
-	    fprintf(temp, "%s", buf);
-	    fprintf(temp, "\n");
-	}
-	pclose(ls);
-    }
-    if (!any)
-	fprintf(temp, "no raster maps available\n");
-    fprintf(temp, "---------------------------------\n");
-    fclose(temp);
-    sprintf(buf, "$GRASS_PAGER %s", tempfile);
-    G_system(buf);
-    unlink(tempfile);
-    fprintf(stderr, "hit RETURN to continue -->");
-    G_gets(buf);
-
-/******/
-    G_list_element("cell", "cell", G_mapset(), NULL);
-
-
-    return 0;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/ls_elev.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/ls_elev.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/ls_elev.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/ls_elev.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,59 @@
+
+/*************************************************************
+* I_list_elev (full)
+*************************************************************/
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <grass/imagery.h>
+
+static char *tempfile = NULL;
+
+int I_list_elev(int full)
+{
+    char *element;
+    char buf[1024];
+    FILE *ls, *temp;
+    int any;
+
+    if (tempfile == NULL)
+	tempfile = G_tempfile();
+
+    element = "cell";
+    G__make_mapset_element(element);
+
+    temp = fopen(tempfile, "w");
+    if (temp == NULL)
+	G_fatal_error("can't open any temp files");
+    fprintf(temp, "Available raster maps:\n");
+    fprintf(temp, "---------------------------------\n");
+
+    any = 0;
+    strcpy(buf, "cd ");
+    G__file_name(buf + strlen(buf), element, " ", " ");
+    strcat(buf, ";ls");
+    strcat(buf, " -C");
+    if (ls = popen(buf, "r")) {
+	while (G_getl(buf, sizeof buf, ls)) {
+	    any = 1;
+	    fprintf(temp, "%s", buf);
+	    fprintf(temp, "\n");
+	}
+	pclose(ls);
+    }
+    if (!any)
+	fprintf(temp, "no raster maps available\n");
+    fprintf(temp, "---------------------------------\n");
+    fclose(temp);
+    sprintf(buf, "$GRASS_PAGER %s", tempfile);
+    G_system(buf);
+    unlink(tempfile);
+    fprintf(stderr, "hit RETURN to continue -->");
+    G_gets(buf);
+
+/******/
+    G_list_element("cell", "cell", G_mapset(), NULL);
+
+
+    return 0;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/m_add.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_add.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_add.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,42 +0,0 @@
-#include <stdio.h>
-#include "mat.h"
-#include "matrixdefs.h"
-#include "local_proto.h"
-
-/*
- * m_add: matrix addition (returns c = a + b)
- */
-
-int m_add(MATRIX * a, MATRIX * b, MATRIX * c)
-{
-    register int nr, nc;
-    char message[256];
-    register double *ap, *bp, *mp;
-    static MATRIX m;
-
-    if (a->nrows == 0)
-	return error("+: arg1 not defined\n");
-    else if (b->nrows == 0)
-	return error("+: arg2 not defined\n");
-
-    /* check for conformity */
-    if ((a->nrows != b->nrows) || (a->ncols != b->ncols)) {
-	sprintf(message, "+: matrices not conformable, %d x %d + %d x %d\n",
-		a->nrows, a->ncols, b->nrows, b->ncols);
-	return error(message);
-    }
-
-    nr = a->nrows;
-    while (nr--) {
-	nc = a->ncols;
-	ap = &(a->x[nr][0]);
-	bp = &(b->x[nr][0]);
-	mp = &(m.x[nr][0]);
-	while (nc--)
-	    *mp++ = *ap++ + *bp++;
-    }
-    m.nrows = a->nrows;
-    m.ncols = a->ncols;
-    m_copy(c, &m);
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/m_add.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/m_add.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_add.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_add.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include "mat.h"
+#include "matrixdefs.h"
+#include "local_proto.h"
+
+/*
+ * m_add: matrix addition (returns c = a + b)
+ */
+
+int m_add(MATRIX * a, MATRIX * b, MATRIX * c)
+{
+    register int nr, nc;
+    char message[256];
+    register double *ap, *bp, *mp;
+    static MATRIX m;
+
+    if (a->nrows == 0)
+	return error("+: arg1 not defined\n");
+    else if (b->nrows == 0)
+	return error("+: arg2 not defined\n");
+
+    /* check for conformity */
+    if ((a->nrows != b->nrows) || (a->ncols != b->ncols)) {
+	sprintf(message, "+: matrices not conformable, %d x %d + %d x %d\n",
+		a->nrows, a->ncols, b->nrows, b->ncols);
+	return error(message);
+    }
+
+    nr = a->nrows;
+    while (nr--) {
+	nc = a->ncols;
+	ap = &(a->x[nr][0]);
+	bp = &(b->x[nr][0]);
+	mp = &(m.x[nr][0]);
+	while (nc--)
+	    *mp++ = *ap++ + *bp++;
+    }
+    m.nrows = a->nrows;
+    m.ncols = a->ncols;
+    m_copy(c, &m);
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/m_copy.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_copy.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_copy.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,28 +0,0 @@
-#include "mat.h"
-#include "local_proto.h"
-
-/*
- * m_copy: matrix equivalency (return a = b).
- */
-
-int m_copy(MATRIX * a, MATRIX * b)
-{
-    register int r, c;
-    register double *ap, *bp;
-
-    if (b->nrows == 0)
-	return error("=: arg2 not defined\n");
-
-    r = b->nrows;
-    a->nrows = b->nrows;
-    a->ncols = b->ncols;
-    while (r--) {
-	c = b->ncols;
-	ap = &(a->x[r][0]);
-	bp = &(b->x[r][0]);
-	while (c--)
-	    *ap++ = *bp++;
-    }
-
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/m_copy.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/m_copy.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_copy.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_copy.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,28 @@
+#include "mat.h"
+#include "local_proto.h"
+
+/*
+ * m_copy: matrix equivalency (return a = b).
+ */
+
+int m_copy(MATRIX * a, MATRIX * b)
+{
+    register int r, c;
+    register double *ap, *bp;
+
+    if (b->nrows == 0)
+	return error("=: arg2 not defined\n");
+
+    r = b->nrows;
+    a->nrows = b->nrows;
+    a->ncols = b->ncols;
+    while (r--) {
+	c = b->ncols;
+	ap = &(a->x[r][0]);
+	bp = &(b->x[r][0]);
+	while (c--)
+	    *ap++ = *bp++;
+    }
+
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/m_inverse.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_inverse.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_inverse.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,127 +0,0 @@
-#include <math.h>
-#include "mat.h"
-#include "matrixdefs.h"
-#include "local_proto.h"
-
-#define EPSILON 1.0e-8
-
-/*
- * inverse: invert a square martix (puts pivot elements on main diagonal).
- *          returns arg2 as the inverse of arg1.
- *
- *  This routine is based on a routine found in Andrei Rogers, "Matrix
- *  Methods in Urban and Regional Analysis", (1971), pp. 143-153.
- */
-
-int inverse(MATRIX * a, MATRIX * b)
-{
-    int i, j, k, l, ir = 0, ic = 0, nr, nc;
-    int ipivot[MAXROWS], itemp[MAXROWS][2];
-    double pivot[MAXROWS], t;
-    static MATRIX m;
-
-    if (a->nrows == 0)
-	return matrix_error("inv: arg1 not defined\n");
-
-    if (a->nrows != a->ncols)
-	return matrix_error("inv: matrix not square\n");
-
-    if (isnull(a)) {
-	/* fprintf (stderr, " inv: matrix is singular\n"); */
-	return
-	    matrix_error
-	    ("inv: matrix is singular. Check camera definitions!\n");
-    }
-    m_copy(&m, a);
-    nr = a->nrows;
-    nc = a->ncols;
-
-    /* initialization */
-    for (i = 0; i < nr; i++)
-	ipivot[i] = 0;
-
-    for (i = 0; i < nr; i++) {
-	t = 0.0;		/* search for pivot element */
-	for (j = 0; j < nr; j++) {
-	    if (ipivot[j] == 1)	/* found pivot */
-		continue;
-	    for (k = 0; k < nc; k++)
-		switch (ipivot[k] - 1) {
-		case 0:
-		    break;
-		case -1:
-		    if (fabs(t) < fabs(m.x[j][k])) {
-			ir = j;
-			ic = k;
-			t = m.x[j][k];
-		    }
-		    break;
-		case 1:
-		    return
-			matrix_error
-			("inv: matrix is singular. Check camera definitions!\n");
-		    break;
-		default:	/* shouldn't get here */
-		    return
-			matrix_error
-			("inv: matrix is singular. Check camera definitions!\n");
-		    break;
-		}
-	}
-	ipivot[ic] += 1;
-	if (ipivot[ic] > 1)	/* check for dependency */
-	    return
-		matrix_error
-		("inv: matrix is singular. Check camera definitions!\n");
-	/* interchange rows to put pivot element on diagonal */
-	if (ir != ic)
-	    for (l = 0; l < nc; l++) {
-		t = m.x[ir][l];
-		m.x[ir][l] = m.x[ic][l];
-		m.x[ic][l] = t;
-	    }
-
-	itemp[i][0] = ir;
-	itemp[i][1] = ic;
-	pivot[i] = m.x[ic][ic];
-
-	/* check for zero pivot */
-	if (fabs(pivot[i]) < EPSILON)
-	    return
-		matrix_error
-		("inv: matrix is singular. Check camera definitions!\n");
-
-	/* divide pivot row by pivot element */
-	m.x[ic][ic] = 1.0;
-	for (j = 0; j < nc; j++)
-	    m.x[ic][j] /= pivot[i];
-
-	/* reduce nonpivot rows */
-	for (k = 0; k < nr; k++)
-	    if (k != ic) {
-		t = m.x[k][ic];
-		m.x[k][ic] = 0.0;
-		for (l = 0; l < nc; l++)
-		    m.x[k][l] -= (m.x[ic][l] * t);
-	    }
-    }
-
-    /* interchange columns */
-    for (i = 0; i < nc; i++) {
-	l = nc - i - 1;
-	if (itemp[l][0] == itemp[l][1])
-	    continue;
-	ir = itemp[l][0];
-	ic = itemp[l][1];
-	for (k = 0; k < nr; k++) {
-	    t = m.x[k][ir];
-	    m.x[k][ir] = m.x[k][ic];
-	    m.x[k][ic] = t;
-	}
-    }
-
-    b->nrows = nr;
-    b->ncols = nc;
-    m_copy(b, &m);
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/m_inverse.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/m_inverse.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_inverse.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_inverse.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,127 @@
+#include <math.h>
+#include "mat.h"
+#include "matrixdefs.h"
+#include "local_proto.h"
+
+#define EPSILON 1.0e-8
+
+/*
+ * inverse: invert a square martix (puts pivot elements on main diagonal).
+ *          returns arg2 as the inverse of arg1.
+ *
+ *  This routine is based on a routine found in Andrei Rogers, "Matrix
+ *  Methods in Urban and Regional Analysis", (1971), pp. 143-153.
+ */
+
+int inverse(MATRIX * a, MATRIX * b)
+{
+    int i, j, k, l, ir = 0, ic = 0, nr, nc;
+    int ipivot[MAXROWS], itemp[MAXROWS][2];
+    double pivot[MAXROWS], t;
+    static MATRIX m;
+
+    if (a->nrows == 0)
+	return matrix_error("inv: arg1 not defined\n");
+
+    if (a->nrows != a->ncols)
+	return matrix_error("inv: matrix not square\n");
+
+    if (isnull(a)) {
+	/* fprintf (stderr, " inv: matrix is singular\n"); */
+	return
+	    matrix_error
+	    ("inv: matrix is singular. Check camera definitions!\n");
+    }
+    m_copy(&m, a);
+    nr = a->nrows;
+    nc = a->ncols;
+
+    /* initialization */
+    for (i = 0; i < nr; i++)
+	ipivot[i] = 0;
+
+    for (i = 0; i < nr; i++) {
+	t = 0.0;		/* search for pivot element */
+	for (j = 0; j < nr; j++) {
+	    if (ipivot[j] == 1)	/* found pivot */
+		continue;
+	    for (k = 0; k < nc; k++)
+		switch (ipivot[k] - 1) {
+		case 0:
+		    break;
+		case -1:
+		    if (fabs(t) < fabs(m.x[j][k])) {
+			ir = j;
+			ic = k;
+			t = m.x[j][k];
+		    }
+		    break;
+		case 1:
+		    return
+			matrix_error
+			("inv: matrix is singular. Check camera definitions!\n");
+		    break;
+		default:	/* shouldn't get here */
+		    return
+			matrix_error
+			("inv: matrix is singular. Check camera definitions!\n");
+		    break;
+		}
+	}
+	ipivot[ic] += 1;
+	if (ipivot[ic] > 1)	/* check for dependency */
+	    return
+		matrix_error
+		("inv: matrix is singular. Check camera definitions!\n");
+	/* interchange rows to put pivot element on diagonal */
+	if (ir != ic)
+	    for (l = 0; l < nc; l++) {
+		t = m.x[ir][l];
+		m.x[ir][l] = m.x[ic][l];
+		m.x[ic][l] = t;
+	    }
+
+	itemp[i][0] = ir;
+	itemp[i][1] = ic;
+	pivot[i] = m.x[ic][ic];
+
+	/* check for zero pivot */
+	if (fabs(pivot[i]) < EPSILON)
+	    return
+		matrix_error
+		("inv: matrix is singular. Check camera definitions!\n");
+
+	/* divide pivot row by pivot element */
+	m.x[ic][ic] = 1.0;
+	for (j = 0; j < nc; j++)
+	    m.x[ic][j] /= pivot[i];
+
+	/* reduce nonpivot rows */
+	for (k = 0; k < nr; k++)
+	    if (k != ic) {
+		t = m.x[k][ic];
+		m.x[k][ic] = 0.0;
+		for (l = 0; l < nc; l++)
+		    m.x[k][l] -= (m.x[ic][l] * t);
+	    }
+    }
+
+    /* interchange columns */
+    for (i = 0; i < nc; i++) {
+	l = nc - i - 1;
+	if (itemp[l][0] == itemp[l][1])
+	    continue;
+	ir = itemp[l][0];
+	ic = itemp[l][1];
+	for (k = 0; k < nr; k++) {
+	    t = m.x[k][ir];
+	    m.x[k][ir] = m.x[k][ic];
+	    m.x[k][ic] = t;
+	}
+    }
+
+    b->nrows = nr;
+    b->ncols = nc;
+    m_copy(b, &m);
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/m_mult.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_mult.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_mult.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,43 +0,0 @@
-#include <stdio.h>
-#include "mat.h"
-#include "matrixdefs.h"
-#include "local_proto.h"
-
-/*
- * m_mult: matrix multiplication (return c = a * b)
- */
-
-int m_mult(MATRIX * a, MATRIX * b, MATRIX * c)
-{
-    register int i, j, k, nr, nc, ncols;
-    char message[256];
-    static MATRIX m;
-
-    if (a->nrows == 0)
-	return error("*: arg1 not defined\n");
-    else if (b->nrows == 0)
-	return error("*: arg2 not defined\n");
-
-    /* check for conformity */
-    if (a->ncols != b->nrows) {
-	sprintf(message, "*: matrices not conformable, %d x %d * %d x %d\n",
-		a->nrows, a->ncols, b->nrows, b->ncols);
-	fprintf(stderr, message);
-	return error(message);
-    }
-
-    ncols = a->ncols;
-    nr = a->nrows;
-    nc = b->ncols;
-    for (i = 0; i < nr; i++)
-	for (j = 0; j < nc; j++) {
-	    m.x[i][j] = 0.0;
-	    for (k = 0; k < ncols; k++)
-		m.x[i][j] += (a->x[i][k] * b->x[k][j]);
-	}
-
-    m.nrows = nr;
-    m.ncols = nc;
-    m_copy(c, &m);
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/m_mult.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/m_mult.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_mult.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_mult.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include "mat.h"
+#include "matrixdefs.h"
+#include "local_proto.h"
+
+/*
+ * m_mult: matrix multiplication (return c = a * b)
+ */
+
+int m_mult(MATRIX * a, MATRIX * b, MATRIX * c)
+{
+    register int i, j, k, nr, nc, ncols;
+    char message[256];
+    static MATRIX m;
+
+    if (a->nrows == 0)
+	return error("*: arg1 not defined\n");
+    else if (b->nrows == 0)
+	return error("*: arg2 not defined\n");
+
+    /* check for conformity */
+    if (a->ncols != b->nrows) {
+	sprintf(message, "*: matrices not conformable, %d x %d * %d x %d\n",
+		a->nrows, a->ncols, b->nrows, b->ncols);
+	fprintf(stderr, message);
+	return error(message);
+    }
+
+    ncols = a->ncols;
+    nr = a->nrows;
+    nc = b->ncols;
+    for (i = 0; i < nr; i++)
+	for (j = 0; j < nc; j++) {
+	    m.x[i][j] = 0.0;
+	    for (k = 0; k < ncols; k++)
+		m.x[i][j] += (a->x[i][k] * b->x[k][j]);
+	}
+
+    m.nrows = nr;
+    m.ncols = nc;
+    m_copy(c, &m);
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/m_transpose.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_transpose.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_transpose.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,28 +0,0 @@
-#include "mat.h"
-#include "matrixdefs.h"
-#include "local_proto.h"
-
-/*
- * transpose: returns arg2 as the transpose of arg1
- */
-
-int transpose(MATRIX * a, MATRIX * b)
-{
-    register int i, j, nr, nc;
-    static MATRIX m;
-
-    if (a->nrows == 0)
-	return error("\': arg1 not defined\n");
-
-    nr = a->nrows;
-    nc = a->ncols;
-
-    for (i = 0; i < nr; i++)
-	for (j = 0; j < nc; j++)
-	    m.x[j][i] = a->x[i][j];
-
-    m.nrows = nc;
-    m.ncols = nr;
-    m_copy(b, &m);
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/m_transpose.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/m_transpose.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_transpose.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_transpose.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,28 @@
+#include "mat.h"
+#include "matrixdefs.h"
+#include "local_proto.h"
+
+/*
+ * transpose: returns arg2 as the transpose of arg1
+ */
+
+int transpose(MATRIX * a, MATRIX * b)
+{
+    register int i, j, nr, nc;
+    static MATRIX m;
+
+    if (a->nrows == 0)
+	return error("\': arg1 not defined\n");
+
+    nr = a->nrows;
+    nc = a->ncols;
+
+    for (i = 0; i < nr; i++)
+	for (j = 0; j < nc; j++)
+	    m.x[j][i] = a->x[i][j];
+
+    m.nrows = nc;
+    m.ncols = nr;
+    m_copy(b, &m);
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/m_zero.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_zero.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_zero.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,16 +0,0 @@
-#include "mat.h"
-
-/*
- * zero: returns arg2 zero filled 
- */
-
-int zero(MATRIX * a)
-{
-    register int i, j;
-
-    for (i = 0; i < a->nrows; i++)
-	for (j = 0; j < a->ncols; j++)
-	    a->x[i][j] = 0.0;
-
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/m_zero.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/m_zero.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/m_zero.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/m_zero.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,16 @@
+#include "mat.h"
+
+/*
+ * zero: returns arg2 zero filled 
+ */
+
+int zero(MATRIX * a)
+{
+    register int i, j;
+
+    for (i = 0; i < a->nrows; i++)
+	for (j = 0; j < a->ncols; j++)
+	    a->x[i][j] = 0.0;
+
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/mat.h
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/mat.h	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/mat.h	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,11 +0,0 @@
-/* mat.h */
-
-#define MAXROWS 25
-#define MAXCOLS MAXROWS
-
-typedef struct matrix
-{
-    int nrows;			/* row index */
-    int ncols;			/* col index */
-    double x[MAXROWS][MAXCOLS];
-} MATRIX;

Copied: grass/trunk/imagery/i.ortho.photo/libes/mat.h (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/mat.h)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/mat.h	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/mat.h	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,11 @@
+/* mat.h */
+
+#define MAXROWS 25
+#define MAXCOLS MAXROWS
+
+typedef struct matrix
+{
+    int nrows;			/* row index */
+    int ncols;			/* col index */
+    double x[MAXROWS][MAXCOLS];
+} MATRIX;

Deleted: grass/trunk/imagery/i.ortho.photo/libes/matrixdefs.h
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/matrixdefs.h	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/matrixdefs.h	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,24 +0,0 @@
-/* matrixdefs.h */
-
-/*
- *   Matrix defs for orthoref.c
- */
-
-/* m_add.c */
-int m_add(MATRIX *, MATRIX *, MATRIX *);
-
-/* m_copy.c */
-int m_copy(MATRIX *, MATRIX *);
-
-/* m_inverse.c */
-int inverse(MATRIX *, MATRIX *);
-int isnull(MATRIX *);
-
-/* m_mult.c */
-int m_mult(MATRIX *, MATRIX *, MATRIX *);
-
-/* m_transpose.c */
-int transpose(MATRIX *, MATRIX *);
-
-/* m_zero.c */
-int zero(MATRIX *);

Copied: grass/trunk/imagery/i.ortho.photo/libes/matrixdefs.h (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/matrixdefs.h)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/matrixdefs.h	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/matrixdefs.h	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,24 @@
+/* matrixdefs.h */
+
+/*
+ *   Matrix defs for orthoref.c
+ */
+
+/* m_add.c */
+int m_add(MATRIX *, MATRIX *, MATRIX *);
+
+/* m_copy.c */
+int m_copy(MATRIX *, MATRIX *);
+
+/* m_inverse.c */
+int inverse(MATRIX *, MATRIX *);
+int isnull(MATRIX *);
+
+/* m_mult.c */
+int m_mult(MATRIX *, MATRIX *, MATRIX *);
+
+/* m_transpose.c */
+int transpose(MATRIX *, MATRIX *);
+
+/* m_zero.c */
+int zero(MATRIX *);

Deleted: grass/trunk/imagery/i.ortho.photo/libes/open_camera.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/open_camera.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/open_camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,56 +0,0 @@
-#include <grass/imagery.h>
-#include <grass/ortholib.h>
-#include <grass/gis.h>
-
-/******************************************************
-* I_open_cam_file_new()
-* I_open_cam_file_old()
-*
-* open new and old imagery group files in the current mapset
-*******************************************************/
-static int camera_error(char *, char *, char *, char *);
-
-int I_open_cam_file_new(char *camera, char *file)
-{
-    int fd;
-    char element[100];
-
-    /* get group element name */
-    sprintf(element, "camera");
-
-    fd = G_open_new(element, camera);
-    if (fd < 0)
-	camera_error(camera, file, "can't create ", "");
-    return fd;
-}
-
-int I_open_cam_file_old(char *camera, char *file)
-{
-    int fd;
-    char element[100];
-
-    /* find the file first */
-    if (!I_find_camera_file(camera, file)) {
-	camera_error(camera, file, "", " not found");
-	return -1;
-    }
-
-    /* get group element name */
-    sprintf(element, "camera/%s", camera);
-
-    fd = G_open_old(element, camera, G_mapset());
-    if (fd < 0)
-	camera_error(camera, file, "can't open ", "");
-    return fd;
-}
-
-static int camera_error(char *camera, char *file, char *msga, char *msgb)
-{
-    char buf[100];
-
-    sprintf(buf, "%sfile [%s] of group [%s in %s]%s",
-	    msga, file, camera, G_mapset(), msgb);
-    G_warning(buf);
-
-    return 0;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/open_camera.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/open_camera.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/open_camera.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/open_camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,56 @@
+#include <grass/imagery.h>
+#include <grass/ortholib.h>
+#include <grass/gis.h>
+
+/******************************************************
+* I_open_cam_file_new()
+* I_open_cam_file_old()
+*
+* open new and old imagery group files in the current mapset
+*******************************************************/
+static int camera_error(char *, char *, char *, char *);
+
+int I_open_cam_file_new(char *camera, char *file)
+{
+    int fd;
+    char element[100];
+
+    /* get group element name */
+    sprintf(element, "camera");
+
+    fd = G_open_new(element, camera);
+    if (fd < 0)
+	camera_error(camera, file, "can't create ", "");
+    return fd;
+}
+
+int I_open_cam_file_old(char *camera, char *file)
+{
+    int fd;
+    char element[100];
+
+    /* find the file first */
+    if (!I_find_camera_file(camera, file)) {
+	camera_error(camera, file, "", " not found");
+	return -1;
+    }
+
+    /* get group element name */
+    sprintf(element, "camera/%s", camera);
+
+    fd = G_open_old(element, camera, G_mapset());
+    if (fd < 0)
+	camera_error(camera, file, "can't open ", "");
+    return fd;
+}
+
+static int camera_error(char *camera, char *file, char *msga, char *msgb)
+{
+    char buf[100];
+
+    sprintf(buf, "%sfile [%s] of group [%s in %s]%s",
+	    msga, file, camera, G_mapset(), msgb);
+    G_warning(buf);
+
+    return 0;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/orthophoto.h
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/orthophoto.h	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/orthophoto.h	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,151 +0,0 @@
-#include <grass/gis.h>
-#include <grass/imagery.h>
-
-/* #define DEBUG  1 */
-
-#define INITIAL_X_VAR   500
-#define INITIAL_Y_VAR   500
-#define INITIAL_Z_VAR  1000
-#define INITIAL_OMEGA_VAR   0.01
-#define INITIAL_PHI_VAR     0.01
-#define INITIAL_KAPPA_VAR   0.1
-
-struct Ortho_Image_Group_Ref
-{
-    int nfiles;
-    struct Ortho_Image_Group_Ref_Files
-    {
-	char name[30];
-	char mapset[30];
-    } *file;
-    struct Ortho_Ref_Color
-    {
-	unsigned char *table;	/* color table for min-max values */
-	unsigned char *index;	/* data translation index */
-	unsigned char *buf;	/* data buffer for reading color file */
-	int fd;			/* for image i/o */
-	CELL min, max;		/* min,max CELL values */
-	int n;			/* index into Ref_Files */
-    } red, grn, blu;
-};
-
-struct Ortho_Camera_File_Ref
-{
-    char cam_name[30];
-    char cam_id[30];
-    double Xp;
-    double Yp;
-    double CFL;
-    int num_fid;
-    struct Fiducial
-    {
-	char fid_id[30];
-	double Xf;
-	double Yf;
-    } fiducials[20];
-};
-
-struct Ortho_Photo_Points
-{
-    int count;
-    double *e1;
-    double *n1;
-    double *e2;
-    double *n2;
-    double *z1;
-    double *z2;
-    int *status;
-};
-
-struct Ortho_Control_Points
-{
-    int count;
-    double *e1;
-    double *n1;
-    double *z1;
-    double *e2;
-    double *n2;
-    double *z2;
-    int *status;
-};
-
-struct Ortho_Camera_Exp_Init
-{
-    double XC_init;
-    double YC_init;
-    double ZC_init;
-    double omega_init;
-    double phi_init;
-    double kappa_init;
-    double XC_var;
-    double YC_var;
-    double ZC_var;
-    double omega_var;
-    double phi_var;
-    double kappa_var;
-    int status;
-};
-
-
-struct Ortho_Image_Group
-{
-    char name[100];
-    /* Ortho_Image_Group_Ref is identical to Ortho_Group_Ref, and
-       we assume this is so in the code.  If Ortho_Image_Group_Ref
-       is ever different, then there will have to be a new set of
-       I_get_group_ref() functions to fill it.
-       struct Ortho_Image_Group_Ref    group_ref; */
-    struct Ref group_ref;
-    struct Ortho_Camera_File_Ref camera_ref;
-    struct Ortho_Photo_Points photo_points;
-    struct Ortho_Control_Points control_points;
-    struct Ortho_Camera_Exp_Init camera_exp;
-    int ref_equation_stat;
-    int con_equation_stat;
-    double E12[3], N12[3], E21[3], N21[3], Z12[3], Z21[3];
-    double XC, YC, ZC, omega, phi, kappa;
-};
-
-/* conz_points.c */
-int I_new_con_point(struct Ortho_Control_Points *,
-		    double, double, double, double, double, double, int);
-int I_get_con_points(char *, struct Ortho_Control_Points *);
-int I_put_con_points(char *, struct Ortho_Control_Points *);
-int I_convert_con_points(char *, struct Ortho_Control_Points *,
-			 struct Ortho_Control_Points *, double[3], double[3]);
-/* georef.c */
-int I_compute_ref_equations(struct Ortho_Photo_Points *,
-			    double *, double *, double *, double *);
-/* orthoref.c */
-int I_compute_ortho_equations(struct Ortho_Control_Points *,
-			      struct Ortho_Camera_File_Ref *,
-			      struct Ortho_Camera_Exp_Init *, double *,
-			      double *, double *, double *, double *,
-			      double *);
-int I_ortho_ref(double, double, double, double *, double *, double *,
-		struct Ortho_Camera_File_Ref *, double, double, double,
-		double, double, double);
-int I_inverse_ortho_ref(double, double, double, double *, double *, double *,
-			struct Ortho_Camera_File_Ref *, double, double,
-			double, double, double, double);
-/* ref_points.c */
-int I_new_ref_point(struct Ortho_Photo_Points *, double, double, double,
-		    double, int);
-int I_get_ref_points(char *, struct Ortho_Photo_Points *);
-int I_put_ref_points(char *, struct Ortho_Photo_Points *);
-
-/* cam_info.h */
-int I_read_cam_info(FILE *, struct Ortho_Camera_File_Ref *);
-int I_new_fid_point(struct Ortho_Camera_File_Ref *, char *, double, double);
-int I_write_cam_info(FILE *, struct Ortho_Camera_File_Ref *);
-int I_get_cam_info(char *, struct Ortho_Camera_File_Ref *);
-int I_put_cam_info(char *, struct Ortho_Camera_File_Ref *);
-
-/* init_info.c */
-int I_read_init_info(FILE *, struct Ortho_Camera_Exp_Init *);
-int I_write_init_info(FILE *, struct Ortho_Camera_Exp_Init *);
-int I_get_init_info(char *, struct Ortho_Camera_Exp_Init *);
-int I_put_init_info(char *, struct Ortho_Camera_Exp_Init *);
-
-
-#include <grass/ortholib.h>

Copied: grass/trunk/imagery/i.ortho.photo/libes/orthophoto.h (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/orthophoto.h)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/orthophoto.h	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/orthophoto.h	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,151 @@
+#include <grass/gis.h>
+#include <grass/imagery.h>
+
+/* #define DEBUG  1 */
+
+#define INITIAL_X_VAR   500
+#define INITIAL_Y_VAR   500
+#define INITIAL_Z_VAR  1000
+#define INITIAL_OMEGA_VAR   0.01
+#define INITIAL_PHI_VAR     0.01
+#define INITIAL_KAPPA_VAR   0.1
+
+struct Ortho_Image_Group_Ref
+{
+    int nfiles;
+    struct Ortho_Image_Group_Ref_Files
+    {
+	char name[30];
+	char mapset[30];
+    } *file;
+    struct Ortho_Ref_Color
+    {
+	unsigned char *table;	/* color table for min-max values */
+	unsigned char *index;	/* data translation index */
+	unsigned char *buf;	/* data buffer for reading color file */
+	int fd;			/* for image i/o */
+	CELL min, max;		/* min,max CELL values */
+	int n;			/* index into Ref_Files */
+    } red, grn, blu;
+};
+
+struct Ortho_Camera_File_Ref
+{
+    char cam_name[30];
+    char cam_id[30];
+    double Xp;
+    double Yp;
+    double CFL;
+    int num_fid;
+    struct Fiducial
+    {
+	char fid_id[30];
+	double Xf;
+	double Yf;
+    } fiducials[20];
+};
+
+struct Ortho_Photo_Points
+{
+    int count;
+    double *e1;
+    double *n1;
+    double *e2;
+    double *n2;
+    double *z1;
+    double *z2;
+    int *status;
+};
+
+struct Ortho_Control_Points
+{
+    int count;
+    double *e1;
+    double *n1;
+    double *z1;
+    double *e2;
+    double *n2;
+    double *z2;
+    int *status;
+};
+
+struct Ortho_Camera_Exp_Init
+{
+    double XC_init;
+    double YC_init;
+    double ZC_init;
+    double omega_init;
+    double phi_init;
+    double kappa_init;
+    double XC_var;
+    double YC_var;
+    double ZC_var;
+    double omega_var;
+    double phi_var;
+    double kappa_var;
+    int status;
+};
+
+
+struct Ortho_Image_Group
+{
+    char name[100];
+    /* Ortho_Image_Group_Ref is identical to Ortho_Group_Ref, and
+       we assume this is so in the code.  If Ortho_Image_Group_Ref
+       is ever different, then there will have to be a new set of
+       I_get_group_ref() functions to fill it.
+       struct Ortho_Image_Group_Ref    group_ref; */
+    struct Ref group_ref;
+    struct Ortho_Camera_File_Ref camera_ref;
+    struct Ortho_Photo_Points photo_points;
+    struct Ortho_Control_Points control_points;
+    struct Ortho_Camera_Exp_Init camera_exp;
+    int ref_equation_stat;
+    int con_equation_stat;
+    double E12[3], N12[3], E21[3], N21[3], Z12[3], Z21[3];
+    double XC, YC, ZC, omega, phi, kappa;
+};
+
+/* conz_points.c */
+int I_new_con_point(struct Ortho_Control_Points *,
+		    double, double, double, double, double, double, int);
+int I_get_con_points(char *, struct Ortho_Control_Points *);
+int I_put_con_points(char *, struct Ortho_Control_Points *);
+int I_convert_con_points(char *, struct Ortho_Control_Points *,
+			 struct Ortho_Control_Points *, double[3], double[3]);
+/* georef.c */
+int I_compute_ref_equations(struct Ortho_Photo_Points *,
+			    double *, double *, double *, double *);
+/* orthoref.c */
+int I_compute_ortho_equations(struct Ortho_Control_Points *,
+			      struct Ortho_Camera_File_Ref *,
+			      struct Ortho_Camera_Exp_Init *, double *,
+			      double *, double *, double *, double *,
+			      double *);
+int I_ortho_ref(double, double, double, double *, double *, double *,
+		struct Ortho_Camera_File_Ref *, double, double, double,
+		double, double, double);
+int I_inverse_ortho_ref(double, double, double, double *, double *, double *,
+			struct Ortho_Camera_File_Ref *, double, double,
+			double, double, double, double);
+/* ref_points.c */
+int I_new_ref_point(struct Ortho_Photo_Points *, double, double, double,
+		    double, int);
+int I_get_ref_points(char *, struct Ortho_Photo_Points *);
+int I_put_ref_points(char *, struct Ortho_Photo_Points *);
+
+/* cam_info.h */
+int I_read_cam_info(FILE *, struct Ortho_Camera_File_Ref *);
+int I_new_fid_point(struct Ortho_Camera_File_Ref *, char *, double, double);
+int I_write_cam_info(FILE *, struct Ortho_Camera_File_Ref *);
+int I_get_cam_info(char *, struct Ortho_Camera_File_Ref *);
+int I_put_cam_info(char *, struct Ortho_Camera_File_Ref *);
+
+/* init_info.c */
+int I_read_init_info(FILE *, struct Ortho_Camera_Exp_Init *);
+int I_write_init_info(FILE *, struct Ortho_Camera_Exp_Init *);
+int I_get_init_info(char *, struct Ortho_Camera_Exp_Init *);
+int I_put_init_info(char *, struct Ortho_Camera_Exp_Init *);
+
+
+#include <grass/ortholib.h>

Deleted: grass/trunk/imagery/i.ortho.photo/libes/orthoref.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/orthoref.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/orthoref.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,677 +0,0 @@
-
-/****************************************************************************
- *
- * MODULE:       orthophoto rectification program
- * AUTHOR(S):    Mike Baba of DBA Systems, Fairfax, VA for CERL
- * PURPOSE:      ortho-rectification of aerial photographs
- * COPYRIGHT:    (C) 1999 by the GRASS Development Team
- *
- *               This program is free software under the GNU General Public
- *               License (>=v2). Read the file COPYING that comes with GRASS
- *               for details.
- *
- *****************************************************************************/
-
-/* orthoref.c */
-
-/***********************************************************************
- * I_compute_ortho_equations()
- * I_orthoref()
- * I_inverse_orthoref()
- ***********************************************************************/
-/*
-   Main algorithm reference:
-
-   Elements of Photogrammetry, With Air Photo Interpretation and Remote Sensing
-   by Paul R. Wolf, 562 pages
-   Publisher: McGraw Hill Text; 2nd edition (January 1983)
- */
-
-#include <signal.h>
-#include <stdio.h>
-#include <math.h>
-#include "orthophoto.h"
-#include <grass/imagery.h>
-#include "mat.h"
-#include "matrixdefs.h"
-#include "local_proto.h"
-
-#define MAX_ITERS   10		/* Max iteration is normal equation solution */
-#define CONV_LIMIT  1.0		/* meters */
-
-#ifdef DEBUG
-FILE *debug;
-char msg[120];
-#endif
-
-static int floating_exception;
-static void catch(int);
-
-
-/* Compute the ortho rectification parameters */
-/* XC,YC,ZC, Omega, Phi, Kappa */
-int I_compute_ortho_equations(struct Ortho_Control_Points *cpz,
-			      struct Ortho_Camera_File_Ref *cam_info,
-			      struct Ortho_Camera_Exp_Init *init_info,
-			      double *XC, double *YC, double *ZC,
-			      double *Omega, double *Phi, double *Kappa)
-{
-    MATRIX delta, epsilon, B, BT, C, E, N, CC, NN, UVW, XYZ, M, WT1;
-    double meanx, meany;
-    double X1 = 0, X2 = 0, x1 = 0, x2 = 0, Z1 = 0, Y1 = 0, Y2 = 0, y1 =
-	0, y2 = 0, dist_grnd = 0, dist_photo = 0;
-    double x, y, z, X, Y, Z, Xp, Yp, CFL;
-    double lam, mu, nu, U, V, W;
-    double xbar, ybar;
-    double m11, m12, m13, m21, m22, m23, m31, m32, m33;
-    double sw, cw, sp, cp, sk, ck;
-    double dx, dy, dz, dd;
-    double Q1;
-    double kappa1, kappa2, XC_var, YC_var, ZC_var;
-    double omega_var, phi_var, kappa_var;
-    int i, iter, n;
-    int first, active;
-
-    Q1 = (double)1.0;
-
-    /*
-     *  floating_exception = 0;
-     *  sigfpe = signal (SIGFPE, catch);
-     */
-
-    /* DEBUG */
-#ifdef DEBUG
-    debug = fopen("ortho_compute.rst", "w");
-    if (debug == NULL) {
-	sprintf(msg, "Cant open debug file ortho_analyze.rst\n");
-	G_fatal_error(msg);
-    }
-#endif
-
-    /*  Need 4 active control points */
-    active = 0;
-    for (i = 0; i < cpz->count; i++) {
-	if (cpz->status[i] > 0)
-	    active++;
-    }
-    if (active < 4) {
-#ifdef DEBUG
-	fclose(debug);
-#endif
-	return (-1);
-    }
-
-    /*  Initialize (and zero out) all matrices needed */
-    /*  Format is delta = [XC,YC,ZC,Omega,Phi,Kappa]-transpose  */
-
-    /*  Normal Equation Matrix */
-    N.nrows = 6;
-    N.ncols = 6;
-    zero(&N);
-    /*  Sum of Normal Equation Matrix */
-    NN.nrows = 6;
-    NN.ncols = 6;
-    zero(&NN);
-    /*  Partial derivates of observation equations */
-    B.nrows = 2;
-    B.ncols = 6;
-    zero(&B);
-    /*  Transpose of B */
-    BT.nrows = 6;
-    BT.ncols = 2;
-    zero(&BT);
-    /*  Partial solution matrix */
-    C.nrows = 6;
-    C.ncols = 1;
-    zero(&C);
-    /*  Sum of Partial solution matrix */
-    CC.nrows = 6;
-    CC.ncols = 1;
-    zero(&CC);
-    /*  Residual matrix */
-    E.nrows = 2;
-    E.ncols = 1;
-    zero(&E);
-    /*  delta Matrix  - [XC,YC,ZC,Omega,Phi,Kappa]-transpose */
-    delta.nrows = 6;
-    delta.ncols = 1;
-    zero(&delta);
-    /*  corrections to delta matrix */
-    epsilon.nrows = 6;
-    epsilon.ncols = 1;
-    zero(&epsilon);
-    /*  Object Space Coordinates (X,Y,Z) */
-    XYZ.nrows = 3;
-    XYZ.ncols = 1;
-    zero(&XYZ);
-    /*  Image Space coordinates  (u,v,w) */
-    UVW.nrows = 3;
-    UVW.ncols = 1;
-    zero(&UVW);
-    /* Oreintaiton Matrix  M=[3,3] functions of (omega,phi,kappa) */
-    M.nrows = 3;
-    M.ncols = 3;
-    zero(&M);
-    /*  Weight Matrix for delta */
-    /*  Weights set to identity matrix unless */
-    WT1.nrows = 6;
-    WT1.ncols = 6;
-    zero(&WT1);
-
-/******************** Start the solution *****************************/
-
-    /* set Xp, Yp, and CFL form cam_info */
-    Xp = cam_info->Xp;
-    Yp = cam_info->Yp;
-    CFL = cam_info->CFL;
-
-#ifdef DEBUG
-    fprintf(debug, "CAMERA INFO:\n");
-    fprintf(debug, "\txp = %f  \typ = %f \tCFL  = %f \n", Xp, Yp, CFL);
-#endif
-
-    /* use initial estimates for XC,YC,ZC,omega,phi,kappa
-     * and initial standard deviations if proveded by i.ortho.photo
-     *
-     * otherwise set from mean value of all active control points 
-     * - init_info is generated by photo.init (file INIT_EXP)
-     * - init_info->status allows for disactivation of defined values 
-     */
-    if ((init_info != NULL) && (init_info->status == 1)) {
-	/* Have initial values */
-	*XC = init_info->XC_init;
-	*YC = init_info->YC_init;
-	*ZC = init_info->ZC_init;
-	*Omega = init_info->omega_init;
-	*Phi = init_info->phi_init;
-	*Kappa = init_info->kappa_init;
-
-	/* weight matrix computed from initial standard variances */
-	WT1.x[0][0] = (Q1 / (init_info->XC_var * init_info->XC_var));
-	WT1.x[1][1] = (Q1 / (init_info->YC_var * init_info->YC_var));
-	WT1.x[2][2] = (Q1 / (init_info->ZC_var * init_info->ZC_var));
-	WT1.x[3][3] = (Q1 / (init_info->omega_var * init_info->omega_var));
-	WT1.x[4][4] = (Q1 / (init_info->phi_var * init_info->phi_var));
-	WT1.x[5][5] = (Q1 / (init_info->kappa_var * init_info->kappa_var));
-    }
-    else {			/* set from mean values of active control points */
-
-
-	/* set intial XC and YC from mean values of control points */
-	meanx = meany = 0;
-	n = 0;
-	first = 1;
-	for (i = 0; i < cpz->count; i++) {
-	    if (cpz->status[i] <= 0)
-		continue;
-
-	    /* set initial XC, YC */
-	    if (first) {
-		X1 = *(cpz->e2);
-		x1 = *(cpz->e1);
-		Y1 = *(cpz->n2);
-		y1 = *(cpz->n1);
-		Z1 = *(cpz->z2);
-		first = 0;
-	    }
-	    if (!first) {
-		X2 = *(cpz->e2);
-		x2 = *(cpz->e1);
-		Y2 = *(cpz->n2);
-		y2 = *(cpz->n1);
-		dist_photo =
-		    sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
-		dist_grnd =
-		    sqrt(((X1 - X2) * (X1 - X2)) + ((Y1 - Y2) * (Y1 - Y2)));
-	    }
-
-	    n++;
-	    meanx += *((cpz->e2)++);
-	    meany += *((cpz->n2)++);
-	    ((cpz->e1)++);
-	    ((cpz->n1)++);
-	}
-	*XC = meanx / n;
-	*YC = meany / n;
-
-	/* reset pointers */
-	for (i = 0; i < cpz->count; i++) {
-	    if (cpz->status[i] <= 0)
-		continue;
-	    (cpz->e1)--;
-	    (cpz->e2)--;
-	    (cpz->n1)--;
-	    (cpz->n2)--;
-	}
-
-	/* set initial ZC from:                                  */
-	/*    scale ~= dist_photo/dist_grnd  ~= (CFL)/(Z1 - Zc)  */
-	/*       Zc ~= Z1 + CFL(dist_grnd)/(dist_photo)          */
-
-	*ZC = Z1 + (CFL * (dist_grnd) / (dist_photo));
-
-	/* set initial rotations to zero (radians) */
-	*Omega = *Phi = 0.0;
-
-	/* find an initial kappa */
-	kappa1 = atan2((y2 - y1), (x2 - x1));
-	kappa2 = atan2((Y2 - Y1), (X2 - X1));
-	*Kappa = (kappa2 - kappa1);
-
-	/* set initial weights */
-	XC_var = INITIAL_X_VAR;
-	YC_var = INITIAL_Y_VAR;
-	ZC_var = INITIAL_Z_VAR;
-	omega_var = INITIAL_OMEGA_VAR;
-	phi_var = INITIAL_PHI_VAR;
-	kappa_var = INITIAL_KAPPA_VAR;
-
-	WT1.x[0][0] = (Q1 / (XC_var * XC_var));
-	WT1.x[1][1] = (Q1 / (YC_var * YC_var));
-	WT1.x[2][2] = (Q1 / (ZC_var * ZC_var));
-	WT1.x[3][3] = (Q1 / (omega_var * omega_var));
-	WT1.x[4][4] = (Q1 / (phi_var * phi_var));
-	WT1.x[5][5] = (Q1 / (kappa_var * kappa_var));
-    }
-
-#ifdef DEBUG
-    fprintf(debug, "\nINITIAL CAMERA POSITION:\n");
-    fprintf(debug, "\tXC = %f  \tYC = %f \tZC = %f \n", *XC, *YC, *ZC);
-    fprintf(debug, "\tOMEGA = %f  \tPHI = %f \tKAPPA = %f \n",
-	    *Omega, *Phi, *Kappa);
-#endif
-
-    /* set initial parameters into epsilon matrix */
-    epsilon.x[0][0] = *XC;
-    epsilon.x[1][0] = *YC;
-    epsilon.x[2][0] = *ZC;
-    epsilon.x[3][0] = *Omega;
-    epsilon.x[4][0] = *Phi;
-    epsilon.x[5][0] = *Kappa;
-
-/************************** Start Iterations *****************************/
-    /* itererate untill convergence */
-
-    for (iter = 0; iter <= MAX_ITERS; iter++) {
-	/*  break if converged */
-	dx = delta.x[0][0];
-	dy = delta.x[1][0];
-	dz = delta.x[2][0];
-	dd = ((dx * dx) + (dy * dy) + (dz * dz));
-
-	if ((iter > 0) && (dd <= CONV_LIMIT))
-	    break;
-
-#ifdef DEBUG
-	fprintf(debug, "\n\tITERATION = %d \n", iter);
-#endif
-
-	/* value of parameters at this iteration */
-	*XC = epsilon.x[0][0];
-	*YC = epsilon.x[1][0];
-	*ZC = epsilon.x[2][0];
-	*Omega = epsilon.x[3][0];
-	*Phi = epsilon.x[4][0];
-	*Kappa = epsilon.x[5][0];
-
-#ifdef DEBUG
-	fprintf(debug,
-		"\n\tepsilon:\n\t\tXC = \t%f \n\t\tYC = \t%f \n\t\tZC = \t%f \n\t\tomega = \t%f \n\t\tphi = \t%f \n\t\tkappa = \t%f \n\n",
-		*XC, *YC, *ZC, *Omega, *Phi, *Kappa);
-#endif
-
-
-	/*  clear NN, CC */
-	zero(&NN);
-	zero(&CC);
-
-	/*   Set Orientation Matrix from latest vales (Omega, Phi, Kappa); */
-	sw = sin(*Omega);
-	cw = cos(*Omega);
-	sp = sin(*Phi);
-	cp = cos(*Phi);
-	sk = sin(*Kappa);
-	ck = cos(*Kappa);
-
-	/* see  WOLF 1983, Appendix, p. 591 */
-
-	M.x[0][0] = (cp * ck);
-	M.x[0][1] = (cw * sk) + (sw * sp * ck);
-	M.x[0][2] = (sw * sk) - (cw * sp * ck);
-	M.x[1][0] = (-cp * sk);
-	M.x[1][1] = (cw * ck) - (sw * sp * sk);
-	M.x[1][2] = (sw * ck) + (cw * sp * sk);
-	M.x[2][0] = sp;
-	M.x[2][1] = (-sw * cp);
-	M.x[2][2] = (cw * cp);
-
-	/* just an abbreviation of M */
-	m11 = M.x[0][0];
-	m12 = M.x[0][1];
-	m13 = M.x[0][2];
-	m21 = M.x[1][0];
-	m22 = M.x[1][1];
-	m23 = M.x[1][2];
-	m31 = M.x[2][0];
-	m32 = M.x[2][1];
-	m33 = M.x[2][2];
-
-	/* Form Normal equations by summation of all active control points */
-	for (i = 0; i < cpz->count; i++) {
-#ifdef DEBUG
-	    fprintf(debug, "\n\t\t\tIn Summation count = %d \n", i);
-#endif
-
-	    x = *((cpz->e1))++;
-	    y = *((cpz->n1))++;
-	    z = *((cpz->z1))++;
-	    X = *((cpz->e2))++;
-	    Y = *((cpz->n2))++;
-	    Z = *((cpz->z2))++;
-
-	    if (cpz->status[i] <= 0)
-		continue;
-
-#ifdef DEBUG
-	    fprintf(debug,
-		    "\n\t\t\timage:\n \t\t\tx = \t%f \n\t\t\ty = \t%f \n\t\t\tz = \t%f \n\t\t\tobject:\n \t\t\tX = \t%f \n\t\t\tY = \t%f \n\t\t\tZ = \t%f \n",
-		    x, y, z, X, Y, Z);
-#endif
-
-
-	    /* Compute Obj. Space coordinates */
-	    XYZ.x[0][0] = X - *XC;
-	    XYZ.x[1][0] = Y - *YC;
-	    XYZ.x[2][0] = Z - *ZC;
-
-	    /* just an abbreviations */
-	    lam = XYZ.x[0][0];
-	    mu = XYZ.x[1][0];
-	    nu = XYZ.x[2][0];
-
-	    /* Compute image space coordiantes */
-	    m_mult(&M, &XYZ, &UVW);
-
-	    /*  just an abbreviation */
-	    U = UVW.x[0][0];
-	    V = UVW.x[1][0];
-	    W = UVW.x[2][0];
-
-
-	    /* Form Partial derivatives of Normal Equations */
-	    xbar = x - Xp;
-	    ybar = y - Yp;
-
-	    B.x[0][0] = (-Q1 / W) * ((xbar * m31) + (CFL * m11));
-	    B.x[0][1] = (-Q1 / W) * ((xbar * m32) + (CFL * m12));
-	    B.x[0][2] = (-Q1 / W) * ((xbar * m33) + (CFL * m13));
-	    B.x[0][3] = (Q1 / W) *
-		((xbar * ((-m33 * mu) + (m32 * nu))) +
-		 (CFL * ((-m13 * mu) + (m12 * nu)))
-		);
-	    B.x[0][4] = (Q1 / W) *
-		((xbar * ((cp * lam) + (sw * sp * mu) + (-cw * sp * nu))) +
-		 (CFL *
-		  ((-sp * ck * lam) + (sw * cp * ck * mu) +
-		   (-cw * cp * ck * nu)))
-		);
-	    B.x[0][5] = (Q1 / W) *
-		(CFL * ((m21 * lam) + (m22 * mu) + (m23 * nu)));
-
-	    B.x[1][0] = (-Q1 / W) * ((ybar * m31) + (CFL * m21));
-	    B.x[1][1] = (-Q1 / W) * ((ybar * m32) + (CFL * m22));
-	    B.x[1][2] = (-Q1 / W) * ((ybar * m33) + (CFL * m23));
-	    B.x[1][3] = (Q1 / W) *
-		((ybar * ((-m33 * mu) + (m32 * nu))) +
-		 (CFL * ((-m23 * mu) + (m22 * nu)))
-		);
-	    B.x[1][4] = (Q1 / W) *
-		((ybar * ((cp * lam) + (sw * sp * mu) + (-cw * sp * nu))) +
-		 (CFL *
-		  ((sp * sk * lam) + (-sw * cp * sk * mu) +
-		   (cw * cp * sk * nu)))
-		);
-	    B.x[1][5] = (Q1 / W) *
-		(CFL * ((-m11 * lam) + (-m12 * mu) + (-m13 * nu)));
-
-	    E.x[0][0] = (-Q1) * (xbar + (CFL * (U / W)));
-	    E.x[1][0] = (-Q1) * (ybar + (CFL * (V / W)));
-
-#ifdef DEBUG
-	    fprintf(debug,
-		    "\n\t\t\tresidual:\n \t\t\tE1 = \t%f \n\t\t\tE2 = \t%f \n",
-		    E.x[0][0], E.x[1][0]);
-#endif
-
-	    /* do the summation into Normal equation and solution matrices */
-	    /* Find B transpose */
-	    transpose(&B, &BT);
-	    /* N = BT*B */
-	    m_mult(&BT, &B, &N);
-	    /* NN += N */
-	    m_add(&NN, &N, &NN);
-	    /* C = BT*E */
-	    m_mult(&BT, &E, &C);
-	    /* CC += C */
-	    m_add(&CC, &C, &CC);
-	}			/* end summation loop over all active control points */
-
-	/* reset pointers */
-	for (i = 0; i < cpz->count; i++) {
-	    (cpz->e1)--;
-	    (cpz->n1)--;
-	    (cpz->z1)--;
-	    (cpz->e2)--;
-	    (cpz->n2)--;
-	    (cpz->z2)--;
-	}
-
-#ifdef DEBUG
-	fprintf(debug, "\n\tN: \n");
-	for (i = 0; i < 6; i++)
-	    fprintf(debug, "\t%f \t%f \t%f \t%f \t%f \t%f \n",
-		    NN.x[i][0], NN.x[i][1], NN.x[i][2],
-		    NN.x[i][3], NN.x[i][4], NN.x[i][5]);
-
-	fprintf(debug, "\n\tC: \n");
-	fprintf(debug, "\t%f \t%f \t%f \t%f \t%f \t%f \n",
-		CC.x[0][0], CC.x[1][0], CC.x[2][0],
-		CC.x[3][0], CC.x[4][0], CC.x[5][0]);
-#endif
-
-
-	/* Add weigth matrix of unknowns to NN */
-	m_add(&NN, &WT1, &NN);
-	/* Solve for delta */
-	if (!inverse(&NN, &N)) {	/* control point status becomes zero if matrix is non-invertable */
-	    error("Matrix Inversion (Control Points status modified)");
-	    for (i = 0; i < cpz->count; i++)
-		cpz->status[i] = 0;
-	    return (0);
-	}
-
-
-	/* delta = N-1 * CC */
-	m_mult(&N, &CC, &delta);
-	/* epsilon += delta */
-	m_add(&epsilon, &delta, &epsilon);
-
-#ifdef DEBUG
-	fprintf(debug,
-		"\ndelta:\n  \n\t\tXC = \t%f \n\t\tYC = \t%f \n\t\tZC = \t%f \n\t\tomega = \t%f \n\t\tphi = \t%f \n\t\tkappa = \t%f \n",
-		delta.x[0][0], delta.x[1][0], delta.x[2][0], delta.x[3][0],
-		delta.x[4][0], delta.x[5][0]);
-#endif
-
-    }				/* end ITERATION loop */
-
-    /* This is the solution */
-    *XC = epsilon.x[0][0];
-    *YC = epsilon.x[1][0];
-    *ZC = epsilon.x[2][0];
-    *Omega = epsilon.x[3][0];
-    *Phi = epsilon.x[4][0];
-    *Kappa = epsilon.x[5][0];
-
-#ifdef DEBUG
-    fclose(debug);
-#endif
-
-    return (1);
-}
-
-static void catch(int n)
-{
-    floating_exception = 1;
-    signal(n, catch);
-}
-
-/* given ground coordinates (e1,n1,z1) and the solution from above */
-/* compute the photo coordinate (e2,n2) position */
-int I_ortho_ref(double e1, double n1, double z1,
-		double *e2, double *n2, double *z2,
-		struct Ortho_Camera_File_Ref *cam_info,
-		double XC, double YC, double ZC,
-		double Omega, double Phi, double Kappa)
-{
-    MATRIX UVW, XYZ, M;
-    double U, V, W;
-    double Xp, Yp, CFL;
-    double sw, cw, sp, cp, sk, ck;
-
-    /*  Initialize and zero the matrices */
-    /*  Object Space Coordinates */
-    XYZ.nrows = 3;
-    XYZ.ncols = 1;
-    zero(&XYZ);
-    /*  Image Space coordinates */
-    UVW.nrows = 3;
-    UVW.ncols = 1;
-    zero(&UVW);
-    /*  Orientation Matrix */
-    M.nrows = 3;
-    M.ncols = 3;
-    zero(&M);
-
-    /************************ Start the work ******************************/
-    /* set Xp, Yp, and CFL form cam_info */
-    Xp = cam_info->Xp;
-    Yp = cam_info->Yp;
-    CFL = cam_info->CFL;
-
-    /*  Compute Orientation Matrix M from (Omega, Phi, Kappa); */
-    sw = sin(Omega);
-    cw = cos(Omega);
-    sp = sin(Phi);
-    cp = cos(Phi);
-    sk = sin(Kappa);
-    ck = cos(Kappa);
-
-    M.x[0][0] = cp * ck;
-    M.x[0][1] = cw * sk + (sw * sp * ck);
-    M.x[0][2] = sw * sk - (cw * sp * ck);
-    M.x[1][0] = -(cp * sk);
-    M.x[1][1] = cw * ck - (sw * sp * sk);
-    M.x[1][2] = sw * ck + (cw * sp * sk);
-    M.x[2][0] = sp;
-    M.x[2][1] = -(sw * cp);
-    M.x[2][2] = cw * cp;
-
-    /* ObjSpace (&XYZ, XC,YC,ZC, X,Y,Z); */
-    XYZ.x[0][0] = e1 - XC;
-    XYZ.x[1][0] = n1 - YC;
-    XYZ.x[2][0] = z1 - ZC;
-
-    m_mult(&M, &XYZ, &UVW);
-
-    /* Image Space */
-    U = UVW.x[0][0];
-    V = UVW.x[1][0];
-    W = UVW.x[2][0];
-
-    /* This is the solution */
-    *e2 = (-CFL) * (U / W);
-    *n2 = (-CFL) * (V / W);
-    return (1);
-}
-
-/* given the photo coordiantes (e1,n1) and elevation z2  */
-/* and the solution from I_compute_ortho_equation */
-/* compute ground position (e2,n2) */
-int I_inverse_ortho_ref(double e1, double n1, double z1,
-			double *e2, double *n2, double *z2,
-			struct Ortho_Camera_File_Ref *cam_info,
-			double XC, double YC, double ZC,
-			double Omega, double Phi, double Kappa)
-{
-    MATRIX UVW, XYZ, M;
-    double lam, mu, nu;
-    double Xp, Yp, CFL;
-    double sw, cw, sp, cp, sk, ck;
-
-    /*  Initialize and zero matrices */
-    /*  Object Space Coordinates */
-    XYZ.nrows = 3;
-    XYZ.ncols = 1;
-    zero(&XYZ);
-    /*  Image Space coordinates */
-    UVW.nrows = 3;
-    UVW.ncols = 1;
-    zero(&UVW);
-    /*  Orientation Matrix */
-    M.nrows = 3;
-    M.ncols = 3;
-    zero(&M);
-
-    /********************** Start the work ********************************/
-    /* set Xp, Yp, and CFL form cam_info */
-    Xp = cam_info->Xp;
-    Yp = cam_info->Yp;
-    CFL = cam_info->CFL;
-
-    /* Compute Orientation Matrix (Omega, Phi, Kappa); */
-    sw = sin(Omega);
-    cw = cos(Omega);
-    sp = sin(Phi);
-    cp = cos(Phi);
-    sk = sin(Kappa);
-    ck = cos(Kappa);
-
-    /* M Transposed */
-    M.x[0][0] = cp * ck;
-    M.x[1][0] = cw * sk + (sw * sp * ck);
-    M.x[2][0] = sw * sk - (cw * sp * ck);
-    M.x[0][1] = -(cp * sk);
-    M.x[1][1] = cw * ck - (sw * sp * sk);
-    M.x[2][1] = sw * ck + (cw * sp * sk);
-    M.x[0][2] = sp;
-    M.x[1][2] = -(sw * cp);
-    M.x[2][2] = cw * cp;
-
-    /* ImageSpace */
-    UVW.x[0][0] = e1 - Xp;
-    UVW.x[1][0] = n1 - Yp;
-    UVW.x[2][0] = -CFL;
-
-    m_mult(&M, &UVW, &XYZ);
-
-    /* Image Space */
-    lam = XYZ.x[0][0];
-    mu = XYZ.x[1][0];
-    nu = XYZ.x[2][0];
-
-    /* This is the solution */
-    *e2 = ((z1 - ZC) * (lam / nu)) + XC;
-    *n2 = ((z1 - ZC) * (mu / nu)) + YC;
-
-    return (1);
-}
-
-int matrix_error(char *s)
-{
-    fprintf(stderr, "WARNING: %s", s);
-#ifdef DEBUG
-    fclose(debug);
-#endif
-    return 0;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/orthoref.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/orthoref.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/orthoref.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/orthoref.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,677 @@
+
+/****************************************************************************
+ *
+ * MODULE:       orthophoto rectification program
+ * AUTHOR(S):    Mike Baba of DBA Systems, Fairfax, VA for CERL
+ * PURPOSE:      ortho-rectification of aerial photographs
+ * COPYRIGHT:    (C) 1999 by the GRASS Development Team
+ *
+ *               This program is free software under the GNU General Public
+ *               License (>=v2). Read the file COPYING that comes with GRASS
+ *               for details.
+ *
+ *****************************************************************************/
+
+/* orthoref.c */
+
+/***********************************************************************
+ * I_compute_ortho_equations()
+ * I_orthoref()
+ * I_inverse_orthoref()
+ ***********************************************************************/
+/*
+   Main algorithm reference:
+
+   Elements of Photogrammetry, With Air Photo Interpretation and Remote Sensing
+   by Paul R. Wolf, 562 pages
+   Publisher: McGraw Hill Text; 2nd edition (January 1983)
+ */
+
+#include <signal.h>
+#include <stdio.h>
+#include <math.h>
+#include "orthophoto.h"
+#include <grass/imagery.h>
+#include "mat.h"
+#include "matrixdefs.h"
+#include "local_proto.h"
+
+#define MAX_ITERS   10		/* Max iteration is normal equation solution */
+#define CONV_LIMIT  1.0		/* meters */
+
+#ifdef DEBUG
+FILE *debug;
+char msg[120];
+#endif
+
+static int floating_exception;
+static void catch(int);
+
+
+/* Compute the ortho rectification parameters */
+/* XC,YC,ZC, Omega, Phi, Kappa */
+int I_compute_ortho_equations(struct Ortho_Control_Points *cpz,
+			      struct Ortho_Camera_File_Ref *cam_info,
+			      struct Ortho_Camera_Exp_Init *init_info,
+			      double *XC, double *YC, double *ZC,
+			      double *Omega, double *Phi, double *Kappa)
+{
+    MATRIX delta, epsilon, B, BT, C, E, N, CC, NN, UVW, XYZ, M, WT1;
+    double meanx, meany;
+    double X1 = 0, X2 = 0, x1 = 0, x2 = 0, Z1 = 0, Y1 = 0, Y2 = 0, y1 =
+	0, y2 = 0, dist_grnd = 0, dist_photo = 0;
+    double x, y, z, X, Y, Z, Xp, Yp, CFL;
+    double lam, mu, nu, U, V, W;
+    double xbar, ybar;
+    double m11, m12, m13, m21, m22, m23, m31, m32, m33;
+    double sw, cw, sp, cp, sk, ck;
+    double dx, dy, dz, dd;
+    double Q1;
+    double kappa1, kappa2, XC_var, YC_var, ZC_var;
+    double omega_var, phi_var, kappa_var;
+    int i, iter, n;
+    int first, active;
+
+    Q1 = (double)1.0;
+
+    /*
+     *  floating_exception = 0;
+     *  sigfpe = signal (SIGFPE, catch);
+     */
+
+    /* DEBUG */
+#ifdef DEBUG
+    debug = fopen("ortho_compute.rst", "w");
+    if (debug == NULL) {
+	sprintf(msg, "Cant open debug file ortho_analyze.rst\n");
+	G_fatal_error(msg);
+    }
+#endif
+
+    /*  Need 4 active control points */
+    active = 0;
+    for (i = 0; i < cpz->count; i++) {
+	if (cpz->status[i] > 0)
+	    active++;
+    }
+    if (active < 4) {
+#ifdef DEBUG
+	fclose(debug);
+#endif
+	return (-1);
+    }
+
+    /*  Initialize (and zero out) all matrices needed */
+    /*  Format is delta = [XC,YC,ZC,Omega,Phi,Kappa]-transpose  */
+
+    /*  Normal Equation Matrix */
+    N.nrows = 6;
+    N.ncols = 6;
+    zero(&N);
+    /*  Sum of Normal Equation Matrix */
+    NN.nrows = 6;
+    NN.ncols = 6;
+    zero(&NN);
+    /*  Partial derivates of observation equations */
+    B.nrows = 2;
+    B.ncols = 6;
+    zero(&B);
+    /*  Transpose of B */
+    BT.nrows = 6;
+    BT.ncols = 2;
+    zero(&BT);
+    /*  Partial solution matrix */
+    C.nrows = 6;
+    C.ncols = 1;
+    zero(&C);
+    /*  Sum of Partial solution matrix */
+    CC.nrows = 6;
+    CC.ncols = 1;
+    zero(&CC);
+    /*  Residual matrix */
+    E.nrows = 2;
+    E.ncols = 1;
+    zero(&E);
+    /*  delta Matrix  - [XC,YC,ZC,Omega,Phi,Kappa]-transpose */
+    delta.nrows = 6;
+    delta.ncols = 1;
+    zero(&delta);
+    /*  corrections to delta matrix */
+    epsilon.nrows = 6;
+    epsilon.ncols = 1;
+    zero(&epsilon);
+    /*  Object Space Coordinates (X,Y,Z) */
+    XYZ.nrows = 3;
+    XYZ.ncols = 1;
+    zero(&XYZ);
+    /*  Image Space coordinates  (u,v,w) */
+    UVW.nrows = 3;
+    UVW.ncols = 1;
+    zero(&UVW);
+    /* Oreintaiton Matrix  M=[3,3] functions of (omega,phi,kappa) */
+    M.nrows = 3;
+    M.ncols = 3;
+    zero(&M);
+    /*  Weight Matrix for delta */
+    /*  Weights set to identity matrix unless */
+    WT1.nrows = 6;
+    WT1.ncols = 6;
+    zero(&WT1);
+
+/******************** Start the solution *****************************/
+
+    /* set Xp, Yp, and CFL form cam_info */
+    Xp = cam_info->Xp;
+    Yp = cam_info->Yp;
+    CFL = cam_info->CFL;
+
+#ifdef DEBUG
+    fprintf(debug, "CAMERA INFO:\n");
+    fprintf(debug, "\txp = %f  \typ = %f \tCFL  = %f \n", Xp, Yp, CFL);
+#endif
+
+    /* use initial estimates for XC,YC,ZC,omega,phi,kappa
+     * and initial standard deviations if proveded by i.ortho.photo
+     *
+     * otherwise set from mean value of all active control points 
+     * - init_info is generated by photo.init (file INIT_EXP)
+     * - init_info->status allows for disactivation of defined values 
+     */
+    if ((init_info != NULL) && (init_info->status == 1)) {
+	/* Have initial values */
+	*XC = init_info->XC_init;
+	*YC = init_info->YC_init;
+	*ZC = init_info->ZC_init;
+	*Omega = init_info->omega_init;
+	*Phi = init_info->phi_init;
+	*Kappa = init_info->kappa_init;
+
+	/* weight matrix computed from initial standard variances */
+	WT1.x[0][0] = (Q1 / (init_info->XC_var * init_info->XC_var));
+	WT1.x[1][1] = (Q1 / (init_info->YC_var * init_info->YC_var));
+	WT1.x[2][2] = (Q1 / (init_info->ZC_var * init_info->ZC_var));
+	WT1.x[3][3] = (Q1 / (init_info->omega_var * init_info->omega_var));
+	WT1.x[4][4] = (Q1 / (init_info->phi_var * init_info->phi_var));
+	WT1.x[5][5] = (Q1 / (init_info->kappa_var * init_info->kappa_var));
+    }
+    else {			/* set from mean values of active control points */
+
+
+	/* set intial XC and YC from mean values of control points */
+	meanx = meany = 0;
+	n = 0;
+	first = 1;
+	for (i = 0; i < cpz->count; i++) {
+	    if (cpz->status[i] <= 0)
+		continue;
+
+	    /* set initial XC, YC */
+	    if (first) {
+		X1 = *(cpz->e2);
+		x1 = *(cpz->e1);
+		Y1 = *(cpz->n2);
+		y1 = *(cpz->n1);
+		Z1 = *(cpz->z2);
+		first = 0;
+	    }
+	    if (!first) {
+		X2 = *(cpz->e2);
+		x2 = *(cpz->e1);
+		Y2 = *(cpz->n2);
+		y2 = *(cpz->n1);
+		dist_photo =
+		    sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
+		dist_grnd =
+		    sqrt(((X1 - X2) * (X1 - X2)) + ((Y1 - Y2) * (Y1 - Y2)));
+	    }
+
+	    n++;
+	    meanx += *((cpz->e2)++);
+	    meany += *((cpz->n2)++);
+	    ((cpz->e1)++);
+	    ((cpz->n1)++);
+	}
+	*XC = meanx / n;
+	*YC = meany / n;
+
+	/* reset pointers */
+	for (i = 0; i < cpz->count; i++) {
+	    if (cpz->status[i] <= 0)
+		continue;
+	    (cpz->e1)--;
+	    (cpz->e2)--;
+	    (cpz->n1)--;
+	    (cpz->n2)--;
+	}
+
+	/* set initial ZC from:                                  */
+	/*    scale ~= dist_photo/dist_grnd  ~= (CFL)/(Z1 - Zc)  */
+	/*       Zc ~= Z1 + CFL(dist_grnd)/(dist_photo)          */
+
+	*ZC = Z1 + (CFL * (dist_grnd) / (dist_photo));
+
+	/* set initial rotations to zero (radians) */
+	*Omega = *Phi = 0.0;
+
+	/* find an initial kappa */
+	kappa1 = atan2((y2 - y1), (x2 - x1));
+	kappa2 = atan2((Y2 - Y1), (X2 - X1));
+	*Kappa = (kappa2 - kappa1);
+
+	/* set initial weights */
+	XC_var = INITIAL_X_VAR;
+	YC_var = INITIAL_Y_VAR;
+	ZC_var = INITIAL_Z_VAR;
+	omega_var = INITIAL_OMEGA_VAR;
+	phi_var = INITIAL_PHI_VAR;
+	kappa_var = INITIAL_KAPPA_VAR;
+
+	WT1.x[0][0] = (Q1 / (XC_var * XC_var));
+	WT1.x[1][1] = (Q1 / (YC_var * YC_var));
+	WT1.x[2][2] = (Q1 / (ZC_var * ZC_var));
+	WT1.x[3][3] = (Q1 / (omega_var * omega_var));
+	WT1.x[4][4] = (Q1 / (phi_var * phi_var));
+	WT1.x[5][5] = (Q1 / (kappa_var * kappa_var));
+    }
+
+#ifdef DEBUG
+    fprintf(debug, "\nINITIAL CAMERA POSITION:\n");
+    fprintf(debug, "\tXC = %f  \tYC = %f \tZC = %f \n", *XC, *YC, *ZC);
+    fprintf(debug, "\tOMEGA = %f  \tPHI = %f \tKAPPA = %f \n",
+	    *Omega, *Phi, *Kappa);
+#endif
+
+    /* set initial parameters into epsilon matrix */
+    epsilon.x[0][0] = *XC;
+    epsilon.x[1][0] = *YC;
+    epsilon.x[2][0] = *ZC;
+    epsilon.x[3][0] = *Omega;
+    epsilon.x[4][0] = *Phi;
+    epsilon.x[5][0] = *Kappa;
+
+/************************** Start Iterations *****************************/
+    /* itererate untill convergence */
+
+    for (iter = 0; iter <= MAX_ITERS; iter++) {
+	/*  break if converged */
+	dx = delta.x[0][0];
+	dy = delta.x[1][0];
+	dz = delta.x[2][0];
+	dd = ((dx * dx) + (dy * dy) + (dz * dz));
+
+	if ((iter > 0) && (dd <= CONV_LIMIT))
+	    break;
+
+#ifdef DEBUG
+	fprintf(debug, "\n\tITERATION = %d \n", iter);
+#endif
+
+	/* value of parameters at this iteration */
+	*XC = epsilon.x[0][0];
+	*YC = epsilon.x[1][0];
+	*ZC = epsilon.x[2][0];
+	*Omega = epsilon.x[3][0];
+	*Phi = epsilon.x[4][0];
+	*Kappa = epsilon.x[5][0];
+
+#ifdef DEBUG
+	fprintf(debug,
+		"\n\tepsilon:\n\t\tXC = \t%f \n\t\tYC = \t%f \n\t\tZC = \t%f \n\t\tomega = \t%f \n\t\tphi = \t%f \n\t\tkappa = \t%f \n\n",
+		*XC, *YC, *ZC, *Omega, *Phi, *Kappa);
+#endif
+
+
+	/*  clear NN, CC */
+	zero(&NN);
+	zero(&CC);
+
+	/*   Set Orientation Matrix from latest vales (Omega, Phi, Kappa); */
+	sw = sin(*Omega);
+	cw = cos(*Omega);
+	sp = sin(*Phi);
+	cp = cos(*Phi);
+	sk = sin(*Kappa);
+	ck = cos(*Kappa);
+
+	/* see  WOLF 1983, Appendix, p. 591 */
+
+	M.x[0][0] = (cp * ck);
+	M.x[0][1] = (cw * sk) + (sw * sp * ck);
+	M.x[0][2] = (sw * sk) - (cw * sp * ck);
+	M.x[1][0] = (-cp * sk);
+	M.x[1][1] = (cw * ck) - (sw * sp * sk);
+	M.x[1][2] = (sw * ck) + (cw * sp * sk);
+	M.x[2][0] = sp;
+	M.x[2][1] = (-sw * cp);
+	M.x[2][2] = (cw * cp);
+
+	/* just an abbreviation of M */
+	m11 = M.x[0][0];
+	m12 = M.x[0][1];
+	m13 = M.x[0][2];
+	m21 = M.x[1][0];
+	m22 = M.x[1][1];
+	m23 = M.x[1][2];
+	m31 = M.x[2][0];
+	m32 = M.x[2][1];
+	m33 = M.x[2][2];
+
+	/* Form Normal equations by summation of all active control points */
+	for (i = 0; i < cpz->count; i++) {
+#ifdef DEBUG
+	    fprintf(debug, "\n\t\t\tIn Summation count = %d \n", i);
+#endif
+
+	    x = *((cpz->e1))++;
+	    y = *((cpz->n1))++;
+	    z = *((cpz->z1))++;
+	    X = *((cpz->e2))++;
+	    Y = *((cpz->n2))++;
+	    Z = *((cpz->z2))++;
+
+	    if (cpz->status[i] <= 0)
+		continue;
+
+#ifdef DEBUG
+	    fprintf(debug,
+		    "\n\t\t\timage:\n \t\t\tx = \t%f \n\t\t\ty = \t%f \n\t\t\tz = \t%f \n\t\t\tobject:\n \t\t\tX = \t%f \n\t\t\tY = \t%f \n\t\t\tZ = \t%f \n",
+		    x, y, z, X, Y, Z);
+#endif
+
+
+	    /* Compute Obj. Space coordinates */
+	    XYZ.x[0][0] = X - *XC;
+	    XYZ.x[1][0] = Y - *YC;
+	    XYZ.x[2][0] = Z - *ZC;
+
+	    /* just an abbreviations */
+	    lam = XYZ.x[0][0];
+	    mu = XYZ.x[1][0];
+	    nu = XYZ.x[2][0];
+
+	    /* Compute image space coordiantes */
+	    m_mult(&M, &XYZ, &UVW);
+
+	    /*  just an abbreviation */
+	    U = UVW.x[0][0];
+	    V = UVW.x[1][0];
+	    W = UVW.x[2][0];
+
+
+	    /* Form Partial derivatives of Normal Equations */
+	    xbar = x - Xp;
+	    ybar = y - Yp;
+
+	    B.x[0][0] = (-Q1 / W) * ((xbar * m31) + (CFL * m11));
+	    B.x[0][1] = (-Q1 / W) * ((xbar * m32) + (CFL * m12));
+	    B.x[0][2] = (-Q1 / W) * ((xbar * m33) + (CFL * m13));
+	    B.x[0][3] = (Q1 / W) *
+		((xbar * ((-m33 * mu) + (m32 * nu))) +
+		 (CFL * ((-m13 * mu) + (m12 * nu)))
+		);
+	    B.x[0][4] = (Q1 / W) *
+		((xbar * ((cp * lam) + (sw * sp * mu) + (-cw * sp * nu))) +
+		 (CFL *
+		  ((-sp * ck * lam) + (sw * cp * ck * mu) +
+		   (-cw * cp * ck * nu)))
+		);
+	    B.x[0][5] = (Q1 / W) *
+		(CFL * ((m21 * lam) + (m22 * mu) + (m23 * nu)));
+
+	    B.x[1][0] = (-Q1 / W) * ((ybar * m31) + (CFL * m21));
+	    B.x[1][1] = (-Q1 / W) * ((ybar * m32) + (CFL * m22));
+	    B.x[1][2] = (-Q1 / W) * ((ybar * m33) + (CFL * m23));
+	    B.x[1][3] = (Q1 / W) *
+		((ybar * ((-m33 * mu) + (m32 * nu))) +
+		 (CFL * ((-m23 * mu) + (m22 * nu)))
+		);
+	    B.x[1][4] = (Q1 / W) *
+		((ybar * ((cp * lam) + (sw * sp * mu) + (-cw * sp * nu))) +
+		 (CFL *
+		  ((sp * sk * lam) + (-sw * cp * sk * mu) +
+		   (cw * cp * sk * nu)))
+		);
+	    B.x[1][5] = (Q1 / W) *
+		(CFL * ((-m11 * lam) + (-m12 * mu) + (-m13 * nu)));
+
+	    E.x[0][0] = (-Q1) * (xbar + (CFL * (U / W)));
+	    E.x[1][0] = (-Q1) * (ybar + (CFL * (V / W)));
+
+#ifdef DEBUG
+	    fprintf(debug,
+		    "\n\t\t\tresidual:\n \t\t\tE1 = \t%f \n\t\t\tE2 = \t%f \n",
+		    E.x[0][0], E.x[1][0]);
+#endif
+
+	    /* do the summation into Normal equation and solution matrices */
+	    /* Find B transpose */
+	    transpose(&B, &BT);
+	    /* N = BT*B */
+	    m_mult(&BT, &B, &N);
+	    /* NN += N */
+	    m_add(&NN, &N, &NN);
+	    /* C = BT*E */
+	    m_mult(&BT, &E, &C);
+	    /* CC += C */
+	    m_add(&CC, &C, &CC);
+	}			/* end summation loop over all active control points */
+
+	/* reset pointers */
+	for (i = 0; i < cpz->count; i++) {
+	    (cpz->e1)--;
+	    (cpz->n1)--;
+	    (cpz->z1)--;
+	    (cpz->e2)--;
+	    (cpz->n2)--;
+	    (cpz->z2)--;
+	}
+
+#ifdef DEBUG
+	fprintf(debug, "\n\tN: \n");
+	for (i = 0; i < 6; i++)
+	    fprintf(debug, "\t%f \t%f \t%f \t%f \t%f \t%f \n",
+		    NN.x[i][0], NN.x[i][1], NN.x[i][2],
+		    NN.x[i][3], NN.x[i][4], NN.x[i][5]);
+
+	fprintf(debug, "\n\tC: \n");
+	fprintf(debug, "\t%f \t%f \t%f \t%f \t%f \t%f \n",
+		CC.x[0][0], CC.x[1][0], CC.x[2][0],
+		CC.x[3][0], CC.x[4][0], CC.x[5][0]);
+#endif
+
+
+	/* Add weigth matrix of unknowns to NN */
+	m_add(&NN, &WT1, &NN);
+	/* Solve for delta */
+	if (!inverse(&NN, &N)) {	/* control point status becomes zero if matrix is non-invertable */
+	    error("Matrix Inversion (Control Points status modified)");
+	    for (i = 0; i < cpz->count; i++)
+		cpz->status[i] = 0;
+	    return (0);
+	}
+
+
+	/* delta = N-1 * CC */
+	m_mult(&N, &CC, &delta);
+	/* epsilon += delta */
+	m_add(&epsilon, &delta, &epsilon);
+
+#ifdef DEBUG
+	fprintf(debug,
+		"\ndelta:\n  \n\t\tXC = \t%f \n\t\tYC = \t%f \n\t\tZC = \t%f \n\t\tomega = \t%f \n\t\tphi = \t%f \n\t\tkappa = \t%f \n",
+		delta.x[0][0], delta.x[1][0], delta.x[2][0], delta.x[3][0],
+		delta.x[4][0], delta.x[5][0]);
+#endif
+
+    }				/* end ITERATION loop */
+
+    /* This is the solution */
+    *XC = epsilon.x[0][0];
+    *YC = epsilon.x[1][0];
+    *ZC = epsilon.x[2][0];
+    *Omega = epsilon.x[3][0];
+    *Phi = epsilon.x[4][0];
+    *Kappa = epsilon.x[5][0];
+
+#ifdef DEBUG
+    fclose(debug);
+#endif
+
+    return (1);
+}
+
+static void catch(int n)
+{
+    floating_exception = 1;
+    signal(n, catch);
+}
+
+/* given ground coordinates (e1,n1,z1) and the solution from above */
+/* compute the photo coordinate (e2,n2) position */
+int I_ortho_ref(double e1, double n1, double z1,
+		double *e2, double *n2, double *z2,
+		struct Ortho_Camera_File_Ref *cam_info,
+		double XC, double YC, double ZC,
+		double Omega, double Phi, double Kappa)
+{
+    MATRIX UVW, XYZ, M;
+    double U, V, W;
+    double Xp, Yp, CFL;
+    double sw, cw, sp, cp, sk, ck;
+
+    /*  Initialize and zero the matrices */
+    /*  Object Space Coordinates */
+    XYZ.nrows = 3;
+    XYZ.ncols = 1;
+    zero(&XYZ);
+    /*  Image Space coordinates */
+    UVW.nrows = 3;
+    UVW.ncols = 1;
+    zero(&UVW);
+    /*  Orientation Matrix */
+    M.nrows = 3;
+    M.ncols = 3;
+    zero(&M);
+
+    /************************ Start the work ******************************/
+    /* set Xp, Yp, and CFL form cam_info */
+    Xp = cam_info->Xp;
+    Yp = cam_info->Yp;
+    CFL = cam_info->CFL;
+
+    /*  Compute Orientation Matrix M from (Omega, Phi, Kappa); */
+    sw = sin(Omega);
+    cw = cos(Omega);
+    sp = sin(Phi);
+    cp = cos(Phi);
+    sk = sin(Kappa);
+    ck = cos(Kappa);
+
+    M.x[0][0] = cp * ck;
+    M.x[0][1] = cw * sk + (sw * sp * ck);
+    M.x[0][2] = sw * sk - (cw * sp * ck);
+    M.x[1][0] = -(cp * sk);
+    M.x[1][1] = cw * ck - (sw * sp * sk);
+    M.x[1][2] = sw * ck + (cw * sp * sk);
+    M.x[2][0] = sp;
+    M.x[2][1] = -(sw * cp);
+    M.x[2][2] = cw * cp;
+
+    /* ObjSpace (&XYZ, XC,YC,ZC, X,Y,Z); */
+    XYZ.x[0][0] = e1 - XC;
+    XYZ.x[1][0] = n1 - YC;
+    XYZ.x[2][0] = z1 - ZC;
+
+    m_mult(&M, &XYZ, &UVW);
+
+    /* Image Space */
+    U = UVW.x[0][0];
+    V = UVW.x[1][0];
+    W = UVW.x[2][0];
+
+    /* This is the solution */
+    *e2 = (-CFL) * (U / W);
+    *n2 = (-CFL) * (V / W);
+    return (1);
+}
+
+/* given the photo coordiantes (e1,n1) and elevation z2  */
+/* and the solution from I_compute_ortho_equation */
+/* compute ground position (e2,n2) */
+int I_inverse_ortho_ref(double e1, double n1, double z1,
+			double *e2, double *n2, double *z2,
+			struct Ortho_Camera_File_Ref *cam_info,
+			double XC, double YC, double ZC,
+			double Omega, double Phi, double Kappa)
+{
+    MATRIX UVW, XYZ, M;
+    double lam, mu, nu;
+    double Xp, Yp, CFL;
+    double sw, cw, sp, cp, sk, ck;
+
+    /*  Initialize and zero matrices */
+    /*  Object Space Coordinates */
+    XYZ.nrows = 3;
+    XYZ.ncols = 1;
+    zero(&XYZ);
+    /*  Image Space coordinates */
+    UVW.nrows = 3;
+    UVW.ncols = 1;
+    zero(&UVW);
+    /*  Orientation Matrix */
+    M.nrows = 3;
+    M.ncols = 3;
+    zero(&M);
+
+    /********************** Start the work ********************************/
+    /* set Xp, Yp, and CFL form cam_info */
+    Xp = cam_info->Xp;
+    Yp = cam_info->Yp;
+    CFL = cam_info->CFL;
+
+    /* Compute Orientation Matrix (Omega, Phi, Kappa); */
+    sw = sin(Omega);
+    cw = cos(Omega);
+    sp = sin(Phi);
+    cp = cos(Phi);
+    sk = sin(Kappa);
+    ck = cos(Kappa);
+
+    /* M Transposed */
+    M.x[0][0] = cp * ck;
+    M.x[1][0] = cw * sk + (sw * sp * ck);
+    M.x[2][0] = sw * sk - (cw * sp * ck);
+    M.x[0][1] = -(cp * sk);
+    M.x[1][1] = cw * ck - (sw * sp * sk);
+    M.x[2][1] = sw * ck + (cw * sp * sk);
+    M.x[0][2] = sp;
+    M.x[1][2] = -(sw * cp);
+    M.x[2][2] = cw * cp;
+
+    /* ImageSpace */
+    UVW.x[0][0] = e1 - Xp;
+    UVW.x[1][0] = n1 - Yp;
+    UVW.x[2][0] = -CFL;
+
+    m_mult(&M, &UVW, &XYZ);
+
+    /* Image Space */
+    lam = XYZ.x[0][0];
+    mu = XYZ.x[1][0];
+    nu = XYZ.x[2][0];
+
+    /* This is the solution */
+    *e2 = ((z1 - ZC) * (lam / nu)) + XC;
+    *n2 = ((z1 - ZC) * (mu / nu)) + YC;
+
+    return (1);
+}
+
+int matrix_error(char *s)
+{
+    fprintf(stderr, "WARNING: %s", s);
+#ifdef DEBUG
+    fclose(debug);
+#endif
+    return 0;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/ref_points.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/ref_points.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/ref_points.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,134 +0,0 @@
-
-/***********************************************************************
- * I_get_ref_points()
- * I_put_ref_points()
- **********************************************************************/
-#include "orthophoto.h"
-#include <grass/imagery.h>
-
-#define REF_POINT_FILE "REF_POINTS"
-
-int I_read_ref_points(FILE * fd, struct Ortho_Photo_Points *cp)
-{
-    char buf[100];
-    double e1, e2, n1, n2;
-    int status;
-
-    cp->count = 0;
-
-    /* read the reference point lines. format is:
-       image_east image_north  photo_x photo_y  status(1=ok)
-     */
-    cp->e1 = NULL;
-    cp->e2 = NULL;
-    cp->n1 = NULL;
-    cp->n2 = NULL;
-    cp->status = NULL;
-
-    /*fprintf (stderr, "Try to read one point \n"); */
-    while (G_getl(buf, sizeof(buf), fd)) {
-	G_strip(buf);
-	if (*buf == '#' || *buf == 0)
-	    continue;
-	if (sscanf(buf, "%lf%lf%lf%lf%d", &e1, &n1, &e2, &n2, &status) == 5)
-	    I_new_ref_point(cp, e1, n1, e2, n2, status);
-	else
-	    return -4;
-    }
-
-    return 1;
-}
-
-int
-I_new_ref_point(struct Ortho_Photo_Points *cp, double e1, double n1,
-		double e2, double n2, int status)
-{
-    int i;
-    size_t size;
-
-    /*fprintf (stderr, "Try to new_ref_point \n"); */
-    if (status < 0)
-	return 0;
-    i = (cp->count)++;
-    size = cp->count * sizeof(double);
-    cp->e1 = (double *)G_realloc(cp->e1, size);
-    cp->e2 = (double *)G_realloc(cp->e2, size);
-    cp->n1 = (double *)G_realloc(cp->n1, size);
-    cp->n2 = (double *)G_realloc(cp->n2, size);
-    size = cp->count * sizeof(int);
-    cp->status = (int *)G_realloc(cp->status, size);
-
-    cp->e1[i] = e1;
-    cp->e2[i] = e2;
-    cp->n1[i] = n1;
-    cp->n2[i] = n2;
-    cp->status[i] = status;
-
-    return 0;
-}
-
-int I_write_ref_points(FILE * fd, struct Ortho_Photo_Points *cp)
-{
-    int i;
-
-    fprintf(fd, "# %7s %15s %15s %15s %9s status\n", "", "image", "", "photo",
-	    "");
-    fprintf(fd, "# %15s %15s %15s %15s   (1=ok)\n", "east", "north", "x",
-	    "y");
-    fprintf(fd, "#\n");
-    for (i = 0; i < cp->count; i++)
-	if (cp->status[i] >= 0)
-	    fprintf(fd, "  %15f %15f %15f %15f %d\n",
-		    cp->e1[i], cp->n1[i], cp->e2[i], cp->n2[i],
-		    cp->status[i]);
-
-    return 0;
-}
-
-int I_get_ref_points(char *groupname, struct Ortho_Photo_Points *cp)
-{
-    FILE *fd;
-    char msg[100];
-    int stat;
-
-    /*fprintf (stderr, "Try to f_open_group_file_old \n"); */
-    fd = I_fopen_group_file_old(groupname, REF_POINT_FILE);
-    if (fd == NULL) {
-	sprintf(msg,
-		"unable to open reference point file for group [%s in %s]",
-		groupname, G_mapset());
-	G_warning(msg);
-	return 0;
-    }
-
-    /*fprintf (stderr, "Try to read_ref_points \n"); */
-    stat = I_read_ref_points(fd, cp);
-    fclose(fd);
-    if (stat < 0) {
-	sprintf(msg,
-		"bad format in reference point file for group [%s in %s]",
-		groupname, G_mapset());
-	G_warning(msg);
-	return 0;
-    }
-    return 1;
-}
-
-int I_put_ref_points(char *groupname, struct Ortho_Photo_Points *cp)
-{
-    FILE *fd;
-    char msg[100];
-
-    fd = I_fopen_group_file_new(groupname, REF_POINT_FILE);
-    if (fd == NULL) {
-	sprintf(msg,
-		"unable to create reference point file for group [%s in %s]",
-		groupname, G_mapset());
-	G_warning(msg);
-	return 0;
-    }
-
-    I_write_ref_points(fd, cp);
-    fclose(fd);
-    return 1;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/ref_points.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/ref_points.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/ref_points.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/ref_points.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,134 @@
+
+/***********************************************************************
+ * I_get_ref_points()
+ * I_put_ref_points()
+ **********************************************************************/
+#include "orthophoto.h"
+#include <grass/imagery.h>
+
+#define REF_POINT_FILE "REF_POINTS"
+
+int I_read_ref_points(FILE * fd, struct Ortho_Photo_Points *cp)
+{
+    char buf[100];
+    double e1, e2, n1, n2;
+    int status;
+
+    cp->count = 0;
+
+    /* read the reference point lines. format is:
+       image_east image_north  photo_x photo_y  status(1=ok)
+     */
+    cp->e1 = NULL;
+    cp->e2 = NULL;
+    cp->n1 = NULL;
+    cp->n2 = NULL;
+    cp->status = NULL;
+
+    /*fprintf (stderr, "Try to read one point \n"); */
+    while (G_getl(buf, sizeof(buf), fd)) {
+	G_strip(buf);
+	if (*buf == '#' || *buf == 0)
+	    continue;
+	if (sscanf(buf, "%lf%lf%lf%lf%d", &e1, &n1, &e2, &n2, &status) == 5)
+	    I_new_ref_point(cp, e1, n1, e2, n2, status);
+	else
+	    return -4;
+    }
+
+    return 1;
+}
+
+int
+I_new_ref_point(struct Ortho_Photo_Points *cp, double e1, double n1,
+		double e2, double n2, int status)
+{
+    int i;
+    size_t size;
+
+    /*fprintf (stderr, "Try to new_ref_point \n"); */
+    if (status < 0)
+	return 0;
+    i = (cp->count)++;
+    size = cp->count * sizeof(double);
+    cp->e1 = (double *)G_realloc(cp->e1, size);
+    cp->e2 = (double *)G_realloc(cp->e2, size);
+    cp->n1 = (double *)G_realloc(cp->n1, size);
+    cp->n2 = (double *)G_realloc(cp->n2, size);
+    size = cp->count * sizeof(int);
+    cp->status = (int *)G_realloc(cp->status, size);
+
+    cp->e1[i] = e1;
+    cp->e2[i] = e2;
+    cp->n1[i] = n1;
+    cp->n2[i] = n2;
+    cp->status[i] = status;
+
+    return 0;
+}
+
+int I_write_ref_points(FILE * fd, struct Ortho_Photo_Points *cp)
+{
+    int i;
+
+    fprintf(fd, "# %7s %15s %15s %15s %9s status\n", "", "image", "", "photo",
+	    "");
+    fprintf(fd, "# %15s %15s %15s %15s   (1=ok)\n", "east", "north", "x",
+	    "y");
+    fprintf(fd, "#\n");
+    for (i = 0; i < cp->count; i++)
+	if (cp->status[i] >= 0)
+	    fprintf(fd, "  %15f %15f %15f %15f %d\n",
+		    cp->e1[i], cp->n1[i], cp->e2[i], cp->n2[i],
+		    cp->status[i]);
+
+    return 0;
+}
+
+int I_get_ref_points(char *groupname, struct Ortho_Photo_Points *cp)
+{
+    FILE *fd;
+    char msg[100];
+    int stat;
+
+    /*fprintf (stderr, "Try to f_open_group_file_old \n"); */
+    fd = I_fopen_group_file_old(groupname, REF_POINT_FILE);
+    if (fd == NULL) {
+	sprintf(msg,
+		"unable to open reference point file for group [%s in %s]",
+		groupname, G_mapset());
+	G_warning(msg);
+	return 0;
+    }
+
+    /*fprintf (stderr, "Try to read_ref_points \n"); */
+    stat = I_read_ref_points(fd, cp);
+    fclose(fd);
+    if (stat < 0) {
+	sprintf(msg,
+		"bad format in reference point file for group [%s in %s]",
+		groupname, G_mapset());
+	G_warning(msg);
+	return 0;
+    }
+    return 1;
+}
+
+int I_put_ref_points(char *groupname, struct Ortho_Photo_Points *cp)
+{
+    FILE *fd;
+    char msg[100];
+
+    fd = I_fopen_group_file_new(groupname, REF_POINT_FILE);
+    if (fd == NULL) {
+	sprintf(msg,
+		"unable to create reference point file for group [%s in %s]",
+		groupname, G_mapset());
+	G_warning(msg);
+	return 0;
+    }
+
+    I_write_ref_points(fd, cp);
+    fclose(fd);
+    return 1;
+}

Deleted: grass/trunk/imagery/i.ortho.photo/libes/title_camera.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/title_camera.c	2008-10-21 02:27:23 UTC (rev 33943)
+++ grass/trunk/imagery/i.ortho.photo/libes/title_camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -1,29 +0,0 @@
-#include <grass/imagery.h>
-#include <grass/ortholib.h>
-
-int I_get_cam_title(char *camera, char *title, int n)
-{
-    FILE *fd;
-
-    *title = 0;
-    G_suppress_warnings(1);
-    fd = I_fopen_cam_file_old(camera);
-    G_suppress_warnings(0);
-    if (fd != NULL) {
-	G_getl(title, n, fd);
-	fclose(fd);
-    }
-    return fd != NULL;
-}
-
-int I_put_camera_title(char *camera, char *title)
-{
-    FILE *fd;
-
-    fd = I_fopen_cam_file_new(camera);
-    if (fd != NULL) {
-	fprintf(fd, "%s\n", title);
-	fclose(fd);
-    }
-    return fd != NULL;
-}

Copied: grass/trunk/imagery/i.ortho.photo/libes/title_camera.c (from rev 33943, grass/trunk/imagery/i.ortho.photo/libes/title_camera.c)
===================================================================
--- grass/trunk/imagery/i.ortho.photo/libes/title_camera.c	                        (rev 0)
+++ grass/trunk/imagery/i.ortho.photo/libes/title_camera.c	2008-11-13 08:24:51 UTC (rev 34271)
@@ -0,0 +1,29 @@
+#include <grass/imagery.h>
+#include <grass/ortholib.h>
+
+int I_get_cam_title(char *camera, char *title, int n)
+{
+    FILE *fd;
+
+    *title = 0;
+    G_suppress_warnings(1);
+    fd = I_fopen_cam_file_old(camera);
+    G_suppress_warnings(0);
+    if (fd != NULL) {
+	G_getl(title, n, fd);
+	fclose(fd);
+    }
+    return fd != NULL;
+}
+
+int I_put_camera_title(char *camera, char *title)
+{
+    FILE *fd;
+
+    fd = I_fopen_cam_file_new(camera);
+    if (fd != NULL) {
+	fprintf(fd, "%s\n", title);
+	fclose(fd);
+    }
+    return fd != NULL;
+}



More information about the grass-commit mailing list