[GRASS-SVN] r30336 - in grass-addons: . imagery imagery/i.homography imagery/i.points.auto imagery/i.pr misc misc/m.eigensystem raster raster/r.out.netcdf raster/r.rast4d raster/r.sun_horizon vector vector/v.curvature

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Feb 24 17:17:59 EST 2008


Author: neteler
Date: 2008-02-24 17:17:58 -0500 (Sun, 24 Feb 2008)
New Revision: 30336

Added:
   grass-addons/imagery/i.homography/
   grass-addons/imagery/i.homography/Makefile
   grass-addons/imagery/i.homography/TODO
   grass-addons/imagery/i.homography/func.h
   grass-addons/imagery/i.homography/global.h
   grass-addons/imagery/i.homography/lu.c
   grass-addons/imagery/i.homography/main.c
   grass-addons/imagery/i.homography/matrix.c
   grass-addons/imagery/i.homography/open.c
   grass-addons/imagery/i.homography/pi.c
   grass-addons/imagery/i.points.auto/
   grass-addons/imagery/i.points.auto/Makefile
   grass-addons/imagery/i.points.auto/TODO
   grass-addons/imagery/i.points.auto/analyze.c
   grass-addons/imagery/i.points.auto/ask.c
   grass-addons/imagery/i.points.auto/ask_mag.c
   grass-addons/imagery/i.points.auto/call.c
   grass-addons/imagery/i.points.auto/cell.c
   grass-addons/imagery/i.points.auto/cellhd.c
   grass-addons/imagery/i.points.auto/colors.c
   grass-addons/imagery/i.points.auto/conv.c
   grass-addons/imagery/i.points.auto/curses.c
   grass-addons/imagery/i.points.auto/debug.c
   grass-addons/imagery/i.points.auto/defs.h
   grass-addons/imagery/i.points.auto/description.html
   grass-addons/imagery/i.points.auto/digit.c
   grass-addons/imagery/i.points.auto/dot.c
   grass-addons/imagery/i.points.auto/drawcell.c
   grass-addons/imagery/i.points.auto/driver.c
   grass-addons/imagery/i.points.auto/equ.c
   grass-addons/imagery/i.points.auto/find.c
   grass-addons/imagery/i.points.auto/find_points.c
   grass-addons/imagery/i.points.auto/find_points_semi.c
   grass-addons/imagery/i.points.auto/georef.c
   grass-addons/imagery/i.points.auto/globals.h
   grass-addons/imagery/i.points.auto/graphics.c
   grass-addons/imagery/i.points.auto/group.c
   grass-addons/imagery/i.points.auto/input.c
   grass-addons/imagery/i.points.auto/line.c
   grass-addons/imagery/i.points.auto/local_proto.h
   grass-addons/imagery/i.points.auto/main.c
   grass-addons/imagery/i.points.auto/mark.c
   grass-addons/imagery/i.points.auto/mouse.c
   grass-addons/imagery/i.points.auto/orig/
   grass-addons/imagery/i.points.auto/overlap_area.c
   grass-addons/imagery/i.points.auto/points.c
   grass-addons/imagery/i.points.auto/target.c
   grass-addons/imagery/i.points.auto/title.c
   grass-addons/imagery/i.points.auto/view.c
   grass-addons/imagery/i.points.auto/where.c
   grass-addons/imagery/i.points.auto/zoom.c
   grass-addons/imagery/i.points.auto/zoom_box.c
   grass-addons/imagery/i.points.auto/zoom_pnt.c
   grass-addons/imagery/i.pr/
   grass-addons/imagery/i.pr/Makefile
   grass-addons/imagery/i.pr/PRLIB/
   grass-addons/imagery/i.pr/README
   grass-addons/imagery/i.pr/TODO
   grass-addons/imagery/i.pr/doc/
   grass-addons/imagery/i.pr/i.pr_blob/
   grass-addons/imagery/i.pr/i.pr_classify/
   grass-addons/imagery/i.pr/i.pr_features/
   grass-addons/imagery/i.pr/i.pr_features_additional/
   grass-addons/imagery/i.pr/i.pr_features_extract/
   grass-addons/imagery/i.pr/i.pr_features_selection/
   grass-addons/imagery/i.pr/i.pr_model/
   grass-addons/imagery/i.pr/i.pr_sites_aggregate/
   grass-addons/imagery/i.pr/i.pr_statistics/
   grass-addons/imagery/i.pr/i.pr_subsets/
   grass-addons/imagery/i.pr/i.pr_training/
   grass-addons/imagery/i.pr/i.pr_uxb/
   grass-addons/imagery/i.pr/include/
   grass-addons/misc/m.eigensystem/
   grass-addons/misc/m.eigensystem/Makefile
   grass-addons/misc/m.eigensystem/README
   grass-addons/misc/m.eigensystem/awk.normal
   grass-addons/misc/m.eigensystem/awk.scale
   grass-addons/misc/m.eigensystem/balanc.f
   grass-addons/misc/m.eigensystem/balbak.f
   grass-addons/misc/m.eigensystem/cdiv.f
   grass-addons/misc/m.eigensystem/corr.7x7
   grass-addons/misc/m.eigensystem/elmhes.f
   grass-addons/misc/m.eigensystem/eltran.f
   grass-addons/misc/m.eigensystem/hqr.f
   grass-addons/misc/m.eigensystem/hqr2.f
   grass-addons/misc/m.eigensystem/m.eigensystem.html
   grass-addons/misc/m.eigensystem/main.f
   grass-addons/misc/m.eigensystem/matrix.7x7
   grass-addons/misc/m.eigensystem/rg.f
   grass-addons/raster/r.out.netcdf/
   grass-addons/raster/r.out.netcdf/COPYING
   grass-addons/raster/r.out.netcdf/LICENSE
   grass-addons/raster/r.out.netcdf/Makefile
   grass-addons/raster/r.out.netcdf/NEWS
   grass-addons/raster/r.out.netcdf/TODO
   grass-addons/raster/r.out.netcdf/description.html
   grass-addons/raster/r.out.netcdf/main.c
   grass-addons/raster/r.rast4d/
   grass-addons/raster/r.rast4d/QuickStart.txt
   grass-addons/raster/r.rast4d/README
   grass-addons/raster/r.rast4d/TODO
   grass-addons/raster/r.rast4d/bin/
   grass-addons/raster/r.rast4d/db/
   grass-addons/raster/r.rast4d/globals/
   grass-addons/raster/r.rast4d/lib/
   grass-addons/raster/r.rast4d/r.rast4d.init
   grass-addons/raster/r.rast4d/sql/
   grass-addons/raster/r.rast4d/test.csv
   grass-addons/raster/r.sun_horizon/
   grass-addons/raster/r.sun_horizon/r.horizon/
   grass-addons/raster/r.sun_horizon/r.sun2/
   grass-addons/vector/v.curvature/
   grass-addons/vector/v.curvature/Makefile
   grass-addons/vector/v.curvature/description.html
   grass-addons/vector/v.curvature/main.c
Removed:
   grass-addons/i.homography/
   grass-addons/i.points.auto/
   grass-addons/i.pr/
   grass-addons/imagery/i.homography/Makefile
   grass-addons/imagery/i.homography/TODO
   grass-addons/imagery/i.homography/func.h
   grass-addons/imagery/i.homography/global.h
   grass-addons/imagery/i.homography/lu.c
   grass-addons/imagery/i.homography/main.c
   grass-addons/imagery/i.homography/matrix.c
   grass-addons/imagery/i.homography/open.c
   grass-addons/imagery/i.homography/pi.c
   grass-addons/imagery/i.points.auto/Makefile
   grass-addons/imagery/i.points.auto/TODO
   grass-addons/imagery/i.points.auto/analyze.c
   grass-addons/imagery/i.points.auto/ask.c
   grass-addons/imagery/i.points.auto/ask_mag.c
   grass-addons/imagery/i.points.auto/call.c
   grass-addons/imagery/i.points.auto/cell.c
   grass-addons/imagery/i.points.auto/cellhd.c
   grass-addons/imagery/i.points.auto/colors.c
   grass-addons/imagery/i.points.auto/conv.c
   grass-addons/imagery/i.points.auto/curses.c
   grass-addons/imagery/i.points.auto/debug.c
   grass-addons/imagery/i.points.auto/defs.h
   grass-addons/imagery/i.points.auto/description.html
   grass-addons/imagery/i.points.auto/digit.c
   grass-addons/imagery/i.points.auto/dot.c
   grass-addons/imagery/i.points.auto/drawcell.c
   grass-addons/imagery/i.points.auto/driver.c
   grass-addons/imagery/i.points.auto/equ.c
   grass-addons/imagery/i.points.auto/find.c
   grass-addons/imagery/i.points.auto/find_points.c
   grass-addons/imagery/i.points.auto/find_points_semi.c
   grass-addons/imagery/i.points.auto/georef.c
   grass-addons/imagery/i.points.auto/globals.h
   grass-addons/imagery/i.points.auto/graphics.c
   grass-addons/imagery/i.points.auto/group.c
   grass-addons/imagery/i.points.auto/input.c
   grass-addons/imagery/i.points.auto/line.c
   grass-addons/imagery/i.points.auto/local_proto.h
   grass-addons/imagery/i.points.auto/main.c
   grass-addons/imagery/i.points.auto/mark.c
   grass-addons/imagery/i.points.auto/mouse.c
   grass-addons/imagery/i.points.auto/orig/
   grass-addons/imagery/i.points.auto/overlap_area.c
   grass-addons/imagery/i.points.auto/points.c
   grass-addons/imagery/i.points.auto/target.c
   grass-addons/imagery/i.points.auto/title.c
   grass-addons/imagery/i.points.auto/view.c
   grass-addons/imagery/i.points.auto/where.c
   grass-addons/imagery/i.points.auto/zoom.c
   grass-addons/imagery/i.points.auto/zoom_box.c
   grass-addons/imagery/i.points.auto/zoom_pnt.c
   grass-addons/imagery/i.pr/Makefile
   grass-addons/imagery/i.pr/PRLIB/
   grass-addons/imagery/i.pr/README
   grass-addons/imagery/i.pr/TODO
   grass-addons/imagery/i.pr/doc/
   grass-addons/imagery/i.pr/i.pr_blob/
   grass-addons/imagery/i.pr/i.pr_classify/
   grass-addons/imagery/i.pr/i.pr_features/
   grass-addons/imagery/i.pr/i.pr_features_additional/
   grass-addons/imagery/i.pr/i.pr_features_extract/
   grass-addons/imagery/i.pr/i.pr_features_selection/
   grass-addons/imagery/i.pr/i.pr_model/
   grass-addons/imagery/i.pr/i.pr_sites_aggregate/
   grass-addons/imagery/i.pr/i.pr_statistics/
   grass-addons/imagery/i.pr/i.pr_subsets/
   grass-addons/imagery/i.pr/i.pr_training/
   grass-addons/imagery/i.pr/i.pr_uxb/
   grass-addons/imagery/i.pr/include/
   grass-addons/m.eigensystem/
   grass-addons/misc/m.eigensystem/Makefile
   grass-addons/misc/m.eigensystem/README
   grass-addons/misc/m.eigensystem/awk.normal
   grass-addons/misc/m.eigensystem/awk.scale
   grass-addons/misc/m.eigensystem/balanc.f
   grass-addons/misc/m.eigensystem/balbak.f
   grass-addons/misc/m.eigensystem/cdiv.f
   grass-addons/misc/m.eigensystem/corr.7x7
   grass-addons/misc/m.eigensystem/elmhes.f
   grass-addons/misc/m.eigensystem/eltran.f
   grass-addons/misc/m.eigensystem/hqr.f
   grass-addons/misc/m.eigensystem/hqr2.f
   grass-addons/misc/m.eigensystem/m.eigensystem.html
   grass-addons/misc/m.eigensystem/main.f
   grass-addons/misc/m.eigensystem/matrix.7x7
   grass-addons/misc/m.eigensystem/rg.f
   grass-addons/r.out.netcdf/
   grass-addons/r.rast4d/
   grass-addons/r.sun_horizon/
   grass-addons/raster/r.out.netcdf/COPYING
   grass-addons/raster/r.out.netcdf/LICENSE
   grass-addons/raster/r.out.netcdf/Makefile
   grass-addons/raster/r.out.netcdf/NEWS
   grass-addons/raster/r.out.netcdf/TODO
   grass-addons/raster/r.out.netcdf/description.html
   grass-addons/raster/r.out.netcdf/main.c
   grass-addons/raster/r.rast4d/QuickStart.txt
   grass-addons/raster/r.rast4d/README
   grass-addons/raster/r.rast4d/TODO
   grass-addons/raster/r.rast4d/bin/
   grass-addons/raster/r.rast4d/db/
   grass-addons/raster/r.rast4d/globals/
   grass-addons/raster/r.rast4d/lib/
   grass-addons/raster/r.rast4d/r.rast4d.init
   grass-addons/raster/r.rast4d/sql/
   grass-addons/raster/r.rast4d/test.csv
   grass-addons/raster/r.sun_horizon/r.horizon/
   grass-addons/raster/r.sun_horizon/r.sun2/
   grass-addons/v.curvature/
   grass-addons/vector/v.curvature/Makefile
   grass-addons/vector/v.curvature/description.html
   grass-addons/vector/v.curvature/main.c
Log:
moved modules into new subdir structure

Copied: grass-addons/imagery/i.homography (from rev 30334, grass-addons/i.homography)

Deleted: grass-addons/imagery/i.homography/Makefile
===================================================================
--- grass-addons/i.homography/Makefile	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.homography/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,10 +0,0 @@
-MODULE_TOPDIR = ../..
-
-PGM = i.homography
-
-LIBES     = $(IMAGERYLIB) $(GPROJLIB) $(GISLIB) $(VASKLIB) $(CURSES) $(GMATHLIB)
-DEPENDENCIES= $(IMAGERYDEP) $(GPROJDEP) $(GISDEP) $(VASKDEP) $(GMATHDEP)
-
-include $(MODULE_TOPDIR)/include/Make/Module.make
-
-default: cmd

Copied: grass-addons/imagery/i.homography/Makefile (from rev 30335, grass-addons/i.homography/Makefile)
===================================================================
--- grass-addons/imagery/i.homography/Makefile	                        (rev 0)
+++ grass-addons/imagery/i.homography/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,10 @@
+MODULE_TOPDIR = ../..
+
+PGM = i.homography
+
+LIBES     = $(IMAGERYLIB) $(GPROJLIB) $(GISLIB) $(VASKLIB) $(CURSES) $(GMATHLIB)
+DEPENDENCIES= $(IMAGERYDEP) $(GPROJDEP) $(GISDEP) $(VASKDEP) $(GMATHDEP)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd

Deleted: grass-addons/imagery/i.homography/TODO
===================================================================
--- grass-addons/i.homography/TODO	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.homography/TODO	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,6 +0,0 @@
-Compile with
-  make MODULE_TOPDIR=$HOME/grass63/
-
-TODO
-
-Code based on GRASS 5. To be updated to GRASS 6.

Copied: grass-addons/imagery/i.homography/TODO (from rev 30335, grass-addons/i.homography/TODO)
===================================================================
--- grass-addons/imagery/i.homography/TODO	                        (rev 0)
+++ grass-addons/imagery/i.homography/TODO	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,6 @@
+Compile with
+  make MODULE_TOPDIR=$HOME/grass63/
+
+TODO
+
+Code based on GRASS 5. To be updated to GRASS 6.

Deleted: grass-addons/imagery/i.homography/func.h
===================================================================
--- grass-addons/i.homography/func.h	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.homography/func.h	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,191 +0,0 @@
-/*
-bootstrap.c
-*/
-
-int Bootsamples();
-
-/*
-random.c
-*/
-
-double ran1();
-double gasdev();
-
-/*
-blob.c
-*/
-
-void extract_sites_from_blob();
-void find_blob();
-
-/*
-tree.c
-*/
-
-int  build_maximal_tree();
-void write_tree();
-int read_tree();
-int godown();
-void write_Btree();
-int read_Btree();
-double evaluateB();
-int evaluateB_multiclass();
-void classify_image_TREE();
-
-/*
-training.c
-*/
-
-void build_training();
-
-/*
-percent.c
-*/
-
-void percent ();
-
-/*
-open.c
-*/
-
-int open_new_CELL();
-int open_new_DCELL();
-
-/*
-pca.c
-*/
-
-void alloc_pca();
-void write_pca();
-void read_pca();
-
-/*
-dist.c
-*/
-
-double squared_distance();
-double euclidean_distance();
-double scalar_product();
-double euclidean_norm();
-
-/*
-getline.c
-*/
-
-char *GetLine();
-
-/*
-pi.c
-*/
-
-void linear_solve();
-
-/*
-read_list.c
-*/
-
-void read_list_of_type_1_and_load_raster_maps();
-void read_list_of_type_2();
-void read_list_of_type_2_and_load_raster_maps();
-int read_list_of_sites();
-
-/*
-filter.c
-*/
-
-void write_filter();
-void read_filter();
-
-/*
-test.c
-*/
-
-void ksone_normal();
-void kstwo();
-double normal_distribution();
-double cumulative_normal_distribution();
-
-/*
-nn.c
-*/
-
-void classify_image_NN();
-void write_nn();
-void read_nn();
-void compute_NN_from_training();
-void read_matrix();
-
-/*
-integration.c
-*/
-
-double trapzd();
-double trapzd1();
-double trapzd2();
-double qtrap();
-double qtrap1();
-double qtrap2();
-
-/*
-gm.c
-*/
-
-void compute_gm();
-void write_gm();
-void read_gm();
-double ComputeDelta();
-void classify_image_GM();
-
-/*
-sort.c
-*/
-
-void shell();
-void indexx_1();
-void indexx();
-
-/*
-eigen.c
-*/
-
-void tred2();
-int tqli();
-int eigen_of_double_matrix();
-void eigsrt();
-
-/*
-matrix.c
-*/
-
-void product_double_matrix_double_matrix();
-void product_double_matrix_double_vector();
-void product_double_vector_double_matrix();
-void transpose_double_matrix();
-void double_matrix_to_vector();
-void extract_portion_of_double_matrix();
-void transpose_double_matrix_rectangular();
-
-/*
-lu.c
-*/
-
-void ludcmp();
-void lubksb();
-void inverse_of_double_matrix();
-double determinant_of_double_matrix();
-
-/*
-stats.c
-*/
-
-double mean_of_double_array();
-double var_of_double_array();
-double sd_of_double_array();
-double var_of_double_array_given_mean();
-double sd_of_double_array_given_mean();
-void mean_and_var_of_double_matrix_by_row();
-void mean_and_sd_of_double_matrix_by_row();
-void mean_and_var_of_double_matrix_by_col();
-void mean_and_sd_of_double_matrix_by_col();
-double auto_covariance_of_2_double_array();
-void covariance_of_double_matrix();

Copied: grass-addons/imagery/i.homography/func.h (from rev 30335, grass-addons/i.homography/func.h)
===================================================================
--- grass-addons/imagery/i.homography/func.h	                        (rev 0)
+++ grass-addons/imagery/i.homography/func.h	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,191 @@
+/*
+bootstrap.c
+*/
+
+int Bootsamples();
+
+/*
+random.c
+*/
+
+double ran1();
+double gasdev();
+
+/*
+blob.c
+*/
+
+void extract_sites_from_blob();
+void find_blob();
+
+/*
+tree.c
+*/
+
+int  build_maximal_tree();
+void write_tree();
+int read_tree();
+int godown();
+void write_Btree();
+int read_Btree();
+double evaluateB();
+int evaluateB_multiclass();
+void classify_image_TREE();
+
+/*
+training.c
+*/
+
+void build_training();
+
+/*
+percent.c
+*/
+
+void percent ();
+
+/*
+open.c
+*/
+
+int open_new_CELL();
+int open_new_DCELL();
+
+/*
+pca.c
+*/
+
+void alloc_pca();
+void write_pca();
+void read_pca();
+
+/*
+dist.c
+*/
+
+double squared_distance();
+double euclidean_distance();
+double scalar_product();
+double euclidean_norm();
+
+/*
+getline.c
+*/
+
+char *GetLine();
+
+/*
+pi.c
+*/
+
+void linear_solve();
+
+/*
+read_list.c
+*/
+
+void read_list_of_type_1_and_load_raster_maps();
+void read_list_of_type_2();
+void read_list_of_type_2_and_load_raster_maps();
+int read_list_of_sites();
+
+/*
+filter.c
+*/
+
+void write_filter();
+void read_filter();
+
+/*
+test.c
+*/
+
+void ksone_normal();
+void kstwo();
+double normal_distribution();
+double cumulative_normal_distribution();
+
+/*
+nn.c
+*/
+
+void classify_image_NN();
+void write_nn();
+void read_nn();
+void compute_NN_from_training();
+void read_matrix();
+
+/*
+integration.c
+*/
+
+double trapzd();
+double trapzd1();
+double trapzd2();
+double qtrap();
+double qtrap1();
+double qtrap2();
+
+/*
+gm.c
+*/
+
+void compute_gm();
+void write_gm();
+void read_gm();
+double ComputeDelta();
+void classify_image_GM();
+
+/*
+sort.c
+*/
+
+void shell();
+void indexx_1();
+void indexx();
+
+/*
+eigen.c
+*/
+
+void tred2();
+int tqli();
+int eigen_of_double_matrix();
+void eigsrt();
+
+/*
+matrix.c
+*/
+
+void product_double_matrix_double_matrix();
+void product_double_matrix_double_vector();
+void product_double_vector_double_matrix();
+void transpose_double_matrix();
+void double_matrix_to_vector();
+void extract_portion_of_double_matrix();
+void transpose_double_matrix_rectangular();
+
+/*
+lu.c
+*/
+
+void ludcmp();
+void lubksb();
+void inverse_of_double_matrix();
+double determinant_of_double_matrix();
+
+/*
+stats.c
+*/
+
+double mean_of_double_array();
+double var_of_double_array();
+double sd_of_double_array();
+double var_of_double_array_given_mean();
+double sd_of_double_array_given_mean();
+void mean_and_var_of_double_matrix_by_row();
+void mean_and_sd_of_double_matrix_by_row();
+void mean_and_var_of_double_matrix_by_col();
+void mean_and_sd_of_double_matrix_by_col();
+double auto_covariance_of_2_double_array();
+void covariance_of_double_matrix();

Deleted: grass-addons/imagery/i.homography/global.h
===================================================================
--- grass-addons/i.homography/global.h	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.homography/global.h	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,212 +0,0 @@
-/*****
-      list of RASTERLISTTYPE1
-
-      name1	class1
-      name2	class2
-      ...	...
-*****/
-
-/*****
-      list of RASTERLISTTYPE2
-
-      name1	additional_name1	moments1
-      name2	additional_name2	moments2
-      ...	...			...
-*****/
-
-/*****
-      classification CLASSIFICATION1
-
-      given a list RASTERLISTTYPE1, optionally build a filter,
-      build the pca model, transform data in pc space,
-      compute a gaussian mixture
-*****/
-
-/*****
-      classification CLASSIFICATION2
-
-      given a list RASTERLISTTYPE2, use a list of sites as training,
-      build a window round each site, using the moments compute mean
-      or mean and var of the value of the raster maps within the
-      window to form predictor variables, compute a gaussian mixture
-      or a nearest neighbour model
-*****/
-
-
-#include "gis.h"
-#include "func.h"
-#include "site.h"
-
-#define PIG 3.141593
-
-#define TRUE 1
-#define FALSE 0
-
-#define GaussianMixture 1
-#define NearestNeighbour 2
-
-#define TREE 1
-#define BOOSTING 2
-#define BAGGING 3
-
-typedef struct
-/*manegement of  list of type 1*/
-{
-  char **mapnames; /*array of raster map names*/
-  char **mapclass; /*class of each raster map*/
-  int nsamples; /*number of raster map*/
-  int rows; /*rows number of each raster map*/
-  int cols; /*cols number of each raster map*/
-  double **samples; /*for each map, the values of the map stored in an array
-		      of length rows x cols*/
-} Maps;
-
-typedef struct
-/*manegement of  list of type 2*/
-{
-  char **mapnames; /*array of raster map names*/
-  char **varnames; /*additional name for each raster map*/
-  int nvar; /*number of raster maps*/
-  int rows; /*rows number of each raster map*/
-  int cols; /*cols number of each raster map*/
-  int *moments; /*for each map, the number of moments of the distribution 
-		  to be considered for the classification:
-		  1 = mean
-		  2 = mean and var*/
-  double ***mapvalues; /*for each map, the values of the map stored in a matrix
-			 of dimension rows x cols*/
-} Variables;
-
-typedef struct
-/*manegement of lists of site files*/
-{
-  char *name; /*name of site file*/
-  Site **sites; /*sites contained within the site file*/
-  int nsites; /*number of sites*/
-} ListSite;
-
-
-typedef struct
-/*filter structure, usually considered as average of matricial examples
-  (usually small raster maps)*/
-{
-  int rows;  /*rows number of the filter*/
-  int cols;  /*cols number of the filter*/
-  double **values; /*values of the filter, stored in a matrix
-		     of dimension rows x cols*/
-} Filter;
-
-typedef struct
-/*principal components structure. Examples are in matricial form 
-    (usually small raster maps) but matricial examples are here 
-    considered as array of length rows x cols*/
-{
-  int rows; /*rows number of the raster maps used to build the PC model*/
-  int cols; /*cols number of the raster maps used to build the PC model*/
-  double *mean; /*the mean value of the examples, stored in an
-		  array of dimension rows x cols*/
-  double *sd; /*the standard deviation of the examples, stored in an
-		array of dimension rows x cols*/
-  double **covar; /*covariance matrix of the examples, stored in a
-		    matrix of dimension (rows x cols)^2*/
-  double *eigval; /*eigenvalues of the covariance matrix*/
-  double **eigmat; /*eigenvectors matrix of the covariance matrix.
-		     Each column is the eigenvector corresponding to  
-		     an eigenvalues*/
-  int correlation; /*boolean:
-		     0 = covariance matrix computed
-		     1 = correlation matrix computed*/
-  int standardize; /*boolean:
-		     0 = examples are not standardized
-		     1 = examples are standardized: E <- (E-mean(E))/sd(E)*/
-} Pca;
-
-typedef struct
-/*gaussian mixture models structure*/
-{
-  int nclasses; /*number of classes*/
-  char **classes; /*array of the class names*/
-  int *nsamples; /*number of examples contained in each class*/
-  int nvars; /*number of predictor variables*/
-  double **mean; /*for each class, the mean value of the examples stored
-		   in an array of length nvars*/
-  double ***covar; /*for each class, the covariance matrix of the esamples
-		     stored in a matrix of dimension nvars x nvars*/
-  double ***inv_covar; /*for each class, the inverse of the covariance matrix
-			 stored in a matrix of dimension nvars x nvars*/
-  double *priors; /* prior probabilities of each class*/
-  double *det; /*for each class, the determinant of the inverse of the
-		 covariance matrix*/
-} NormalModel;
-
-typedef struct
-/*Non-intuitive structure: is almost always derived from 
-  the ListSite and Variables structures*/
-{
-  int nclasses; /*number of classes*/
-  int *number_of_data_for_class; /*number of elements of each class*/
-  int rows; /*rows number to be considered for building the window 
-	      around each site*/
-  int cols;  /*cols number to be considered for building the window 
-	       around each site*/
-  int nsites; /*number of sites*/
-  double ****trdata; /*for each raster map, for each class, 
-		       for each sample within the class, 
-		       the values of the raster map contained within the 
-		       window and stored in an array of length rows*cols
-		       = window size */
-} Training;
-
-typedef struct
-/*nearest neighbour structure*/
-{
-  int nsites; /*number of examples*/
-  int nvar; /*number of predictor variables*/
-  double **values; /* for each example, the values of the predictors*/
-  char **classes; /* array of the classes of each example*/
-  int *num_classes; /*array of the classes of each example
-		      in integer format (for compatibility)*/
-} NN;
-
-typedef struct
-{
-  double **data;
-  char **classes;
-  int npoints;
-  int nvar;
-
-  int nclasses;
-  
-  
-  int *npoints_for_class;
-  double *priors;
-  char *class;
-
-
-  int terminal;
-
-  int left;
-  int right;
-  int var;
-  double value;
-} Node;
-
-typedef struct
-/*indeces of a matrix (row,col) and blob thay belog to (number)*/
-{
-  int row; /*row index of a point belonging to a blob*/
-  int col; /*row index of a point belonging to a blob*/ 
-  int number /* blob number the point belong to*/;
-} Blob;
-
-typedef struct
-/*geographical coordinates of the center of a blob and minimum 
-  value of the blob itself*/
-{
-  double east; /*east value of the center*/
-  double north; /*north value of the center*/
-  double min; /*minimum value of the blob*/
-  int n; /*number of points whitin the blob*/
-} BlobSites;
-
-

Copied: grass-addons/imagery/i.homography/global.h (from rev 30335, grass-addons/i.homography/global.h)
===================================================================
--- grass-addons/imagery/i.homography/global.h	                        (rev 0)
+++ grass-addons/imagery/i.homography/global.h	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,212 @@
+/*****
+      list of RASTERLISTTYPE1
+
+      name1	class1
+      name2	class2
+      ...	...
+*****/
+
+/*****
+      list of RASTERLISTTYPE2
+
+      name1	additional_name1	moments1
+      name2	additional_name2	moments2
+      ...	...			...
+*****/
+
+/*****
+      classification CLASSIFICATION1
+
+      given a list RASTERLISTTYPE1, optionally build a filter,
+      build the pca model, transform data in pc space,
+      compute a gaussian mixture
+*****/
+
+/*****
+      classification CLASSIFICATION2
+
+      given a list RASTERLISTTYPE2, use a list of sites as training,
+      build a window round each site, using the moments compute mean
+      or mean and var of the value of the raster maps within the
+      window to form predictor variables, compute a gaussian mixture
+      or a nearest neighbour model
+*****/
+
+
+#include "gis.h"
+#include "func.h"
+#include "site.h"
+
+#define PIG 3.141593
+
+#define TRUE 1
+#define FALSE 0
+
+#define GaussianMixture 1
+#define NearestNeighbour 2
+
+#define TREE 1
+#define BOOSTING 2
+#define BAGGING 3
+
+typedef struct
+/*manegement of  list of type 1*/
+{
+  char **mapnames; /*array of raster map names*/
+  char **mapclass; /*class of each raster map*/
+  int nsamples; /*number of raster map*/
+  int rows; /*rows number of each raster map*/
+  int cols; /*cols number of each raster map*/
+  double **samples; /*for each map, the values of the map stored in an array
+		      of length rows x cols*/
+} Maps;
+
+typedef struct
+/*manegement of  list of type 2*/
+{
+  char **mapnames; /*array of raster map names*/
+  char **varnames; /*additional name for each raster map*/
+  int nvar; /*number of raster maps*/
+  int rows; /*rows number of each raster map*/
+  int cols; /*cols number of each raster map*/
+  int *moments; /*for each map, the number of moments of the distribution 
+		  to be considered for the classification:
+		  1 = mean
+		  2 = mean and var*/
+  double ***mapvalues; /*for each map, the values of the map stored in a matrix
+			 of dimension rows x cols*/
+} Variables;
+
+typedef struct
+/*manegement of lists of site files*/
+{
+  char *name; /*name of site file*/
+  Site **sites; /*sites contained within the site file*/
+  int nsites; /*number of sites*/
+} ListSite;
+
+
+typedef struct
+/*filter structure, usually considered as average of matricial examples
+  (usually small raster maps)*/
+{
+  int rows;  /*rows number of the filter*/
+  int cols;  /*cols number of the filter*/
+  double **values; /*values of the filter, stored in a matrix
+		     of dimension rows x cols*/
+} Filter;
+
+typedef struct
+/*principal components structure. Examples are in matricial form 
+    (usually small raster maps) but matricial examples are here 
+    considered as array of length rows x cols*/
+{
+  int rows; /*rows number of the raster maps used to build the PC model*/
+  int cols; /*cols number of the raster maps used to build the PC model*/
+  double *mean; /*the mean value of the examples, stored in an
+		  array of dimension rows x cols*/
+  double *sd; /*the standard deviation of the examples, stored in an
+		array of dimension rows x cols*/
+  double **covar; /*covariance matrix of the examples, stored in a
+		    matrix of dimension (rows x cols)^2*/
+  double *eigval; /*eigenvalues of the covariance matrix*/
+  double **eigmat; /*eigenvectors matrix of the covariance matrix.
+		     Each column is the eigenvector corresponding to  
+		     an eigenvalues*/
+  int correlation; /*boolean:
+		     0 = covariance matrix computed
+		     1 = correlation matrix computed*/
+  int standardize; /*boolean:
+		     0 = examples are not standardized
+		     1 = examples are standardized: E <- (E-mean(E))/sd(E)*/
+} Pca;
+
+typedef struct
+/*gaussian mixture models structure*/
+{
+  int nclasses; /*number of classes*/
+  char **classes; /*array of the class names*/
+  int *nsamples; /*number of examples contained in each class*/
+  int nvars; /*number of predictor variables*/
+  double **mean; /*for each class, the mean value of the examples stored
+		   in an array of length nvars*/
+  double ***covar; /*for each class, the covariance matrix of the esamples
+		     stored in a matrix of dimension nvars x nvars*/
+  double ***inv_covar; /*for each class, the inverse of the covariance matrix
+			 stored in a matrix of dimension nvars x nvars*/
+  double *priors; /* prior probabilities of each class*/
+  double *det; /*for each class, the determinant of the inverse of the
+		 covariance matrix*/
+} NormalModel;
+
+typedef struct
+/*Non-intuitive structure: is almost always derived from 
+  the ListSite and Variables structures*/
+{
+  int nclasses; /*number of classes*/
+  int *number_of_data_for_class; /*number of elements of each class*/
+  int rows; /*rows number to be considered for building the window 
+	      around each site*/
+  int cols;  /*cols number to be considered for building the window 
+	       around each site*/
+  int nsites; /*number of sites*/
+  double ****trdata; /*for each raster map, for each class, 
+		       for each sample within the class, 
+		       the values of the raster map contained within the 
+		       window and stored in an array of length rows*cols
+		       = window size */
+} Training;
+
+typedef struct
+/*nearest neighbour structure*/
+{
+  int nsites; /*number of examples*/
+  int nvar; /*number of predictor variables*/
+  double **values; /* for each example, the values of the predictors*/
+  char **classes; /* array of the classes of each example*/
+  int *num_classes; /*array of the classes of each example
+		      in integer format (for compatibility)*/
+} NN;
+
+typedef struct
+{
+  double **data;
+  char **classes;
+  int npoints;
+  int nvar;
+
+  int nclasses;
+  
+  
+  int *npoints_for_class;
+  double *priors;
+  char *class;
+
+
+  int terminal;
+
+  int left;
+  int right;
+  int var;
+  double value;
+} Node;
+
+typedef struct
+/*indeces of a matrix (row,col) and blob thay belog to (number)*/
+{
+  int row; /*row index of a point belonging to a blob*/
+  int col; /*row index of a point belonging to a blob*/ 
+  int number /* blob number the point belong to*/;
+} Blob;
+
+typedef struct
+/*geographical coordinates of the center of a blob and minimum 
+  value of the blob itself*/
+{
+  double east; /*east value of the center*/
+  double north; /*north value of the center*/
+  double min; /*minimum value of the blob*/
+  int n; /*number of points whitin the blob*/
+} BlobSites;
+
+

Deleted: grass-addons/imagery/i.homography/lu.c
===================================================================
--- grass-addons/i.homography/lu.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.homography/lu.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,192 +0,0 @@
-/*
-  Some of the following routines are borrowed from "Numerical Recipes in C"
-  other are written and tested by Stefano Merler
-
-  for
-  
-  LU matrix decomposition, linear equation solution (Ax=b), inversion
-  of matrices and deteminant computation
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-
-
-#define CTINY 1.0e-32
-
-void ludcmp(a,n,indx,d)
-     /*
-       LU decomposition of n x n matrix a.
-     */
-     int n,*indx;
-     double **a,*d;
-{
-  int i,imax=0,j,k;
-  double big,dum,sum,temp;
-  double *vv;
-
-  vv=(double *)calloc(n,sizeof(double));
-  *d=1.0;
-  for (i=0;i<n;i++)
-    {
-      big=0;
-      for (j=0;j<n;j++)
-	if ((temp=fabs(a[i][j]))>big) big=temp;
-      if (big==0.0)
-	{	fprintf(stderr,"Singular matrix in routine ludcmp\n");
-	exit(1);
-	}
-      vv[i]=1.0/big;
-    }
-  for (j=0;j<n;j++)
-    {
-      for (i=0;i<j;i++)
-	{
-	  sum=a[i][j];
-	  for (k=0;k<i;k++) sum -= a[i][k]*a[k][j];
-	  a[i][j]=sum;
-	}
-      big=0.0;
-      for (i=j;i<n;i++)
-	{
-	  sum=a[i][j];
-	  for (k=0;k<j;k++) sum -= a[i][k]*a[k][j];
-	  a[i][j]=sum;
-	  if ((dum=vv[i]*fabs(sum))>=big)
-	    {
-	      big=dum;
-	      imax=i;
-	    }
-	}
-      if (j!=imax)
-	{
-	  for (k=0;k<n;k++)
-	    {
-	      dum=a[imax][k];
-	      a[imax][k]=a[j][k];
-	      a[j][k]=dum;
-	    }
-	  *d= -(*d);
-	  vv[imax]=vv[j];
-	}
-      indx[j]=imax;
-      if (a[j][j]==0.0) a[j][j]=CTINY;
-      if (j!=n)
-	{
-	  dum=1.0/a[j][j];
-	  for (i=j+1;i<n;i++) a[i][j]*=dum;
-	}
-    }
-  free(vv);
-}
-
-#undef CTINY 
-
-
-void lubksb(a,n,indx,b)
-     /* 
-	Solve linear equation Ax=B
-	a has to be a LU decomposed n x n matrix, and indx 
-	is usually the output of ludcmp.
-	On output, b contains the solution
-     */
-     double **a,b[];
-     int n,*indx;
-{
-  int i,ii= -1,ip,j;
-  double sum;
-
-  for (i=0;i<n;i++)
-    {
-      ip=indx[i];
-      sum=b[ip];
-      b[ip]=b[i];
-      if (ii>=0)
-	for (j=ii;j<=i-1;j++) sum -=a[i][j]*b[j];
-      else if (sum!=0.0) ii=i;
-      b[i]=sum;
-    }
-  for (i=n-1;i>=0;i--)
-    {
-      sum=b[i];
-      for (j=i+1;j<n;j++) sum -= a[i][j]*b[j];
-      b[i]=sum/a[i][i];
-    }
-}
-
-void inverse_of_double_matrix(A,inv_A,n)
-     /* 
-	Inverse of a matrix A of dimension n x n.
-	Output stoed in inv_A
-     */	
-     double **A,**inv_A;
-     int n;
-{
-  double d,*col, **tmpA;
-  int i,j,*indx;
-
-  tmpA=(double**)calloc(n, sizeof(double*));
-  for (j=0;j<n;j++)
-    tmpA[j]=(double*)calloc(n,  sizeof(double));
-
-  for (j=0;j<n;j++)
-    for (i=0;i<n;i++)
-      tmpA[j][i]=A[j][i];
-		
-  col=(double *)calloc(n,sizeof(double));
-  indx=(int *)calloc(n,sizeof(int));
-
-  ludcmp(tmpA,n,indx,&d);
-  for (j=0;j<n;j++)
-    {
-      for (i=0;i<n;i++)
-	col[i]=0;
-      col[j]=1;
-      lubksb(tmpA,n,indx,col);
-      for (i=0;i<n;i++)
-	inv_A[i][j]=col[i];
-    }
-
-  free(col);
-  free(indx);
-  for (j=0;j<n;j++)
-    free(tmpA[j]);
-  free(tmpA);
-	
-}
-
-double determinant_of_double_matrix(A,n)
-     /* 
-	determinant of a double matrix A of dimension n x n
-     */
-     double **A;
-     int n;
-{
-  double d, **tmpA;
-  int i,j,*indx;
-	
-  tmpA=(double**)calloc(n, sizeof(double*));
-  for (j=0;j<n;j++)
-    tmpA[j]=(double*)calloc(n,  sizeof(double));
-
-  for (j=0;j<n;j++)
-    for (i=0;i<n;i++)
-      tmpA[j][i]=A[j][i];
-		
-  indx=(int *)calloc(n,sizeof(int));
-
-  ludcmp(tmpA,n,indx,&d);
-
-  for (j=0;j<n;j++) 
-    d *= tmpA[j][j];
- 
-  free(indx);
-  for (j=0;j<n;j++)
-    free(tmpA[j]);
-  free(tmpA);
-	
-  return(d);
-	
-}
-

Copied: grass-addons/imagery/i.homography/lu.c (from rev 30335, grass-addons/i.homography/lu.c)
===================================================================
--- grass-addons/imagery/i.homography/lu.c	                        (rev 0)
+++ grass-addons/imagery/i.homography/lu.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,192 @@
+/*
+  Some of the following routines are borrowed from "Numerical Recipes in C"
+  other are written and tested by Stefano Merler
+
+  for
+  
+  LU matrix decomposition, linear equation solution (Ax=b), inversion
+  of matrices and deteminant computation
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+#define CTINY 1.0e-32
+
+void ludcmp(a,n,indx,d)
+     /*
+       LU decomposition of n x n matrix a.
+     */
+     int n,*indx;
+     double **a,*d;
+{
+  int i,imax=0,j,k;
+  double big,dum,sum,temp;
+  double *vv;
+
+  vv=(double *)calloc(n,sizeof(double));
+  *d=1.0;
+  for (i=0;i<n;i++)
+    {
+      big=0;
+      for (j=0;j<n;j++)
+	if ((temp=fabs(a[i][j]))>big) big=temp;
+      if (big==0.0)
+	{	fprintf(stderr,"Singular matrix in routine ludcmp\n");
+	exit(1);
+	}
+      vv[i]=1.0/big;
+    }
+  for (j=0;j<n;j++)
+    {
+      for (i=0;i<j;i++)
+	{
+	  sum=a[i][j];
+	  for (k=0;k<i;k++) sum -= a[i][k]*a[k][j];
+	  a[i][j]=sum;
+	}
+      big=0.0;
+      for (i=j;i<n;i++)
+	{
+	  sum=a[i][j];
+	  for (k=0;k<j;k++) sum -= a[i][k]*a[k][j];
+	  a[i][j]=sum;
+	  if ((dum=vv[i]*fabs(sum))>=big)
+	    {
+	      big=dum;
+	      imax=i;
+	    }
+	}
+      if (j!=imax)
+	{
+	  for (k=0;k<n;k++)
+	    {
+	      dum=a[imax][k];
+	      a[imax][k]=a[j][k];
+	      a[j][k]=dum;
+	    }
+	  *d= -(*d);
+	  vv[imax]=vv[j];
+	}
+      indx[j]=imax;
+      if (a[j][j]==0.0) a[j][j]=CTINY;
+      if (j!=n)
+	{
+	  dum=1.0/a[j][j];
+	  for (i=j+1;i<n;i++) a[i][j]*=dum;
+	}
+    }
+  free(vv);
+}
+
+#undef CTINY 
+
+
+void lubksb(a,n,indx,b)
+     /* 
+	Solve linear equation Ax=B
+	a has to be a LU decomposed n x n matrix, and indx 
+	is usually the output of ludcmp.
+	On output, b contains the solution
+     */
+     double **a,b[];
+     int n,*indx;
+{
+  int i,ii= -1,ip,j;
+  double sum;
+
+  for (i=0;i<n;i++)
+    {
+      ip=indx[i];
+      sum=b[ip];
+      b[ip]=b[i];
+      if (ii>=0)
+	for (j=ii;j<=i-1;j++) sum -=a[i][j]*b[j];
+      else if (sum!=0.0) ii=i;
+      b[i]=sum;
+    }
+  for (i=n-1;i>=0;i--)
+    {
+      sum=b[i];
+      for (j=i+1;j<n;j++) sum -= a[i][j]*b[j];
+      b[i]=sum/a[i][i];
+    }
+}
+
+void inverse_of_double_matrix(A,inv_A,n)
+     /* 
+	Inverse of a matrix A of dimension n x n.
+	Output stoed in inv_A
+     */	
+     double **A,**inv_A;
+     int n;
+{
+  double d,*col, **tmpA;
+  int i,j,*indx;
+
+  tmpA=(double**)calloc(n, sizeof(double*));
+  for (j=0;j<n;j++)
+    tmpA[j]=(double*)calloc(n,  sizeof(double));
+
+  for (j=0;j<n;j++)
+    for (i=0;i<n;i++)
+      tmpA[j][i]=A[j][i];
+		
+  col=(double *)calloc(n,sizeof(double));
+  indx=(int *)calloc(n,sizeof(int));
+
+  ludcmp(tmpA,n,indx,&d);
+  for (j=0;j<n;j++)
+    {
+      for (i=0;i<n;i++)
+	col[i]=0;
+      col[j]=1;
+      lubksb(tmpA,n,indx,col);
+      for (i=0;i<n;i++)
+	inv_A[i][j]=col[i];
+    }
+
+  free(col);
+  free(indx);
+  for (j=0;j<n;j++)
+    free(tmpA[j]);
+  free(tmpA);
+	
+}
+
+double determinant_of_double_matrix(A,n)
+     /* 
+	determinant of a double matrix A of dimension n x n
+     */
+     double **A;
+     int n;
+{
+  double d, **tmpA;
+  int i,j,*indx;
+	
+  tmpA=(double**)calloc(n, sizeof(double*));
+  for (j=0;j<n;j++)
+    tmpA[j]=(double*)calloc(n,  sizeof(double));
+
+  for (j=0;j<n;j++)
+    for (i=0;i<n;i++)
+      tmpA[j][i]=A[j][i];
+		
+  indx=(int *)calloc(n,sizeof(int));
+
+  ludcmp(tmpA,n,indx,&d);
+
+  for (j=0;j<n;j++) 
+    d *= tmpA[j][j];
+ 
+  free(indx);
+  for (j=0;j<n;j++)
+    free(tmpA[j]);
+  free(tmpA);
+	
+  return(d);
+	
+}
+

Deleted: grass-addons/imagery/i.homography/main.c
===================================================================
--- grass-addons/i.homography/main.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.homography/main.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,581 +0,0 @@
-/*
-****************************************************************************
-*
-* MODULE:       i.pr.homolp
-* AUTHOR(S):    2004, Daniel Grasso, Bolzano, Italy
-*               based on code written by Stefano Merler, ITC-irst, Italy
-*               http://gisws.media.osaka-cu.ac.jp/grass04/viewpaper.php?id=37
-*
-* PURPOSE:      rectifies an image by computing a coordinate transformation
-*               for each pixel in the image based on the control points created by
-*               i.linespoints. The approach uses homography extended for corresponding
-*               lines.
-*
-* COPYRIGHT:    (C) 2004 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.
-*
-*****************************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <math.h>
-#include "gis.h"
-#include "global.h"
-#include "imagery.h"
-#include "gprojects.h"
-
-/* #define DEBUG 1 */
-
-#define ITMAX 20000
-#define CGOLD 0.3819660
-#define ZEPS 1.0e-10
-
-#define SIGN(a,b) ((b) > 0.0 ? fabs(a) : -fabs(a))
-#define SHFT(a,b,c,d) (a)=(b); (b)=(c); (c)=(d);
-
-void coords();
-void show_env();
-void select_target_env();
-void select_current_env();
-void proj();
-void georef_window ();
-void points_to_line (double e1, double n1, double e2, double n2, double *t, double *u);
-
-static int which_env = -1;
-
-static double offsetx /*= 1660000.0*/;
-static double offsety/* = 5100000.0*/;
-
-FILE *file_test;
-
-
-
-
-int main(int argc, char *argv[])
-{
-  struct Option *opt1;
-  struct Option *opt2;
-  struct Option *opt3;
-  struct Option *opt4;
-  struct Option *opt5;
-  char risp[100];
-  char *input_name;
-  char *output_name;
-  char *output_location;
-  char *output_mapset;
-  char *input_group;
-  char *data_location;
-  int i,j,k;
-  int permissions;
-  char *setname;
-  char tempbuf[1000];
-  double PROJECTIVE[9];
-  double I_PROJECTIVE[9];
-  char *input_mapset;
-  char *input_location;
-  struct Cell_head input_cellhd;
-  struct Cell_head output_cellhd;
-  int outfd,infd;
-  DCELL *output_cell;
-  CELL *rowbuf;
-  int **matrix;
-  double e,n;
-  int x,y;
-  double translated_n;
-  double translated_w;
-  struct Control_Points cp;
-  int r,c,rp;
-  double **A;
-  double *X,*Y;
-  double newE,newN;
-  double error;
-  double t1, u1,t2,u2;
-  double err_test_RMS=0;
-  double x1,y1,x2,y2,homography_x2,homography_y2, diff_x2,diff_y2;
-  double p_optimal;
-  double parziale;
-  int stampa=0;
-
-  double estimate (double parameter) {
-
-  j=0;
-  for(i=0;i<cp.count;i++)
-  {
-    if(cp.status[i]==1){
-      A[j][0]=cp.e1[i];
-      A[j][1]=cp.n1[i];
-      A[j][2]=1.0;
-      A[j][3]=0.0;
-      A[j][4]=0.0;
-      A[j][5]=0.0;
-      A[j][6]=-1.0*cp.e1[i]*cp.e2[i];
-      A[j][7]=-1.0*cp.n1[i]*cp.e2[i];
-      Y[j]=cp.e2[i];
-      A[j+1][0]=0.0;
-      A[j+1][1]=0.0;
-      A[j+1][2]=0.0;
-      A[j+1][3]=cp.e1[i];
-      A[j+1][4]=cp.n1[i];
-      A[j+1][5]=1.0;
-      A[j+1][6]=-1.0*cp.e1[i]*cp.n2[i];
-      A[j+1][7]=-1.0*cp.n1[i]*cp.n2[i];
-      Y[j+1]=cp.n2[i];
-      j += 2;
-    }
-    else if (cp.status[i]==2){
-
-      points_to_line(cp.e1[i],cp.n1[i], cp.e1[i+1],cp.n1[i+1], &t1,&u1);
-      points_to_line(cp.e2[i],cp.n2[i], cp.e2[i+1],cp.n2[i+1], &t2,&u2);
-      t1=parameter*t1;
-      u1=parameter*u1;
-      t2=parameter*t2;
-      u2=parameter*u2;
-
-      A[j][0]=t2;
-      A[j][1]=0.0;
-      A[j][2]=-1.0*(t1)*(t2)/parameter;
-      A[j][3]=u2;
-      A[j][4]=0.0;
-      A[j][5]=-1.0*(t1)*(u2)/parameter;
-      A[j][6]=parameter;
-      A[j][7]=0.0;
-      Y[j]=t1;
-      A[j+1][0]=0.0;
-      A[j+1][1]=t2;
-      A[j+1][2]=-1.0*(u1)*(t2)/parameter;
-      A[j+1][3]=0.0;
-      A[j+1][4]=u2;
-      A[j+1][5]=-1.0*(u1)*(u2)/parameter;
-      A[j+1][6]=0.0;
-      A[j+1][7]=parameter;
-      Y[j+1]=u1;
-      j += 2;
-      i++;
-    }
-  }
-
-#ifdef DEBUG
- if(stampa){
-  for(i=0;i<2*r;i++){
-    for(j=0;j<8;j++)
-      fprintf(stderr,"%e\t",A[i][j]);
-    fprintf(stderr,"%e\n",Y[i]);
-  }
- }
-#endif
-
-  linear_solve(A,Y,&X,2*r,c);
-
-  PROJECTIVE[0] = X[0];
-  PROJECTIVE[1] = X[3];
-  PROJECTIVE[2] = X[6];
-  PROJECTIVE[3] = X[1];
-  PROJECTIVE[4] = X[4];
-  PROJECTIVE[5] = X[7];
-  PROJECTIVE[6] = X[2];
-  PROJECTIVE[7] = X[5];
-  PROJECTIVE[8] = 1.0;
-
-
-
- if(stampa){
-  /*RESULTS TO STDOUT*/
-  fprintf(stdout,"Homography:\n\nx' = (%ex + %ey + %e)/(%ex + %ey + 1)\n",
-	  PROJECTIVE[0],
-	  PROJECTIVE[3],PROJECTIVE[6],PROJECTIVE[2],PROJECTIVE[5]);
-  fprintf(stdout,"y' = (%ex + %ey + %e)/(%ex + %ey + 1)\n", PROJECTIVE[1],
-	  PROJECTIVE[4],PROJECTIVE[7],PROJECTIVE[2],PROJECTIVE[5]);
- }
-
-   error = 0.0;
-  rp = 0;
-  for(i=0;i<cp.count;i++){
-    if(cp.status[i] == 1){
-      rp+= 1;
-      proj(cp.e1[i],cp.n1[i],&newE,&newN,PROJECTIVE);
-      error+=sqrt((newE-cp.e2[i])*(newE-cp.e2[i])+
-		  (newN-cp.n2[i])*(newN-cp.n2[i]));
-      }
-
-  }
- 
- if(stampa){
-  fprintf(stdout,"\n parameter determined:%g \n", parameter);
-   error =error /  rp;
-
-  fprintf(stdout,"\n Mean squared Error = %f \n",error);
-  return error;
- }
-
-}
-
-
-  /* Define the different options */
-  G_gisinit(argv[0]);
-
-  opt1              = G_define_option();
-  opt1->key         = "input";
-  opt1->type        = TYPE_STRING;
-  opt1->required    = YES;
-  opt1->gisprompt   = "old,cell,raster" ;
-  opt1->description = "input raster map to be rectified";
-
-  opt2              = G_define_option();
-  opt2->key         = "output";
-  opt2->type        = TYPE_STRING;
-  opt2->required    = YES;
-  opt2->gisprompt   = "new,cell,raster" ;
-  opt2->description = "output raster map of the rectified map";
-
-  opt3              = G_define_option();
-  opt3->key         = "location";
-  opt3->type        = TYPE_STRING;
-  opt3->required    = YES;
-  opt3->description = "location of the rectified raster map";
-
-  opt4              = G_define_option();
-  opt4->key         = "mapset";
-  opt4->type        = TYPE_STRING;
-  opt4->required    = YES;
-  opt4->description = "mapset of the rectified raster map";
-
-  opt5 = G_define_option() ;
-  opt5->key        = "group";
-  opt5->type       = TYPE_STRING;
-  opt5->required   = YES;
-  opt5->description= "input group containing points for homography computation";
-
-
-  /***** Start of main *****/
-
-  if (G_parser(argc, argv))
-    exit(-1);
-
-  input_name = opt1->answer;
-  output_name = opt2->answer;
-  output_location = opt3->answer;
-  output_mapset = opt4->answer;
-  input_group = opt5->answer;
-
-  input_mapset=G_find_cell2 (input_name, "");
-  setname = output_location ? output_mapset : G_store(G_mapset());
-  input_location=G_location();
-  data_location=G_gisdbase();
-
-  /*sprintf(tempbuf,"cp %s/%s/%s/colr/%s %s/%s/%s/colr/%s",data_location,
-	  input_location, input_mapset,input_name,data_location,
-	  output_location,output_mapset,output_name);  */
-  G_debug(3,"%s/%s/%s/cell/%s %s/%s/%s/cell/%s",data_location,
-	  input_location, input_mapset,input_name,data_location,
-	  output_location,output_mapset,output_name); 
-
-  /* READ POINTS*/
-  if(!I_find_group(input_group)){
-    fprintf(stderr,"Group %s not in current mapset\n",input_group);
-    exit(0);
-  }
-
-  I_get_control_points(input_group,&cp);
-
-#ifdef DEBUG
-  for(i=0;i<cp.count;i++){
-    fprintf(stderr,"%f %f %f %f %d\n",cp.e1[i],cp.n1[i],cp.e2[i],cp.n2[i],
-	    cp.status[i]);
-  }
-#endif
-
-
- fprintf(stdout,"\nExecute the quality test (requires file 'TEST_SET')?\n y --> yes, everything else --> no \n");
- scanf("%1c",risp);
-
- if (risp[0] == 'y')
-   {
-     file_test=fopen ("TEST_SET","r");
-     if(file_test==NULL) G_fatal_error("File 'TEST_SET' not found.");
-    }
- while (risp[0]!='\n') scanf("%1c",risp);
-
-
-
-  /*COMPUTE PROJECTIVE PARAMETERS*/
-
-  if (cp.count == 0)
-     exit(-1);
-
-/*offsetx = cp.e2[0] - 10000;
- offsety = cp.n2[0] - 10000;*/
-
-  i=0;
-  while(cp.status[i]!=1 && i < cp.count)
-        i++;
-  if(i >=cp.count && cp.status[i]!=1)
-        i=0;
-  offsetx = cp.e2[i] - cp.e1[i];
-  offsety = cp.n2[i] - cp.n1[i];
-
-  r=0;
-  for(i=0;i<cp.count;i++){
-    if(cp.status[i]==1){
-      r += 1;
-      cp.e2[i] -= offsetx;
-      cp.n2[i] -= offsety;
-
-      /*printf( " \n  i points after offset est %f e  nord %f  \n", cp.e2[i], cp.n2[i]);*/
-
-    }
-    else if (cp.status[i]==2){
-            r+=1;
-            cp.e2[i] -= offsetx;
-            cp.n2[i] -= offsety;
-            cp.e2[i+1] -= offsetx;
-            cp.n2[i+1] -= offsety;
-
-           /* printf( " \n points of lines after offset est[i=1]= %f,  nord[i=1]= %f, est[i=2] =%f, nord[i=2]= %f  \n", cp.e2[i], cp.n2[i], cp.e2[i+1], cp.n2[i+1]);*/
-           }
-    }
-
-  c=8;
-  A=(double**)G_calloc(2*r,sizeof(double*));
-  for(i=0;i<2*r;i++)
-    A[i]=(double*)G_calloc(c,sizeof(double));
-
-  Y=(double*)G_calloc(2*r,sizeof(double));
-
-  p_optimal = brent_iterate ( estimate, 1.0e3, 1.0e10, ITMAX); 
-
-  stampa =1;
-  
-  estimate (p_optimal);
-
-   fprintf(stdout,"\n Mean squared Error = %f \n",error);
-  /*fprintf(stdout,"\n number of used points = %i \n",rp);*/
-
-
-   rp=0;
-   if (file_test!=NULL) {
-  while(fgets(risp,100,file_test)!=NULL)
-  {
-    rp+=1;
-    x1=atof(strtok(risp," "));
-    y1=atof(strtok(NULL," "));
-    x2=atof(strtok(NULL," "));
-    y2=atof(strtok(NULL," "));
-    homography_x2 = ((PROJECTIVE[0]*x1 + PROJECTIVE[3] * y1 +  PROJECTIVE[6]) / (PROJECTIVE[2]*x1 + PROJECTIVE[5] * y1 + 1));
-    homography_y2 = ((PROJECTIVE[1]*x1 + PROJECTIVE[4] * y1 +  PROJECTIVE[7]) / (PROJECTIVE[2]*x1 + PROJECTIVE[5] * y1 + 1));
-    fprintf(stdout," x2=%f     y2=%f     o_x2=%f     o_y2=%f\n",x2,y2, homography_x2+offsetx,homography_y2+offsety);
-    diff_x2 = x2 -  homography_x2 - offsetx;
-    diff_y2 = y2 -  homography_y2 - offsety;
-    err_test_RMS+=((diff_x2)*(diff_x2))+((diff_y2)*(diff_y2));
-    }
-  err_test_RMS=sqrt(err_test_RMS)/rp;
-  fprintf(stdout, "test error= %f \n", err_test_RMS);
-   }
-
-
-  /*COMPUTE INVERSE PARAMETERS*/
-  I_PROJECTIVE[2]=PROJECTIVE[1]*PROJECTIVE[5] - PROJECTIVE[2]*PROJECTIVE[4];
-  I_PROJECTIVE[5]=PROJECTIVE[2]*PROJECTIVE[3] - PROJECTIVE[0]*PROJECTIVE[5];
-  I_PROJECTIVE[8]=PROJECTIVE[0]*PROJECTIVE[4] - PROJECTIVE[1]*PROJECTIVE[3];
-  I_PROJECTIVE[0]=PROJECTIVE[4]- PROJECTIVE[5]*PROJECTIVE[7];
-  I_PROJECTIVE[3]=PROJECTIVE[5]*PROJECTIVE[6]-PROJECTIVE[3];
-  I_PROJECTIVE[6]=PROJECTIVE[3]*PROJECTIVE[7] - PROJECTIVE[4]*PROJECTIVE[6];
-  I_PROJECTIVE[1]=PROJECTIVE[2]*PROJECTIVE[7]-PROJECTIVE[1];
-  I_PROJECTIVE[4]=PROJECTIVE[0]- PROJECTIVE[2]*PROJECTIVE[6];
-  I_PROJECTIVE[7]=PROJECTIVE[1]*PROJECTIVE[6] - PROJECTIVE[0]*PROJECTIVE[7];
-
-
-  /* READ INPUT MAP HEADER FILE,READ MAP TO BE TRANSFORMED
-     AND COMPUTE OUTPUT REGION*/
-  if (G_get_cellhd (input_name, input_mapset, &input_cellhd) < 0)
-        exit(-1);
-
-  G_set_window(&input_cellhd);
-  matrix=(int **)calloc(input_cellhd.rows,sizeof(int*));
-  for(i=0;i<input_cellhd.rows;i++)
-    matrix[i] = (int *)calloc(input_cellhd.cols,sizeof(int));
-  infd = G_open_cell_old(input_name, input_mapset);
-  rowbuf = G_allocate_cell_buf();
-  for(j = 0; j < input_cellhd.rows; j++){
-    if(G_get_map_row(infd, rowbuf, j) == -1){
-      sprintf(tempbuf,"error reading raster map [%s]", input_name);
-      G_fatal_error(tempbuf);
-    }
-    for(k = 0; k < input_cellhd.cols; k++){
-      matrix[j][k] =rowbuf[k];
-    }
-
-  }
-  G_close_cell(infd);
-  free(rowbuf);
-
-  /* check if target location exists etc */
-  G__setenv ("LOCATION_NAME", output_location);
-  G__setenv ("MAPSET", output_mapset);
-  permissions = G__mapset_permissions(setname);
-  if (permissions < 0)    /* can't access mapset   */
-     G_fatal_error("Mapset [%s] in output location [%s] - %s\n",
-       setname, output_location,
-       permissions == 0
-       ? "permission denied"
-       : "not found");
-
-  /****** get the output projection/zone parameters ******/
-  select_target_env();
-  G__get_window (&output_cellhd,"","WIND","PERMANENT");
-
-  georef_window (&input_cellhd, &output_cellhd, PROJECTIVE);
-
-  if(G_put_window (&output_cellhd)>=0)
-    fprintf (stdout,"Computing...\n");
-
-  /*OPEN RASTER FILE IN THE TARGET LOCATION*/
-  G_get_window (&output_cellhd);
-  G_set_window (&output_cellhd);
-  outfd = open_new_DCELL(output_name);
-  if (outfd < 0)
-    return 0;
-  output_cell=G_allocate_d_raster_buf();
-
-
-  /*COMPUTE RECTIFICATION*/
-  translated_n = output_cellhd.north - offsety;
-  translated_w = output_cellhd.west - offsetx;
-  for(i=0;i<output_cellhd.rows;i++){
-    G_zero_raster_buf(output_cell, DCELL_TYPE); /* better NULL ?! */
-    for(j=0;j<output_cellhd.cols;j++){
-      proj(translated_w + (j+0.5)*output_cellhd.ew_res,
-	   translated_n - (i+0.5)*output_cellhd.ns_res,
-	   &e,&n,I_PROJECTIVE);
-      coords(e,n,&x,&y,&input_cellhd);
-      if((x>=0)&&(x<input_cellhd.rows)&&(y>=0)&&(y<input_cellhd.cols))
-	output_cell[j]=matrix[x][y];
-    }
-    G_percent(i,output_cellhd.rows, 5);
-    G_put_d_raster_row(outfd,output_cell);
-  }
-  G_close_cell(outfd);
-
-  system(tempbuf);
-
-  return 0;
-}
-
-/*PROJECTIVE TRANSFORMATION OF A POINT*/
-void proj(e1,n1,e,n,param)
-double e1;  /* EASTINGS TO BE TRANSFORMED */
-double n1;  /* NORTHINGS TO BE TRANSFORMED */
-double *e;  /* EASTINGS TO BE TRANSFORMED */
-double *n;  /* NORTHINGS TO BE TRANSFORMED */
-double param[]; /* (Inverse) PROJECTIVE COEFFICIENTS */
-{
-  double tmp;
-  tmp = param[2] * e1 +  param[5]* n1 + param[8];
-  *e = (param[6] + param[0] * e1 + param[3] * n1)/tmp;
-  *n = (param[7] + param[1] * e1 + param[4] * n1)/tmp;
-}
-
-/*PROJECTIVE TRANSFORMATION OF A WINDOW (THE CORNERS OF A)*/
-void georef_window (w1, w2, param)
-    struct Cell_head *w1, *w2;
-    double param[];
-
-{
-    double n,e;
-
-    proj (w1->west, w1->north, &e, &n, param);
-    n += offsety;
-    e += offsetx;
-    w2->north = w2->south = n;
-    w2->west  = w2->east  = e;
-
-    proj (w1->east, w1->north, &e, &n, param);
-    n += offsety;
-    e += offsetx;
-    if (n > w2->north) w2->north = n;
-    if (n < w2->south) w2->south = n;
-    if (e > w2->east ) w2->east  = e;
-    if (e < w2->west ) w2->west  = e;
-
-    proj (w1->west, w1->south, &e, &n, param);
-    n += offsety;
-    e += offsetx;
-    if (n > w2->north) w2->north = n;
-    if (n < w2->south) w2->south = n;
-    if (e > w2->east ) w2->east  = e;
-    if (e < w2->west ) w2->west  = e;
-
-    proj (w1->east, w1->south, &e, &n, param);
-    n += offsety;
-    e += offsetx;
-    if (n > w2->north) w2->north = n;
-    if (n < w2->south) w2->south = n;
-    if (e > w2->east ) w2->east  = e;
-    if (e < w2->west ) w2->west  = e;
-
-    w2->ns_res = (w2->north - w2->south) / w1->rows;
-    w2->ew_res = (w2->east  - w2->west ) / w1->cols;
-    w2->cols=w1->cols;
-    w2->rows=w1->rows;
-}
-
-/*SELECT CURRENT ENV*/
-void select_current_env()
-{
-    if (which_env < 0)
-    {
-        G__create_alt_env();
-        which_env = 0;
-    }
-    if (which_env != 0)
-    {
-        G__switch_env();
-        which_env = 0;
-    }
-}
-
-/*SELECT TARGET ENV*/
-void select_target_env()
-{
-    if (which_env < 0)
-    {
-        G__create_alt_env();
-        which_env = 1;
-    }
-    if (which_env != 1)
-    {
-        G__switch_env();
-        which_env = 1;
-    }
-}
-/*PRINT ENV*/
-void show_env()
-{
-  fprintf (stdout,"env(%d) switch to LOCATION %s, MAPSET %s\n", which_env,
-	  G__getenv("LOCATION_NAME")==NULL ? "?" : G__getenv("LOCATION_NAME"),
-	  G__getenv("MAPSET")==NULL ? "?" : G__getenv("MAPSET"));
-  sleep(2);
-}
-
-void coords(e,n,x,y,win)
-     double e,n;
-     int *x,*y;
-     struct Cell_head *win;
-{
-  *y=(int)(e - win->west) / win->ew_res;
-  *x=(int)(win->north - n) / win->ns_res;
-}
-
-void points_to_line (double e1, double n1, double e2, double n2, double *t, double *u)
-{
-        double a,b,c;
-        a=(n1 - n2);
-        b= (e2 - e1);
-        c= (n2*e1 - n1*e2);
-        *t= a/c;
-        *u=b/c;
-   /* printf( " \n a %f  b %f  c %f  t %f  u %f  \n\n",a,b,c,*t,*u);  */
-}

Copied: grass-addons/imagery/i.homography/main.c (from rev 30335, grass-addons/i.homography/main.c)
===================================================================
--- grass-addons/imagery/i.homography/main.c	                        (rev 0)
+++ grass-addons/imagery/i.homography/main.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,581 @@
+/*
+****************************************************************************
+*
+* MODULE:       i.pr.homolp
+* AUTHOR(S):    2004, Daniel Grasso, Bolzano, Italy
+*               based on code written by Stefano Merler, ITC-irst, Italy
+*               http://gisws.media.osaka-cu.ac.jp/grass04/viewpaper.php?id=37
+*
+* PURPOSE:      rectifies an image by computing a coordinate transformation
+*               for each pixel in the image based on the control points created by
+*               i.linespoints. The approach uses homography extended for corresponding
+*               lines.
+*
+* COPYRIGHT:    (C) 2004 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.
+*
+*****************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <math.h>
+#include "gis.h"
+#include "global.h"
+#include "imagery.h"
+#include "gprojects.h"
+
+/* #define DEBUG 1 */
+
+#define ITMAX 20000
+#define CGOLD 0.3819660
+#define ZEPS 1.0e-10
+
+#define SIGN(a,b) ((b) > 0.0 ? fabs(a) : -fabs(a))
+#define SHFT(a,b,c,d) (a)=(b); (b)=(c); (c)=(d);
+
+void coords();
+void show_env();
+void select_target_env();
+void select_current_env();
+void proj();
+void georef_window ();
+void points_to_line (double e1, double n1, double e2, double n2, double *t, double *u);
+
+static int which_env = -1;
+
+static double offsetx /*= 1660000.0*/;
+static double offsety/* = 5100000.0*/;
+
+FILE *file_test;
+
+
+
+
+int main(int argc, char *argv[])
+{
+  struct Option *opt1;
+  struct Option *opt2;
+  struct Option *opt3;
+  struct Option *opt4;
+  struct Option *opt5;
+  char risp[100];
+  char *input_name;
+  char *output_name;
+  char *output_location;
+  char *output_mapset;
+  char *input_group;
+  char *data_location;
+  int i,j,k;
+  int permissions;
+  char *setname;
+  char tempbuf[1000];
+  double PROJECTIVE[9];
+  double I_PROJECTIVE[9];
+  char *input_mapset;
+  char *input_location;
+  struct Cell_head input_cellhd;
+  struct Cell_head output_cellhd;
+  int outfd,infd;
+  DCELL *output_cell;
+  CELL *rowbuf;
+  int **matrix;
+  double e,n;
+  int x,y;
+  double translated_n;
+  double translated_w;
+  struct Control_Points cp;
+  int r,c,rp;
+  double **A;
+  double *X,*Y;
+  double newE,newN;
+  double error;
+  double t1, u1,t2,u2;
+  double err_test_RMS=0;
+  double x1,y1,x2,y2,homography_x2,homography_y2, diff_x2,diff_y2;
+  double p_optimal;
+  double parziale;
+  int stampa=0;
+
+  double estimate (double parameter) {
+
+  j=0;
+  for(i=0;i<cp.count;i++)
+  {
+    if(cp.status[i]==1){
+      A[j][0]=cp.e1[i];
+      A[j][1]=cp.n1[i];
+      A[j][2]=1.0;
+      A[j][3]=0.0;
+      A[j][4]=0.0;
+      A[j][5]=0.0;
+      A[j][6]=-1.0*cp.e1[i]*cp.e2[i];
+      A[j][7]=-1.0*cp.n1[i]*cp.e2[i];
+      Y[j]=cp.e2[i];
+      A[j+1][0]=0.0;
+      A[j+1][1]=0.0;
+      A[j+1][2]=0.0;
+      A[j+1][3]=cp.e1[i];
+      A[j+1][4]=cp.n1[i];
+      A[j+1][5]=1.0;
+      A[j+1][6]=-1.0*cp.e1[i]*cp.n2[i];
+      A[j+1][7]=-1.0*cp.n1[i]*cp.n2[i];
+      Y[j+1]=cp.n2[i];
+      j += 2;
+    }
+    else if (cp.status[i]==2){
+
+      points_to_line(cp.e1[i],cp.n1[i], cp.e1[i+1],cp.n1[i+1], &t1,&u1);
+      points_to_line(cp.e2[i],cp.n2[i], cp.e2[i+1],cp.n2[i+1], &t2,&u2);
+      t1=parameter*t1;
+      u1=parameter*u1;
+      t2=parameter*t2;
+      u2=parameter*u2;
+
+      A[j][0]=t2;
+      A[j][1]=0.0;
+      A[j][2]=-1.0*(t1)*(t2)/parameter;
+      A[j][3]=u2;
+      A[j][4]=0.0;
+      A[j][5]=-1.0*(t1)*(u2)/parameter;
+      A[j][6]=parameter;
+      A[j][7]=0.0;
+      Y[j]=t1;
+      A[j+1][0]=0.0;
+      A[j+1][1]=t2;
+      A[j+1][2]=-1.0*(u1)*(t2)/parameter;
+      A[j+1][3]=0.0;
+      A[j+1][4]=u2;
+      A[j+1][5]=-1.0*(u1)*(u2)/parameter;
+      A[j+1][6]=0.0;
+      A[j+1][7]=parameter;
+      Y[j+1]=u1;
+      j += 2;
+      i++;
+    }
+  }
+
+#ifdef DEBUG
+ if(stampa){
+  for(i=0;i<2*r;i++){
+    for(j=0;j<8;j++)
+      fprintf(stderr,"%e\t",A[i][j]);
+    fprintf(stderr,"%e\n",Y[i]);
+  }
+ }
+#endif
+
+  linear_solve(A,Y,&X,2*r,c);
+
+  PROJECTIVE[0] = X[0];
+  PROJECTIVE[1] = X[3];
+  PROJECTIVE[2] = X[6];
+  PROJECTIVE[3] = X[1];
+  PROJECTIVE[4] = X[4];
+  PROJECTIVE[5] = X[7];
+  PROJECTIVE[6] = X[2];
+  PROJECTIVE[7] = X[5];
+  PROJECTIVE[8] = 1.0;
+
+
+
+ if(stampa){
+  /*RESULTS TO STDOUT*/
+  fprintf(stdout,"Homography:\n\nx' = (%ex + %ey + %e)/(%ex + %ey + 1)\n",
+	  PROJECTIVE[0],
+	  PROJECTIVE[3],PROJECTIVE[6],PROJECTIVE[2],PROJECTIVE[5]);
+  fprintf(stdout,"y' = (%ex + %ey + %e)/(%ex + %ey + 1)\n", PROJECTIVE[1],
+	  PROJECTIVE[4],PROJECTIVE[7],PROJECTIVE[2],PROJECTIVE[5]);
+ }
+
+   error = 0.0;
+  rp = 0;
+  for(i=0;i<cp.count;i++){
+    if(cp.status[i] == 1){
+      rp+= 1;
+      proj(cp.e1[i],cp.n1[i],&newE,&newN,PROJECTIVE);
+      error+=sqrt((newE-cp.e2[i])*(newE-cp.e2[i])+
+		  (newN-cp.n2[i])*(newN-cp.n2[i]));
+      }
+
+  }
+ 
+ if(stampa){
+  fprintf(stdout,"\n parameter determined:%g \n", parameter);
+   error =error /  rp;
+
+  fprintf(stdout,"\n Mean squared Error = %f \n",error);
+  return error;
+ }
+
+}
+
+
+  /* Define the different options */
+  G_gisinit(argv[0]);
+
+  opt1              = G_define_option();
+  opt1->key         = "input";
+  opt1->type        = TYPE_STRING;
+  opt1->required    = YES;
+  opt1->gisprompt   = "old,cell,raster" ;
+  opt1->description = "input raster map to be rectified";
+
+  opt2              = G_define_option();
+  opt2->key         = "output";
+  opt2->type        = TYPE_STRING;
+  opt2->required    = YES;
+  opt2->gisprompt   = "new,cell,raster" ;
+  opt2->description = "output raster map of the rectified map";
+
+  opt3              = G_define_option();
+  opt3->key         = "location";
+  opt3->type        = TYPE_STRING;
+  opt3->required    = YES;
+  opt3->description = "location of the rectified raster map";
+
+  opt4              = G_define_option();
+  opt4->key         = "mapset";
+  opt4->type        = TYPE_STRING;
+  opt4->required    = YES;
+  opt4->description = "mapset of the rectified raster map";
+
+  opt5 = G_define_option() ;
+  opt5->key        = "group";
+  opt5->type       = TYPE_STRING;
+  opt5->required   = YES;
+  opt5->description= "input group containing points for homography computation";
+
+
+  /***** Start of main *****/
+
+  if (G_parser(argc, argv))
+    exit(-1);
+
+  input_name = opt1->answer;
+  output_name = opt2->answer;
+  output_location = opt3->answer;
+  output_mapset = opt4->answer;
+  input_group = opt5->answer;
+
+  input_mapset=G_find_cell2 (input_name, "");
+  setname = output_location ? output_mapset : G_store(G_mapset());
+  input_location=G_location();
+  data_location=G_gisdbase();
+
+  /*sprintf(tempbuf,"cp %s/%s/%s/colr/%s %s/%s/%s/colr/%s",data_location,
+	  input_location, input_mapset,input_name,data_location,
+	  output_location,output_mapset,output_name);  */
+  G_debug(3,"%s/%s/%s/cell/%s %s/%s/%s/cell/%s",data_location,
+	  input_location, input_mapset,input_name,data_location,
+	  output_location,output_mapset,output_name); 
+
+  /* READ POINTS*/
+  if(!I_find_group(input_group)){
+    fprintf(stderr,"Group %s not in current mapset\n",input_group);
+    exit(0);
+  }
+
+  I_get_control_points(input_group,&cp);
+
+#ifdef DEBUG
+  for(i=0;i<cp.count;i++){
+    fprintf(stderr,"%f %f %f %f %d\n",cp.e1[i],cp.n1[i],cp.e2[i],cp.n2[i],
+	    cp.status[i]);
+  }
+#endif
+
+
+ fprintf(stdout,"\nExecute the quality test (requires file 'TEST_SET')?\n y --> yes, everything else --> no \n");
+ scanf("%1c",risp);
+
+ if (risp[0] == 'y')
+   {
+     file_test=fopen ("TEST_SET","r");
+     if(file_test==NULL) G_fatal_error("File 'TEST_SET' not found.");
+    }
+ while (risp[0]!='\n') scanf("%1c",risp);
+
+
+
+  /*COMPUTE PROJECTIVE PARAMETERS*/
+
+  if (cp.count == 0)
+     exit(-1);
+
+/*offsetx = cp.e2[0] - 10000;
+ offsety = cp.n2[0] - 10000;*/
+
+  i=0;
+  while(cp.status[i]!=1 && i < cp.count)
+        i++;
+  if(i >=cp.count && cp.status[i]!=1)
+        i=0;
+  offsetx = cp.e2[i] - cp.e1[i];
+  offsety = cp.n2[i] - cp.n1[i];
+
+  r=0;
+  for(i=0;i<cp.count;i++){
+    if(cp.status[i]==1){
+      r += 1;
+      cp.e2[i] -= offsetx;
+      cp.n2[i] -= offsety;
+
+      /*printf( " \n  i points after offset est %f e  nord %f  \n", cp.e2[i], cp.n2[i]);*/
+
+    }
+    else if (cp.status[i]==2){
+            r+=1;
+            cp.e2[i] -= offsetx;
+            cp.n2[i] -= offsety;
+            cp.e2[i+1] -= offsetx;
+            cp.n2[i+1] -= offsety;
+
+           /* printf( " \n points of lines after offset est[i=1]= %f,  nord[i=1]= %f, est[i=2] =%f, nord[i=2]= %f  \n", cp.e2[i], cp.n2[i], cp.e2[i+1], cp.n2[i+1]);*/
+           }
+    }
+
+  c=8;
+  A=(double**)G_calloc(2*r,sizeof(double*));
+  for(i=0;i<2*r;i++)
+    A[i]=(double*)G_calloc(c,sizeof(double));
+
+  Y=(double*)G_calloc(2*r,sizeof(double));
+
+  p_optimal = brent_iterate ( estimate, 1.0e3, 1.0e10, ITMAX); 
+
+  stampa =1;
+  
+  estimate (p_optimal);
+
+   fprintf(stdout,"\n Mean squared Error = %f \n",error);
+  /*fprintf(stdout,"\n number of used points = %i \n",rp);*/
+
+
+   rp=0;
+   if (file_test!=NULL) {
+  while(fgets(risp,100,file_test)!=NULL)
+  {
+    rp+=1;
+    x1=atof(strtok(risp," "));
+    y1=atof(strtok(NULL," "));
+    x2=atof(strtok(NULL," "));
+    y2=atof(strtok(NULL," "));
+    homography_x2 = ((PROJECTIVE[0]*x1 + PROJECTIVE[3] * y1 +  PROJECTIVE[6]) / (PROJECTIVE[2]*x1 + PROJECTIVE[5] * y1 + 1));
+    homography_y2 = ((PROJECTIVE[1]*x1 + PROJECTIVE[4] * y1 +  PROJECTIVE[7]) / (PROJECTIVE[2]*x1 + PROJECTIVE[5] * y1 + 1));
+    fprintf(stdout," x2=%f     y2=%f     o_x2=%f     o_y2=%f\n",x2,y2, homography_x2+offsetx,homography_y2+offsety);
+    diff_x2 = x2 -  homography_x2 - offsetx;
+    diff_y2 = y2 -  homography_y2 - offsety;
+    err_test_RMS+=((diff_x2)*(diff_x2))+((diff_y2)*(diff_y2));
+    }
+  err_test_RMS=sqrt(err_test_RMS)/rp;
+  fprintf(stdout, "test error= %f \n", err_test_RMS);
+   }
+
+
+  /*COMPUTE INVERSE PARAMETERS*/
+  I_PROJECTIVE[2]=PROJECTIVE[1]*PROJECTIVE[5] - PROJECTIVE[2]*PROJECTIVE[4];
+  I_PROJECTIVE[5]=PROJECTIVE[2]*PROJECTIVE[3] - PROJECTIVE[0]*PROJECTIVE[5];
+  I_PROJECTIVE[8]=PROJECTIVE[0]*PROJECTIVE[4] - PROJECTIVE[1]*PROJECTIVE[3];
+  I_PROJECTIVE[0]=PROJECTIVE[4]- PROJECTIVE[5]*PROJECTIVE[7];
+  I_PROJECTIVE[3]=PROJECTIVE[5]*PROJECTIVE[6]-PROJECTIVE[3];
+  I_PROJECTIVE[6]=PROJECTIVE[3]*PROJECTIVE[7] - PROJECTIVE[4]*PROJECTIVE[6];
+  I_PROJECTIVE[1]=PROJECTIVE[2]*PROJECTIVE[7]-PROJECTIVE[1];
+  I_PROJECTIVE[4]=PROJECTIVE[0]- PROJECTIVE[2]*PROJECTIVE[6];
+  I_PROJECTIVE[7]=PROJECTIVE[1]*PROJECTIVE[6] - PROJECTIVE[0]*PROJECTIVE[7];
+
+
+  /* READ INPUT MAP HEADER FILE,READ MAP TO BE TRANSFORMED
+     AND COMPUTE OUTPUT REGION*/
+  if (G_get_cellhd (input_name, input_mapset, &input_cellhd) < 0)
+        exit(-1);
+
+  G_set_window(&input_cellhd);
+  matrix=(int **)calloc(input_cellhd.rows,sizeof(int*));
+  for(i=0;i<input_cellhd.rows;i++)
+    matrix[i] = (int *)calloc(input_cellhd.cols,sizeof(int));
+  infd = G_open_cell_old(input_name, input_mapset);
+  rowbuf = G_allocate_cell_buf();
+  for(j = 0; j < input_cellhd.rows; j++){
+    if(G_get_map_row(infd, rowbuf, j) == -1){
+      sprintf(tempbuf,"error reading raster map [%s]", input_name);
+      G_fatal_error(tempbuf);
+    }
+    for(k = 0; k < input_cellhd.cols; k++){
+      matrix[j][k] =rowbuf[k];
+    }
+
+  }
+  G_close_cell(infd);
+  free(rowbuf);
+
+  /* check if target location exists etc */
+  G__setenv ("LOCATION_NAME", output_location);
+  G__setenv ("MAPSET", output_mapset);
+  permissions = G__mapset_permissions(setname);
+  if (permissions < 0)    /* can't access mapset   */
+     G_fatal_error("Mapset [%s] in output location [%s] - %s\n",
+       setname, output_location,
+       permissions == 0
+       ? "permission denied"
+       : "not found");
+
+  /****** get the output projection/zone parameters ******/
+  select_target_env();
+  G__get_window (&output_cellhd,"","WIND","PERMANENT");
+
+  georef_window (&input_cellhd, &output_cellhd, PROJECTIVE);
+
+  if(G_put_window (&output_cellhd)>=0)
+    fprintf (stdout,"Computing...\n");
+
+  /*OPEN RASTER FILE IN THE TARGET LOCATION*/
+  G_get_window (&output_cellhd);
+  G_set_window (&output_cellhd);
+  outfd = open_new_DCELL(output_name);
+  if (outfd < 0)
+    return 0;
+  output_cell=G_allocate_d_raster_buf();
+
+
+  /*COMPUTE RECTIFICATION*/
+  translated_n = output_cellhd.north - offsety;
+  translated_w = output_cellhd.west - offsetx;
+  for(i=0;i<output_cellhd.rows;i++){
+    G_zero_raster_buf(output_cell, DCELL_TYPE); /* better NULL ?! */
+    for(j=0;j<output_cellhd.cols;j++){
+      proj(translated_w + (j+0.5)*output_cellhd.ew_res,
+	   translated_n - (i+0.5)*output_cellhd.ns_res,
+	   &e,&n,I_PROJECTIVE);
+      coords(e,n,&x,&y,&input_cellhd);
+      if((x>=0)&&(x<input_cellhd.rows)&&(y>=0)&&(y<input_cellhd.cols))
+	output_cell[j]=matrix[x][y];
+    }
+    G_percent(i,output_cellhd.rows, 5);
+    G_put_d_raster_row(outfd,output_cell);
+  }
+  G_close_cell(outfd);
+
+  system(tempbuf);
+
+  return 0;
+}
+
+/*PROJECTIVE TRANSFORMATION OF A POINT*/
+void proj(e1,n1,e,n,param)
+double e1;  /* EASTINGS TO BE TRANSFORMED */
+double n1;  /* NORTHINGS TO BE TRANSFORMED */
+double *e;  /* EASTINGS TO BE TRANSFORMED */
+double *n;  /* NORTHINGS TO BE TRANSFORMED */
+double param[]; /* (Inverse) PROJECTIVE COEFFICIENTS */
+{
+  double tmp;
+  tmp = param[2] * e1 +  param[5]* n1 + param[8];
+  *e = (param[6] + param[0] * e1 + param[3] * n1)/tmp;
+  *n = (param[7] + param[1] * e1 + param[4] * n1)/tmp;
+}
+
+/*PROJECTIVE TRANSFORMATION OF A WINDOW (THE CORNERS OF A)*/
+void georef_window (w1, w2, param)
+    struct Cell_head *w1, *w2;
+    double param[];
+
+{
+    double n,e;
+
+    proj (w1->west, w1->north, &e, &n, param);
+    n += offsety;
+    e += offsetx;
+    w2->north = w2->south = n;
+    w2->west  = w2->east  = e;
+
+    proj (w1->east, w1->north, &e, &n, param);
+    n += offsety;
+    e += offsetx;
+    if (n > w2->north) w2->north = n;
+    if (n < w2->south) w2->south = n;
+    if (e > w2->east ) w2->east  = e;
+    if (e < w2->west ) w2->west  = e;
+
+    proj (w1->west, w1->south, &e, &n, param);
+    n += offsety;
+    e += offsetx;
+    if (n > w2->north) w2->north = n;
+    if (n < w2->south) w2->south = n;
+    if (e > w2->east ) w2->east  = e;
+    if (e < w2->west ) w2->west  = e;
+
+    proj (w1->east, w1->south, &e, &n, param);
+    n += offsety;
+    e += offsetx;
+    if (n > w2->north) w2->north = n;
+    if (n < w2->south) w2->south = n;
+    if (e > w2->east ) w2->east  = e;
+    if (e < w2->west ) w2->west  = e;
+
+    w2->ns_res = (w2->north - w2->south) / w1->rows;
+    w2->ew_res = (w2->east  - w2->west ) / w1->cols;
+    w2->cols=w1->cols;
+    w2->rows=w1->rows;
+}
+
+/*SELECT CURRENT ENV*/
+void select_current_env()
+{
+    if (which_env < 0)
+    {
+        G__create_alt_env();
+        which_env = 0;
+    }
+    if (which_env != 0)
+    {
+        G__switch_env();
+        which_env = 0;
+    }
+}
+
+/*SELECT TARGET ENV*/
+void select_target_env()
+{
+    if (which_env < 0)
+    {
+        G__create_alt_env();
+        which_env = 1;
+    }
+    if (which_env != 1)
+    {
+        G__switch_env();
+        which_env = 1;
+    }
+}
+/*PRINT ENV*/
+void show_env()
+{
+  fprintf (stdout,"env(%d) switch to LOCATION %s, MAPSET %s\n", which_env,
+	  G__getenv("LOCATION_NAME")==NULL ? "?" : G__getenv("LOCATION_NAME"),
+	  G__getenv("MAPSET")==NULL ? "?" : G__getenv("MAPSET"));
+  sleep(2);
+}
+
+void coords(e,n,x,y,win)
+     double e,n;
+     int *x,*y;
+     struct Cell_head *win;
+{
+  *y=(int)(e - win->west) / win->ew_res;
+  *x=(int)(win->north - n) / win->ns_res;
+}
+
+void points_to_line (double e1, double n1, double e2, double n2, double *t, double *u)
+{
+        double a,b,c;
+        a=(n1 - n2);
+        b= (e2 - e1);
+        c= (n2*e1 - n1*e2);
+        *t= a/c;
+        *u=b/c;
+   /* printf( " \n a %f  b %f  c %f  t %f  u %f  \n\n",a,b,c,*t,*u);  */
+}

Deleted: grass-addons/imagery/i.homography/matrix.c
===================================================================
--- grass-addons/i.homography/matrix.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.homography/matrix.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,162 +0,0 @@
-/*
-  The following routines are written and tested by Stefano Merler
-
-  for
-  
-  management of matrices and arrays
-
-  Supported function for 
-  - product matrix matrix or vector matrix
-  - transpose matrix
-  - conversion of matrix to array
-  - extraction of portion of matrix
-*/
-
-#include <stdio.h>
-
-void product_double_matrix_double_matrix(x,y,r,cr,c,out)
-     /*
-       product of matrices x * y, 
-       r = rows of x 
-       cr= cols of x = rows of y
-       c = cols of y
-       out is the r x c matrix. 
-     */
-     double **x, **y, **out;
-     int r,cr,c;
-{
-  int i,j,h;
- 
-  for(i=0; i<r; i++)
-    for(j=0; j<c; j++){
-      out[i][j] = .0;
-      for(h=0; h<cr; h++)
-	out[i][j] += x[i][h] * y[h][j];
-    }
-
-}
-
-
-void product_double_matrix_double_vector(x,y,r,cr,out)
-     /*
-       matrices x vector x * y, 
-       r = rows of x 
-       cr= cols of x = elements of y
-       out is the output vector (r elements) . Memory for out is not stored.
-     */
-     double **x, *y, *out;
-     int r,cr;
-{
-  int i,h;
- 
-  for(i=0; i<r; i++){
-    out[i] = .0;
-    for(h=0; h<cr; h++)
-      out[i] += x[i][h] * y[h];
-  }
-
-}	   
-
-void product_double_vector_double_matrix(x,y,rr,c,out)
-     /*
-       vector x matrix y * x, 
-       rr = rows of x = elements of y 
-       c= cols of x 
-       out is the output vector (c elements) . Memory for out is not stored.
-     */
-     double **x, *y, *out;
-     int rr,c;
-{
-  int i,h;
- 
-  for(i=0; i<c; i++){
-    out[i] = .0;
-    for(h=0; h<rr; h++)
-      out[i] += x[h][i] * y[h];
-  }
-
-}	   
-
-
-void transpose_double_matrix(x,n)
-     /*
-       transpose, and overwrite, the input matrix x 
-       of dimension n x n
-     */
-     double **x;
-     int  n;
-{
-  double **trans;
-  int i,j;
-
-  trans = (double **) calloc(n,sizeof(double *));
-  for(i=0 ; i<n ; i++)
-    trans[i] = (double *)calloc (n,sizeof(double));
-  for(i=0 ; i<n ; i++)
-    for(j=0 ; j<n ; j++)
-      trans[j][i]=x[i][j];
-  for (i=0;i<n;i++)
-    for (j=0;j<n;j++)
-      x[i][j]=trans[i][j];
-
-  for(i=0 ; i<n ; i++)
-    free(trans[i]);
-  free(trans);
-  
-}
-
-void double_matrix_to_vector(mat,rows,cols,vect)
-     /*
-       transform matrix mat of dimension rows x cols in vector
-       vect of length rows x cols.
-       matrix is scanned by row
-     */
-     double **mat;
-     int rows, cols;
-     double *vect;
-{
-  int i,j;
-  
-  for(i=0;i<rows;i++)
-    for(j=0;j<cols;j++)
-      vect[(i*cols)+j] = mat[i][j];
-}
-
-void extract_portion_of_double_matrix(r,c,br,bc,mat,wind)
-     /*
-       extract a squared portion of a matrix mat
-       given a the indeces of the center [r,c] 
-       and the semilength of the borders [br,bc]
-       Output to array wind
-     */
-     int r, c, br, bc;
-     double **mat, **wind;
-{
-  int i,j;
-  
-  for(i = 0; i < 2*br + 1;i++){
-    for(j = 0; j < 2*bc + 1;j++){
-      wind[i][j] = mat[r - br + i][c - bc +j];
-    }
-  }
-}
-
-void transpose_double_matrix_rectangular(x,n,m,trans)
-     /*
-       transpose the input matrix x  of dimension n x m
-       output to pointer to matrix trans
-     */
-     double **x,***trans;
-     int  n,m;
-{
-  int i,j;
-
-  (*trans) = (double **) calloc(m,sizeof(double *));
-  for(i=0 ; i<m ; i++)
-    (*trans)[i] = (double *)calloc (n,sizeof(double));
-
-  for(i=0 ; i<m ; i++)
-    for(j=0 ; j<n ; j++)
-      (*trans)[i][j]=x[j][i];
-
-}

Copied: grass-addons/imagery/i.homography/matrix.c (from rev 30335, grass-addons/i.homography/matrix.c)
===================================================================
--- grass-addons/imagery/i.homography/matrix.c	                        (rev 0)
+++ grass-addons/imagery/i.homography/matrix.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,162 @@
+/*
+  The following routines are written and tested by Stefano Merler
+
+  for
+  
+  management of matrices and arrays
+
+  Supported function for 
+  - product matrix matrix or vector matrix
+  - transpose matrix
+  - conversion of matrix to array
+  - extraction of portion of matrix
+*/
+
+#include <stdio.h>
+
+void product_double_matrix_double_matrix(x,y,r,cr,c,out)
+     /*
+       product of matrices x * y, 
+       r = rows of x 
+       cr= cols of x = rows of y
+       c = cols of y
+       out is the r x c matrix. 
+     */
+     double **x, **y, **out;
+     int r,cr,c;
+{
+  int i,j,h;
+ 
+  for(i=0; i<r; i++)
+    for(j=0; j<c; j++){
+      out[i][j] = .0;
+      for(h=0; h<cr; h++)
+	out[i][j] += x[i][h] * y[h][j];
+    }
+
+}
+
+
+void product_double_matrix_double_vector(x,y,r,cr,out)
+     /*
+       matrices x vector x * y, 
+       r = rows of x 
+       cr= cols of x = elements of y
+       out is the output vector (r elements) . Memory for out is not stored.
+     */
+     double **x, *y, *out;
+     int r,cr;
+{
+  int i,h;
+ 
+  for(i=0; i<r; i++){
+    out[i] = .0;
+    for(h=0; h<cr; h++)
+      out[i] += x[i][h] * y[h];
+  }
+
+}	   
+
+void product_double_vector_double_matrix(x,y,rr,c,out)
+     /*
+       vector x matrix y * x, 
+       rr = rows of x = elements of y 
+       c= cols of x 
+       out is the output vector (c elements) . Memory for out is not stored.
+     */
+     double **x, *y, *out;
+     int rr,c;
+{
+  int i,h;
+ 
+  for(i=0; i<c; i++){
+    out[i] = .0;
+    for(h=0; h<rr; h++)
+      out[i] += x[h][i] * y[h];
+  }
+
+}	   
+
+
+void transpose_double_matrix(x,n)
+     /*
+       transpose, and overwrite, the input matrix x 
+       of dimension n x n
+     */
+     double **x;
+     int  n;
+{
+  double **trans;
+  int i,j;
+
+  trans = (double **) calloc(n,sizeof(double *));
+  for(i=0 ; i<n ; i++)
+    trans[i] = (double *)calloc (n,sizeof(double));
+  for(i=0 ; i<n ; i++)
+    for(j=0 ; j<n ; j++)
+      trans[j][i]=x[i][j];
+  for (i=0;i<n;i++)
+    for (j=0;j<n;j++)
+      x[i][j]=trans[i][j];
+
+  for(i=0 ; i<n ; i++)
+    free(trans[i]);
+  free(trans);
+  
+}
+
+void double_matrix_to_vector(mat,rows,cols,vect)
+     /*
+       transform matrix mat of dimension rows x cols in vector
+       vect of length rows x cols.
+       matrix is scanned by row
+     */
+     double **mat;
+     int rows, cols;
+     double *vect;
+{
+  int i,j;
+  
+  for(i=0;i<rows;i++)
+    for(j=0;j<cols;j++)
+      vect[(i*cols)+j] = mat[i][j];
+}
+
+void extract_portion_of_double_matrix(r,c,br,bc,mat,wind)
+     /*
+       extract a squared portion of a matrix mat
+       given a the indeces of the center [r,c] 
+       and the semilength of the borders [br,bc]
+       Output to array wind
+     */
+     int r, c, br, bc;
+     double **mat, **wind;
+{
+  int i,j;
+  
+  for(i = 0; i < 2*br + 1;i++){
+    for(j = 0; j < 2*bc + 1;j++){
+      wind[i][j] = mat[r - br + i][c - bc +j];
+    }
+  }
+}
+
+void transpose_double_matrix_rectangular(x,n,m,trans)
+     /*
+       transpose the input matrix x  of dimension n x m
+       output to pointer to matrix trans
+     */
+     double **x,***trans;
+     int  n,m;
+{
+  int i,j;
+
+  (*trans) = (double **) calloc(m,sizeof(double *));
+  for(i=0 ; i<m ; i++)
+    (*trans)[i] = (double *)calloc (n,sizeof(double));
+
+  for(i=0 ; i<m ; i++)
+    for(j=0 ; j<n ; j++)
+      (*trans)[i][j]=x[j][i];
+
+}

Deleted: grass-addons/imagery/i.homography/open.c
===================================================================
--- grass-addons/i.homography/open.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.homography/open.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,63 +0,0 @@
-/*
-  The following routines are written and tested by Stefano Merler
-
-  for
-  
-  open new raster maps
-*/
-
-#include "gis.h"
-
-int open_new_CELL(name)
-     /* 
-	open a new raster map of name name in CELL format
-     */
-     char *name;
-{
-  int fd;
-  char err[400];
-    
-  if (G_legal_filename (name) < 0)
-    {
-      sprintf (err, "%s - ** illegal name **", name);
-      G_fatal_error (err);
-      exit(1);
-    }
-
-  fd = G_open_raster_new (name, CELL_TYPE);
-  if (fd < 0)
-    {
-      sprintf (err, "failed in attempt to open %s\n", name);
-      G_fatal_error (err);
-      exit(1);
-    }
-
-  return fd;
-}
-
-int open_new_DCELL(name)
-     /* 
-	open a new raster map of name name in DELL format
-     */
-     char *name;
-{
-  int fd;
-  char err[400];
-    
-  if (G_legal_filename (name) < 0)
-    {
-      sprintf (err, "%s - ** illegal name **", name);
-      G_fatal_error (err);
-      exit(1);
-    }
-
-  fd = G_open_raster_new (name, DCELL_TYPE);
-  if (fd < 0)
-    {
-      sprintf (err, "failed in attempt to open %s\n", name);
-      G_fatal_error (err);
-      exit(1);
-    }
-
-  return fd;
-}

Copied: grass-addons/imagery/i.homography/open.c (from rev 30335, grass-addons/i.homography/open.c)
===================================================================
--- grass-addons/imagery/i.homography/open.c	                        (rev 0)
+++ grass-addons/imagery/i.homography/open.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,63 @@
+/*
+  The following routines are written and tested by Stefano Merler
+
+  for
+  
+  open new raster maps
+*/
+
+#include "gis.h"
+
+int open_new_CELL(name)
+     /* 
+	open a new raster map of name name in CELL format
+     */
+     char *name;
+{
+  int fd;
+  char err[400];
+    
+  if (G_legal_filename (name) < 0)
+    {
+      sprintf (err, "%s - ** illegal name **", name);
+      G_fatal_error (err);
+      exit(1);
+    }
+
+  fd = G_open_raster_new (name, CELL_TYPE);
+  if (fd < 0)
+    {
+      sprintf (err, "failed in attempt to open %s\n", name);
+      G_fatal_error (err);
+      exit(1);
+    }
+
+  return fd;
+}
+
+int open_new_DCELL(name)
+     /* 
+	open a new raster map of name name in DELL format
+     */
+     char *name;
+{
+  int fd;
+  char err[400];
+    
+  if (G_legal_filename (name) < 0)
+    {
+      sprintf (err, "%s - ** illegal name **", name);
+      G_fatal_error (err);
+      exit(1);
+    }
+
+  fd = G_open_raster_new (name, DCELL_TYPE);
+  if (fd < 0)
+    {
+      sprintf (err, "failed in attempt to open %s\n", name);
+      G_fatal_error (err);
+      exit(1);
+    }
+
+  return fd;
+}

Deleted: grass-addons/imagery/i.homography/pi.c
===================================================================
--- grass-addons/i.homography/pi.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.homography/pi.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,38 +0,0 @@
-#include "gis.h"
-#include "global.h"
-
-
-void linear_solve(A,y,x,r,c)
-     /* solve linear system Ax=y, where A is a matrix of r x c
-	dimension. Memory for x stored
-     */
-     double **A,*y,**x;
-     int r,c;
-{
-
-  double **tA,**B, **inv_B;
-  double *C,*D;
-  int i;
-
-
-  transpose_double_matrix_rectangular(A,r,c,&tA);
-  
-  
-  B=(double**)G_calloc(c,sizeof(double*));
-  for(i=0;i<c;i++)
-    B[i]=(double*)G_calloc(c,sizeof(double));
-
-  product_double_matrix_double_matrix(tA,A,c,r,c,B);
-
-  inv_B=(double**)G_calloc(c,sizeof(double*));
-  for(i=0;i<c;i++)
-    inv_B[i]=(double*)G_calloc(c,sizeof(double));
-
-  inverse_of_double_matrix(B,inv_B,c);
-
-  C=(double*)G_calloc(c,sizeof(double));
-  product_double_matrix_double_vector(tA,y,c,r,C);
-
-  *x=(double*)G_calloc(c,sizeof(double));
-  product_double_matrix_double_vector(inv_B,C,c,c,*x);
-}

Copied: grass-addons/imagery/i.homography/pi.c (from rev 30335, grass-addons/i.homography/pi.c)
===================================================================
--- grass-addons/imagery/i.homography/pi.c	                        (rev 0)
+++ grass-addons/imagery/i.homography/pi.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,38 @@
+#include "gis.h"
+#include "global.h"
+
+
+void linear_solve(A,y,x,r,c)
+     /* solve linear system Ax=y, where A is a matrix of r x c
+	dimension. Memory for x stored
+     */
+     double **A,*y,**x;
+     int r,c;
+{
+
+  double **tA,**B, **inv_B;
+  double *C,*D;
+  int i;
+
+
+  transpose_double_matrix_rectangular(A,r,c,&tA);
+  
+  
+  B=(double**)G_calloc(c,sizeof(double*));
+  for(i=0;i<c;i++)
+    B[i]=(double*)G_calloc(c,sizeof(double));
+
+  product_double_matrix_double_matrix(tA,A,c,r,c,B);
+
+  inv_B=(double**)G_calloc(c,sizeof(double*));
+  for(i=0;i<c;i++)
+    inv_B[i]=(double*)G_calloc(c,sizeof(double));
+
+  inverse_of_double_matrix(B,inv_B,c);
+
+  C=(double*)G_calloc(c,sizeof(double));
+  product_double_matrix_double_vector(tA,y,c,r,C);
+
+  *x=(double*)G_calloc(c,sizeof(double));
+  product_double_matrix_double_vector(inv_B,C,c,c,*x);
+}

Copied: grass-addons/imagery/i.points.auto (from rev 30334, grass-addons/i.points.auto)

Deleted: grass-addons/imagery/i.points.auto/Makefile
===================================================================
--- grass-addons/i.points.auto/Makefile	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,10 +0,0 @@
-MODULE_TOPDIR = ../..
-
-PGM = i.points.auto
-
-LIBES     = $(IMAGERYLIB) $(GMATHLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(VASKLIB) $(CURSES) $(FFTWLIB)
-DEPENDENCIES= $(IMAGERYDEP) $(GMATHDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(VASKDEP)
-
-include $(MODULE_TOPDIR)/include/Make/Module.make
-
-default: cmd

Copied: grass-addons/imagery/i.points.auto/Makefile (from rev 30335, grass-addons/i.points.auto/Makefile)
===================================================================
--- grass-addons/imagery/i.points.auto/Makefile	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,10 @@
+MODULE_TOPDIR = ../..
+
+PGM = i.points.auto
+
+LIBES     = $(IMAGERYLIB) $(GMATHLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(VASKLIB) $(CURSES) $(FFTWLIB)
+DEPENDENCIES= $(IMAGERYDEP) $(GMATHDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(VASKDEP)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd

Deleted: grass-addons/imagery/i.points.auto/TODO
===================================================================
--- grass-addons/i.points.auto/TODO	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/TODO	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,5 +0,0 @@
-Compile with
-  make MODULE_TOPDIR=$HOME/grass63/
-
-This code is basically an improved i.points (from 2004).
-Further changes in i.points haven's been ported here yet.

Copied: grass-addons/imagery/i.points.auto/TODO (from rev 30335, grass-addons/i.points.auto/TODO)
===================================================================
--- grass-addons/imagery/i.points.auto/TODO	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/TODO	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,5 @@
+Compile with
+  make MODULE_TOPDIR=$HOME/grass63/
+
+This code is basically an improved i.points (from 2004).
+Further changes in i.points haven's been ported here yet.

Deleted: grass-addons/imagery/i.points.auto/analyze.c
===================================================================
--- grass-addons/i.points.auto/analyze.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/analyze.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,935 +0,0 @@
-#include <string.h>
-#include <unistd.h>
-#include <math.h>
-#include <stdlib.h>
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-#define NLINES 18
-struct box
-{
-    int top, bottom, left,right;
-};
-
-static int uparrow ( struct box *,int);
-static int downarrow ( struct box *,int) ;
-static int pick(int,int);
-static int done(void);
-static int cancel_which(void);
-static int inbox (struct box *,int,int);
-static int dotext (char *,int,int,int,int,int,int);
-static int compute_transformation(void);
-static int to_file(void);
-static int askfile(void);
-static int to_printer(void);
-static int do_report ( FILE *);
-static int printcentered(FILE *,char *,int);
-static int show_point(int,int);
-static int offsetx, offsety;
-static int n_old;
-static int which;
-static struct box more, less, report,box_lines, box_points;
-static int height, size, edge, nlines;
-static int curp, first_point;
-static double rms,l_rms;
-static double *xres, *yres, *gnd, *tres, *ures, *lgnd;
-static int pager;
-static int xmax, ymax, gmax;
-static int tmax, umax, lgmax;
-static char buf[300];
-int new_control_line (Lines *ln,double t1,double u1,double t2,double u2,int status);
-Lines lines;               /* contiene t ed u delle rette inserite */
-int  use_points=1;
-int top, bottom, left, right, width, middle, nums;
-int count =0, first_line=0;
-#define FMT0(buf,n) \
-	sprintf (buf, "%3d ", n)
-#define FMT1(buf,xres,yres,gnd) \
-	sprintf (buf, "%5.1f %5.1f %6.1f ", xres,yres,gnd)
-#define LHEAD1 "        error          "
-#define LHEAD2 "  #   col   row  target"
-#define LLINEHEAD2 "  #   dt    du   target"
-
-#define FMT2(buf,e1,n1,e2,n2) \
-	sprintf (buf, "%9.1f %9.1f %9.1f %9.1f ", e1,n1,e2,n2)
-#define RHEAD1 "         image              target"
-#define RHEAD2 "    east     north      east     north"
-#define RLINEHEAD2 "    t1       u1         t2       u2  "
-
-#define BACKGROUND WHITE
-
-int
-analyze (void)
-{
-
-    double t_temp1,u_temp1, t_temp2, u_temp2;
-
-    static int use = 1;
-
-    static Objects objects[]=
-    {
-	MENU(" DONE  ", done, &use),
-	MENU(" PRINT  ", to_printer, &use),
-	MENU(" FILE  ", to_file, &use),
-	INFO(" Double click on point to be included/excluded ", &use),
-	OTHER(pick,&use),
-	{0}
-    };
-
-    int color;
-    int tsize;
-    int cury;
-    int len;
-    int line;
-    int i;
-/* to give user a response of some sort */
-    if (group.points.count ==0)
-    return 0;
-
-
-    Menu_msg ("Preparing analysis ...");
-
-/*
- * build a popup window at center of the screen.
- * 35% the height and wide enough to hold the report
- *
- */
-
-  /* height of 1 line, based on NLINES taking up 35% vertical space */
-    height = (.35 * (SCREEN_BOTTOM - SCREEN_TOP))/NLINES + 1;
-    use_points=1;
-/* size of text, 80% of line height */
-    tsize = .8 * height;
-    size = tsize-2; /* fudge for computing pixels width of text */
-
-/* indent for the text */
-    edge = .1 * height + 1;
-
-/* determine the length, in chars, of printed line */
-    FMT0 (buf,0);
-    nums = strlen(buf) * size;
-    FMT1 (buf, 0.0, 0.0, 0.0);
-    len = strlen(buf);
-    middle = len * size;
-    FMT2 (buf, 0.0, 0.0, 0.0, 0.0);
-    len += strlen(buf) ;
-
-/* width is for max chars plus sidecar for more/less */
-    R_standard_color (WHITE);
-    width = len * size + nums + 2*height;
-    if ((SCREEN_RIGHT - SCREEN_LEFT) < width)
-	width = SCREEN_RIGHT - SCREEN_LEFT;
-
-
-/* define the window */
-    
-    //bottom = VIEW_MENU->top-1;
-    //top = bottom - height*NLINES;
-
-    bottom = height*NLINES;
-    top = 0;
-
-
-    left = SCREEN_LEFT;
-    right = left + width;
-    middle += left + nums;
-    nums += left;
-
-/* save what is under this area, so it can be restored */
-    R_panel_save (tempfile1, top, bottom, left, right);
-
-
-/* fill it with white */
-    R_standard_color (WHITE);
-    R_box_abs (left, top, right, bottom);
-
-    right -= 2*height;	/* reduce it to exclude sidecar */
-
-/* print messages in message area */
-    R_text_size (tsize, tsize);
-
-
-/* setup the more/less boxes in the sidecar */
-    R_standard_color (BLUE);
-    less.top = top;
-    less.bottom = top + 2*height;
-    less.left = right;
-    less.right = right + 2*height;
-    Outline_box (less.top, less.bottom, less.left, less.right);
-
-    more.top = bottom - 2*height;
-    more.bottom = bottom;
-    more.left = right;
-    more.right = right + 2*height;
-    Outline_box (more.top, more.bottom, more.left, more.right);
-
-/*
- * top two lines are for column labels
- * last two line is for overall rms error.
- */
-    nlines = NLINES - 4;
-    first_point = 0;
-
-/* allocate predicted values */
-    xres = (double *) G_calloc (group.points.count, sizeof (double));
-    yres = (double *) G_calloc (group.points.count, sizeof (double));
-    gnd  = (double *) G_calloc (group.points.count, sizeof (double));
-
-
-   i=0;
-  while(group.points.status[i]!=1 && i < group.points.count)
-        i++;
-  if(i >=group.points.count && group.points.status[i]!=1)
-        i=0;
-offsetx = group.points.e2[i] - group.points.e1[i];
-offsety = group.points.n2[i] - group.points.n1[i];
-
-
-lines.count=0;
- for (i=0; i < group.points.count; i++)
-   { 
-     if (group.points.status[i] == 2 || group.points.status[i] == -2)
-       {
-	 points_to_line (group.points.e1[i], group.points.n1[i],group.points.e1[i+1], group.points.n1[i+1],&t_temp1,&u_temp1);
-	 points_to_line (group.points.e2[i]- offsetx, group.points.n2[i]-offsety,group.points.e2[i+1]-offsetx, group.points.n2[i+1]-offsety,&t_temp2,&u_temp2);
-	 
-	 sprintf (buf, "t2[0] e u2[0]....   %f  %f   \n",10000*t_temp2,10000*u_temp2 );
-	 Curses_write_window (INFO_WINDOW, 3+ i, 2, buf);
-
-	 
-	 new_control_line ( &lines,10000*t_temp1,10000*u_temp1,10000*t_temp2,10000*u_temp2,group.points.status[i]);
-       }
-   }
- 
- tres = (double *) G_calloc (lines.count, sizeof (double));
- ures = (double *) G_calloc (lines.count, sizeof (double));
- lgnd = (double *) G_calloc (lines.count, sizeof (double));
- 
- /* compute transformation for the first time */
-    compute_transformation();
-    
-    
-    /* put head on the report */
-    
-    box_points.top=top;
-    box_points.bottom=top+height-1;
-    box_points.left= left;
-    box_points.right=(right-left)/2;
-    dotext ("        ANALYZE -> POINTS",top, top+height, left, (right-left)/2, 0, RED);
-    Outline_box (box_points.top, box_points.bottom, box_points.left, box_points.right);
-
-    box_lines.top=top;
-    box_lines.bottom=top+height-1;
-    box_lines.left= ((right- left)/2)+1;
-    box_lines.right=right;
-    dotext ("        ANALYZE -> LINES",top, top+height, ((right-left)/2)+1, right, 0, BLACK);
-   Outline_box (box_lines.top, box_lines.bottom, box_lines.left, box_lines.right);
-
-    cury=top;
-    cury = top+height;
-    dotext (LHEAD1, cury, cury+height, left, middle, 0, BLACK);
-    dotext (RHEAD1, cury, cury+height, middle, right-1, 0, BLACK);
-    cury += height;
-    dotext (LHEAD2, cury, cury+height, left, middle, 0, BLACK);
-    dotext (RHEAD2, cury, cury+height, middle, right-1, 0, BLACK);
-
-    cury += height;
-    R_move_abs (left, cury-1);
-    R_cont_abs (right, cury-1);
-
-/* isolate the sidecar */
-    R_standard_color (BLACK);
-    R_move_abs (right, top);
-    R_cont_abs (right, bottom);
-
-/* define report box */
-    report.top = cury;
-    report.left = left;
-    report.right = right;
-    count = 0;
-    first_line = 0;
-
-/* lets do it */
-    pager = 1;
-    while(1)
-      {
-	R_text_size (tsize, tsize);
-	line = 0;
-	curp = first_point;
-	cury = top + 3*height;
-	count=0;
-	while(1)
-	  {
-	    if (line >= nlines || curp >= group.points.count)
-	      break;
-	    if(group.equation_stat > 0 && group.points.status[curp]==1)
-	      {
-		if(use_points)
-		  {
-		    color = BLUE;
-		    FMT1(buf, xres[curp], yres[curp], gnd[curp]);
-		    if (curp == xmax || curp == ymax || curp == gmax)
-		      color = RED;
-		    dotext (buf, cury, cury+height, nums, middle, 0, color);
-		    line++;
-		    cury += height;
-		  }
-	      }
-	    else if(group.points.status[curp] ==2)
-	      {
-		/* if(group.points.status[curp+1]!=3)
-		   break;*/
-		if(!use_points)
-		  {
-		    color = BLUE;
-		    if (count+first_line == tmax || count+first_line == umax || count+first_line == lgmax)
-		      color = RED;
-		    sprintf (buf, "%5.1f %5.1f %5.1f ", tres[count+ first_line],ures[count+first_line],lgnd[count+first_line]);
-		    dotext (buf, cury, cury+height, nums, middle, 0, color);
-		    line++;
-		    cury += height;
-		  }
-		
-		curp++;
-	      }
-	    else if (group.points.status[curp] > 0) 
-	      {
-		FMT0 (buf, curp+1-count);
-		dotext (buf, cury, cury+height, left, nums, 0, BLACK);
-		FMT2(buf,
-		     group.points.e1[curp],
-		     group.points.n1[curp],
-		     group.points.e2[curp],
-		     group.points.n2[curp]);
-		dotext (buf, cury, cury+height, middle, right-1, 0, BLACK);
-		dotext ("?", cury, cury+height, nums, middle, 1, BLACK);
-		line++;
-		cury += height;
-	      }
-	    
-	    else if (group.points.status[curp] == -2 )
-	      {
-		if(group.points.status[curp+1]!=-3)
-		  break;
-		if (!use_points) 
-		  {
-		    dotext ("not used", cury, cury+height, nums, middle, 1, BLUE);
-		    line++;
-		    cury += height;
-		  }
-		curp++;
-	      }
-	    else  if (use_points) 
-	      {
-		dotext ("not used", cury, cury+height, nums, middle, 1, BLACK);
-		line++;
-		cury += height;
-	      }
-	    if (pager)
-	      {
-		if(use_points &&( group.points.status[curp]==1 || group.points.status[curp]==0))
-		  {
-		    
-		    FMT0 (buf, curp+1-2*(first_line+count));
-		    dotext (buf, cury-height, cury, left, nums, 0, BLACK);
-		    FMT2(buf,
-			 group.points.e1[curp],
-			 group.points.n1[curp],
-			 group.points.e2[curp],
-			 group.points.n2[curp]);
-		    dotext (buf, cury-height, cury, middle, right-1, 0, BLACK);
-		  }
-		if(!use_points &&( group.points.status[curp]>1 ||  group.points.status[curp]<-1))
-		  {
-		    FMT0 (buf, first_line + count);
-		    dotext (buf, cury-height, cury, left, nums, 0, BLACK);
-		    sprintf (buf, "%9.1f %9.1f %9.1f %9.1f ",
-			     lines.t1[first_line+count],
-			     lines.u1[first_line+count],
-			     lines.t2[first_line+count],
-			     lines.u2[first_line+count]);
-		    dotext (buf, cury-height, cury, middle, right-1, 0, BLACK);
-		    
-		  }
-	      }
-	    if( group.points.status[curp]>1 ||  group.points.status[curp]<-1)
-	      count++;
-	    curp++;
-	  }
-	report.bottom = cury;
-	if(use_points) 
-	  {
-	    downarrow (&more,  ((group.points.count-curp)-2*(lines.count-(count+first_line)))>0 ? BLACK : BACKGROUND);
-	    uparrow   (&less, first_point > 0  ? BLACK : BACKGROUND);
-	  }
-	if(!use_points) 
-	  {
-	    downarrow (&more,  (lines.count-(count+first_line))>0 ? BLACK : BACKGROUND);
-	    uparrow   (&less, first_point > 0  ? BLACK : BACKGROUND);
-	  }
-	
-	R_standard_color (BACKGROUND);
-	R_box_abs (left, cury, right-1, bottom);
-	if(use_points) {
-	  if (group.equation_stat < 0)
-	    {
-	      color = RED;
-	      strcpy (buf, "Poorly placed control points");
-	    }
-	  else if (group.equation_stat == 0)
-	    {
-	      color = RED;
-	      strcpy (buf, "No active control points");
-	    }
-	  else
-	    {
-	      color = BLACK;
-	      sprintf (buf, "Overall rms error: %.2f", rms);
-	    }
-	}
-	else 
-	  {
-	    if (lines.line_stat < 0)
-	      {
-		color = RED;
-		strcpy (buf, "Poorly placed control points");
-	      }
-	    else if (lines.line_stat == 0)
-	      {
-		color = RED;
-		strcpy (buf, "No active control points");
-	      }
-	    else
-	      {
-		color = BLACK;
-		sprintf (buf, "Overall rms error: %.2f", l_rms);
-	      }
-	  }
-	dotext (buf, bottom-height, bottom, left, right-1, 0, color);
-	R_standard_color (BLACK);
-	R_move_abs (left, bottom-height);
-	R_cont_abs (right-1, bottom-height);
-	
-	pager = 0;
-	which = -1;
-	if(Input_pointer(objects) < 0)
-	  break;
-	
-	
-	
-      }
-    
-    /* all done. restore what was under the window */
-    right += 2*height;	/* move it back over the sidecar */
-    R_standard_color (BACKGROUND);
-    R_box_abs (left, top, right, bottom);
-    R_panel_restore (tempfile1);
-    R_panel_delete (tempfile1);
-    R_flush();
-    
-    free (xres); free (yres); free (gnd);
-    I_put_control_points (group.name, &group.points);
-    display_points(1);
-    return 0; /* return but don't QUIT */
-}
-
-
-static int uparrow (struct box *box, int color)
-{
-    R_standard_color (BLACK);
-    Uparrow (box->top+edge, box->bottom-edge, box->left+edge, box->right-edge);
-
-    return 0;
-}
-
-static int downarrow(struct box *box, int color)
-{
-    R_standard_color (BLACK);
-    Downarrow (box->top+edge, box->bottom-edge, box->left+edge, box->right-edge);
-
-    return 0;
-}
-
-static int pick(int x,int y)
-{
-    int n;
-    int cur;
-    int i;
-
-    cur = which;
-    cancel_which();
-    if (inbox(&more,x,y))
-    {
-	if (use_points && ((group.points.count-curp)-2*(lines.count-(count+first_line)))<=0)
-	    return 0;
-                  if(!use_points && (lines.count-(count+first_line))<=0)
-                      return 0;
-	first_point = curp;
-                 first_line +=count;
-        	pager = 1;
-	return 1;
-    }
-    if (inbox(&box_points,x,y))
-    {
-                 R_text_size (.8*height, .8*height);
-                 use_points=1;
-                 dotext ("        ANALYZE -> POINTS",top, top+height, left, (right-left)/2, 0, RED);
-                 dotext ("        ANALYZE -> LINES",top, top+height,((right-left)/2)+1, right, 0, BLACK);
-                 Outline_box (box_points.top, box_points.bottom, box_points.left, box_points.right);
-                 Outline_box (box_lines.top, box_lines.bottom, box_lines.left, box_lines.right);
-                 dotext (LHEAD2, top+2*height, top+3*height, left, middle, 0, BLACK);
-                 dotext (RHEAD2, top+2*height, top+3*height, middle, right-1, 0, BLACK);
-                 first_point = 0;
-                 first_line = 0;
-                 pager = 1;
-	return 1;
-    }
-    if (inbox(&box_lines,x,y))
-    {
-                 R_text_size (.8*height, .8*height);
-                 use_points=0;
-                 dotext ("        ANALYZE -> LINES",top, top+height, ((right-left)/2)+1, right, 0, RED);
-                 dotext ("        ANALYZE -> POINTS",top, top+height, left, (right-left)/2, 0, BLACK);
-                 Outline_box (box_points.top, box_points.bottom, box_points.left, box_points.right);
-                 Outline_box (box_lines.top, box_lines.bottom, box_lines.left, box_lines.right);
-                 dotext (LLINEHEAD2, top+2*height, top+3*height, left, middle, 0, BLACK);
-                 dotext (RLINEHEAD2, top+2*height, top+3*height, middle, right-1, 0, BLACK);
-                 first_point = 0;
-                 first_line = 0;
-                 pager = 1;
-	return 1;
-    }
-    if (inbox(&less,x,y))
-    {
-	if (first_point == 0)
-	    return 0;
-	first_point = 0;
-                 first_line = 0;
-	pager = 1;
-	return 1;
-    }
-    if (!inbox (&report,x,y))
-    {
-      return 0;
-    }
-
-   n_old = n = (y - report.top)/height;
-    i=0;
-    if(use_points){
-        for (i; i<=n;  i++)
-                if (group.points.status[first_point + i]==2||group.points.status[first_point + i]==-2) n+=2;
-        }
-    else { while (n>=0) {
-                        if (group.points.status[first_point + i]==2||group.points.status[first_point + i]==-2)  {
-                                                                          n--;
-                                                                          i++;
-                                                                          }
-                          i++;
-                                    }
-              n=i-2;
-              }
-    if (n == cur) /* second click! */
-    {
-                 if  (group.points.status[first_point +n]==2||group.points.status[first_point +n]==-2) {
-                         group.points.status[first_point+n] = -group.points.status[first_point+n];
-                         group.points.status[first_point+(n+1)] = -group.points.status[first_point+(n+1)];
-                         lines.status[first_line + n_old] = - lines.status[first_line + n_old];
-                                                 }
-
-                   else
-                         group.points.status[first_point+n] = !group.points.status[first_point+n];
-                 compute_transformation();
-	show_point (first_point+n, 1);
-
-
-           return 1;
-    }
-    which = n;
-    show_point (first_point+n, 0);
-    R_standard_color (RED);
-    Outline_box (report.top + n*height, report.top +(n+1)*height,
-		         report.left, report.right-1);
-    return 0; /* ignore first click */
-
-}
-
-static int done (void)
-{
-  cancel_which();
-  return -1;  
-}
-
-static int cancel_which (void)
-{
-    if (which >= 0)
-    {
-	R_standard_color (BACKGROUND);
-	Outline_box (report.top + which*height, report.top +(which+1)*height,
-		         report.left, report.right-1);
-	show_point (first_point+which, 1);
-    }
-    which = -1;
-
-    return 0;
-}
-
-static int inbox (struct box *box,int x,int y)
-{
-    return (x>box->left && x <box->right && y>box->top && y<box->bottom);
-}
-
-static int dotext (char *text,
-       int top,int bottom,int left,int right,int centered,int color)
-{
-    R_standard_color (BACKGROUND);
-    R_box_abs (left, top, right, bottom);
-    R_standard_color (color);
-    R_move_abs (left+1+edge, bottom-1-edge);
-    if (centered)
-	R_move_rel ((right-left-strlen(text)*size)/2,0);
-    R_set_window (top, bottom, left, right);	/* for text clipping */
-    R_text (text);
-    R_set_window (SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
-
-    return 0;
-}
-
-static int compute_transformation (void)
-{
-    int n, count;
-    double d,d1,d2,sum;
-    double e1, e2, n1, n2;
-    double t1, t2, u1, u2;
-    double xval, yval, gval;
-    double tval, uval, lgval;
-
-    xmax = ymax = gmax = 0;
-    xval = yval = gval = 0.0;
-
-    Compute_equation();     /*trova gli A,B,C che legano punti dell'image a punti del ltarget  */
-     lines.line_stat = compute_georef_equations_lp(&lines);
-
-    if (group.equation_stat <= 0 && lines.line_stat<=0) return 1;
-
-/* compute the row,col error plus ground error
- * keep track of largest and second largest error
- */
-    sum = 0.0;
-    rms = 0.0;
-    count = 0;
-    for (n = 0; n < group.points.count && group.equation_stat>0; n++)
-    {
-	if (group.points.status[n] !=1) continue;
-	count++;
-	georef (group.points.e2[n], group.points.n2[n], &e1, &n1, group.E21, group.N21);
-	georef (group.points.e1[n], group.points.n1[n], &e2, &n2, group.E12, group.N12);
-
-	if((d = xres[n] = e1-group.points.e1[n]) < 0)
-	    d = -d;
-	if (d > xval)
-	{
-	    xmax = n;
-	    xval = d;
-	}
-
-	if ((d = yres[n] = n1-group.points.n1[n]) < 0)
-	    d = -d;
-	if (d > yval)
-	{
-	    ymax = n;
-	    yval = d;
-	}
-
-/* compute ground error (ie along diagonal) */
-	d1 = e2 - group.points.e2[n];
-	d2 = n2 - group.points.n2[n];
-	d = d1*d1 + d2*d2;
-	sum += d;                 /* add it to rms sum, before taking sqrt */
-	d = sqrt(d);
-	gnd[n] = d;
-	if (d > gval)             /* is this one the max? */
-	{
-	    gmax = n;
-	    gval = d;
-	}
-
-    }
-/* compute overall rms error */
-     if (count)
-	rms = sqrt (sum/count);
-
-     count =0;
-     tmax = umax = lgmax = 0;
-     tval = uval = lgval = 0.0;
-     sum = 0.0;
-    l_rms = 0.0;
-    for (n = 0; n < lines.count && lines.line_stat>0 ; n++)
-    {
-	if (lines.status[n] !=2) continue;
-	count++;
-	georef (lines.t2[n], lines.u2[n], &t1, &u1, lines.E21, lines.N21);
-	georef (lines.t1[n], lines.u1[n], &t2, &u2, lines.E12, lines.N12);
-	if((d = tres[n] = t1- lines.t1[n]) < 0)
-	    d = -d;
-	if (d > tval)
-	{
-	    tmax = n;
-	    tval = d;
-	}
-
-	if ((d = ures[n] = u1- lines.u1[n]) < 0)
-	    d = -d;
-	if (d > uval)
-	{
-	    umax = n;
-	    uval = d;
-	}
-
-/* compute ground error (ie along diagonal) */
-	d1 = t2 - lines.t2[n];
-	d2 = u2 - lines.u2[n];
-	d = d1*d1 + d2*d2;
-	sum += d;                 /* add it to rms sum, before taking sqrt */
-	d = sqrt(d);
-	lgnd[n] = d;
-	if (d > lgval)             /* is this one the max? */
-	{
-	    lgmax = n;
-	    lgval = d;
-	}
-
-    }
-     if (count)
-	l_rms = sqrt (sum/count);
-
-
-
-    return 0;
-}
-
-static int to_file (void)
-{
-    FILE *fd;
-    char msg[1024];
-
-    cancel_which();
-    if (Input_other (askfile, "Keyboard") < 0)
-    {
-	return 0;
-    }
-
-    fd = fopen (buf, "w");
-    if (fd == NULL)
-    {
-	sprintf (msg, "** Unable to create file %s\n", buf);
-	Beep();
-	Curses_write_window (PROMPT_WINDOW, 2, 1, msg);
-    }
-    else
-    {
-	do_report (fd);
-	fclose (fd);
-	sprintf (msg, "Report saved in file %s\n", buf);
-	Curses_write_window (PROMPT_WINDOW, 2, 1, msg);
-    }
-    return 0;
-}
-
-static int askfile (void)
-{
-    char file[100];
-
-    while (1)
-    {
-	Curses_prompt_gets ("Enter file to hold report: ", file);
-	G_strip (file);
-	if (*file == 0) return -1;
-	if (G_index (file, '/'))
-	    strcpy (buf, file);
-	else
-	    sprintf (buf, "%s/%s", G_home(), file);
-	if (access (buf, 0) != 0)
-	    return 1;
-	sprintf (buf, "** %s already exists. choose another file", file);
-	Beep();
-	Curses_write_window (PROMPT_WINDOW, 2, 1, buf);
-    }
-
-    return 0;
-}
-
-static int to_printer (void)
-{
-    FILE *fd;
-    cancel_which();
-    Menu_msg ("sending report to printer ...");
-
-    fd = popen ("lpr", "w");
-    do_report (fd);
-    pclose (fd);
-    return 0;
-}
-
-static int do_report ( FILE *fd)
-{
-    char buf[100];
-    int n;
-    int width;
-
-    fprintf (fd, "LOCATION: %-20s GROUP: %-20s MAPSET: %s\n\n",
-	G_location(), group.name, G_mapset());
-    fprintf (fd, "%15sAnalysis of control point registration\n\n", "");
-    fprintf (fd, "%s   %s\n", LHEAD1, RHEAD1);
-    fprintf (fd, "%s   %s\n", LHEAD2, RHEAD2);
-
-    FMT1 (buf,0.0,0.0,0.0);
-    width = strlen (buf);
-
-    for (n = 0; n < group.points.count; n++)
-    {
-	FMT0(buf,n+1);
-	fprintf (fd, "%s", buf);
-	if(group.equation_stat > 0 && group.points.status[n] > 0)
-	{
-	    FMT1(buf, xres[n], yres[n], gnd[n]);
-	    fprintf (fd, "%s", buf);
-	}
-	else if (group.points.status[n] > 0)
-	    printcentered (fd, "?", width);
-	else
-	    printcentered (fd, "not used", width);
-	FMT2(buf,
-	    group.points.e1[n],
-	    group.points.n1[n],
-	    group.points.e2[n],
-	    group.points.n2[n]);
-	fprintf (fd, "   %s\n", buf);
-    }
-    fprintf (fd, "\n");
-    if (group.equation_stat < 0)
-	fprintf (fd, "Poorly place control points\n");
-    else if (group.equation_stat == 0)
-	fprintf (fd, "No active control points\n");
-    else
-	fprintf (fd, "Overall rms error: %.2f\n", rms);
-
-    return 0;
-}
-
-static int printcentered (FILE *fd, char *buf,int width)
-{
-    int len;
-    int n;
-    int i;
-
-    len = strlen (buf);
-    n = (width -len)/2;
-
-    for (i = 0; i < n; i++)
-	fprintf (fd, " ");
-    fprintf (fd, "%s", buf);
-    i += len;
-    while (i++ < width)
-	fprintf (fd, " ");
-
-    return 0;
-}
-
-static int show_point(int n,int true_color)
-{
-   int  x_temp[2], y_temp[2];
-   int row,col;
-
-    if (!true_color)
-	R_standard_color (ORANGE);
-    else if(group.points.status[n]>0)
-	R_standard_color (GREEN);
-    else
-	R_standard_color (RED);
-
-    
-    /* Display red_points in VIEW_MAP1_ZOOM */ 
-    
-    if (group.points.status[n]==0 || group.points.status[n] == 1 )
-      display_one_point (VIEW_MAP1_ZOOM, group.points.e1[n], group.points.n1[n]);
-    else 
-      {
-	display_one_point (VIEW_MAP1_ZOOM, group.points.e1[n], group.points.n1[n]);
-	display_one_point (VIEW_MAP1_ZOOM, group.points.e1[n+1], group.points.n1[n+1]);
-	row = northing_to_row (&VIEW_MAP1_ZOOM->cell.head, group.points.n1[n]) + .5;
-	col = easting_to_col  (&VIEW_MAP1_ZOOM->cell.head, group.points.e1[n]) + .5;
-	y_temp[0] = row_to_view (VIEW_MAP1_ZOOM, row);
-	x_temp[0] = col_to_view (VIEW_MAP1_ZOOM, col);
-	
-	row = northing_to_row (&VIEW_MAP1_ZOOM->cell.head, group.points.n1[n+1]) + .5;
-	col = easting_to_col  (&VIEW_MAP1_ZOOM->cell.head,group.points.e1[n+1]) + .5;
-	y_temp[1] = row_to_view (VIEW_MAP1_ZOOM, row);
-	x_temp[1] = col_to_view (VIEW_MAP1_ZOOM, col);
-	
-	R_polyline_abs (x_temp,y_temp,2);
-	R_flush();
-	
-      }
-    
-    
-    /* Display red_points in VIEW_MAP2_ZOOM */ 
-    if (group.points.status[n]==0 || group.points.status[n] == 1 )
-      display_one_point (VIEW_MAP2_ZOOM, group.points.e2[n], group.points.n2[n]);
-    else 
-      {
-	display_one_point (VIEW_MAP2_ZOOM, group.points.e2[n], group.points.n2[n]);
-	display_one_point (VIEW_MAP2_ZOOM, group.points.e2[n+1], group.points.n2[n+1]);
-	row = northing_to_row (&VIEW_MAP2_ZOOM->cell.head, group.points.n2[n]) + .5;
-	col = easting_to_col  (&VIEW_MAP2_ZOOM->cell.head, group.points.e2[n]) + .5;
-	y_temp[0] = row_to_view (VIEW_MAP2_ZOOM, row);
-	x_temp[0] = col_to_view (VIEW_MAP2_ZOOM, col);
-	
-	row = northing_to_row (&VIEW_MAP2_ZOOM->cell.head, group.points.n2[n+1]) + .5;
-	col = easting_to_col  (&VIEW_MAP2_ZOOM->cell.head,group.points.e2[n+1]) + .5;
-	y_temp[1] = row_to_view (VIEW_MAP2_ZOOM, row);
-	x_temp[1] = col_to_view (VIEW_MAP2_ZOOM, col);
-	
-	R_polyline_abs (x_temp,y_temp,2);
-	R_flush();
-	
-      }
-    
-    
-    
-    return 0;
-}
-
-
-int points_to_line (double e1, double n1, double e2, double n2, double *t, double *u)
-{
-        double a,b,c;
-        a=-(n2 - n1);
-        b= (e2 - e1);
-        c= (n2*e1 - n1*e2);
-        *t= a/c;
-        *u=b/c;
-  }
-
-int new_control_line ( Lines *ln,
-    double t1,double u1,double t2,double u2,int status)
-{
-    int i;
-    unsigned int size;
-
-    i = (ln->count)++ ;
-    size =  ln->count * sizeof(double) ;
-    ln->t1 = (double *) G_realloc (ln->t1, size);
-    ln->t2 = (double *) G_realloc (ln->t2, size);
-    ln->u1 = (double *) G_realloc (ln->u1, size);
-    ln->u2 = (double *) G_realloc (ln->u2, size);
-    size =  ln->count * sizeof(int) ;
-    ln->status = (int *) G_realloc (ln->status, size);
-
-    ln->t1[i] = t1;
-    ln->t2[i] = t2;
-    ln->u1[i] = u1;
-    ln->u2[i] = u2;
-    ln->status[i] = status;
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/analyze.c (from rev 30335, grass-addons/i.points.auto/analyze.c)
===================================================================
--- grass-addons/imagery/i.points.auto/analyze.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/analyze.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,935 @@
+#include <string.h>
+#include <unistd.h>
+#include <math.h>
+#include <stdlib.h>
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+#define NLINES 18
+struct box
+{
+    int top, bottom, left,right;
+};
+
+static int uparrow ( struct box *,int);
+static int downarrow ( struct box *,int) ;
+static int pick(int,int);
+static int done(void);
+static int cancel_which(void);
+static int inbox (struct box *,int,int);
+static int dotext (char *,int,int,int,int,int,int);
+static int compute_transformation(void);
+static int to_file(void);
+static int askfile(void);
+static int to_printer(void);
+static int do_report ( FILE *);
+static int printcentered(FILE *,char *,int);
+static int show_point(int,int);
+static int offsetx, offsety;
+static int n_old;
+static int which;
+static struct box more, less, report,box_lines, box_points;
+static int height, size, edge, nlines;
+static int curp, first_point;
+static double rms,l_rms;
+static double *xres, *yres, *gnd, *tres, *ures, *lgnd;
+static int pager;
+static int xmax, ymax, gmax;
+static int tmax, umax, lgmax;
+static char buf[300];
+int new_control_line (Lines *ln,double t1,double u1,double t2,double u2,int status);
+Lines lines;               /* contiene t ed u delle rette inserite */
+int  use_points=1;
+int top, bottom, left, right, width, middle, nums;
+int count =0, first_line=0;
+#define FMT0(buf,n) \
+	sprintf (buf, "%3d ", n)
+#define FMT1(buf,xres,yres,gnd) \
+	sprintf (buf, "%5.1f %5.1f %6.1f ", xres,yres,gnd)
+#define LHEAD1 "        error          "
+#define LHEAD2 "  #   col   row  target"
+#define LLINEHEAD2 "  #   dt    du   target"
+
+#define FMT2(buf,e1,n1,e2,n2) \
+	sprintf (buf, "%9.1f %9.1f %9.1f %9.1f ", e1,n1,e2,n2)
+#define RHEAD1 "         image              target"
+#define RHEAD2 "    east     north      east     north"
+#define RLINEHEAD2 "    t1       u1         t2       u2  "
+
+#define BACKGROUND WHITE
+
+int
+analyze (void)
+{
+
+    double t_temp1,u_temp1, t_temp2, u_temp2;
+
+    static int use = 1;
+
+    static Objects objects[]=
+    {
+	MENU(" DONE  ", done, &use),
+	MENU(" PRINT  ", to_printer, &use),
+	MENU(" FILE  ", to_file, &use),
+	INFO(" Double click on point to be included/excluded ", &use),
+	OTHER(pick,&use),
+	{0}
+    };
+
+    int color;
+    int tsize;
+    int cury;
+    int len;
+    int line;
+    int i;
+/* to give user a response of some sort */
+    if (group.points.count ==0)
+    return 0;
+
+
+    Menu_msg ("Preparing analysis ...");
+
+/*
+ * build a popup window at center of the screen.
+ * 35% the height and wide enough to hold the report
+ *
+ */
+
+  /* height of 1 line, based on NLINES taking up 35% vertical space */
+    height = (.35 * (SCREEN_BOTTOM - SCREEN_TOP))/NLINES + 1;
+    use_points=1;
+/* size of text, 80% of line height */
+    tsize = .8 * height;
+    size = tsize-2; /* fudge for computing pixels width of text */
+
+/* indent for the text */
+    edge = .1 * height + 1;
+
+/* determine the length, in chars, of printed line */
+    FMT0 (buf,0);
+    nums = strlen(buf) * size;
+    FMT1 (buf, 0.0, 0.0, 0.0);
+    len = strlen(buf);
+    middle = len * size;
+    FMT2 (buf, 0.0, 0.0, 0.0, 0.0);
+    len += strlen(buf) ;
+
+/* width is for max chars plus sidecar for more/less */
+    R_standard_color (WHITE);
+    width = len * size + nums + 2*height;
+    if ((SCREEN_RIGHT - SCREEN_LEFT) < width)
+	width = SCREEN_RIGHT - SCREEN_LEFT;
+
+
+/* define the window */
+    
+    //bottom = VIEW_MENU->top-1;
+    //top = bottom - height*NLINES;
+
+    bottom = height*NLINES;
+    top = 0;
+
+
+    left = SCREEN_LEFT;
+    right = left + width;
+    middle += left + nums;
+    nums += left;
+
+/* save what is under this area, so it can be restored */
+    R_panel_save (tempfile1, top, bottom, left, right);
+
+
+/* fill it with white */
+    R_standard_color (WHITE);
+    R_box_abs (left, top, right, bottom);
+
+    right -= 2*height;	/* reduce it to exclude sidecar */
+
+/* print messages in message area */
+    R_text_size (tsize, tsize);
+
+
+/* setup the more/less boxes in the sidecar */
+    R_standard_color (BLUE);
+    less.top = top;
+    less.bottom = top + 2*height;
+    less.left = right;
+    less.right = right + 2*height;
+    Outline_box (less.top, less.bottom, less.left, less.right);
+
+    more.top = bottom - 2*height;
+    more.bottom = bottom;
+    more.left = right;
+    more.right = right + 2*height;
+    Outline_box (more.top, more.bottom, more.left, more.right);
+
+/*
+ * top two lines are for column labels
+ * last two line is for overall rms error.
+ */
+    nlines = NLINES - 4;
+    first_point = 0;
+
+/* allocate predicted values */
+    xres = (double *) G_calloc (group.points.count, sizeof (double));
+    yres = (double *) G_calloc (group.points.count, sizeof (double));
+    gnd  = (double *) G_calloc (group.points.count, sizeof (double));
+
+
+   i=0;
+  while(group.points.status[i]!=1 && i < group.points.count)
+        i++;
+  if(i >=group.points.count && group.points.status[i]!=1)
+        i=0;
+offsetx = group.points.e2[i] - group.points.e1[i];
+offsety = group.points.n2[i] - group.points.n1[i];
+
+
+lines.count=0;
+ for (i=0; i < group.points.count; i++)
+   { 
+     if (group.points.status[i] == 2 || group.points.status[i] == -2)
+       {
+	 points_to_line (group.points.e1[i], group.points.n1[i],group.points.e1[i+1], group.points.n1[i+1],&t_temp1,&u_temp1);
+	 points_to_line (group.points.e2[i]- offsetx, group.points.n2[i]-offsety,group.points.e2[i+1]-offsetx, group.points.n2[i+1]-offsety,&t_temp2,&u_temp2);
+	 
+	 sprintf (buf, "t2[0] e u2[0]....   %f  %f   \n",10000*t_temp2,10000*u_temp2 );
+	 Curses_write_window (INFO_WINDOW, 3+ i, 2, buf);
+
+	 
+	 new_control_line ( &lines,10000*t_temp1,10000*u_temp1,10000*t_temp2,10000*u_temp2,group.points.status[i]);
+       }
+   }
+ 
+ tres = (double *) G_calloc (lines.count, sizeof (double));
+ ures = (double *) G_calloc (lines.count, sizeof (double));
+ lgnd = (double *) G_calloc (lines.count, sizeof (double));
+ 
+ /* compute transformation for the first time */
+    compute_transformation();
+    
+    
+    /* put head on the report */
+    
+    box_points.top=top;
+    box_points.bottom=top+height-1;
+    box_points.left= left;
+    box_points.right=(right-left)/2;
+    dotext ("        ANALYZE -> POINTS",top, top+height, left, (right-left)/2, 0, RED);
+    Outline_box (box_points.top, box_points.bottom, box_points.left, box_points.right);
+
+    box_lines.top=top;
+    box_lines.bottom=top+height-1;
+    box_lines.left= ((right- left)/2)+1;
+    box_lines.right=right;
+    dotext ("        ANALYZE -> LINES",top, top+height, ((right-left)/2)+1, right, 0, BLACK);
+   Outline_box (box_lines.top, box_lines.bottom, box_lines.left, box_lines.right);
+
+    cury=top;
+    cury = top+height;
+    dotext (LHEAD1, cury, cury+height, left, middle, 0, BLACK);
+    dotext (RHEAD1, cury, cury+height, middle, right-1, 0, BLACK);
+    cury += height;
+    dotext (LHEAD2, cury, cury+height, left, middle, 0, BLACK);
+    dotext (RHEAD2, cury, cury+height, middle, right-1, 0, BLACK);
+
+    cury += height;
+    R_move_abs (left, cury-1);
+    R_cont_abs (right, cury-1);
+
+/* isolate the sidecar */
+    R_standard_color (BLACK);
+    R_move_abs (right, top);
+    R_cont_abs (right, bottom);
+
+/* define report box */
+    report.top = cury;
+    report.left = left;
+    report.right = right;
+    count = 0;
+    first_line = 0;
+
+/* lets do it */
+    pager = 1;
+    while(1)
+      {
+	R_text_size (tsize, tsize);
+	line = 0;
+	curp = first_point;
+	cury = top + 3*height;
+	count=0;
+	while(1)
+	  {
+	    if (line >= nlines || curp >= group.points.count)
+	      break;
+	    if(group.equation_stat > 0 && group.points.status[curp]==1)
+	      {
+		if(use_points)
+		  {
+		    color = BLUE;
+		    FMT1(buf, xres[curp], yres[curp], gnd[curp]);
+		    if (curp == xmax || curp == ymax || curp == gmax)
+		      color = RED;
+		    dotext (buf, cury, cury+height, nums, middle, 0, color);
+		    line++;
+		    cury += height;
+		  }
+	      }
+	    else if(group.points.status[curp] ==2)
+	      {
+		/* if(group.points.status[curp+1]!=3)
+		   break;*/
+		if(!use_points)
+		  {
+		    color = BLUE;
+		    if (count+first_line == tmax || count+first_line == umax || count+first_line == lgmax)
+		      color = RED;
+		    sprintf (buf, "%5.1f %5.1f %5.1f ", tres[count+ first_line],ures[count+first_line],lgnd[count+first_line]);
+		    dotext (buf, cury, cury+height, nums, middle, 0, color);
+		    line++;
+		    cury += height;
+		  }
+		
+		curp++;
+	      }
+	    else if (group.points.status[curp] > 0) 
+	      {
+		FMT0 (buf, curp+1-count);
+		dotext (buf, cury, cury+height, left, nums, 0, BLACK);
+		FMT2(buf,
+		     group.points.e1[curp],
+		     group.points.n1[curp],
+		     group.points.e2[curp],
+		     group.points.n2[curp]);
+		dotext (buf, cury, cury+height, middle, right-1, 0, BLACK);
+		dotext ("?", cury, cury+height, nums, middle, 1, BLACK);
+		line++;
+		cury += height;
+	      }
+	    
+	    else if (group.points.status[curp] == -2 )
+	      {
+		if(group.points.status[curp+1]!=-3)
+		  break;
+		if (!use_points) 
+		  {
+		    dotext ("not used", cury, cury+height, nums, middle, 1, BLUE);
+		    line++;
+		    cury += height;
+		  }
+		curp++;
+	      }
+	    else  if (use_points) 
+	      {
+		dotext ("not used", cury, cury+height, nums, middle, 1, BLACK);
+		line++;
+		cury += height;
+	      }
+	    if (pager)
+	      {
+		if(use_points &&( group.points.status[curp]==1 || group.points.status[curp]==0))
+		  {
+		    
+		    FMT0 (buf, curp+1-2*(first_line+count));
+		    dotext (buf, cury-height, cury, left, nums, 0, BLACK);
+		    FMT2(buf,
+			 group.points.e1[curp],
+			 group.points.n1[curp],
+			 group.points.e2[curp],
+			 group.points.n2[curp]);
+		    dotext (buf, cury-height, cury, middle, right-1, 0, BLACK);
+		  }
+		if(!use_points &&( group.points.status[curp]>1 ||  group.points.status[curp]<-1))
+		  {
+		    FMT0 (buf, first_line + count);
+		    dotext (buf, cury-height, cury, left, nums, 0, BLACK);
+		    sprintf (buf, "%9.1f %9.1f %9.1f %9.1f ",
+			     lines.t1[first_line+count],
+			     lines.u1[first_line+count],
+			     lines.t2[first_line+count],
+			     lines.u2[first_line+count]);
+		    dotext (buf, cury-height, cury, middle, right-1, 0, BLACK);
+		    
+		  }
+	      }
+	    if( group.points.status[curp]>1 ||  group.points.status[curp]<-1)
+	      count++;
+	    curp++;
+	  }
+	report.bottom = cury;
+	if(use_points) 
+	  {
+	    downarrow (&more,  ((group.points.count-curp)-2*(lines.count-(count+first_line)))>0 ? BLACK : BACKGROUND);
+	    uparrow   (&less, first_point > 0  ? BLACK : BACKGROUND);
+	  }
+	if(!use_points) 
+	  {
+	    downarrow (&more,  (lines.count-(count+first_line))>0 ? BLACK : BACKGROUND);
+	    uparrow   (&less, first_point > 0  ? BLACK : BACKGROUND);
+	  }
+	
+	R_standard_color (BACKGROUND);
+	R_box_abs (left, cury, right-1, bottom);
+	if(use_points) {
+	  if (group.equation_stat < 0)
+	    {
+	      color = RED;
+	      strcpy (buf, "Poorly placed control points");
+	    }
+	  else if (group.equation_stat == 0)
+	    {
+	      color = RED;
+	      strcpy (buf, "No active control points");
+	    }
+	  else
+	    {
+	      color = BLACK;
+	      sprintf (buf, "Overall rms error: %.2f", rms);
+	    }
+	}
+	else 
+	  {
+	    if (lines.line_stat < 0)
+	      {
+		color = RED;
+		strcpy (buf, "Poorly placed control points");
+	      }
+	    else if (lines.line_stat == 0)
+	      {
+		color = RED;
+		strcpy (buf, "No active control points");
+	      }
+	    else
+	      {
+		color = BLACK;
+		sprintf (buf, "Overall rms error: %.2f", l_rms);
+	      }
+	  }
+	dotext (buf, bottom-height, bottom, left, right-1, 0, color);
+	R_standard_color (BLACK);
+	R_move_abs (left, bottom-height);
+	R_cont_abs (right-1, bottom-height);
+	
+	pager = 0;
+	which = -1;
+	if(Input_pointer(objects) < 0)
+	  break;
+	
+	
+	
+      }
+    
+    /* all done. restore what was under the window */
+    right += 2*height;	/* move it back over the sidecar */
+    R_standard_color (BACKGROUND);
+    R_box_abs (left, top, right, bottom);
+    R_panel_restore (tempfile1);
+    R_panel_delete (tempfile1);
+    R_flush();
+    
+    free (xres); free (yres); free (gnd);
+    I_put_control_points (group.name, &group.points);
+    display_points(1);
+    return 0; /* return but don't QUIT */
+}
+
+
+static int uparrow (struct box *box, int color)
+{
+    R_standard_color (BLACK);
+    Uparrow (box->top+edge, box->bottom-edge, box->left+edge, box->right-edge);
+
+    return 0;
+}
+
+static int downarrow(struct box *box, int color)
+{
+    R_standard_color (BLACK);
+    Downarrow (box->top+edge, box->bottom-edge, box->left+edge, box->right-edge);
+
+    return 0;
+}
+
+static int pick(int x,int y)
+{
+    int n;
+    int cur;
+    int i;
+
+    cur = which;
+    cancel_which();
+    if (inbox(&more,x,y))
+    {
+	if (use_points && ((group.points.count-curp)-2*(lines.count-(count+first_line)))<=0)
+	    return 0;
+                  if(!use_points && (lines.count-(count+first_line))<=0)
+                      return 0;
+	first_point = curp;
+                 first_line +=count;
+        	pager = 1;
+	return 1;
+    }
+    if (inbox(&box_points,x,y))
+    {
+                 R_text_size (.8*height, .8*height);
+                 use_points=1;
+                 dotext ("        ANALYZE -> POINTS",top, top+height, left, (right-left)/2, 0, RED);
+                 dotext ("        ANALYZE -> LINES",top, top+height,((right-left)/2)+1, right, 0, BLACK);
+                 Outline_box (box_points.top, box_points.bottom, box_points.left, box_points.right);
+                 Outline_box (box_lines.top, box_lines.bottom, box_lines.left, box_lines.right);
+                 dotext (LHEAD2, top+2*height, top+3*height, left, middle, 0, BLACK);
+                 dotext (RHEAD2, top+2*height, top+3*height, middle, right-1, 0, BLACK);
+                 first_point = 0;
+                 first_line = 0;
+                 pager = 1;
+	return 1;
+    }
+    if (inbox(&box_lines,x,y))
+    {
+                 R_text_size (.8*height, .8*height);
+                 use_points=0;
+                 dotext ("        ANALYZE -> LINES",top, top+height, ((right-left)/2)+1, right, 0, RED);
+                 dotext ("        ANALYZE -> POINTS",top, top+height, left, (right-left)/2, 0, BLACK);
+                 Outline_box (box_points.top, box_points.bottom, box_points.left, box_points.right);
+                 Outline_box (box_lines.top, box_lines.bottom, box_lines.left, box_lines.right);
+                 dotext (LLINEHEAD2, top+2*height, top+3*height, left, middle, 0, BLACK);
+                 dotext (RLINEHEAD2, top+2*height, top+3*height, middle, right-1, 0, BLACK);
+                 first_point = 0;
+                 first_line = 0;
+                 pager = 1;
+	return 1;
+    }
+    if (inbox(&less,x,y))
+    {
+	if (first_point == 0)
+	    return 0;
+	first_point = 0;
+                 first_line = 0;
+	pager = 1;
+	return 1;
+    }
+    if (!inbox (&report,x,y))
+    {
+      return 0;
+    }
+
+   n_old = n = (y - report.top)/height;
+    i=0;
+    if(use_points){
+        for (i; i<=n;  i++)
+                if (group.points.status[first_point + i]==2||group.points.status[first_point + i]==-2) n+=2;
+        }
+    else { while (n>=0) {
+                        if (group.points.status[first_point + i]==2||group.points.status[first_point + i]==-2)  {
+                                                                          n--;
+                                                                          i++;
+                                                                          }
+                          i++;
+                                    }
+              n=i-2;
+              }
+    if (n == cur) /* second click! */
+    {
+                 if  (group.points.status[first_point +n]==2||group.points.status[first_point +n]==-2) {
+                         group.points.status[first_point+n] = -group.points.status[first_point+n];
+                         group.points.status[first_point+(n+1)] = -group.points.status[first_point+(n+1)];
+                         lines.status[first_line + n_old] = - lines.status[first_line + n_old];
+                                                 }
+
+                   else
+                         group.points.status[first_point+n] = !group.points.status[first_point+n];
+                 compute_transformation();
+	show_point (first_point+n, 1);
+
+
+           return 1;
+    }
+    which = n;
+    show_point (first_point+n, 0);
+    R_standard_color (RED);
+    Outline_box (report.top + n*height, report.top +(n+1)*height,
+		         report.left, report.right-1);
+    return 0; /* ignore first click */
+
+}
+
+static int done (void)
+{
+  cancel_which();
+  return -1;  
+}
+
+static int cancel_which (void)
+{
+    if (which >= 0)
+    {
+	R_standard_color (BACKGROUND);
+	Outline_box (report.top + which*height, report.top +(which+1)*height,
+		         report.left, report.right-1);
+	show_point (first_point+which, 1);
+    }
+    which = -1;
+
+    return 0;
+}
+
+static int inbox (struct box *box,int x,int y)
+{
+    return (x>box->left && x <box->right && y>box->top && y<box->bottom);
+}
+
+static int dotext (char *text,
+       int top,int bottom,int left,int right,int centered,int color)
+{
+    R_standard_color (BACKGROUND);
+    R_box_abs (left, top, right, bottom);
+    R_standard_color (color);
+    R_move_abs (left+1+edge, bottom-1-edge);
+    if (centered)
+	R_move_rel ((right-left-strlen(text)*size)/2,0);
+    R_set_window (top, bottom, left, right);	/* for text clipping */
+    R_text (text);
+    R_set_window (SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
+
+    return 0;
+}
+
+static int compute_transformation (void)
+{
+    int n, count;
+    double d,d1,d2,sum;
+    double e1, e2, n1, n2;
+    double t1, t2, u1, u2;
+    double xval, yval, gval;
+    double tval, uval, lgval;
+
+    xmax = ymax = gmax = 0;
+    xval = yval = gval = 0.0;
+
+    Compute_equation();     /*trova gli A,B,C che legano punti dell'image a punti del ltarget  */
+     lines.line_stat = compute_georef_equations_lp(&lines);
+
+    if (group.equation_stat <= 0 && lines.line_stat<=0) return 1;
+
+/* compute the row,col error plus ground error
+ * keep track of largest and second largest error
+ */
+    sum = 0.0;
+    rms = 0.0;
+    count = 0;
+    for (n = 0; n < group.points.count && group.equation_stat>0; n++)
+    {
+	if (group.points.status[n] !=1) continue;
+	count++;
+	georef (group.points.e2[n], group.points.n2[n], &e1, &n1, group.E21, group.N21);
+	georef (group.points.e1[n], group.points.n1[n], &e2, &n2, group.E12, group.N12);
+
+	if((d = xres[n] = e1-group.points.e1[n]) < 0)
+	    d = -d;
+	if (d > xval)
+	{
+	    xmax = n;
+	    xval = d;
+	}
+
+	if ((d = yres[n] = n1-group.points.n1[n]) < 0)
+	    d = -d;
+	if (d > yval)
+	{
+	    ymax = n;
+	    yval = d;
+	}
+
+/* compute ground error (ie along diagonal) */
+	d1 = e2 - group.points.e2[n];
+	d2 = n2 - group.points.n2[n];
+	d = d1*d1 + d2*d2;
+	sum += d;                 /* add it to rms sum, before taking sqrt */
+	d = sqrt(d);
+	gnd[n] = d;
+	if (d > gval)             /* is this one the max? */
+	{
+	    gmax = n;
+	    gval = d;
+	}
+
+    }
+/* compute overall rms error */
+     if (count)
+	rms = sqrt (sum/count);
+
+     count =0;
+     tmax = umax = lgmax = 0;
+     tval = uval = lgval = 0.0;
+     sum = 0.0;
+    l_rms = 0.0;
+    for (n = 0; n < lines.count && lines.line_stat>0 ; n++)
+    {
+	if (lines.status[n] !=2) continue;
+	count++;
+	georef (lines.t2[n], lines.u2[n], &t1, &u1, lines.E21, lines.N21);
+	georef (lines.t1[n], lines.u1[n], &t2, &u2, lines.E12, lines.N12);
+	if((d = tres[n] = t1- lines.t1[n]) < 0)
+	    d = -d;
+	if (d > tval)
+	{
+	    tmax = n;
+	    tval = d;
+	}
+
+	if ((d = ures[n] = u1- lines.u1[n]) < 0)
+	    d = -d;
+	if (d > uval)
+	{
+	    umax = n;
+	    uval = d;
+	}
+
+/* compute ground error (ie along diagonal) */
+	d1 = t2 - lines.t2[n];
+	d2 = u2 - lines.u2[n];
+	d = d1*d1 + d2*d2;
+	sum += d;                 /* add it to rms sum, before taking sqrt */
+	d = sqrt(d);
+	lgnd[n] = d;
+	if (d > lgval)             /* is this one the max? */
+	{
+	    lgmax = n;
+	    lgval = d;
+	}
+
+    }
+     if (count)
+	l_rms = sqrt (sum/count);
+
+
+
+    return 0;
+}
+
+static int to_file (void)
+{
+    FILE *fd;
+    char msg[1024];
+
+    cancel_which();
+    if (Input_other (askfile, "Keyboard") < 0)
+    {
+	return 0;
+    }
+
+    fd = fopen (buf, "w");
+    if (fd == NULL)
+    {
+	sprintf (msg, "** Unable to create file %s\n", buf);
+	Beep();
+	Curses_write_window (PROMPT_WINDOW, 2, 1, msg);
+    }
+    else
+    {
+	do_report (fd);
+	fclose (fd);
+	sprintf (msg, "Report saved in file %s\n", buf);
+	Curses_write_window (PROMPT_WINDOW, 2, 1, msg);
+    }
+    return 0;
+}
+
+static int askfile (void)
+{
+    char file[100];
+
+    while (1)
+    {
+	Curses_prompt_gets ("Enter file to hold report: ", file);
+	G_strip (file);
+	if (*file == 0) return -1;
+	if (G_index (file, '/'))
+	    strcpy (buf, file);
+	else
+	    sprintf (buf, "%s/%s", G_home(), file);
+	if (access (buf, 0) != 0)
+	    return 1;
+	sprintf (buf, "** %s already exists. choose another file", file);
+	Beep();
+	Curses_write_window (PROMPT_WINDOW, 2, 1, buf);
+    }
+
+    return 0;
+}
+
+static int to_printer (void)
+{
+    FILE *fd;
+    cancel_which();
+    Menu_msg ("sending report to printer ...");
+
+    fd = popen ("lpr", "w");
+    do_report (fd);
+    pclose (fd);
+    return 0;
+}
+
+static int do_report ( FILE *fd)
+{
+    char buf[100];
+    int n;
+    int width;
+
+    fprintf (fd, "LOCATION: %-20s GROUP: %-20s MAPSET: %s\n\n",
+	G_location(), group.name, G_mapset());
+    fprintf (fd, "%15sAnalysis of control point registration\n\n", "");
+    fprintf (fd, "%s   %s\n", LHEAD1, RHEAD1);
+    fprintf (fd, "%s   %s\n", LHEAD2, RHEAD2);
+
+    FMT1 (buf,0.0,0.0,0.0);
+    width = strlen (buf);
+
+    for (n = 0; n < group.points.count; n++)
+    {
+	FMT0(buf,n+1);
+	fprintf (fd, "%s", buf);
+	if(group.equation_stat > 0 && group.points.status[n] > 0)
+	{
+	    FMT1(buf, xres[n], yres[n], gnd[n]);
+	    fprintf (fd, "%s", buf);
+	}
+	else if (group.points.status[n] > 0)
+	    printcentered (fd, "?", width);
+	else
+	    printcentered (fd, "not used", width);
+	FMT2(buf,
+	    group.points.e1[n],
+	    group.points.n1[n],
+	    group.points.e2[n],
+	    group.points.n2[n]);
+	fprintf (fd, "   %s\n", buf);
+    }
+    fprintf (fd, "\n");
+    if (group.equation_stat < 0)
+	fprintf (fd, "Poorly place control points\n");
+    else if (group.equation_stat == 0)
+	fprintf (fd, "No active control points\n");
+    else
+	fprintf (fd, "Overall rms error: %.2f\n", rms);
+
+    return 0;
+}
+
+static int printcentered (FILE *fd, char *buf,int width)
+{
+    int len;
+    int n;
+    int i;
+
+    len = strlen (buf);
+    n = (width -len)/2;
+
+    for (i = 0; i < n; i++)
+	fprintf (fd, " ");
+    fprintf (fd, "%s", buf);
+    i += len;
+    while (i++ < width)
+	fprintf (fd, " ");
+
+    return 0;
+}
+
+static int show_point(int n,int true_color)
+{
+   int  x_temp[2], y_temp[2];
+   int row,col;
+
+    if (!true_color)
+	R_standard_color (ORANGE);
+    else if(group.points.status[n]>0)
+	R_standard_color (GREEN);
+    else
+	R_standard_color (RED);
+
+    
+    /* Display red_points in VIEW_MAP1_ZOOM */ 
+    
+    if (group.points.status[n]==0 || group.points.status[n] == 1 )
+      display_one_point (VIEW_MAP1_ZOOM, group.points.e1[n], group.points.n1[n]);
+    else 
+      {
+	display_one_point (VIEW_MAP1_ZOOM, group.points.e1[n], group.points.n1[n]);
+	display_one_point (VIEW_MAP1_ZOOM, group.points.e1[n+1], group.points.n1[n+1]);
+	row = northing_to_row (&VIEW_MAP1_ZOOM->cell.head, group.points.n1[n]) + .5;
+	col = easting_to_col  (&VIEW_MAP1_ZOOM->cell.head, group.points.e1[n]) + .5;
+	y_temp[0] = row_to_view (VIEW_MAP1_ZOOM, row);
+	x_temp[0] = col_to_view (VIEW_MAP1_ZOOM, col);
+	
+	row = northing_to_row (&VIEW_MAP1_ZOOM->cell.head, group.points.n1[n+1]) + .5;
+	col = easting_to_col  (&VIEW_MAP1_ZOOM->cell.head,group.points.e1[n+1]) + .5;
+	y_temp[1] = row_to_view (VIEW_MAP1_ZOOM, row);
+	x_temp[1] = col_to_view (VIEW_MAP1_ZOOM, col);
+	
+	R_polyline_abs (x_temp,y_temp,2);
+	R_flush();
+	
+      }
+    
+    
+    /* Display red_points in VIEW_MAP2_ZOOM */ 
+    if (group.points.status[n]==0 || group.points.status[n] == 1 )
+      display_one_point (VIEW_MAP2_ZOOM, group.points.e2[n], group.points.n2[n]);
+    else 
+      {
+	display_one_point (VIEW_MAP2_ZOOM, group.points.e2[n], group.points.n2[n]);
+	display_one_point (VIEW_MAP2_ZOOM, group.points.e2[n+1], group.points.n2[n+1]);
+	row = northing_to_row (&VIEW_MAP2_ZOOM->cell.head, group.points.n2[n]) + .5;
+	col = easting_to_col  (&VIEW_MAP2_ZOOM->cell.head, group.points.e2[n]) + .5;
+	y_temp[0] = row_to_view (VIEW_MAP2_ZOOM, row);
+	x_temp[0] = col_to_view (VIEW_MAP2_ZOOM, col);
+	
+	row = northing_to_row (&VIEW_MAP2_ZOOM->cell.head, group.points.n2[n+1]) + .5;
+	col = easting_to_col  (&VIEW_MAP2_ZOOM->cell.head,group.points.e2[n+1]) + .5;
+	y_temp[1] = row_to_view (VIEW_MAP2_ZOOM, row);
+	x_temp[1] = col_to_view (VIEW_MAP2_ZOOM, col);
+	
+	R_polyline_abs (x_temp,y_temp,2);
+	R_flush();
+	
+      }
+    
+    
+    
+    return 0;
+}
+
+
+int points_to_line (double e1, double n1, double e2, double n2, double *t, double *u)
+{
+        double a,b,c;
+        a=-(n2 - n1);
+        b= (e2 - e1);
+        c= (n2*e1 - n1*e2);
+        *t= a/c;
+        *u=b/c;
+  }
+
+int new_control_line ( Lines *ln,
+    double t1,double u1,double t2,double u2,int status)
+{
+    int i;
+    unsigned int size;
+
+    i = (ln->count)++ ;
+    size =  ln->count * sizeof(double) ;
+    ln->t1 = (double *) G_realloc (ln->t1, size);
+    ln->t2 = (double *) G_realloc (ln->t2, size);
+    ln->u1 = (double *) G_realloc (ln->u1, size);
+    ln->u2 = (double *) G_realloc (ln->u2, size);
+    size =  ln->count * sizeof(int) ;
+    ln->status = (int *) G_realloc (ln->status, size);
+
+    ln->t1[i] = t1;
+    ln->t2[i] = t2;
+    ln->u1[i] = u1;
+    ln->u2[i] = u2;
+    ln->status[i] = status;
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/ask.c
===================================================================
--- grass-addons/i.points.auto/ask.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/ask.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,676 +0,0 @@
-#include <string.h>
-#include <stdlib.h>
-#include <grass/gis.h>
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-#define NLINES 18
-
-struct box
-{
-    int top, bottom, left,right;
-};
-
-static int pick(int,int,int);
-static int downarrow(struct box *,int);
-static int uparrow(struct box *,int);
-static int dobox(struct box *,char *,int,int,int,int,int);
-static int dotext(char *,int ,int ,int ,int ,int );
-static int inbox(struct box *,int ,int );
-static int cancel_which();
-
-static int text_size;
-static int which;
-static struct box cancel, more, less;
-static int height, size, edge, count;
-static int page,npages;
-static struct
-{
-    char name[GNAME_MAX], mapset[GMAPSET_MAX];
-    struct box box;
-} list[NLINES*2];
-
-int 
-ask_gis_files (char *type, char *file, char *xname, char *xmapset, int position)
-{
-    static int use = 1;
-    int pick();
-    static Objects objects[]=
-    {
-	OTHER(pick,&use),
-	{0}
-    };
-
-    char msg[100];
-    FILE *fd;
-    int width;
-    int len1, len2, len;
-    long offset;
-    long *page_offset;
-    int col, nlist;
-    int line;
-    int stat;
-    char buf[100];
-    int top, bottom, left, right, center;
-    int topx, bottomx, leftx, rightx, widthx;
-    char name[GNAME_MAX], mapset[GMAPSET_MAX], cur_mapset[GMAPSET_MAX];
-    int new_mapset;
-    char debugmsg[200];
-
-    Menu_msg("");
-     debug("ask_gis_files todo\n");
-
-    fd = fopen (file, "r");
-    if (fd == NULL)
-	G_fatal_error ("ask_gis_files: can't read tempfile");
-    if (fread (&len1, sizeof(len1), 1, fd) != 1 
-    ||  fread (&len2, sizeof(len2), 1, fd) != 1
-    ||  len1 <= 0 || len2 <= 0)
-    {
-	fclose (fd);
-	return 0;
-    }
-
-    sprintf (msg, "Double click on %s file to be plotted", type);
-
-/*
- * build a popup window at center of the screen.
- * 35% the height and wide enough to hold 2 columms of file names
- *
- * the window is for choosing file names and will be laid out in 2 columns
- *
- *             ------------------------------------------
- *             |     CANCEL           | (MORE) | (LESS) | 
- *             ------------------------------------------
- *             |             mapset                     |
- *             ------------------------------------------
- *             |      name1        |   name2            |
- *             ------------------------------------------
- *             |      name3        |   name4            |
- *             ------------------------------------------
- *             |      name5        |   name6            |
- *             |                   .                    |
- *             |                   .                    |
- *             |                   .                    |
- *             ------------------------------------------
- */
-
-/* height of 1 line, based on NLINES taking up 35% vertical space */
-    height = (.35 * (SCREEN_BOTTOM - SCREEN_TOP))/NLINES + 1;
-
-/* size of text, 80% of line height */
-    text_size = .8 * height;
-    size = text_size - 1;	/* fudge for computing pixels width of text */
-
-/* indent for the text */
-    edge = .1 * height + 1;
-
-/* this is a fudge to determine the length of the largest text */
-    len1 = 2 * len1 ;	/* name in 2 columns */
-    len2 += strlen ("mapset ");
-    len = (len1 > len2 ? len1 : len2);
-
-/* width is for max chars plus sidecar for more/less */
-    width = len * size + height;
-    widthx = strlen(msg) * size;
-    if (widthx < width)
-	widthx = width;
-
-/* define the window */
-    top = (SCREEN_TOP + SCREEN_BOTTOM - height*NLINES)/2;
-    bottom = top + height*NLINES;
-
-    center = (SCREEN_LEFT + SCREEN_RIGHT)/2;
-    if (position > 0)
-    {
-	right = (center + SCREEN_RIGHT + width)/2;
-	if (right >= SCREEN_RIGHT)
-	    right = SCREEN_RIGHT-1;
-	left = right - width;
-    }
-    else if (position < 0)
-    {
-	left = (center + SCREEN_LEFT - width)/2;
-	if (left <= SCREEN_LEFT)
-	    left = SCREEN_LEFT+1;
-	right = left + width;
-    }
-    else
-    {
-	left = center + width/2;
-	right = left + width;
-    }
-
-    topx = top - 3 *height;
-    bottomx = topx + 2*height;
-    leftx = (left+right-widthx)/2;
-    if (leftx < SCREEN_LEFT)
-	leftx = SCREEN_LEFT;
-    rightx = leftx + widthx;
-
-/* save what is under these areas, so they can be restored */
-    R_panel_save (tempfile1, top, bottom, left, right);
-    R_panel_save (tempfile2, topx, bottomx, leftx, rightx);
-
-/* fill it top with GREY, pick area with white */
-    R_standard_color (WHITE);
-    R_box_abs (left, top, right, bottom);
-    R_standard_color (BLACK);                    /* GREY  */
-    R_box_abs (leftx, topx, rightx, bottomx);
-
-    R_standard_color (BLUE);                      /* BLACK*/
-    Outline_box (top, bottom, left, right);
-    right -=height;	/* reduce it to exclude sidecar */
-    Outline_box (top, bottom, left, right);
-
-/* print messages above the files */
-    R_standard_color (ORANGE);/*WHITE*/                      /* ADDED */
-    dotext (msg, topx, topx+height, leftx, rightx, 1);
-    dotext ("Double click here to cancel", topx+height, bottomx, leftx, rightx, 1);
-    cancel.top = topx;
-    cancel.bottom = bottomx;
-    cancel.left = leftx;
-    cancel.right = rightx;
-
-/* start the mouse in the cancel box */
-    Set_mouse_xy ((leftx + rightx)/2, (topx + bottomx)/2);
-
-    dobox (&less,   "",       BLUE, top, right, right+height,0);
-    dobox (&more,   "",       BLUE, bottom-height, right, right+height,0);
-
-/* as we read the file of names, keep track of pages so we can
- * page backward
- */
-    page = 0;
-    page_offset = (long *) G_calloc (npages=1, sizeof(long));
-    *page_offset = ftell(fd);
-
-    nlist = sizeof (list)/ sizeof(list[0]);
-    for (stat = -1; stat < 0;)
-    {
-	line = 0;
-	count = 0;
-	*cur_mapset = 0;
-	col = 0;         
-	while(1)
-	{
-	    offset = ftell (fd);
-	    if (fgets (buf, sizeof buf, fd) == NULL
-	    || sscanf (buf, "%s %s", name, mapset) != 2)
-		break;
-	    sprintf(debugmsg, "fgets name: %s\n", name);
-            debug(debugmsg);
-	    if(new_mapset = (strcmp (cur_mapset,mapset) != 0))
-	    {
-		if(line) line++;
-		if (col) line++;
-		col = 0;
-	    }
-	    if (count >= nlist || line+new_mapset >= NLINES)
-	    {
-		if (page+1 == npages)
-		{
-		    npages++;
-		    page_offset = (long *) G_realloc (page_offset, npages * sizeof (long));
-		    page_offset[npages-1] = offset;
-		}
-		break;
-	    }
-	    if (new_mapset)
-	    {
-		struct box dummy;
-		char label[GMAPSET_MAX+7];
-
-		strcpy (cur_mapset, mapset);
-		sprintf (label, "Mapset %s", mapset);
-		dobox (&dummy, label, GREY, top+line*height, left, right, 0);
-		line++;
-	    }
-	    if (col)
-	    {
-	      dobox (&list[count].box, name, WHITE, top+line*height, left+width/2, right, 0);  
-		line++;
-		col = 0;
-	    }
-	    else
-	    {
-		dobox (&list[count].box, name, WHITE, top+line*height, left, left+width/2, 0);
-		col = 1;
-	    }
-
-	    strcpy (list[count].name, name);
-	    strcpy (list[count].mapset, mapset);
-	    count++;
-	}
-
-	downarrow (&more, page+1 < npages ? BLACK : WHITE);   
-	uparrow   (&less, page   > 0      ? BLACK : WHITE);
-	which = -1;
-	switch(Input_pointer(objects))
-	{
-	case -1: /* more or less */
-		break;
-	case -2: /* cancel */
-		stat = 0;
-		continue;
-	default: /* file picked */
-		strcpy (xname, list[which].name);
-		strcpy (xmapset, list[which].mapset);
-		stat = 1;
-		continue;
-	}
-	fseek (fd, page_offset[page], 0);
-	R_standard_color (WHITE);
-	R_box_abs (left+1, top+1, right-1, bottom-1);
-    }
-
-/* all done. restore what was under the window */
-    right += height;	/* move it back over the sidecar */
-    R_standard_color (WHITE);
-    R_box_abs (left, top, right, bottom);
-    R_panel_restore (tempfile1);
-    R_panel_restore (tempfile2);
-    R_panel_delete (tempfile1);
-    R_panel_delete (tempfile2);
-    R_flush();
-
-    G_free (page_offset);
-    return stat;
-}
-
-
-
-
-
-
-
-
-
-
-int 
-ask_original_map(char *type, char *file, char *xname, char *xmapset, int position)
-{
-    static int use = 1;
-    int pick();
-    static Objects objects[]=
-    {
-	OTHER(pick,&use),
-	{0}
-    };
-
-    char msg[100];
-    FILE *fd;
-    int width;
-    int len1, len2, len;
-    long offset;
-    long *page_offset;
-    int col, nlist;
-    int line;
-    int stat;
-    char buf[100];
-    int top, bottom, left, right, center;
-    int topx, bottomx, leftx, rightx, widthx;
-    char name[GNAME_MAX], mapset[GMAPSET_MAX], cur_mapset[GMAPSET_MAX];
-    int new_mapset;
-
-    Menu_msg("");
-     
-    fd = fopen (file, "r");
-    if (fd == NULL)
-	G_fatal_error ("ask_gis_files: can't read tempfile");
-    if (fread (&len1, sizeof(len1), 1, fd) != 1 
-    ||  fread (&len2, sizeof(len2), 1, fd) != 1
-    ||  len1 <= 0 || len2 <= 0)
-    {
-	fclose (fd);
-	return 0;
-	}
-
-    sprintf (msg, "Double click on the final %s map  ", type);
-
-/*
- * build a popup window at center of the screen.
- * 35% the height and wide enough to hold 2 columms of file names
- *
- * the window is for choosing file names and will be laid out in 2 columns
- *
- *             ------------------------------------------
- *             |     CANCEL           | (MORE) | (LESS) | 
- *             ------------------------------------------
- *             |             mapset                     |
- *             ------------------------------------------
- *             |      name1        |   name2            |
- *             ------------------------------------------
- *             |      name3        |   name4            |
- *             ------------------------------------------
- *             |      name5        |   name6            |
- *             |                   .                    |
- *             |                   .                    |
- *             |                   .                    |
- *             ------------------------------------------
- */
-
-
-
-/* height of 1 line, based on NLINES taking up 35% vertical space */
-    height = (.35 * (SCREEN_BOTTOM - SCREEN_TOP))/NLINES + 1;
-
-/* size of text, 80% of line height */
-    text_size = .8 * height;
-    size = text_size - 1;	/* fudge for computing pixels width of text */
-
-/* indent for the text */
-    edge = .1 * height + 1;
-
-/* this is a fudge to determine the length of the largest text */
-    len1 = 2 * len1 ;	/* name in 2 columns */
-    len2 += strlen ("mapset ");
-    len = (len1 > len2 ? len1 : len2);
-
-/* width is for max chars plus sidecar for more/less */
-    width = len * size + height;
-    widthx = strlen(msg) * size;
-    if (widthx < width)
-	widthx = width;
-
-/* define the window */
-    top = (SCREEN_TOP + SCREEN_BOTTOM - height*NLINES)/2;
-    bottom = top + height*NLINES;
-
-    center = (SCREEN_LEFT + SCREEN_RIGHT)/2;
-    if (position > 0)
-    {
-	right = (center + SCREEN_RIGHT + width)/2;
-	if (right >= SCREEN_RIGHT)
-	    right = SCREEN_RIGHT-1;
-	left = right - width;
-    }
-    else if (position < 0)
-    {
-	left = (center + SCREEN_LEFT - width)/2;
-	if (left <= SCREEN_LEFT)
-	    left = SCREEN_LEFT+1;
-	right = left + width;
-    }
-    else
-    {
-	left = center + width/2;
-	right = left + width;
-    }
-
-    topx = top - 3 *height;
-    bottomx = topx + 2*height;
-    leftx = (left+right-widthx)/2;
-    if (leftx < SCREEN_LEFT)
-	leftx = SCREEN_LEFT;
-    rightx = leftx + widthx;
-
-
-
-
-/* save what is under these areas, so they can be restored */
-    R_panel_save (tempfile1, top, bottom, left, right);
-    R_panel_save (tempfile2, topx, bottomx, leftx, rightx);
-
-/* fill it top with GREY, pick area with white */
-    R_standard_color (WHITE);
-    R_box_abs (left, top, right, bottom);
-    R_standard_color (BLACK);
-    R_box_abs (leftx, topx, rightx, bottomx);
-
-    R_standard_color (BLUE); /*BLACK */
-    Outline_box (top, bottom, left, right);
-    right -=height;	/* reduce it to exclude sidecar */
-    Outline_box (top, bottom, left, right);
-
-/* print messages above the files */
-    R_standard_color (ORANGE); /*BLACK */
-    dotext (msg, topx, topx+height, leftx, rightx, 1);
-    dotext ("Double click here to cancel", topx+height, bottomx, leftx, rightx, 1);
-    cancel.top = topx;
-    cancel.bottom = bottomx;
-    cancel.left = leftx;
-    cancel.right = rightx;
-
-/* start the mouse in the cancel box */
-    Set_mouse_xy ((leftx + rightx)/2, (topx + bottomx)/2);
-
-    dobox (&less,   "",       BLUE, top, right, right+height,0);
-    dobox (&more,   "",       BLUE, bottom-height, right, right+height,0);
-
-/* as we read the file of names, keep track of pages so we can
- * page backward
- */
-    page = 0;
-    page_offset = (long *) G_calloc (npages=1, sizeof(long));
-    *page_offset = ftell(fd);
-
-
-
-    nlist = sizeof (list)/ sizeof(list[0]);
-    for (stat = -1; stat < 0;)
-    {
-	line = 0;
-	count = 0;
-	*cur_mapset = 0;
-	col = 0;
-	while(1)
-	{ 
-
-	    offset = ftell (fd);
-	    if (fgets (buf, sizeof buf, fd) == NULL
-	    || sscanf (buf, "%s %s", name, mapset) != 2)
-		break;
-	    if(new_mapset = (strcmp (cur_mapset,mapset) != 0))
-	    {
-		if(line) line++;
-		if (col) line++;
-		col = 0;
-	    }
-	    if (count >= nlist || line+new_mapset >= NLINES)
-	    {
-		if (page+1 == npages)
-		{
-		    npages++;
-		    page_offset = (long *) G_realloc (page_offset, npages * sizeof (long));
-		    page_offset[npages-1] = offset;
-		}
-		break;
-	    }
-	    if (new_mapset)
-	    {
-		struct box dummy;
-		char label[GMAPSET_MAX+7];
-
-		strcpy (cur_mapset, mapset);
-		sprintf (label, "Mapset %s", mapset);
-		dobox (&dummy, label, GREY, top+line*height, left, right, 0);
-		line++;
-	    }
-	    if (col)
-	    {
-		dobox (&list[count].box, name, WHITE, top+line*height, left+width/2, right, 0);
-		line++;
-		col = 0;
-	    }
-	    else
-	    {
-	      dobox (&list[count].box, name, WHITE, top+line*height, left, left+width/2, 0);
-		col = 1;
-	    }
-	    strcpy (list[count].name, name);
-	    strcpy (list[count].mapset, mapset);
-	    count++;
-	}
-	downarrow (&more, page+1 < npages ? BLACK : WHITE);
-	uparrow   (&less, page   > 0      ? BLACK : WHITE);
-	which = -1;
-
-
-
-
-
-	switch(Input_pointer(objects))
-	{
-	case -1: /* more or less */
-		break;
-	case -2: /* cancel */
-		stat = 0;
-		continue;
-	default: /* file picked */
-		strcpy (xname, list[which].name);
-		strcpy (xmapset, list[which].mapset);
-		stat = 1;
-		continue;
-	}
-	fseek (fd, page_offset[page], 0);
-	R_standard_color (WHITE);
-	R_box_abs (left+1, top+1, right-1, bottom-1);
-    }
-
-
-
-/* all done. restore what was under the window */
-    right += height;	/* move it back over the sidecar */
-    R_standard_color (WHITE);
-    R_box_abs (left, top, right, bottom);
-    R_panel_restore (tempfile1);
-    R_panel_restore (tempfile2);
-    R_panel_delete (tempfile1);
-    R_panel_delete (tempfile2);
-    R_flush();
-
-
-    G_free (page_offset);
-    return stat;
-}
-
-
-
-
-
-
-
-static int dobox(struct box *box, char *text,int color,int top,int left,int right,int centered)
-{
-    int bottom;
-
-    bottom = top+height;
-/* fill inside of box with color */
-    R_standard_color (color);
-    R_box_abs (left+1, top+1, right-1, bottom-1);
-
-/* draw box outline and text in black */
-    R_standard_color (BLUE);                     /*BLACK*/
-    Outline_box (top, bottom, left, right);
-    R_standard_color (BLACK);                    /* ADDED. It determines the colour of text in the table */
-    dotext (text, top, bottom, left, right, centered);
-
-    box->top = top;
-    box->bottom = bottom;
-    box->left = left;
-    box->right = right;
-
-    return 0;
-}
-
-static int uparrow(struct box *box,int color)
-{
-    R_standard_color (color);
-    Uparrow (box->top+edge, box->bottom-edge, box->left+edge, box->right-edge);
-
-    return 0;
-}
-
-static int downarrow ( struct box *box,int color)
-{
-    R_standard_color (color);
-    Downarrow (box->top+edge, box->bottom-edge, box->left+edge, box->right-edge);
-
-    return 0;
-}
-
-static int pick(int x,int y,int button)
-{
-    int n;
-
-    if (inbox(&more,x,y))
-    {
-	cancel_which();
-	if (page+1 >= npages)
-	    return 0;
-	page++;
-	return -1;
-    }
-    if (inbox(&less,x,y))
-    {
-	cancel_which();
-	if (page == 0)
-	    return 0;
-	page--;
-	return -1;
-    }
-    if (inbox(&cancel,x,y))
-    {
-	if (which == -2)
-	    return -2;
-	cancel_which();
-	which = -2;
-	R_standard_color (RED);
-	Outline_box (cancel.top, cancel.bottom, cancel.left, cancel.right);
-	return 0;
-    }
-/* search name list. handle double click */
-    for (n = 0; n < count; n++)
-	if (inbox(&list[n].box,x,y))
-	{
-	    if (n == which) /* second click! */
-		return 1;
-	    cancel_which();
-	    which = n;
-	    R_standard_color (RED);
-	    Outline_box (list[n].box.top, list[n].box.bottom,
-		         list[n].box.left, list[n].box.right);
-	    return 0; /* ignore first click */
-	}
-
-    cancel_which();
-    return 0;
-}
-
-static int 
-cancel_which (void)
-{
-    if (which == -2)
-    {
-	R_standard_color (BLACK);
-	Outline_box (cancel.top, cancel.bottom, cancel.left, cancel.right);
-    }
-    else if (which >= 0)
-    {
-	R_standard_color (BLACK);
-	Outline_box (list[which].box.top, list[which].box.bottom,
-		     list[which].box.left, list[which].box.right);
-    }
-    which = -1;
-
-    return 0;
-}
-
-static int inbox(struct box *box,int x,int y)
-{
-    return (x>box->left && x <box->right && y>box->top && y<box->bottom);
-}
-
-static int dotext(char *text,int top,int bottom,int left,int right,int centered)
-{
-    R_text_size (text_size, text_size);
-    R_move_abs (left+1+edge, bottom-1-edge);
-    if (centered)
-	R_move_rel ((right-left-strlen(text)*size)/2,0);
-    R_set_window (top, bottom, left, right);	/* for text clipping */
-    R_text (text);
-    R_set_window (SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/ask.c (from rev 30335, grass-addons/i.points.auto/ask.c)
===================================================================
--- grass-addons/imagery/i.points.auto/ask.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/ask.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,676 @@
+#include <string.h>
+#include <stdlib.h>
+#include <grass/gis.h>
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+#define NLINES 18
+
+struct box
+{
+    int top, bottom, left,right;
+};
+
+static int pick(int,int,int);
+static int downarrow(struct box *,int);
+static int uparrow(struct box *,int);
+static int dobox(struct box *,char *,int,int,int,int,int);
+static int dotext(char *,int ,int ,int ,int ,int );
+static int inbox(struct box *,int ,int );
+static int cancel_which();
+
+static int text_size;
+static int which;
+static struct box cancel, more, less;
+static int height, size, edge, count;
+static int page,npages;
+static struct
+{
+    char name[GNAME_MAX], mapset[GMAPSET_MAX];
+    struct box box;
+} list[NLINES*2];
+
+int 
+ask_gis_files (char *type, char *file, char *xname, char *xmapset, int position)
+{
+    static int use = 1;
+    int pick();
+    static Objects objects[]=
+    {
+	OTHER(pick,&use),
+	{0}
+    };
+
+    char msg[100];
+    FILE *fd;
+    int width;
+    int len1, len2, len;
+    long offset;
+    long *page_offset;
+    int col, nlist;
+    int line;
+    int stat;
+    char buf[100];
+    int top, bottom, left, right, center;
+    int topx, bottomx, leftx, rightx, widthx;
+    char name[GNAME_MAX], mapset[GMAPSET_MAX], cur_mapset[GMAPSET_MAX];
+    int new_mapset;
+    char debugmsg[200];
+
+    Menu_msg("");
+     debug("ask_gis_files todo\n");
+
+    fd = fopen (file, "r");
+    if (fd == NULL)
+	G_fatal_error ("ask_gis_files: can't read tempfile");
+    if (fread (&len1, sizeof(len1), 1, fd) != 1 
+    ||  fread (&len2, sizeof(len2), 1, fd) != 1
+    ||  len1 <= 0 || len2 <= 0)
+    {
+	fclose (fd);
+	return 0;
+    }
+
+    sprintf (msg, "Double click on %s file to be plotted", type);
+
+/*
+ * build a popup window at center of the screen.
+ * 35% the height and wide enough to hold 2 columms of file names
+ *
+ * the window is for choosing file names and will be laid out in 2 columns
+ *
+ *             ------------------------------------------
+ *             |     CANCEL           | (MORE) | (LESS) | 
+ *             ------------------------------------------
+ *             |             mapset                     |
+ *             ------------------------------------------
+ *             |      name1        |   name2            |
+ *             ------------------------------------------
+ *             |      name3        |   name4            |
+ *             ------------------------------------------
+ *             |      name5        |   name6            |
+ *             |                   .                    |
+ *             |                   .                    |
+ *             |                   .                    |
+ *             ------------------------------------------
+ */
+
+/* height of 1 line, based on NLINES taking up 35% vertical space */
+    height = (.35 * (SCREEN_BOTTOM - SCREEN_TOP))/NLINES + 1;
+
+/* size of text, 80% of line height */
+    text_size = .8 * height;
+    size = text_size - 1;	/* fudge for computing pixels width of text */
+
+/* indent for the text */
+    edge = .1 * height + 1;
+
+/* this is a fudge to determine the length of the largest text */
+    len1 = 2 * len1 ;	/* name in 2 columns */
+    len2 += strlen ("mapset ");
+    len = (len1 > len2 ? len1 : len2);
+
+/* width is for max chars plus sidecar for more/less */
+    width = len * size + height;
+    widthx = strlen(msg) * size;
+    if (widthx < width)
+	widthx = width;
+
+/* define the window */
+    top = (SCREEN_TOP + SCREEN_BOTTOM - height*NLINES)/2;
+    bottom = top + height*NLINES;
+
+    center = (SCREEN_LEFT + SCREEN_RIGHT)/2;
+    if (position > 0)
+    {
+	right = (center + SCREEN_RIGHT + width)/2;
+	if (right >= SCREEN_RIGHT)
+	    right = SCREEN_RIGHT-1;
+	left = right - width;
+    }
+    else if (position < 0)
+    {
+	left = (center + SCREEN_LEFT - width)/2;
+	if (left <= SCREEN_LEFT)
+	    left = SCREEN_LEFT+1;
+	right = left + width;
+    }
+    else
+    {
+	left = center + width/2;
+	right = left + width;
+    }
+
+    topx = top - 3 *height;
+    bottomx = topx + 2*height;
+    leftx = (left+right-widthx)/2;
+    if (leftx < SCREEN_LEFT)
+	leftx = SCREEN_LEFT;
+    rightx = leftx + widthx;
+
+/* save what is under these areas, so they can be restored */
+    R_panel_save (tempfile1, top, bottom, left, right);
+    R_panel_save (tempfile2, topx, bottomx, leftx, rightx);
+
+/* fill it top with GREY, pick area with white */
+    R_standard_color (WHITE);
+    R_box_abs (left, top, right, bottom);
+    R_standard_color (BLACK);                    /* GREY  */
+    R_box_abs (leftx, topx, rightx, bottomx);
+
+    R_standard_color (BLUE);                      /* BLACK*/
+    Outline_box (top, bottom, left, right);
+    right -=height;	/* reduce it to exclude sidecar */
+    Outline_box (top, bottom, left, right);
+
+/* print messages above the files */
+    R_standard_color (ORANGE);/*WHITE*/                      /* ADDED */
+    dotext (msg, topx, topx+height, leftx, rightx, 1);
+    dotext ("Double click here to cancel", topx+height, bottomx, leftx, rightx, 1);
+    cancel.top = topx;
+    cancel.bottom = bottomx;
+    cancel.left = leftx;
+    cancel.right = rightx;
+
+/* start the mouse in the cancel box */
+    Set_mouse_xy ((leftx + rightx)/2, (topx + bottomx)/2);
+
+    dobox (&less,   "",       BLUE, top, right, right+height,0);
+    dobox (&more,   "",       BLUE, bottom-height, right, right+height,0);
+
+/* as we read the file of names, keep track of pages so we can
+ * page backward
+ */
+    page = 0;
+    page_offset = (long *) G_calloc (npages=1, sizeof(long));
+    *page_offset = ftell(fd);
+
+    nlist = sizeof (list)/ sizeof(list[0]);
+    for (stat = -1; stat < 0;)
+    {
+	line = 0;
+	count = 0;
+	*cur_mapset = 0;
+	col = 0;         
+	while(1)
+	{
+	    offset = ftell (fd);
+	    if (fgets (buf, sizeof buf, fd) == NULL
+	    || sscanf (buf, "%s %s", name, mapset) != 2)
+		break;
+	    sprintf(debugmsg, "fgets name: %s\n", name);
+            debug(debugmsg);
+	    if(new_mapset = (strcmp (cur_mapset,mapset) != 0))
+	    {
+		if(line) line++;
+		if (col) line++;
+		col = 0;
+	    }
+	    if (count >= nlist || line+new_mapset >= NLINES)
+	    {
+		if (page+1 == npages)
+		{
+		    npages++;
+		    page_offset = (long *) G_realloc (page_offset, npages * sizeof (long));
+		    page_offset[npages-1] = offset;
+		}
+		break;
+	    }
+	    if (new_mapset)
+	    {
+		struct box dummy;
+		char label[GMAPSET_MAX+7];
+
+		strcpy (cur_mapset, mapset);
+		sprintf (label, "Mapset %s", mapset);
+		dobox (&dummy, label, GREY, top+line*height, left, right, 0);
+		line++;
+	    }
+	    if (col)
+	    {
+	      dobox (&list[count].box, name, WHITE, top+line*height, left+width/2, right, 0);  
+		line++;
+		col = 0;
+	    }
+	    else
+	    {
+		dobox (&list[count].box, name, WHITE, top+line*height, left, left+width/2, 0);
+		col = 1;
+	    }
+
+	    strcpy (list[count].name, name);
+	    strcpy (list[count].mapset, mapset);
+	    count++;
+	}
+
+	downarrow (&more, page+1 < npages ? BLACK : WHITE);   
+	uparrow   (&less, page   > 0      ? BLACK : WHITE);
+	which = -1;
+	switch(Input_pointer(objects))
+	{
+	case -1: /* more or less */
+		break;
+	case -2: /* cancel */
+		stat = 0;
+		continue;
+	default: /* file picked */
+		strcpy (xname, list[which].name);
+		strcpy (xmapset, list[which].mapset);
+		stat = 1;
+		continue;
+	}
+	fseek (fd, page_offset[page], 0);
+	R_standard_color (WHITE);
+	R_box_abs (left+1, top+1, right-1, bottom-1);
+    }
+
+/* all done. restore what was under the window */
+    right += height;	/* move it back over the sidecar */
+    R_standard_color (WHITE);
+    R_box_abs (left, top, right, bottom);
+    R_panel_restore (tempfile1);
+    R_panel_restore (tempfile2);
+    R_panel_delete (tempfile1);
+    R_panel_delete (tempfile2);
+    R_flush();
+
+    G_free (page_offset);
+    return stat;
+}
+
+
+
+
+
+
+
+
+
+
+int 
+ask_original_map(char *type, char *file, char *xname, char *xmapset, int position)
+{
+    static int use = 1;
+    int pick();
+    static Objects objects[]=
+    {
+	OTHER(pick,&use),
+	{0}
+    };
+
+    char msg[100];
+    FILE *fd;
+    int width;
+    int len1, len2, len;
+    long offset;
+    long *page_offset;
+    int col, nlist;
+    int line;
+    int stat;
+    char buf[100];
+    int top, bottom, left, right, center;
+    int topx, bottomx, leftx, rightx, widthx;
+    char name[GNAME_MAX], mapset[GMAPSET_MAX], cur_mapset[GMAPSET_MAX];
+    int new_mapset;
+
+    Menu_msg("");
+     
+    fd = fopen (file, "r");
+    if (fd == NULL)
+	G_fatal_error ("ask_gis_files: can't read tempfile");
+    if (fread (&len1, sizeof(len1), 1, fd) != 1 
+    ||  fread (&len2, sizeof(len2), 1, fd) != 1
+    ||  len1 <= 0 || len2 <= 0)
+    {
+	fclose (fd);
+	return 0;
+	}
+
+    sprintf (msg, "Double click on the final %s map  ", type);
+
+/*
+ * build a popup window at center of the screen.
+ * 35% the height and wide enough to hold 2 columms of file names
+ *
+ * the window is for choosing file names and will be laid out in 2 columns
+ *
+ *             ------------------------------------------
+ *             |     CANCEL           | (MORE) | (LESS) | 
+ *             ------------------------------------------
+ *             |             mapset                     |
+ *             ------------------------------------------
+ *             |      name1        |   name2            |
+ *             ------------------------------------------
+ *             |      name3        |   name4            |
+ *             ------------------------------------------
+ *             |      name5        |   name6            |
+ *             |                   .                    |
+ *             |                   .                    |
+ *             |                   .                    |
+ *             ------------------------------------------
+ */
+
+
+
+/* height of 1 line, based on NLINES taking up 35% vertical space */
+    height = (.35 * (SCREEN_BOTTOM - SCREEN_TOP))/NLINES + 1;
+
+/* size of text, 80% of line height */
+    text_size = .8 * height;
+    size = text_size - 1;	/* fudge for computing pixels width of text */
+
+/* indent for the text */
+    edge = .1 * height + 1;
+
+/* this is a fudge to determine the length of the largest text */
+    len1 = 2 * len1 ;	/* name in 2 columns */
+    len2 += strlen ("mapset ");
+    len = (len1 > len2 ? len1 : len2);
+
+/* width is for max chars plus sidecar for more/less */
+    width = len * size + height;
+    widthx = strlen(msg) * size;
+    if (widthx < width)
+	widthx = width;
+
+/* define the window */
+    top = (SCREEN_TOP + SCREEN_BOTTOM - height*NLINES)/2;
+    bottom = top + height*NLINES;
+
+    center = (SCREEN_LEFT + SCREEN_RIGHT)/2;
+    if (position > 0)
+    {
+	right = (center + SCREEN_RIGHT + width)/2;
+	if (right >= SCREEN_RIGHT)
+	    right = SCREEN_RIGHT-1;
+	left = right - width;
+    }
+    else if (position < 0)
+    {
+	left = (center + SCREEN_LEFT - width)/2;
+	if (left <= SCREEN_LEFT)
+	    left = SCREEN_LEFT+1;
+	right = left + width;
+    }
+    else
+    {
+	left = center + width/2;
+	right = left + width;
+    }
+
+    topx = top - 3 *height;
+    bottomx = topx + 2*height;
+    leftx = (left+right-widthx)/2;
+    if (leftx < SCREEN_LEFT)
+	leftx = SCREEN_LEFT;
+    rightx = leftx + widthx;
+
+
+
+
+/* save what is under these areas, so they can be restored */
+    R_panel_save (tempfile1, top, bottom, left, right);
+    R_panel_save (tempfile2, topx, bottomx, leftx, rightx);
+
+/* fill it top with GREY, pick area with white */
+    R_standard_color (WHITE);
+    R_box_abs (left, top, right, bottom);
+    R_standard_color (BLACK);
+    R_box_abs (leftx, topx, rightx, bottomx);
+
+    R_standard_color (BLUE); /*BLACK */
+    Outline_box (top, bottom, left, right);
+    right -=height;	/* reduce it to exclude sidecar */
+    Outline_box (top, bottom, left, right);
+
+/* print messages above the files */
+    R_standard_color (ORANGE); /*BLACK */
+    dotext (msg, topx, topx+height, leftx, rightx, 1);
+    dotext ("Double click here to cancel", topx+height, bottomx, leftx, rightx, 1);
+    cancel.top = topx;
+    cancel.bottom = bottomx;
+    cancel.left = leftx;
+    cancel.right = rightx;
+
+/* start the mouse in the cancel box */
+    Set_mouse_xy ((leftx + rightx)/2, (topx + bottomx)/2);
+
+    dobox (&less,   "",       BLUE, top, right, right+height,0);
+    dobox (&more,   "",       BLUE, bottom-height, right, right+height,0);
+
+/* as we read the file of names, keep track of pages so we can
+ * page backward
+ */
+    page = 0;
+    page_offset = (long *) G_calloc (npages=1, sizeof(long));
+    *page_offset = ftell(fd);
+
+
+
+    nlist = sizeof (list)/ sizeof(list[0]);
+    for (stat = -1; stat < 0;)
+    {
+	line = 0;
+	count = 0;
+	*cur_mapset = 0;
+	col = 0;
+	while(1)
+	{ 
+
+	    offset = ftell (fd);
+	    if (fgets (buf, sizeof buf, fd) == NULL
+	    || sscanf (buf, "%s %s", name, mapset) != 2)
+		break;
+	    if(new_mapset = (strcmp (cur_mapset,mapset) != 0))
+	    {
+		if(line) line++;
+		if (col) line++;
+		col = 0;
+	    }
+	    if (count >= nlist || line+new_mapset >= NLINES)
+	    {
+		if (page+1 == npages)
+		{
+		    npages++;
+		    page_offset = (long *) G_realloc (page_offset, npages * sizeof (long));
+		    page_offset[npages-1] = offset;
+		}
+		break;
+	    }
+	    if (new_mapset)
+	    {
+		struct box dummy;
+		char label[GMAPSET_MAX+7];
+
+		strcpy (cur_mapset, mapset);
+		sprintf (label, "Mapset %s", mapset);
+		dobox (&dummy, label, GREY, top+line*height, left, right, 0);
+		line++;
+	    }
+	    if (col)
+	    {
+		dobox (&list[count].box, name, WHITE, top+line*height, left+width/2, right, 0);
+		line++;
+		col = 0;
+	    }
+	    else
+	    {
+	      dobox (&list[count].box, name, WHITE, top+line*height, left, left+width/2, 0);
+		col = 1;
+	    }
+	    strcpy (list[count].name, name);
+	    strcpy (list[count].mapset, mapset);
+	    count++;
+	}
+	downarrow (&more, page+1 < npages ? BLACK : WHITE);
+	uparrow   (&less, page   > 0      ? BLACK : WHITE);
+	which = -1;
+
+
+
+
+
+	switch(Input_pointer(objects))
+	{
+	case -1: /* more or less */
+		break;
+	case -2: /* cancel */
+		stat = 0;
+		continue;
+	default: /* file picked */
+		strcpy (xname, list[which].name);
+		strcpy (xmapset, list[which].mapset);
+		stat = 1;
+		continue;
+	}
+	fseek (fd, page_offset[page], 0);
+	R_standard_color (WHITE);
+	R_box_abs (left+1, top+1, right-1, bottom-1);
+    }
+
+
+
+/* all done. restore what was under the window */
+    right += height;	/* move it back over the sidecar */
+    R_standard_color (WHITE);
+    R_box_abs (left, top, right, bottom);
+    R_panel_restore (tempfile1);
+    R_panel_restore (tempfile2);
+    R_panel_delete (tempfile1);
+    R_panel_delete (tempfile2);
+    R_flush();
+
+
+    G_free (page_offset);
+    return stat;
+}
+
+
+
+
+
+
+
+static int dobox(struct box *box, char *text,int color,int top,int left,int right,int centered)
+{
+    int bottom;
+
+    bottom = top+height;
+/* fill inside of box with color */
+    R_standard_color (color);
+    R_box_abs (left+1, top+1, right-1, bottom-1);
+
+/* draw box outline and text in black */
+    R_standard_color (BLUE);                     /*BLACK*/
+    Outline_box (top, bottom, left, right);
+    R_standard_color (BLACK);                    /* ADDED. It determines the colour of text in the table */
+    dotext (text, top, bottom, left, right, centered);
+
+    box->top = top;
+    box->bottom = bottom;
+    box->left = left;
+    box->right = right;
+
+    return 0;
+}
+
+static int uparrow(struct box *box,int color)
+{
+    R_standard_color (color);
+    Uparrow (box->top+edge, box->bottom-edge, box->left+edge, box->right-edge);
+
+    return 0;
+}
+
+static int downarrow ( struct box *box,int color)
+{
+    R_standard_color (color);
+    Downarrow (box->top+edge, box->bottom-edge, box->left+edge, box->right-edge);
+
+    return 0;
+}
+
+static int pick(int x,int y,int button)
+{
+    int n;
+
+    if (inbox(&more,x,y))
+    {
+	cancel_which();
+	if (page+1 >= npages)
+	    return 0;
+	page++;
+	return -1;
+    }
+    if (inbox(&less,x,y))
+    {
+	cancel_which();
+	if (page == 0)
+	    return 0;
+	page--;
+	return -1;
+    }
+    if (inbox(&cancel,x,y))
+    {
+	if (which == -2)
+	    return -2;
+	cancel_which();
+	which = -2;
+	R_standard_color (RED);
+	Outline_box (cancel.top, cancel.bottom, cancel.left, cancel.right);
+	return 0;
+    }
+/* search name list. handle double click */
+    for (n = 0; n < count; n++)
+	if (inbox(&list[n].box,x,y))
+	{
+	    if (n == which) /* second click! */
+		return 1;
+	    cancel_which();
+	    which = n;
+	    R_standard_color (RED);
+	    Outline_box (list[n].box.top, list[n].box.bottom,
+		         list[n].box.left, list[n].box.right);
+	    return 0; /* ignore first click */
+	}
+
+    cancel_which();
+    return 0;
+}
+
+static int 
+cancel_which (void)
+{
+    if (which == -2)
+    {
+	R_standard_color (BLACK);
+	Outline_box (cancel.top, cancel.bottom, cancel.left, cancel.right);
+    }
+    else if (which >= 0)
+    {
+	R_standard_color (BLACK);
+	Outline_box (list[which].box.top, list[which].box.bottom,
+		     list[which].box.left, list[which].box.right);
+    }
+    which = -1;
+
+    return 0;
+}
+
+static int inbox(struct box *box,int x,int y)
+{
+    return (x>box->left && x <box->right && y>box->top && y<box->bottom);
+}
+
+static int dotext(char *text,int top,int bottom,int left,int right,int centered)
+{
+    R_text_size (text_size, text_size);
+    R_move_abs (left+1+edge, bottom-1-edge);
+    if (centered)
+	R_move_rel ((right-left-strlen(text)*size)/2,0);
+    R_set_window (top, bottom, left, right);	/* for text clipping */
+    R_text (text);
+    R_set_window (SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/ask_mag.c
===================================================================
--- grass-addons/i.points.auto/ask_mag.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/ask_mag.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,168 +0,0 @@
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-
-struct box
-{
-    int top, bottom, left, right;
-};
-
-static struct box plus, minus, value;
-static struct box cancel, accept;
-static int mag;
-static int inbox(struct box *,int,int);
-static int dotext(char *,int,int,int,int,int);
-static int incr(int,int);
-
-int 
-ask_magnification (int *magnification)
-{
-    static int use = 1;
-    int incr();
-    int x,y;
-    int height;
-    int stat;
-    int width;
-    int top, bottom, left, right;
-
-    static Objects objects[]=
-    {
-	OTHER(incr, &use),
-	{0}
-    };
-
-    Menu_msg ("");
-
-    mag = *magnification ;
-    if (mag < 1)
-	mag = 1;
-
-    height = VIEW_MENU->nrows;
-    R_text_size (height-4, height-4);
-
-
-    Get_mouse_xy (&x, &y);
-    top = y - height/2;
-    if (top < SCREEN_TOP)
-	top = SCREEN_TOP;
-    bottom = top + 4 * height;
-    if (bottom >= VIEW_MENU->top)
-    {
-	top -= bottom - (VIEW_MENU->top -1);
-	bottom = VIEW_MENU->top-1;
-    }
-    width = Text_width ("MAGNIFICATION") + 4;
-    left = x - width/2;
-    if (left < SCREEN_LEFT)
-	left = SCREEN_LEFT;
-    right = left + width;
-    if (right > SCREEN_RIGHT)
-    {
-	left -= right - SCREEN_RIGHT;
-	right = SCREEN_RIGHT;
-    }
-
-    R_panel_save (tempfile1, top, bottom, left, right);
-    R_standard_color (BLUE);  /*WHITE*/
-    R_box_abs (left, top, right, bottom);
-    R_standard_color (RED); /*BLACK*/
-    Outline_box (top, bottom, left, right);
-
-    plus.top    = top + height;
-    plus.bottom = plus.top + height;
-    plus.left   = left;
-    plus.right  = plus.left + Text_width ("++") + 4;
-    Outline_box (plus.top, plus.bottom, plus.left, plus.right);
-
-    minus.top    = top + height;
-    minus.bottom = minus.top + height;
-    minus.right  = right;
-    minus.left   = minus.right - Text_width ("--") - 4;
-    Outline_box (minus.top, minus.bottom, minus.left, minus.right);
-
-    value.top = top + height;
-    value.bottom = value.top + height;
-    value.left = plus.right;
-    value.right = minus.left;
-    Outline_box (value.top, value.bottom, value.left, value.right);
-
-    accept.top = value.bottom;
-    accept.bottom = accept.top + height;
-    accept.left = left;
-    accept.right = right;
-    Outline_box (accept.top, accept.bottom, accept.left, accept.right);
-
-    cancel.top = accept.bottom;
-    cancel.bottom = cancel.top + height;
-    cancel.left = left;
-    cancel.right = right;
-    Outline_box (cancel.top, cancel.bottom, cancel.left, cancel.right);
-
-    dotext ("MAGNIFICATION", top, top+height, left, right, WHITE);
-    dotext ("+", plus.top, plus.bottom, plus.left, plus.right, GREY);
-    dotext ("-", minus.top, minus.bottom, minus.left, minus.right, GREY);
-    dotext ("ACCEPT", accept.top, accept.bottom, accept.left, accept.right, GREY);
-    dotext ("CANCEL", cancel.top, cancel.bottom, cancel.left, cancel.right, GREY);
-    draw_mag();
-
-    stat = Input_pointer (objects);
-
-/* to respond to user */
-    R_standard_color (BLUE); /*WHITE*/
-    R_box_abs (left, top, right, bottom);
-    R_flush();
-
-    R_panel_restore (tempfile1);
-    R_panel_delete (tempfile1);
-
-    *magnification = mag;
-    return stat > 0;
-}
-
-int 
-draw_mag (void)
-{
-    char buf[10];
-
-    sprintf (buf, "%d", mag);
-    dotext (buf, value.top, value.bottom, value.left, value.right, WHITE);
-
-    return 0;
-}
-
-static int incr(int x,int y)
-{
-    if (inbox (&accept,x,y))
-	return 1;
-    if (inbox (&cancel,x,y))
-	return -1;
-    if (inbox (&plus,x,y))
-    {
-	mag++;
-	draw_mag();
-    }
-    else if (inbox (&minus,x,y) && mag > 1)
-    {
-	mag--;
-	draw_mag();
-    }
-    return 0;
-}
-
-static int dotext(char *text,int top,int bottom,int left,int right,int background)
-{
-  R_standard_color (BLUE); /*background*/
-  R_box_abs (left+1, top+1, right-1, bottom-1);
-  R_standard_color (WHITE); /*BLACK*/
-  /* center the text */
-  left = (left + right - Text_width (text))/2;
-  Text (text, top, bottom, left, right, 2);
-  R_flush();
-  
-  return 0;
-}
-
-static int inbox(struct box *box,int x,int y)
-{
-    return (x>box->left && x <box->right && y>box->top && y<box->bottom);
-}

Copied: grass-addons/imagery/i.points.auto/ask_mag.c (from rev 30335, grass-addons/i.points.auto/ask_mag.c)
===================================================================
--- grass-addons/imagery/i.points.auto/ask_mag.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/ask_mag.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,168 @@
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+
+struct box
+{
+    int top, bottom, left, right;
+};
+
+static struct box plus, minus, value;
+static struct box cancel, accept;
+static int mag;
+static int inbox(struct box *,int,int);
+static int dotext(char *,int,int,int,int,int);
+static int incr(int,int);
+
+int 
+ask_magnification (int *magnification)
+{
+    static int use = 1;
+    int incr();
+    int x,y;
+    int height;
+    int stat;
+    int width;
+    int top, bottom, left, right;
+
+    static Objects objects[]=
+    {
+	OTHER(incr, &use),
+	{0}
+    };
+
+    Menu_msg ("");
+
+    mag = *magnification ;
+    if (mag < 1)
+	mag = 1;
+
+    height = VIEW_MENU->nrows;
+    R_text_size (height-4, height-4);
+
+
+    Get_mouse_xy (&x, &y);
+    top = y - height/2;
+    if (top < SCREEN_TOP)
+	top = SCREEN_TOP;
+    bottom = top + 4 * height;
+    if (bottom >= VIEW_MENU->top)
+    {
+	top -= bottom - (VIEW_MENU->top -1);
+	bottom = VIEW_MENU->top-1;
+    }
+    width = Text_width ("MAGNIFICATION") + 4;
+    left = x - width/2;
+    if (left < SCREEN_LEFT)
+	left = SCREEN_LEFT;
+    right = left + width;
+    if (right > SCREEN_RIGHT)
+    {
+	left -= right - SCREEN_RIGHT;
+	right = SCREEN_RIGHT;
+    }
+
+    R_panel_save (tempfile1, top, bottom, left, right);
+    R_standard_color (BLUE);  /*WHITE*/
+    R_box_abs (left, top, right, bottom);
+    R_standard_color (RED); /*BLACK*/
+    Outline_box (top, bottom, left, right);
+
+    plus.top    = top + height;
+    plus.bottom = plus.top + height;
+    plus.left   = left;
+    plus.right  = plus.left + Text_width ("++") + 4;
+    Outline_box (plus.top, plus.bottom, plus.left, plus.right);
+
+    minus.top    = top + height;
+    minus.bottom = minus.top + height;
+    minus.right  = right;
+    minus.left   = minus.right - Text_width ("--") - 4;
+    Outline_box (minus.top, minus.bottom, minus.left, minus.right);
+
+    value.top = top + height;
+    value.bottom = value.top + height;
+    value.left = plus.right;
+    value.right = minus.left;
+    Outline_box (value.top, value.bottom, value.left, value.right);
+
+    accept.top = value.bottom;
+    accept.bottom = accept.top + height;
+    accept.left = left;
+    accept.right = right;
+    Outline_box (accept.top, accept.bottom, accept.left, accept.right);
+
+    cancel.top = accept.bottom;
+    cancel.bottom = cancel.top + height;
+    cancel.left = left;
+    cancel.right = right;
+    Outline_box (cancel.top, cancel.bottom, cancel.left, cancel.right);
+
+    dotext ("MAGNIFICATION", top, top+height, left, right, WHITE);
+    dotext ("+", plus.top, plus.bottom, plus.left, plus.right, GREY);
+    dotext ("-", minus.top, minus.bottom, minus.left, minus.right, GREY);
+    dotext ("ACCEPT", accept.top, accept.bottom, accept.left, accept.right, GREY);
+    dotext ("CANCEL", cancel.top, cancel.bottom, cancel.left, cancel.right, GREY);
+    draw_mag();
+
+    stat = Input_pointer (objects);
+
+/* to respond to user */
+    R_standard_color (BLUE); /*WHITE*/
+    R_box_abs (left, top, right, bottom);
+    R_flush();
+
+    R_panel_restore (tempfile1);
+    R_panel_delete (tempfile1);
+
+    *magnification = mag;
+    return stat > 0;
+}
+
+int 
+draw_mag (void)
+{
+    char buf[10];
+
+    sprintf (buf, "%d", mag);
+    dotext (buf, value.top, value.bottom, value.left, value.right, WHITE);
+
+    return 0;
+}
+
+static int incr(int x,int y)
+{
+    if (inbox (&accept,x,y))
+	return 1;
+    if (inbox (&cancel,x,y))
+	return -1;
+    if (inbox (&plus,x,y))
+    {
+	mag++;
+	draw_mag();
+    }
+    else if (inbox (&minus,x,y) && mag > 1)
+    {
+	mag--;
+	draw_mag();
+    }
+    return 0;
+}
+
+static int dotext(char *text,int top,int bottom,int left,int right,int background)
+{
+  R_standard_color (BLUE); /*background*/
+  R_box_abs (left+1, top+1, right-1, bottom-1);
+  R_standard_color (WHITE); /*BLACK*/
+  /* center the text */
+  left = (left + right - Text_width (text))/2;
+  Text (text, top, bottom, left, right, 2);
+  R_flush();
+  
+  return 0;
+}
+
+static int inbox(struct box *box,int x,int y)
+{
+    return (x>box->left && x <box->right && y>box->top && y<box->bottom);
+}

Deleted: grass-addons/imagery/i.points.auto/call.c
===================================================================
--- grass-addons/i.points.auto/call.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/call.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,58 +0,0 @@
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-
-/*
- * call a subroutine, but as a child process
- * allowing interrupts for the child
- */
-#include <signal.h>
-
-int call (int (*function)(),char *msg)
-{
-    int pid;
-    int w, status;
-    char i_msg[80];
-
-/*
- * build interrupt msg
- */
-    sprintf (i_msg, "Hit %s %s\n", G_unctrl(interrupt_char), msg);
-/*
- * make sure all graphics have gotten to the monitor
- */
-    R_stabilize();
-
-/* fork to create child */
-    pid = fork();
-    if (pid < 0)
-    {
-	End_curses();
-	perror ("Can't fork");
-	exit (1);
-    }
-
-/* parent just waits for child */
-    Curses_allow_interrupts(1);
-    if (pid)
-    {
-	Curses_write_window (PROMPT_WINDOW, 1, 1, i_msg);
-	while ( (w = wait (&status)) != pid && w != -1)
-	    ;
-	Curses_allow_interrupts(0);
-	Curses_write_window (PROMPT_WINDOW, 1, 1, "\n");
-    }
-
-/* child turns on interrupts and calls the function */
-    else
-    {
-	signal (SIGINT, SIG_DFL);
-	(*function)();
-	exit(0);
-    }
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/call.c (from rev 30335, grass-addons/i.points.auto/call.c)
===================================================================
--- grass-addons/imagery/i.points.auto/call.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/call.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,58 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+
+/*
+ * call a subroutine, but as a child process
+ * allowing interrupts for the child
+ */
+#include <signal.h>
+
+int call (int (*function)(),char *msg)
+{
+    int pid;
+    int w, status;
+    char i_msg[80];
+
+/*
+ * build interrupt msg
+ */
+    sprintf (i_msg, "Hit %s %s\n", G_unctrl(interrupt_char), msg);
+/*
+ * make sure all graphics have gotten to the monitor
+ */
+    R_stabilize();
+
+/* fork to create child */
+    pid = fork();
+    if (pid < 0)
+    {
+	End_curses();
+	perror ("Can't fork");
+	exit (1);
+    }
+
+/* parent just waits for child */
+    Curses_allow_interrupts(1);
+    if (pid)
+    {
+	Curses_write_window (PROMPT_WINDOW, 1, 1, i_msg);
+	while ( (w = wait (&status)) != pid && w != -1)
+	    ;
+	Curses_allow_interrupts(0);
+	Curses_write_window (PROMPT_WINDOW, 1, 1, "\n");
+    }
+
+/* child turns on interrupts and calls the function */
+    else
+    {
+	signal (SIGINT, SIG_DFL);
+	(*function)();
+	exit(0);
+    }
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/cell.c
===================================================================
--- grass-addons/i.points.auto/cell.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/cell.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,100 +0,0 @@
-#include <unistd.h>
-#include "globals.h"
-#include "local_proto.h"
-
-static int use = 1;
-static int choose_cellfile(char *,char *);
-static int plot(int,int);
-static int cancel(void);
-
-int 
-plotcell (int x, int y)
-{
-    int cancel();
-    int plot();
-    static Objects objects[] =
-    {
-	MENU("CANCEL", cancel, &use),
-	INFO("Indicate which side should be plotted", &use),
-	OTHER(plot, &use),
-	{0}
-    };
-/*
- * if the target cell file list is ready, ask the user which side
- * should be plotted, otherwise can only plot group files
- */
-    if (access (cell_list,0) == 0)
-	Input_pointer (objects);
-    else
-	plot (VIEW_MAP1->left+1,0);
-    return 0;
-}
-
-static int 
-cancel (void)
-{
-    return 1;
-}
-
-
-static int plot(int x,int y)
-{
-    char name[100], mapset[100];
-    struct Cell_head cellhd;
-
-    if (x > VIEW_MAP1->left && x < VIEW_MAP1->right)
-    {
-	if (!choose_groupfile(name,mapset))
-	    return 1;
-	if(G_get_cellhd(name, mapset, &cellhd) < 0)
-	    return 1;
-
-	Erase_view (VIEW_MAP1_ZOOM);
-	VIEW_MAP1_ZOOM->cell.configured = 0;
-
-	G_adjust_window_to_box (&cellhd, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows, VIEW_MAP1->ncols);
-	Configure_view (VIEW_MAP1, name, mapset, cellhd.ns_res, cellhd.ew_res);
-	drawcell(VIEW_MAP1);
-    }
-    else if (x > VIEW_MAP2->left && x < VIEW_MAP2->right)
-    {
-      if (!ask_gis_files("raster",group_list,name, mapset,1))
-	    return 1;
-	select_target_env();
-
-	if(G_get_cellhd(name, mapset, &cellhd) < 0)
-	{
-	    select_current_env();
-	    return 1;
-	}
-
-	Erase_view (VIEW_MAP2_ZOOM);
-	VIEW_MAP2_ZOOM->cell.configured = 0;
-
-	G_adjust_window_to_box (&cellhd, &VIEW_MAP2->cell.head, VIEW_MAP2->nrows, VIEW_MAP2->ncols);
-	Configure_view (VIEW_MAP2, name, mapset, cellhd.ns_res, cellhd.ew_res);
-	select_target_env();
-	drawcell(VIEW_MAP2);
-	select_current_env();
-	if (from_screen < 0)
-	{
-	    from_flag = 1;
-	    from_screen = 0;
-	    if (from_keyboard < 0)
-	    {
-		from_keyboard = 0;
-		from_screen = 1;
-	    }
-	}
-    }
-    else
-	return 0; /* ignore mouse click */
-
-    display_points(1);
-    return 1;
-}
-
-static int choose_cellfile(char *name,char *mapset)
-{
-    return ask_gis_files ("raster", cell_list, name, mapset, 1);
-}

Copied: grass-addons/imagery/i.points.auto/cell.c (from rev 30335, grass-addons/i.points.auto/cell.c)
===================================================================
--- grass-addons/imagery/i.points.auto/cell.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/cell.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,100 @@
+#include <unistd.h>
+#include "globals.h"
+#include "local_proto.h"
+
+static int use = 1;
+static int choose_cellfile(char *,char *);
+static int plot(int,int);
+static int cancel(void);
+
+int 
+plotcell (int x, int y)
+{
+    int cancel();
+    int plot();
+    static Objects objects[] =
+    {
+	MENU("CANCEL", cancel, &use),
+	INFO("Indicate which side should be plotted", &use),
+	OTHER(plot, &use),
+	{0}
+    };
+/*
+ * if the target cell file list is ready, ask the user which side
+ * should be plotted, otherwise can only plot group files
+ */
+    if (access (cell_list,0) == 0)
+	Input_pointer (objects);
+    else
+	plot (VIEW_MAP1->left+1,0);
+    return 0;
+}
+
+static int 
+cancel (void)
+{
+    return 1;
+}
+
+
+static int plot(int x,int y)
+{
+    char name[100], mapset[100];
+    struct Cell_head cellhd;
+
+    if (x > VIEW_MAP1->left && x < VIEW_MAP1->right)
+    {
+	if (!choose_groupfile(name,mapset))
+	    return 1;
+	if(G_get_cellhd(name, mapset, &cellhd) < 0)
+	    return 1;
+
+	Erase_view (VIEW_MAP1_ZOOM);
+	VIEW_MAP1_ZOOM->cell.configured = 0;
+
+	G_adjust_window_to_box (&cellhd, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows, VIEW_MAP1->ncols);
+	Configure_view (VIEW_MAP1, name, mapset, cellhd.ns_res, cellhd.ew_res);
+	drawcell(VIEW_MAP1);
+    }
+    else if (x > VIEW_MAP2->left && x < VIEW_MAP2->right)
+    {
+      if (!ask_gis_files("raster",group_list,name, mapset,1))
+	    return 1;
+	select_target_env();
+
+	if(G_get_cellhd(name, mapset, &cellhd) < 0)
+	{
+	    select_current_env();
+	    return 1;
+	}
+
+	Erase_view (VIEW_MAP2_ZOOM);
+	VIEW_MAP2_ZOOM->cell.configured = 0;
+
+	G_adjust_window_to_box (&cellhd, &VIEW_MAP2->cell.head, VIEW_MAP2->nrows, VIEW_MAP2->ncols);
+	Configure_view (VIEW_MAP2, name, mapset, cellhd.ns_res, cellhd.ew_res);
+	select_target_env();
+	drawcell(VIEW_MAP2);
+	select_current_env();
+	if (from_screen < 0)
+	{
+	    from_flag = 1;
+	    from_screen = 0;
+	    if (from_keyboard < 0)
+	    {
+		from_keyboard = 0;
+		from_screen = 1;
+	    }
+	}
+    }
+    else
+	return 0; /* ignore mouse click */
+
+    display_points(1);
+    return 1;
+}
+
+static int choose_cellfile(char *name,char *mapset)
+{
+    return ask_gis_files ("raster", cell_list, name, mapset, 1);
+}

Deleted: grass-addons/imagery/i.points.auto/cellhd.c
===================================================================
--- grass-addons/i.points.auto/cellhd.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/cellhd.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,25 +0,0 @@
-#include "globals.h"
-#include "local_proto.h"
-
-int 
-Outline_cellhd (View *view, struct Cell_head *cellhd)
-{
-    int row,col;
-    int top, bottom, left, right;
-
-    row = northing_to_row (&view->cell.head, cellhd->north) + .5;
-    top = row_to_view (view, row);
-
-    col = easting_to_col (&view->cell.head, cellhd->west) + .5;
-    left = col_to_view (view, col);
-
-    row = northing_to_row (&view->cell.head, cellhd->south) + .5;
-    bottom = row_to_view (view, row);
-
-    col = easting_to_col (&view->cell.head, cellhd->east) + .5;
-    right = col_to_view (view, col);
-
-    Outline_box (top, bottom, left, right);
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/cellhd.c (from rev 30335, grass-addons/i.points.auto/cellhd.c)
===================================================================
--- grass-addons/imagery/i.points.auto/cellhd.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/cellhd.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,25 @@
+#include "globals.h"
+#include "local_proto.h"
+
+int 
+Outline_cellhd (View *view, struct Cell_head *cellhd)
+{
+    int row,col;
+    int top, bottom, left, right;
+
+    row = northing_to_row (&view->cell.head, cellhd->north) + .5;
+    top = row_to_view (view, row);
+
+    col = easting_to_col (&view->cell.head, cellhd->west) + .5;
+    left = col_to_view (view, col);
+
+    row = northing_to_row (&view->cell.head, cellhd->south) + .5;
+    bottom = row_to_view (view, row);
+
+    col = easting_to_col (&view->cell.head, cellhd->east) + .5;
+    right = col_to_view (view, col);
+
+    Outline_box (top, bottom, left, right);
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/colors.c
===================================================================
--- grass-addons/i.points.auto/colors.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/colors.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,7 +0,0 @@
-#include <grass/gis.h>
-#include <grass/display.h>
-int 
-set_colors (struct Colors *colors)
-{
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/colors.c (from rev 30335, grass-addons/i.points.auto/colors.c)
===================================================================
--- grass-addons/imagery/i.points.auto/colors.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/colors.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,7 @@
+#include <grass/gis.h>
+#include <grass/display.h>
+int 
+set_colors (struct Colors *colors)
+{
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/conv.c
===================================================================
--- grass-addons/i.points.auto/conv.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/conv.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,59 +0,0 @@
-#include "globals.h"
-
-/* conversion routines to convert from view x,y to cell col,row
- * as well as cell col,row to cell east,north
- */
-int 
-view_to_col (View *view, int x)
-{
-    return x - view->cell.left;
-}
-
-int 
-view_to_row (View *view, int y)
-{
-    return y - view->cell.top;
-}
-
-int 
-col_to_view (View *view, int col)
-{
-    return view->cell.left + col;
-}
-
-int 
-row_to_view (View *view, int row)
-{
-    return view->cell.top + row;
-}
-
-/* in these next 2 routines, location determines if we are
- * converting from center of the cell (location == .5)
- * top or left edge (location == 0.0)
- * bottom or right edge (location == 1.0)
- */
-
-double 
-row_to_northing (struct Cell_head *cellhd, int row, double location)
-{
-    return cellhd->north - (row + location) * cellhd->ns_res;
-}
-
-double 
-col_to_easting (struct Cell_head *cellhd, int col, double location)
-{
-    return cellhd->west + (col + location) * cellhd->ew_res;
-}
-
-double 
-northing_to_row (struct Cell_head *cellhd, double north)
-{
-    return  (cellhd->north - north) / cellhd->ns_res;
-}
-
-double 
-easting_to_col (struct Cell_head *cellhd, double east)
-{
-    return  (east - cellhd->west) / cellhd->ew_res;
-}
-

Copied: grass-addons/imagery/i.points.auto/conv.c (from rev 30335, grass-addons/i.points.auto/conv.c)
===================================================================
--- grass-addons/imagery/i.points.auto/conv.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/conv.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,59 @@
+#include "globals.h"
+
+/* conversion routines to convert from view x,y to cell col,row
+ * as well as cell col,row to cell east,north
+ */
+int 
+view_to_col (View *view, int x)
+{
+    return x - view->cell.left;
+}
+
+int 
+view_to_row (View *view, int y)
+{
+    return y - view->cell.top;
+}
+
+int 
+col_to_view (View *view, int col)
+{
+    return view->cell.left + col;
+}
+
+int 
+row_to_view (View *view, int row)
+{
+    return view->cell.top + row;
+}
+
+/* in these next 2 routines, location determines if we are
+ * converting from center of the cell (location == .5)
+ * top or left edge (location == 0.0)
+ * bottom or right edge (location == 1.0)
+ */
+
+double 
+row_to_northing (struct Cell_head *cellhd, int row, double location)
+{
+    return cellhd->north - (row + location) * cellhd->ns_res;
+}
+
+double 
+col_to_easting (struct Cell_head *cellhd, int col, double location)
+{
+    return cellhd->west + (col + location) * cellhd->ew_res;
+}
+
+double 
+northing_to_row (struct Cell_head *cellhd, double north)
+{
+    return  (cellhd->north - north) / cellhd->ns_res;
+}
+
+double 
+easting_to_col (struct Cell_head *cellhd, double east)
+{
+    return  (east - cellhd->west) / cellhd->ew_res;
+}
+

Deleted: grass-addons/imagery/i.points.auto/curses.c
===================================================================
--- grass-addons/i.points.auto/curses.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/curses.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,282 +0,0 @@
-#include <stdlib.h>
-#include <unistd.h>
-#include "globals.h"
-#include "local_proto.h"
-
-static int inited = 0;
-
-static WINDOW *save;
-WINDOW *newwin();
-
-static Window *make_window (int top, int bottom, int left, int right)
-{
-    Window *window;
-
-    if (top < 0 || bottom >= LINES || left < 0 || right >= COLS
-    ||	bottom-top <= 1 || right-left <= 1)
-    {
-	End_curses();
-	fprintf (stderr, "make_window(%d,%d,%d,%d): illegal screen values\n",
-		top, bottom, left, right);
-	sleep(3);
-	exit(1);
-    }
-    window = (Window *) G_malloc (sizeof(Window));
-    window->top    = top;
-    window->bottom = bottom;
-    window->left   = left;
-    window->right  = right;
-    Curses_clear_window (window);
-    return window;
-}
-
-int Begin_curses (void)
-{
-/* should only be called once at program outset */
-
-    initscr () ;       /* initialize curses standard screens   */
-    raw() ;            /* set tty modes via curses calls       */
-    noecho() ;
-    nonl()   ;
-
-    inited = 1;
-
-/* make a window to save stdscr */
-    save = newwin(LINES,COLS,0,0);
-
-/* make_window (nrows, ncols, start_row, start_col) */
-    INFO_WINDOW   = make_window (0, LINES-4, COLS/2, COLS-1);
-    MENU_WINDOW   = make_window (0, LINES-4, 0, COLS/2);
-    PROMPT_WINDOW = make_window (LINES-4, LINES-1, 0, COLS-1);
-    refresh();
-
-
-    return 0;
-}
-
-int End_curses (void)
-{
-/* should only be called upon program exit */
-
-    clear() ;       /* clear the screen */
-    refresh() ;
-    endwin() ;      /* let curses reset the tty now */
-
-    return 0;
-}
-
-int Suspend_curses (void)
-{
-    overwrite (stdscr, save);
-    clear();
-    refresh();
-    endwin();
-
-    return 0;
-}
-
-int Resume_curses (void)
-{
-    clear();
-    refresh();
-    overwrite (save, stdscr);
-    refresh();
-
-    return 0;
-}
-
-int Curses_allow_interrupts (int ok)
-{
-    refresh();
-    if (ok)
-	noraw();
-    else
-	raw();
-
-    return 0;
-}
-
-int Curses_clear_window (Window *window)
-{
-    int y,x;
-
-if (!inited) return 1;
-    for (y = window->top+1; y < window->bottom; y++)
-    {
-	move (y, x=window->left+1);
-	while (x++ < window->right)
-	    addch (' ');
-    }
-    Curses_outline_window (window);
-    refresh();
-
-    return 0;
-}
-
-int Curses_outline_window (Window *window)
-{
-    int x, y;
-
-    move (window->top, x=window->left+1);
-    while (x++ < window->right)
-	addch ('-');
-    move (window->bottom, x=window->left+1);
-    while (x++ < window->right)
-	addch ('-');
-    for (y=window->top+1; y < window->bottom; y++)
-    {
-	move (y, window->left);
-	addch ('|');
-	move (y, window->right);
-	addch ('|');
-    }
-    move (window->top, window->left);
-    addch ('+');
-    move (window->top, window->right);
-    addch ('+');
-    move (window->bottom, window->left);
-    addch ('+');
-    if (window->bottom < LINES-1 || window->right < COLS-1)
-    {
-	move (window->bottom, window->right);
-	addch ('+');
-    }
-
-    return 0;
-}
-
-int Curses_write_window (Window *window, int line, int col, char *message)
-{
-    int y,x,i;
-
-if (!inited)
-{
-	fprintf (stderr, "%s\n", message);
-	return 1;
-}
-    if (line <= 0 || line >= window->bottom-window->top)
-	return 1;
-    if (col <= 0 || col >= window->right-window->left)
-	return 1;
-    move(y=window->top+line, x=window->left+col);
-    while (*message != 0 && *message != '\n' && x < window->right)
-    {
-	addch (*message);
-	message++;
-	x++;
-    }
-    if (*message == '\n')
-	for (i = x; i < window->right; i++)
-	    addch (' ');
-    move (y, x);
-    refresh();
-
-    return 0;
-}
-
-
-int 
-Curses_replot_screen (void) 
-{
-    int x,y;
-    getyx (stdscr, y, x);
-    wrefresh(curscr) ;
-    move (y, x);
-    refresh();
-
-    return 0;
-}
-
-int Curses_prompt_gets (char *prompt, char *answer)
-{
-    char c ;
-    int n;
-    int y,x;
-
-    *answer = 0;
-    n = 0;
-
-    Curses_write_window (PROMPT_WINDOW, 1, 1, "\n");
-    Curses_write_window (PROMPT_WINDOW, 1, 1, prompt);
-
-    for(;;)
-    {
-	refresh ();
-	c = Curses_getch(0) ;
-	if (c == '\n' || c == '\r')
-	    break;
-
-	getyx (stdscr, y, x);
-	if (c > 037 && c < 0177)
-	{
-	    if (x < PROMPT_WINDOW->right)
-	    {
-		*answer++ = c ;
-		*answer = 0 ;
-		addch(c) ;
-		n++;
-	    }
-	    continue;
-	}
-	if (c == '\b')
-	{
-	    if (n > 0)
-	    {
-		answer--;
-		*answer = 0;
-		move (y, x-1);
-		addch (' ');
-		move (y, x-1);
-		n--;
-	    }
-	    continue;
-	}
-	Beep();
-    }
-
-    return 0;
-}
-
-int 
-Beep (void)
-{
-    putchar ('\7');
-    fflush (stdout);
-
-    return 0;
-}
-
-int 
-Curses_getch (int with_echo)
-{
-    char achar;
-    int c;
-    int kill;
-
-if (!inited) return 0;
-    kill = 0;
-    while(1)
-    {
-	c = getch() & 0177;
-	if (c == interrupt_char)
-	{
-	    if (kill++ >= 3)
-	    {
-		End_curses();
-		exit(0);
-	    }
-	    continue;
-	}
-	kill = 0;
-	if (c != 18)
-	    break;
-	Curses_replot_screen();
-    }
-    if (with_echo)
-    {
-	achar = c;
-	addch(achar);
-	refresh();
-    }
-    return c;
-}

Copied: grass-addons/imagery/i.points.auto/curses.c (from rev 30335, grass-addons/i.points.auto/curses.c)
===================================================================
--- grass-addons/imagery/i.points.auto/curses.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/curses.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,282 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include "globals.h"
+#include "local_proto.h"
+
+static int inited = 0;
+
+static WINDOW *save;
+WINDOW *newwin();
+
+static Window *make_window (int top, int bottom, int left, int right)
+{
+    Window *window;
+
+    if (top < 0 || bottom >= LINES || left < 0 || right >= COLS
+    ||	bottom-top <= 1 || right-left <= 1)
+    {
+	End_curses();
+	fprintf (stderr, "make_window(%d,%d,%d,%d): illegal screen values\n",
+		top, bottom, left, right);
+	sleep(3);
+	exit(1);
+    }
+    window = (Window *) G_malloc (sizeof(Window));
+    window->top    = top;
+    window->bottom = bottom;
+    window->left   = left;
+    window->right  = right;
+    Curses_clear_window (window);
+    return window;
+}
+
+int Begin_curses (void)
+{
+/* should only be called once at program outset */
+
+    initscr () ;       /* initialize curses standard screens   */
+    raw() ;            /* set tty modes via curses calls       */
+    noecho() ;
+    nonl()   ;
+
+    inited = 1;
+
+/* make a window to save stdscr */
+    save = newwin(LINES,COLS,0,0);
+
+/* make_window (nrows, ncols, start_row, start_col) */
+    INFO_WINDOW   = make_window (0, LINES-4, COLS/2, COLS-1);
+    MENU_WINDOW   = make_window (0, LINES-4, 0, COLS/2);
+    PROMPT_WINDOW = make_window (LINES-4, LINES-1, 0, COLS-1);
+    refresh();
+
+
+    return 0;
+}
+
+int End_curses (void)
+{
+/* should only be called upon program exit */
+
+    clear() ;       /* clear the screen */
+    refresh() ;
+    endwin() ;      /* let curses reset the tty now */
+
+    return 0;
+}
+
+int Suspend_curses (void)
+{
+    overwrite (stdscr, save);
+    clear();
+    refresh();
+    endwin();
+
+    return 0;
+}
+
+int Resume_curses (void)
+{
+    clear();
+    refresh();
+    overwrite (save, stdscr);
+    refresh();
+
+    return 0;
+}
+
+int Curses_allow_interrupts (int ok)
+{
+    refresh();
+    if (ok)
+	noraw();
+    else
+	raw();
+
+    return 0;
+}
+
+int Curses_clear_window (Window *window)
+{
+    int y,x;
+
+if (!inited) return 1;
+    for (y = window->top+1; y < window->bottom; y++)
+    {
+	move (y, x=window->left+1);
+	while (x++ < window->right)
+	    addch (' ');
+    }
+    Curses_outline_window (window);
+    refresh();
+
+    return 0;
+}
+
+int Curses_outline_window (Window *window)
+{
+    int x, y;
+
+    move (window->top, x=window->left+1);
+    while (x++ < window->right)
+	addch ('-');
+    move (window->bottom, x=window->left+1);
+    while (x++ < window->right)
+	addch ('-');
+    for (y=window->top+1; y < window->bottom; y++)
+    {
+	move (y, window->left);
+	addch ('|');
+	move (y, window->right);
+	addch ('|');
+    }
+    move (window->top, window->left);
+    addch ('+');
+    move (window->top, window->right);
+    addch ('+');
+    move (window->bottom, window->left);
+    addch ('+');
+    if (window->bottom < LINES-1 || window->right < COLS-1)
+    {
+	move (window->bottom, window->right);
+	addch ('+');
+    }
+
+    return 0;
+}
+
+int Curses_write_window (Window *window, int line, int col, char *message)
+{
+    int y,x,i;
+
+if (!inited)
+{
+	fprintf (stderr, "%s\n", message);
+	return 1;
+}
+    if (line <= 0 || line >= window->bottom-window->top)
+	return 1;
+    if (col <= 0 || col >= window->right-window->left)
+	return 1;
+    move(y=window->top+line, x=window->left+col);
+    while (*message != 0 && *message != '\n' && x < window->right)
+    {
+	addch (*message);
+	message++;
+	x++;
+    }
+    if (*message == '\n')
+	for (i = x; i < window->right; i++)
+	    addch (' ');
+    move (y, x);
+    refresh();
+
+    return 0;
+}
+
+
+int 
+Curses_replot_screen (void) 
+{
+    int x,y;
+    getyx (stdscr, y, x);
+    wrefresh(curscr) ;
+    move (y, x);
+    refresh();
+
+    return 0;
+}
+
+int Curses_prompt_gets (char *prompt, char *answer)
+{
+    char c ;
+    int n;
+    int y,x;
+
+    *answer = 0;
+    n = 0;
+
+    Curses_write_window (PROMPT_WINDOW, 1, 1, "\n");
+    Curses_write_window (PROMPT_WINDOW, 1, 1, prompt);
+
+    for(;;)
+    {
+	refresh ();
+	c = Curses_getch(0) ;
+	if (c == '\n' || c == '\r')
+	    break;
+
+	getyx (stdscr, y, x);
+	if (c > 037 && c < 0177)
+	{
+	    if (x < PROMPT_WINDOW->right)
+	    {
+		*answer++ = c ;
+		*answer = 0 ;
+		addch(c) ;
+		n++;
+	    }
+	    continue;
+	}
+	if (c == '\b')
+	{
+	    if (n > 0)
+	    {
+		answer--;
+		*answer = 0;
+		move (y, x-1);
+		addch (' ');
+		move (y, x-1);
+		n--;
+	    }
+	    continue;
+	}
+	Beep();
+    }
+
+    return 0;
+}
+
+int 
+Beep (void)
+{
+    putchar ('\7');
+    fflush (stdout);
+
+    return 0;
+}
+
+int 
+Curses_getch (int with_echo)
+{
+    char achar;
+    int c;
+    int kill;
+
+if (!inited) return 0;
+    kill = 0;
+    while(1)
+    {
+	c = getch() & 0177;
+	if (c == interrupt_char)
+	{
+	    if (kill++ >= 3)
+	    {
+		End_curses();
+		exit(0);
+	    }
+	    continue;
+	}
+	kill = 0;
+	if (c != 18)
+	    break;
+	Curses_replot_screen();
+    }
+    if (with_echo)
+    {
+	achar = c;
+	addch(achar);
+	refresh();
+    }
+    return c;
+}

Deleted: grass-addons/imagery/i.points.auto/debug.c
===================================================================
--- grass-addons/i.points.auto/debug.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/debug.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,13 +0,0 @@
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-
-int 
-debug (char *msg)
-{
-    R_stabilize();
-    Curses_write_window (PROMPT_WINDOW, 1, 1, msg);
-    /* Curses_getch(0);*/
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/debug.c (from rev 30335, grass-addons/i.points.auto/debug.c)
===================================================================
--- grass-addons/imagery/i.points.auto/debug.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/debug.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,13 @@
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+
+int 
+debug (char *msg)
+{
+    R_stabilize();
+    Curses_write_window (PROMPT_WINDOW, 1, 1, msg);
+    /* Curses_getch(0);*/
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/defs.h
===================================================================
--- grass-addons/i.points.auto/defs.h	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/defs.h	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,72 +0,0 @@
-#include <grass/imagery.h>
-#include <curses.h>
-
-/* this is a curses structure */
-typedef struct
-{
-    int top, left, bottom, right;
-} Window;
-
-/* this is a graphics structure */
-typedef struct
-{
-    int top, bottom ,left, right;
-    int nrows, ncols;
-    struct
-    {
-	int configured;
-	struct Cell_head head;
-	struct Colors colors;
-	char name[100];
-	char mapset[100];
-	int top, bottom ,left, right;
-	double ew_res, ns_res;	/* original map resolution */
-    } cell;
-} View;
-
-
-typedef struct
-{
-    char name[100];
-    struct Ref ref;
-    struct Control_Points points;
-    double E12[3], N12[3], E21[3], N21[3];
-    int equation_stat;
-} Group;
-
-typedef struct
-{
-    int   type;         /* object type */
-    int (*handler)();	/* routine to handle the event */
-    char *label;	/* label to display if MENU or OPTION */
-    int   binding;      /* OPTION bindings */
-    int  *status;	/* MENU,OPTION status */
-    int top,bottom,left,right;
-} Objects;
-
-#define MENU_OBJECT 1
-#define OPTION_OBJECT 2
-#define INFO_OBJECT 3
-#define OTHER_OBJECT 4
-
-
-#define MENU(label,handler,status) \
-	{MENU_OBJECT,handler,label,0,status,0,0,0,0}  
-#define OPTION(label,binding,status) \
-	{OPTION_OBJECT,NULL,label,binding,status,0,0,0,0}
-#define INFO(label,status) \
-	{INFO_OBJECT,NULL,label,0,status,0,0,0,0}
-#define OTHER(handler,status) \
-	{OTHER_OBJECT,handler,NULL,0,status,0,0,0,0}
-
-typedef struct
-{
-      double *t1;
-      double *u1;
-      double *t2;
-      double *u2;
-      int *status;
-     double E12[3], N12[3], E21[3], N21[3];
-      int count;
-      int line_stat;
-} Lines;

Copied: grass-addons/imagery/i.points.auto/defs.h (from rev 30335, grass-addons/i.points.auto/defs.h)
===================================================================
--- grass-addons/imagery/i.points.auto/defs.h	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/defs.h	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,72 @@
+#include <grass/imagery.h>
+#include <curses.h>
+
+/* this is a curses structure */
+typedef struct
+{
+    int top, left, bottom, right;
+} Window;
+
+/* this is a graphics structure */
+typedef struct
+{
+    int top, bottom ,left, right;
+    int nrows, ncols;
+    struct
+    {
+	int configured;
+	struct Cell_head head;
+	struct Colors colors;
+	char name[100];
+	char mapset[100];
+	int top, bottom ,left, right;
+	double ew_res, ns_res;	/* original map resolution */
+    } cell;
+} View;
+
+
+typedef struct
+{
+    char name[100];
+    struct Ref ref;
+    struct Control_Points points;
+    double E12[3], N12[3], E21[3], N21[3];
+    int equation_stat;
+} Group;
+
+typedef struct
+{
+    int   type;         /* object type */
+    int (*handler)();	/* routine to handle the event */
+    char *label;	/* label to display if MENU or OPTION */
+    int   binding;      /* OPTION bindings */
+    int  *status;	/* MENU,OPTION status */
+    int top,bottom,left,right;
+} Objects;
+
+#define MENU_OBJECT 1
+#define OPTION_OBJECT 2
+#define INFO_OBJECT 3
+#define OTHER_OBJECT 4
+
+
+#define MENU(label,handler,status) \
+	{MENU_OBJECT,handler,label,0,status,0,0,0,0}  
+#define OPTION(label,binding,status) \
+	{OPTION_OBJECT,NULL,label,binding,status,0,0,0,0}
+#define INFO(label,status) \
+	{INFO_OBJECT,NULL,label,0,status,0,0,0,0}
+#define OTHER(handler,status) \
+	{OTHER_OBJECT,handler,NULL,0,status,0,0,0,0}
+
+typedef struct
+{
+      double *t1;
+      double *u1;
+      double *t2;
+      double *u2;
+      int *status;
+     double E12[3], N12[3], E21[3], N21[3];
+      int count;
+      int line_stat;
+} Lines;

Deleted: grass-addons/imagery/i.points.auto/description.html
===================================================================
--- grass-addons/i.points.auto/description.html	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/description.html	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,55 +0,0 @@
-<H2>DESCRIPTION</H2>
-
-This module allows a search of GCP's on two raster-maps with differents levels 
-of automation.
-
-The manual search is the default search, so it's possible to
-determine the GCP's manually with the mouse.
-
-<b>Semiautomated-search</b>
-You have to determine with the mouse some corrispondent areas
-(with a discrete precision) in the two maps and the module searches the GCP's in these areas. 
-
-<b>Automated-search</b>
-At the start of module you have to load the maps that the algorithm uses to the search,
-so it's recommended to use the maps filtered with the filters DIVERSITY or STDDEV 
-(of GRASS) with a window of 3x3 or 5x5 pixels. However, the algorithm sometimes work
-well with the original maps too.
-
-You click the button Automated-Search and then you have to load the maps that you want to
-visualize at the end of the search (with the GCP's), usually they are the original maps.
-
-If the maps have strong geometric distortion and strong geometric differencies, maybe 
-the results of the search (with the default options) are not good, so you can click the 
-button LESS-GCP's and then repeat the operation. 
-
-The Overlap-Points (O.P.) era two corresponding points (one for every maps) that is 
-used from the algorithm to determine the overlapping-area in the two maps.
-The Master-map is considered the map on the left, and the Slave-map is the map on the right.
-
-Center, top, bottom, left, right are the position of the Master Overlap-Point (on the 
-left map) that will be searched on the Slave map (right map). Center is the point at the
-center of the map. Top, bottom, left, right are the position of the O.P. respect to
-the center of the map. If you choose one of these possibilities, then you have to 
-choose the shift from the center, measured in percentage of the dimensions of the map; there
-are two possibilities: 5% and 10%.
-This type of search is the most automated (fully-automated ).
-
-If you choose -MARK SLAVE O.P.-, then the module visualizes a blue point at the center 
-of the master map, and you have to mark the corrispondent point on the slave map.
-You can use this function if the maps are overlapped for more of 50% and if the 
-algorithm doesn't have success in the fully-automated search.
-
-If the maps have a overlapping area less of 50%, you can use the function -MARK M and S O.P.-.
-You have to mark a point in the master map and the corresponding point on the slave map.
-
-At the end of search it's possible to exclude automatically the points not really 
-corresponding. This function use the rms with a threshold. The default-value for
-the threshold is 2.5, but (before to active the Auto-Exclusion) you can change it,
-chossing one of different proposed values; you can choose an arbitrary value with 
-click on -OTHER-, so you go on the shell and digit the value from keyboard and confirm 
-with ENTER.
-
-<H2>AUTHOR</H2>
-
-<p><i>Last changed: $Date: 2006/06/22 07:46:46 $</i></p>

Copied: grass-addons/imagery/i.points.auto/description.html (from rev 30335, grass-addons/i.points.auto/description.html)
===================================================================
--- grass-addons/imagery/i.points.auto/description.html	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/description.html	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,55 @@
+<H2>DESCRIPTION</H2>
+
+This module allows a search of GCP's on two raster-maps with differents levels 
+of automation.
+
+The manual search is the default search, so it's possible to
+determine the GCP's manually with the mouse.
+
+<b>Semiautomated-search</b>
+You have to determine with the mouse some corrispondent areas
+(with a discrete precision) in the two maps and the module searches the GCP's in these areas. 
+
+<b>Automated-search</b>
+At the start of module you have to load the maps that the algorithm uses to the search,
+so it's recommended to use the maps filtered with the filters DIVERSITY or STDDEV 
+(of GRASS) with a window of 3x3 or 5x5 pixels. However, the algorithm sometimes work
+well with the original maps too.
+
+You click the button Automated-Search and then you have to load the maps that you want to
+visualize at the end of the search (with the GCP's), usually they are the original maps.
+
+If the maps have strong geometric distortion and strong geometric differencies, maybe 
+the results of the search (with the default options) are not good, so you can click the 
+button LESS-GCP's and then repeat the operation. 
+
+The Overlap-Points (O.P.) era two corresponding points (one for every maps) that is 
+used from the algorithm to determine the overlapping-area in the two maps.
+The Master-map is considered the map on the left, and the Slave-map is the map on the right.
+
+Center, top, bottom, left, right are the position of the Master Overlap-Point (on the 
+left map) that will be searched on the Slave map (right map). Center is the point at the
+center of the map. Top, bottom, left, right are the position of the O.P. respect to
+the center of the map. If you choose one of these possibilities, then you have to 
+choose the shift from the center, measured in percentage of the dimensions of the map; there
+are two possibilities: 5% and 10%.
+This type of search is the most automated (fully-automated ).
+
+If you choose -MARK SLAVE O.P.-, then the module visualizes a blue point at the center 
+of the master map, and you have to mark the corrispondent point on the slave map.
+You can use this function if the maps are overlapped for more of 50% and if the 
+algorithm doesn't have success in the fully-automated search.
+
+If the maps have a overlapping area less of 50%, you can use the function -MARK M and S O.P.-.
+You have to mark a point in the master map and the corresponding point on the slave map.
+
+At the end of search it's possible to exclude automatically the points not really 
+corresponding. This function use the rms with a threshold. The default-value for
+the threshold is 2.5, but (before to active the Auto-Exclusion) you can change it,
+chossing one of different proposed values; you can choose an arbitrary value with 
+click on -OTHER-, so you go on the shell and digit the value from keyboard and confirm 
+with ENTER.
+
+<H2>AUTHOR</H2>
+
+<p><i>Last changed: $Date: 2006/06/22 07:46:46 $</i></p>

Deleted: grass-addons/imagery/i.points.auto/digit.c
===================================================================
--- grass-addons/i.points.auto/digit.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/digit.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,129 +0,0 @@
-#include <stdlib.h>
-#include <unistd.h>
-#include "globals.h"
-#include "local_proto.h"
-
-static int setup(void);
-static int oops(void);
-static int yes(void);
-static int no(void);
-
-int 
-setup_digitizer (void)
-{
-    static int use = 1;
-    int setup(), no(), yes();
-    static Objects objects[]=
-    {
-	INFO("Do you wish to use the digitizer?  ", &use),
-	MENU("YES", yes, &use),
-	MENU("NO", no, &use),
-	{0}
-    };
-    char command[1024];
-
-    use_digitizer = 0;
-/*
- * test to see if we have a digitizer (geo.quest)
- * make sure this program has execute permission first.
- * then run the program and check its exit status
- *  0 means can use digitizer, other means can't
- */
-    sprintf (command, "%s/etc/geo.quest", G_gisbase());
-    if (access (command, 1) != 0)
-	return 0;
-    if (system(command))
-	return 0;
-
-
-/*
- * ask the user if he/she wishes to use it
- */
-    Start_mouse_in_menu();
-    Input_pointer (objects);
-    if (use_digitizer)
-	Input_other (setup, "Keyboard");
-
-    return 0;
-}
-
-static int 
-setup (void)
-{
-    char command[1024];
-/*
- * setup the digitizer. system() call must exit with 0 to indicate
- * everything went fine
- */
-    sprintf (command, "%s/etc/geo.reg %s %d",
-	G_gisbase(), digit_points, getpid());
-    Suspend_curses();
-    if (system (command))
-    {
-	use_digitizer = 0;
-	sleep(3);
-    }
-    Resume_curses();
-
-    return 0;
-}
-
-int 
-digitizer_point (double *east, double *north)
-{
-    char command[1024];
-    FILE *fd;
-    int stat;
-
-/* make sure digitzer is to be used */
-    if (!use_digitizer)
-	return 0;
-
-    sprintf (command, "%s/etc/geo.point %s %s",
-	G_gisbase(), digit_points, digit_results);
-
-    Suspend_curses();
-    if(system (command))
-    {
-	sleep(3);
-	Resume_curses();
-	oops();
-	return 0;
-    }
-    Resume_curses();
-    fd = fopen (digit_results, "r");
-    if (fd == NULL)
-    {
-	oops();
-	return 0;
-    }
-    stat = (fscanf (fd, "%lf %lf", east, north) == 2);
-    fclose (fd);
-
-    if (stat == 0)
-	oops();
-    return stat;
-}
-
-static int 
-oops (void)
-{
-    Curses_clear_window (MENU_WINDOW);
-    Curses_write_window (MENU_WINDOW, 3,2,"Can't get data from digitizer");
-
-    return 0;
-}
-
-static int 
-no (void)
-{
-    use_digitizer = 0;
-    return 1;
-}
-
-static int 
-yes (void)
-{
-    use_digitizer = 1;
-    return 1;
-}

Copied: grass-addons/imagery/i.points.auto/digit.c (from rev 30335, grass-addons/i.points.auto/digit.c)
===================================================================
--- grass-addons/imagery/i.points.auto/digit.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/digit.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,129 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include "globals.h"
+#include "local_proto.h"
+
+static int setup(void);
+static int oops(void);
+static int yes(void);
+static int no(void);
+
+int 
+setup_digitizer (void)
+{
+    static int use = 1;
+    int setup(), no(), yes();
+    static Objects objects[]=
+    {
+	INFO("Do you wish to use the digitizer?  ", &use),
+	MENU("YES", yes, &use),
+	MENU("NO", no, &use),
+	{0}
+    };
+    char command[1024];
+
+    use_digitizer = 0;
+/*
+ * test to see if we have a digitizer (geo.quest)
+ * make sure this program has execute permission first.
+ * then run the program and check its exit status
+ *  0 means can use digitizer, other means can't
+ */
+    sprintf (command, "%s/etc/geo.quest", G_gisbase());
+    if (access (command, 1) != 0)
+	return 0;
+    if (system(command))
+	return 0;
+
+
+/*
+ * ask the user if he/she wishes to use it
+ */
+    Start_mouse_in_menu();
+    Input_pointer (objects);
+    if (use_digitizer)
+	Input_other (setup, "Keyboard");
+
+    return 0;
+}
+
+static int 
+setup (void)
+{
+    char command[1024];
+/*
+ * setup the digitizer. system() call must exit with 0 to indicate
+ * everything went fine
+ */
+    sprintf (command, "%s/etc/geo.reg %s %d",
+	G_gisbase(), digit_points, getpid());
+    Suspend_curses();
+    if (system (command))
+    {
+	use_digitizer = 0;
+	sleep(3);
+    }
+    Resume_curses();
+
+    return 0;
+}
+
+int 
+digitizer_point (double *east, double *north)
+{
+    char command[1024];
+    FILE *fd;
+    int stat;
+
+/* make sure digitzer is to be used */
+    if (!use_digitizer)
+	return 0;
+
+    sprintf (command, "%s/etc/geo.point %s %s",
+	G_gisbase(), digit_points, digit_results);
+
+    Suspend_curses();
+    if(system (command))
+    {
+	sleep(3);
+	Resume_curses();
+	oops();
+	return 0;
+    }
+    Resume_curses();
+    fd = fopen (digit_results, "r");
+    if (fd == NULL)
+    {
+	oops();
+	return 0;
+    }
+    stat = (fscanf (fd, "%lf %lf", east, north) == 2);
+    fclose (fd);
+
+    if (stat == 0)
+	oops();
+    return stat;
+}
+
+static int 
+oops (void)
+{
+    Curses_clear_window (MENU_WINDOW);
+    Curses_write_window (MENU_WINDOW, 3,2,"Can't get data from digitizer");
+
+    return 0;
+}
+
+static int 
+no (void)
+{
+    use_digitizer = 0;
+    return 1;
+}
+
+static int 
+yes (void)
+{
+    use_digitizer = 1;
+    return 1;
+}

Deleted: grass-addons/imagery/i.points.auto/dot.c
===================================================================
--- grass-addons/i.points.auto/dot.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/dot.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,55 +0,0 @@
-#include <grass/raster.h>
-#include "globals.h"
-
-int 
-dot (int x, int y)
-{
-    int vx[5], vy[5];
-
-    vx[0] = x;           vy[0] = y - dotsize;
-    vx[1] = x - dotsize; vy[1] = y;
-    vx[2] = x;           vy[2] = y + dotsize;
-    vx[3] = x + dotsize; vy[3] = y;
-    vx[4] = x;           vy[4] = y - dotsize;
-
-    R_polygon_abs (vx, vy, 5);
-/*
-    int i;
-
-    for (i = 0; i < dotsize; i++)
-    {
-	R_move_abs (x-i, y+i-dotsize);
-	R_cont_rel (i+i,0);
-	R_move_abs (x-i, y+dotsize-i);
-	R_cont_rel (i+i,0);
-    }
-    R_move_abs (x-dotsize, y);
-    R_cont_rel (dotsize+dotsize, 0);
-*/
-
-    return 0;
-}
-
-int 
-save_under_dot (int x, int y)
-{
-    R_panel_save (tempfile1, y-dotsize, y+dotsize, x-dotsize, x+dotsize);
-
-    return 0;
-}
-
-int 
-restore_under_dot (void)
-{
-    R_panel_restore (tempfile1);
-
-    return 0;
-}
-
-int 
-release_under_dot (void)
-{
-    R_panel_delete (tempfile1);
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/dot.c (from rev 30335, grass-addons/i.points.auto/dot.c)
===================================================================
--- grass-addons/imagery/i.points.auto/dot.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/dot.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,55 @@
+#include <grass/raster.h>
+#include "globals.h"
+
+int 
+dot (int x, int y)
+{
+    int vx[5], vy[5];
+
+    vx[0] = x;           vy[0] = y - dotsize;
+    vx[1] = x - dotsize; vy[1] = y;
+    vx[2] = x;           vy[2] = y + dotsize;
+    vx[3] = x + dotsize; vy[3] = y;
+    vx[4] = x;           vy[4] = y - dotsize;
+
+    R_polygon_abs (vx, vy, 5);
+/*
+    int i;
+
+    for (i = 0; i < dotsize; i++)
+    {
+	R_move_abs (x-i, y+i-dotsize);
+	R_cont_rel (i+i,0);
+	R_move_abs (x-i, y+dotsize-i);
+	R_cont_rel (i+i,0);
+    }
+    R_move_abs (x-dotsize, y);
+    R_cont_rel (dotsize+dotsize, 0);
+*/
+
+    return 0;
+}
+
+int 
+save_under_dot (int x, int y)
+{
+    R_panel_save (tempfile1, y-dotsize, y+dotsize, x-dotsize, x+dotsize);
+
+    return 0;
+}
+
+int 
+restore_under_dot (void)
+{
+    R_panel_restore (tempfile1);
+
+    return 0;
+}
+
+int 
+release_under_dot (void)
+{
+    R_panel_delete (tempfile1);
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/drawcell.c
===================================================================
--- grass-addons/i.points.auto/drawcell.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/drawcell.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,77 +0,0 @@
-#include <stdlib.h>
-#include <grass/gis.h>
-#include "globals.h"
-#include <grass/display.h>
-#include <grass/raster.h>
-#include "local_proto.h"
-
-int drawcell(View *view)
-{
-    int fd;
-    int left, top;
-    int ncols, nrows;
-    int row;
-    DCELL *dcell;
-    struct Colors *colors;
-    int read_colors;
-    char msg[GNAME_MAX];
-
-
-    if (!view->cell.configured) return 0;
-    if (view == VIEW_MAP1 || view == VIEW_MAP1_ZOOM)
-    {
-	colors = &VIEW_MAP1->cell.colors;
-	read_colors = view == VIEW_MAP1;
-    }
-    else
-    {
-	colors = &VIEW_MAP2->cell.colors;
-	read_colors = view == VIEW_MAP2;
-    }
-    if (read_colors)
-    {
-	G_free_colors (colors);
-	if(G_read_colors (view->cell.name, view->cell.mapset, colors) < 0)
-	    return 0;
-    }
-
-    display_title (view);
-
-    set_colors (colors);
-
-    G_set_window (&view->cell.head);
-    nrows = G_window_rows();
-    ncols = G_window_cols();
-
-    left = view->cell.left;
-    top = view->cell.top;
-
-    R_standard_color (BLUE);
-    Outline_box (top, top+nrows-1, left, left+ncols-1);
-
-    if (getenv("NO_DRAW"))
-        return 1;
-
-    fd = G_open_cell_old (view->cell.name, view->cell.mapset);
-    if (fd < 0)
-	return 0;
-    dcell = G_allocate_d_raster_buf();
-
-    sprintf (msg, "Plotting %s ...", view->cell.name);
-    Menu_msg(msg);
-
-    D_cell_draw_setup(top, top + nrows, left, left + ncols);
-    for (row = 0; row < nrows; row++)
-    {
-	if(G_get_d_raster_row_nomask(fd, dcell, row) < 0)
-	    break;
-	D_draw_d_raster (row, dcell, colors);
-    }
-    D_cell_draw_end();
-    G_close_cell (fd);
-    G_free (dcell);
-    if(colors != &VIEW_MAP1->cell.colors)
-	set_colors(&VIEW_MAP1->cell.colors);
-
-    return row==nrows;
-}

Copied: grass-addons/imagery/i.points.auto/drawcell.c (from rev 30335, grass-addons/i.points.auto/drawcell.c)
===================================================================
--- grass-addons/imagery/i.points.auto/drawcell.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/drawcell.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,77 @@
+#include <stdlib.h>
+#include <grass/gis.h>
+#include "globals.h"
+#include <grass/display.h>
+#include <grass/raster.h>
+#include "local_proto.h"
+
+int drawcell(View *view)
+{
+    int fd;
+    int left, top;
+    int ncols, nrows;
+    int row;
+    DCELL *dcell;
+    struct Colors *colors;
+    int read_colors;
+    char msg[GNAME_MAX];
+
+
+    if (!view->cell.configured) return 0;
+    if (view == VIEW_MAP1 || view == VIEW_MAP1_ZOOM)
+    {
+	colors = &VIEW_MAP1->cell.colors;
+	read_colors = view == VIEW_MAP1;
+    }
+    else
+    {
+	colors = &VIEW_MAP2->cell.colors;
+	read_colors = view == VIEW_MAP2;
+    }
+    if (read_colors)
+    {
+	G_free_colors (colors);
+	if(G_read_colors (view->cell.name, view->cell.mapset, colors) < 0)
+	    return 0;
+    }
+
+    display_title (view);
+
+    set_colors (colors);
+
+    G_set_window (&view->cell.head);
+    nrows = G_window_rows();
+    ncols = G_window_cols();
+
+    left = view->cell.left;
+    top = view->cell.top;
+
+    R_standard_color (BLUE);
+    Outline_box (top, top+nrows-1, left, left+ncols-1);
+
+    if (getenv("NO_DRAW"))
+        return 1;
+
+    fd = G_open_cell_old (view->cell.name, view->cell.mapset);
+    if (fd < 0)
+	return 0;
+    dcell = G_allocate_d_raster_buf();
+
+    sprintf (msg, "Plotting %s ...", view->cell.name);
+    Menu_msg(msg);
+
+    D_cell_draw_setup(top, top + nrows, left, left + ncols);
+    for (row = 0; row < nrows; row++)
+    {
+	if(G_get_d_raster_row_nomask(fd, dcell, row) < 0)
+	    break;
+	D_draw_d_raster (row, dcell, colors);
+    }
+    D_cell_draw_end();
+    G_close_cell (fd);
+    G_free (dcell);
+    if(colors != &VIEW_MAP1->cell.colors)
+	set_colors(&VIEW_MAP1->cell.colors);
+
+    return row==nrows;
+}

Deleted: grass-addons/imagery/i.points.auto/driver.c
===================================================================
--- grass-addons/i.points.auto/driver.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/driver.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,63 +0,0 @@
-#include "globals.h"
-#include "local_proto.h"
-
-static int use = 1;
-static int stop(void);
-static int dont_stop(void);
-static int really_quit(void);
-
-int driver (void)
-{
-  static Objects objects[] =
-    {
-      MENU(" QUIT  ",really_quit,&use),
-      MENU(" ZOOM  ",zoom,&use),
-      MENU(" PLOT RASTER  ",plotcell,&use),
-      MENU(" LINE  ",line,&use), 
-      MENU(" ANALYZE  ",analyze,&use),
-      MENU(" SEMIAUTOMATED SEARCH  ",Extract_matrix_semi,&use),
-      MENU(" AUTOMATED SEARCH  ",automated_search,&use),
-      OTHER(mark, &use),
-      {0}
-    };
-  
-  Input_pointer (objects);
-  Menu_msg ("");
-  
-  return 0;
-}
-
-
-
-
-
-
-static int
-really_quit (void)
-{
-    static Objects objects[] =
-    {
-	INFO("really quit? ",&use),
-	MENU(" NO  ",dont_stop,&use),
-	MENU(" YES  ",stop,&use),
-	{0}
-    };
-    if (Input_pointer (objects) < 0)
-	return -1;
-    return 0; /* don't quit */
-}
-
-
-static int 
-dont_stop (void)
-{
-    return 1;
-}
-
-static int 
-stop (void)
-{
-    return -1;
-}
-
-

Copied: grass-addons/imagery/i.points.auto/driver.c (from rev 30335, grass-addons/i.points.auto/driver.c)
===================================================================
--- grass-addons/imagery/i.points.auto/driver.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/driver.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,63 @@
+#include "globals.h"
+#include "local_proto.h"
+
+static int use = 1;
+static int stop(void);
+static int dont_stop(void);
+static int really_quit(void);
+
+int driver (void)
+{
+  static Objects objects[] =
+    {
+      MENU(" QUIT  ",really_quit,&use),
+      MENU(" ZOOM  ",zoom,&use),
+      MENU(" PLOT RASTER  ",plotcell,&use),
+      MENU(" LINE  ",line,&use), 
+      MENU(" ANALYZE  ",analyze,&use),
+      MENU(" SEMIAUTOMATED SEARCH  ",Extract_matrix_semi,&use),
+      MENU(" AUTOMATED SEARCH  ",automated_search,&use),
+      OTHER(mark, &use),
+      {0}
+    };
+  
+  Input_pointer (objects);
+  Menu_msg ("");
+  
+  return 0;
+}
+
+
+
+
+
+
+static int
+really_quit (void)
+{
+    static Objects objects[] =
+    {
+	INFO("really quit? ",&use),
+	MENU(" NO  ",dont_stop,&use),
+	MENU(" YES  ",stop,&use),
+	{0}
+    };
+    if (Input_pointer (objects) < 0)
+	return -1;
+    return 0; /* don't quit */
+}
+
+
+static int 
+dont_stop (void)
+{
+    return 1;
+}
+
+static int 
+stop (void)
+{
+    return -1;
+}
+
+

Deleted: grass-addons/imagery/i.points.auto/equ.c
===================================================================
--- grass-addons/i.points.auto/equ.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/equ.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,11 +0,0 @@
-#include "globals.h"
-#include "local_proto.h"
-
-int 
-Compute_equation (void)
-{
-    group.equation_stat = compute_georef_equations(&group.points,
-	group.E12, group.N12, group.E21, group.N21);
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/equ.c (from rev 30335, grass-addons/i.points.auto/equ.c)
===================================================================
--- grass-addons/imagery/i.points.auto/equ.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/equ.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,11 @@
+#include "globals.h"
+#include "local_proto.h"
+
+int 
+Compute_equation (void)
+{
+    group.equation_stat = compute_georef_equations(&group.points,
+	group.E12, group.N12, group.E21, group.N21);
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/find.c
===================================================================
--- grass-addons/i.points.auto/find.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/find.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,21 +0,0 @@
-#include <stdlib.h>
-#include "globals.h"
-#include "local_proto.h"
-
-/*
- * run etc/i.find command find all cell, vect files
- * in the target location.
- */
-int find_target_files (void)
-{
-    char command[1024];
-
-    select_target_env();
-    sprintf (command, "%s/etc/i.find %s %s cell %s dig %s",
-	G_gisbase(), G_location(), G_mapset(), cell_list, vect_list);
-    select_current_env();
-
-    system(command);
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/find.c (from rev 30335, grass-addons/i.points.auto/find.c)
===================================================================
--- grass-addons/imagery/i.points.auto/find.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/find.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,21 @@
+#include <stdlib.h>
+#include "globals.h"
+#include "local_proto.h"
+
+/*
+ * run etc/i.find command find all cell, vect files
+ * in the target location.
+ */
+int find_target_files (void)
+{
+    char command[1024];
+
+    select_target_env();
+    sprintf (command, "%s/etc/i.find %s %s cell %s dig %s",
+	G_gisbase(), G_location(), G_mapset(), cell_list, vect_list);
+    select_current_env();
+
+    system(command);
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/find_points.c
===================================================================
--- grass-addons/i.points.auto/find_points.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/find_points.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,2212 +0,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
-#include <math.h>
-
-#include <grass/config.h>
-#ifdef HAVE_FFTW_H
-#include <fftw.h>
-#endif
-#ifdef HAVE_DFFTW_H
-#include <dfftw.h>
-#endif
-
-#include <grass/raster.h>
-#include <grass/imagery.h>
-#include <grass/gmath.h>
-#include "globals.h"
-#include "local_proto.h"
-
-#ifdef NULL_VALUE
-#undef NULL_VALUE
-#endif
-#define NULL_VALUE -1
-
-
-double *fft_first[2];
-double *fft_second[2];
-double *fft_prod_con[2];
- 
-int n=1;   /*If (n==1) then the algorithm is searching the Overlapping-Area, if (n==2), it is searching the GCP's*/ 
-int pos_point;
-int dist;                                             
-int ncols1, ncols2, nrows1, nrows2;
-int nrows1_img, ncols1_img, nrows2_img, ncols2_img;
-int r1, c1;                                          /* Central (or around the central) point of the first img    */
-int r2, c2;                                          /* Corresponding point in the second img                     */
-int r2c, c2c;                                        /* Central point of the first img                            */
-
-char *group_name;
-char *group_MAPSET;
-char *group_LOCATION_NAME;
-char *group_GISDBASE;
-int q;
-FILE *fp;
-FILE *fp_old; 
-/*int i;*/
-char file_name[500];
-
-char name1[100];
-char name2[100];
-char mapset[100];
-
-int dist_r, dist_c;  
-
-int z;
-
-
-int n_points=0;           /* When "LESS_GCP's" is activated, then (n_points==0) */
-int man_op=0;             /* Variable for the option "Manual_OP". It's 1 if the option is activated */
-double e_man2, n_man2;     /* Coordinates for the manual_OP */
-int man_m_s_op=0; 
-double e_man1, n_man1;
-
-View *m1, *m2; 
-
-
-
-
-int min(int a, int b)
-{
- 
-  if(a <= b)
-    {
-      return a;
-    }
-  else
-    {
-      return b;
-    } 
-}
-
-static int main_menu();
-static int cancel();
-static int shift1();
-static int shift2();
-
-static int less_GCPs();
-static int manual_op();
-static int manual_op1();
-static int mark_op(int x,int y,int button);
-static int mark_point_op (View *view,int x, int y);
-
-static int central();
-static int top();
-static int bottom();
-static int left();
-static int right();
-
-static int manual_m_s_op();
-static int manual_m_s_op1();
-static int mark_m_s_op(int x,int y,int button);
-static int mark_point_m_s_op (View *view,int x, int y);
-
-/* variables for function "TRY_AGAIN" */
-char name1_initial[100];
-char name2_initial[100];
-char mapset_initial[100];
-static int try_again();
-static int store_points();
-
-
-
-
-/* Variables and functions for the Auto-Exclusion */
-static int curp, first_point;
-static double *xres, *yres, *gnd, *tres, *ures, *lgnd;
-static int offsetx, offsety;
-static int xmax, ymax, gmax;
-static int tmax, umax, lgmax;
-static double rms,l_rms;
-static double th=2.5;                 /*Default threshold of the rms for the Auto-Exclusion.*/
-char file_name1[500];
-static int auto_exclusion();
-static int change_rms_th();
-static int compute_transformation(void);
-static int th_1();
-static int th_2();
-static int th_3();
-static int th_4();
-static int th_5();
-static int other_th();
-static int pre_analyze();
-
-
-
-
-
-
-
-
-
-int automated_search()
-{
-
-  static int use = 1;
-
-  ask_original_map ("raster", group_list, name1,mapset, -1);      
-  ask_original_map ("raster", group_list, name2,mapset, 1);       
-
-  
-
-  static Objects objects1[]=
-    {   
-      MENU(" MAIN MENU  ",cancel,&use),   
-      INFO(" O.P. -> ",&use),
-      MENU(" Central  ",central,&use),
-      MENU(" Top  ",top,&use),
-      MENU(" Bottom  ",bottom,&use),   
-      MENU(" Left  ",left,&use),   
-      MENU(" Right  ",right,&use),
-      INFO("  ",&use),
-      MENU(" LESS GCPs  ",less_GCPs,&use),
-      MENU(" Mark Slave-O.P.  ",manual_op,&use),
-      MENU(" Mark M&S-O.P.  ",manual_m_s_op,&use),
-      {0}
-    };
-
-      
-  Input_pointer (objects1);
-
-  m=0;
-
-  return 0;
-
-}
-
-
-
-
-
-
-void Extract_matrix()
-{
-  struct GModule *module;
-  struct Control_Points *cp1;
-  char buf[256];
-  char *s;
-  int rows, cols;
-  
-  char *first_map_R_mapset;
-  char *first_map_R_name;
-  int first_map_R_fd;
-  char *second_map_R_mapset;
-  char *second_map_R_name;
-  int second_map_R_fd;
-  
-  int K;
-  
-  int correlation_window_dim;
-  int search_window_dim;
-  int search_window_dim1;
-  int search_window_dim2;
-
-
-  int squared_search_window_dim;
-  int search_jump;
-  
-  int left1, top1, left2, top2;   
-  int repeat;  
-
-  int n_1, e_1, n_2, e_2, s_1, s_2, w_1, w_2;
-  int r1_1, r1_2, r2_1, r2_2;
-  int c1_1, c1_2, c2_1, c2_2;
-
-  int i;
-
-  int h1_r;
-  int h1_c;
-  int h2_r;
-  int h2_c;
-
-  
-  DCELL *rowbuf1_R;
-  DCELL *tf1_R;
-  DCELL *rowbuf2_R;
-  DCELL *tf2_R;
-  double **search_window;
-  double **mat1,**mat2;    
-  int r,c;
-  int search_border;
-  int p1;
-  int dim_win_c, dim_win_r;
-  char first_sites[500];
-  char second_sites[500];
-  char file_name_old[500];
-  FILE *first_fp;
-  FILE *second_fp;  
-
-  int xp1, yp1, xs1, ys1;
-  int xp2, yp2, xs2, ys2;
-  int nimg;
-   
-  static int use = 1;
-
-
- 
-
-  if(n==1)
-    {
-      m1=VIEW_MAP1;    
-      m2=VIEW_MAP2;
-    }
-
-  else    
-    {
-               
-      if( (r2 >= r1) && (c2 >= c1 ) )                         
-	{
-	  xp1 = (c1 - (min(c1,c2)))+1;           
-	  xp2 = (c2 - (c1-xp1));        
-	  xs2 = (c2 + min((ncols1-c1),(ncols2-c2)))-1;                                     
-	  xs1 = (c1 + (xs2 - c2)); 
-	  yp1 = (r1 - (min(r1,r2)))+1;    
-	  yp2 = (r2 - (r1 - yp1));
-	  ys2 = (r2 + min((nrows1-r1),(nrows2-r2)))-1;
-	  ys1 = (r1 + (ys2 - r2));
-	}     
-      else if( (r2 <= r1) && (c2 <= c1) )                        
-	{
-	  xp2 = (c2 - (min(c2,c1)))+1;
-	  xp1 = (c1 - (c2 - xp2));
-	  xs1 = (c1 + min((ncols1-c1),(ncols2-c2)))-1;
-	  xs2 = (c2 + (xs1 - c1));
-	  yp2 = (r2 - min(r2,r1))+1; 
-	  yp1 = (r1 - (r2 - yp2));
-	  ys1 = (r1 + min((nrows1-r1),(nrows2-r2)))-1;
-	  ys2 = (r2 + (ys1 - r1));
-	}
-      else if( (r2 >= r1) && (c2 <= c1) )    
-	{    
-	  xp2 = (c2 - min(c2,c1))+1;
-	  xp1 = (c1 - (c2 - xp2));
-	  xs1 = (c1 + min((ncols1-c1),(ncols2-c2)))-1;
-	  xs2 = (c2 + (xs1 - c1));
-	  yp1 = (r1 - min(r1,r2))+1;
-	  yp2 = (r2 - (r1 - yp1));
-	  ys2 = (r2 + min((nrows1-r1),(nrows2-r2)))-1;
-	  ys1 = (r1 + (ys2 - r2));
-	}
-      else if( (r2 <= r1) && (c2 >= c1) )                          
-	{ 
-	  xp1 = (c1 - min(c1,c2))+1;
-	  xp2 = (c2 - (c1 - xp1));
-	  xs2 = (c2 + min((ncols2-c2),(ncols1-c1)))-1;
-	  xs1 = (c1 + (xs2 - c2));
-	  yp2 = (r2 - min(r1,r2))+1;
-	  yp1 = (r1 - (r2 - yp2));
-	  ys1 = (r1 + min((nrows1-r1),(nrows2-r2)))-1;
-	  ys2 = (r2 + (ys1 - r1));
-	}
-
-
-      /* overlap_area(): function that extracts a window from the angle-points 
-       * top_left (xp1, yp1) and down_right (xs1, ys1)  
-       */
-      nimg = 1;
-      overlap_area(xp1, yp1, xs1, ys1, nimg, ncols1, nrows1);      
-  
- 
-      nimg = 2;
-      overlap_area(xp2, yp2, xs2, ys2, nimg, ncols2, nrows2);
-  
-  
-      m1=VIEW_MAP1_ZOOM;   
-      m2=VIEW_MAP2_ZOOM;   
-  
-    } 
-
-
-
-  first_map_R_name=m1->cell.name;
-  second_map_R_name=m2->cell.name;
- 
- 
-
-
-
-  /* rows & cols of the view in m1 */
-  n_1=m1->cell.head.north;
-  e_1=m1->cell.head.east;
-  s_1=m1->cell.head.south;
-  w_1=m1->cell.head.west; 
-  left1 = m1->cell.left;
-  top1 = m1->cell.top;
-  
-  r1_1=s_1/m1->cell.ns_res;
-  r1_2=n_1/m1->cell.ns_res;
-  c1_1=w_1/m1->cell.ew_res; 
-  c1_2=e_1/m1->cell.ew_res;
-  
-  nrows1=r1_2-r1_1;
-  ncols1=c1_2-c1_1;
-
-
-  /* rows & cols of the view in m2 */
-  n_2=m2->cell.head.north;
-  e_2=m2->cell.head.east; 
-  s_2=m2->cell.head.south;
-  w_2=m2->cell.head.west;    
-  left2 = m2->cell.left;
-  top2 = m2->cell.top; 
-  
-  r2_1=s_2/m2->cell.ns_res;
-  r2_2=n_2/m2->cell.ns_res;
-  c2_1=w_2/m2->cell.ew_res; 
-  c2_2=e_2/m2->cell.ew_res;
-
-  nrows2=r2_2-r2_1; 
-  ncols2=c2_2-c2_1;
-  
-  
-  if(n==1)
-    {
-      nrows1_img = nrows1;
-      ncols1_img = ncols1;
-      nrows2_img = nrows2;
-      ncols2_img = ncols2;
-    }
-  
- 
-  /* Initialize the GIS calls */
-  module = G_define_module();
-  module->description = "Fine registration of two stereo images";
-  
-  /* Load environmental vars*/
-  group_LOCATION_NAME=buf;
-  group_LOCATION_NAME=G_getenv("LOCATION_NAME");
-  group_GISDBASE=buf;
-  group_GISDBASE=G_getenv("GISDBASE");
-  group_MAPSET=buf;
-  group_MAPSET=G_getenv("MAPSET");
-  
-   
-  if(n==1)
-    {  
-
-      strcpy (name1_initial,first_map_R_name);
-      strcpy (name2_initial,second_map_R_name);
-      strcpy (mapset_initial,group_MAPSET);
-     
-    }
-
-
-  /* Correlation parameters */
-  if(n==1)
-    {
-
-      if(ncols1 <= nrows1)
-	{  
-	  search_window_dim1 = ncols1;                      
-	} 
-      else
-	{
-	  search_window_dim1 = nrows1;                      
-	}
-
-      if(ncols2 <= nrows2)
-	{
-	  search_window_dim2 = ncols2;                     
-	}
-      else
-	{
-	  search_window_dim2 = nrows2;                       
-	}
-
-
-
-      if(search_window_dim1 <= search_window_dim2)
-	{
-	  search_window_dim = search_window_dim1;
-	} 
-      else
-	{  
-	  search_window_dim = search_window_dim2;
-	} 
-    }
-
-
-  else if(n==2)
-    { 
-      correlation_window_dim=((ncols1/10+nrows1/10)/4);
-
-
-      
-      if(n_points==1)
-	{
-
-	  K=((ncols1/4+nrows1/4)/3);    
-	  search_window_dim = (correlation_window_dim + K);
-	  n_points = 0;
-
-	}
-      else
-	{
-
-	  K=((ncols1/4+nrows1/4)/8);  
-	  search_window_dim = G_math_max_pow2(correlation_window_dim + K);
-
-	}
-
-
-     
-      search_jump=search_window_dim / 2; 
-    }
-  
-
-
-
-  group_name=group.name;
-  squared_search_window_dim=search_window_dim*search_window_dim;
-  
-  
-  if(n==1)
-    {
-      Menu_msg ("Loading first image...");
-    } 
-
-  else
-    {
-      Menu_msg ("Loading first overlapping_image..."); 
-    }
-
-  /* Open first real map*/
-  
-  if((first_map_R_mapset = G_find_cell2(first_map_R_name, "")) == NULL)
-    {
-      sprintf(buf,"Raster map [%s] not available",first_map_R_name);
-      G_fatal_error(buf);
-    }
-  
-  
-  if((first_map_R_fd = G_open_cell_old(first_map_R_name, 
-				       first_map_R_mapset)) < 0)
-    {
-      sprintf(buf,"Error opening raster map [%s]", first_map_R_name);
-      G_fatal_error(buf);
-    }
-
-  /* Set region to first map definition region  < m1 > */ 
-  G_get_cellhd (first_map_R_name, first_map_R_mapset, &cellhd1);
-  G_set_window(&cellhd1);
-  h1_r=cellhd1.rows;
-  h1_c=cellhd1.cols;
-    
-
-   
-  /* Memory allocation for the first overlapping_map */
-  
-  mat1 = (DCELL **) G_calloc(nrows1,sizeof(DCELL *));
-  for(r=0;r<nrows1;r++)
-    mat1[r] = (DCELL *) G_calloc(ncols1,sizeof(DCELL)); 
-  
-
-  /* Load first map*/
-  
-  rowbuf1_R = (DCELL *)G_calloc(h1_r * h1_c,sizeof(DCELL));
-  tf1_R=rowbuf1_R;
-  
-  for(r=h1_r-r1_2;r<h1_r-r1_1;r++)
-    {  
-      G_get_d_raster_row(first_map_R_fd, tf1_R, r);	
-      if (G_is_d_null_value (tf1_R)) 
-	*tf1_R = NULL_VALUE;	
-      c=0;
-      while(c<c1_1)
-	{	
-	  tf1_R++;
-	  c++;
-	}	
-      for(c = c1_1; c < c1_2; c++)
-	{
-	  mat1[-h1_r+r1_2+r][c-c1_1] = *tf1_R;
-	  tf1_R++;
-	}
-    }
-  G_close_cell(first_map_R_fd);
-  
-  
-  /* Open second map*/
-  if((second_map_R_mapset = G_find_cell2(second_map_R_name, "")) == NULL)
-    {
-      sprintf(buf,"Raster map [%s] not available",second_map_R_name);
-      G_fatal_error(buf);
-    }
-  
-  if((second_map_R_fd = G_open_cell_old(second_map_R_name, 
-					second_map_R_mapset)) < 0) 
-    {
-      sprintf(buf,"Error opening raster map [%s]", second_map_R_name);
-      G_fatal_error(buf);
-    } 
-    
-  /* Set region to second map definition region */
-  G_get_cellhd (second_map_R_name, second_map_R_mapset, &cellhd2);
-  G_set_window(&cellhd2);
-  h2_r=cellhd2.rows;
-  h2_c=cellhd2.cols;
-  
-  
-  /* Memory allocation for the second overlapping_map */
-  mat2 = (DCELL **) G_calloc(nrows2,sizeof(DCELL *));
-  for(r=0;r<nrows2;r++)
-    mat2[r] = (DCELL *) G_calloc(ncols2,sizeof(DCELL));
-
-  /* Load second real map */
-  if(n==1)
-    {
-      Menu_msg ("Loading second image...");
-    }
-
-  else
-    {
-      Menu_msg ("Loading second overlapping_image...");
-    }
-  
-  rowbuf2_R=(DCELL *)G_calloc(h2_r * h2_c,sizeof(DCELL));
-  tf2_R=rowbuf2_R;
-  for(r=h2_r-r2_2;r<h2_r-r2_1;r++)
-    
-    {				
-      G_get_d_raster_row(second_map_R_fd, tf2_R, r);	
-      c=0;
-      while(c<c2_1)
-	{	
-	  tf2_R++;
-	  c++;
-	}	
-      for(c = c2_1; c < c2_2; c++)
-	{
-	  if (G_is_d_null_value (tf2_R)) 
-	    *tf2_R = NULL_VALUE;
-	  mat2[-h2_r+r2_2+r][c-c2_1] = *tf2_R;
-	  tf2_R++;
-	}
-    }
-  
-  G_close_cell(second_map_R_fd);
-  
-
-  if( (n==1) && (man_op==0) )
-    {
-      Menu_msg ("Searching in the second image the corresponding point of the central point of the first one...");
-    }
-  else if(n==2)
-    {
-      Menu_msg ("Searching points...");
-    }
- 
-  /* Memory allocation */
-  search_window = (DCELL **) G_calloc(search_window_dim,
-				      sizeof(DCELL *));
-  for(r=0;r<search_window_dim;r++)
-    search_window[r] = (DCELL *) G_calloc(search_window_dim,
-					  sizeof(DCELL));
-    
-  fft_first[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-  fft_first[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-  fft_second[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-  fft_second[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-  fft_prod_con[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-  fft_prod_con[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-    
-
-  /* Inizialize control points */
-  if(n==1)  
-    {
-      sPoints.count=1;
-      sPoints.e1=(double *) G_calloc(sPoints.count,sizeof(double));
-      sPoints.n1=(double *) G_calloc(sPoints.count,sizeof(double));
-      sPoints.e2=(double *) G_calloc(sPoints.count,sizeof(double));
-      sPoints.n2=(double *) G_calloc(sPoints.count,sizeof(double));
-      sPoints.status=(int *) G_calloc(sPoints.count,sizeof(int));
-    }
-
-  /* Sites file */
-  sprintf(first_sites,"%s/%s/%s/site_lists/%s_%s",G__getenv("GISDBASE"),
-	  G__getenv("LOCATION_NAME"),G__getenv("MAPSET"),
-	  group_name,first_map_R_name);
-  sprintf(second_sites,"%s/%s/%s/site_lists/%s_%s",G__getenv("GISDBASE"),
-	  G__getenv("LOCATION_NAME"),G__getenv("MAPSET"),
-	  group_name,second_map_R_name);
-    
-   
-  /* Set cellhd1 to overlapping_map_1 */  
-  cellhd1.rows=nrows1;
-  cellhd1.cols=ncols1;
-  cellhd1.north=r1_2*m1->cell.ns_res;
-  cellhd1.south=r1_1*m1->cell.ns_res;
-  cellhd1.east=c1_2*m1->cell.ew_res;
-  cellhd1.west=c1_1*m1->cell.ew_res;
- 
-  /* Set cellhd2 to overlapping_map_2 */  
-  cellhd2.rows=nrows2;
-  cellhd2.cols=ncols2;
-  cellhd2.north=r2_2*m2->cell.ns_res;
-  cellhd2.south=r1_1*m2->cell.ns_res;
-  cellhd2.east=c2_2*m2->cell.ew_res;
-  cellhd2.west=c2_1*m2->cell.ew_res;
-  
-  /* Set windows to cellhd1 */
-  G_set_window(&cellhd1);
- 
-  
-    
-  /******************************************/
-  /* function --> Search_correlation_points */ 
-  /******************************************/     
-  Search_correlation_points(mat1, mat2,
-			    search_window_dim, 
-			    squared_search_window_dim,
-			    search_jump,group_name, nrows1, ncols1,
-			    search_window, r1_2, c1_1, r2_2, c2_1,
-			    h1_r, h2_r, h1_c, h2_c, nrows2, ncols2, n );
-    
-  
- 
-  
-  sprintf(file_name,"%s/%s/%s/group/%s/TARGET",group_GISDBASE,
-	  group_LOCATION_NAME, group_MAPSET,group_name);
-  fp = fopen(file_name,"w");
-  fprintf(fp,"%s\n%s\n",group_LOCATION_NAME,group_MAPSET);
-  fclose(fp);
-    
-
-  if(n==2)
-    {
-      
-      G_get_cellhd (name1, mapset, &cellhd1);
-      G_adjust_window_to_box (&cellhd1, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows, VIEW_MAP1->ncols);
-      Configure_view (VIEW_MAP1, name1, mapset, cellhd1.ns_res, cellhd1.ew_res);
-      drawcell(VIEW_MAP1);
-      display_points(1);
-      R_flush();
-      Curses_clear_window (PROMPT_WINDOW);
-      
-
-      G_get_cellhd (name2, mapset, &cellhd2);
-      G_adjust_window_to_box (&cellhd2, &VIEW_MAP2->cell.head, VIEW_MAP2->nrows, VIEW_MAP2->ncols);
-      Configure_view (VIEW_MAP2, name2, mapset, cellhd2.ns_res, cellhd2.ew_res);
-      drawcell(VIEW_MAP2);
-      display_points(1);
-      R_flush();
-      Curses_clear_window (PROMPT_WINDOW);
-      
-      nimg = 1;
-      overlap_area(xp1, yp1, xs1, ys1, nimg, ncols1_img, nrows1_img);
-     
-      nimg = 2;
-      overlap_area(xp2, yp2, xs2, ys2, nimg, ncols2_img, nrows2_img);
-
-     
-    }
-
-
-    
-  select_current_env ();
-
-  
-  display_points_in_view_diff_color (VIEW_MAP1, 1,
-				     sPoints.e1, sPoints.n1,
-				     sPoints.status, sPoints.count);
-  
-  
-  display_points_in_view_diff_color (VIEW_MAP2, 1,
-				     sPoints.e2, sPoints.n2,
-				     sPoints.status, sPoints.count);
-
-  
-  
-  
-  display_points_in_view_diff_color (VIEW_MAP1_ZOOM, 1,
-				     sPoints.e1, sPoints.n1,
-				     sPoints.status, sPoints.count);
-  
-  
-  
-  display_points_in_view_diff_color (VIEW_MAP2_ZOOM, 1,
-				     sPoints.e2, sPoints.n2,
-				     sPoints.status, sPoints.count);  
-  
-  R_flush();   
-
-
- 
-  if(n==2)
-    {
-        
-      static Objects objects[]=
-	{
-	  MENU(" MAIN MENU  ",main_menu,&use),   
-	  MENU(" STORE POINTS IN FILE  ",store_points,&use),
-	  MENU(" TRY AGAIN  ",try_again,&use),   
-	  INFO("                ",&use),
-	  MENU(" rms-th  ",change_rms_th,&use),
-	  MENU(" Auto-Exclusion GCPs  ",auto_exclusion,&use),
-	  {0}
-	};
-
-      Input_pointer (objects);
-
-
-      return 0;  
-    }
-
-
-
-
-
-  /* Free memory */
-
-  free( rowbuf1_R);
-  free( rowbuf2_R);
-
-
-  for(r=0;r<nrows1;r++)
-    free( mat1[r]);
-  free(mat1);
-    
-  for(r=0;r<nrows2;r++)
-    free( mat2[r]);
-  free(mat2);
-    
-  for(r=0;r<search_window_dim;r++)
-    free(search_window[r]);
-  free(search_window);
-    
-  for(r=0;r<2;r++) 
-    {
-      free(fft_first[r]);
-      free(fft_second[r]);
-      free(fft_prod_con[r]);
-    }
-    
-
-  if(n==2)         
-    {
-      sPoints.e1[0];
-      sPoints.n1[0];
-      sPoints.e2[0];
-      sPoints.n2[0];
-      sPoints.status[0];
-      
-      free(sPoints.e1);
-      free(sPoints.n1);
-      free(sPoints.n2);
-      free(sPoints.e2);
-      free(sPoints.status);
-    }
-
-
-  
-  
-  if(n==1)
-    {
-      n=2;
-      Extract_matrix();
-    }
-  else
-    {
-      man_op = 0;
-      man_m_s_op = 0;
-
-      return 0;
-    }
-
-}
-
-
-
-
-
-
-void Search_correlation_points(DCELL **mat1_R, DCELL **mat2_R,
-			       int search_window_dim, 
-			       int squared_search_window_dim, 
-			       int search_jump, char *group_name,
-			       int dim_win_r, int dim_win_c,
-			       DCELL **search_window, int r1_2,int c1_1,
-			       int r2_2,int c2_1, int h1_r, int h2_r, 
-			       int  h1_c, int h2_c, int nrows2, int ncols2,   int n  )
-{
-  int r,c;
-  int i, j, search_border;
-  char *group_MAPSET;
-  char *group_LOCATION_NAME;
-  char *group_GISDBASE;
-  char first_sites[500];
-  char second_sites[500];
-  char file_name[500];    
-  FILE *fp;
-  FILE *first_fp;
-  FILE *second_fp;  
-  double cc;
-  double north1,east1,north2,east2;
-  int tmp_r,tmp_c;
-  double mean;
-  int index;
-  
- 
-  
-
-  if( (n==1) && (man_m_s_op==0) )   
-    {
-	
-      r1 = (dim_win_r/2);
-      c1 = (dim_win_c/2);
-      
-      
-      if(man_op==0) 
-	{	    
-                
-	  switch (pos_point)
-	    {
-	    case 0: dist = 0;
-	      dist_r = 0;
-	      dist_c = 0;
-	      break;
-	    case 1: r1 = ((dim_win_r/2)-dist);	          
-	      break;
-	    case 2: r1 = ((dim_win_r/2)+dist);	       
-	      break;
-	    case 3: c1 = ((dim_win_c/2)-dist);                    
-	      break;
-	    case 4: c1 = ((dim_win_c/2)+dist);	                     
-	      break;
-	    }
-	  
-	  
-      
-	  r2c = (nrows2 / 2);
-	  c2c = (ncols2 / 2);
-	  
-	  
-	  if(pos_point!=0)
-	    {
-	      search_window_dim = (search_window_dim - (2*dist));
-	      squared_search_window_dim = (search_window_dim * search_window_dim);
-	      search_jump = (search_window_dim / 2);
-	    }
-      
-      
-      
-	  search_border =  search_window_dim / 2;
-	  
-	  
-	  
-	  /*  Reinizialize fft vectors */
-	  
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fft_first[0][i]=0.0;
-	      fft_first[1][i]=0.0;
-	      fft_second[0][i]=0.0;
-	      fft_second[1][i]=0.0;
-	      fft_prod_con[0][i]=0.0;
-	      fft_prod_con[1][i]=0.0;
-	    }
-      
-      
-	  /* Coordinates of the "initial" point */
-      
-	  east1 = G_col_to_easting((double) c1, &cellhd1);
-	  north1 = G_row_to_northing((double) r1, &cellhd1);
-      
-	 
-      
-
-	  
-	
-	  /* Real window in the first image */
-	  
-	  Extract_portion_of_double_matrix(r1,c1,search_border,search_border,
-					   mat1_R,search_window);
-      
-
-
-	  mean = 0.0;
-	  for(i=0;i<search_window_dim;i++)
-	    {
-	      for(j=0;j<search_window_dim;j++)
-		{
-		  mean +=  search_window[i][j];
-		}
-	    }
-	  mean /= squared_search_window_dim;
-      
-	  for(i=0;i<search_window_dim;i++)
-	    {
-	      for(j=0;j<search_window_dim;j++)
-		{
-		  fft_first[0][i*search_window_dim+j]=search_window[i][j]-mean;
-		}
-	    }
-
-
-	  
-
-	  Extract_portion_of_double_matrix(r2c,c2c,search_border,search_border,
-					   mat2_R,search_window);
-
-
-	  mean = 0.0;
-	  for(i=0;i<search_window_dim;i++)
-	    {
-	      for(j=0;j<search_window_dim;j++)
-		{
-		  mean +=  search_window[i][j];
-		}
-	    }
-	  mean /= squared_search_window_dim;
-	  for(i=0;i<search_window_dim;i++)
-	    {
-	      for(j=0;j<search_window_dim;j++)
-		{
-		  fft_second[0][i*search_window_dim+j]=search_window[i][j]-mean;
-		}
-	    }
-
-
-
-
-	  /* fft of the 2 (complex) windows */
-	  fft(-1,fft_first,squared_search_window_dim,search_window_dim,
-	      search_window_dim);
-	  fft(-1,fft_second,squared_search_window_dim,search_window_dim,
-	      search_window_dim);
-
-
-
-	  
-	  /* product of the first fft for the coniugate of the second one */
-	  for(i=0;i<squared_search_window_dim;i+=1)
-	    {
-	      fft_prod_con[0][i] = (fft_first[0][i] * fft_second[0][i]) +
-		(fft_first[1][i] * fft_second[1][i]);
-	      fft_prod_con[1][i] = (fft_first[1][i] * fft_second[0][i]) -
-		(fft_first[0][i] * fft_second[1][i]);
-	    }
-	  
-
-
-
-	  /* fft^{-1} of the product <==> cross-correlation at differnet lag
-	     between the two orig. (complex) windows */
-	  fft(1,fft_prod_con,squared_search_window_dim,search_window_dim,
-	      search_window_dim);
-
-
-
-
-	  /* Search the lag coresponding to the maximum correlation */
-	  cc = 0.0;
-	 
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      if(fft_prod_con[0][i] > cc)
-		{
-		  cc = fft_prod_con[0][i];
-		  tmp_r=i/search_window_dim;
-		  tmp_c=i%search_window_dim;
-		
-		}
-	    } 
-
-
-	
-	 
-	  /* Get coordinates of "ending" point  */
-	  if((tmp_r <= search_window_dim/2) && (tmp_c <= search_window_dim/2))
-	    {
-	   
-	      east2 = G_col_to_easting((double) c1  - tmp_c,&cellhd2) + dist_c;
-	      north2 = G_row_to_northing((double) r1  - tmp_r,&cellhd2) + dist_r;
-	   
-	    }
-	  if((tmp_r <= search_window_dim/2) && (tmp_c >= search_window_dim/2))
-	    {
-	      
-	      east2 = G_col_to_easting((double) c1  - (tmp_c-search_window_dim-1),&cellhd2) + dist_c;
-	      north2 = G_row_to_northing((double) r1 -  tmp_r,&cellhd2) + dist_r;
-	   
-	    }
-	  if((tmp_r >= search_window_dim/2) && (tmp_c <= search_window_dim/2))
-	    {
-	     
-	      east2 = G_col_to_easting((double) c1  - tmp_c,&cellhd2) + dist_c;
-	      north2 = G_row_to_northing((double) r1 - (tmp_r-search_window_dim-1),&cellhd2) + dist_r;
-	    
-	    }
-	  if((tmp_r >= search_window_dim/2) && (tmp_c >= search_window_dim/2))
-	    {
-	    
-	      east2 = G_col_to_easting((double) c1  - (tmp_c-search_window_dim-1),&cellhd2) + dist_c;
-	      north2 = G_row_to_northing((double) r1  - (tmp_r-search_window_dim-1),&cellhd2) + dist_r;
-	    
-	    }
-
-
-	  	  
-	  r2 = G_northing_to_row(north2,&cellhd2);
-	  c2 = G_easting_to_col(east2,&cellhd2);
-
-	  sPoints.e1[sPoints.count-1] = east1;
-	  sPoints.n1[sPoints.count-1] = north1;
-	  sPoints.e2[sPoints.count-1] = east2;
-	  sPoints.n2[sPoints.count-1] = north2;
-	}
- 
-
-
-
-      else if(man_op==1) 
-	{
- 
-	  east1 = G_col_to_easting((double) c1, &cellhd1);
-	  north1 = G_row_to_northing((double) r1, &cellhd1);
-      
- 
-	  sPoints.e1[sPoints.count-1] = east1;
-	  sPoints.n1[sPoints.count-1] = north1;
-  
-	 
-	 
-	  R_standard_color (BLUE);
-	  display_one_point(VIEW_MAP1,east1,north1);
-	 
-	  
-	  manual_op1();
-	  
-	 	  
-	  east2 = e_man2;
-	  north2 = n_man2;
-
-  	  
-	  r2 = G_northing_to_row(north2,&cellhd2);
-	  c2 = G_easting_to_col(east2,&cellhd2);
-
-
-	  sPoints.e2[sPoints.count-1] = east2;
-	  sPoints.n2[sPoints.count-1] = north2;
-	  
-	  display_points_in_view_diff_color (VIEW_MAP2, 1,
-					     sPoints.e2, sPoints.n2,
-					     sPoints.status, sPoints.count);
-      
-	  
-      
-	  R_flush();   
-
-      
-	}
-      
-
-	  
-  
-      /* Fill the POINTS file*/	  
-      sPoints.status[sPoints.count-1] = 1;
-      sPoints.count += 1;
-      sPoints.e1=(double *)G_realloc(sPoints.e1,sPoints.count*sizeof(double));
-      sPoints.n1=(double *)G_realloc(sPoints.n1,sPoints.count*sizeof(double));
-      sPoints.e2=(double *)G_realloc(sPoints.e2,sPoints.count*sizeof(double));
-      sPoints.n2=(double *)G_realloc(sPoints.n2,sPoints.count*sizeof(double));
-      sPoints.status=(int *)G_realloc(sPoints.status,sPoints.count*sizeof(int));
-  
-
-    }
-  
-
-  else if( (n==1) && (man_m_s_op==1) )
-    {
-      manual_m_s_op1();
-
-      east1 = e_man1;
-      north1 = n_man1;
-
-      r1 = G_northing_to_row(north1,&cellhd1);
-      c1 = G_easting_to_col(east1,&cellhd1);
-      
-      
-      sPoints.e1[sPoints.count-1] = east1;
-      sPoints.n1[sPoints.count-1] = north1;
-      
-
-      R_standard_color (BLUE);
-      display_one_point(VIEW_MAP1,east1,north1);
-	 
-      
- 
-      manual_op1();
-	  
-	 	  
-      east2 = e_man2;
-      north2 = n_man2;
-
-  	  
-      r2 = G_northing_to_row(north2,&cellhd2);
-      c2 = G_easting_to_col(east2,&cellhd2);
-
-
-      sPoints.e2[sPoints.count-1] = east2;
-      sPoints.n2[sPoints.count-1] = north2;
-      
-
-      display_points_in_view_diff_color (VIEW_MAP2, 1,
-					 sPoints.e2, sPoints.n2,
-					 sPoints.status, sPoints.count);
-      
-	  
-
-      R_flush();   
-	  
-  
-      /* Fill the POINTS file*/	  
-      sPoints.status[sPoints.count-1] = 1;
-      sPoints.count += 1;
-      sPoints.e1=(double *)G_realloc(sPoints.e1,sPoints.count*sizeof(double));
-      sPoints.n1=(double *)G_realloc(sPoints.n1,sPoints.count*sizeof(double));
-      sPoints.e2=(double *)G_realloc(sPoints.e2,sPoints.count*sizeof(double));
-      sPoints.n2=(double *)G_realloc(sPoints.n2,sPoints.count*sizeof(double));
-      sPoints.status=(int *)G_realloc(sPoints.status,sPoints.count*sizeof(int));
-  
-
-
-    }   
-
-
-
-
-  else
-    {
-
-    
-      /*Begin computation*/
-      search_border =  search_window_dim / 2;
-  
-      for(r = search_border; r < dim_win_r - search_border; r += search_jump)
-	{
-	  for(c = search_border; c < dim_win_c - search_border; c += search_jump)
-	    {
-  
-	      /*  Reinizialize fft vectors */
-	  
-	      for(i=0;i<squared_search_window_dim;i++)
-		{
-		  fft_first[0][i]=0.0;
-		  fft_first[1][i]=0.0;
-		  fft_second[0][i]=0.0;
-		  fft_second[1][i]=0.0;
-		  fft_prod_con[0][i]=0.0;
-		  fft_prod_con[1][i]=0.0;
-		}
-	  
-	  
-	      /* Coordinates of the "initial" point */
-	  
-	      east1 = G_col_to_easting((double) c, &cellhd1);
-	      north1 = G_row_to_northing((double) r, &cellhd1);
-	
-	      /* Real window in the first image */
-	  
-	      Extract_portion_of_double_matrix(r,c,search_border,search_border,
-					       mat1_R,search_window);
-	  
-	      mean = 0.0;
-	      for(i=0;i<search_window_dim;i++)
-		{
-		  for(j=0;j<search_window_dim;j++)
-		    {
-		      mean +=  search_window[i][j];
-		    }
-		}
-	      mean /= squared_search_window_dim;
-	
-	      for(i=0;i<search_window_dim;i++)
-		{
-		  for(j=0;j<search_window_dim;j++)
-		    {
-		      fft_first[0][i*search_window_dim+j]=search_window[i][j]-mean;
-		    }
-		}
-	  
-	  
-	      /* Real window in the second image */
-	      	
-	      if((r-search_border+2*search_border>=nrows2)||(c-search_border+2*search_border>=ncols2))
-		{
-		  if (sPoints.count<=1)
-		    {	   
-		      Menu_msg("DEFINE A NEW REGION.");
-		      sleep(3);
-		      pause;
-		    }
-		  return 0;
-		}
-
-	      Extract_portion_of_double_matrix(r,c,search_border,search_border,
-					       mat2_R,search_window);
-	      mean = 0.0;
-	      for(i=0;i<search_window_dim;i++)
-		{
-		  for(j=0;j<search_window_dim;j++)
-		    {
-		      mean +=  search_window[i][j];
-		    }
-		}
-	      mean /= squared_search_window_dim;
-	      for(i=0;i<search_window_dim;i++)
-		{
-		  for(j=0;j<search_window_dim;j++)
-		    {
-		      fft_second[0][i*search_window_dim+j]=search_window[i][j]-mean;
-		    }
-		}
-
-
-
-
-	      /* fft of the 2 (complex) windows */
-	      fft(-1,fft_first,squared_search_window_dim,search_window_dim,
-		  search_window_dim);
-	      fft(-1,fft_second,squared_search_window_dim,search_window_dim,
-		  search_window_dim);
-
-
-
-
-	  
-	      /* product of the first fft for the coniugate of the second one */
-	      for(i=0;i<squared_search_window_dim;i+=1)
-		{
-		  fft_prod_con[0][i] = (fft_first[0][i] * fft_second[0][i]) +
-		    (fft_first[1][i] * fft_second[1][i]);
-		  fft_prod_con[1][i] = (fft_first[1][i] * fft_second[0][i]) -
-		    (fft_first[0][i] * fft_second[1][i]);
-		}
-	  
-	  
-
-
-	  
-	      /* fft^{-1} of the product <==> cross-correlation at differnet lag
-		 between the two orig. (complex) windows */
-	      fft(1,fft_prod_con,squared_search_window_dim,search_window_dim,
-		  search_window_dim);
-
-
-
-
-	  
-	      /* Search the lag coresponding to the maximum correlation */
-	      cc = 0.0;
-	 
-	      for(i=0;i<squared_search_window_dim;i++)
-		{
-		  if(fft_prod_con[0][i] > cc)
-		    {
-		      cc = fft_prod_con[0][i];
-		      tmp_r=i/search_window_dim;
-		      tmp_c=i%search_window_dim;
-		
-		    }
-		} 
-	
-	      /* Get coordinates of "ending" point  */
-	      if((tmp_r <= search_window_dim/2) && (tmp_c <= search_window_dim/2))
-		{
-	   
-		  east2 = G_col_to_easting((double) c  - tmp_c,&cellhd2);
-		  north2 = G_row_to_northing((double) r  - tmp_r,&cellhd2);
-	   
-		}
-	      if((tmp_r <= search_window_dim/2) && (tmp_c >= search_window_dim/2))
-		{
-	      
-		  east2 = G_col_to_easting((double) c  - (tmp_c-search_window_dim-1),&cellhd2);
-		  north2 = G_row_to_northing((double) r -  tmp_r,&cellhd2);
-	   
-		}
-	      if((tmp_r >= search_window_dim/2) && (tmp_c <= search_window_dim/2))
-		{
-	     
-		  east2 = G_col_to_easting((double) c  - tmp_c,&cellhd2);
-		  north2 = G_row_to_northing((double) r  - (tmp_r-search_window_dim-1),&cellhd2);
-	    
-		}
-	      if((tmp_r >= search_window_dim/2) && (tmp_c >= search_window_dim/2))
-		{
-	    
-		  east2 = G_col_to_easting((double) c  - (tmp_c-search_window_dim-1),&cellhd2);
-		  north2 = G_row_to_northing((double) r  - (tmp_r-search_window_dim-1),&cellhd2);
-	    
-		}
-      
-    
-
-	      /* Fill the POINTS file*/
-	      sPoints.e1[sPoints.count-1] = east1;
-	      sPoints.n1[sPoints.count-1] = north1;
-	      sPoints.e2[sPoints.count-1] = east2;
-	      sPoints.n2[sPoints.count-1] = north2;
-	
-	      sPoints.status[sPoints.count-1] = 1;
-	      sPoints.count += 1;
-	      sPoints.e1=(double *)G_realloc(sPoints.e1,sPoints.count*sizeof(double));
-	      sPoints.n1=(double *)G_realloc(sPoints.n1,sPoints.count*sizeof(double));
-	      sPoints.e2=(double *)G_realloc(sPoints.e2,sPoints.count*sizeof(double));
-	      sPoints.n2=(double *)G_realloc(sPoints.n2,sPoints.count*sizeof(double));
-	      sPoints.status=(int *)G_realloc(sPoints.status,sPoints.count*sizeof(int));
-	    }
-	  G_percent (r,dim_win_r, 1);   
-	}
-
-
-
-    }
-
-}
-
-void Extract_portion_of_double_matrix(int r,int c,int br,int bc,DCELL **mat,DCELL **wind)
-     /*
-       extract a squared portion of a matrix mat
-       given a the indeces of the center [r,c] 
-       and the semilength of the borders [br,bc]
-       Output to array wind
-     */
-{
-  int i,j;
-  for(i=0;(i <2*br);i++)
-    for(j = 0;(j <2*bc);j++)
-      {
-	wind[i][j] = mat[r - br + i][c - bc +j];    
-      }
-}
-
-
-
-
-
-
-
-static int less_GCPs()
-{
-
-  n_points = 1;
-
-  return 0;
-}
-
-
-
-
-
-static int manual_op()
-{
-  man_op = 1;
-
-  n=1;
-
-  Extract_matrix();
-
-  return 0;
-}
-
-
-
-
-static int manual_op1()
-{
-
-  static int use = 1;
-
-
-  static Objects objects[] =
-    {
-      INFO(" Mark on the second img the Overlap-Point  ",&use),
-      OTHER(mark_op, &use),
-      {0}
-    };
-  
-  Input_pointer (objects);
-  Menu_msg ("");
-  
-  
-  
-  return 0;
-
-
-}
-
-
-
-
-
-static int mark_op(int x,int y,int button)
-{
-
-  static int use = 1;
-  
-  if (button != 1)
-    return where (x,y);
-    
-  if (VIEW_MAP2->cell.configured && In_view (VIEW_MAP2, x, y))
-    mark_point_op(VIEW_MAP2, x, y);
-   
-  else
-    return 0;
-  
-  return -1 ; /* return but don't quit */
-}
-
-
-
-
-static int mark_point_op (View *view,int x, int y)
-{
-
-  /* convert x,y to east,north at center of cell */
-  c2= view_to_col (view, x);
-  e_man2 = col_to_easting (&view->cell.head, c2, 0.5);
-  r2= view_to_row (view, y);
-  n_man2 = row_to_northing (&view->cell.head, r2, 0.5);
-
-
-
-  return 0 ; 
-
-
-}
-
-
-
-static int manual_m_s_op()
-{
-  man_m_s_op = 1;
-
-  n=1;
-
-  Extract_matrix();
-
-
-  return 0;
-}
-
-
-static int manual_m_s_op1()
-{
-
-  static int use = 1;
-
-
-  static Objects objects[] =
-    {
-      INFO(" Mark on the first img the Overlap-Point  ",&use),
-      OTHER(mark_m_s_op, &use),
-      {0}
-    };
-  
-  Input_pointer (objects);
-  Menu_msg ("");
-  
-
-  return 0;
-}
-
-
-static int mark_m_s_op(int x,int y,int button)
-{
-
-  static int use = 1;
-  
-  if (button != 1)
-    return where (x,y);
-    
-  if (VIEW_MAP1->cell.configured && In_view (VIEW_MAP1, x, y))
-    mark_point_m_s_op(VIEW_MAP1, x, y);
-   
-  else
-    return 0;
-  
-  return -1 ; /* return but don't quit */
-}
-
-
-
-
-static int mark_point_m_s_op (View *view,int x, int y)
-{
-
-  /* convert x,y to east,north at center of cell */
-  c1= view_to_col (view, x);
-  e_man1 = col_to_easting (&view->cell.head, c1, 0.5);
-  r1= view_to_row (view, y);
-  n_man1 = row_to_northing (&view->cell.head, r1, 0.5);
-
-
-
-  return 0 ; 
-
-
-}
-
-
-
-
-static int central()
-{
-  n=1;
-  pos_point = 0;
-  man_op=0; 
-
-  Extract_matrix();
-
-  return 0;
-
-}
-
-
-static int shift1()
-{
-  double nn_1,ee_1,ss_1,ww_1,rr1_1,rr1_2,cc1_1,cc1_2,nnrows1,nncols1;
-  int shift1;
-
-  nn_1=VIEW_MAP1->cell.head.north;
-  ee_1=VIEW_MAP1->cell.head.east;
-  ss_1=VIEW_MAP1->cell.head.south;
-  ww_1=VIEW_MAP1->cell.head.west; 
- 
-  rr1_1=ss_1/VIEW_MAP1->cell.ns_res;
-  rr1_2=nn_1/VIEW_MAP1->cell.ns_res;
-  cc1_1=ww_1/VIEW_MAP1->cell.ew_res; 
-  cc1_2=ee_1/VIEW_MAP1->cell.ew_res;
-  
-  nnrows1=rr1_2-rr1_1;
-  nncols1=cc1_2-cc1_1;
-
-
-
-  shift1 = (((nnrows1 + nncols1)/2)/100)*5;
-
-  switch (pos_point)
-    {
-      
-    case 1: dist = shift1;
-      dist_r = -shift1;
-      dist_c = 0;               
-      break;
-    case 2: dist = shift1;
-      dist_r = shift1;
-      dist_c = 0;
-      break;
-    case 3: dist = shift1;
-      dist_c = shift1;
-      dist_r = 0;            
-      break;
-    case 4: dist = shift1;
-      dist_c = -shift1;
-      dist_r = 0;               
-      break;
-    }
-  
-
-
-  Extract_matrix();
-
-  return 0;
-}
-
-
-
-
-static int shift2()
-{
-
-  double nn_1,ee_1,ss_1,ww_1,rr1_1,rr1_2,cc1_1,cc1_2,nnrows1,nncols1;
-  int shift2;
-
-  nn_1=VIEW_MAP1->cell.head.north;
-  ee_1=VIEW_MAP1->cell.head.east;
-  ss_1=VIEW_MAP1->cell.head.south;
-  ww_1=VIEW_MAP1->cell.head.west; 
- 
-  rr1_1=ss_1/VIEW_MAP1->cell.ns_res;
-  rr1_2=nn_1/VIEW_MAP1->cell.ns_res;
-  cc1_1=ww_1/VIEW_MAP1->cell.ew_res; 
-  cc1_2=ee_1/VIEW_MAP1->cell.ew_res;
-  
-  nnrows1=rr1_2-rr1_1;
-  nncols1=cc1_2-cc1_1;
-
-
-
-  shift2 = (((nnrows1 + nncols1)/2)/100)*10;
-
-
-
-  switch (pos_point)
-    {
-	
-    case 1: dist = shift2;
-      dist_r = -shift2;
-      dist_c = 0;               
-      break;
-    case 2: dist = shift2;
-      dist_r = shift2;
-      dist_c = 0;
-      break;
-    case 3: dist = shift2;
-      dist_c = shift2;
-      dist_r = 0;            
-      break;
-    case 4: dist = shift2;
-      dist_c = -shift2;
-      dist_r = 0;               
-      break;
-    }
-  
-
-  
-  Extract_matrix();
-
-  return 0;
-}
-
-
-
-
-
-static int top()
-{
-  static int use = 1;
-  
-  n=1;
-  pos_point = 1;
-  man_op=0; 
-
-  static Objects objects2[]=
-    {   
-      MENU(" MAIN MENU  ",main_menu,&use),  
-      MENU(" <--  ",cancel,&use), 
-      INFO("  Shift O.P. (% of map) -> ",&use),
-      MENU(" 5%  ",shift1,&use),
-      MENU(" 10%  ",shift2,&use),   
-      {0}
-    };
-
-  Input_pointer (objects2);
-
-
-  return 0;
-
-}
-
-
-
-
-
-static int bottom()
-{
-  static int use = 1;
-
-  n=1;
-  pos_point = 2;
-  man_op=0; 
-
-  static Objects objects3[]=
-    {  
-      MENU(" MAIN MENU  ",main_menu,&use),  
-      MENU(" <--  ",cancel,&use), 
-      INFO("  Shift O.P. (% of map) -> ",&use),
-      MENU(" 5%  ",shift1,&use),
-      MENU(" 10%  ",shift2,&use),   
-      {0}
-    };
-
-  Input_pointer (objects3);
-
-
-  return 0;
-
-}
-
-
-
-static int left()
-{
-  static int use = 1;
- 
-  n=1;
-  pos_point = 3;
-  man_op=0; 
-
-  static Objects objects4[]=
-    {        
-      MENU(" MAIN MENU  ",main_menu,&use),  
-      MENU(" <--  ",cancel,&use),
-      INFO("  Shift O.P. (% of map) -> ",&use),
-      MENU(" 5%  ",shift1,&use),
-      MENU(" 10%  ",shift2,&use),   
-      {0}
-    };
-
-  Input_pointer (objects4);
-
-
-  return 0;
-
-}
-
-
-
-static int right()
-{
-  static int use = 1;
-
-  n=1;
-  pos_point = 4;
-  man_op=0; 
-
-  static Objects objects5[]=
-    {     
-      MENU(" MAIN MENU  ",main_menu,&use),  
-      MENU(" <--  ",cancel,&use), 
-      INFO("  Shift O.P. (% of map) -> ",&use),
-      MENU(" 5%  ",shift1,&use),
-      MENU(" 10%  ",shift2,&use),   
-      {0}
-    };
-
-  Input_pointer (objects5);
-
-
-  return 0;
-
-}
-
-
-
-
-
-
-static int try_again()
-{
-
-  static int use = 1;
-
-  G_get_cellhd (name1_initial, mapset_initial, &cellhd1);
-  G_adjust_window_to_box (&cellhd1, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows, VIEW_MAP1->ncols);
-  Configure_view (VIEW_MAP1, name1_initial, mapset_initial, cellhd1.ns_res, cellhd1.ew_res);
-  drawcell(VIEW_MAP1);
-  display_points(1);
-  R_flush();
-  Curses_clear_window (PROMPT_WINDOW);
-
-  Erase_view (VIEW_MAP1_ZOOM);  
-
-  
-  G_get_cellhd (name2_initial, mapset_initial, &cellhd2);
-  G_adjust_window_to_box (&cellhd2, &VIEW_MAP2->cell.head, VIEW_MAP2->nrows, VIEW_MAP2->ncols);
-  Configure_view (VIEW_MAP2, name2_initial, mapset_initial, cellhd2.ns_res, cellhd2.ew_res);
-  drawcell(VIEW_MAP2);
-  display_points(1);
-  R_flush();
-  Curses_clear_window (PROMPT_WINDOW);
-
-  Erase_view (VIEW_MAP2_ZOOM);  
-
-
-  static Objects objects3[]=
-    {   
-
-
-      MENU(" MAIN MENU  ",cancel,&use),   
-      INFO(" O.P. -> ",&use),
-      MENU(" Central  ",central,&use),
-      MENU(" Top  ",top,&use),
-      MENU(" Bottom  ",bottom,&use),   
-      MENU(" Left  ",left,&use),   
-      MENU(" Right  ",right,&use),
-      INFO("  ",&use),
-      MENU(" LESS GCPs  ",less_GCPs,&use),
-      MENU(" Mark Slave-O.P.  ",manual_op,&use),
-      MENU(" Mark M&S-O.P.  ",manual_m_s_op,&use),
-      {0}
-    };
-
-      
-  Input_pointer (objects3);
-  
-  return 0;
-}
-
-
-
-
-
-
-
-
-
-static int store_points()
-{
-
-  int i;
-
-
-  sPoints.count -= 1;
-  if(sPoints.count > 0)
-    {
-      
-      sprintf(file_name,"%s/%s/%s/group/%s/POINTS",group_GISDBASE,
-	      group_LOCATION_NAME,group_MAPSET,group_name);
-    
-      fp = fopen(file_name,"w");                                
-      fprintf (fp,"# %7s %15s %15s %15s %9s status\n","",
-	       "provaimage","","target","");
-      fprintf (fp,"# %15s %15s %15s %15s   (1=ok)\n",
-	       "east","north","east","north");
-      fprintf (fp,"#\n");
-	    
-      for (i = 1; i < sPoints.count; i++)            /* i=1 because the sPoints[0] is the O.P. */
-	if ( sPoints.status[i] != -1)
-	  fprintf (fp, "  %15f %15f %15f %15f %4d\n",
-		   sPoints.e1[i],  sPoints.n1[i],  sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i]);
-
-
-      fclose (fp);
-    }
-  
-
-    
-  /* Load new control points */
-     
-  for (i = 1; i < sPoints.count; i++)   
-    if ( sPoints.status[i] != -1)
-      I_new_control_point (&group.points,sPoints.e1[i],  sPoints.n1[i],  
-			 sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i] );
-  
-
-
-  m=1;  /* To directly return to the main menu */
-  
-
-  return 0;
-
-}
-
-
-
-
-
-static int main_menu()
-{
-  m=1;
-
-  return 0;
-}
-
-
-static int 
-cancel (void)
-{
-  return -1; 
-}
-
-
-
-
-
-
-static int change_rms_th()
-{
-  static int use = 1;
-
-  static Objects objects[]=
-    {
-      MENU(" MAIN MENU  ",main_menu,&use),   
-      MENU(" <--  ",cancel,&use), 
-      INFO("      ",&use),
-      MENU(" 1  ",th_1,&use), 
-      MENU(" 2  ",th_2,&use), 
-      MENU(" 3  ",th_3,&use), 
-      MENU(" 4  ",th_4,&use), 
-      MENU(" 5  ",th_5,&use), 
-      MENU(" OTHER  ",other_th,&use), 
-      /*
-	OPTION(" 1  ",   2, &after_OPTION_out),
-	OPTION(" 2  ",   2, &temp_th_2),
-	OPTION(" 3  ",   2, &temp_th_3),
-	OPTION(" 4  ",   2, &temp_th_4),
-	OPTION(" 5  ",   2, &temp_th_5),*/
-      {0}
-    };
-
- 
-  
-  Input_pointer (objects);
-  
-    
-  return 0;
-}
-
-
-
-static int after_th()
-{  
-  static int use = 1;
-
-  
-  static Objects objects3[]=
-    {  
-      MENU(" MAIN MENU  ",main_menu,&use),   
-      MENU(" STORE POINTS IN FILE  ",store_points,&use),
-      MENU(" TRY AGAIN  ",try_again,&use),   
-      INFO("                ",&use),
-      MENU(" rms-th  ",change_rms_th,&use),
-      MENU(" Auto-Exclusion GCPs  ",auto_exclusion,&use),
-      {0}
-    };
-
-      
-  Input_pointer (objects3);
-  
-
-
-  return 0;
-}
-
-
-
-
-
-
-static int th_1()
-{
-  th=1;
-
-  after_th();
-
-  return 0;
-}
-
-
-static int th_2()
-{
-  th=2;
-
-  after_th();
-
-  return 0;
-}
-
-
-static int th_3()
-{
-  th=3;
-
-  after_th();
-
-  return 0;
-}
-
-
-static int th_4()
-{
-  th=4;
-
-  after_th();
-
-  return 0;
-}
-
-static int th_5()
-{
-  th=5;
-
-  after_th();
-
-  return 0;
-}
-
- 
-
-static int other_th()
-{
-  char buf[100];
-  double tmp_th;
-  
-  G_clear_screen();
-
-  while(1)
-    {
-      Curses_prompt_gets ("Insert the rms-threshold desired: ", buf);
-      sscanf (buf, "%lf", &tmp_th); 
-      if(tmp_th!=0) break;
-      
-    }
-  
-  th = tmp_th;
-  
-  after_th();
-  
-  return 0;
-}
-
-
-
-
-
-int auto_exclusion(void)
-{
-  int k;
-  int i;
-  static int use = 1;
-
-  sPoints.count = sPoints.count -1;   
-
-  /* Load new control points */
-     
-  for (i = 1; i < sPoints.count; i++)   
-    if ( sPoints.status[i] != -1)
-      I_new_control_point (&group.points,sPoints.e1[i],  sPoints.n1[i],  
-			 sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i] );
-  
-
-
-
-  first_point = 0;
-
-  /* allocate predicted values */
-  xres = (double *) G_calloc (group.points.count, sizeof (double));
-  yres = (double *) G_calloc (group.points.count, sizeof (double));
-  gnd  = (double *) G_calloc (group.points.count, sizeof (double));
-  
- 
-  compute_transformation();
-
-
-  while(rms>=th)
-    { 
-      for(k=0; k < group.points.count; k++)
-	{
-	  
-	  if(group.equation_stat > 0 && group.points.status[k]==1)
-	    {
-	      
-	      if (k == xmax || k == ymax || k == gmax)
-		{
-		  group.points.status[k] = 0;		
-		}
-	    }
-	  compute_transformation();
-
-	}
-    }
-  display_points(1);
-
-  
-  
-  static Objects objects[]=
-    {
-      MENU(" MAIN MENU  ",main_menu,&use),   
-      MENU(" ANALYZE & STORE  ",pre_analyze,&use),
-      {0}
-    };
-  
-  Input_pointer (objects);
-
-
-  free (xres); free (yres); free (gnd);
-
-  return 0;
-}
-
-
-
-static int pre_analyze()
-{    
-  
-  analyze();
- 
-  m=1;
-  
-  return 0;
-}
-
-
-
-
-
-
-static int compute_transformation (void)
-{
-  int n, count;
-  double d,d1,d2,sum;
-  double e1, e2, n1, n2;
-  double t1, t2, u1, u2;
-  double xval, yval, gval;
-  double tval, uval, lgval;
-
-  xmax = ymax = gmax = 0;
-  xval = yval = gval = 0.0;
-
-  Compute_equation();     
-
-  /* compute the row,col error plus ground error
-   * keep track of largest and second largest error
-   */
-  sum = 0.0;
-  rms = 0.0;
-  count = 0;
-  for (n = 0; n < group.points.count && group.equation_stat>0; n++)
-    {
-      if (group.points.status[n] !=1) continue;
-      count++;
-      georef (group.points.e2[n], group.points.n2[n], &e1, &n1, group.E21, group.N21);
-      georef (group.points.e1[n], group.points.n1[n], &e2, &n2, group.E12, group.N12);
-      
-      if((d = xres[n] = e1-group.points.e1[n]) < 0)
-	d = -d;
-      if (d > xval)
-	{
-	  xmax = n;
-	  xval = d;
-	}
-
-      if ((d = yres[n] = n1-group.points.n1[n]) < 0)
-	d = -d;
-      if (d > yval)
-	{
-	  ymax = n;
-	  yval = d;
-	}
-
-      /* compute ground error (ie along diagonal) */
-      d1 = e2 - group.points.e2[n];
-      d2 = n2 - group.points.n2[n];
-      d = d1*d1 + d2*d2;
-      sum += d;                 /* add it to rms sum, before taking sqrt */
-      d = sqrt(d);
-      gnd[n] = d;
-      if (d > gval)             /* is this one the max? */
-	{
-	  gmax = n;
-	  gval = d;
-	}
-
-    }
-  /* compute overall rms error */
-  if (count)
-    rms = sqrt (sum/count);
-
-    
-  return 0;
-}
-
-
-
-
-
-

Copied: grass-addons/imagery/i.points.auto/find_points.c (from rev 30335, grass-addons/i.points.auto/find_points.c)
===================================================================
--- grass-addons/imagery/i.points.auto/find_points.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/find_points.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,2212 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+#include <math.h>
+
+#include <grass/config.h>
+#ifdef HAVE_FFTW_H
+#include <fftw.h>
+#endif
+#ifdef HAVE_DFFTW_H
+#include <dfftw.h>
+#endif
+
+#include <grass/raster.h>
+#include <grass/imagery.h>
+#include <grass/gmath.h>
+#include "globals.h"
+#include "local_proto.h"
+
+#ifdef NULL_VALUE
+#undef NULL_VALUE
+#endif
+#define NULL_VALUE -1
+
+
+double *fft_first[2];
+double *fft_second[2];
+double *fft_prod_con[2];
+ 
+int n=1;   /*If (n==1) then the algorithm is searching the Overlapping-Area, if (n==2), it is searching the GCP's*/ 
+int pos_point;
+int dist;                                             
+int ncols1, ncols2, nrows1, nrows2;
+int nrows1_img, ncols1_img, nrows2_img, ncols2_img;
+int r1, c1;                                          /* Central (or around the central) point of the first img    */
+int r2, c2;                                          /* Corresponding point in the second img                     */
+int r2c, c2c;                                        /* Central point of the first img                            */
+
+char *group_name;
+char *group_MAPSET;
+char *group_LOCATION_NAME;
+char *group_GISDBASE;
+int q;
+FILE *fp;
+FILE *fp_old; 
+/*int i;*/
+char file_name[500];
+
+char name1[100];
+char name2[100];
+char mapset[100];
+
+int dist_r, dist_c;  
+
+int z;
+
+
+int n_points=0;           /* When "LESS_GCP's" is activated, then (n_points==0) */
+int man_op=0;             /* Variable for the option "Manual_OP". It's 1 if the option is activated */
+double e_man2, n_man2;     /* Coordinates for the manual_OP */
+int man_m_s_op=0; 
+double e_man1, n_man1;
+
+View *m1, *m2; 
+
+
+
+
+int min(int a, int b)
+{
+ 
+  if(a <= b)
+    {
+      return a;
+    }
+  else
+    {
+      return b;
+    } 
+}
+
+static int main_menu();
+static int cancel();
+static int shift1();
+static int shift2();
+
+static int less_GCPs();
+static int manual_op();
+static int manual_op1();
+static int mark_op(int x,int y,int button);
+static int mark_point_op (View *view,int x, int y);
+
+static int central();
+static int top();
+static int bottom();
+static int left();
+static int right();
+
+static int manual_m_s_op();
+static int manual_m_s_op1();
+static int mark_m_s_op(int x,int y,int button);
+static int mark_point_m_s_op (View *view,int x, int y);
+
+/* variables for function "TRY_AGAIN" */
+char name1_initial[100];
+char name2_initial[100];
+char mapset_initial[100];
+static int try_again();
+static int store_points();
+
+
+
+
+/* Variables and functions for the Auto-Exclusion */
+static int curp, first_point;
+static double *xres, *yres, *gnd, *tres, *ures, *lgnd;
+static int offsetx, offsety;
+static int xmax, ymax, gmax;
+static int tmax, umax, lgmax;
+static double rms,l_rms;
+static double th=2.5;                 /*Default threshold of the rms for the Auto-Exclusion.*/
+char file_name1[500];
+static int auto_exclusion();
+static int change_rms_th();
+static int compute_transformation(void);
+static int th_1();
+static int th_2();
+static int th_3();
+static int th_4();
+static int th_5();
+static int other_th();
+static int pre_analyze();
+
+
+
+
+
+
+
+
+
+int automated_search()
+{
+
+  static int use = 1;
+
+  ask_original_map ("raster", group_list, name1,mapset, -1);      
+  ask_original_map ("raster", group_list, name2,mapset, 1);       
+
+  
+
+  static Objects objects1[]=
+    {   
+      MENU(" MAIN MENU  ",cancel,&use),   
+      INFO(" O.P. -> ",&use),
+      MENU(" Central  ",central,&use),
+      MENU(" Top  ",top,&use),
+      MENU(" Bottom  ",bottom,&use),   
+      MENU(" Left  ",left,&use),   
+      MENU(" Right  ",right,&use),
+      INFO("  ",&use),
+      MENU(" LESS GCPs  ",less_GCPs,&use),
+      MENU(" Mark Slave-O.P.  ",manual_op,&use),
+      MENU(" Mark M&S-O.P.  ",manual_m_s_op,&use),
+      {0}
+    };
+
+      
+  Input_pointer (objects1);
+
+  m=0;
+
+  return 0;
+
+}
+
+
+
+
+
+
+void Extract_matrix()
+{
+  struct GModule *module;
+  struct Control_Points *cp1;
+  char buf[256];
+  char *s;
+  int rows, cols;
+  
+  char *first_map_R_mapset;
+  char *first_map_R_name;
+  int first_map_R_fd;
+  char *second_map_R_mapset;
+  char *second_map_R_name;
+  int second_map_R_fd;
+  
+  int K;
+  
+  int correlation_window_dim;
+  int search_window_dim;
+  int search_window_dim1;
+  int search_window_dim2;
+
+
+  int squared_search_window_dim;
+  int search_jump;
+  
+  int left1, top1, left2, top2;   
+  int repeat;  
+
+  int n_1, e_1, n_2, e_2, s_1, s_2, w_1, w_2;
+  int r1_1, r1_2, r2_1, r2_2;
+  int c1_1, c1_2, c2_1, c2_2;
+
+  int i;
+
+  int h1_r;
+  int h1_c;
+  int h2_r;
+  int h2_c;
+
+  
+  DCELL *rowbuf1_R;
+  DCELL *tf1_R;
+  DCELL *rowbuf2_R;
+  DCELL *tf2_R;
+  double **search_window;
+  double **mat1,**mat2;    
+  int r,c;
+  int search_border;
+  int p1;
+  int dim_win_c, dim_win_r;
+  char first_sites[500];
+  char second_sites[500];
+  char file_name_old[500];
+  FILE *first_fp;
+  FILE *second_fp;  
+
+  int xp1, yp1, xs1, ys1;
+  int xp2, yp2, xs2, ys2;
+  int nimg;
+   
+  static int use = 1;
+
+
+ 
+
+  if(n==1)
+    {
+      m1=VIEW_MAP1;    
+      m2=VIEW_MAP2;
+    }
+
+  else    
+    {
+               
+      if( (r2 >= r1) && (c2 >= c1 ) )                         
+	{
+	  xp1 = (c1 - (min(c1,c2)))+1;           
+	  xp2 = (c2 - (c1-xp1));        
+	  xs2 = (c2 + min((ncols1-c1),(ncols2-c2)))-1;                                     
+	  xs1 = (c1 + (xs2 - c2)); 
+	  yp1 = (r1 - (min(r1,r2)))+1;    
+	  yp2 = (r2 - (r1 - yp1));
+	  ys2 = (r2 + min((nrows1-r1),(nrows2-r2)))-1;
+	  ys1 = (r1 + (ys2 - r2));
+	}     
+      else if( (r2 <= r1) && (c2 <= c1) )                        
+	{
+	  xp2 = (c2 - (min(c2,c1)))+1;
+	  xp1 = (c1 - (c2 - xp2));
+	  xs1 = (c1 + min((ncols1-c1),(ncols2-c2)))-1;
+	  xs2 = (c2 + (xs1 - c1));
+	  yp2 = (r2 - min(r2,r1))+1; 
+	  yp1 = (r1 - (r2 - yp2));
+	  ys1 = (r1 + min((nrows1-r1),(nrows2-r2)))-1;
+	  ys2 = (r2 + (ys1 - r1));
+	}
+      else if( (r2 >= r1) && (c2 <= c1) )    
+	{    
+	  xp2 = (c2 - min(c2,c1))+1;
+	  xp1 = (c1 - (c2 - xp2));
+	  xs1 = (c1 + min((ncols1-c1),(ncols2-c2)))-1;
+	  xs2 = (c2 + (xs1 - c1));
+	  yp1 = (r1 - min(r1,r2))+1;
+	  yp2 = (r2 - (r1 - yp1));
+	  ys2 = (r2 + min((nrows1-r1),(nrows2-r2)))-1;
+	  ys1 = (r1 + (ys2 - r2));
+	}
+      else if( (r2 <= r1) && (c2 >= c1) )                          
+	{ 
+	  xp1 = (c1 - min(c1,c2))+1;
+	  xp2 = (c2 - (c1 - xp1));
+	  xs2 = (c2 + min((ncols2-c2),(ncols1-c1)))-1;
+	  xs1 = (c1 + (xs2 - c2));
+	  yp2 = (r2 - min(r1,r2))+1;
+	  yp1 = (r1 - (r2 - yp2));
+	  ys1 = (r1 + min((nrows1-r1),(nrows2-r2)))-1;
+	  ys2 = (r2 + (ys1 - r1));
+	}
+
+
+      /* overlap_area(): function that extracts a window from the angle-points 
+       * top_left (xp1, yp1) and down_right (xs1, ys1)  
+       */
+      nimg = 1;
+      overlap_area(xp1, yp1, xs1, ys1, nimg, ncols1, nrows1);      
+  
+ 
+      nimg = 2;
+      overlap_area(xp2, yp2, xs2, ys2, nimg, ncols2, nrows2);
+  
+  
+      m1=VIEW_MAP1_ZOOM;   
+      m2=VIEW_MAP2_ZOOM;   
+  
+    } 
+
+
+
+  first_map_R_name=m1->cell.name;
+  second_map_R_name=m2->cell.name;
+ 
+ 
+
+
+
+  /* rows & cols of the view in m1 */
+  n_1=m1->cell.head.north;
+  e_1=m1->cell.head.east;
+  s_1=m1->cell.head.south;
+  w_1=m1->cell.head.west; 
+  left1 = m1->cell.left;
+  top1 = m1->cell.top;
+  
+  r1_1=s_1/m1->cell.ns_res;
+  r1_2=n_1/m1->cell.ns_res;
+  c1_1=w_1/m1->cell.ew_res; 
+  c1_2=e_1/m1->cell.ew_res;
+  
+  nrows1=r1_2-r1_1;
+  ncols1=c1_2-c1_1;
+
+
+  /* rows & cols of the view in m2 */
+  n_2=m2->cell.head.north;
+  e_2=m2->cell.head.east; 
+  s_2=m2->cell.head.south;
+  w_2=m2->cell.head.west;    
+  left2 = m2->cell.left;
+  top2 = m2->cell.top; 
+  
+  r2_1=s_2/m2->cell.ns_res;
+  r2_2=n_2/m2->cell.ns_res;
+  c2_1=w_2/m2->cell.ew_res; 
+  c2_2=e_2/m2->cell.ew_res;
+
+  nrows2=r2_2-r2_1; 
+  ncols2=c2_2-c2_1;
+  
+  
+  if(n==1)
+    {
+      nrows1_img = nrows1;
+      ncols1_img = ncols1;
+      nrows2_img = nrows2;
+      ncols2_img = ncols2;
+    }
+  
+ 
+  /* Initialize the GIS calls */
+  module = G_define_module();
+  module->description = "Fine registration of two stereo images";
+  
+  /* Load environmental vars*/
+  group_LOCATION_NAME=buf;
+  group_LOCATION_NAME=G_getenv("LOCATION_NAME");
+  group_GISDBASE=buf;
+  group_GISDBASE=G_getenv("GISDBASE");
+  group_MAPSET=buf;
+  group_MAPSET=G_getenv("MAPSET");
+  
+   
+  if(n==1)
+    {  
+
+      strcpy (name1_initial,first_map_R_name);
+      strcpy (name2_initial,second_map_R_name);
+      strcpy (mapset_initial,group_MAPSET);
+     
+    }
+
+
+  /* Correlation parameters */
+  if(n==1)
+    {
+
+      if(ncols1 <= nrows1)
+	{  
+	  search_window_dim1 = ncols1;                      
+	} 
+      else
+	{
+	  search_window_dim1 = nrows1;                      
+	}
+
+      if(ncols2 <= nrows2)
+	{
+	  search_window_dim2 = ncols2;                     
+	}
+      else
+	{
+	  search_window_dim2 = nrows2;                       
+	}
+
+
+
+      if(search_window_dim1 <= search_window_dim2)
+	{
+	  search_window_dim = search_window_dim1;
+	} 
+      else
+	{  
+	  search_window_dim = search_window_dim2;
+	} 
+    }
+
+
+  else if(n==2)
+    { 
+      correlation_window_dim=((ncols1/10+nrows1/10)/4);
+
+
+      
+      if(n_points==1)
+	{
+
+	  K=((ncols1/4+nrows1/4)/3);    
+	  search_window_dim = (correlation_window_dim + K);
+	  n_points = 0;
+
+	}
+      else
+	{
+
+	  K=((ncols1/4+nrows1/4)/8);  
+	  search_window_dim = G_math_max_pow2(correlation_window_dim + K);
+
+	}
+
+
+     
+      search_jump=search_window_dim / 2; 
+    }
+  
+
+
+
+  group_name=group.name;
+  squared_search_window_dim=search_window_dim*search_window_dim;
+  
+  
+  if(n==1)
+    {
+      Menu_msg ("Loading first image...");
+    } 
+
+  else
+    {
+      Menu_msg ("Loading first overlapping_image..."); 
+    }
+
+  /* Open first real map*/
+  
+  if((first_map_R_mapset = G_find_cell2(first_map_R_name, "")) == NULL)
+    {
+      sprintf(buf,"Raster map [%s] not available",first_map_R_name);
+      G_fatal_error(buf);
+    }
+  
+  
+  if((first_map_R_fd = G_open_cell_old(first_map_R_name, 
+				       first_map_R_mapset)) < 0)
+    {
+      sprintf(buf,"Error opening raster map [%s]", first_map_R_name);
+      G_fatal_error(buf);
+    }
+
+  /* Set region to first map definition region  < m1 > */ 
+  G_get_cellhd (first_map_R_name, first_map_R_mapset, &cellhd1);
+  G_set_window(&cellhd1);
+  h1_r=cellhd1.rows;
+  h1_c=cellhd1.cols;
+    
+
+   
+  /* Memory allocation for the first overlapping_map */
+  
+  mat1 = (DCELL **) G_calloc(nrows1,sizeof(DCELL *));
+  for(r=0;r<nrows1;r++)
+    mat1[r] = (DCELL *) G_calloc(ncols1,sizeof(DCELL)); 
+  
+
+  /* Load first map*/
+  
+  rowbuf1_R = (DCELL *)G_calloc(h1_r * h1_c,sizeof(DCELL));
+  tf1_R=rowbuf1_R;
+  
+  for(r=h1_r-r1_2;r<h1_r-r1_1;r++)
+    {  
+      G_get_d_raster_row(first_map_R_fd, tf1_R, r);	
+      if (G_is_d_null_value (tf1_R)) 
+	*tf1_R = NULL_VALUE;	
+      c=0;
+      while(c<c1_1)
+	{	
+	  tf1_R++;
+	  c++;
+	}	
+      for(c = c1_1; c < c1_2; c++)
+	{
+	  mat1[-h1_r+r1_2+r][c-c1_1] = *tf1_R;
+	  tf1_R++;
+	}
+    }
+  G_close_cell(first_map_R_fd);
+  
+  
+  /* Open second map*/
+  if((second_map_R_mapset = G_find_cell2(second_map_R_name, "")) == NULL)
+    {
+      sprintf(buf,"Raster map [%s] not available",second_map_R_name);
+      G_fatal_error(buf);
+    }
+  
+  if((second_map_R_fd = G_open_cell_old(second_map_R_name, 
+					second_map_R_mapset)) < 0) 
+    {
+      sprintf(buf,"Error opening raster map [%s]", second_map_R_name);
+      G_fatal_error(buf);
+    } 
+    
+  /* Set region to second map definition region */
+  G_get_cellhd (second_map_R_name, second_map_R_mapset, &cellhd2);
+  G_set_window(&cellhd2);
+  h2_r=cellhd2.rows;
+  h2_c=cellhd2.cols;
+  
+  
+  /* Memory allocation for the second overlapping_map */
+  mat2 = (DCELL **) G_calloc(nrows2,sizeof(DCELL *));
+  for(r=0;r<nrows2;r++)
+    mat2[r] = (DCELL *) G_calloc(ncols2,sizeof(DCELL));
+
+  /* Load second real map */
+  if(n==1)
+    {
+      Menu_msg ("Loading second image...");
+    }
+
+  else
+    {
+      Menu_msg ("Loading second overlapping_image...");
+    }
+  
+  rowbuf2_R=(DCELL *)G_calloc(h2_r * h2_c,sizeof(DCELL));
+  tf2_R=rowbuf2_R;
+  for(r=h2_r-r2_2;r<h2_r-r2_1;r++)
+    
+    {				
+      G_get_d_raster_row(second_map_R_fd, tf2_R, r);	
+      c=0;
+      while(c<c2_1)
+	{	
+	  tf2_R++;
+	  c++;
+	}	
+      for(c = c2_1; c < c2_2; c++)
+	{
+	  if (G_is_d_null_value (tf2_R)) 
+	    *tf2_R = NULL_VALUE;
+	  mat2[-h2_r+r2_2+r][c-c2_1] = *tf2_R;
+	  tf2_R++;
+	}
+    }
+  
+  G_close_cell(second_map_R_fd);
+  
+
+  if( (n==1) && (man_op==0) )
+    {
+      Menu_msg ("Searching in the second image the corresponding point of the central point of the first one...");
+    }
+  else if(n==2)
+    {
+      Menu_msg ("Searching points...");
+    }
+ 
+  /* Memory allocation */
+  search_window = (DCELL **) G_calloc(search_window_dim,
+				      sizeof(DCELL *));
+  for(r=0;r<search_window_dim;r++)
+    search_window[r] = (DCELL *) G_calloc(search_window_dim,
+					  sizeof(DCELL));
+    
+  fft_first[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+  fft_first[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+  fft_second[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+  fft_second[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+  fft_prod_con[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+  fft_prod_con[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+    
+
+  /* Inizialize control points */
+  if(n==1)  
+    {
+      sPoints.count=1;
+      sPoints.e1=(double *) G_calloc(sPoints.count,sizeof(double));
+      sPoints.n1=(double *) G_calloc(sPoints.count,sizeof(double));
+      sPoints.e2=(double *) G_calloc(sPoints.count,sizeof(double));
+      sPoints.n2=(double *) G_calloc(sPoints.count,sizeof(double));
+      sPoints.status=(int *) G_calloc(sPoints.count,sizeof(int));
+    }
+
+  /* Sites file */
+  sprintf(first_sites,"%s/%s/%s/site_lists/%s_%s",G__getenv("GISDBASE"),
+	  G__getenv("LOCATION_NAME"),G__getenv("MAPSET"),
+	  group_name,first_map_R_name);
+  sprintf(second_sites,"%s/%s/%s/site_lists/%s_%s",G__getenv("GISDBASE"),
+	  G__getenv("LOCATION_NAME"),G__getenv("MAPSET"),
+	  group_name,second_map_R_name);
+    
+   
+  /* Set cellhd1 to overlapping_map_1 */  
+  cellhd1.rows=nrows1;
+  cellhd1.cols=ncols1;
+  cellhd1.north=r1_2*m1->cell.ns_res;
+  cellhd1.south=r1_1*m1->cell.ns_res;
+  cellhd1.east=c1_2*m1->cell.ew_res;
+  cellhd1.west=c1_1*m1->cell.ew_res;
+ 
+  /* Set cellhd2 to overlapping_map_2 */  
+  cellhd2.rows=nrows2;
+  cellhd2.cols=ncols2;
+  cellhd2.north=r2_2*m2->cell.ns_res;
+  cellhd2.south=r1_1*m2->cell.ns_res;
+  cellhd2.east=c2_2*m2->cell.ew_res;
+  cellhd2.west=c2_1*m2->cell.ew_res;
+  
+  /* Set windows to cellhd1 */
+  G_set_window(&cellhd1);
+ 
+  
+    
+  /******************************************/
+  /* function --> Search_correlation_points */ 
+  /******************************************/     
+  Search_correlation_points(mat1, mat2,
+			    search_window_dim, 
+			    squared_search_window_dim,
+			    search_jump,group_name, nrows1, ncols1,
+			    search_window, r1_2, c1_1, r2_2, c2_1,
+			    h1_r, h2_r, h1_c, h2_c, nrows2, ncols2, n );
+    
+  
+ 
+  
+  sprintf(file_name,"%s/%s/%s/group/%s/TARGET",group_GISDBASE,
+	  group_LOCATION_NAME, group_MAPSET,group_name);
+  fp = fopen(file_name,"w");
+  fprintf(fp,"%s\n%s\n",group_LOCATION_NAME,group_MAPSET);
+  fclose(fp);
+    
+
+  if(n==2)
+    {
+      
+      G_get_cellhd (name1, mapset, &cellhd1);
+      G_adjust_window_to_box (&cellhd1, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows, VIEW_MAP1->ncols);
+      Configure_view (VIEW_MAP1, name1, mapset, cellhd1.ns_res, cellhd1.ew_res);
+      drawcell(VIEW_MAP1);
+      display_points(1);
+      R_flush();
+      Curses_clear_window (PROMPT_WINDOW);
+      
+
+      G_get_cellhd (name2, mapset, &cellhd2);
+      G_adjust_window_to_box (&cellhd2, &VIEW_MAP2->cell.head, VIEW_MAP2->nrows, VIEW_MAP2->ncols);
+      Configure_view (VIEW_MAP2, name2, mapset, cellhd2.ns_res, cellhd2.ew_res);
+      drawcell(VIEW_MAP2);
+      display_points(1);
+      R_flush();
+      Curses_clear_window (PROMPT_WINDOW);
+      
+      nimg = 1;
+      overlap_area(xp1, yp1, xs1, ys1, nimg, ncols1_img, nrows1_img);
+     
+      nimg = 2;
+      overlap_area(xp2, yp2, xs2, ys2, nimg, ncols2_img, nrows2_img);
+
+     
+    }
+
+
+    
+  select_current_env ();
+
+  
+  display_points_in_view_diff_color (VIEW_MAP1, 1,
+				     sPoints.e1, sPoints.n1,
+				     sPoints.status, sPoints.count);
+  
+  
+  display_points_in_view_diff_color (VIEW_MAP2, 1,
+				     sPoints.e2, sPoints.n2,
+				     sPoints.status, sPoints.count);
+
+  
+  
+  
+  display_points_in_view_diff_color (VIEW_MAP1_ZOOM, 1,
+				     sPoints.e1, sPoints.n1,
+				     sPoints.status, sPoints.count);
+  
+  
+  
+  display_points_in_view_diff_color (VIEW_MAP2_ZOOM, 1,
+				     sPoints.e2, sPoints.n2,
+				     sPoints.status, sPoints.count);  
+  
+  R_flush();   
+
+
+ 
+  if(n==2)
+    {
+        
+      static Objects objects[]=
+	{
+	  MENU(" MAIN MENU  ",main_menu,&use),   
+	  MENU(" STORE POINTS IN FILE  ",store_points,&use),
+	  MENU(" TRY AGAIN  ",try_again,&use),   
+	  INFO("                ",&use),
+	  MENU(" rms-th  ",change_rms_th,&use),
+	  MENU(" Auto-Exclusion GCPs  ",auto_exclusion,&use),
+	  {0}
+	};
+
+      Input_pointer (objects);
+
+
+      return 0;  
+    }
+
+
+
+
+
+  /* Free memory */
+
+  free( rowbuf1_R);
+  free( rowbuf2_R);
+
+
+  for(r=0;r<nrows1;r++)
+    free( mat1[r]);
+  free(mat1);
+    
+  for(r=0;r<nrows2;r++)
+    free( mat2[r]);
+  free(mat2);
+    
+  for(r=0;r<search_window_dim;r++)
+    free(search_window[r]);
+  free(search_window);
+    
+  for(r=0;r<2;r++) 
+    {
+      free(fft_first[r]);
+      free(fft_second[r]);
+      free(fft_prod_con[r]);
+    }
+    
+
+  if(n==2)         
+    {
+      sPoints.e1[0];
+      sPoints.n1[0];
+      sPoints.e2[0];
+      sPoints.n2[0];
+      sPoints.status[0];
+      
+      free(sPoints.e1);
+      free(sPoints.n1);
+      free(sPoints.n2);
+      free(sPoints.e2);
+      free(sPoints.status);
+    }
+
+
+  
+  
+  if(n==1)
+    {
+      n=2;
+      Extract_matrix();
+    }
+  else
+    {
+      man_op = 0;
+      man_m_s_op = 0;
+
+      return 0;
+    }
+
+}
+
+
+
+
+
+
+void Search_correlation_points(DCELL **mat1_R, DCELL **mat2_R,
+			       int search_window_dim, 
+			       int squared_search_window_dim, 
+			       int search_jump, char *group_name,
+			       int dim_win_r, int dim_win_c,
+			       DCELL **search_window, int r1_2,int c1_1,
+			       int r2_2,int c2_1, int h1_r, int h2_r, 
+			       int  h1_c, int h2_c, int nrows2, int ncols2,   int n  )
+{
+  int r,c;
+  int i, j, search_border;
+  char *group_MAPSET;
+  char *group_LOCATION_NAME;
+  char *group_GISDBASE;
+  char first_sites[500];
+  char second_sites[500];
+  char file_name[500];    
+  FILE *fp;
+  FILE *first_fp;
+  FILE *second_fp;  
+  double cc;
+  double north1,east1,north2,east2;
+  int tmp_r,tmp_c;
+  double mean;
+  int index;
+  
+ 
+  
+
+  if( (n==1) && (man_m_s_op==0) )   
+    {
+	
+      r1 = (dim_win_r/2);
+      c1 = (dim_win_c/2);
+      
+      
+      if(man_op==0) 
+	{	    
+                
+	  switch (pos_point)
+	    {
+	    case 0: dist = 0;
+	      dist_r = 0;
+	      dist_c = 0;
+	      break;
+	    case 1: r1 = ((dim_win_r/2)-dist);	          
+	      break;
+	    case 2: r1 = ((dim_win_r/2)+dist);	       
+	      break;
+	    case 3: c1 = ((dim_win_c/2)-dist);                    
+	      break;
+	    case 4: c1 = ((dim_win_c/2)+dist);	                     
+	      break;
+	    }
+	  
+	  
+      
+	  r2c = (nrows2 / 2);
+	  c2c = (ncols2 / 2);
+	  
+	  
+	  if(pos_point!=0)
+	    {
+	      search_window_dim = (search_window_dim - (2*dist));
+	      squared_search_window_dim = (search_window_dim * search_window_dim);
+	      search_jump = (search_window_dim / 2);
+	    }
+      
+      
+      
+	  search_border =  search_window_dim / 2;
+	  
+	  
+	  
+	  /*  Reinizialize fft vectors */
+	  
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fft_first[0][i]=0.0;
+	      fft_first[1][i]=0.0;
+	      fft_second[0][i]=0.0;
+	      fft_second[1][i]=0.0;
+	      fft_prod_con[0][i]=0.0;
+	      fft_prod_con[1][i]=0.0;
+	    }
+      
+      
+	  /* Coordinates of the "initial" point */
+      
+	  east1 = G_col_to_easting((double) c1, &cellhd1);
+	  north1 = G_row_to_northing((double) r1, &cellhd1);
+      
+	 
+      
+
+	  
+	
+	  /* Real window in the first image */
+	  
+	  Extract_portion_of_double_matrix(r1,c1,search_border,search_border,
+					   mat1_R,search_window);
+      
+
+
+	  mean = 0.0;
+	  for(i=0;i<search_window_dim;i++)
+	    {
+	      for(j=0;j<search_window_dim;j++)
+		{
+		  mean +=  search_window[i][j];
+		}
+	    }
+	  mean /= squared_search_window_dim;
+      
+	  for(i=0;i<search_window_dim;i++)
+	    {
+	      for(j=0;j<search_window_dim;j++)
+		{
+		  fft_first[0][i*search_window_dim+j]=search_window[i][j]-mean;
+		}
+	    }
+
+
+	  
+
+	  Extract_portion_of_double_matrix(r2c,c2c,search_border,search_border,
+					   mat2_R,search_window);
+
+
+	  mean = 0.0;
+	  for(i=0;i<search_window_dim;i++)
+	    {
+	      for(j=0;j<search_window_dim;j++)
+		{
+		  mean +=  search_window[i][j];
+		}
+	    }
+	  mean /= squared_search_window_dim;
+	  for(i=0;i<search_window_dim;i++)
+	    {
+	      for(j=0;j<search_window_dim;j++)
+		{
+		  fft_second[0][i*search_window_dim+j]=search_window[i][j]-mean;
+		}
+	    }
+
+
+
+
+	  /* fft of the 2 (complex) windows */
+	  fft(-1,fft_first,squared_search_window_dim,search_window_dim,
+	      search_window_dim);
+	  fft(-1,fft_second,squared_search_window_dim,search_window_dim,
+	      search_window_dim);
+
+
+
+	  
+	  /* product of the first fft for the coniugate of the second one */
+	  for(i=0;i<squared_search_window_dim;i+=1)
+	    {
+	      fft_prod_con[0][i] = (fft_first[0][i] * fft_second[0][i]) +
+		(fft_first[1][i] * fft_second[1][i]);
+	      fft_prod_con[1][i] = (fft_first[1][i] * fft_second[0][i]) -
+		(fft_first[0][i] * fft_second[1][i]);
+	    }
+	  
+
+
+
+	  /* fft^{-1} of the product <==> cross-correlation at differnet lag
+	     between the two orig. (complex) windows */
+	  fft(1,fft_prod_con,squared_search_window_dim,search_window_dim,
+	      search_window_dim);
+
+
+
+
+	  /* Search the lag coresponding to the maximum correlation */
+	  cc = 0.0;
+	 
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      if(fft_prod_con[0][i] > cc)
+		{
+		  cc = fft_prod_con[0][i];
+		  tmp_r=i/search_window_dim;
+		  tmp_c=i%search_window_dim;
+		
+		}
+	    } 
+
+
+	
+	 
+	  /* Get coordinates of "ending" point  */
+	  if((tmp_r <= search_window_dim/2) && (tmp_c <= search_window_dim/2))
+	    {
+	   
+	      east2 = G_col_to_easting((double) c1  - tmp_c,&cellhd2) + dist_c;
+	      north2 = G_row_to_northing((double) r1  - tmp_r,&cellhd2) + dist_r;
+	   
+	    }
+	  if((tmp_r <= search_window_dim/2) && (tmp_c >= search_window_dim/2))
+	    {
+	      
+	      east2 = G_col_to_easting((double) c1  - (tmp_c-search_window_dim-1),&cellhd2) + dist_c;
+	      north2 = G_row_to_northing((double) r1 -  tmp_r,&cellhd2) + dist_r;
+	   
+	    }
+	  if((tmp_r >= search_window_dim/2) && (tmp_c <= search_window_dim/2))
+	    {
+	     
+	      east2 = G_col_to_easting((double) c1  - tmp_c,&cellhd2) + dist_c;
+	      north2 = G_row_to_northing((double) r1 - (tmp_r-search_window_dim-1),&cellhd2) + dist_r;
+	    
+	    }
+	  if((tmp_r >= search_window_dim/2) && (tmp_c >= search_window_dim/2))
+	    {
+	    
+	      east2 = G_col_to_easting((double) c1  - (tmp_c-search_window_dim-1),&cellhd2) + dist_c;
+	      north2 = G_row_to_northing((double) r1  - (tmp_r-search_window_dim-1),&cellhd2) + dist_r;
+	    
+	    }
+
+
+	  	  
+	  r2 = G_northing_to_row(north2,&cellhd2);
+	  c2 = G_easting_to_col(east2,&cellhd2);
+
+	  sPoints.e1[sPoints.count-1] = east1;
+	  sPoints.n1[sPoints.count-1] = north1;
+	  sPoints.e2[sPoints.count-1] = east2;
+	  sPoints.n2[sPoints.count-1] = north2;
+	}
+ 
+
+
+
+      else if(man_op==1) 
+	{
+ 
+	  east1 = G_col_to_easting((double) c1, &cellhd1);
+	  north1 = G_row_to_northing((double) r1, &cellhd1);
+      
+ 
+	  sPoints.e1[sPoints.count-1] = east1;
+	  sPoints.n1[sPoints.count-1] = north1;
+  
+	 
+	 
+	  R_standard_color (BLUE);
+	  display_one_point(VIEW_MAP1,east1,north1);
+	 
+	  
+	  manual_op1();
+	  
+	 	  
+	  east2 = e_man2;
+	  north2 = n_man2;
+
+  	  
+	  r2 = G_northing_to_row(north2,&cellhd2);
+	  c2 = G_easting_to_col(east2,&cellhd2);
+
+
+	  sPoints.e2[sPoints.count-1] = east2;
+	  sPoints.n2[sPoints.count-1] = north2;
+	  
+	  display_points_in_view_diff_color (VIEW_MAP2, 1,
+					     sPoints.e2, sPoints.n2,
+					     sPoints.status, sPoints.count);
+      
+	  
+      
+	  R_flush();   
+
+      
+	}
+      
+
+	  
+  
+      /* Fill the POINTS file*/	  
+      sPoints.status[sPoints.count-1] = 1;
+      sPoints.count += 1;
+      sPoints.e1=(double *)G_realloc(sPoints.e1,sPoints.count*sizeof(double));
+      sPoints.n1=(double *)G_realloc(sPoints.n1,sPoints.count*sizeof(double));
+      sPoints.e2=(double *)G_realloc(sPoints.e2,sPoints.count*sizeof(double));
+      sPoints.n2=(double *)G_realloc(sPoints.n2,sPoints.count*sizeof(double));
+      sPoints.status=(int *)G_realloc(sPoints.status,sPoints.count*sizeof(int));
+  
+
+    }
+  
+
+  else if( (n==1) && (man_m_s_op==1) )
+    {
+      manual_m_s_op1();
+
+      east1 = e_man1;
+      north1 = n_man1;
+
+      r1 = G_northing_to_row(north1,&cellhd1);
+      c1 = G_easting_to_col(east1,&cellhd1);
+      
+      
+      sPoints.e1[sPoints.count-1] = east1;
+      sPoints.n1[sPoints.count-1] = north1;
+      
+
+      R_standard_color (BLUE);
+      display_one_point(VIEW_MAP1,east1,north1);
+	 
+      
+ 
+      manual_op1();
+	  
+	 	  
+      east2 = e_man2;
+      north2 = n_man2;
+
+  	  
+      r2 = G_northing_to_row(north2,&cellhd2);
+      c2 = G_easting_to_col(east2,&cellhd2);
+
+
+      sPoints.e2[sPoints.count-1] = east2;
+      sPoints.n2[sPoints.count-1] = north2;
+      
+
+      display_points_in_view_diff_color (VIEW_MAP2, 1,
+					 sPoints.e2, sPoints.n2,
+					 sPoints.status, sPoints.count);
+      
+	  
+
+      R_flush();   
+	  
+  
+      /* Fill the POINTS file*/	  
+      sPoints.status[sPoints.count-1] = 1;
+      sPoints.count += 1;
+      sPoints.e1=(double *)G_realloc(sPoints.e1,sPoints.count*sizeof(double));
+      sPoints.n1=(double *)G_realloc(sPoints.n1,sPoints.count*sizeof(double));
+      sPoints.e2=(double *)G_realloc(sPoints.e2,sPoints.count*sizeof(double));
+      sPoints.n2=(double *)G_realloc(sPoints.n2,sPoints.count*sizeof(double));
+      sPoints.status=(int *)G_realloc(sPoints.status,sPoints.count*sizeof(int));
+  
+
+
+    }   
+
+
+
+
+  else
+    {
+
+    
+      /*Begin computation*/
+      search_border =  search_window_dim / 2;
+  
+      for(r = search_border; r < dim_win_r - search_border; r += search_jump)
+	{
+	  for(c = search_border; c < dim_win_c - search_border; c += search_jump)
+	    {
+  
+	      /*  Reinizialize fft vectors */
+	  
+	      for(i=0;i<squared_search_window_dim;i++)
+		{
+		  fft_first[0][i]=0.0;
+		  fft_first[1][i]=0.0;
+		  fft_second[0][i]=0.0;
+		  fft_second[1][i]=0.0;
+		  fft_prod_con[0][i]=0.0;
+		  fft_prod_con[1][i]=0.0;
+		}
+	  
+	  
+	      /* Coordinates of the "initial" point */
+	  
+	      east1 = G_col_to_easting((double) c, &cellhd1);
+	      north1 = G_row_to_northing((double) r, &cellhd1);
+	
+	      /* Real window in the first image */
+	  
+	      Extract_portion_of_double_matrix(r,c,search_border,search_border,
+					       mat1_R,search_window);
+	  
+	      mean = 0.0;
+	      for(i=0;i<search_window_dim;i++)
+		{
+		  for(j=0;j<search_window_dim;j++)
+		    {
+		      mean +=  search_window[i][j];
+		    }
+		}
+	      mean /= squared_search_window_dim;
+	
+	      for(i=0;i<search_window_dim;i++)
+		{
+		  for(j=0;j<search_window_dim;j++)
+		    {
+		      fft_first[0][i*search_window_dim+j]=search_window[i][j]-mean;
+		    }
+		}
+	  
+	  
+	      /* Real window in the second image */
+	      	
+	      if((r-search_border+2*search_border>=nrows2)||(c-search_border+2*search_border>=ncols2))
+		{
+		  if (sPoints.count<=1)
+		    {	   
+		      Menu_msg("DEFINE A NEW REGION.");
+		      sleep(3);
+		      pause;
+		    }
+		  return 0;
+		}
+
+	      Extract_portion_of_double_matrix(r,c,search_border,search_border,
+					       mat2_R,search_window);
+	      mean = 0.0;
+	      for(i=0;i<search_window_dim;i++)
+		{
+		  for(j=0;j<search_window_dim;j++)
+		    {
+		      mean +=  search_window[i][j];
+		    }
+		}
+	      mean /= squared_search_window_dim;
+	      for(i=0;i<search_window_dim;i++)
+		{
+		  for(j=0;j<search_window_dim;j++)
+		    {
+		      fft_second[0][i*search_window_dim+j]=search_window[i][j]-mean;
+		    }
+		}
+
+
+
+
+	      /* fft of the 2 (complex) windows */
+	      fft(-1,fft_first,squared_search_window_dim,search_window_dim,
+		  search_window_dim);
+	      fft(-1,fft_second,squared_search_window_dim,search_window_dim,
+		  search_window_dim);
+
+
+
+
+	  
+	      /* product of the first fft for the coniugate of the second one */
+	      for(i=0;i<squared_search_window_dim;i+=1)
+		{
+		  fft_prod_con[0][i] = (fft_first[0][i] * fft_second[0][i]) +
+		    (fft_first[1][i] * fft_second[1][i]);
+		  fft_prod_con[1][i] = (fft_first[1][i] * fft_second[0][i]) -
+		    (fft_first[0][i] * fft_second[1][i]);
+		}
+	  
+	  
+
+
+	  
+	      /* fft^{-1} of the product <==> cross-correlation at differnet lag
+		 between the two orig. (complex) windows */
+	      fft(1,fft_prod_con,squared_search_window_dim,search_window_dim,
+		  search_window_dim);
+
+
+
+
+	  
+	      /* Search the lag coresponding to the maximum correlation */
+	      cc = 0.0;
+	 
+	      for(i=0;i<squared_search_window_dim;i++)
+		{
+		  if(fft_prod_con[0][i] > cc)
+		    {
+		      cc = fft_prod_con[0][i];
+		      tmp_r=i/search_window_dim;
+		      tmp_c=i%search_window_dim;
+		
+		    }
+		} 
+	
+	      /* Get coordinates of "ending" point  */
+	      if((tmp_r <= search_window_dim/2) && (tmp_c <= search_window_dim/2))
+		{
+	   
+		  east2 = G_col_to_easting((double) c  - tmp_c,&cellhd2);
+		  north2 = G_row_to_northing((double) r  - tmp_r,&cellhd2);
+	   
+		}
+	      if((tmp_r <= search_window_dim/2) && (tmp_c >= search_window_dim/2))
+		{
+	      
+		  east2 = G_col_to_easting((double) c  - (tmp_c-search_window_dim-1),&cellhd2);
+		  north2 = G_row_to_northing((double) r -  tmp_r,&cellhd2);
+	   
+		}
+	      if((tmp_r >= search_window_dim/2) && (tmp_c <= search_window_dim/2))
+		{
+	     
+		  east2 = G_col_to_easting((double) c  - tmp_c,&cellhd2);
+		  north2 = G_row_to_northing((double) r  - (tmp_r-search_window_dim-1),&cellhd2);
+	    
+		}
+	      if((tmp_r >= search_window_dim/2) && (tmp_c >= search_window_dim/2))
+		{
+	    
+		  east2 = G_col_to_easting((double) c  - (tmp_c-search_window_dim-1),&cellhd2);
+		  north2 = G_row_to_northing((double) r  - (tmp_r-search_window_dim-1),&cellhd2);
+	    
+		}
+      
+    
+
+	      /* Fill the POINTS file*/
+	      sPoints.e1[sPoints.count-1] = east1;
+	      sPoints.n1[sPoints.count-1] = north1;
+	      sPoints.e2[sPoints.count-1] = east2;
+	      sPoints.n2[sPoints.count-1] = north2;
+	
+	      sPoints.status[sPoints.count-1] = 1;
+	      sPoints.count += 1;
+	      sPoints.e1=(double *)G_realloc(sPoints.e1,sPoints.count*sizeof(double));
+	      sPoints.n1=(double *)G_realloc(sPoints.n1,sPoints.count*sizeof(double));
+	      sPoints.e2=(double *)G_realloc(sPoints.e2,sPoints.count*sizeof(double));
+	      sPoints.n2=(double *)G_realloc(sPoints.n2,sPoints.count*sizeof(double));
+	      sPoints.status=(int *)G_realloc(sPoints.status,sPoints.count*sizeof(int));
+	    }
+	  G_percent (r,dim_win_r, 1);   
+	}
+
+
+
+    }
+
+}
+
+void Extract_portion_of_double_matrix(int r,int c,int br,int bc,DCELL **mat,DCELL **wind)
+     /*
+       extract a squared portion of a matrix mat
+       given a the indeces of the center [r,c] 
+       and the semilength of the borders [br,bc]
+       Output to array wind
+     */
+{
+  int i,j;
+  for(i=0;(i <2*br);i++)
+    for(j = 0;(j <2*bc);j++)
+      {
+	wind[i][j] = mat[r - br + i][c - bc +j];    
+      }
+}
+
+
+
+
+
+
+
+static int less_GCPs()
+{
+
+  n_points = 1;
+
+  return 0;
+}
+
+
+
+
+
+static int manual_op()
+{
+  man_op = 1;
+
+  n=1;
+
+  Extract_matrix();
+
+  return 0;
+}
+
+
+
+
+static int manual_op1()
+{
+
+  static int use = 1;
+
+
+  static Objects objects[] =
+    {
+      INFO(" Mark on the second img the Overlap-Point  ",&use),
+      OTHER(mark_op, &use),
+      {0}
+    };
+  
+  Input_pointer (objects);
+  Menu_msg ("");
+  
+  
+  
+  return 0;
+
+
+}
+
+
+
+
+
+static int mark_op(int x,int y,int button)
+{
+
+  static int use = 1;
+  
+  if (button != 1)
+    return where (x,y);
+    
+  if (VIEW_MAP2->cell.configured && In_view (VIEW_MAP2, x, y))
+    mark_point_op(VIEW_MAP2, x, y);
+   
+  else
+    return 0;
+  
+  return -1 ; /* return but don't quit */
+}
+
+
+
+
+static int mark_point_op (View *view,int x, int y)
+{
+
+  /* convert x,y to east,north at center of cell */
+  c2= view_to_col (view, x);
+  e_man2 = col_to_easting (&view->cell.head, c2, 0.5);
+  r2= view_to_row (view, y);
+  n_man2 = row_to_northing (&view->cell.head, r2, 0.5);
+
+
+
+  return 0 ; 
+
+
+}
+
+
+
+static int manual_m_s_op()
+{
+  man_m_s_op = 1;
+
+  n=1;
+
+  Extract_matrix();
+
+
+  return 0;
+}
+
+
+static int manual_m_s_op1()
+{
+
+  static int use = 1;
+
+
+  static Objects objects[] =
+    {
+      INFO(" Mark on the first img the Overlap-Point  ",&use),
+      OTHER(mark_m_s_op, &use),
+      {0}
+    };
+  
+  Input_pointer (objects);
+  Menu_msg ("");
+  
+
+  return 0;
+}
+
+
+static int mark_m_s_op(int x,int y,int button)
+{
+
+  static int use = 1;
+  
+  if (button != 1)
+    return where (x,y);
+    
+  if (VIEW_MAP1->cell.configured && In_view (VIEW_MAP1, x, y))
+    mark_point_m_s_op(VIEW_MAP1, x, y);
+   
+  else
+    return 0;
+  
+  return -1 ; /* return but don't quit */
+}
+
+
+
+
+static int mark_point_m_s_op (View *view,int x, int y)
+{
+
+  /* convert x,y to east,north at center of cell */
+  c1= view_to_col (view, x);
+  e_man1 = col_to_easting (&view->cell.head, c1, 0.5);
+  r1= view_to_row (view, y);
+  n_man1 = row_to_northing (&view->cell.head, r1, 0.5);
+
+
+
+  return 0 ; 
+
+
+}
+
+
+
+
+static int central()
+{
+  n=1;
+  pos_point = 0;
+  man_op=0; 
+
+  Extract_matrix();
+
+  return 0;
+
+}
+
+
+static int shift1()
+{
+  double nn_1,ee_1,ss_1,ww_1,rr1_1,rr1_2,cc1_1,cc1_2,nnrows1,nncols1;
+  int shift1;
+
+  nn_1=VIEW_MAP1->cell.head.north;
+  ee_1=VIEW_MAP1->cell.head.east;
+  ss_1=VIEW_MAP1->cell.head.south;
+  ww_1=VIEW_MAP1->cell.head.west; 
+ 
+  rr1_1=ss_1/VIEW_MAP1->cell.ns_res;
+  rr1_2=nn_1/VIEW_MAP1->cell.ns_res;
+  cc1_1=ww_1/VIEW_MAP1->cell.ew_res; 
+  cc1_2=ee_1/VIEW_MAP1->cell.ew_res;
+  
+  nnrows1=rr1_2-rr1_1;
+  nncols1=cc1_2-cc1_1;
+
+
+
+  shift1 = (((nnrows1 + nncols1)/2)/100)*5;
+
+  switch (pos_point)
+    {
+      
+    case 1: dist = shift1;
+      dist_r = -shift1;
+      dist_c = 0;               
+      break;
+    case 2: dist = shift1;
+      dist_r = shift1;
+      dist_c = 0;
+      break;
+    case 3: dist = shift1;
+      dist_c = shift1;
+      dist_r = 0;            
+      break;
+    case 4: dist = shift1;
+      dist_c = -shift1;
+      dist_r = 0;               
+      break;
+    }
+  
+
+
+  Extract_matrix();
+
+  return 0;
+}
+
+
+
+
+static int shift2()
+{
+
+  double nn_1,ee_1,ss_1,ww_1,rr1_1,rr1_2,cc1_1,cc1_2,nnrows1,nncols1;
+  int shift2;
+
+  nn_1=VIEW_MAP1->cell.head.north;
+  ee_1=VIEW_MAP1->cell.head.east;
+  ss_1=VIEW_MAP1->cell.head.south;
+  ww_1=VIEW_MAP1->cell.head.west; 
+ 
+  rr1_1=ss_1/VIEW_MAP1->cell.ns_res;
+  rr1_2=nn_1/VIEW_MAP1->cell.ns_res;
+  cc1_1=ww_1/VIEW_MAP1->cell.ew_res; 
+  cc1_2=ee_1/VIEW_MAP1->cell.ew_res;
+  
+  nnrows1=rr1_2-rr1_1;
+  nncols1=cc1_2-cc1_1;
+
+
+
+  shift2 = (((nnrows1 + nncols1)/2)/100)*10;
+
+
+
+  switch (pos_point)
+    {
+	
+    case 1: dist = shift2;
+      dist_r = -shift2;
+      dist_c = 0;               
+      break;
+    case 2: dist = shift2;
+      dist_r = shift2;
+      dist_c = 0;
+      break;
+    case 3: dist = shift2;
+      dist_c = shift2;
+      dist_r = 0;            
+      break;
+    case 4: dist = shift2;
+      dist_c = -shift2;
+      dist_r = 0;               
+      break;
+    }
+  
+
+  
+  Extract_matrix();
+
+  return 0;
+}
+
+
+
+
+
+static int top()
+{
+  static int use = 1;
+  
+  n=1;
+  pos_point = 1;
+  man_op=0; 
+
+  static Objects objects2[]=
+    {   
+      MENU(" MAIN MENU  ",main_menu,&use),  
+      MENU(" <--  ",cancel,&use), 
+      INFO("  Shift O.P. (% of map) -> ",&use),
+      MENU(" 5%  ",shift1,&use),
+      MENU(" 10%  ",shift2,&use),   
+      {0}
+    };
+
+  Input_pointer (objects2);
+
+
+  return 0;
+
+}
+
+
+
+
+
+static int bottom()
+{
+  static int use = 1;
+
+  n=1;
+  pos_point = 2;
+  man_op=0; 
+
+  static Objects objects3[]=
+    {  
+      MENU(" MAIN MENU  ",main_menu,&use),  
+      MENU(" <--  ",cancel,&use), 
+      INFO("  Shift O.P. (% of map) -> ",&use),
+      MENU(" 5%  ",shift1,&use),
+      MENU(" 10%  ",shift2,&use),   
+      {0}
+    };
+
+  Input_pointer (objects3);
+
+
+  return 0;
+
+}
+
+
+
+static int left()
+{
+  static int use = 1;
+ 
+  n=1;
+  pos_point = 3;
+  man_op=0; 
+
+  static Objects objects4[]=
+    {        
+      MENU(" MAIN MENU  ",main_menu,&use),  
+      MENU(" <--  ",cancel,&use),
+      INFO("  Shift O.P. (% of map) -> ",&use),
+      MENU(" 5%  ",shift1,&use),
+      MENU(" 10%  ",shift2,&use),   
+      {0}
+    };
+
+  Input_pointer (objects4);
+
+
+  return 0;
+
+}
+
+
+
+static int right()
+{
+  static int use = 1;
+
+  n=1;
+  pos_point = 4;
+  man_op=0; 
+
+  static Objects objects5[]=
+    {     
+      MENU(" MAIN MENU  ",main_menu,&use),  
+      MENU(" <--  ",cancel,&use), 
+      INFO("  Shift O.P. (% of map) -> ",&use),
+      MENU(" 5%  ",shift1,&use),
+      MENU(" 10%  ",shift2,&use),   
+      {0}
+    };
+
+  Input_pointer (objects5);
+
+
+  return 0;
+
+}
+
+
+
+
+
+
+static int try_again()
+{
+
+  static int use = 1;
+
+  G_get_cellhd (name1_initial, mapset_initial, &cellhd1);
+  G_adjust_window_to_box (&cellhd1, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows, VIEW_MAP1->ncols);
+  Configure_view (VIEW_MAP1, name1_initial, mapset_initial, cellhd1.ns_res, cellhd1.ew_res);
+  drawcell(VIEW_MAP1);
+  display_points(1);
+  R_flush();
+  Curses_clear_window (PROMPT_WINDOW);
+
+  Erase_view (VIEW_MAP1_ZOOM);  
+
+  
+  G_get_cellhd (name2_initial, mapset_initial, &cellhd2);
+  G_adjust_window_to_box (&cellhd2, &VIEW_MAP2->cell.head, VIEW_MAP2->nrows, VIEW_MAP2->ncols);
+  Configure_view (VIEW_MAP2, name2_initial, mapset_initial, cellhd2.ns_res, cellhd2.ew_res);
+  drawcell(VIEW_MAP2);
+  display_points(1);
+  R_flush();
+  Curses_clear_window (PROMPT_WINDOW);
+
+  Erase_view (VIEW_MAP2_ZOOM);  
+
+
+  static Objects objects3[]=
+    {   
+
+
+      MENU(" MAIN MENU  ",cancel,&use),   
+      INFO(" O.P. -> ",&use),
+      MENU(" Central  ",central,&use),
+      MENU(" Top  ",top,&use),
+      MENU(" Bottom  ",bottom,&use),   
+      MENU(" Left  ",left,&use),   
+      MENU(" Right  ",right,&use),
+      INFO("  ",&use),
+      MENU(" LESS GCPs  ",less_GCPs,&use),
+      MENU(" Mark Slave-O.P.  ",manual_op,&use),
+      MENU(" Mark M&S-O.P.  ",manual_m_s_op,&use),
+      {0}
+    };
+
+      
+  Input_pointer (objects3);
+  
+  return 0;
+}
+
+
+
+
+
+
+
+
+
+static int store_points()
+{
+
+  int i;
+
+
+  sPoints.count -= 1;
+  if(sPoints.count > 0)
+    {
+      
+      sprintf(file_name,"%s/%s/%s/group/%s/POINTS",group_GISDBASE,
+	      group_LOCATION_NAME,group_MAPSET,group_name);
+    
+      fp = fopen(file_name,"w");                                
+      fprintf (fp,"# %7s %15s %15s %15s %9s status\n","",
+	       "provaimage","","target","");
+      fprintf (fp,"# %15s %15s %15s %15s   (1=ok)\n",
+	       "east","north","east","north");
+      fprintf (fp,"#\n");
+	    
+      for (i = 1; i < sPoints.count; i++)            /* i=1 because the sPoints[0] is the O.P. */
+	if ( sPoints.status[i] != -1)
+	  fprintf (fp, "  %15f %15f %15f %15f %4d\n",
+		   sPoints.e1[i],  sPoints.n1[i],  sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i]);
+
+
+      fclose (fp);
+    }
+  
+
+    
+  /* Load new control points */
+     
+  for (i = 1; i < sPoints.count; i++)   
+    if ( sPoints.status[i] != -1)
+      I_new_control_point (&group.points,sPoints.e1[i],  sPoints.n1[i],  
+			 sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i] );
+  
+
+
+  m=1;  /* To directly return to the main menu */
+  
+
+  return 0;
+
+}
+
+
+
+
+
+static int main_menu()
+{
+  m=1;
+
+  return 0;
+}
+
+
+static int 
+cancel (void)
+{
+  return -1; 
+}
+
+
+
+
+
+
+static int change_rms_th()
+{
+  static int use = 1;
+
+  static Objects objects[]=
+    {
+      MENU(" MAIN MENU  ",main_menu,&use),   
+      MENU(" <--  ",cancel,&use), 
+      INFO("      ",&use),
+      MENU(" 1  ",th_1,&use), 
+      MENU(" 2  ",th_2,&use), 
+      MENU(" 3  ",th_3,&use), 
+      MENU(" 4  ",th_4,&use), 
+      MENU(" 5  ",th_5,&use), 
+      MENU(" OTHER  ",other_th,&use), 
+      /*
+	OPTION(" 1  ",   2, &after_OPTION_out),
+	OPTION(" 2  ",   2, &temp_th_2),
+	OPTION(" 3  ",   2, &temp_th_3),
+	OPTION(" 4  ",   2, &temp_th_4),
+	OPTION(" 5  ",   2, &temp_th_5),*/
+      {0}
+    };
+
+ 
+  
+  Input_pointer (objects);
+  
+    
+  return 0;
+}
+
+
+
+static int after_th()
+{  
+  static int use = 1;
+
+  
+  static Objects objects3[]=
+    {  
+      MENU(" MAIN MENU  ",main_menu,&use),   
+      MENU(" STORE POINTS IN FILE  ",store_points,&use),
+      MENU(" TRY AGAIN  ",try_again,&use),   
+      INFO("                ",&use),
+      MENU(" rms-th  ",change_rms_th,&use),
+      MENU(" Auto-Exclusion GCPs  ",auto_exclusion,&use),
+      {0}
+    };
+
+      
+  Input_pointer (objects3);
+  
+
+
+  return 0;
+}
+
+
+
+
+
+
+static int th_1()
+{
+  th=1;
+
+  after_th();
+
+  return 0;
+}
+
+
+static int th_2()
+{
+  th=2;
+
+  after_th();
+
+  return 0;
+}
+
+
+static int th_3()
+{
+  th=3;
+
+  after_th();
+
+  return 0;
+}
+
+
+static int th_4()
+{
+  th=4;
+
+  after_th();
+
+  return 0;
+}
+
+static int th_5()
+{
+  th=5;
+
+  after_th();
+
+  return 0;
+}
+
+ 
+
+static int other_th()
+{
+  char buf[100];
+  double tmp_th;
+  
+  G_clear_screen();
+
+  while(1)
+    {
+      Curses_prompt_gets ("Insert the rms-threshold desired: ", buf);
+      sscanf (buf, "%lf", &tmp_th); 
+      if(tmp_th!=0) break;
+      
+    }
+  
+  th = tmp_th;
+  
+  after_th();
+  
+  return 0;
+}
+
+
+
+
+
+int auto_exclusion(void)
+{
+  int k;
+  int i;
+  static int use = 1;
+
+  sPoints.count = sPoints.count -1;   
+
+  /* Load new control points */
+     
+  for (i = 1; i < sPoints.count; i++)   
+    if ( sPoints.status[i] != -1)
+      I_new_control_point (&group.points,sPoints.e1[i],  sPoints.n1[i],  
+			 sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i] );
+  
+
+
+
+  first_point = 0;
+
+  /* allocate predicted values */
+  xres = (double *) G_calloc (group.points.count, sizeof (double));
+  yres = (double *) G_calloc (group.points.count, sizeof (double));
+  gnd  = (double *) G_calloc (group.points.count, sizeof (double));
+  
+ 
+  compute_transformation();
+
+
+  while(rms>=th)
+    { 
+      for(k=0; k < group.points.count; k++)
+	{
+	  
+	  if(group.equation_stat > 0 && group.points.status[k]==1)
+	    {
+	      
+	      if (k == xmax || k == ymax || k == gmax)
+		{
+		  group.points.status[k] = 0;		
+		}
+	    }
+	  compute_transformation();
+
+	}
+    }
+  display_points(1);
+
+  
+  
+  static Objects objects[]=
+    {
+      MENU(" MAIN MENU  ",main_menu,&use),   
+      MENU(" ANALYZE & STORE  ",pre_analyze,&use),
+      {0}
+    };
+  
+  Input_pointer (objects);
+
+
+  free (xres); free (yres); free (gnd);
+
+  return 0;
+}
+
+
+
+static int pre_analyze()
+{    
+  
+  analyze();
+ 
+  m=1;
+  
+  return 0;
+}
+
+
+
+
+
+
+static int compute_transformation (void)
+{
+  int n, count;
+  double d,d1,d2,sum;
+  double e1, e2, n1, n2;
+  double t1, t2, u1, u2;
+  double xval, yval, gval;
+  double tval, uval, lgval;
+
+  xmax = ymax = gmax = 0;
+  xval = yval = gval = 0.0;
+
+  Compute_equation();     
+
+  /* compute the row,col error plus ground error
+   * keep track of largest and second largest error
+   */
+  sum = 0.0;
+  rms = 0.0;
+  count = 0;
+  for (n = 0; n < group.points.count && group.equation_stat>0; n++)
+    {
+      if (group.points.status[n] !=1) continue;
+      count++;
+      georef (group.points.e2[n], group.points.n2[n], &e1, &n1, group.E21, group.N21);
+      georef (group.points.e1[n], group.points.n1[n], &e2, &n2, group.E12, group.N12);
+      
+      if((d = xres[n] = e1-group.points.e1[n]) < 0)
+	d = -d;
+      if (d > xval)
+	{
+	  xmax = n;
+	  xval = d;
+	}
+
+      if ((d = yres[n] = n1-group.points.n1[n]) < 0)
+	d = -d;
+      if (d > yval)
+	{
+	  ymax = n;
+	  yval = d;
+	}
+
+      /* compute ground error (ie along diagonal) */
+      d1 = e2 - group.points.e2[n];
+      d2 = n2 - group.points.n2[n];
+      d = d1*d1 + d2*d2;
+      sum += d;                 /* add it to rms sum, before taking sqrt */
+      d = sqrt(d);
+      gnd[n] = d;
+      if (d > gval)             /* is this one the max? */
+	{
+	  gmax = n;
+	  gval = d;
+	}
+
+    }
+  /* compute overall rms error */
+  if (count)
+    rms = sqrt (sum/count);
+
+    
+  return 0;
+}
+
+
+
+
+
+

Deleted: grass-addons/imagery/i.points.auto/find_points_semi.c
===================================================================
--- grass-addons/i.points.auto/find_points_semi.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/find_points_semi.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,778 +0,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <signal.h>
-
-#include <grass/config.h>
-#ifdef HAVE_FFTW_H
-#include <fftw.h>
-#endif
-#ifdef HAVE_DFFTW_H
-#include <dfftw.h>
-#endif
-
-#include <grass/raster.h>
-#include <grass/imagery.h>
-#include <grass/gmath.h>
-#include "globals.h"
-#include "local_proto.h"
-
-#ifdef NULL_VALUE
-#undef NULL_VALUE
-#endif
-#define NULL_VALUE -1
-
-
-#ifdef DEBUG
-#undef DEBUG
-#endif
-
-double *fft_first_s[2];
-double *fft_second_s[2];
-double *fft_prod_con_s[2];
- 
-View *ms1, *ms2; 
-
-void Extract_matrix_semi()
-{
-  struct GModule *module;
-  struct Control_Points *cp1;
-  char buf[256];
-  char *s;
-  int rows, cols;
-  char *first_map_R_mapset;
-  char *first_map_R_name;
-  int first_map_R_fd;
-  char *second_map_R_mapset;
-  char *second_map_R_name;
-  int second_map_R_fd;
-  
-  int K;
-  
-  int correlation_window_dim;
-  int search_window_dim;
-
-  int squared_search_window_dim;
-  int search_jump;
-  
-  int ncols1, ncols2, nrows1, nrows2;
-  int left1, top1, left2, top2;   
-  int repeat;  
-
-  int n_1, e_1, n_2, e_2, s_1, s_2, w_1, w_2;
-  int r1_1, r1_2, r2_1, r2_2;
-  int c1_1, c1_2, c2_1, c2_2;
-
-  int i;
-
-  int h1_r;
-  int h1_c;
-  int h2_r;
-  int h2_c;
-
-  
-  char *group_name;
-  char *group_MAPSET;
-  char *group_LOCATION_NAME;
-  char *group_GISDBASE;
-  DCELL *rowbuf1_R;
-  DCELL *tf1_R;
-  DCELL *rowbuf2_R;
-  DCELL *tf2_R;
-  double **search_window;
-  double **mat1,**mat2;    
-  int r,c;
-  int search_border;
-  int q;
-  int p1;
-  int dim_win_c, dim_win_r;
-  char first_sites[500];
-  char second_sites[500];
-  char file_name[500];
-  char file_name_old[500];
-  FILE *first_fp;
-  FILE *second_fp;  
-  FILE *fp;
-  FILE *fp_old; 
-  
- 
-  
-  /* Read VIEW_MAP1_ZOOM & VIEW_MAP2_ZOOM informations */
-  
-  
-  ms1=VIEW_MAP1_ZOOM;
-  ms2=VIEW_MAP2_ZOOM;
-  
-  first_map_R_name=ms1->cell.name;
-  second_map_R_name=ms2->cell.name;
- 
-  /* rows & cols of VIEW_MAP1_ZOOM */
-  n_1=ms1->cell.head.north;
-  e_1=ms1->cell.head.east;
-  s_1=ms1->cell.head.south;
-  w_1=ms1->cell.head.west; 
-  left1 = ms1->cell.left;
-  top1 = ms1->cell.top;
-  
-  r1_1=s_1/ms1->cell.ns_res;
-  r1_2=n_1/ms1->cell.ns_res;
-  c1_1=w_1/ms1->cell.ew_res; 
-  c1_2=e_1/ms1->cell.ew_res;
-  
-  nrows1=r1_2-r1_1;
-  ncols1=c1_2-c1_1;
-
-
-  /* rows & cols of VIEW_MAP2_ZOOM */
-  n_2=ms2->cell.head.north;
-  e_2=ms2->cell.head.east; 
-  s_2=ms2->cell.head.south;
-  w_2=ms2->cell.head.west;    
-  left2 = ms2->cell.left;
-  top2 = ms2->cell.top; 
-  
-  r2_1=s_2/ms2->cell.ns_res;
-  r2_2=n_2/ms2->cell.ns_res;
-  c2_1=w_2/ms2->cell.ew_res; 
-  c2_2=e_2/ms2->cell.ew_res;
-
-  nrows2=r2_2-r2_1; 
-  ncols2=c2_2-c2_1;
-  
-  
- 
-   /* Initialize the GIS calls */
-  module = G_define_module();
-  module->description = "Fine registration of two stereo images";
-  
-  /* Load environmental vars*/
-  group_LOCATION_NAME=buf;
-  group_LOCATION_NAME=G_getenv("LOCATION_NAME");
-  group_GISDBASE=buf;
-  group_GISDBASE=G_getenv("GISDBASE");
-  group_MAPSET=buf;
-  group_MAPSET=G_getenv("MAPSET");
-  
-  
-  /* Correlation parameters */
-  correlation_window_dim=((ncols1/10+nrows1/10)/2);
-  K=((ncols1/4+nrows1/4)/2);
-
-  search_window_dim = G_math_max_pow2(correlation_window_dim + K);
-  group_name=group.name;
-  squared_search_window_dim=search_window_dim*search_window_dim;
-  search_jump=search_window_dim / 2; 
-  
- 
-  
-  Menu_msg ("Loading first zoom_image..."); 
-  
-  /* Open first real map*/
-  if((first_map_R_mapset = G_find_cell2(first_map_R_name, "")) == NULL)
-    {
-      sprintf(buf,"Raster map [%s] not available",first_map_R_name);
-      G_fatal_error(buf);
-    }
-  
-  
-  if((first_map_R_fd = G_open_cell_old(first_map_R_name, 
-				       first_map_R_mapset)) < 0)
-    {
-      sprintf(buf,"Error opening raster map [%s]", first_map_R_name);
-      G_fatal_error(buf);
-    }
-
-  /* Set region to first map definition region  < ms1 > */ 
-  G_get_cellhd (first_map_R_name, first_map_R_mapset, &cellhd1);
-  G_set_window(&cellhd1);
-  h1_r=cellhd1.rows;
-  h1_c=cellhd1.cols;
-    
-
-   
-  /* Memory allocation for zoom_map_1 */
-  
-  mat1 = (DCELL **) G_calloc(nrows1,sizeof(DCELL *));
-  for(r=0;r<nrows1;r++)
-    mat1[r] = (DCELL *) G_calloc(ncols1,sizeof(DCELL)); 
-  
-
-  /* Load first  map*/
-  
-  rowbuf1_R = (DCELL *)G_calloc(h1_r * h1_c,sizeof(DCELL));
-  tf1_R=rowbuf1_R;
-  
-  for(r=h1_r-r1_2;r<h1_r-r1_1;r++)
-    {  
-      G_get_d_raster_row(first_map_R_fd, tf1_R, r);	
-      if (G_is_d_null_value (tf1_R)) 
-	*tf1_R = NULL_VALUE;	
-      c=0;
-      while(c<c1_1)
-	{	
-	  tf1_R++;
-	  c++;
-	}	
-      for(c = c1_1; c < c1_2; c++)
-	{
-	  mat1[-h1_r+r1_2+r][c-c1_1] = *tf1_R;
-	  tf1_R++;
-	}
-    }
-  G_close_cell(first_map_R_fd);
-  
-  
-  /* Open second  map*/
-  if((second_map_R_mapset = G_find_cell2(second_map_R_name, "")) == NULL)
-    {
-      sprintf(buf,"Raster map [%s] not available",second_map_R_name);
-      G_fatal_error(buf);
-    }
-  
-  if((second_map_R_fd = G_open_cell_old(second_map_R_name, 
-					second_map_R_mapset)) < 0) 
-    {
-      sprintf(buf,"Error opening raster map [%s]", second_map_R_name);
-      G_fatal_error(buf);
-    } 
-    
-  /* Set region to second map definition region */
-  G_get_cellhd (second_map_R_name, second_map_R_mapset, &cellhd2);
-  G_set_window(&cellhd2);
-  h2_r=cellhd2.rows;
-  h2_c=cellhd2.cols;
-  
-  
-  /* Memory allocation for zoom_map_2 */
-  mat2 = (DCELL **) G_calloc(nrows2,sizeof(DCELL *));
-  for(r=0;r<nrows2;r++)
-    mat2[r] = (DCELL *) G_calloc(ncols2,sizeof(DCELL));
-
-  /* Load second real map */
-  Menu_msg ("Loading second zoom_image...");
-  
-  rowbuf2_R=(DCELL *)G_calloc(h2_r * h2_c,sizeof(DCELL));
-  tf2_R=rowbuf2_R;
-  for(r=h2_r-r2_2;r<h2_r-r2_1;r++)
-    
-    {				
-      G_get_d_raster_row(second_map_R_fd, tf2_R, r);	
-      c=0;
-      while(c<c2_1)
-	{	
-	  tf2_R++;
-	  c++;
-	}	
-      for(c = c2_1; c < c2_2; c++)
-	{
-	  if (G_is_d_null_value (tf2_R)) 
-	    *tf2_R = NULL_VALUE;
-	  mat2[-h2_r+r2_2+r][c-c2_1] = *tf2_R;
-	  tf2_R++;
-	}
-    }
-  
-  G_close_cell(second_map_R_fd);
-  
-  
-  Menu_msg ("Searching points...");
-  
-  /* Memory allocation */
-  search_window = (DCELL **) G_calloc(search_window_dim,
-				      sizeof(DCELL *));
-  for(r=0;r<search_window_dim;r++)
-    search_window[r] = (DCELL *) G_calloc(search_window_dim,
-					  sizeof(DCELL));
-    
-  fft_first_s[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-  fft_first_s[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-  fft_second_s[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-  fft_second_s[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-  fft_prod_con_s[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-  fft_prod_con_s[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
-    
-
-  /* Inizialize control points */
-  sPoints.count=1;
-  sPoints.e1=(double *) G_calloc(sPoints.count,sizeof(double));
-  sPoints.n1=(double *) G_calloc(sPoints.count,sizeof(double));
-  sPoints.e2=(double *) G_calloc(sPoints.count,sizeof(double));
-  sPoints.n2=(double *) G_calloc(sPoints.count,sizeof(double));
-  sPoints.status=(int *) G_calloc(sPoints.count,sizeof(int));
-
-  /* Sites file */
-  sprintf(first_sites,"%s/%s/%s/site_lists/%s_%s",G__getenv("GISDBASE"),
-	  G__getenv("LOCATION_NAME"),G__getenv("MAPSET"),
-	  group_name,first_map_R_name);
-  sprintf(second_sites,"%s/%s/%s/site_lists/%s_%s",G__getenv("GISDBASE"),
-	  G__getenv("LOCATION_NAME"),G__getenv("MAPSET"),
-	  group_name,second_map_R_name);
-    
-   
-  /* Set cellhd1 to zoom_map_1 */  
-  cellhd1.rows=nrows1;
-  cellhd1.cols=ncols1;
-  cellhd1.north=r1_2*ms1->cell.ns_res;
-  cellhd1.south=r1_1*ms1->cell.ns_res;
-  cellhd1.east=c1_2*ms1->cell.ew_res;
-  cellhd1.west=c1_1*ms1->cell.ew_res;
- 
-  /* Set cellhd2 to zoom_map_2 */  
-  cellhd2.rows=nrows2;
-  cellhd2.cols=ncols2;
-  cellhd2.north=r2_2*ms2->cell.ns_res;
-  cellhd2.south=r1_1*ms2->cell.ns_res;
-  cellhd2.east=c2_2*ms2->cell.ew_res;
-  cellhd2.west=c2_1*ms2->cell.ew_res;
-  
-  /* Set windows to cellhd1 */
-  G_set_window(&cellhd1);
- 
-    
-    
-  /******************************************/
-  /* function --> Search_correlation_points */ 
-  /******************************************/     
-  Search_correlation_points_semi(mat1, mat2,
-			    search_window_dim, 
-			    squared_search_window_dim,
-			    search_jump,group_name, nrows1, ncols1,
-			    search_window, r1_2, c1_1, r2_2, c2_1,
-			    h1_r, h2_r, h1_c, h2_c, nrows2, ncols2 );
-    
-   
-  
-   
-  /* Build group/POINTS file */ 
-  sPoints.count -= 1;
-  if(sPoints.count > 0)
-    {
-      sprintf(file_name,"%s/%s/%s/group/%s/POINTS",group_GISDBASE,
-	      group_LOCATION_NAME,group_MAPSET,group_name);
-      fp_old = fopen(file_name,"r");
-     if( fp_old==NULL)
-	{	   
-	  q=0;
-	}
-      else
-	{
-	  q=1;
-	  fclose(fp_old);
-	}
-      
-      if (q==0)
-	{
-	  fp = fopen(file_name,"a");
-	  fprintf (fp,"# %7s %15s %15s %15s %9s status\n","",
-		   "image","","target","");
-	  fprintf (fp,"# %15s %15s %15s %15s   (1=ok)\n",
-		   "east","north","east","north");
-	  fprintf (fp,"#\n");
-	    
-	  for (i = 0; i < sPoints.count; i++)
-	    if ( sPoints.status[i] != -1)
-	      fprintf (fp, "  %15f %15f %15f %15f %4d\n",
-		       sPoints.e1[i],  sPoints.n1[i],  sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i]);
-	    
-	}
-      if(q==1)
-	{
-	  fp = fopen(file_name,"a");
-	  for (i = 0; i <  sPoints.count; i++)
-	    if ( sPoints.status[i] != -1)
-	      fprintf (fp, "  %15f %15f %15f %15f %4d\n", sPoints.e1[i],  sPoints.n1[i],  sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i]);
-	}
-      fclose (fp);
-    }
-    
-  /* Load new control points */
-   
-  for (i = 0; i < sPoints.count; i++)
-    if ( sPoints.status[i] != -1)
-      I_new_control_point (&group.points,sPoints.e1[i],  sPoints.n1[i],  
-			 sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i] );
-    
-  /* Build group/REF file */
-  /* 
-  sprintf(file_name,"%s/%s/%s/group/%s/REF",group_GISDBASE,
-	  group_LOCATION_NAME, group_MAPSET,group_name);
-  fp = fopen(file_name,"w");
-  fprintf(fp,"%s %s\n",first_map_R_name,first_map_R_mapset);
-    
-  fclose(fp);
-  */    
-
-  /* Build group/TARGET file */ 
-  sprintf(file_name,"%s/%s/%s/group/%s/TARGET",group_GISDBASE,
-	  group_LOCATION_NAME, group_MAPSET,group_name);
-  fp = fopen(file_name,"w");
-  fprintf(fp,"%s\n%s\n",group_LOCATION_NAME,group_MAPSET);
-  fclose(fp);
-    
-  /* Display new points */   
-  select_current_env ();
-  display_points_in_view (VIEW_MAP1, 1,
-			  group.points.e1, group.points.n1,
-			  group.points.status, group.points.count);
-    
-  display_points_in_view (VIEW_MAP1_ZOOM, 1,
-			  group.points.e1, group.points.n1,
-			  group.points.status, group.points.count);
-    
-  display_points_in_view (VIEW_MAP2, 1,
-			  group.points.e2, group.points.n2,
-			  group.points.status, group.points.count);
-    
-  display_points_in_view (VIEW_MAP2_ZOOM, 1,
-			  group.points.e2, group.points.n2,
-			  group.points.status, group.points.count);
-  R_flush();   
-    
-  /* Free memory */
-
-  free( rowbuf1_R);
-  free( rowbuf2_R);
-
-
-  for(r=0;r<nrows1;r++)
-    free( mat1[r]);
-  free(mat1);
-    
-  for(r=0;r<nrows2;r++)
-    free( mat2[r]);
-  free(mat2);
-    
-  for(r=0;r<search_window_dim;r++)
-    free(search_window[r]);
-  free(search_window);
-    
-  for(r=0;r<2;r++) 
-    {
-      free(fft_first_s[r]);
-      free(fft_second_s[r]);
-      free(fft_prod_con_s[r]);
-    }
-    
-  sPoints.e1[0];
-  sPoints.n1[0];
-  sPoints.e2[0];
-  sPoints.n2[0];
-  sPoints.status[0];
-    
-  free(sPoints.e1);
-  free(sPoints.n1);
-  free(sPoints.n2);
-  free(sPoints.e2);
-  free(sPoints.status);
-    
-
-    
-  return 0;
-}
-
-
-void Search_correlation_points_semi(DCELL **mat1_R, DCELL **mat2_R,
-			       int search_window_dim, 
-			       int squared_search_window_dim, 
-			       int search_jump, char *group_name,
-			       int dim_win_r, int dim_win_c,
-			       DCELL **search_window, int r1_2,int c1_1,
-			       int r2_2,int c2_1, int h1_r, int h2_r, 
-			       int  h1_c, int h2_c, int nrows2, int ncols2  )
-{
-  int r,c,i, j,search_border;
-  char *group_MAPSET;
-  char *group_LOCATION_NAME;
-  char *group_GISDBASE;
-  char first_sites[500];
-  char second_sites[500];
-  char file_name[500];    
-  FILE *fp;
-  FILE *first_fp;
-  FILE *second_fp;  
-  double cc;
-  double north1,east1,north2,east2;
-  int tmp_r,tmp_c;
-  double mean;
-  int index;
-  
-  
-  
-  
-  
-  /*Begin computation*/
-  search_border =  search_window_dim / 2;
-  
-  
-  for(r = search_border; r < dim_win_r - search_border; r += search_jump)
-    {
-      for(c = search_border; c < dim_win_c - search_border; c += search_jump)
-	{
-	  /*  Reinizialize fft vectors */
-	  
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fft_first_s[0][i]=0.0;
-	      fft_first_s[1][i]=0.0;
-	      fft_second_s[0][i]=0.0;
-	      fft_second_s[1][i]=0.0;
-	      fft_prod_con_s[0][i]=0.0;
-	      fft_prod_con_s[1][i]=0.0;
-	    }
-	  
-	  
-	  /* Coordinates of the "initial" point */
-	  
-	  east1 = G_col_to_easting((double) c, &cellhd1);
-	  north1 = G_row_to_northing((double) r, &cellhd1);
-	
-	  /* Real window in the first image */
-	  
-	  Extract_portion_of_double_matrix_semi(r,c,search_border,search_border,
-					   mat1_R,search_window);
-	  
-	  mean = 0.0;
-	  for(i=0;i<search_window_dim;i++)
-	    {
-	      for(j=0;j<search_window_dim;j++)
-		{
-		  mean +=  search_window[i][j];
-		}
-	    }
-	  mean /= squared_search_window_dim;
-	
-	  for(i=0;i<search_window_dim;i++)
-	    {
-	      for(j=0;j<search_window_dim;j++)
-		{
-		  fft_first_s[0][i*search_window_dim+j]=search_window[i][j]-mean;
-		}
-	    }
-	  
-	  
-	  /* Real window in the second image */
-	
-	  if((r-search_border+2*search_border>=nrows2)||(c-search_border+2*search_border>=ncols2))
-	    {
-	      if (sPoints.count<=1)
-		{	   
-		  Menu_msg("DEFINE A NEW REGION.");
-		  sleep(3);
-		  pause;
-		}
-	      return 0;
-	    }
-
-	  Extract_portion_of_double_matrix_semi(r,c,search_border,search_border,
-					   mat2_R,search_window);
-	  mean = 0.0;
-	  for(i=0;i<search_window_dim;i++)
-	    {
-	      for(j=0;j<search_window_dim;j++)
-		{
-		  mean +=  search_window[i][j];
-		}
-	    }
-	  mean /= squared_search_window_dim;
-	  for(i=0;i<search_window_dim;i++)
-	    {
-	      for(j=0;j<search_window_dim;j++)
-		{
-		  fft_second_s[0][i*search_window_dim+j]=search_window[i][j]-mean;
-		}
-	    }
-	  
-#ifdef DEBUG
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_first_s[0][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_first_s[1][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_second_s[0][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_second_s[1][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-#endif
-	  /* fft of the 2 (complex) windows */
-	  fft(-1,fft_first_s,squared_search_window_dim,search_window_dim,
-	      search_window_dim);
-	  fft(-1,fft_second_s,squared_search_window_dim,search_window_dim,
-	      search_window_dim);
-	
-	  
-#ifdef DEBUG
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_first_s[0][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_first_s[1][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_second_s[0][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_second_s[1][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-#endif
-	  
-	  /* product of the first fft for the coniugate of the second one */
-	  for(i=0;i<squared_search_window_dim;i+=1)
-	    {
-	      fft_prod_con_s[0][i] = (fft_first_s[0][i] * fft_second_s[0][i]) +
-		(fft_first_s[1][i] * fft_second_s[1][i]);
-	      fft_prod_con_s[1][i] = (fft_first_s[1][i] * fft_second_s[0][i]) -
-		(fft_first_s[0][i] * fft_second_s[1][i]);
-	    }
-	  
-	  
-#ifdef DEBUG
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_prod_con_s[0][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_prod_con_s[1][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-#endif
-	  
-	  /* fft^{-1} of the product <==> cross-correlation at differnet lag
-	     between the two orig. (complex) windows */
-	  fft(1,fft_prod_con_s,squared_search_window_dim,search_window_dim,
-	      search_window_dim);
-	  
-#ifdef DEBUG
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_prod_con_s[0][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      fprintf(stderr,"%f\t",fft_prod_con_s[1][i]);
-	    }
-	  fprintf(stderr,"\n\n");
-#endif
-	  
-	  /* Search the lag coresponding to the maximum correlation */
-	  cc = 0.0;
-	 
-	  for(i=0;i<squared_search_window_dim;i++)
-	    {
-	      if(fft_prod_con_s[0][i] > cc)
-		{
-		  cc = fft_prod_con_s[0][i];
-		  tmp_r=i/search_window_dim;
-		  tmp_c=i%search_window_dim;
-		
-		}
-	    } 
-	
-	  /* Get coordinates of "ending" point  */
-	  if((tmp_r <= search_window_dim/2) && (tmp_c <= search_window_dim/2))
-	    {
-	   
-	      east2 = G_col_to_easting((double) c  - tmp_c,&cellhd2);
-	      north2 = G_row_to_northing((double) r  - tmp_r,&cellhd2);
-	   
-	    }
-	  if((tmp_r <= search_window_dim/2) && (tmp_c >= search_window_dim/2))
-	    {
-	      
-	      east2 = G_col_to_easting((double) c  - (tmp_c-search_window_dim-1),&cellhd2);
-	      north2 = G_row_to_northing((double) r -  tmp_r,&cellhd2);
-	   
-	    }
-	  if((tmp_r >= search_window_dim/2) && (tmp_c <= search_window_dim/2))
-	    {
-	     
-	      east2 = G_col_to_easting((double) c  - tmp_c,&cellhd2);
-	      north2 = G_row_to_northing((double) r  - (tmp_r-search_window_dim-1),&cellhd2);
-	    
-	    }
-	  if((tmp_r >= search_window_dim/2) && (tmp_c >= search_window_dim/2))
-	    {
-	    
-	      east2 = G_col_to_easting((double) c  - (tmp_c-search_window_dim-1),&cellhd2);
-	      north2 = G_row_to_northing((double) r  - (tmp_r-search_window_dim-1),&cellhd2);
-	    
-	    }
-	
-	
-	  /* Fill the POINTS file*/
-	  sPoints.e1[sPoints.count-1] = east1;
-	  sPoints.n1[sPoints.count-1] = north1;
-	  sPoints.e2[sPoints.count-1] = east2;
-	  sPoints.n2[sPoints.count-1] = north2;
-	
-	  sPoints.status[sPoints.count-1] = 1;
-	  sPoints.count += 1;
-	  sPoints.e1=(double *)G_realloc(sPoints.e1,sPoints.count*sizeof(double));
-	  sPoints.n1=(double *)G_realloc(sPoints.n1,sPoints.count*sizeof(double));
-	  sPoints.e2=(double *)G_realloc(sPoints.e2,sPoints.count*sizeof(double));
-	  sPoints.n2=(double *)G_realloc(sPoints.n2,sPoints.count*sizeof(double));
-	  sPoints.status=(int *)G_realloc(sPoints.status,sPoints.count*sizeof(int));
-	}
-      G_percent (r,dim_win_r, 1);   
-    }
-  }
-
-
-void Extract_portion_of_double_matrix_semi(int r,int c,int br,int bc,DCELL **mat,DCELL **wind)
-     /*
-       extract a squared portion of a matrix mat
-       given a the indeces of the center [r,c] 
-       and the semilength of the borders [br,bc]
-       Output to array wind
-     */
-{
-  int i,j;
-  for(i=0;(i <2*br);i++)
-    for(j = 0;(j <2*bc);j++)
-      {
-	wind[i][j] = mat[r - br + i][c - bc +j];    
-      }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

Copied: grass-addons/imagery/i.points.auto/find_points_semi.c (from rev 30335, grass-addons/i.points.auto/find_points_semi.c)
===================================================================
--- grass-addons/imagery/i.points.auto/find_points_semi.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/find_points_semi.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,778 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <signal.h>
+
+#include <grass/config.h>
+#ifdef HAVE_FFTW_H
+#include <fftw.h>
+#endif
+#ifdef HAVE_DFFTW_H
+#include <dfftw.h>
+#endif
+
+#include <grass/raster.h>
+#include <grass/imagery.h>
+#include <grass/gmath.h>
+#include "globals.h"
+#include "local_proto.h"
+
+#ifdef NULL_VALUE
+#undef NULL_VALUE
+#endif
+#define NULL_VALUE -1
+
+
+#ifdef DEBUG
+#undef DEBUG
+#endif
+
+double *fft_first_s[2];
+double *fft_second_s[2];
+double *fft_prod_con_s[2];
+ 
+View *ms1, *ms2; 
+
+void Extract_matrix_semi()
+{
+  struct GModule *module;
+  struct Control_Points *cp1;
+  char buf[256];
+  char *s;
+  int rows, cols;
+  char *first_map_R_mapset;
+  char *first_map_R_name;
+  int first_map_R_fd;
+  char *second_map_R_mapset;
+  char *second_map_R_name;
+  int second_map_R_fd;
+  
+  int K;
+  
+  int correlation_window_dim;
+  int search_window_dim;
+
+  int squared_search_window_dim;
+  int search_jump;
+  
+  int ncols1, ncols2, nrows1, nrows2;
+  int left1, top1, left2, top2;   
+  int repeat;  
+
+  int n_1, e_1, n_2, e_2, s_1, s_2, w_1, w_2;
+  int r1_1, r1_2, r2_1, r2_2;
+  int c1_1, c1_2, c2_1, c2_2;
+
+  int i;
+
+  int h1_r;
+  int h1_c;
+  int h2_r;
+  int h2_c;
+
+  
+  char *group_name;
+  char *group_MAPSET;
+  char *group_LOCATION_NAME;
+  char *group_GISDBASE;
+  DCELL *rowbuf1_R;
+  DCELL *tf1_R;
+  DCELL *rowbuf2_R;
+  DCELL *tf2_R;
+  double **search_window;
+  double **mat1,**mat2;    
+  int r,c;
+  int search_border;
+  int q;
+  int p1;
+  int dim_win_c, dim_win_r;
+  char first_sites[500];
+  char second_sites[500];
+  char file_name[500];
+  char file_name_old[500];
+  FILE *first_fp;
+  FILE *second_fp;  
+  FILE *fp;
+  FILE *fp_old; 
+  
+ 
+  
+  /* Read VIEW_MAP1_ZOOM & VIEW_MAP2_ZOOM informations */
+  
+  
+  ms1=VIEW_MAP1_ZOOM;
+  ms2=VIEW_MAP2_ZOOM;
+  
+  first_map_R_name=ms1->cell.name;
+  second_map_R_name=ms2->cell.name;
+ 
+  /* rows & cols of VIEW_MAP1_ZOOM */
+  n_1=ms1->cell.head.north;
+  e_1=ms1->cell.head.east;
+  s_1=ms1->cell.head.south;
+  w_1=ms1->cell.head.west; 
+  left1 = ms1->cell.left;
+  top1 = ms1->cell.top;
+  
+  r1_1=s_1/ms1->cell.ns_res;
+  r1_2=n_1/ms1->cell.ns_res;
+  c1_1=w_1/ms1->cell.ew_res; 
+  c1_2=e_1/ms1->cell.ew_res;
+  
+  nrows1=r1_2-r1_1;
+  ncols1=c1_2-c1_1;
+
+
+  /* rows & cols of VIEW_MAP2_ZOOM */
+  n_2=ms2->cell.head.north;
+  e_2=ms2->cell.head.east; 
+  s_2=ms2->cell.head.south;
+  w_2=ms2->cell.head.west;    
+  left2 = ms2->cell.left;
+  top2 = ms2->cell.top; 
+  
+  r2_1=s_2/ms2->cell.ns_res;
+  r2_2=n_2/ms2->cell.ns_res;
+  c2_1=w_2/ms2->cell.ew_res; 
+  c2_2=e_2/ms2->cell.ew_res;
+
+  nrows2=r2_2-r2_1; 
+  ncols2=c2_2-c2_1;
+  
+  
+ 
+   /* Initialize the GIS calls */
+  module = G_define_module();
+  module->description = "Fine registration of two stereo images";
+  
+  /* Load environmental vars*/
+  group_LOCATION_NAME=buf;
+  group_LOCATION_NAME=G_getenv("LOCATION_NAME");
+  group_GISDBASE=buf;
+  group_GISDBASE=G_getenv("GISDBASE");
+  group_MAPSET=buf;
+  group_MAPSET=G_getenv("MAPSET");
+  
+  
+  /* Correlation parameters */
+  correlation_window_dim=((ncols1/10+nrows1/10)/2);
+  K=((ncols1/4+nrows1/4)/2);
+
+  search_window_dim = G_math_max_pow2(correlation_window_dim + K);
+  group_name=group.name;
+  squared_search_window_dim=search_window_dim*search_window_dim;
+  search_jump=search_window_dim / 2; 
+  
+ 
+  
+  Menu_msg ("Loading first zoom_image..."); 
+  
+  /* Open first real map*/
+  if((first_map_R_mapset = G_find_cell2(first_map_R_name, "")) == NULL)
+    {
+      sprintf(buf,"Raster map [%s] not available",first_map_R_name);
+      G_fatal_error(buf);
+    }
+  
+  
+  if((first_map_R_fd = G_open_cell_old(first_map_R_name, 
+				       first_map_R_mapset)) < 0)
+    {
+      sprintf(buf,"Error opening raster map [%s]", first_map_R_name);
+      G_fatal_error(buf);
+    }
+
+  /* Set region to first map definition region  < ms1 > */ 
+  G_get_cellhd (first_map_R_name, first_map_R_mapset, &cellhd1);
+  G_set_window(&cellhd1);
+  h1_r=cellhd1.rows;
+  h1_c=cellhd1.cols;
+    
+
+   
+  /* Memory allocation for zoom_map_1 */
+  
+  mat1 = (DCELL **) G_calloc(nrows1,sizeof(DCELL *));
+  for(r=0;r<nrows1;r++)
+    mat1[r] = (DCELL *) G_calloc(ncols1,sizeof(DCELL)); 
+  
+
+  /* Load first  map*/
+  
+  rowbuf1_R = (DCELL *)G_calloc(h1_r * h1_c,sizeof(DCELL));
+  tf1_R=rowbuf1_R;
+  
+  for(r=h1_r-r1_2;r<h1_r-r1_1;r++)
+    {  
+      G_get_d_raster_row(first_map_R_fd, tf1_R, r);	
+      if (G_is_d_null_value (tf1_R)) 
+	*tf1_R = NULL_VALUE;	
+      c=0;
+      while(c<c1_1)
+	{	
+	  tf1_R++;
+	  c++;
+	}	
+      for(c = c1_1; c < c1_2; c++)
+	{
+	  mat1[-h1_r+r1_2+r][c-c1_1] = *tf1_R;
+	  tf1_R++;
+	}
+    }
+  G_close_cell(first_map_R_fd);
+  
+  
+  /* Open second  map*/
+  if((second_map_R_mapset = G_find_cell2(second_map_R_name, "")) == NULL)
+    {
+      sprintf(buf,"Raster map [%s] not available",second_map_R_name);
+      G_fatal_error(buf);
+    }
+  
+  if((second_map_R_fd = G_open_cell_old(second_map_R_name, 
+					second_map_R_mapset)) < 0) 
+    {
+      sprintf(buf,"Error opening raster map [%s]", second_map_R_name);
+      G_fatal_error(buf);
+    } 
+    
+  /* Set region to second map definition region */
+  G_get_cellhd (second_map_R_name, second_map_R_mapset, &cellhd2);
+  G_set_window(&cellhd2);
+  h2_r=cellhd2.rows;
+  h2_c=cellhd2.cols;
+  
+  
+  /* Memory allocation for zoom_map_2 */
+  mat2 = (DCELL **) G_calloc(nrows2,sizeof(DCELL *));
+  for(r=0;r<nrows2;r++)
+    mat2[r] = (DCELL *) G_calloc(ncols2,sizeof(DCELL));
+
+  /* Load second real map */
+  Menu_msg ("Loading second zoom_image...");
+  
+  rowbuf2_R=(DCELL *)G_calloc(h2_r * h2_c,sizeof(DCELL));
+  tf2_R=rowbuf2_R;
+  for(r=h2_r-r2_2;r<h2_r-r2_1;r++)
+    
+    {				
+      G_get_d_raster_row(second_map_R_fd, tf2_R, r);	
+      c=0;
+      while(c<c2_1)
+	{	
+	  tf2_R++;
+	  c++;
+	}	
+      for(c = c2_1; c < c2_2; c++)
+	{
+	  if (G_is_d_null_value (tf2_R)) 
+	    *tf2_R = NULL_VALUE;
+	  mat2[-h2_r+r2_2+r][c-c2_1] = *tf2_R;
+	  tf2_R++;
+	}
+    }
+  
+  G_close_cell(second_map_R_fd);
+  
+  
+  Menu_msg ("Searching points...");
+  
+  /* Memory allocation */
+  search_window = (DCELL **) G_calloc(search_window_dim,
+				      sizeof(DCELL *));
+  for(r=0;r<search_window_dim;r++)
+    search_window[r] = (DCELL *) G_calloc(search_window_dim,
+					  sizeof(DCELL));
+    
+  fft_first_s[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+  fft_first_s[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+  fft_second_s[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+  fft_second_s[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+  fft_prod_con_s[0] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+  fft_prod_con_s[1] = (double *)G_calloc(squared_search_window_dim, sizeof(double));
+    
+
+  /* Inizialize control points */
+  sPoints.count=1;
+  sPoints.e1=(double *) G_calloc(sPoints.count,sizeof(double));
+  sPoints.n1=(double *) G_calloc(sPoints.count,sizeof(double));
+  sPoints.e2=(double *) G_calloc(sPoints.count,sizeof(double));
+  sPoints.n2=(double *) G_calloc(sPoints.count,sizeof(double));
+  sPoints.status=(int *) G_calloc(sPoints.count,sizeof(int));
+
+  /* Sites file */
+  sprintf(first_sites,"%s/%s/%s/site_lists/%s_%s",G__getenv("GISDBASE"),
+	  G__getenv("LOCATION_NAME"),G__getenv("MAPSET"),
+	  group_name,first_map_R_name);
+  sprintf(second_sites,"%s/%s/%s/site_lists/%s_%s",G__getenv("GISDBASE"),
+	  G__getenv("LOCATION_NAME"),G__getenv("MAPSET"),
+	  group_name,second_map_R_name);
+    
+   
+  /* Set cellhd1 to zoom_map_1 */  
+  cellhd1.rows=nrows1;
+  cellhd1.cols=ncols1;
+  cellhd1.north=r1_2*ms1->cell.ns_res;
+  cellhd1.south=r1_1*ms1->cell.ns_res;
+  cellhd1.east=c1_2*ms1->cell.ew_res;
+  cellhd1.west=c1_1*ms1->cell.ew_res;
+ 
+  /* Set cellhd2 to zoom_map_2 */  
+  cellhd2.rows=nrows2;
+  cellhd2.cols=ncols2;
+  cellhd2.north=r2_2*ms2->cell.ns_res;
+  cellhd2.south=r1_1*ms2->cell.ns_res;
+  cellhd2.east=c2_2*ms2->cell.ew_res;
+  cellhd2.west=c2_1*ms2->cell.ew_res;
+  
+  /* Set windows to cellhd1 */
+  G_set_window(&cellhd1);
+ 
+    
+    
+  /******************************************/
+  /* function --> Search_correlation_points */ 
+  /******************************************/     
+  Search_correlation_points_semi(mat1, mat2,
+			    search_window_dim, 
+			    squared_search_window_dim,
+			    search_jump,group_name, nrows1, ncols1,
+			    search_window, r1_2, c1_1, r2_2, c2_1,
+			    h1_r, h2_r, h1_c, h2_c, nrows2, ncols2 );
+    
+   
+  
+   
+  /* Build group/POINTS file */ 
+  sPoints.count -= 1;
+  if(sPoints.count > 0)
+    {
+      sprintf(file_name,"%s/%s/%s/group/%s/POINTS",group_GISDBASE,
+	      group_LOCATION_NAME,group_MAPSET,group_name);
+      fp_old = fopen(file_name,"r");
+     if( fp_old==NULL)
+	{	   
+	  q=0;
+	}
+      else
+	{
+	  q=1;
+	  fclose(fp_old);
+	}
+      
+      if (q==0)
+	{
+	  fp = fopen(file_name,"a");
+	  fprintf (fp,"# %7s %15s %15s %15s %9s status\n","",
+		   "image","","target","");
+	  fprintf (fp,"# %15s %15s %15s %15s   (1=ok)\n",
+		   "east","north","east","north");
+	  fprintf (fp,"#\n");
+	    
+	  for (i = 0; i < sPoints.count; i++)
+	    if ( sPoints.status[i] != -1)
+	      fprintf (fp, "  %15f %15f %15f %15f %4d\n",
+		       sPoints.e1[i],  sPoints.n1[i],  sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i]);
+	    
+	}
+      if(q==1)
+	{
+	  fp = fopen(file_name,"a");
+	  for (i = 0; i <  sPoints.count; i++)
+	    if ( sPoints.status[i] != -1)
+	      fprintf (fp, "  %15f %15f %15f %15f %4d\n", sPoints.e1[i],  sPoints.n1[i],  sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i]);
+	}
+      fclose (fp);
+    }
+    
+  /* Load new control points */
+   
+  for (i = 0; i < sPoints.count; i++)
+    if ( sPoints.status[i] != -1)
+      I_new_control_point (&group.points,sPoints.e1[i],  sPoints.n1[i],  
+			 sPoints.e2[i],  sPoints.n2[i],  sPoints.status[i] );
+    
+  /* Build group/REF file */
+  /* 
+  sprintf(file_name,"%s/%s/%s/group/%s/REF",group_GISDBASE,
+	  group_LOCATION_NAME, group_MAPSET,group_name);
+  fp = fopen(file_name,"w");
+  fprintf(fp,"%s %s\n",first_map_R_name,first_map_R_mapset);
+    
+  fclose(fp);
+  */    
+
+  /* Build group/TARGET file */ 
+  sprintf(file_name,"%s/%s/%s/group/%s/TARGET",group_GISDBASE,
+	  group_LOCATION_NAME, group_MAPSET,group_name);
+  fp = fopen(file_name,"w");
+  fprintf(fp,"%s\n%s\n",group_LOCATION_NAME,group_MAPSET);
+  fclose(fp);
+    
+  /* Display new points */   
+  select_current_env ();
+  display_points_in_view (VIEW_MAP1, 1,
+			  group.points.e1, group.points.n1,
+			  group.points.status, group.points.count);
+    
+  display_points_in_view (VIEW_MAP1_ZOOM, 1,
+			  group.points.e1, group.points.n1,
+			  group.points.status, group.points.count);
+    
+  display_points_in_view (VIEW_MAP2, 1,
+			  group.points.e2, group.points.n2,
+			  group.points.status, group.points.count);
+    
+  display_points_in_view (VIEW_MAP2_ZOOM, 1,
+			  group.points.e2, group.points.n2,
+			  group.points.status, group.points.count);
+  R_flush();   
+    
+  /* Free memory */
+
+  free( rowbuf1_R);
+  free( rowbuf2_R);
+
+
+  for(r=0;r<nrows1;r++)
+    free( mat1[r]);
+  free(mat1);
+    
+  for(r=0;r<nrows2;r++)
+    free( mat2[r]);
+  free(mat2);
+    
+  for(r=0;r<search_window_dim;r++)
+    free(search_window[r]);
+  free(search_window);
+    
+  for(r=0;r<2;r++) 
+    {
+      free(fft_first_s[r]);
+      free(fft_second_s[r]);
+      free(fft_prod_con_s[r]);
+    }
+    
+  sPoints.e1[0];
+  sPoints.n1[0];
+  sPoints.e2[0];
+  sPoints.n2[0];
+  sPoints.status[0];
+    
+  free(sPoints.e1);
+  free(sPoints.n1);
+  free(sPoints.n2);
+  free(sPoints.e2);
+  free(sPoints.status);
+    
+
+    
+  return 0;
+}
+
+
+void Search_correlation_points_semi(DCELL **mat1_R, DCELL **mat2_R,
+			       int search_window_dim, 
+			       int squared_search_window_dim, 
+			       int search_jump, char *group_name,
+			       int dim_win_r, int dim_win_c,
+			       DCELL **search_window, int r1_2,int c1_1,
+			       int r2_2,int c2_1, int h1_r, int h2_r, 
+			       int  h1_c, int h2_c, int nrows2, int ncols2  )
+{
+  int r,c,i, j,search_border;
+  char *group_MAPSET;
+  char *group_LOCATION_NAME;
+  char *group_GISDBASE;
+  char first_sites[500];
+  char second_sites[500];
+  char file_name[500];    
+  FILE *fp;
+  FILE *first_fp;
+  FILE *second_fp;  
+  double cc;
+  double north1,east1,north2,east2;
+  int tmp_r,tmp_c;
+  double mean;
+  int index;
+  
+  
+  
+  
+  
+  /*Begin computation*/
+  search_border =  search_window_dim / 2;
+  
+  
+  for(r = search_border; r < dim_win_r - search_border; r += search_jump)
+    {
+      for(c = search_border; c < dim_win_c - search_border; c += search_jump)
+	{
+	  /*  Reinizialize fft vectors */
+	  
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fft_first_s[0][i]=0.0;
+	      fft_first_s[1][i]=0.0;
+	      fft_second_s[0][i]=0.0;
+	      fft_second_s[1][i]=0.0;
+	      fft_prod_con_s[0][i]=0.0;
+	      fft_prod_con_s[1][i]=0.0;
+	    }
+	  
+	  
+	  /* Coordinates of the "initial" point */
+	  
+	  east1 = G_col_to_easting((double) c, &cellhd1);
+	  north1 = G_row_to_northing((double) r, &cellhd1);
+	
+	  /* Real window in the first image */
+	  
+	  Extract_portion_of_double_matrix_semi(r,c,search_border,search_border,
+					   mat1_R,search_window);
+	  
+	  mean = 0.0;
+	  for(i=0;i<search_window_dim;i++)
+	    {
+	      for(j=0;j<search_window_dim;j++)
+		{
+		  mean +=  search_window[i][j];
+		}
+	    }
+	  mean /= squared_search_window_dim;
+	
+	  for(i=0;i<search_window_dim;i++)
+	    {
+	      for(j=0;j<search_window_dim;j++)
+		{
+		  fft_first_s[0][i*search_window_dim+j]=search_window[i][j]-mean;
+		}
+	    }
+	  
+	  
+	  /* Real window in the second image */
+	
+	  if((r-search_border+2*search_border>=nrows2)||(c-search_border+2*search_border>=ncols2))
+	    {
+	      if (sPoints.count<=1)
+		{	   
+		  Menu_msg("DEFINE A NEW REGION.");
+		  sleep(3);
+		  pause;
+		}
+	      return 0;
+	    }
+
+	  Extract_portion_of_double_matrix_semi(r,c,search_border,search_border,
+					   mat2_R,search_window);
+	  mean = 0.0;
+	  for(i=0;i<search_window_dim;i++)
+	    {
+	      for(j=0;j<search_window_dim;j++)
+		{
+		  mean +=  search_window[i][j];
+		}
+	    }
+	  mean /= squared_search_window_dim;
+	  for(i=0;i<search_window_dim;i++)
+	    {
+	      for(j=0;j<search_window_dim;j++)
+		{
+		  fft_second_s[0][i*search_window_dim+j]=search_window[i][j]-mean;
+		}
+	    }
+	  
+#ifdef DEBUG
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_first_s[0][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_first_s[1][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_second_s[0][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_second_s[1][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+#endif
+	  /* fft of the 2 (complex) windows */
+	  fft(-1,fft_first_s,squared_search_window_dim,search_window_dim,
+	      search_window_dim);
+	  fft(-1,fft_second_s,squared_search_window_dim,search_window_dim,
+	      search_window_dim);
+	
+	  
+#ifdef DEBUG
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_first_s[0][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_first_s[1][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_second_s[0][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_second_s[1][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+#endif
+	  
+	  /* product of the first fft for the coniugate of the second one */
+	  for(i=0;i<squared_search_window_dim;i+=1)
+	    {
+	      fft_prod_con_s[0][i] = (fft_first_s[0][i] * fft_second_s[0][i]) +
+		(fft_first_s[1][i] * fft_second_s[1][i]);
+	      fft_prod_con_s[1][i] = (fft_first_s[1][i] * fft_second_s[0][i]) -
+		(fft_first_s[0][i] * fft_second_s[1][i]);
+	    }
+	  
+	  
+#ifdef DEBUG
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_prod_con_s[0][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_prod_con_s[1][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+#endif
+	  
+	  /* fft^{-1} of the product <==> cross-correlation at differnet lag
+	     between the two orig. (complex) windows */
+	  fft(1,fft_prod_con_s,squared_search_window_dim,search_window_dim,
+	      search_window_dim);
+	  
+#ifdef DEBUG
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_prod_con_s[0][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      fprintf(stderr,"%f\t",fft_prod_con_s[1][i]);
+	    }
+	  fprintf(stderr,"\n\n");
+#endif
+	  
+	  /* Search the lag coresponding to the maximum correlation */
+	  cc = 0.0;
+	 
+	  for(i=0;i<squared_search_window_dim;i++)
+	    {
+	      if(fft_prod_con_s[0][i] > cc)
+		{
+		  cc = fft_prod_con_s[0][i];
+		  tmp_r=i/search_window_dim;
+		  tmp_c=i%search_window_dim;
+		
+		}
+	    } 
+	
+	  /* Get coordinates of "ending" point  */
+	  if((tmp_r <= search_window_dim/2) && (tmp_c <= search_window_dim/2))
+	    {
+	   
+	      east2 = G_col_to_easting((double) c  - tmp_c,&cellhd2);
+	      north2 = G_row_to_northing((double) r  - tmp_r,&cellhd2);
+	   
+	    }
+	  if((tmp_r <= search_window_dim/2) && (tmp_c >= search_window_dim/2))
+	    {
+	      
+	      east2 = G_col_to_easting((double) c  - (tmp_c-search_window_dim-1),&cellhd2);
+	      north2 = G_row_to_northing((double) r -  tmp_r,&cellhd2);
+	   
+	    }
+	  if((tmp_r >= search_window_dim/2) && (tmp_c <= search_window_dim/2))
+	    {
+	     
+	      east2 = G_col_to_easting((double) c  - tmp_c,&cellhd2);
+	      north2 = G_row_to_northing((double) r  - (tmp_r-search_window_dim-1),&cellhd2);
+	    
+	    }
+	  if((tmp_r >= search_window_dim/2) && (tmp_c >= search_window_dim/2))
+	    {
+	    
+	      east2 = G_col_to_easting((double) c  - (tmp_c-search_window_dim-1),&cellhd2);
+	      north2 = G_row_to_northing((double) r  - (tmp_r-search_window_dim-1),&cellhd2);
+	    
+	    }
+	
+	
+	  /* Fill the POINTS file*/
+	  sPoints.e1[sPoints.count-1] = east1;
+	  sPoints.n1[sPoints.count-1] = north1;
+	  sPoints.e2[sPoints.count-1] = east2;
+	  sPoints.n2[sPoints.count-1] = north2;
+	
+	  sPoints.status[sPoints.count-1] = 1;
+	  sPoints.count += 1;
+	  sPoints.e1=(double *)G_realloc(sPoints.e1,sPoints.count*sizeof(double));
+	  sPoints.n1=(double *)G_realloc(sPoints.n1,sPoints.count*sizeof(double));
+	  sPoints.e2=(double *)G_realloc(sPoints.e2,sPoints.count*sizeof(double));
+	  sPoints.n2=(double *)G_realloc(sPoints.n2,sPoints.count*sizeof(double));
+	  sPoints.status=(int *)G_realloc(sPoints.status,sPoints.count*sizeof(int));
+	}
+      G_percent (r,dim_win_r, 1);   
+    }
+  }
+
+
+void Extract_portion_of_double_matrix_semi(int r,int c,int br,int bc,DCELL **mat,DCELL **wind)
+     /*
+       extract a squared portion of a matrix mat
+       given a the indeces of the center [r,c] 
+       and the semilength of the borders [br,bc]
+       Output to array wind
+     */
+{
+  int i,j;
+  for(i=0;(i <2*br);i++)
+    for(j = 0;(j <2*bc);j++)
+      {
+	wind[i][j] = mat[r - br + i][c - bc +j];    
+      }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Deleted: grass-addons/imagery/i.points.auto/georef.c
===================================================================
--- grass-addons/i.points.auto/georef.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/georef.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,326 +0,0 @@
-#include <signal.h>
-#include "globals.h"
-
-static int floating_exception;
-static void catch(int);
-static double determinant(double,double,
-                double,double,double,double,double,double,double);
-
-void (*sigfpe)();
-
-/* 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 compute_georef_equations(
-    struct Control_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;
-    int i;
-
-
-    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
-    for (i = 0; i < cp->count; i++)
-    {
-	if (cp->status[i] != 1)
-	    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] != 1)
-	    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] != 1)
-	    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] != 1)
-	    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] != 1)
-	    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] != 1)
-	    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;
-}
-
-
-int compute_georef_equations_lp (Lines *ln)
-{
-    double s0,s1,s2,s3,s4,s5;
-    double x0,x1,x2;
-    double det;
-    int i;
-
-
-    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
-    for (i = 0; i < ln->count; i++)
-    {
-	if (ln->status[i] != 2)
-	    continue;
-	s0 += 1.0;
-	s1 += ln->t1[i];
-	s2 += ln->u1[i];
-	s3 += ln->t1[i] * ln->t1[i];
-	s4 += ln->t1[i] * ln->u1[i];
-	s5 += ln->u1[i] * ln->u1[i];
-    }
-    if (s0 < 0.5) return 0;
-
-    floating_exception = 0;
-    sigfpe = signal (SIGFPE, catch);
-
-/* eastings */
-    x0 = x1 = x2 = 0.0;
-    for (i = 0; i < ln->count; i++)
-    {
-	if (ln->status[i] != 2)
-	    continue;
-	x0 += ln->t2[i];
-	x1 += ln->t1[i] * ln->t2[i];
-	x2 += ln->u1[i] * ln->t2[i];
-    }
-
-    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
-    if (det == 0.0)
-    {
-	signal (SIGFPE, sigfpe);
-	return -1;
-    }
-    ln->E12[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
-    ln->E12[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
-    ln->E12[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
-
-/* northings */
-    x0 = x1 = x2 = 0.0;
-    for (i = 0; i < ln->count; i++)
-    {
-	if (ln->status[i] != 2)
-	    continue;
-	x0 += ln->u2[i];
-	x1 += ln->t1[i] * ln->u2[i];
-	x2 += ln->u1[i] * ln->u2[i];
-    }
-
-    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
-    if (det == 0.0)
-    {
-	signal (SIGFPE, sigfpe);
-	return -1;
-    }
-    ln->N12[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
-    ln->N12[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
-    ln->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 < ln->count; i++)
-    {
-	if (ln->status[i] != 2)
-	    continue;
-	s0 += 1.0;
-	s1 += ln->t2[i];
-	s2 += ln->u2[i];
-	s3 += ln->t2[i] * ln->t2[i];
-	s4 += ln->t2[i] * ln->u2[i];
-	s5 += ln->u2[i] * ln->u2[i];
-    }
-
-/* eastings */
-    x0 = x1 = x2 = 0.0;
-    for (i = 0; i < ln->count; i++)
-    {
-	if (ln->status[i] != 2)
-	    continue;
-	x0 += ln->t1[i];
-	x1 += ln->t2[i] * ln->t1[i];
-	x2 += ln->u2[i] * ln->t1[i];
-    }
-
-    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
-    if (det == 0.0)
-    {
-	signal (SIGFPE, sigfpe);
-	return -1;
-    }
-    ln->E21[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
-    ln->E21[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
-    ln->E21[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
-
-/* northings */
-    x0 = x1 = x2 = 0.0;
-    for (i = 0; i < ln->count; i++)
-    {
-	if (ln->status[i] != 2)
-	    continue;
-	x0 += ln->u1[i];
-	x1 += ln->t2[i] * ln->u1[i];
-	x2 += ln->u2[i] * ln->u1[i];
-    }
-
-    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
-    if (det == 0.0)
-    {
-	signal (SIGFPE, sigfpe);
-	return -1;
-    }
-    ln->N21[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
-    ln->N21[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
-    ln->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);
-}
-
-int georef (
-    double e1,double n1,
-    double *e2,double *n2,
-    double E[3],double N[3])
-{
-    *e2 = E[0] + E[1] * e1 + E[2] * n1;
-    *n2 = N[0] + N[1] * e1 + N[2] * n1;
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/georef.c (from rev 30335, grass-addons/i.points.auto/georef.c)
===================================================================
--- grass-addons/imagery/i.points.auto/georef.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/georef.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,326 @@
+#include <signal.h>
+#include "globals.h"
+
+static int floating_exception;
+static void catch(int);
+static double determinant(double,double,
+                double,double,double,double,double,double,double);
+
+void (*sigfpe)();
+
+/* 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 compute_georef_equations(
+    struct Control_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;
+    int i;
+
+
+    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
+    for (i = 0; i < cp->count; i++)
+    {
+	if (cp->status[i] != 1)
+	    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] != 1)
+	    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] != 1)
+	    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] != 1)
+	    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] != 1)
+	    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] != 1)
+	    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;
+}
+
+
+int compute_georef_equations_lp (Lines *ln)
+{
+    double s0,s1,s2,s3,s4,s5;
+    double x0,x1,x2;
+    double det;
+    int i;
+
+
+    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
+    for (i = 0; i < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	s0 += 1.0;
+	s1 += ln->t1[i];
+	s2 += ln->u1[i];
+	s3 += ln->t1[i] * ln->t1[i];
+	s4 += ln->t1[i] * ln->u1[i];
+	s5 += ln->u1[i] * ln->u1[i];
+    }
+    if (s0 < 0.5) return 0;
+
+    floating_exception = 0;
+    sigfpe = signal (SIGFPE, catch);
+
+/* eastings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	x0 += ln->t2[i];
+	x1 += ln->t1[i] * ln->t2[i];
+	x2 += ln->u1[i] * ln->t2[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    ln->E12[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    ln->E12[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    ln->E12[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
+
+/* northings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	x0 += ln->u2[i];
+	x1 += ln->t1[i] * ln->u2[i];
+	x2 += ln->u1[i] * ln->u2[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    ln->N12[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    ln->N12[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    ln->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 < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	s0 += 1.0;
+	s1 += ln->t2[i];
+	s2 += ln->u2[i];
+	s3 += ln->t2[i] * ln->t2[i];
+	s4 += ln->t2[i] * ln->u2[i];
+	s5 += ln->u2[i] * ln->u2[i];
+    }
+
+/* eastings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	x0 += ln->t1[i];
+	x1 += ln->t2[i] * ln->t1[i];
+	x2 += ln->u2[i] * ln->t1[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    ln->E21[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    ln->E21[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    ln->E21[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
+
+/* northings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	x0 += ln->u1[i];
+	x1 += ln->t2[i] * ln->u1[i];
+	x2 += ln->u2[i] * ln->u1[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    ln->N21[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    ln->N21[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    ln->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);
+}
+
+int georef (
+    double e1,double n1,
+    double *e2,double *n2,
+    double E[3],double N[3])
+{
+    *e2 = E[0] + E[1] * e1 + E[2] * n1;
+    *n2 = N[0] + N[1] * e1 + N[2] * n1;
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/globals.h
===================================================================
--- grass-addons/i.points.auto/globals.h	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/globals.h	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,85 +0,0 @@
-#include "defs.h"
-
-#ifndef GLOBAL
-#  define GLOBAL extern
-#  define INIT(x)
-#else
-#  define INIT(x) = x
-#endif
-
-GLOBAL struct Control_Points sPoints;
-GLOBAL struct Cell_head cellhd1;
-GLOBAL struct Cell_head cellhd2;
-
-
-
-/* Variable for the botton "Main-Menu". */
-GLOBAL int m;
-
-GLOBAL int G_get_color();
-
-GLOBAL int SCREEN_TOP;
-GLOBAL int SCREEN_BOTTOM;
-GLOBAL int SCREEN_LEFT;
-GLOBAL int SCREEN_RIGHT;
-
-GLOBAL int correlation_window_dim;
-GLOBAL int K;
-
-GLOBAL Window *INFO_WINDOW;
-GLOBAL Window *MENU_WINDOW;
-GLOBAL Window *PROMPT_WINDOW;
-
-GLOBAL View *VIEW_MAP1;
-GLOBAL View *VIEW_TITLE1;
-GLOBAL View *VIEW_MAP1_ZOOM;
-GLOBAL View *VIEW_TITLE1_ZOOM;
-
-GLOBAL View *VIEW_MAP2;
-GLOBAL View *VIEW_TITLE2;
-GLOBAL View *VIEW_MAP2_ZOOM;
-GLOBAL View *VIEW_TITLE2_ZOOM;
-
-GLOBAL View *VIEW_MENU;
-
-GLOBAL Group group;
-
-GLOBAL char interrupt_char;
-GLOBAL char *tempfile1;
-GLOBAL char *tempfile2;
-GLOBAL char *tempfile3;
-GLOBAL char *digit_points;            /* digitizer control points */
-GLOBAL char *digit_results;           /* digitizer results */
-GLOBAL int  use_digitizer INIT(0);    /* is there a digitizer out there? */
-
-/* group file list, target cell,vector files */
-GLOBAL char *group_list INIT(NULL);
-GLOBAL char *cell_list INIT(NULL);
-GLOBAL char *vect_list INIT(NULL);
-
-GLOBAL int  from_keyboard  INIT(-1);   /* input method */
-GLOBAL int  from_digitizer INIT(-1);
-GLOBAL int  from_screen    INIT(-1);
-GLOBAL int  from_flag      INIT(0);
-
-GLOBAL int  dotsize INIT(4);
-
-GLOBAL int THE_COLORS[10];
-#define BLACK	THE_COLORS[0]
-#define BLUE	THE_COLORS[1]
-#define BROWN	THE_COLORS[2]
-#define GREEN	THE_COLORS[3]
-#define GREY	THE_COLORS[4]
-#define ORANGE	THE_COLORS[5]
-#define PURPLE	THE_COLORS[6]
-#define RED	THE_COLORS[7]
-#define WHITE	THE_COLORS[8]
-#define YELLOW	THE_COLORS[9]
-
-double row_to_northing();
-double col_to_easting();
-double northing_to_row();
-double easting_to_col();
-
-#undef INIT
-

Copied: grass-addons/imagery/i.points.auto/globals.h (from rev 30335, grass-addons/i.points.auto/globals.h)
===================================================================
--- grass-addons/imagery/i.points.auto/globals.h	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/globals.h	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,85 @@
+#include "defs.h"
+
+#ifndef GLOBAL
+#  define GLOBAL extern
+#  define INIT(x)
+#else
+#  define INIT(x) = x
+#endif
+
+GLOBAL struct Control_Points sPoints;
+GLOBAL struct Cell_head cellhd1;
+GLOBAL struct Cell_head cellhd2;
+
+
+
+/* Variable for the botton "Main-Menu". */
+GLOBAL int m;
+
+GLOBAL int G_get_color();
+
+GLOBAL int SCREEN_TOP;
+GLOBAL int SCREEN_BOTTOM;
+GLOBAL int SCREEN_LEFT;
+GLOBAL int SCREEN_RIGHT;
+
+GLOBAL int correlation_window_dim;
+GLOBAL int K;
+
+GLOBAL Window *INFO_WINDOW;
+GLOBAL Window *MENU_WINDOW;
+GLOBAL Window *PROMPT_WINDOW;
+
+GLOBAL View *VIEW_MAP1;
+GLOBAL View *VIEW_TITLE1;
+GLOBAL View *VIEW_MAP1_ZOOM;
+GLOBAL View *VIEW_TITLE1_ZOOM;
+
+GLOBAL View *VIEW_MAP2;
+GLOBAL View *VIEW_TITLE2;
+GLOBAL View *VIEW_MAP2_ZOOM;
+GLOBAL View *VIEW_TITLE2_ZOOM;
+
+GLOBAL View *VIEW_MENU;
+
+GLOBAL Group group;
+
+GLOBAL char interrupt_char;
+GLOBAL char *tempfile1;
+GLOBAL char *tempfile2;
+GLOBAL char *tempfile3;
+GLOBAL char *digit_points;            /* digitizer control points */
+GLOBAL char *digit_results;           /* digitizer results */
+GLOBAL int  use_digitizer INIT(0);    /* is there a digitizer out there? */
+
+/* group file list, target cell,vector files */
+GLOBAL char *group_list INIT(NULL);
+GLOBAL char *cell_list INIT(NULL);
+GLOBAL char *vect_list INIT(NULL);
+
+GLOBAL int  from_keyboard  INIT(-1);   /* input method */
+GLOBAL int  from_digitizer INIT(-1);
+GLOBAL int  from_screen    INIT(-1);
+GLOBAL int  from_flag      INIT(0);
+
+GLOBAL int  dotsize INIT(4);
+
+GLOBAL int THE_COLORS[10];
+#define BLACK	THE_COLORS[0]
+#define BLUE	THE_COLORS[1]
+#define BROWN	THE_COLORS[2]
+#define GREEN	THE_COLORS[3]
+#define GREY	THE_COLORS[4]
+#define ORANGE	THE_COLORS[5]
+#define PURPLE	THE_COLORS[6]
+#define RED	THE_COLORS[7]
+#define WHITE	THE_COLORS[8]
+#define YELLOW	THE_COLORS[9]
+
+double row_to_northing();
+double col_to_easting();
+double northing_to_row();
+double easting_to_col();
+
+#undef INIT
+

Deleted: grass-addons/imagery/i.points.auto/graphics.c
===================================================================
--- grass-addons/i.points.auto/graphics.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/graphics.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,149 +0,0 @@
-#include "globals.h"
-#include "local_proto.h"
-#include <grass/display.h>
-#include <grass/raster.h>
-
-static View *
-makeview (double bottom, double top, double left, double right)
-{
-    View *view;
-
-    view = (View *) G_malloc (sizeof (View));
-
-    top = 100-top;
-    bottom = 100-bottom;
-
-    view->top    = SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP) * top / 100.0 ;
-    view->bottom = SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP) * bottom / 100.0 ;
-    view->left   = SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT) * left / 100.0 ;
-    view->right  = SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT) * right / 100.0 ;
-
-    if (view->top < SCREEN_TOP)
-	view->top = SCREEN_TOP;
-    if (view->bottom > SCREEN_BOTTOM)
-	view->bottom = SCREEN_BOTTOM;
-    if (view->left < SCREEN_LEFT)
-	view->left = SCREEN_LEFT;
-    if (view->right > SCREEN_RIGHT)
-	view->right = SCREEN_RIGHT;
-
-    Outline_box (view->top, view->bottom, view->left, view->right);
-
-    view->top++;
-    view->bottom--;
-    view->left++;
-    view->right--;
-
-    view->nrows = view->bottom - view->top + 1;
-    view->ncols = view->right - view->left + 1;
-    view->cell.configured = 0;
-
-    return view;
-}
-
-int 
-Init_graphics (void)
-{
-    D_full_screen();
-
-
-    SCREEN_TOP    = R_screen_top();
-    SCREEN_BOTTOM = R_screen_bot();
-    SCREEN_LEFT   = R_screen_left();
-    SCREEN_RIGHT  = R_screen_rite();
-
-
-    BLACK  = D_translate_color ("black");
-    BLUE   = D_translate_color ("blue");
-    BROWN  = D_translate_color ("brown");
-    GREEN  = D_translate_color ("green");
-    GREY   = D_translate_color ("grey");
-    ORANGE = D_translate_color ("orange");
-    PURPLE = D_translate_color ("purple");
-    RED    = D_translate_color ("red");
-    WHITE  = D_translate_color ("white");
-    YELLOW = D_translate_color ("yellow");
-
-    R_standard_color (WHITE);
-
-    VIEW_TITLE1      = makeview (97.5, 100.0,  0.0,  50.0);
-    VIEW_TITLE2      = makeview (97.5, 100.0, 50.0, 100.0);
-    VIEW_MAP1        = makeview (51.0,  97.5,  0.0,  50.0);
-    VIEW_MAP2        = makeview (51.0,  97.5, 50.0, 100.0);
-    VIEW_TITLE1_ZOOM = makeview (47.5,  51.0,  0.0,  50.0);
-    VIEW_TITLE2_ZOOM = makeview (47.5,  51.0, 50.0, 100.0);
-    VIEW_MAP1_ZOOM   = makeview (2.5,   47.5,  0.0,  50.0);
-    VIEW_MAP2_ZOOM   = makeview (2.5,   47.5, 50.0, 100.0);
-    VIEW_MENU        = makeview (0.0,    2.5,  0.0, 100.0);
-
-    G_init_colors (&VIEW_MAP1->cell.colors);
-    G_init_colors (&VIEW_MAP2->cell.colors);
-
-    Erase_view (VIEW_MAP1);
-    Erase_view (VIEW_MAP1_ZOOM);
-    Erase_view (VIEW_MAP2);
-    Erase_view (VIEW_MAP2_ZOOM);
-
-    return 0;
-}
-
-int 
-Outline_box (int top, int bottom, int left, int right)
-{
-    R_move_abs (left,  top);
-    R_cont_abs (left,  bottom);
-    R_cont_abs (right, bottom);
-    R_cont_abs (right, top);
-    R_cont_abs (left,  top);
-
-    return 0;
-}
-
-
-int 
-Text_width (char *text)
-{
-    int top, bottom, left, right;
-
-    R_get_text_box (text, &top, &bottom, &left, &right);
-
-    if (right > left)
-	return right-left+1;
-    else
-	return left-right+1;
-}
-
-int 
-Text (char *text, int top, int bottom, int left, int right, int edge)
-{
-    R_set_window (top, bottom, left, right);
-    R_move_abs (left+edge, bottom-edge);
-    R_text (text);
-    R_set_window (SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
-
-    return 0;
-}
-
-int 
-Uparrow (int top, int bottom, int left, int right)
-{
-    R_move_abs ((left+right)/2, bottom);
-    R_cont_abs ((left+right)/2, top);
-    R_cont_rel ((left-right)/2, (bottom-top)/2);
-    R_move_abs ((left+right)/2, top);
-    R_cont_rel ((right-left)/2, (bottom-top)/2);
-
-    return 0;
-}
-
-int 
-Downarrow (int top, int bottom, int left, int right)
-{
-    R_move_abs ((left+right)/2, top);
-    R_cont_abs ((left+right)/2, bottom);
-    R_cont_rel ((left-right)/2, (top-bottom)/2);
-    R_move_abs ((left+right)/2, bottom);
-    R_cont_rel ((right-left)/2, (top-bottom)/2);
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/graphics.c (from rev 30335, grass-addons/i.points.auto/graphics.c)
===================================================================
--- grass-addons/imagery/i.points.auto/graphics.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/graphics.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,149 @@
+#include "globals.h"
+#include "local_proto.h"
+#include <grass/display.h>
+#include <grass/raster.h>
+
+static View *
+makeview (double bottom, double top, double left, double right)
+{
+    View *view;
+
+    view = (View *) G_malloc (sizeof (View));
+
+    top = 100-top;
+    bottom = 100-bottom;
+
+    view->top    = SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP) * top / 100.0 ;
+    view->bottom = SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP) * bottom / 100.0 ;
+    view->left   = SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT) * left / 100.0 ;
+    view->right  = SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT) * right / 100.0 ;
+
+    if (view->top < SCREEN_TOP)
+	view->top = SCREEN_TOP;
+    if (view->bottom > SCREEN_BOTTOM)
+	view->bottom = SCREEN_BOTTOM;
+    if (view->left < SCREEN_LEFT)
+	view->left = SCREEN_LEFT;
+    if (view->right > SCREEN_RIGHT)
+	view->right = SCREEN_RIGHT;
+
+    Outline_box (view->top, view->bottom, view->left, view->right);
+
+    view->top++;
+    view->bottom--;
+    view->left++;
+    view->right--;
+
+    view->nrows = view->bottom - view->top + 1;
+    view->ncols = view->right - view->left + 1;
+    view->cell.configured = 0;
+
+    return view;
+}
+
+int 
+Init_graphics (void)
+{
+    D_full_screen();
+
+
+    SCREEN_TOP    = R_screen_top();
+    SCREEN_BOTTOM = R_screen_bot();
+    SCREEN_LEFT   = R_screen_left();
+    SCREEN_RIGHT  = R_screen_rite();
+
+
+    BLACK  = D_translate_color ("black");
+    BLUE   = D_translate_color ("blue");
+    BROWN  = D_translate_color ("brown");
+    GREEN  = D_translate_color ("green");
+    GREY   = D_translate_color ("grey");
+    ORANGE = D_translate_color ("orange");
+    PURPLE = D_translate_color ("purple");
+    RED    = D_translate_color ("red");
+    WHITE  = D_translate_color ("white");
+    YELLOW = D_translate_color ("yellow");
+
+    R_standard_color (WHITE);
+
+    VIEW_TITLE1      = makeview (97.5, 100.0,  0.0,  50.0);
+    VIEW_TITLE2      = makeview (97.5, 100.0, 50.0, 100.0);
+    VIEW_MAP1        = makeview (51.0,  97.5,  0.0,  50.0);
+    VIEW_MAP2        = makeview (51.0,  97.5, 50.0, 100.0);
+    VIEW_TITLE1_ZOOM = makeview (47.5,  51.0,  0.0,  50.0);
+    VIEW_TITLE2_ZOOM = makeview (47.5,  51.0, 50.0, 100.0);
+    VIEW_MAP1_ZOOM   = makeview (2.5,   47.5,  0.0,  50.0);
+    VIEW_MAP2_ZOOM   = makeview (2.5,   47.5, 50.0, 100.0);
+    VIEW_MENU        = makeview (0.0,    2.5,  0.0, 100.0);
+
+    G_init_colors (&VIEW_MAP1->cell.colors);
+    G_init_colors (&VIEW_MAP2->cell.colors);
+
+    Erase_view (VIEW_MAP1);
+    Erase_view (VIEW_MAP1_ZOOM);
+    Erase_view (VIEW_MAP2);
+    Erase_view (VIEW_MAP2_ZOOM);
+
+    return 0;
+}
+
+int 
+Outline_box (int top, int bottom, int left, int right)
+{
+    R_move_abs (left,  top);
+    R_cont_abs (left,  bottom);
+    R_cont_abs (right, bottom);
+    R_cont_abs (right, top);
+    R_cont_abs (left,  top);
+
+    return 0;
+}
+
+
+int 
+Text_width (char *text)
+{
+    int top, bottom, left, right;
+
+    R_get_text_box (text, &top, &bottom, &left, &right);
+
+    if (right > left)
+	return right-left+1;
+    else
+	return left-right+1;
+}
+
+int 
+Text (char *text, int top, int bottom, int left, int right, int edge)
+{
+    R_set_window (top, bottom, left, right);
+    R_move_abs (left+edge, bottom-edge);
+    R_text (text);
+    R_set_window (SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
+
+    return 0;
+}
+
+int 
+Uparrow (int top, int bottom, int left, int right)
+{
+    R_move_abs ((left+right)/2, bottom);
+    R_cont_abs ((left+right)/2, top);
+    R_cont_rel ((left-right)/2, (bottom-top)/2);
+    R_move_abs ((left+right)/2, top);
+    R_cont_rel ((right-left)/2, (bottom-top)/2);
+
+    return 0;
+}
+
+int 
+Downarrow (int top, int bottom, int left, int right)
+{
+    R_move_abs ((left+right)/2, top);
+    R_cont_abs ((left+right)/2, bottom);
+    R_cont_rel ((left-right)/2, (top-bottom)/2);
+    R_move_abs ((left+right)/2, bottom);
+    R_cont_rel ((right-left)/2, (top-bottom)/2);
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/group.c
===================================================================
--- grass-addons/i.points.auto/group.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/group.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,70 +0,0 @@
-#include <string.h>
-#include <stdlib.h>
-#include <grass/gis.h>
-#include "globals.h"
-#include "local_proto.h"
-
-static int cmp(const void *, const void *);
-
-int prepare_group_list (void)
-{
-    FILE *fd;
-    int *idx;
-    int n;
-    int len,len1,len2;
-
-/* open file to store group file names */
-    fd = fopen (group_list, "w");
-    if (fd == NULL)
-	G_fatal_error ("Can't open any tempfiles");
-
-/*
- * build sorted index into group files
- * so that all cell files for a mapset to appear together
- */
-    idx = (int *) G_calloc (group.ref.nfiles, sizeof (int));
-    for (n = 0; n < group.ref.nfiles; n++)
-	idx[n] = n;
-    qsort (idx, group.ref.nfiles, sizeof(int), cmp);
-
-/* determine length of longest mapset name, and longest cell file name */
-    len1 = len2 = 0;
-    for (n = 0; n < group.ref.nfiles; n++)
-    {
-	len = strlen (group.ref.file[n].name);
-	if (len > len1)
-	    len1 = len;
-	len = strlen (group.ref.file[n].mapset);
-	if (len > len2)
-	    len2 = len;
-    }
-
-/* write lengths, names to file */
-    fwrite (&len1, sizeof (len1), 1, fd);
-    fwrite (&len2, sizeof (len2), 1, fd);
-    for (n = 0; n < group.ref.nfiles; n++)
-	fprintf (fd, "%s %s\n", group.ref.file[idx[n]].name, group.ref.file[idx[n]].mapset);
-    fclose (fd);
-
-    G_free (idx);
-
-    return 0;
-}
-
-static int cmp (const void *aa, const void *bb)
-{
-    const int *a = aa, *b = bb;
-    int n;
-
-    if(n = strcmp (group.ref.file[*a].mapset, group.ref.file[*b].mapset))
-	return n;
-    return strcmp (group.ref.file[*a].name, group.ref.file[*b].name);
-}
-
-/* ask the user to pick a file */
-int choose_groupfile (char *name,char *mapset)
-{
-    int stat;
-    stat = ask_gis_files ("raster", group_list, name, mapset, -1);
-    return(stat);
-}

Copied: grass-addons/imagery/i.points.auto/group.c (from rev 30335, grass-addons/i.points.auto/group.c)
===================================================================
--- grass-addons/imagery/i.points.auto/group.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/group.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,70 @@
+#include <string.h>
+#include <stdlib.h>
+#include <grass/gis.h>
+#include "globals.h"
+#include "local_proto.h"
+
+static int cmp(const void *, const void *);
+
+int prepare_group_list (void)
+{
+    FILE *fd;
+    int *idx;
+    int n;
+    int len,len1,len2;
+
+/* open file to store group file names */
+    fd = fopen (group_list, "w");
+    if (fd == NULL)
+	G_fatal_error ("Can't open any tempfiles");
+
+/*
+ * build sorted index into group files
+ * so that all cell files for a mapset to appear together
+ */
+    idx = (int *) G_calloc (group.ref.nfiles, sizeof (int));
+    for (n = 0; n < group.ref.nfiles; n++)
+	idx[n] = n;
+    qsort (idx, group.ref.nfiles, sizeof(int), cmp);
+
+/* determine length of longest mapset name, and longest cell file name */
+    len1 = len2 = 0;
+    for (n = 0; n < group.ref.nfiles; n++)
+    {
+	len = strlen (group.ref.file[n].name);
+	if (len > len1)
+	    len1 = len;
+	len = strlen (group.ref.file[n].mapset);
+	if (len > len2)
+	    len2 = len;
+    }
+
+/* write lengths, names to file */
+    fwrite (&len1, sizeof (len1), 1, fd);
+    fwrite (&len2, sizeof (len2), 1, fd);
+    for (n = 0; n < group.ref.nfiles; n++)
+	fprintf (fd, "%s %s\n", group.ref.file[idx[n]].name, group.ref.file[idx[n]].mapset);
+    fclose (fd);
+
+    G_free (idx);
+
+    return 0;
+}
+
+static int cmp (const void *aa, const void *bb)
+{
+    const int *a = aa, *b = bb;
+    int n;
+
+    if(n = strcmp (group.ref.file[*a].mapset, group.ref.file[*b].mapset))
+	return n;
+    return strcmp (group.ref.file[*a].name, group.ref.file[*b].name);
+}
+
+/* ask the user to pick a file */
+int choose_groupfile (char *name,char *mapset)
+{
+    int stat;
+    stat = ask_gis_files ("raster", group_list, name, mapset, -1);
+    return(stat);
+}

Deleted: grass-addons/imagery/i.points.auto/input.c
===================================================================
--- grass-addons/i.points.auto/input.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/input.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,296 +0,0 @@
-#include <string.h>
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-
-static int active = 0;
-static int replot;
-static int mouse (Objects *,int,int,int);
-static int use_mouse_msg(void);
-static int draw_objects (Objects *);
-static Objects *find (Objects *,int, int);
-static int select_option (Objects *,Objects *);
-static int draw_option_boxes (Objects *);
-static int visible( Objects *);
-
-#define TEXT_COLOR ORANGE /*WHITE*/      
-#define FILL_COLOR BLACK /*BLUE*/      
-#define OUTLINE_COLOR RED 
-
-/* Input: drive mouse. returns status of handler that returns != 0 */
-int Input_pointer (Objects *objects)
-{
-  return mouse (objects,0,0,0);
-}
-
-int Input_box (Objects *objects,int ax,int ay)
-{
-    return mouse (objects,ax,ay,1);
-}
-
-int Input_other (int (*function)(), char *type)
-{
-    int stat;
-    char msg[1024];
-
-    sprintf (msg, "%s input required", type);
-    Menu_msg(msg);
-
-    stat = (*function)();
-    if (active)
-    {
-	use_mouse_msg();
-    }
-
-    Menu_msg("");
-    return stat;
-}
-
-static int mouse (Objects *objects,int ax,int ay,int box)
-{
-    int first;
-    int stat;
-    int x,y,button;
-    Objects *obj;
-    Objects *find();
-
-       
-    first = !active;
-    active = 1;
-    if (first)
-	use_mouse_msg();
-
-    if (box)
-    {
-	x = ax + 20;
-	y = ay + 20;
-    }
-    stat = 0;
-    replot = 1;
-    while (stat == 0)
-    {
-
-     
-      draw_objects (objects); 
-	    
-      if (box)
-	Mouse_box_anchored (ax, ay, &x, &y, &button) ;
-      else
-	Mouse_pointer (&x, &y, &button) ;
-      
-      if (!(obj = find (objects, x, y)))
-	continue;
-      
-      
-      
-      switch (obj->type)
-	{
-	case MENU_OBJECT:
-	case OTHER_OBJECT:
-	  stat = (*obj->handler)(x,y,button);
-	  break;
-	case OPTION_OBJECT:
-	  select_option (objects, obj);
-	  draw_option_boxes(objects);
-	  break;
-	}
-	
-
-	/*This expression is necessary for the button "Main-Menu". */
-	if(m!=0)
-	  return -1;
-	 
-
-    }
-
-/* if we are first call, mark not active
- * indicate that objects above use must be replotted.
- */
-    if (first)
-	active = 0;
-    Menu_msg("");
-
-
-    return stat;
-}
-
-
-static int
-use_mouse_msg (void)
-{
-    Curses_write_window (PROMPT_WINDOW, 1, 1, "Use mouse now ...\n");
-
-    return 0;
-}
-
-static int draw_objects (Objects *objects)
-{
-    Objects *obj;
-    int top, bottom, left, right;
-    int size, edge;
-
-
-/* erase the menu window */
-    Erase_view (VIEW_MENU);
-    R_flush();
-
-/* determine sizes and text indentation */
-    size = VIEW_MENU->nrows - 4;                    /* TEXT-SIZE FOR THE BUTTONS */
-    edge = 2; 
-
-    R_text_size (size, size);
-
-    left  = VIEW_MENU->left;
-    top   = VIEW_MENU->top;
-    bottom  = VIEW_MENU->bottom;
-
-
-/* put the (boxed) text on the menu view */
-    for (obj = objects; obj->type; obj++)
-    {
-	if (!visible(obj))
-	    continue;
-	switch (obj->type)
-	{
-	case OPTION_OBJECT:
-	case MENU_OBJECT:
-		right = left + 2*edge + Text_width (obj->label);
-		if(!strcmp(obj->label,"LINE")){
-                                        obj->left = left+1;
-		obj->right = right+1;
-                                    } else {
-                                          obj->left = left;
-		       obj->right = right;
-
-                                        }
-
-		obj->top = top;
-		obj->bottom = bottom;
-
-		R_standard_color (FILL_COLOR);
-		R_box_abs (left, top, right, bottom);
-
-		R_standard_color (TEXT_COLOR);
-		Text (obj->label, top, bottom, left, right, edge);
-
-                                   if(!strcmp(obj->label,"LINE"))
-                                       R_standard_color(BLUE);
-                                   else R_standard_color (OUTLINE_COLOR);
-		Outline_box (top, bottom, left, right);
-
-		left = right;
-		break;
-
-	case INFO_OBJECT:
-		if (*obj->label == 0) break;
-		if (*obj->status < 0) break;
-		right = left + 2*edge + Text_width (obj->label);
-		R_standard_color (WHITE);
-		Text (obj->label, top, bottom, left, right, edge);
-
-		left = right;
-		break;
-	}
-    }
-    draw_option_boxes (objects);
-    R_flush();
-
-    return 0;
-}
-
-static Objects *find (Objects *objects,int x, int y)
-{
-    Objects *other;
-    other = NULL;
-    for (; objects->type; objects++)
-    {
-	if (!visible (objects))
-	    continue;
-	switch (objects->type)
-	{
-	case MENU_OBJECT:
-	case OPTION_OBJECT:
-	    if (x >= objects->left && x <= objects->right
-	    &&  y >= objects->top  && y <= objects->bottom)
-		    return objects;
-	    break;
-	case OTHER_OBJECT:
-	    other = objects;
-	    break;
-	}
-    }
-    return other;
-}
-
-static int select_option (Objects *objects,Objects *obj)
-{
-    while (objects->type)
-    {
-	if (objects->type == OPTION_OBJECT && *objects->status >= 0 &&
-	    objects->binding == obj->binding)
-		*objects->status = 0;
-	objects++;
-    }
-    *obj->status = 1;
-
-    return 0;
-}
-
-static int draw_option_boxes (Objects *objects)
-{
-    Objects *x;
-
-    R_standard_color (OUTLINE_COLOR);
-    for (x = objects; x->type; x++)
-    {
-	if (x->type == OPTION_OBJECT && *x->status == 0)
-	    Outline_box (x->top, x->bottom, x->left, x->right);
-    }
-    R_standard_color (GREEN);
-    for (x = objects; x->type; x++)
-    {
-	if (x->type == OPTION_OBJECT && *x->status > 0)
-	    Outline_box (x->top, x->bottom, x->left, x->right);
-    }
-
-    return 0;
-}
-
-static int visible( Objects *object)
-{
-    if (object->type == OPTION_OBJECT)
-	return (*object->status >= 0);
-    return (*object->status > 0);
-}
-
-int Menu_msg(char *msg)
-{
-    int size, edge;
-
-    size = VIEW_MENU->nrows - 4;
-    edge = 2;
-
-    Erase_view (VIEW_MENU);
-
-    if (*msg)
-    {
-	R_text_size (size, size);
-	R_standard_color (WHITE);
-	Text (msg, VIEW_MENU->top, VIEW_MENU->bottom,
-		   VIEW_MENU->left, VIEW_MENU->right, edge);
-    }
-    R_flush();
-    replot = 1;
-
-    return 0;
-}
-
-int 
-Start_mouse_in_menu (void)
-{
-    Set_mouse_xy (
-	(VIEW_MENU->left+2*VIEW_MENU->right)/3,
-	(VIEW_MENU->top+VIEW_MENU->bottom)/2);
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/input.c (from rev 30335, grass-addons/i.points.auto/input.c)
===================================================================
--- grass-addons/imagery/i.points.auto/input.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/input.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,296 @@
+#include <string.h>
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+
+static int active = 0;
+static int replot;
+static int mouse (Objects *,int,int,int);
+static int use_mouse_msg(void);
+static int draw_objects (Objects *);
+static Objects *find (Objects *,int, int);
+static int select_option (Objects *,Objects *);
+static int draw_option_boxes (Objects *);
+static int visible( Objects *);
+
+#define TEXT_COLOR ORANGE /*WHITE*/      
+#define FILL_COLOR BLACK /*BLUE*/      
+#define OUTLINE_COLOR RED 
+
+/* Input: drive mouse. returns status of handler that returns != 0 */
+int Input_pointer (Objects *objects)
+{
+  return mouse (objects,0,0,0);
+}
+
+int Input_box (Objects *objects,int ax,int ay)
+{
+    return mouse (objects,ax,ay,1);
+}
+
+int Input_other (int (*function)(), char *type)
+{
+    int stat;
+    char msg[1024];
+
+    sprintf (msg, "%s input required", type);
+    Menu_msg(msg);
+
+    stat = (*function)();
+    if (active)
+    {
+	use_mouse_msg();
+    }
+
+    Menu_msg("");
+    return stat;
+}
+
+static int mouse (Objects *objects,int ax,int ay,int box)
+{
+    int first;
+    int stat;
+    int x,y,button;
+    Objects *obj;
+    Objects *find();
+
+       
+    first = !active;
+    active = 1;
+    if (first)
+	use_mouse_msg();
+
+    if (box)
+    {
+	x = ax + 20;
+	y = ay + 20;
+    }
+    stat = 0;
+    replot = 1;
+    while (stat == 0)
+    {
+
+     
+      draw_objects (objects); 
+	    
+      if (box)
+	Mouse_box_anchored (ax, ay, &x, &y, &button) ;
+      else
+	Mouse_pointer (&x, &y, &button) ;
+      
+      if (!(obj = find (objects, x, y)))
+	continue;
+      
+      
+      
+      switch (obj->type)
+	{
+	case MENU_OBJECT:
+	case OTHER_OBJECT:
+	  stat = (*obj->handler)(x,y,button);
+	  break;
+	case OPTION_OBJECT:
+	  select_option (objects, obj);
+	  draw_option_boxes(objects);
+	  break;
+	}
+	
+
+	/*This expression is necessary for the button "Main-Menu". */
+	if(m!=0)
+	  return -1;
+	 
+
+    }
+
+/* if we are first call, mark not active
+ * indicate that objects above use must be replotted.
+ */
+    if (first)
+	active = 0;
+    Menu_msg("");
+
+
+    return stat;
+}
+
+
+static int
+use_mouse_msg (void)
+{
+    Curses_write_window (PROMPT_WINDOW, 1, 1, "Use mouse now ...\n");
+
+    return 0;
+}
+
+static int draw_objects (Objects *objects)
+{
+    Objects *obj;
+    int top, bottom, left, right;
+    int size, edge;
+
+
+/* erase the menu window */
+    Erase_view (VIEW_MENU);
+    R_flush();
+
+/* determine sizes and text indentation */
+    size = VIEW_MENU->nrows - 4;                    /* TEXT-SIZE FOR THE BUTTONS */
+    edge = 2; 
+
+    R_text_size (size, size);
+
+    left  = VIEW_MENU->left;
+    top   = VIEW_MENU->top;
+    bottom  = VIEW_MENU->bottom;
+
+
+/* put the (boxed) text on the menu view */
+    for (obj = objects; obj->type; obj++)
+    {
+	if (!visible(obj))
+	    continue;
+	switch (obj->type)
+	{
+	case OPTION_OBJECT:
+	case MENU_OBJECT:
+		right = left + 2*edge + Text_width (obj->label);
+		if(!strcmp(obj->label,"LINE")){
+                                        obj->left = left+1;
+		obj->right = right+1;
+                                    } else {
+                                          obj->left = left;
+		       obj->right = right;
+
+                                        }
+
+		obj->top = top;
+		obj->bottom = bottom;
+
+		R_standard_color (FILL_COLOR);
+		R_box_abs (left, top, right, bottom);
+
+		R_standard_color (TEXT_COLOR);
+		Text (obj->label, top, bottom, left, right, edge);
+
+                                   if(!strcmp(obj->label,"LINE"))
+                                       R_standard_color(BLUE);
+                                   else R_standard_color (OUTLINE_COLOR);
+		Outline_box (top, bottom, left, right);
+
+		left = right;
+		break;
+
+	case INFO_OBJECT:
+		if (*obj->label == 0) break;
+		if (*obj->status < 0) break;
+		right = left + 2*edge + Text_width (obj->label);
+		R_standard_color (WHITE);
+		Text (obj->label, top, bottom, left, right, edge);
+
+		left = right;
+		break;
+	}
+    }
+    draw_option_boxes (objects);
+    R_flush();
+
+    return 0;
+}
+
+static Objects *find (Objects *objects,int x, int y)
+{
+    Objects *other;
+    other = NULL;
+    for (; objects->type; objects++)
+    {
+	if (!visible (objects))
+	    continue;
+	switch (objects->type)
+	{
+	case MENU_OBJECT:
+	case OPTION_OBJECT:
+	    if (x >= objects->left && x <= objects->right
+	    &&  y >= objects->top  && y <= objects->bottom)
+		    return objects;
+	    break;
+	case OTHER_OBJECT:
+	    other = objects;
+	    break;
+	}
+    }
+    return other;
+}
+
+static int select_option (Objects *objects,Objects *obj)
+{
+    while (objects->type)
+    {
+	if (objects->type == OPTION_OBJECT && *objects->status >= 0 &&
+	    objects->binding == obj->binding)
+		*objects->status = 0;
+	objects++;
+    }
+    *obj->status = 1;
+
+    return 0;
+}
+
+static int draw_option_boxes (Objects *objects)
+{
+    Objects *x;
+
+    R_standard_color (OUTLINE_COLOR);
+    for (x = objects; x->type; x++)
+    {
+	if (x->type == OPTION_OBJECT && *x->status == 0)
+	    Outline_box (x->top, x->bottom, x->left, x->right);
+    }
+    R_standard_color (GREEN);
+    for (x = objects; x->type; x++)
+    {
+	if (x->type == OPTION_OBJECT && *x->status > 0)
+	    Outline_box (x->top, x->bottom, x->left, x->right);
+    }
+
+    return 0;
+}
+
+static int visible( Objects *object)
+{
+    if (object->type == OPTION_OBJECT)
+	return (*object->status >= 0);
+    return (*object->status > 0);
+}
+
+int Menu_msg(char *msg)
+{
+    int size, edge;
+
+    size = VIEW_MENU->nrows - 4;
+    edge = 2;
+
+    Erase_view (VIEW_MENU);
+
+    if (*msg)
+    {
+	R_text_size (size, size);
+	R_standard_color (WHITE);
+	Text (msg, VIEW_MENU->top, VIEW_MENU->bottom,
+		   VIEW_MENU->left, VIEW_MENU->right, edge);
+    }
+    R_flush();
+    replot = 1;
+
+    return 0;
+}
+
+int 
+Start_mouse_in_menu (void)
+{
+    Set_mouse_xy (
+	(VIEW_MENU->left+2*VIEW_MENU->right)/3,
+	(VIEW_MENU->top+VIEW_MENU->bottom)/2);
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/line.c
===================================================================
--- grass-addons/i.points.auto/line.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/line.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,226 +0,0 @@
-#include <grass/gis.h>
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-
-static int cancel();
-static int select(int x1,int y1,int button);
-
-
-double temp_e1,temp_e2,temp_n1,temp_n2;
-static int flag;
-void find_position (int *x1, int *x2,int *y1,int *y2);
-int xtemp[2],ytemp[2], first_linex[2],first_liney[2];
-
-int
-line (void)
-{
-    int stat,row,col,i;
-    static int use = 1;
-    double e1,e2,e3,e4,n1,n2,n3,n4;
-    static Objects objects1[]=
-    {
-	MENU("CANCEL",cancel,&use),
-	INFO("select first line (left side) ",&use),
-                 OTHER(select, &use),
-	{0}
-    };
-
-     static Objects objects2[]=
-    {
-	MENU("CANCEL",cancel,&use),
-	INFO("select second line (right side) ",&use),
-                 OTHER(select, &use),
-	{0}
-    };
-
-
-    flag =0;
-    stat= Input_pointer (objects1);
-    if (stat==-1) return 0;
-
-    e1=temp_e1;
-    e2=temp_e2;
-    n1=temp_n1;
-    n2=temp_n2;
-    flag = 1;
-
-    for (i=0;i<2;i++)
-        {
-         first_linex[i]=xtemp[i];
-         first_liney[i]=ytemp[i];
-          }
-
-    stat=Input_pointer (objects2);
-     if (stat==-1)
-    {
-         R_panel_restore (tempfile2);   /* serve al ripristino del quadrato che contiene la linea collogante i 2 punti */
-         R_panel_restore (tempfile3);    /*  serve al ripristino del secondo punto*/
-         R_panel_restore (tempfile1);    /*  serve al ripristino del primo punto*/
-         R_panel_delete (tempfile1);
-         R_panel_delete (tempfile2);
-         R_panel_delete (tempfile3);
-
-         return 0;
-    }
-
-
-    e3=temp_e1;
-    e4=temp_e2;
-    n3=temp_n1;
-    n4=temp_n2;
-     I_new_control_point (&group.points, e1, n1, e3, n3, 2);
-     I_put_control_points (group.name, &group.points);
-     Compute_equation();
-     display_points(1) ;
-     I_new_control_point (&group.points, e2, n2, e4, n4, 3);
-     I_put_control_points (group.name, &group.points);
-     Compute_equation();
-     display_points(1) ;
-     R_standard_color (GREEN);
-     R_polyline_abs (first_linex ,first_liney,2);
-     R_polyline_abs (xtemp ,ytemp,2);
-     R_flush();
-
-    return 0;	/* return, but don't QUIT */
-}
-
-static int select(int x,int y,int button)
-{
-        if (button != 1)
-          return where (x,y);
-
-        if (flag==0) {
-                                         if (VIEW_MAP1->cell.configured && In_view (VIEW_MAP1, x, y))
-                                                select_line (VIEW_MAP1, x, y);
-                                        else if (VIEW_MAP1_ZOOM->cell.configured && In_view (VIEW_MAP1_ZOOM, x, y))
-                                                select_line (VIEW_MAP1_ZOOM, x, y);
-                                        else return 0;
-                                     }
-         if (flag==1) {
-                                        if (VIEW_MAP2->cell.configured && In_view (VIEW_MAP2, x, y))
-                                                select_line (VIEW_MAP2, x, y);
-                                        else if (VIEW_MAP2_ZOOM->cell.configured && In_view (VIEW_MAP2_ZOOM, x, y))
-                                                select_line (VIEW_MAP2_ZOOM, x, y);
-                                         else return 0;
-                                      }
-          return 1 ; /* return but don't quit */
-
-};
-
-int select_line (View *view,int x1, int y1)
-{
-    int col, row;
-    int x2,y2,button=0;
-    char buf[50];
-
-
-
-    col = view_to_col (view, x1);
-    temp_e1 = col_to_easting (&view->cell.head, col, 0.5);
-    row = view_to_row (view, y1);
-    temp_n1 = row_to_northing (&view->cell.head, row, 0.5);
-
-    if (flag== 0)
-                {
-                         Curses_clear_window (INFO_WINDOW);
-                         Curses_clear_window (MENU_WINDOW);
-                         sprintf (buf, "Point  %d marked on image at", group.points.count+1);
-                         Curses_write_window (MENU_WINDOW, 1, 1, buf);
-                         sprintf (buf, "East:  %10.2f", temp_e1);
-                         Curses_write_window (MENU_WINDOW, 3, 3, buf);
-                         sprintf (buf, "North: %10.2f", temp_n1);
-                         Curses_write_window (MENU_WINDOW, 4, 3, buf);
-                }
-     else
-              {
-
-                         sprintf (buf, "Point  %d marked on target image at", group.points.count+1);
-                         Curses_write_window (INFO_WINDOW, 1, 1, buf);
-                         sprintf (buf, "East:  %10.2f",temp_e1);
-                         Curses_write_window (INFO_WINDOW, 3, 3, buf);
-                         sprintf (buf, "North: %10.2f", temp_n1);
-                         Curses_write_window (INFO_WINDOW, 4, 3, buf);
-               }
-
-    R_standard_color (ORANGE);
-    R_panel_save (tempfile1, y1-dotsize, y1+dotsize, x1-dotsize, x1+dotsize);
-     dot(x1,y1);
-
-         while (button!=1)
-        {
-        R_get_location_with_line (x1,y1,&x2,&y2,&button);
-        if( button!=1)
-            where (x2,y2);
-         if (!(view->cell.configured && In_view (view, x2, y2)))
-                                  button=0;
-          }
-
-    col = view_to_col (view, x2);
-   temp_e2 = col_to_easting (&view->cell.head, col, 0.5);
-    row = view_to_row (view, y2);
-    temp_n2 = row_to_northing (&view->cell.head, row, 0.5);
-
-   if (flag== 0)
-                {
-                         sprintf (buf, "Point  %d marked on image at", group.points.count+2);
-                         Curses_write_window (MENU_WINDOW, 6, 1, buf);
-                         sprintf (buf, "East:  %10.2f", temp_e2);
-                         Curses_write_window (MENU_WINDOW, 8, 3, buf);
-                         sprintf (buf, "North: %10.2f", temp_n2);
-                         Curses_write_window (MENU_WINDOW, 9, 3, buf);
-                  }
-     else
-              {
-                         sprintf (buf, "Point  %d marked on target image at", group.points.count+2);
-                         Curses_write_window (INFO_WINDOW, 6, 1, buf);
-                         sprintf (buf, "East:  %10.2f",temp_e2);
-                         Curses_write_window (INFO_WINDOW, 8, 3, buf);
-                         sprintf (buf, "North: %10.2f", temp_n2);
-                         Curses_write_window (INFO_WINDOW, 9, 3, buf);
-                 }
-
-    R_standard_color (ORANGE);
-    R_panel_save (tempfile3, y2-dotsize, y2+dotsize, x2-dotsize, x2+dotsize);
-     dot(x2,y2);
-
-     xtemp[0]= x1;
-     xtemp[1]= x2;
-     ytemp[0]= y1;
-     ytemp[1]= y2;
-
-    find_position (&x1,&x2,&y1,&y2);
-    R_panel_save (tempfile2, y1, y2, x1, x2);
-    R_polyline_abs (xtemp ,ytemp,2);
-
-    return 1 ;
-
- }
-
- void find_position (int *x1, int *x2,int *y1,int *y2)
-  { int temp;
-    if (*y2<*y1) {
-                         temp=*y1;
-                         *y1=*y2;
-                         *y2= temp;
-                         }
-     else if (*y2==*y1) { *y2= *y2+dotsize;
-                                  *y1= *y1 - dotsize ;
-                                  }
-     if (*x2<*x1) {
-                         temp=*x1;
-                         *x1=*x2;
-                         *x2= temp;
-                         }
-     else if (*x2==*x1) { *x2= *x2+dotsize;
-                                  *x1= *x1 - dotsize ;
-                                  }
- }
-
-
-   static int cancel()
- {
-    return -1 ;
-}
-
-

Copied: grass-addons/imagery/i.points.auto/line.c (from rev 30335, grass-addons/i.points.auto/line.c)
===================================================================
--- grass-addons/imagery/i.points.auto/line.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/line.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,226 @@
+#include <grass/gis.h>
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+
+static int cancel();
+static int select(int x1,int y1,int button);
+
+
+double temp_e1,temp_e2,temp_n1,temp_n2;
+static int flag;
+void find_position (int *x1, int *x2,int *y1,int *y2);
+int xtemp[2],ytemp[2], first_linex[2],first_liney[2];
+
+int
+line (void)
+{
+    int stat,row,col,i;
+    static int use = 1;
+    double e1,e2,e3,e4,n1,n2,n3,n4;
+    static Objects objects1[]=
+    {
+	MENU("CANCEL",cancel,&use),
+	INFO("select first line (left side) ",&use),
+                 OTHER(select, &use),
+	{0}
+    };
+
+     static Objects objects2[]=
+    {
+	MENU("CANCEL",cancel,&use),
+	INFO("select second line (right side) ",&use),
+                 OTHER(select, &use),
+	{0}
+    };
+
+
+    flag =0;
+    stat= Input_pointer (objects1);
+    if (stat==-1) return 0;
+
+    e1=temp_e1;
+    e2=temp_e2;
+    n1=temp_n1;
+    n2=temp_n2;
+    flag = 1;
+
+    for (i=0;i<2;i++)
+        {
+         first_linex[i]=xtemp[i];
+         first_liney[i]=ytemp[i];
+          }
+
+    stat=Input_pointer (objects2);
+     if (stat==-1)
+    {
+         R_panel_restore (tempfile2);   /* serve al ripristino del quadrato che contiene la linea collogante i 2 punti */
+         R_panel_restore (tempfile3);    /*  serve al ripristino del secondo punto*/
+         R_panel_restore (tempfile1);    /*  serve al ripristino del primo punto*/
+         R_panel_delete (tempfile1);
+         R_panel_delete (tempfile2);
+         R_panel_delete (tempfile3);
+
+         return 0;
+    }
+
+
+    e3=temp_e1;
+    e4=temp_e2;
+    n3=temp_n1;
+    n4=temp_n2;
+     I_new_control_point (&group.points, e1, n1, e3, n3, 2);
+     I_put_control_points (group.name, &group.points);
+     Compute_equation();
+     display_points(1) ;
+     I_new_control_point (&group.points, e2, n2, e4, n4, 3);
+     I_put_control_points (group.name, &group.points);
+     Compute_equation();
+     display_points(1) ;
+     R_standard_color (GREEN);
+     R_polyline_abs (first_linex ,first_liney,2);
+     R_polyline_abs (xtemp ,ytemp,2);
+     R_flush();
+
+    return 0;	/* return, but don't QUIT */
+}
+
+static int select(int x,int y,int button)
+{
+        if (button != 1)
+          return where (x,y);
+
+        if (flag==0) {
+                                         if (VIEW_MAP1->cell.configured && In_view (VIEW_MAP1, x, y))
+                                                select_line (VIEW_MAP1, x, y);
+                                        else if (VIEW_MAP1_ZOOM->cell.configured && In_view (VIEW_MAP1_ZOOM, x, y))
+                                                select_line (VIEW_MAP1_ZOOM, x, y);
+                                        else return 0;
+                                     }
+         if (flag==1) {
+                                        if (VIEW_MAP2->cell.configured && In_view (VIEW_MAP2, x, y))
+                                                select_line (VIEW_MAP2, x, y);
+                                        else if (VIEW_MAP2_ZOOM->cell.configured && In_view (VIEW_MAP2_ZOOM, x, y))
+                                                select_line (VIEW_MAP2_ZOOM, x, y);
+                                         else return 0;
+                                      }
+          return 1 ; /* return but don't quit */
+
+};
+
+int select_line (View *view,int x1, int y1)
+{
+    int col, row;
+    int x2,y2,button=0;
+    char buf[50];
+
+
+
+    col = view_to_col (view, x1);
+    temp_e1 = col_to_easting (&view->cell.head, col, 0.5);
+    row = view_to_row (view, y1);
+    temp_n1 = row_to_northing (&view->cell.head, row, 0.5);
+
+    if (flag== 0)
+                {
+                         Curses_clear_window (INFO_WINDOW);
+                         Curses_clear_window (MENU_WINDOW);
+                         sprintf (buf, "Point  %d marked on image at", group.points.count+1);
+                         Curses_write_window (MENU_WINDOW, 1, 1, buf);
+                         sprintf (buf, "East:  %10.2f", temp_e1);
+                         Curses_write_window (MENU_WINDOW, 3, 3, buf);
+                         sprintf (buf, "North: %10.2f", temp_n1);
+                         Curses_write_window (MENU_WINDOW, 4, 3, buf);
+                }
+     else
+              {
+
+                         sprintf (buf, "Point  %d marked on target image at", group.points.count+1);
+                         Curses_write_window (INFO_WINDOW, 1, 1, buf);
+                         sprintf (buf, "East:  %10.2f",temp_e1);
+                         Curses_write_window (INFO_WINDOW, 3, 3, buf);
+                         sprintf (buf, "North: %10.2f", temp_n1);
+                         Curses_write_window (INFO_WINDOW, 4, 3, buf);
+               }
+
+    R_standard_color (ORANGE);
+    R_panel_save (tempfile1, y1-dotsize, y1+dotsize, x1-dotsize, x1+dotsize);
+     dot(x1,y1);
+
+         while (button!=1)
+        {
+        R_get_location_with_line (x1,y1,&x2,&y2,&button);
+        if( button!=1)
+            where (x2,y2);
+         if (!(view->cell.configured && In_view (view, x2, y2)))
+                                  button=0;
+          }
+
+    col = view_to_col (view, x2);
+   temp_e2 = col_to_easting (&view->cell.head, col, 0.5);
+    row = view_to_row (view, y2);
+    temp_n2 = row_to_northing (&view->cell.head, row, 0.5);
+
+   if (flag== 0)
+                {
+                         sprintf (buf, "Point  %d marked on image at", group.points.count+2);
+                         Curses_write_window (MENU_WINDOW, 6, 1, buf);
+                         sprintf (buf, "East:  %10.2f", temp_e2);
+                         Curses_write_window (MENU_WINDOW, 8, 3, buf);
+                         sprintf (buf, "North: %10.2f", temp_n2);
+                         Curses_write_window (MENU_WINDOW, 9, 3, buf);
+                  }
+     else
+              {
+                         sprintf (buf, "Point  %d marked on target image at", group.points.count+2);
+                         Curses_write_window (INFO_WINDOW, 6, 1, buf);
+                         sprintf (buf, "East:  %10.2f",temp_e2);
+                         Curses_write_window (INFO_WINDOW, 8, 3, buf);
+                         sprintf (buf, "North: %10.2f", temp_n2);
+                         Curses_write_window (INFO_WINDOW, 9, 3, buf);
+                 }
+
+    R_standard_color (ORANGE);
+    R_panel_save (tempfile3, y2-dotsize, y2+dotsize, x2-dotsize, x2+dotsize);
+     dot(x2,y2);
+
+     xtemp[0]= x1;
+     xtemp[1]= x2;
+     ytemp[0]= y1;
+     ytemp[1]= y2;
+
+    find_position (&x1,&x2,&y1,&y2);
+    R_panel_save (tempfile2, y1, y2, x1, x2);
+    R_polyline_abs (xtemp ,ytemp,2);
+
+    return 1 ;
+
+ }
+
+ void find_position (int *x1, int *x2,int *y1,int *y2)
+  { int temp;
+    if (*y2<*y1) {
+                         temp=*y1;
+                         *y1=*y2;
+                         *y2= temp;
+                         }
+     else if (*y2==*y1) { *y2= *y2+dotsize;
+                                  *y1= *y1 - dotsize ;
+                                  }
+     if (*x2<*x1) {
+                         temp=*x1;
+                         *x1=*x2;
+                         *x2= temp;
+                         }
+     else if (*x2==*x1) { *x2= *x2+dotsize;
+                                  *x1= *x1 - dotsize ;
+                                  }
+ }
+
+
+   static int cancel()
+ {
+    return -1 ;
+}
+
+

Deleted: grass-addons/imagery/i.points.auto/local_proto.h
===================================================================
--- grass-addons/i.points.auto/local_proto.h	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/local_proto.h	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,142 +0,0 @@
-/* analyze.c */
-int analyze(void);
-int points_to_line (double, double, double, double, double *, double *);
-/* ask.c */
-int ask_gis_files(char *, char *, char *, char *, int);
-int ask_original_map(char *, char *, char *, char *, int);  /* AGGIUNTA */
-/* ask_mag.c */
-int ask_magnification(int *);
-int draw_mag(void);
-/* call.c */
-int call(int (*)(), char *);
-/* cell.c */
-int plotcell(int, int);
-/* cellhd.c */
-int Outline_cellhd(View *, struct Cell_head *);
-/* colors.c */
-int set_colors(struct Colors *);
-/* conv.c */
-int view_to_col(View *, int);
-int view_to_row(View *, int);
-int col_to_view(View *, int);
-int row_to_view(View *, int);
-double row_to_northing(struct Cell_head *, int, double);
-double col_to_easting(struct Cell_head *, int, double);
-double northing_to_row(struct Cell_head *, double);
-double easting_to_col(struct Cell_head *, double);
-/* curses.c */
-int Begin_curses(void);
-int End_curses(void);
-int Suspend_curses(void);
-int Resume_curses(void);
-int Curses_allow_interrupts(int);
-int Curses_clear_window(Window *);
-int Curses_outline_window(Window *);
-int Curses_write_window(Window *, int, int, char *);
-int Curses_replot_screen(void);
-int Curses_prompt_gets(char *, char *);
-int Beep(void);
-int Curses_getch(int);
-/* debug.c */
-int debug(char *);
-/* digit.c */
-int setup_digitizer(void);
-int digitizer_point(double *, double *);
-/* dot.c */
-int dot(int, int);
-int save_under_dot(int, int);
-int restore_under_dot(void);
-int release_under_dot(void);
-/* drawcell.c */
-int drawcell(View *);
-/* driver.c */
-int driver(void);
-/* equ.c */
-int Compute_equation(void);
-/* find_points.c */
-int automated_search(void);
-void Extract_matrix(void);
-void Search_correlation_points(DCELL**, DCELL**, int, int,  int, char *,
-			       int, int, DCELL **, int, int,  int, int, int, int, int, int,int,int,   int); /*Aggiunta*/
-void Extract_portion_of_double_matrix(int, int, int, int, DCELL**, DCELL**);
-
-
-
-/* find_points_semi */
-extern void Extract_matrix_semi(void);
-extern void Search_correlation_points_semi(DCELL**, DCELL**, int, int,  int, char *,
-			       int, int, DCELL **, int, int,  int, int, int, int, int, int,int,int);
-extern void Extract_portion_of_double_matrix_semi(int, int, int, int, DCELL**, DCELL**);        
-
-
-/* find.c */
-int find_target_files(void);
-/*georef.c*/
-int compute_georef_equations(struct Control_Points *cp, double E12[3], double N12[3], double E21[3], double N21[3]);
-int compute_georef_equations_lp (Lines *ln);
-int georef (double e1,double n1,double *e2,double *n2,double E[3],double N[3]);
-/* graphics.c */
-int Init_graphics(void);
-int Outline_box(int, int, int, int);
-int Text_width(char *);
-int Text(char *, int, int, int, int, int);
-int Uparrow(int, int, int, int);
-int Downarrow(int, int, int, int);
-/* group.c */
-int prepare_group_list(void);
-int choose_groupfile(char *, char *);
-/* input.c */
-int Input_pointer(Objects *);
-int Input_box(Objects *, int, int);
-int Input_other(int (*)(), char *);
-int Menu_msg(char *);
-int Start_mouse_in_menu(void);
-/* line.c */
-int line(void);
-int select_line (View *, int, int);
-/* main.c */
-int quit(int);
-int error(char *, int);
-/* mark.c */
-int mark(int, int, int);
-int mark_point(View *, int, int);
-/* mouse.c */
-int Mouse_pointer(int *, int *, int *);
-int Mouse_box_anchored(int, int, int *, int *, int *);
-int Get_mouse_xy(int *, int *);
-int Set_mouse_xy(int, int);
-/* points.c */
-int display_points(int);
-int display_points_in_view(View *, int, double *, double *, int *, int);
-int display_points_in_view_diff_color(View *, int, double *, double *, int *, int);
-int display_points_in_view_diff_color_if_active(View *, int, double *, double *, int *, int);
-int display_one_point(View *, double, double);
-/* target.c */
-int get_target(void);
-int select_current_env(void);
-int select_target_env(void);
-/* title.c */
-int display_title(View *);
-/* view.c */
-int Configure_view(View *, char *, char *, double, double);
-int In_view(View *, int, int);
-int Erase_view(View *);
-double magnification(View *);
-/* where.c */
-int where(int, int);
-/*write_line.c*/
-int put_control_points ( char *group, struct Control_Points *cp);
-int read_control_points (FILE *fd, struct Control_Points *cp);
-int new_control_point (struct Control_Points *cp,double e1,double n1,double e2,double n2, int status);
-int write_control_points(FILE *fd, struct Control_Points *cp);
-int get_control_points (char *group, struct Control_Points *cp);
-/* zoom.c */
-int zoom(void);
-static int which_zoom(int x, int y, int button);
-/* overlap_area.c */
-int overlap_area(int,int,int,int,int, int,int);  
-/* zoom_box.c */
-int zoom_box(int ,int );
-/* zoom_pnt.c */
-int zoom_point(int , int );
-int zoom_pnt (int ,int );

Copied: grass-addons/imagery/i.points.auto/local_proto.h (from rev 30335, grass-addons/i.points.auto/local_proto.h)
===================================================================
--- grass-addons/imagery/i.points.auto/local_proto.h	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/local_proto.h	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,142 @@
+/* analyze.c */
+int analyze(void);
+int points_to_line (double, double, double, double, double *, double *);
+/* ask.c */
+int ask_gis_files(char *, char *, char *, char *, int);
+int ask_original_map(char *, char *, char *, char *, int);  /* AGGIUNTA */
+/* ask_mag.c */
+int ask_magnification(int *);
+int draw_mag(void);
+/* call.c */
+int call(int (*)(), char *);
+/* cell.c */
+int plotcell(int, int);
+/* cellhd.c */
+int Outline_cellhd(View *, struct Cell_head *);
+/* colors.c */
+int set_colors(struct Colors *);
+/* conv.c */
+int view_to_col(View *, int);
+int view_to_row(View *, int);
+int col_to_view(View *, int);
+int row_to_view(View *, int);
+double row_to_northing(struct Cell_head *, int, double);
+double col_to_easting(struct Cell_head *, int, double);
+double northing_to_row(struct Cell_head *, double);
+double easting_to_col(struct Cell_head *, double);
+/* curses.c */
+int Begin_curses(void);
+int End_curses(void);
+int Suspend_curses(void);
+int Resume_curses(void);
+int Curses_allow_interrupts(int);
+int Curses_clear_window(Window *);
+int Curses_outline_window(Window *);
+int Curses_write_window(Window *, int, int, char *);
+int Curses_replot_screen(void);
+int Curses_prompt_gets(char *, char *);
+int Beep(void);
+int Curses_getch(int);
+/* debug.c */
+int debug(char *);
+/* digit.c */
+int setup_digitizer(void);
+int digitizer_point(double *, double *);
+/* dot.c */
+int dot(int, int);
+int save_under_dot(int, int);
+int restore_under_dot(void);
+int release_under_dot(void);
+/* drawcell.c */
+int drawcell(View *);
+/* driver.c */
+int driver(void);
+/* equ.c */
+int Compute_equation(void);
+/* find_points.c */
+int automated_search(void);
+void Extract_matrix(void);
+void Search_correlation_points(DCELL**, DCELL**, int, int,  int, char *,
+			       int, int, DCELL **, int, int,  int, int, int, int, int, int,int,int,   int); /*Aggiunta*/
+void Extract_portion_of_double_matrix(int, int, int, int, DCELL**, DCELL**);
+
+
+
+/* find_points_semi */
+extern void Extract_matrix_semi(void);
+extern void Search_correlation_points_semi(DCELL**, DCELL**, int, int,  int, char *,
+			       int, int, DCELL **, int, int,  int, int, int, int, int, int,int,int);
+extern void Extract_portion_of_double_matrix_semi(int, int, int, int, DCELL**, DCELL**);        
+
+
+/* find.c */
+int find_target_files(void);
+/*georef.c*/
+int compute_georef_equations(struct Control_Points *cp, double E12[3], double N12[3], double E21[3], double N21[3]);
+int compute_georef_equations_lp (Lines *ln);
+int georef (double e1,double n1,double *e2,double *n2,double E[3],double N[3]);
+/* graphics.c */
+int Init_graphics(void);
+int Outline_box(int, int, int, int);
+int Text_width(char *);
+int Text(char *, int, int, int, int, int);
+int Uparrow(int, int, int, int);
+int Downarrow(int, int, int, int);
+/* group.c */
+int prepare_group_list(void);
+int choose_groupfile(char *, char *);
+/* input.c */
+int Input_pointer(Objects *);
+int Input_box(Objects *, int, int);
+int Input_other(int (*)(), char *);
+int Menu_msg(char *);
+int Start_mouse_in_menu(void);
+/* line.c */
+int line(void);
+int select_line (View *, int, int);
+/* main.c */
+int quit(int);
+int error(char *, int);
+/* mark.c */
+int mark(int, int, int);
+int mark_point(View *, int, int);
+/* mouse.c */
+int Mouse_pointer(int *, int *, int *);
+int Mouse_box_anchored(int, int, int *, int *, int *);
+int Get_mouse_xy(int *, int *);
+int Set_mouse_xy(int, int);
+/* points.c */
+int display_points(int);
+int display_points_in_view(View *, int, double *, double *, int *, int);
+int display_points_in_view_diff_color(View *, int, double *, double *, int *, int);
+int display_points_in_view_diff_color_if_active(View *, int, double *, double *, int *, int);
+int display_one_point(View *, double, double);
+/* target.c */
+int get_target(void);
+int select_current_env(void);
+int select_target_env(void);
+/* title.c */
+int display_title(View *);
+/* view.c */
+int Configure_view(View *, char *, char *, double, double);
+int In_view(View *, int, int);
+int Erase_view(View *);
+double magnification(View *);
+/* where.c */
+int where(int, int);
+/*write_line.c*/
+int put_control_points ( char *group, struct Control_Points *cp);
+int read_control_points (FILE *fd, struct Control_Points *cp);
+int new_control_point (struct Control_Points *cp,double e1,double n1,double e2,double n2, int status);
+int write_control_points(FILE *fd, struct Control_Points *cp);
+int get_control_points (char *group, struct Control_Points *cp);
+/* zoom.c */
+int zoom(void);
+static int which_zoom(int x, int y, int button);
+/* overlap_area.c */
+int overlap_area(int,int,int,int,int, int,int);  
+/* zoom_box.c */
+int zoom_box(int ,int );
+/* zoom_pnt.c */
+int zoom_point(int , int );
+int zoom_pnt (int ,int );

Deleted: grass-addons/imagery/i.points.auto/main.c
===================================================================
--- grass-addons/i.points.auto/main.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/main.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,204 +0,0 @@
-/*****************************************************************************
-*
-* MODULE:     i.points.auto
-* AUTHOR(S):  based on i.points; additions by 
-*              Ivan Michelazzi, Luca Miori (MSc theses at ITC-irst)
-*             http://gisws.media.osaka-cu.ac.jp/grass04/viewpaper.php?id=37  
-*             Supervisors: Markus Neteler, Stefano Merler, ITC-irst 2003, 2004
-*            
-* PURPOSE:    semi-automated image registration based in FFT correlation
-* COPYRIGHT: GPL >=2
-*
-*****************************************************************************/
-
-#define GLOBAL
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <grass/gis.h>
-#include <grass/raster.h>
-#include <grass/glocale.h>
-#include "globals.h"
-#include "local_proto.h"
-
-#ifdef __GNUC_MINOR__
-int quit (int) __attribute__ ((__noreturn__));
-#else
-int quit (int);
-#endif
-int error (char *, int);
-
-
-
-int main (int argc, char *argv[])
-{
-    char name[GNAME_MAX], mapset[GMAPSET_MAX];
-    struct Cell_head cellhd;
-    struct GModule *module;
-
-    G_gisinit (argv[0]);
-    module = G_define_module();
-    module->description =
-	_("Mark or search ground control points on image to be rectified.");
-
-    G_suppress_masking();	/* need to do this for target location */
-
-    interrupt_char = G_intr_char();
-    tempfile1 = G_tempfile();
-    tempfile2 = G_tempfile();
-    tempfile3 = G_tempfile();
-    cell_list = G_tempfile();
-    vect_list = G_tempfile();
-    group_list = G_tempfile();
-    digit_points = G_tempfile();
-    digit_results = G_tempfile();
-
-   if (R_open_driver() != 0)
-	G_fatal_error(_("No graphics device selected"));
-
-    /* temporary parser code: */
-    if(argc == 2) {
-	strncpy(group.name, argv[1], GNAME_MAX);
-	if(group.name[0] == '-')
-	    G_fatal_error(_("The parser doesn't work here."));
-    }
-    else {
-	if (!I_ask_group_old (_("Enter imagery group to be registered"), group.name))
-	    exit(EXIT_FAILURE);
-    }
-
-    if (!I_get_group_ref (group.name, &group.ref))
-        G_fatal_error ( _("Group [%s] contains no files"), group.name);
-
-    if (group.ref.nfiles <= 0)
-	G_fatal_error ( _( "Group [%s] contains no files"), group.name);
-
-/* write group files to group list file */
-    prepare_group_list();
-    debug("prepare_group_list done");
-
-/* get target info and enviroment */
-    get_target();
-    find_target_files();
-    debug("find_target_files done");
-
-/* read group control points, if any */
-    G_suppress_warnings(1);
-    if (!I_get_control_points (group.name, &group.points))
-	group.points.count = 0;
-    G_suppress_warnings(0);
-
-/* determine tranformation equation */
-    G_debug(0, "starting Compute_equation()");
-    Compute_equation();
-
-    signal (SIGINT, SIG_IGN);
-/*  signal (SIGQUIT, SIG_IGN); */
-
-    R_standard_color (BLUE);
-
-    Init_graphics();
-    display_title (VIEW_MAP1);
-
-    G_debug(0, "select_target_env");
-    select_target_env ();
-    display_title (VIEW_MAP2);
-    select_current_env ();
-    G_debug(0, "select_target_env done");
-
-    Begin_curses();
-    G_debug(0, "Begin_curses done");
-    G_set_error_routine (error);
-
-/*
-#ifdef SIGTSTP
-    signal (SIGTSTP, SIG_IGN);
-#endif
-*/
-
-/* ask user for group file to be displayed */
-    G_debug(0, "ask user for group file to be displayed");
-    do
-    {
-	if(!choose_groupfile (name, mapset))
-	    quit(0);
-     
-/* display this file in "map1" */
-    }
-    while (G_get_cellhd (name, mapset, &cellhd) < 0);
-    G_adjust_window_to_box (&cellhd, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows, VIEW_MAP1->ncols);
-    Configure_view (VIEW_MAP1, name, mapset, cellhd.ns_res, cellhd.ew_res);
-
-    drawcell(VIEW_MAP1);
-    display_points(1);
-    R_flush();
-
-    Curses_clear_window (PROMPT_WINDOW);
-
-    Erase_view (VIEW_MAP1_ZOOM);          
-
-
-/* determine initial input method. */
-    setup_digitizer();
-    if (use_digitizer)
-    {
-	from_digitizer = 1;
-	from_keyboard  = 0;
-	from_flag = 1;
-    }
-
-/* go do the work */
-    driver();
-
-    quit(0);
-}
-
-int quit (int n)
-{
-    char command[1024];
-
-    End_curses();
-    R_close_driver();
-    if (use_digitizer)
-    {
-	sprintf (command, "%s/etc/geo.unlock %s",
-	    G_gisbase(), digit_points);
-	system (command);
-    }
-    unlink (tempfile1);
-    unlink (tempfile2);
-    unlink (tempfile3);
-    unlink (cell_list);
-    unlink (group_list);
-    unlink (vect_list);
-    unlink (digit_points);
-    unlink (digit_results);
-    exit(n);
-}
-
-int error (char *msg, int fatal)
-{
-    char buf[200];
-    int x,y,button;
-
-Curses_clear_window (PROMPT_WINDOW);
-Curses_write_window (PROMPT_WINDOW,1,1, "LOCATION:\n");
-Curses_write_window (PROMPT_WINDOW,1,12,G_location());
-Curses_write_window (PROMPT_WINDOW,2,1, "MAPSET:\n");
-Curses_write_window (PROMPT_WINDOW,2,12,G_location());
- Beep();
- if (fatal)
-   sprintf (buf, "ERROR: %s", msg);
- else
-   sprintf (buf, "WARNING: %s (click mouse to continue)", msg);
- Menu_msg (buf);
- 
- if (fatal)
-   quit(1);
- Mouse_pointer (&x, &y, &button);
- Curses_clear_window (PROMPT_WINDOW);
- 
-    return 0;
-}
-

Copied: grass-addons/imagery/i.points.auto/main.c (from rev 30335, grass-addons/i.points.auto/main.c)
===================================================================
--- grass-addons/imagery/i.points.auto/main.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/main.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,204 @@
+/*****************************************************************************
+*
+* MODULE:     i.points.auto
+* AUTHOR(S):  based on i.points; additions by 
+*              Ivan Michelazzi, Luca Miori (MSc theses at ITC-irst)
+*             http://gisws.media.osaka-cu.ac.jp/grass04/viewpaper.php?id=37  
+*             Supervisors: Markus Neteler, Stefano Merler, ITC-irst 2003, 2004
+*            
+* PURPOSE:    semi-automated image registration based in FFT correlation
+* COPYRIGHT: GPL >=2
+*
+*****************************************************************************/
+
+#define GLOBAL
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <grass/gis.h>
+#include <grass/raster.h>
+#include <grass/glocale.h>
+#include "globals.h"
+#include "local_proto.h"
+
+#ifdef __GNUC_MINOR__
+int quit (int) __attribute__ ((__noreturn__));
+#else
+int quit (int);
+#endif
+int error (char *, int);
+
+
+
+int main (int argc, char *argv[])
+{
+    char name[GNAME_MAX], mapset[GMAPSET_MAX];
+    struct Cell_head cellhd;
+    struct GModule *module;
+
+    G_gisinit (argv[0]);
+    module = G_define_module();
+    module->description =
+	_("Mark or search ground control points on image to be rectified.");
+
+    G_suppress_masking();	/* need to do this for target location */
+
+    interrupt_char = G_intr_char();
+    tempfile1 = G_tempfile();
+    tempfile2 = G_tempfile();
+    tempfile3 = G_tempfile();
+    cell_list = G_tempfile();
+    vect_list = G_tempfile();
+    group_list = G_tempfile();
+    digit_points = G_tempfile();
+    digit_results = G_tempfile();
+
+   if (R_open_driver() != 0)
+	G_fatal_error(_("No graphics device selected"));
+
+    /* temporary parser code: */
+    if(argc == 2) {
+	strncpy(group.name, argv[1], GNAME_MAX);
+	if(group.name[0] == '-')
+	    G_fatal_error(_("The parser doesn't work here."));
+    }
+    else {
+	if (!I_ask_group_old (_("Enter imagery group to be registered"), group.name))
+	    exit(EXIT_FAILURE);
+    }
+
+    if (!I_get_group_ref (group.name, &group.ref))
+        G_fatal_error ( _("Group [%s] contains no files"), group.name);
+
+    if (group.ref.nfiles <= 0)
+	G_fatal_error ( _( "Group [%s] contains no files"), group.name);
+
+/* write group files to group list file */
+    prepare_group_list();
+    debug("prepare_group_list done");
+
+/* get target info and enviroment */
+    get_target();
+    find_target_files();
+    debug("find_target_files done");
+
+/* read group control points, if any */
+    G_suppress_warnings(1);
+    if (!I_get_control_points (group.name, &group.points))
+	group.points.count = 0;
+    G_suppress_warnings(0);
+
+/* determine tranformation equation */
+    G_debug(0, "starting Compute_equation()");
+    Compute_equation();
+
+    signal (SIGINT, SIG_IGN);
+/*  signal (SIGQUIT, SIG_IGN); */
+
+    R_standard_color (BLUE);
+
+    Init_graphics();
+    display_title (VIEW_MAP1);
+
+    G_debug(0, "select_target_env");
+    select_target_env ();
+    display_title (VIEW_MAP2);
+    select_current_env ();
+    G_debug(0, "select_target_env done");
+
+    Begin_curses();
+    G_debug(0, "Begin_curses done");
+    G_set_error_routine (error);
+
+/*
+#ifdef SIGTSTP
+    signal (SIGTSTP, SIG_IGN);
+#endif
+*/
+
+/* ask user for group file to be displayed */
+    G_debug(0, "ask user for group file to be displayed");
+    do
+    {
+	if(!choose_groupfile (name, mapset))
+	    quit(0);
+     
+/* display this file in "map1" */
+    }
+    while (G_get_cellhd (name, mapset, &cellhd) < 0);
+    G_adjust_window_to_box (&cellhd, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows, VIEW_MAP1->ncols);
+    Configure_view (VIEW_MAP1, name, mapset, cellhd.ns_res, cellhd.ew_res);
+
+    drawcell(VIEW_MAP1);
+    display_points(1);
+    R_flush();
+
+    Curses_clear_window (PROMPT_WINDOW);
+
+    Erase_view (VIEW_MAP1_ZOOM);          
+
+
+/* determine initial input method. */
+    setup_digitizer();
+    if (use_digitizer)
+    {
+	from_digitizer = 1;
+	from_keyboard  = 0;
+	from_flag = 1;
+    }
+
+/* go do the work */
+    driver();
+
+    quit(0);
+}
+
+int quit (int n)
+{
+    char command[1024];
+
+    End_curses();
+    R_close_driver();
+    if (use_digitizer)
+    {
+	sprintf (command, "%s/etc/geo.unlock %s",
+	    G_gisbase(), digit_points);
+	system (command);
+    }
+    unlink (tempfile1);
+    unlink (tempfile2);
+    unlink (tempfile3);
+    unlink (cell_list);
+    unlink (group_list);
+    unlink (vect_list);
+    unlink (digit_points);
+    unlink (digit_results);
+    exit(n);
+}
+
+int error (char *msg, int fatal)
+{
+    char buf[200];
+    int x,y,button;
+
+Curses_clear_window (PROMPT_WINDOW);
+Curses_write_window (PROMPT_WINDOW,1,1, "LOCATION:\n");
+Curses_write_window (PROMPT_WINDOW,1,12,G_location());
+Curses_write_window (PROMPT_WINDOW,2,1, "MAPSET:\n");
+Curses_write_window (PROMPT_WINDOW,2,12,G_location());
+ Beep();
+ if (fatal)
+   sprintf (buf, "ERROR: %s", msg);
+ else
+   sprintf (buf, "WARNING: %s (click mouse to continue)", msg);
+ Menu_msg (buf);
+ 
+ if (fatal)
+   quit(1);
+ Mouse_pointer (&x, &y, &button);
+ Curses_clear_window (PROMPT_WINDOW);
+ 
+    return 0;
+}
+

Deleted: grass-addons/imagery/i.points.auto/mark.c
===================================================================
--- grass-addons/i.points.auto/mark.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/mark.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,205 +0,0 @@
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-
-static int get_point2 (double *,double *);
-static int keyboard();
-static int _keyboard();
-static int screen (int,int,int);
-static int digitizer();
-static int cancel();
-
-int mark(int x,int y,int button)
-{
-    if (button != 1)
-    return where (x,y);
-
-                if (VIEW_MAP1->cell.configured && In_view (VIEW_MAP1, x, y))
-                        mark_point (VIEW_MAP1, x, y);
-                else if (VIEW_MAP1_ZOOM->cell.configured && In_view (VIEW_MAP1_ZOOM, x, y))
-                        mark_point (VIEW_MAP1_ZOOM, x, y);
-                return 0 ; /* return but don't quit */
-       
-
-}
-
-int mark_point (View *view,int x, int y)
-{
-    double e1,n1;
-    double e2,n2;
-    int row,col;
-
-    char buf[100];
-
-/* convert x,y to east,north at center of cell */
-    col = view_to_col (view, x);
-    e1 = col_to_easting (&view->cell.head, col, 0.5);
-    row = view_to_row (view, y);
-    n1 = row_to_northing (&view->cell.head, row, 0.5);
-
-    Curses_clear_window (MENU_WINDOW);
-    sprintf (buf, "Point %d marked on image at", group.points.count+1);
-    Curses_write_window (MENU_WINDOW, 1, 1, buf);
-    sprintf (buf, "East:  %10.2f", e1);
-    Curses_write_window (MENU_WINDOW, 3, 3, buf);
-    sprintf (buf, "North: %10.2f", n1);
-    Curses_write_window (MENU_WINDOW, 4, 3, buf);
-    Curses_clear_window (INFO_WINDOW);
-
-    R_standard_color (ORANGE);
-    save_under_dot (x,y);
-    dot(x,y);
-
-    if (!get_point2(&e2, &n2))
-    {
-	Curses_clear_window (MENU_WINDOW);
-	restore_under_dot();
-    }
-    else
-    {
-	Curses_write_window (MENU_WINDOW, 7, 1, "Point located at");
-	sprintf (buf, "East:  %10.2f", e2);
-	Curses_write_window (MENU_WINDOW, 9, 3, buf);
-	sprintf (buf, "North: %10.2f", n2);
-	Curses_write_window (MENU_WINDOW,10, 3, buf);
-	I_new_control_point (&group.points, e1, n1, e2, n2, 1);
-	I_put_control_points (group.name, &group.points);
-	Compute_equation();
-	display_points(1);
-    }
-    release_under_dot();
-
-    return 0;
-}
-
-static double N,E;
-
-static int get_point2 (double *east,double *north)
-{
-    int digitizer();
-    int keyboard();
-    int stat;
-    int screen();
-    int cancel();
-    static int use = 1;
-    static Objects objects[] =
-    {
-	MENU ("CANCEL", cancel, &use),
-	INFO ("Mark point on target image", &use),
-	OTHER (screen, &use),
-	{0}
-    };
-
-    if (from_digitizer > 0)
-    {
-	stat = Input_other (digitizer, "Digitizer");
-    }
-    else if (from_screen > 0)
-    {
-	set_colors (&VIEW_MAP2->cell.colors);
-	stat = Input_pointer(objects) > 0;
-	set_colors (&VIEW_MAP1->cell.colors);
-    }
-    else
-	stat = Input_other (keyboard, "Keyboard");
-
-    if(stat)
-    {
-	*east = E;
-	*north = N;
-    }
-
-    return stat ;
-}
-
-static int 
-keyboard (void)
-{
-    int ok;
-    Curses_clear_window (INFO_WINDOW);
-    ok = _keyboard ();
-    Curses_clear_window (INFO_WINDOW);
-    return ok;
-}
-
-static int 
-_keyboard (void)
-{
-    char buf[100];
-
-    while(1)
-    {
-	Curses_prompt_gets ("Enter coordinates as east north: ", buf);
-	G_strip (buf);
-	if (*buf == 0)
-	{
-	    return 0;
-	}
-	if (sscanf (buf, "%lf %lf", &E, &N) != 2)
-	{
-	    Beep();
-	    continue;
-	}
-	Curses_clear_window (INFO_WINDOW);
-	sprintf (buf, "East:   %f\n", E);
-	Curses_write_window (INFO_WINDOW, 2, 2, buf);
-	sprintf (buf, "North:  %f\n", N);
-	Curses_write_window (INFO_WINDOW, 3, 2, buf);
-	Curses_write_window (INFO_WINDOW, 5, 1, "Look ok? (y/n) ");
-
-	while(1)
-	{
-	    int c;
-	    c = Curses_getch(0);
-	    if (c == 'y' || c == 'Y')
-		return 1;
-	    if (c == 'n' || c == 'N')
-		break;
-	    Beep();
-	}
-    }
-
-    return 0;
-}
-
-static int 
-digitizer (void)
-{
-    return digitizer_point (&E, &N);
-}
-
-
-static int screen (int x,int y,int button)
-{
-    int row,col;
-    char buf[50];
-
-    View *view;
-    if (In_view (VIEW_MAP2, x, y) && VIEW_MAP2->cell.configured)
-	view = VIEW_MAP2;
-    else if (In_view (VIEW_MAP2_ZOOM, x, y) && VIEW_MAP2_ZOOM->cell.configured)
-	view = VIEW_MAP2_ZOOM;
-    else
-	return 0; /* ignore mouse event */
-
-    col = view_to_col (view, x);
-    E = col_to_easting (&view->cell.head, col, 0.5);
-    row = view_to_row (view, y);
-    N = row_to_northing (&view->cell.head, row, 0.5);
-
-    if (button == 1)
-	return 1;
-
-    sprintf (buf, "East:   %10.2f\n", E);
-    Curses_write_window (INFO_WINDOW, 2, 2, buf);
-    sprintf (buf, "North:  %10.2f\n", N);
-    Curses_write_window (INFO_WINDOW, 3, 2, buf);
-
-    return 0;
-}
-
-static int 
-cancel (void)
-{
-    return -1;
-}

Copied: grass-addons/imagery/i.points.auto/mark.c (from rev 30335, grass-addons/i.points.auto/mark.c)
===================================================================
--- grass-addons/imagery/i.points.auto/mark.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/mark.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,205 @@
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+
+static int get_point2 (double *,double *);
+static int keyboard();
+static int _keyboard();
+static int screen (int,int,int);
+static int digitizer();
+static int cancel();
+
+int mark(int x,int y,int button)
+{
+    if (button != 1)
+    return where (x,y);
+
+                if (VIEW_MAP1->cell.configured && In_view (VIEW_MAP1, x, y))
+                        mark_point (VIEW_MAP1, x, y);
+                else if (VIEW_MAP1_ZOOM->cell.configured && In_view (VIEW_MAP1_ZOOM, x, y))
+                        mark_point (VIEW_MAP1_ZOOM, x, y);
+                return 0 ; /* return but don't quit */
+       
+
+}
+
+int mark_point (View *view,int x, int y)
+{
+    double e1,n1;
+    double e2,n2;
+    int row,col;
+
+    char buf[100];
+
+/* convert x,y to east,north at center of cell */
+    col = view_to_col (view, x);
+    e1 = col_to_easting (&view->cell.head, col, 0.5);
+    row = view_to_row (view, y);
+    n1 = row_to_northing (&view->cell.head, row, 0.5);
+
+    Curses_clear_window (MENU_WINDOW);
+    sprintf (buf, "Point %d marked on image at", group.points.count+1);
+    Curses_write_window (MENU_WINDOW, 1, 1, buf);
+    sprintf (buf, "East:  %10.2f", e1);
+    Curses_write_window (MENU_WINDOW, 3, 3, buf);
+    sprintf (buf, "North: %10.2f", n1);
+    Curses_write_window (MENU_WINDOW, 4, 3, buf);
+    Curses_clear_window (INFO_WINDOW);
+
+    R_standard_color (ORANGE);
+    save_under_dot (x,y);
+    dot(x,y);
+
+    if (!get_point2(&e2, &n2))
+    {
+	Curses_clear_window (MENU_WINDOW);
+	restore_under_dot();
+    }
+    else
+    {
+	Curses_write_window (MENU_WINDOW, 7, 1, "Point located at");
+	sprintf (buf, "East:  %10.2f", e2);
+	Curses_write_window (MENU_WINDOW, 9, 3, buf);
+	sprintf (buf, "North: %10.2f", n2);
+	Curses_write_window (MENU_WINDOW,10, 3, buf);
+	I_new_control_point (&group.points, e1, n1, e2, n2, 1);
+	I_put_control_points (group.name, &group.points);
+	Compute_equation();
+	display_points(1);
+    }
+    release_under_dot();
+
+    return 0;
+}
+
+static double N,E;
+
+static int get_point2 (double *east,double *north)
+{
+    int digitizer();
+    int keyboard();
+    int stat;
+    int screen();
+    int cancel();
+    static int use = 1;
+    static Objects objects[] =
+    {
+	MENU ("CANCEL", cancel, &use),
+	INFO ("Mark point on target image", &use),
+	OTHER (screen, &use),
+	{0}
+    };
+
+    if (from_digitizer > 0)
+    {
+	stat = Input_other (digitizer, "Digitizer");
+    }
+    else if (from_screen > 0)
+    {
+	set_colors (&VIEW_MAP2->cell.colors);
+	stat = Input_pointer(objects) > 0;
+	set_colors (&VIEW_MAP1->cell.colors);
+    }
+    else
+	stat = Input_other (keyboard, "Keyboard");
+
+    if(stat)
+    {
+	*east = E;
+	*north = N;
+    }
+
+    return stat ;
+}
+
+static int 
+keyboard (void)
+{
+    int ok;
+    Curses_clear_window (INFO_WINDOW);
+    ok = _keyboard ();
+    Curses_clear_window (INFO_WINDOW);
+    return ok;
+}
+
+static int 
+_keyboard (void)
+{
+    char buf[100];
+
+    while(1)
+    {
+	Curses_prompt_gets ("Enter coordinates as east north: ", buf);
+	G_strip (buf);
+	if (*buf == 0)
+	{
+	    return 0;
+	}
+	if (sscanf (buf, "%lf %lf", &E, &N) != 2)
+	{
+	    Beep();
+	    continue;
+	}
+	Curses_clear_window (INFO_WINDOW);
+	sprintf (buf, "East:   %f\n", E);
+	Curses_write_window (INFO_WINDOW, 2, 2, buf);
+	sprintf (buf, "North:  %f\n", N);
+	Curses_write_window (INFO_WINDOW, 3, 2, buf);
+	Curses_write_window (INFO_WINDOW, 5, 1, "Look ok? (y/n) ");
+
+	while(1)
+	{
+	    int c;
+	    c = Curses_getch(0);
+	    if (c == 'y' || c == 'Y')
+		return 1;
+	    if (c == 'n' || c == 'N')
+		break;
+	    Beep();
+	}
+    }
+
+    return 0;
+}
+
+static int 
+digitizer (void)
+{
+    return digitizer_point (&E, &N);
+}
+
+
+static int screen (int x,int y,int button)
+{
+    int row,col;
+    char buf[50];
+
+    View *view;
+    if (In_view (VIEW_MAP2, x, y) && VIEW_MAP2->cell.configured)
+	view = VIEW_MAP2;
+    else if (In_view (VIEW_MAP2_ZOOM, x, y) && VIEW_MAP2_ZOOM->cell.configured)
+	view = VIEW_MAP2_ZOOM;
+    else
+	return 0; /* ignore mouse event */
+
+    col = view_to_col (view, x);
+    E = col_to_easting (&view->cell.head, col, 0.5);
+    row = view_to_row (view, y);
+    N = row_to_northing (&view->cell.head, row, 0.5);
+
+    if (button == 1)
+	return 1;
+
+    sprintf (buf, "East:   %10.2f\n", E);
+    Curses_write_window (INFO_WINDOW, 2, 2, buf);
+    sprintf (buf, "North:  %10.2f\n", N);
+    Curses_write_window (INFO_WINDOW, 3, 2, buf);
+
+    return 0;
+}
+
+static int 
+cancel (void)
+{
+    return -1;
+}

Deleted: grass-addons/imagery/i.points.auto/mouse.c
===================================================================
--- grass-addons/i.points.auto/mouse.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/mouse.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,59 +0,0 @@
-#include <grass/raster.h>
-#include "globals.h"
-
-static int first = 1;
-static int curx, cury;
-
-int 
-Mouse_pointer (int *x, int *y, int *button)
-{
-    if (first)
-    {
-	curx = (SCREEN_LEFT + SCREEN_RIGHT)/2;
-	cury = (SCREEN_TOP + SCREEN_BOTTOM)/2;
-	first = 0;
-    }
-    R_get_location_with_pointer (&curx, &cury, button);
-    *x = curx;
-    *y = cury;
-
-#ifdef BUTTON3
-    if (*button == 3) quit(0);
-#endif
-
-    return 0;
-}
-
-int 
-Mouse_box_anchored (int x1, int y1, int *x2, int *y2, int *button)
-{
-    R_get_location_with_box (x1, y1, x2, y2, button);
-    curx = *x2;
-    cury = *y2;
-    first = 0;
-
-#ifdef BUTTON3
-    if (*button == 3) quit(0);
-#endif
-
-    return 0;
-}
-
-int 
-Get_mouse_xy (int *x, int *y)
-{
-    *x = curx;
-    *y = cury;
-
-    return 0;
-}
-
-int 
-Set_mouse_xy (int x, int y)
-{
-    first = 0;
-    curx = x;
-    cury = y;
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/mouse.c (from rev 30335, grass-addons/i.points.auto/mouse.c)
===================================================================
--- grass-addons/imagery/i.points.auto/mouse.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/mouse.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,59 @@
+#include <grass/raster.h>
+#include "globals.h"
+
+static int first = 1;
+static int curx, cury;
+
+int 
+Mouse_pointer (int *x, int *y, int *button)
+{
+    if (first)
+    {
+	curx = (SCREEN_LEFT + SCREEN_RIGHT)/2;
+	cury = (SCREEN_TOP + SCREEN_BOTTOM)/2;
+	first = 0;
+    }
+    R_get_location_with_pointer (&curx, &cury, button);
+    *x = curx;
+    *y = cury;
+
+#ifdef BUTTON3
+    if (*button == 3) quit(0);
+#endif
+
+    return 0;
+}
+
+int 
+Mouse_box_anchored (int x1, int y1, int *x2, int *y2, int *button)
+{
+    R_get_location_with_box (x1, y1, x2, y2, button);
+    curx = *x2;
+    cury = *y2;
+    first = 0;
+
+#ifdef BUTTON3
+    if (*button == 3) quit(0);
+#endif
+
+    return 0;
+}
+
+int 
+Get_mouse_xy (int *x, int *y)
+{
+    *x = curx;
+    *y = cury;
+
+    return 0;
+}
+
+int 
+Set_mouse_xy (int x, int y)
+{
+    first = 0;
+    curx = x;
+    cury = y;
+
+    return 0;
+}

Copied: grass-addons/imagery/i.points.auto/orig (from rev 30335, grass-addons/i.points.auto/orig)

Deleted: grass-addons/imagery/i.points.auto/overlap_area.c
===================================================================
--- grass-addons/i.points.auto/overlap_area.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/overlap_area.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,141 +0,0 @@
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-
-static View *pick_view, *zoom_view, *main_view; 
-static int target_flag;
-
-
-int overlap_area(int xp, int yp, int xs, int ys, int n_img, int ncols, int nrows)   
-{
-  
-  int x_1, y_1, x_2, y_2;
-  int tmp_right, tmp_left;
-  int tmp_bottom, tmp_top;
-  int tmp_ncols; 
-  int tmp_nrows; 
-
-  int top, bottom, left, right;
-  int row,col;
-  struct Cell_head cellhd;
-
-
- 
-  if(n_img==1)
-    {
-      pick_view = VIEW_MAP1;
-      main_view = VIEW_MAP1;
-      zoom_view = VIEW_MAP1_ZOOM;
-      target_flag = 0;
-      printf("info VIEW_MAP1_ZOOM: nrows=%d ncols=%d",zoom_view->nrows,zoom_view->ncols);
-    }  
-  
-  else if (n_img==2)
-    {
-      pick_view = VIEW_MAP2;
-      main_view = VIEW_MAP2;
-      zoom_view = VIEW_MAP2_ZOOM;
-      target_flag = 1;
-    }
-    
-  else
-    return 0;  
-  if (!pick_view->cell.configured) return 0;             /*	just to be sure */
-
-
-  tmp_right = pick_view->cell.right;
-  tmp_left = pick_view->cell.left;
-  tmp_ncols = (tmp_right - tmp_left);
-
-  tmp_bottom = pick_view->cell.bottom;
-  tmp_top = pick_view->cell.top;
-  tmp_nrows = (tmp_bottom - tmp_top);
-
-
-  x_1 = ((tmp_ncols*xp)/ncols);
-  y_1 = (((pick_view->nrows)*yp)/nrows);
-  x_2 = ((tmp_ncols*xs)/ncols);
-  y_2 = (((pick_view->nrows)*ys)/nrows);
-
-
-
-  
-  if (x_1 == x_2 || y_1 == y_2) return 0;      /* ignore event */
-
-
-    
-  top = row_to_view (pick_view, y_1);
-  left = col_to_view (pick_view, x_1);
-  bottom = row_to_view (pick_view, y_2);
-  right = col_to_view (pick_view, x_2);
- 
-
-  if (!In_view (pick_view,right,bottom)) return 0; 
-    
-
-  Menu_msg("");
-
-  
-  G_copy (&cellhd, &pick_view->cell.head, sizeof(cellhd)); 
-
-
-  col = view_to_col(pick_view,left);
-  row = view_to_row(pick_view,top);
-  cellhd.north = row_to_northing (&pick_view->cell.head,row,0.0);
-  cellhd.west  = col_to_easting  (&pick_view->cell.head,col,0.0);
-
-
-  col = view_to_col(pick_view,right);
-  row = view_to_row(pick_view,bottom);
-  cellhd.south = row_to_northing (&pick_view->cell.head,row,1.0);
-  cellhd.east  = col_to_easting  (&pick_view->cell.head,col,1.0);
-
-  
-    
-  cellhd.rows = bottom-top+1;
-  cellhd.cols = right-left+1;
-  cellhd.ns_res = (cellhd.north-cellhd.south)/cellhd.rows;
-  cellhd.ew_res = (cellhd.east-cellhd.west)/cellhd.cols;
-  
-  if (zoom_view->cell.configured)
-    {
-      R_standard_color (GREY);
-      Outline_cellhd (main_view, &zoom_view->cell.head);    
-    }
-  R_standard_color (RED);              
-  Outline_cellhd (main_view, &cellhd);       
-  
-  if (target_flag)
-    select_target_env();
-  G_adjust_window_to_box (&cellhd, &zoom_view->cell.head, zoom_view->nrows, 
-			  zoom_view->ncols);
-  Configure_view (zoom_view, pick_view->cell.name, pick_view->cell.mapset,
-		  pick_view->cell.ns_res, pick_view->cell.ew_res);
-  
-    
-  drawcell (zoom_view);   
-  select_current_env();
-  display_points(1);
-
-
-  return 0;
-
-}
-
-
-static int 
-
-cancel (void)
-{
-    return -1;
-}
-
-
-
-
-
-
-
-
-
-

Copied: grass-addons/imagery/i.points.auto/overlap_area.c (from rev 30335, grass-addons/i.points.auto/overlap_area.c)
===================================================================
--- grass-addons/imagery/i.points.auto/overlap_area.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/overlap_area.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,141 @@
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+
+static View *pick_view, *zoom_view, *main_view; 
+static int target_flag;
+
+
+int overlap_area(int xp, int yp, int xs, int ys, int n_img, int ncols, int nrows)   
+{
+  
+  int x_1, y_1, x_2, y_2;
+  int tmp_right, tmp_left;
+  int tmp_bottom, tmp_top;
+  int tmp_ncols; 
+  int tmp_nrows; 
+
+  int top, bottom, left, right;
+  int row,col;
+  struct Cell_head cellhd;
+
+
+ 
+  if(n_img==1)
+    {
+      pick_view = VIEW_MAP1;
+      main_view = VIEW_MAP1;
+      zoom_view = VIEW_MAP1_ZOOM;
+      target_flag = 0;
+      printf("info VIEW_MAP1_ZOOM: nrows=%d ncols=%d",zoom_view->nrows,zoom_view->ncols);
+    }  
+  
+  else if (n_img==2)
+    {
+      pick_view = VIEW_MAP2;
+      main_view = VIEW_MAP2;
+      zoom_view = VIEW_MAP2_ZOOM;
+      target_flag = 1;
+    }
+    
+  else
+    return 0;  
+  if (!pick_view->cell.configured) return 0;             /*	just to be sure */
+
+
+  tmp_right = pick_view->cell.right;
+  tmp_left = pick_view->cell.left;
+  tmp_ncols = (tmp_right - tmp_left);
+
+  tmp_bottom = pick_view->cell.bottom;
+  tmp_top = pick_view->cell.top;
+  tmp_nrows = (tmp_bottom - tmp_top);
+
+
+  x_1 = ((tmp_ncols*xp)/ncols);
+  y_1 = (((pick_view->nrows)*yp)/nrows);
+  x_2 = ((tmp_ncols*xs)/ncols);
+  y_2 = (((pick_view->nrows)*ys)/nrows);
+
+
+
+  
+  if (x_1 == x_2 || y_1 == y_2) return 0;      /* ignore event */
+
+
+    
+  top = row_to_view (pick_view, y_1);
+  left = col_to_view (pick_view, x_1);
+  bottom = row_to_view (pick_view, y_2);
+  right = col_to_view (pick_view, x_2);
+ 
+
+  if (!In_view (pick_view,right,bottom)) return 0; 
+    
+
+  Menu_msg("");
+
+  
+  G_copy (&cellhd, &pick_view->cell.head, sizeof(cellhd)); 
+
+
+  col = view_to_col(pick_view,left);
+  row = view_to_row(pick_view,top);
+  cellhd.north = row_to_northing (&pick_view->cell.head,row,0.0);
+  cellhd.west  = col_to_easting  (&pick_view->cell.head,col,0.0);
+
+
+  col = view_to_col(pick_view,right);
+  row = view_to_row(pick_view,bottom);
+  cellhd.south = row_to_northing (&pick_view->cell.head,row,1.0);
+  cellhd.east  = col_to_easting  (&pick_view->cell.head,col,1.0);
+
+  
+    
+  cellhd.rows = bottom-top+1;
+  cellhd.cols = right-left+1;
+  cellhd.ns_res = (cellhd.north-cellhd.south)/cellhd.rows;
+  cellhd.ew_res = (cellhd.east-cellhd.west)/cellhd.cols;
+  
+  if (zoom_view->cell.configured)
+    {
+      R_standard_color (GREY);
+      Outline_cellhd (main_view, &zoom_view->cell.head);    
+    }
+  R_standard_color (RED);              
+  Outline_cellhd (main_view, &cellhd);       
+  
+  if (target_flag)
+    select_target_env();
+  G_adjust_window_to_box (&cellhd, &zoom_view->cell.head, zoom_view->nrows, 
+			  zoom_view->ncols);
+  Configure_view (zoom_view, pick_view->cell.name, pick_view->cell.mapset,
+		  pick_view->cell.ns_res, pick_view->cell.ew_res);
+  
+    
+  drawcell (zoom_view);   
+  select_current_env();
+  display_points(1);
+
+
+  return 0;
+
+}
+
+
+static int 
+
+cancel (void)
+{
+    return -1;
+}
+
+
+
+
+
+
+
+
+
+

Deleted: grass-addons/imagery/i.points.auto/points.c
===================================================================
--- grass-addons/i.points.auto/points.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/points.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,184 +0,0 @@
-#include <grass/raster.h>
-#include <grass/display.h>
-#include "globals.h"
-#include "local_proto.h"
-
-int display_line (View *view, double *east, double *north,int *status,int count);
-
-int display_points (int in_color)
-{
-    display_points_in_view (VIEW_MAP1, in_color,
-	    group.points.e1, group.points.n1,
-	    group.points.status, group.points.count);
-
-    display_points_in_view (VIEW_MAP1_ZOOM, in_color,
-	    group.points.e1, group.points.n1,
-	    group.points.status, group.points.count);
-
-    display_points_in_view (VIEW_MAP2, in_color,
-	    group.points.e2, group.points.n2,
-	    group.points.status, group.points.count);
-
-    display_points_in_view (VIEW_MAP2_ZOOM, in_color,
-	    group.points.e2, group.points.n2,
-	    group.points.status, group.points.count);
-
-    return 0;
-}
-
-int display_points_in_view (View *view, int in_color,
-			    double *east, double *north, int *status, int count)
-{
-    if (!view->cell.configured) return 1;
-    D_cell_draw_setup(view->top, view->bottom,  view->left, view->right);
-    D_set_clip_window(view->top, view->bottom,  view->left, view->right);
-    while (count-- > 0)
-    {
-                if (in_color && ((*status ==2)||(*status ==-2)))
-                       display_line(view,east,  north, status,count);
-                if (in_color && (*status > 0))
-	    R_standard_color (GREEN);
-	else if (in_color && ((*status == 0)||(*status <= -2)))
-	    R_standard_color (RED);
-	else
-	    R_standard_color (GREEN);
-	
-	status++;
-	display_one_point (view, *east++, *north++);
-    }
-
-    return 0;
-}
-
-/*The first point is displayed with BLUE, and the others with GREEN */
-int display_points_in_view_diff_color (View *view, int in_color,
-			    double *east, double *north, int *status, int count)
-{
-    if (!view->cell.configured) return 1;
-    D_cell_draw_setup(view->top, view->bottom,  view->left, view->right);
-    D_set_clip_window(view->top, view->bottom,  view->left, view->right);
-
-    count--;
-    if (in_color && (*status > 0))		  	   
-    R_standard_color (BLUE);
-    status++;    
-    display_one_point (view, *east++, *north++);
-
-
-    while (count-- > 0)
-    {
-                if (in_color && ((*status ==2)||(*status ==-2)))
-                       display_line(view,east,  north, status,count);
-                if (in_color && (*status > 0))		  	   
-		  R_standard_color (GREEN);
-		  
-		else if (in_color && ((*status == 0)||(*status <= -2)))
-		  R_standard_color (RED);
-		else		  
-		  R_standard_color (GREEN);
-		  
-		status++;
-		display_one_point (view, *east++, *north++);
-    }
-
-    return 0;
-}
-
-
-
-/*Displays only the active points (with GREEN) */
-int display_points_in_view_diff_color_if_active (View *view, int in_color,
-			    double *east, double *north, int *status, int count)
-{
-    if (!view->cell.configured) return 1;
-    D_cell_draw_setup(view->top, view->bottom,  view->left, view->right);
-    D_set_clip_window(view->top, view->bottom,  view->left, view->right);
-
-    count--;
-    if (in_color && (*status > 0))		  	   
-    R_standard_color (BLUE);
-    status++;    
-    display_one_point (view, *east++, *north++);
-
-
-    while (count-- > 0)
-    {
-      if (in_color && (*status > 0))		  	
-	{   
-	  R_standard_color (GREEN);
-	  status++;
-	  display_one_point (view, *east++, *north++);
-	}
-      else if (in_color && ((*status == 0)||(*status <= -2)))
-	{
-	  R_standard_color (RED);
-	  status++;
-	  *east++;
-	  *north++;
-	}
-      else		
-	{  
-	  R_standard_color (GREEN);
-      
-	  status++;
-	  display_one_point (view, *east++, *north++);
-	}
-              
-    }
-
-    return 0;
-}
-
-
-
-
-
-
-
-
-
-
-
-int display_one_point (View *view, double east, double north)
-{
-    int row, col, x, y;
-
-    row = northing_to_row (&view->cell.head, north) + .5;
-    col = easting_to_col  (&view->cell.head, east) + .5;
-    y = row_to_view (view, row);
-    x = col_to_view (view, col);
-    if (In_view(view, x, y))
-	dot (x,y);
-
-    return 0;
-}
-
-
-int display_line (View *view, double *east, double *north,int *status,int count)
-   {
-      int row, col, x[2], y[2];
-
-      if (count==0) return 1;
-      if ((*(status +1)!=3) && (*(status+1)!=-3)) return 1;
-
-   row = northing_to_row (&view->cell.head, *north) + .5;
-    col = easting_to_col  (&view->cell.head, *east) + .5;
-    y[0] = row_to_view (view, row);
-    x[0] = col_to_view (view, col);
-
-    row = northing_to_row (&view->cell.head, *(north+1)) + .5;
-    col = easting_to_col  (&view->cell.head, *(east+1)) + .5;
-    y[1] = row_to_view (view, row);
-    x[1] = col_to_view (view, col);
-    if (*status == 2 )
-        R_standard_color (GREEN);
-
-    else   R_standard_color (RED);
-    D_move_abs(x[0],y[0]);
-    D_cont_abs(x[1],y[1]);
-    /*  R_polyline_abs (x,y,2); */
-    /*plot_line(*east,*north,*(east+1),*(north+1)); */
-    R_flush();
-      }
-
-

Copied: grass-addons/imagery/i.points.auto/points.c (from rev 30335, grass-addons/i.points.auto/points.c)
===================================================================
--- grass-addons/imagery/i.points.auto/points.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/points.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,184 @@
+#include <grass/raster.h>
+#include <grass/display.h>
+#include "globals.h"
+#include "local_proto.h"
+
+int display_line (View *view, double *east, double *north,int *status,int count);
+
+int display_points (int in_color)
+{
+    display_points_in_view (VIEW_MAP1, in_color,
+	    group.points.e1, group.points.n1,
+	    group.points.status, group.points.count);
+
+    display_points_in_view (VIEW_MAP1_ZOOM, in_color,
+	    group.points.e1, group.points.n1,
+	    group.points.status, group.points.count);
+
+    display_points_in_view (VIEW_MAP2, in_color,
+	    group.points.e2, group.points.n2,
+	    group.points.status, group.points.count);
+
+    display_points_in_view (VIEW_MAP2_ZOOM, in_color,
+	    group.points.e2, group.points.n2,
+	    group.points.status, group.points.count);
+
+    return 0;
+}
+
+int display_points_in_view (View *view, int in_color,
+			    double *east, double *north, int *status, int count)
+{
+    if (!view->cell.configured) return 1;
+    D_cell_draw_setup(view->top, view->bottom,  view->left, view->right);
+    D_set_clip_window(view->top, view->bottom,  view->left, view->right);
+    while (count-- > 0)
+    {
+                if (in_color && ((*status ==2)||(*status ==-2)))
+                       display_line(view,east,  north, status,count);
+                if (in_color && (*status > 0))
+	    R_standard_color (GREEN);
+	else if (in_color && ((*status == 0)||(*status <= -2)))
+	    R_standard_color (RED);
+	else
+	    R_standard_color (GREEN);
+	
+	status++;
+	display_one_point (view, *east++, *north++);
+    }
+
+    return 0;
+}
+
+/*The first point is displayed with BLUE, and the others with GREEN */
+int display_points_in_view_diff_color (View *view, int in_color,
+			    double *east, double *north, int *status, int count)
+{
+    if (!view->cell.configured) return 1;
+    D_cell_draw_setup(view->top, view->bottom,  view->left, view->right);
+    D_set_clip_window(view->top, view->bottom,  view->left, view->right);
+
+    count--;
+    if (in_color && (*status > 0))		  	   
+    R_standard_color (BLUE);
+    status++;    
+    display_one_point (view, *east++, *north++);
+
+
+    while (count-- > 0)
+    {
+                if (in_color && ((*status ==2)||(*status ==-2)))
+                       display_line(view,east,  north, status,count);
+                if (in_color && (*status > 0))		  	   
+		  R_standard_color (GREEN);
+		  
+		else if (in_color && ((*status == 0)||(*status <= -2)))
+		  R_standard_color (RED);
+		else		  
+		  R_standard_color (GREEN);
+		  
+		status++;
+		display_one_point (view, *east++, *north++);
+    }
+
+    return 0;
+}
+
+
+
+/*Displays only the active points (with GREEN) */
+int display_points_in_view_diff_color_if_active (View *view, int in_color,
+			    double *east, double *north, int *status, int count)
+{
+    if (!view->cell.configured) return 1;
+    D_cell_draw_setup(view->top, view->bottom,  view->left, view->right);
+    D_set_clip_window(view->top, view->bottom,  view->left, view->right);
+
+    count--;
+    if (in_color && (*status > 0))		  	   
+    R_standard_color (BLUE);
+    status++;    
+    display_one_point (view, *east++, *north++);
+
+
+    while (count-- > 0)
+    {
+      if (in_color && (*status > 0))		  	
+	{   
+	  R_standard_color (GREEN);
+	  status++;
+	  display_one_point (view, *east++, *north++);
+	}
+      else if (in_color && ((*status == 0)||(*status <= -2)))
+	{
+	  R_standard_color (RED);
+	  status++;
+	  *east++;
+	  *north++;
+	}
+      else		
+	{  
+	  R_standard_color (GREEN);
+      
+	  status++;
+	  display_one_point (view, *east++, *north++);
+	}
+              
+    }
+
+    return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+int display_one_point (View *view, double east, double north)
+{
+    int row, col, x, y;
+
+    row = northing_to_row (&view->cell.head, north) + .5;
+    col = easting_to_col  (&view->cell.head, east) + .5;
+    y = row_to_view (view, row);
+    x = col_to_view (view, col);
+    if (In_view(view, x, y))
+	dot (x,y);
+
+    return 0;
+}
+
+
+int display_line (View *view, double *east, double *north,int *status,int count)
+   {
+      int row, col, x[2], y[2];
+
+      if (count==0) return 1;
+      if ((*(status +1)!=3) && (*(status+1)!=-3)) return 1;
+
+   row = northing_to_row (&view->cell.head, *north) + .5;
+    col = easting_to_col  (&view->cell.head, *east) + .5;
+    y[0] = row_to_view (view, row);
+    x[0] = col_to_view (view, col);
+
+    row = northing_to_row (&view->cell.head, *(north+1)) + .5;
+    col = easting_to_col  (&view->cell.head, *(east+1)) + .5;
+    y[1] = row_to_view (view, row);
+    x[1] = col_to_view (view, col);
+    if (*status == 2 )
+        R_standard_color (GREEN);
+
+    else   R_standard_color (RED);
+    D_move_abs(x[0],y[0]);
+    D_cont_abs(x[1],y[1]);
+    /*  R_polyline_abs (x,y,2); */
+    /*plot_line(*east,*north,*(east+1),*(north+1)); */
+    R_flush();
+      }
+
+

Deleted: grass-addons/imagery/i.points.auto/target.c
===================================================================
--- grass-addons/i.points.auto/target.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/target.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,71 +0,0 @@
-#include <unistd.h>
-#include <string.h>
-#include "globals.h"
-
-/* read the target for the group and cast it into the alternate GRASS env */
-
-static int which_env;
-
-int get_target (void)
-{
-    char location[40];
-    char mapset[40];
-    char buf[1024];
-    int stat;
-
-    if (!I_get_target(group.name, location, mapset))
-    {
-	sprintf(buf, "Target information for group [%s] missing\n", group.name);
-	goto error;
-    }
-
-    sprintf (buf, "%s/%s", G_gisdbase(), location);
-    if (access(buf,0) != 0)
-    {
-	sprintf (buf,"Target location [%s] not found\n", location);
-	goto error;
-    }
-    G__create_alt_env();
-    G__setenv ("LOCATION_NAME", location);
-    stat = G__mapset_permissions(mapset);
-    if (stat > 0)
-    {
-	G__setenv ("MAPSET", mapset);
-	G__create_alt_search_path();
-	G__switch_env();
-	G__switch_search_path();
-	which_env = 0;
-	return 1;
-    }
-    sprintf (buf, "Mapset [%s] in target location [%s] - ",
-		mapset, location);
-    strcat (buf, stat == 0 ? "permission denied\n" : "not found\n");
-error:
-    strcat (buf, "Please run i.target for group ");
-    strcat (buf, group.name);
-    G_fatal_error (buf);
-}
-
-int select_current_env (void)
-{
-    if (which_env != 0)
-    {
-	G__switch_env();
-	G__switch_search_path();
-	which_env = 0;
-    }
-
-    return 0;
-}
-
-int select_target_env (void)
-{
-    if (which_env != 1)
-    {
-	G__switch_env();
-	G__switch_search_path();
-	which_env = 1;
-    }
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/target.c (from rev 30335, grass-addons/i.points.auto/target.c)
===================================================================
--- grass-addons/imagery/i.points.auto/target.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/target.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,71 @@
+#include <unistd.h>
+#include <string.h>
+#include "globals.h"
+
+/* read the target for the group and cast it into the alternate GRASS env */
+
+static int which_env;
+
+int get_target (void)
+{
+    char location[40];
+    char mapset[40];
+    char buf[1024];
+    int stat;
+
+    if (!I_get_target(group.name, location, mapset))
+    {
+	sprintf(buf, "Target information for group [%s] missing\n", group.name);
+	goto error;
+    }
+
+    sprintf (buf, "%s/%s", G_gisdbase(), location);
+    if (access(buf,0) != 0)
+    {
+	sprintf (buf,"Target location [%s] not found\n", location);
+	goto error;
+    }
+    G__create_alt_env();
+    G__setenv ("LOCATION_NAME", location);
+    stat = G__mapset_permissions(mapset);
+    if (stat > 0)
+    {
+	G__setenv ("MAPSET", mapset);
+	G__create_alt_search_path();
+	G__switch_env();
+	G__switch_search_path();
+	which_env = 0;
+	return 1;
+    }
+    sprintf (buf, "Mapset [%s] in target location [%s] - ",
+		mapset, location);
+    strcat (buf, stat == 0 ? "permission denied\n" : "not found\n");
+error:
+    strcat (buf, "Please run i.target for group ");
+    strcat (buf, group.name);
+    G_fatal_error (buf);
+}
+
+int select_current_env (void)
+{
+    if (which_env != 0)
+    {
+	G__switch_env();
+	G__switch_search_path();
+	which_env = 0;
+    }
+
+    return 0;
+}
+
+int select_target_env (void)
+{
+    if (which_env != 1)
+    {
+	G__switch_env();
+	G__switch_search_path();
+	which_env = 1;
+    }
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/title.c
===================================================================
--- grass-addons/i.points.auto/title.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/title.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,56 +0,0 @@
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-
-int 
-display_title (View *view)
-{
-    View *title;
-    char left[100], center[100];
-    int size;
-    double magnification();
-
-    *left = 0;
-    *center = 0;
-
-    if (view->cell.configured)
-    {
-	sprintf (center, "%s (mag %.1f)",
-	    view->cell.name, magnification (view));
-    }
-
-    if (view == VIEW_MAP1)
-    {
-	sprintf (left, "%s", G_location());
-	title = VIEW_TITLE1;
-    }
-    else if (view == VIEW_MAP1_ZOOM)
-    {
-	title = VIEW_TITLE1_ZOOM;
-    }
-
-    if (view == VIEW_MAP2)
-    {
-	sprintf (left, "%s", G_location());
-	title = VIEW_TITLE2;
-    }
-    else if (view == VIEW_MAP2_ZOOM)
-    {
-	title = VIEW_TITLE2_ZOOM;
-    }
-
-    Erase_view (title);
-    R_standard_color (ORANGE); /*WHITE*/
-    size = title->nrows - 4;
-    R_text_size (size, size);
-    Text (left, title->top, title->bottom, title->left, title->right, 2);
-    if (*center)
-    {
-	R_standard_color (YELLOW);
-	Text (center, title->top, title->bottom,
-		(title->left + title->right - Text_width (center)) / 2,
-		title->right, 2);
-    }
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/title.c (from rev 30335, grass-addons/i.points.auto/title.c)
===================================================================
--- grass-addons/imagery/i.points.auto/title.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/title.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,56 @@
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+
+int 
+display_title (View *view)
+{
+    View *title;
+    char left[100], center[100];
+    int size;
+    double magnification();
+
+    *left = 0;
+    *center = 0;
+
+    if (view->cell.configured)
+    {
+	sprintf (center, "%s (mag %.1f)",
+	    view->cell.name, magnification (view));
+    }
+
+    if (view == VIEW_MAP1)
+    {
+	sprintf (left, "%s", G_location());
+	title = VIEW_TITLE1;
+    }
+    else if (view == VIEW_MAP1_ZOOM)
+    {
+	title = VIEW_TITLE1_ZOOM;
+    }
+
+    if (view == VIEW_MAP2)
+    {
+	sprintf (left, "%s", G_location());
+	title = VIEW_TITLE2;
+    }
+    else if (view == VIEW_MAP2_ZOOM)
+    {
+	title = VIEW_TITLE2_ZOOM;
+    }
+
+    Erase_view (title);
+    R_standard_color (ORANGE); /*WHITE*/
+    size = title->nrows - 4;
+    R_text_size (size, size);
+    Text (left, title->top, title->bottom, title->left, title->right, 2);
+    if (*center)
+    {
+	R_standard_color (YELLOW);
+	Text (center, title->top, title->bottom,
+		(title->left + title->right - Text_width (center)) / 2,
+		title->right, 2);
+    }
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/view.c
===================================================================
--- grass-addons/i.points.auto/view.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/view.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,57 +0,0 @@
-#include <string.h>
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-
-int Configure_view (
-    View *view,
-    char *name,
-    char *mapset,
-    double ns_res,
-    double ew_res	/* original map resolution */
-)
-{
-    Erase_view(view);
-    view->cell.configured = 0;
-
-/* copy the cell name into the view */
-    strcpy (view->cell.name, name);
-    strcpy (view->cell.mapset, mapset);
-
-/* determine the map edges */
-    view->cell.left   = view->left + (view->ncols - view->cell.head.cols)/2;
-    view->cell.right  = view->cell.left + view->cell.head.cols - 1;
-    view->cell.top    = view->top  + (view->nrows - view->cell.head.rows)/2;
-    view->cell.bottom = view->cell.top + view->cell.head.rows - 1;
-
-/* remember original resolutions */
-    view->cell.ns_res = ns_res;
-    view->cell.ew_res = ew_res;
-
-    view->cell.configured = 1;
-
-    return 0;
-}
-
-int 
-In_view (View *view, int x, int y)
-{
-    return (x >= view->left && x <= view->right && y >= view->top && y <= view->bottom);
-}
-
-int 
-Erase_view (View *view)
-{
-    R_standard_color (BLUE);
-    R_box_abs (view->left, view->top, view->right, view->bottom);
-
-    return 0;
-}
-
-double 
-magnification (View *view)
-{
-    if (!view->cell.configured)
-	return ((double) 0.0);
-    return (view->cell.ew_res / view->cell.head.ew_res);
-}

Copied: grass-addons/imagery/i.points.auto/view.c (from rev 30335, grass-addons/i.points.auto/view.c)
===================================================================
--- grass-addons/imagery/i.points.auto/view.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/view.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,57 @@
+#include <string.h>
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+
+int Configure_view (
+    View *view,
+    char *name,
+    char *mapset,
+    double ns_res,
+    double ew_res	/* original map resolution */
+)
+{
+    Erase_view(view);
+    view->cell.configured = 0;
+
+/* copy the cell name into the view */
+    strcpy (view->cell.name, name);
+    strcpy (view->cell.mapset, mapset);
+
+/* determine the map edges */
+    view->cell.left   = view->left + (view->ncols - view->cell.head.cols)/2;
+    view->cell.right  = view->cell.left + view->cell.head.cols - 1;
+    view->cell.top    = view->top  + (view->nrows - view->cell.head.rows)/2;
+    view->cell.bottom = view->cell.top + view->cell.head.rows - 1;
+
+/* remember original resolutions */
+    view->cell.ns_res = ns_res;
+    view->cell.ew_res = ew_res;
+
+    view->cell.configured = 1;
+
+    return 0;
+}
+
+int 
+In_view (View *view, int x, int y)
+{
+    return (x >= view->left && x <= view->right && y >= view->top && y <= view->bottom);
+}
+
+int 
+Erase_view (View *view)
+{
+    R_standard_color (BLUE);
+    R_box_abs (view->left, view->top, view->right, view->bottom);
+
+    return 0;
+}
+
+double 
+magnification (View *view)
+{
+    if (!view->cell.configured)
+	return ((double) 0.0);
+    return (view->cell.ew_res / view->cell.head.ew_res);
+}

Deleted: grass-addons/imagery/i.points.auto/where.c
===================================================================
--- grass-addons/i.points.auto/where.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/where.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,66 +0,0 @@
-#include "globals.h"
-#include "local_proto.h"
-
-static int where_12 (View *,int,int);
-static int where_21 (View *,int,int);
-static int where_am_i (View *,int,int,Window *,double *,double *,Window *);
-
-int where (int x, int y)
-{
-    if (VIEW_MAP1->cell.configured && In_view (VIEW_MAP1, x, y))
-	where_12 (VIEW_MAP1, x, y);
-    else if (VIEW_MAP1_ZOOM->cell.configured && In_view (VIEW_MAP1_ZOOM, x, y))
-	where_12 (VIEW_MAP1_ZOOM, x, y);
-    else if (VIEW_MAP2->cell.configured && In_view (VIEW_MAP2, x, y))
-	where_21 (VIEW_MAP2, x, y);
-    else if (VIEW_MAP2_ZOOM->cell.configured && In_view (VIEW_MAP2_ZOOM, x, y))
-	where_21 (VIEW_MAP2_ZOOM, x, y);
-    return 0 ; /* return but don't quit */
-}
-
-static int where_12 (View *view,int x, int y)
-{
-    where_am_i (view, x, y, MENU_WINDOW, group.E12, group.N12, INFO_WINDOW);
-
-    return 0;
-}
-
-static int where_21 (View *view,int x, int y)
-{
-    where_am_i (view, x, y, INFO_WINDOW, group.E21, group.N21, MENU_WINDOW);
-
-    return 0;
-}
-
-static int where_am_i (View *view,int x, int y,Window *w1,
-    double *E,double *N,Window *w2)
-{
-    double e1,n1,e2,n2;
-    int row,col;
-
-    char buf[100];
-
-/* convert x,y to east,north at center of cell */
-    col = view_to_col (view, x);
-    e1 = col_to_easting (&view->cell.head, col, 0.5);
-    row = view_to_row (view, y);
-    n1 = row_to_northing (&view->cell.head, row, 0.5);
-
-    Curses_clear_window (w1);
-    sprintf (buf, "East:  %10.2f", e1);
-    Curses_write_window (w1, 3, 3, buf);
-    sprintf (buf, "North: %10.2f", n1);
-    Curses_write_window (w1, 4, 3, buf);
-
-/* if transformation equation is useable, determine point via equation */
-    if (group.equation_stat <= 0) return 1;
-
-    I_georef (e1, n1, &e2, &n2, E, N);
-    Curses_clear_window (w2);
-    sprintf (buf, "East:  %10.2f", e2);
-    Curses_write_window (w2, 3, 3, buf);
-    sprintf (buf, "North: %10.2f", n2);
-    Curses_write_window (w2, 4, 3, buf);
-
-    return 0;
-}

Copied: grass-addons/imagery/i.points.auto/where.c (from rev 30335, grass-addons/i.points.auto/where.c)
===================================================================
--- grass-addons/imagery/i.points.auto/where.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/where.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,66 @@
+#include "globals.h"
+#include "local_proto.h"
+
+static int where_12 (View *,int,int);
+static int where_21 (View *,int,int);
+static int where_am_i (View *,int,int,Window *,double *,double *,Window *);
+
+int where (int x, int y)
+{
+    if (VIEW_MAP1->cell.configured && In_view (VIEW_MAP1, x, y))
+	where_12 (VIEW_MAP1, x, y);
+    else if (VIEW_MAP1_ZOOM->cell.configured && In_view (VIEW_MAP1_ZOOM, x, y))
+	where_12 (VIEW_MAP1_ZOOM, x, y);
+    else if (VIEW_MAP2->cell.configured && In_view (VIEW_MAP2, x, y))
+	where_21 (VIEW_MAP2, x, y);
+    else if (VIEW_MAP2_ZOOM->cell.configured && In_view (VIEW_MAP2_ZOOM, x, y))
+	where_21 (VIEW_MAP2_ZOOM, x, y);
+    return 0 ; /* return but don't quit */
+}
+
+static int where_12 (View *view,int x, int y)
+{
+    where_am_i (view, x, y, MENU_WINDOW, group.E12, group.N12, INFO_WINDOW);
+
+    return 0;
+}
+
+static int where_21 (View *view,int x, int y)
+{
+    where_am_i (view, x, y, INFO_WINDOW, group.E21, group.N21, MENU_WINDOW);
+
+    return 0;
+}
+
+static int where_am_i (View *view,int x, int y,Window *w1,
+    double *E,double *N,Window *w2)
+{
+    double e1,n1,e2,n2;
+    int row,col;
+
+    char buf[100];
+
+/* convert x,y to east,north at center of cell */
+    col = view_to_col (view, x);
+    e1 = col_to_easting (&view->cell.head, col, 0.5);
+    row = view_to_row (view, y);
+    n1 = row_to_northing (&view->cell.head, row, 0.5);
+
+    Curses_clear_window (w1);
+    sprintf (buf, "East:  %10.2f", e1);
+    Curses_write_window (w1, 3, 3, buf);
+    sprintf (buf, "North: %10.2f", n1);
+    Curses_write_window (w1, 4, 3, buf);
+
+/* if transformation equation is useable, determine point via equation */
+    if (group.equation_stat <= 0) return 1;
+
+    I_georef (e1, n1, &e2, &n2, E, N);
+    Curses_clear_window (w2);
+    sprintf (buf, "East:  %10.2f", e2);
+    Curses_write_window (w2, 3, 3, buf);
+    sprintf (buf, "North: %10.2f", n2);
+    Curses_write_window (w2, 4, 3, buf);
+
+    return 0;
+}

Deleted: grass-addons/imagery/i.points.auto/zoom.c
===================================================================
--- grass-addons/i.points.auto/zoom.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/zoom.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,53 +0,0 @@
-#include "globals.h"
-#include "local_proto.h"
-
-static int cancel();
-static int use_zoom_box = 1;
-static int use_zoom_pnt = 0;
-
-
-
-int zoom()
-{
-    static int use = 1;
-    int cancel();
-    /*static int which_zoom();*/
-
-   static Objects objects[]=
-    {
-      MENU("CANCEL",cancel,&use),
-      INFO("Current ZOOM Type.",&use),
-      OPTION("BOX",   2, &use_zoom_box),
-      OPTION("POINT", 2, &use_zoom_pnt),
-      OTHER(which_zoom, &use),
-      {0}
- };
-
-  Input_pointer (objects);
-  return 0;	/* return, but don't QUIT */
-}
-
-static int
-which_zoom(int x,int y,int button)
-{
-
-  /* Button one to set point, Button 2 & 3 return location */
-  if (button != 1)
-    return where (x,y);
-
-
-  if (use_zoom_box == 1)
-    zoom_box(x,y);             
-  else zoom_pnt(x,y);
-
-  return 0;
-}
-
-
-
-
-static int 
-cancel (void)
-{
-    return -1;
-}

Copied: grass-addons/imagery/i.points.auto/zoom.c (from rev 30335, grass-addons/i.points.auto/zoom.c)
===================================================================
--- grass-addons/imagery/i.points.auto/zoom.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/zoom.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,53 @@
+#include "globals.h"
+#include "local_proto.h"
+
+static int cancel();
+static int use_zoom_box = 1;
+static int use_zoom_pnt = 0;
+
+
+
+int zoom()
+{
+    static int use = 1;
+    int cancel();
+    /*static int which_zoom();*/
+
+   static Objects objects[]=
+    {
+      MENU("CANCEL",cancel,&use),
+      INFO("Current ZOOM Type.",&use),
+      OPTION("BOX",   2, &use_zoom_box),
+      OPTION("POINT", 2, &use_zoom_pnt),
+      OTHER(which_zoom, &use),
+      {0}
+ };
+
+  Input_pointer (objects);
+  return 0;	/* return, but don't QUIT */
+}
+
+static int
+which_zoom(int x,int y,int button)
+{
+
+  /* Button one to set point, Button 2 & 3 return location */
+  if (button != 1)
+    return where (x,y);
+
+
+  if (use_zoom_box == 1)
+    zoom_box(x,y);             
+  else zoom_pnt(x,y);
+
+  return 0;
+}
+
+
+
+
+static int 
+cancel (void)
+{
+    return -1;
+}

Deleted: grass-addons/imagery/i.points.auto/zoom_box.c
===================================================================
--- grass-addons/i.points.auto/zoom_box.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/zoom_box.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,193 +0,0 @@
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-
-
-static int zoom2(int,int);
-static int cancel(void);
-
-static int x1, y1, x2, y2;
-static View *pick_view, *zoom_view, *main_view;
-static int target_flag;
-
-
-
-int zoom_box (int x,int y)	/* called by Input_pointer */
-{
-    static int use = 1;
-    int zoom2();
-    int cancel();
-
-    static Objects objects[] =
-    {
-	MENU("CANCEL",cancel,&use),
-	INFO(" Define the region ",&use),
-	OTHER(zoom2,&use),
-	{0}
-    };
-
-/* 
- * user has marked first corner 
- * this determines which view is being zoomed
- */
-    x1 = x;
-    y1 = y;
-
-    if (In_view (pick_view = VIEW_MAP1, x1, y1))
-    {
-	main_view = VIEW_MAP1;
-	zoom_view = VIEW_MAP1_ZOOM;
-	target_flag = 0;
-	printf("info VIEW_MAP1_ZOOM: nrows=%d ncols=%d",zoom_view->nrows,zoom_view->ncols);  
-    }
-    else if (In_view (pick_view = VIEW_MAP2, x1, y1))
-    {
-	if (!pick_view->cell.configured)
-	  return 0;	/* ignore the mouse event */
-	main_view = VIEW_MAP2;
-	zoom_view = VIEW_MAP2_ZOOM;
-	target_flag = 1;
-    }
-    else if (In_view (pick_view = VIEW_MAP1_ZOOM, x1, y1))
-      {
-	if (!pick_view->cell.configured)
-	  return 0;	/* ignore the mouse event */
-	main_view = VIEW_MAP1;
-	zoom_view = VIEW_MAP1_ZOOM;
-	target_flag = 0;
-      }
-    else if (In_view (pick_view = VIEW_MAP2_ZOOM, x1, y1))
-      {
-	if (!pick_view->cell.configured)
-	    return 0;	/* ignore the mouse event */
-	main_view = VIEW_MAP2;
-	zoom_view = VIEW_MAP2_ZOOM;
-	target_flag = 1;
-    }
-    else
-	return 0;	/* ignore the mouse event */
-    if (!pick_view->cell.configured) return 0;	/* just to be sure */
-
-    return Input_box (objects, x, y);
-}
-
-
-
-
-static int zoom2(int x,int y)
-{
-    int top, bottom, left, right;
-    int row,col;
-    struct Cell_head cellhd;
-
-    x2 = x;
-    y2 = y;
-/* 
- * user has completed the zoom window.
- * must be in same view as first corner
- */
-
-    if (x1 == x2 || y1 == y2) return 0;	/* ignore event */
-    if (!In_view (pick_view,x2,y2)) return 0;
-
-/*
- * ok, erase menu messages
- */
- 
-   Menu_msg("");
-
-/*
- * assign window coordinates to top,bottom,left,right
- */
-    if (x1 < x2)
-    {
-	left = x1;
-	right = x2;
-    }
-    else
-    {
-	left = x2;
-	right = x1;
-    }
-    if (y1 < y2)
-    {
-	top = y1;
-	bottom = y2;
-    }
-    else
-    {
-	top = y2;
-	bottom = y1;
-    }
-
-/* 
- * Determine the zoom window (ie, cellhd)
- * must copy the current view cellhd first, to preserve header info
- * (such as projection, zone, and other items.)
- * compute zoom window northings,eastings, rows, cols, and resolution
- */
-
-    G_copy (&cellhd, &pick_view->cell.head, sizeof(cellhd));
-
-/* 
- * convert top to northing at top edge of cell
- * left to easting at left edge
- */
-    col = view_to_col(pick_view,left);
-    row = view_to_row(pick_view,top);
-    cellhd.north = row_to_northing (&pick_view->cell.head,row,0.0);
-    cellhd.west  = col_to_easting  (&pick_view->cell.head,col,0.0);
-
-/* 
- * convert bottom to northing at bottom edge of cell
- * right to easting at right edge
- */
-    col = view_to_col(pick_view,right);
-    row = view_to_row(pick_view,bottom);
-    cellhd.south = row_to_northing (&pick_view->cell.head,row,1.0);
-    cellhd.east  = col_to_easting  (&pick_view->cell.head,col,1.0);
-
-
-    cellhd.rows = bottom-top+1;
-    cellhd.cols = right-left+1;
-    cellhd.ns_res = (cellhd.north-cellhd.south)/cellhd.rows;
-    cellhd.ew_res = (cellhd.east-cellhd.west)/cellhd.cols;
-
-/*
- * Outline the zoom window on the main map
- * Turn previous one to grey.
- */
-    if (zoom_view->cell.configured)
-    {
-	R_standard_color (GREY);
-	Outline_cellhd (main_view, &zoom_view->cell.head);
-    }
-    R_standard_color (RED);
-    Outline_cellhd (main_view, &cellhd);
-
-
-/*
- * zoom
- */
-    if (target_flag)
-	select_target_env();
-    G_adjust_window_to_box (&cellhd, &zoom_view->cell.head, zoom_view->nrows, 
-			    zoom_view->ncols);
-    Configure_view (zoom_view, pick_view->cell.name, pick_view->cell.mapset,
-		    pick_view->cell.ns_res, pick_view->cell.ew_res);
-
-
-    
-    drawcell (zoom_view);
-    select_current_env();
-    display_points(1);
-    return 1;	/* pop back */
-
-}
-
-static int 
-
-cancel (void)
-{
-    return -1;
-}

Copied: grass-addons/imagery/i.points.auto/zoom_box.c (from rev 30335, grass-addons/i.points.auto/zoom_box.c)
===================================================================
--- grass-addons/imagery/i.points.auto/zoom_box.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/zoom_box.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,193 @@
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+
+
+static int zoom2(int,int);
+static int cancel(void);
+
+static int x1, y1, x2, y2;
+static View *pick_view, *zoom_view, *main_view;
+static int target_flag;
+
+
+
+int zoom_box (int x,int y)	/* called by Input_pointer */
+{
+    static int use = 1;
+    int zoom2();
+    int cancel();
+
+    static Objects objects[] =
+    {
+	MENU("CANCEL",cancel,&use),
+	INFO(" Define the region ",&use),
+	OTHER(zoom2,&use),
+	{0}
+    };
+
+/* 
+ * user has marked first corner 
+ * this determines which view is being zoomed
+ */
+    x1 = x;
+    y1 = y;
+
+    if (In_view (pick_view = VIEW_MAP1, x1, y1))
+    {
+	main_view = VIEW_MAP1;
+	zoom_view = VIEW_MAP1_ZOOM;
+	target_flag = 0;
+	printf("info VIEW_MAP1_ZOOM: nrows=%d ncols=%d",zoom_view->nrows,zoom_view->ncols);  
+    }
+    else if (In_view (pick_view = VIEW_MAP2, x1, y1))
+    {
+	if (!pick_view->cell.configured)
+	  return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP2;
+	zoom_view = VIEW_MAP2_ZOOM;
+	target_flag = 1;
+    }
+    else if (In_view (pick_view = VIEW_MAP1_ZOOM, x1, y1))
+      {
+	if (!pick_view->cell.configured)
+	  return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP1;
+	zoom_view = VIEW_MAP1_ZOOM;
+	target_flag = 0;
+      }
+    else if (In_view (pick_view = VIEW_MAP2_ZOOM, x1, y1))
+      {
+	if (!pick_view->cell.configured)
+	    return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP2;
+	zoom_view = VIEW_MAP2_ZOOM;
+	target_flag = 1;
+    }
+    else
+	return 0;	/* ignore the mouse event */
+    if (!pick_view->cell.configured) return 0;	/* just to be sure */
+
+    return Input_box (objects, x, y);
+}
+
+
+
+
+static int zoom2(int x,int y)
+{
+    int top, bottom, left, right;
+    int row,col;
+    struct Cell_head cellhd;
+
+    x2 = x;
+    y2 = y;
+/* 
+ * user has completed the zoom window.
+ * must be in same view as first corner
+ */
+
+    if (x1 == x2 || y1 == y2) return 0;	/* ignore event */
+    if (!In_view (pick_view,x2,y2)) return 0;
+
+/*
+ * ok, erase menu messages
+ */
+ 
+   Menu_msg("");
+
+/*
+ * assign window coordinates to top,bottom,left,right
+ */
+    if (x1 < x2)
+    {
+	left = x1;
+	right = x2;
+    }
+    else
+    {
+	left = x2;
+	right = x1;
+    }
+    if (y1 < y2)
+    {
+	top = y1;
+	bottom = y2;
+    }
+    else
+    {
+	top = y2;
+	bottom = y1;
+    }
+
+/* 
+ * Determine the zoom window (ie, cellhd)
+ * must copy the current view cellhd first, to preserve header info
+ * (such as projection, zone, and other items.)
+ * compute zoom window northings,eastings, rows, cols, and resolution
+ */
+
+    G_copy (&cellhd, &pick_view->cell.head, sizeof(cellhd));
+
+/* 
+ * convert top to northing at top edge of cell
+ * left to easting at left edge
+ */
+    col = view_to_col(pick_view,left);
+    row = view_to_row(pick_view,top);
+    cellhd.north = row_to_northing (&pick_view->cell.head,row,0.0);
+    cellhd.west  = col_to_easting  (&pick_view->cell.head,col,0.0);
+
+/* 
+ * convert bottom to northing at bottom edge of cell
+ * right to easting at right edge
+ */
+    col = view_to_col(pick_view,right);
+    row = view_to_row(pick_view,bottom);
+    cellhd.south = row_to_northing (&pick_view->cell.head,row,1.0);
+    cellhd.east  = col_to_easting  (&pick_view->cell.head,col,1.0);
+
+
+    cellhd.rows = bottom-top+1;
+    cellhd.cols = right-left+1;
+    cellhd.ns_res = (cellhd.north-cellhd.south)/cellhd.rows;
+    cellhd.ew_res = (cellhd.east-cellhd.west)/cellhd.cols;
+
+/*
+ * Outline the zoom window on the main map
+ * Turn previous one to grey.
+ */
+    if (zoom_view->cell.configured)
+    {
+	R_standard_color (GREY);
+	Outline_cellhd (main_view, &zoom_view->cell.head);
+    }
+    R_standard_color (RED);
+    Outline_cellhd (main_view, &cellhd);
+
+
+/*
+ * zoom
+ */
+    if (target_flag)
+	select_target_env();
+    G_adjust_window_to_box (&cellhd, &zoom_view->cell.head, zoom_view->nrows, 
+			    zoom_view->ncols);
+    Configure_view (zoom_view, pick_view->cell.name, pick_view->cell.mapset,
+		    pick_view->cell.ns_res, pick_view->cell.ew_res);
+
+
+    
+    drawcell (zoom_view);
+    select_current_env();
+    display_points(1);
+    return 1;	/* pop back */
+
+}
+
+static int 
+
+cancel (void)
+{
+    return -1;
+}

Deleted: grass-addons/imagery/i.points.auto/zoom_pnt.c
===================================================================
--- grass-addons/i.points.auto/zoom_pnt.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.points.auto/zoom_pnt.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,179 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include <grass/raster.h>
-#include "globals.h"
-#include "local_proto.h"
-
-static int cancel(void);
-
-static View *pick_view, *zoom_view, *main_view;
-static int target_flag;
-
-int zoom_pnt (int x,int y)	/* called by Input_pointer */
-{
-    int top, bottom, left, right;
-    int n,row,col;
-    int nrows, ncols;
-    struct Cell_head cellhd;
-    int mag;
-    double magnification();
-    double north, south, east, west;
-
-    if (In_view (pick_view = VIEW_MAP1, x, y))
-    {
-	main_view = VIEW_MAP1;
-	zoom_view = VIEW_MAP1_ZOOM;
-	target_flag = 0;
-    }
-    else if (In_view (pick_view = VIEW_MAP2, x, y))
-    {
-	if (!pick_view->cell.configured)
-	    return 0;	/* ignore the mouse event */
-	main_view = VIEW_MAP2;
-	zoom_view = VIEW_MAP2_ZOOM;
-	target_flag = 1;
-    }
-    else if (In_view (pick_view = VIEW_MAP1_ZOOM, x, y))
-    {
-	if (!pick_view->cell.configured)
-	    return 0;	/* ignore the mouse event */
-	main_view = VIEW_MAP1;
-	zoom_view = VIEW_MAP1_ZOOM;
-	target_flag = 0;
-    }
-    else if (In_view (pick_view = VIEW_MAP2_ZOOM, x, y))
-    {
-	if (!pick_view->cell.configured)
-	    return 0;	/* ignore the mouse event */
-	main_view = VIEW_MAP2;
-	zoom_view = VIEW_MAP2_ZOOM;
-	target_flag = 1;
-    }
-    else
-	return 0;	/* ignore the mouse event */
-    if (!pick_view->cell.configured) return 0;	/* just to be sure */
-/*
- * make sure point is within edges of image as well
- */
-    if (x <= pick_view->cell.left) return 0;
-    if (x >= pick_view->cell.right) return 0;
-    if (y <= pick_view->cell.top) return 0;
-    if (y >= pick_view->cell.bottom) return 0;
-
-
-/*
- * ok, erase menu messages
- */
-    Menu_msg("");
-
-/* determine magnification of zoom */
-    if (zoom_view->cell.configured)
-    {
-	if (zoom_view == pick_view)
-	    mag = floor(magnification (zoom_view) + 1.0) + .1;
-	else
-	    mag = ceil(magnification (zoom_view)) + .1;
-    }
-    else
-    {
-	mag = floor(magnification (main_view) + 1.0) + .1;
-    }
-    if(!ask_magnification (&mag))
-	return 1;
-/* 
- * Determine the the zoom window (ie, cellhd)
- */
-
-    G_copy (&cellhd, &main_view->cell.head, sizeof(cellhd));
-    cellhd.ns_res = main_view->cell.ns_res / mag;
-    cellhd.ew_res = main_view->cell.ew_res / mag;
-    cellhd.cols   = (cellhd.east - cellhd.west) / cellhd.ew_res;
-    cellhd.rows   = (cellhd.north - cellhd.south) / cellhd.ns_res;
-
-
-/* convert x,y to col,row */
-
-    col  = view_to_col(pick_view,x);
-    east = col_to_easting (&pick_view->cell.head, col, 0.5);
-    col  = easting_to_col (&cellhd, east);
-
-    row   = view_to_row(pick_view,y);
-    north = row_to_northing (&pick_view->cell.head, row, 0.5);
-    row   = northing_to_row (&cellhd, north);
-
-    ncols = zoom_view->ncols ;
-    nrows = zoom_view->nrows ;
-
-
-    n = cellhd.cols - col;
-    if (n > col)
-	n = col;
-    if (n+n+1 >= ncols)
-    {
-	n = ncols/2;
-	if (n+n+1 >= ncols) n--;
-    }
-    left = col - n;
-    right = col + n;
-
-    n = cellhd.rows - row;
-    if (n > row)
-	n = row;
-    if (n+n+1 >= nrows)
-    {
-	n = nrows/2;
-	if (n+n+1 >= nrows) n--;
-    }
-    top = row - n;
-    bottom = row + n;
-
-
-    north = row_to_northing (&cellhd, top,0.0);
-    west  = col_to_easting  (&cellhd,left,0.0);
-    south = row_to_northing (&cellhd,bottom,1.0);
-    east  = col_to_easting  (&cellhd,right,1.0);
-
-
-    cellhd.north = north;
-    cellhd.south = south;
-    cellhd.east  = east ;
-    cellhd.west  = west ;
-
-    cellhd.rows = (cellhd.north-cellhd.south)/cellhd.ns_res;
-    cellhd.cols = (cellhd.east-cellhd.west)/cellhd.ew_res ;
-
-/*
- * Outline the zoom window on the main map
- * Turn previous one to grey.
- */
-    if (zoom_view->cell.configured)
-    {
-	R_standard_color (GREY);
-	Outline_cellhd (main_view, &zoom_view->cell.head);
-    }
-    R_standard_color (RED);
-    Outline_cellhd (main_view, &cellhd);
-
-
-/*
- * zoom
- */
-    if (target_flag)
-	select_target_env();
-    G_copy (&zoom_view->cell.head, &cellhd, sizeof (cellhd));
-    Configure_view (zoom_view, pick_view->cell.name, pick_view->cell.mapset,
-	pick_view->cell.ns_res, pick_view->cell.ew_res);
-    drawcell (zoom_view);
-    select_current_env();
-    display_points(1);
-
-    return 1;	/* pop back */
-}
-
-
-static int 
-cancel (void)
-{
-    return -1;
-}

Copied: grass-addons/imagery/i.points.auto/zoom_pnt.c (from rev 30335, grass-addons/i.points.auto/zoom_pnt.c)
===================================================================
--- grass-addons/imagery/i.points.auto/zoom_pnt.c	                        (rev 0)
+++ grass-addons/imagery/i.points.auto/zoom_pnt.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,179 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <grass/raster.h>
+#include "globals.h"
+#include "local_proto.h"
+
+static int cancel(void);
+
+static View *pick_view, *zoom_view, *main_view;
+static int target_flag;
+
+int zoom_pnt (int x,int y)	/* called by Input_pointer */
+{
+    int top, bottom, left, right;
+    int n,row,col;
+    int nrows, ncols;
+    struct Cell_head cellhd;
+    int mag;
+    double magnification();
+    double north, south, east, west;
+
+    if (In_view (pick_view = VIEW_MAP1, x, y))
+    {
+	main_view = VIEW_MAP1;
+	zoom_view = VIEW_MAP1_ZOOM;
+	target_flag = 0;
+    }
+    else if (In_view (pick_view = VIEW_MAP2, x, y))
+    {
+	if (!pick_view->cell.configured)
+	    return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP2;
+	zoom_view = VIEW_MAP2_ZOOM;
+	target_flag = 1;
+    }
+    else if (In_view (pick_view = VIEW_MAP1_ZOOM, x, y))
+    {
+	if (!pick_view->cell.configured)
+	    return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP1;
+	zoom_view = VIEW_MAP1_ZOOM;
+	target_flag = 0;
+    }
+    else if (In_view (pick_view = VIEW_MAP2_ZOOM, x, y))
+    {
+	if (!pick_view->cell.configured)
+	    return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP2;
+	zoom_view = VIEW_MAP2_ZOOM;
+	target_flag = 1;
+    }
+    else
+	return 0;	/* ignore the mouse event */
+    if (!pick_view->cell.configured) return 0;	/* just to be sure */
+/*
+ * make sure point is within edges of image as well
+ */
+    if (x <= pick_view->cell.left) return 0;
+    if (x >= pick_view->cell.right) return 0;
+    if (y <= pick_view->cell.top) return 0;
+    if (y >= pick_view->cell.bottom) return 0;
+
+
+/*
+ * ok, erase menu messages
+ */
+    Menu_msg("");
+
+/* determine magnification of zoom */
+    if (zoom_view->cell.configured)
+    {
+	if (zoom_view == pick_view)
+	    mag = floor(magnification (zoom_view) + 1.0) + .1;
+	else
+	    mag = ceil(magnification (zoom_view)) + .1;
+    }
+    else
+    {
+	mag = floor(magnification (main_view) + 1.0) + .1;
+    }
+    if(!ask_magnification (&mag))
+	return 1;
+/* 
+ * Determine the the zoom window (ie, cellhd)
+ */
+
+    G_copy (&cellhd, &main_view->cell.head, sizeof(cellhd));
+    cellhd.ns_res = main_view->cell.ns_res / mag;
+    cellhd.ew_res = main_view->cell.ew_res / mag;
+    cellhd.cols   = (cellhd.east - cellhd.west) / cellhd.ew_res;
+    cellhd.rows   = (cellhd.north - cellhd.south) / cellhd.ns_res;
+
+
+/* convert x,y to col,row */
+
+    col  = view_to_col(pick_view,x);
+    east = col_to_easting (&pick_view->cell.head, col, 0.5);
+    col  = easting_to_col (&cellhd, east);
+
+    row   = view_to_row(pick_view,y);
+    north = row_to_northing (&pick_view->cell.head, row, 0.5);
+    row   = northing_to_row (&cellhd, north);
+
+    ncols = zoom_view->ncols ;
+    nrows = zoom_view->nrows ;
+
+
+    n = cellhd.cols - col;
+    if (n > col)
+	n = col;
+    if (n+n+1 >= ncols)
+    {
+	n = ncols/2;
+	if (n+n+1 >= ncols) n--;
+    }
+    left = col - n;
+    right = col + n;
+
+    n = cellhd.rows - row;
+    if (n > row)
+	n = row;
+    if (n+n+1 >= nrows)
+    {
+	n = nrows/2;
+	if (n+n+1 >= nrows) n--;
+    }
+    top = row - n;
+    bottom = row + n;
+
+
+    north = row_to_northing (&cellhd, top,0.0);
+    west  = col_to_easting  (&cellhd,left,0.0);
+    south = row_to_northing (&cellhd,bottom,1.0);
+    east  = col_to_easting  (&cellhd,right,1.0);
+
+
+    cellhd.north = north;
+    cellhd.south = south;
+    cellhd.east  = east ;
+    cellhd.west  = west ;
+
+    cellhd.rows = (cellhd.north-cellhd.south)/cellhd.ns_res;
+    cellhd.cols = (cellhd.east-cellhd.west)/cellhd.ew_res ;
+
+/*
+ * Outline the zoom window on the main map
+ * Turn previous one to grey.
+ */
+    if (zoom_view->cell.configured)
+    {
+	R_standard_color (GREY);
+	Outline_cellhd (main_view, &zoom_view->cell.head);
+    }
+    R_standard_color (RED);
+    Outline_cellhd (main_view, &cellhd);
+
+
+/*
+ * zoom
+ */
+    if (target_flag)
+	select_target_env();
+    G_copy (&zoom_view->cell.head, &cellhd, sizeof (cellhd));
+    Configure_view (zoom_view, pick_view->cell.name, pick_view->cell.mapset,
+	pick_view->cell.ns_res, pick_view->cell.ew_res);
+    drawcell (zoom_view);
+    select_current_env();
+    display_points(1);
+
+    return 1;	/* pop back */
+}
+
+
+static int 
+cancel (void)
+{
+    return -1;
+}

Copied: grass-addons/imagery/i.pr (from rev 30334, grass-addons/i.pr)

Deleted: grass-addons/imagery/i.pr/Makefile
===================================================================
--- grass-addons/i.pr/Makefile	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.pr/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,22 +0,0 @@
-MODULE_TOPDIR = ../..
-
-include $(MODULE_TOPDIR)/include/Make/Dir.make
-
-SUBDIRS = \
-        PRLIB \
-	i.pr_blob \
-	i.pr_classify \
-	i.pr_features \
-	i.pr_features_additional \
-	i.pr_features_extract \
-	i.pr_features_selection \
-	i.pr_model \
-	i.pr_statistics \
-	i.pr_subsets \
-	i.pr_training \
-	i.pr_uxb \
-	i.pr_sites_aggregate
-
-default: subdirs
-
-clean: cleansubdirs

Copied: grass-addons/imagery/i.pr/Makefile (from rev 30335, grass-addons/i.pr/Makefile)
===================================================================
--- grass-addons/imagery/i.pr/Makefile	                        (rev 0)
+++ grass-addons/imagery/i.pr/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,22 @@
+MODULE_TOPDIR = ../..
+
+include $(MODULE_TOPDIR)/include/Make/Dir.make
+
+SUBDIRS = \
+        PRLIB \
+	i.pr_blob \
+	i.pr_classify \
+	i.pr_features \
+	i.pr_features_additional \
+	i.pr_features_extract \
+	i.pr_features_selection \
+	i.pr_model \
+	i.pr_statistics \
+	i.pr_subsets \
+	i.pr_training \
+	i.pr_uxb \
+	i.pr_sites_aggregate
+
+default: subdirs
+
+clean: cleansubdirs

Copied: grass-addons/imagery/i.pr/PRLIB (from rev 30335, grass-addons/i.pr/PRLIB)

Deleted: grass-addons/imagery/i.pr/README
===================================================================
--- grass-addons/i.pr/README	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.pr/README	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,21 +0,0 @@
-Stefano Merler
-ITC-irst
-Via Sommarive, 18
-38050, Povo
-Trento
-Italy
-http://mpa.itc.it/people/merler/
-
-    * pr : C code for classification problems. It implements k-NN (multiclass), classification trees (multiclass), maximum likelihood (multiclass), Support Vector Machines (binary), bagging versions of all the base classifiers, AdaBoost for binary trees and support vector machines. It allows feature manipulation (normalization, principal components,...). It also implements feature selection techniques (RFE, E-RFE,...), statistical tests on variables, tools for resampling (cross-validation and bootstrap) and cost-sensitive techniques for trees and support vector machines. Feature selection techniques and statistical tests are not distributed in the current release.
-    * i.pr : a version of pr implemented in the GIS GRASS for dealing with images. 
-
-###############
-Compilation
-
-The easiest way to compile this module set is to
-tell 'make' where to find GRASS:
-
-  make MODULE_TOPDIR=$HOME/grass63/
-
-(adapt to your /path/to/grass6/ )
-

Copied: grass-addons/imagery/i.pr/README (from rev 30335, grass-addons/i.pr/README)
===================================================================
--- grass-addons/imagery/i.pr/README	                        (rev 0)
+++ grass-addons/imagery/i.pr/README	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,21 @@
+Stefano Merler
+ITC-irst
+Via Sommarive, 18
+38050, Povo
+Trento
+Italy
+http://mpa.itc.it/people/merler/
+
+    * pr : C code for classification problems. It implements k-NN (multiclass), classification trees (multiclass), maximum likelihood (multiclass), Support Vector Machines (binary), bagging versions of all the base classifiers, AdaBoost for binary trees and support vector machines. It allows feature manipulation (normalization, principal components,...). It also implements feature selection techniques (RFE, E-RFE,...), statistical tests on variables, tools for resampling (cross-validation and bootstrap) and cost-sensitive techniques for trees and support vector machines. Feature selection techniques and statistical tests are not distributed in the current release.
+    * i.pr : a version of pr implemented in the GIS GRASS for dealing with images. 
+
+###############
+Compilation
+
+The easiest way to compile this module set is to
+tell 'make' where to find GRASS:
+
+  make MODULE_TOPDIR=$HOME/grass63/
+
+(adapt to your /path/to/grass6/ )
+

Deleted: grass-addons/imagery/i.pr/TODO
===================================================================
--- grass-addons/i.pr/TODO	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/imagery/i.pr/TODO	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,6 +0,0 @@
-This module set was developed for GRASS 5.
-
-TODO:
-- change to ANSI prototypes
-- follow SUBMITTING rules
-- change sites to vector

Copied: grass-addons/imagery/i.pr/TODO (from rev 30335, grass-addons/i.pr/TODO)
===================================================================
--- grass-addons/imagery/i.pr/TODO	                        (rev 0)
+++ grass-addons/imagery/i.pr/TODO	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,6 @@
+This module set was developed for GRASS 5.
+
+TODO:
+- change to ANSI prototypes
+- follow SUBMITTING rules
+- change sites to vector

Copied: grass-addons/imagery/i.pr/doc (from rev 30335, grass-addons/i.pr/doc)

Copied: grass-addons/imagery/i.pr/i.pr_blob (from rev 30335, grass-addons/i.pr/i.pr_blob)

Copied: grass-addons/imagery/i.pr/i.pr_classify (from rev 30335, grass-addons/i.pr/i.pr_classify)

Copied: grass-addons/imagery/i.pr/i.pr_features (from rev 30335, grass-addons/i.pr/i.pr_features)

Copied: grass-addons/imagery/i.pr/i.pr_features_additional (from rev 30335, grass-addons/i.pr/i.pr_features_additional)

Copied: grass-addons/imagery/i.pr/i.pr_features_extract (from rev 30335, grass-addons/i.pr/i.pr_features_extract)

Copied: grass-addons/imagery/i.pr/i.pr_features_selection (from rev 30335, grass-addons/i.pr/i.pr_features_selection)

Copied: grass-addons/imagery/i.pr/i.pr_model (from rev 30335, grass-addons/i.pr/i.pr_model)

Copied: grass-addons/imagery/i.pr/i.pr_sites_aggregate (from rev 30335, grass-addons/i.pr/i.pr_sites_aggregate)

Copied: grass-addons/imagery/i.pr/i.pr_statistics (from rev 30335, grass-addons/i.pr/i.pr_statistics)

Copied: grass-addons/imagery/i.pr/i.pr_subsets (from rev 30335, grass-addons/i.pr/i.pr_subsets)

Copied: grass-addons/imagery/i.pr/i.pr_training (from rev 30335, grass-addons/i.pr/i.pr_training)

Copied: grass-addons/imagery/i.pr/i.pr_uxb (from rev 30335, grass-addons/i.pr/i.pr_uxb)

Copied: grass-addons/imagery/i.pr/include (from rev 30335, grass-addons/i.pr/include)

Copied: grass-addons/misc/m.eigensystem (from rev 30334, grass-addons/m.eigensystem)

Deleted: grass-addons/misc/m.eigensystem/Makefile
===================================================================
--- grass-addons/m.eigensystem/Makefile	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,25 +0,0 @@
-MODULE_TOPDIR = ../..
-
-PGM = m.eigensystem
-
-include $(MODULE_TOPDIR)/include/Make/Module.make
-
-default: $(BIN)/$(PGM) html
-
-OBJ = main.o\
-    balanc.o \
-    balbak.o \
-    cdiv.o \
-    elmhes.o \
-    eltran.o \
-    hqr.o \
-    hqr2.o \
-    rg.o
-
-$(BIN)/$(PGM): $(OBJ)
-	$(FC) -o $@ $(OBJ)
-
-html:
-	$(MKDIR) $(GISBASE)/docs/html
-	$(INSTALL_DATA) $(PGM).html $(GISBASE)/docs/html/
-

Copied: grass-addons/misc/m.eigensystem/Makefile (from rev 30335, grass-addons/m.eigensystem/Makefile)
===================================================================
--- grass-addons/misc/m.eigensystem/Makefile	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,25 @@
+MODULE_TOPDIR = ../..
+
+PGM = m.eigensystem
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: $(BIN)/$(PGM) html
+
+OBJ = main.o\
+    balanc.o \
+    balbak.o \
+    cdiv.o \
+    elmhes.o \
+    eltran.o \
+    hqr.o \
+    hqr2.o \
+    rg.o
+
+$(BIN)/$(PGM): $(OBJ)
+	$(FC) -o $@ $(OBJ)
+
+html:
+	$(MKDIR) $(GISBASE)/docs/html
+	$(INSTALL_DATA) $(PGM).html $(GISBASE)/docs/html/
+

Deleted: grass-addons/misc/m.eigensystem/README
===================================================================
--- grass-addons/m.eigensystem/README	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/README	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1 +0,0 @@
-This code requires a fortran compiler

Copied: grass-addons/misc/m.eigensystem/README (from rev 30335, grass-addons/m.eigensystem/README)
===================================================================
--- grass-addons/misc/m.eigensystem/README	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/README	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1 @@
+This code requires a fortran compiler

Deleted: grass-addons/misc/m.eigensystem/awk.normal
===================================================================
--- grass-addons/m.eigensystem/awk.normal	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/awk.normal	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,3 +0,0 @@
-/E/ {i=0;sum=0.0;print}
-/V/ {i++;V[i]=$2;sum += $2*$2;print;n=0}
-/N/ {n++; print $0, V[n] / sqrt(sum), sqrt(sum)}

Copied: grass-addons/misc/m.eigensystem/awk.normal (from rev 30335, grass-addons/m.eigensystem/awk.normal)
===================================================================
--- grass-addons/misc/m.eigensystem/awk.normal	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/awk.normal	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,3 @@
+/E/ {i=0;sum=0.0;print}
+/V/ {i++;V[i]=$2;sum += $2*$2;print;n=0}
+/N/ {n++; print $0, V[n] / sqrt(sum), sqrt(sum)}

Deleted: grass-addons/misc/m.eigensystem/awk.scale
===================================================================
--- grass-addons/m.eigensystem/awk.scale	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/awk.scale	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,4 +0,0 @@
-/V/ {print $0 "    " $2/E; next}
-/N/ {print $0 "    " $2/E; next}
-/E/ {E=sqrt($2)}
-{print}

Copied: grass-addons/misc/m.eigensystem/awk.scale (from rev 30335, grass-addons/m.eigensystem/awk.scale)
===================================================================
--- grass-addons/misc/m.eigensystem/awk.scale	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/awk.scale	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,4 @@
+/V/ {print $0 "    " $2/E; next}
+/N/ {print $0 "    " $2/E; next}
+/E/ {E=sqrt($2)}
+{print}

Deleted: grass-addons/misc/m.eigensystem/balanc.f
===================================================================
--- grass-addons/m.eigensystem/balanc.f	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/balanc.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,166 +0,0 @@
-      SUBROUTINE BALANC(NM,N,A,LOW,IGH,SCALE)                           EIS0
-C                                                                       EIS0
-      INTEGER I,J,K,L,M,N,JJ,NM,IGH,LOW,IEXC                            EIS0
-      DOUBLE PRECISION A(NM,N),SCALE(N)                                 EIS0
-      DOUBLE PRECISION C,F,G,R,S,B2,RADIX                               EIS0
-      LOGICAL NOCONV                                                    EIS0
-C                                                                       EIS0
-C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE BALANCE,  EIS0
-C     NUM. MATH. 13, 293-304(1969) BY PARLETT AND REINSCH.              EIS0
-C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 315-326(1971).   EIS0
-C                                                                       EIS0
-C     THIS SUBROUTINE BALANCES A REAL MATRIX AND ISOLATES               EIS0
-C     EIGENVALUES WHENEVER POSSIBLE.                                    EIS0
-C                                                                       EIS0
-C     ON INPUT                                                          EIS0
-C                                                                       EIS0
-C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS0
-C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS0
-C          DIMENSION STATEMENT.                                         EIS0
-C                                                                       EIS0
-C        N IS THE ORDER OF THE MATRIX.                                  EIS0
-C                                                                       EIS0
-C        A CONTAINS THE INPUT MATRIX TO BE BALANCED.                    EIS0
-C                                                                       EIS0
-C     ON OUTPUT                                                         EIS0
-C                                                                       EIS0
-C        A CONTAINS THE BALANCED MATRIX.                                EIS0
-C                                                                       EIS0
-C        LOW AND IGH ARE TWO INTEGERS SUCH THAT A(I,J)                  EIS0
-C          IS EQUAL TO ZERO IF                                          EIS0
-C           (1) I IS GREATER THAN J AND                                 EIS0
-C           (2) J=1,...,LOW-1 OR I=IGH+1,...,N.                         EIS0
-C                                                                       EIS0
-C        SCALE CONTAINS INFORMATION DETERMINING THE                     EIS0
-C           PERMUTATIONS AND SCALING FACTORS USED.                      EIS0
-C                                                                       EIS0
-C     SUPPOSE THAT THE PRINCIPAL SUBMATRIX IN ROWS LOW THROUGH IGH      EIS0
-C     HAS BEEN BALANCED, THAT P(J) DENOTES THE INDEX INTERCHANGED       EIS0
-C     WITH J DURING THE PERMUTATION STEP, AND THAT THE ELEMENTS         EIS0
-C     OF THE DIAGONAL MATRIX USED ARE DENOTED BY D(I,J).  THEN          EIS0
-C        SCALE(J) = P(J),    FOR J = 1,...,LOW-1                        EIS0
-C                 = D(J,J),      J = LOW,...,IGH                        EIS0
-C                 = P(J)         J = IGH+1,...,N.                       EIS0
-C     THE ORDER IN WHICH THE INTERCHANGES ARE MADE IS N TO IGH+1,       EIS0
-C     THEN 1 TO LOW-1.                                                  EIS0
-C                                                                       EIS0
-C     NOTE THAT 1 IS RETURNED FOR IGH IF IGH IS ZERO FORMALLY.          EIS0
-C                                                                       EIS0
-C     THE ALGOL PROCEDURE EXC CONTAINED IN BALANCE APPEARS IN           EIS0
-C     BALANC  IN LINE.  (NOTE THAT THE ALGOL ROLES OF IDENTIFIERS       EIS0
-C     K,L HAVE BEEN REVERSED.)                                          EIS0
-C                                                                       EIS0
-C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS0
-C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS0
-C                                                                       EIS0
-C     THIS VERSION DATED AUGUST 1983.                                   EIS0
-C                                                                       EIS0
-C     ------------------------------------------------------------------EIS0
-C                                                                       EIS0
-      RADIX = 16.0D0                                                    EIS0
-C                                                                       EIS0
-      B2 = RADIX * RADIX                                                EIS0
-      K = 1                                                             EIS0
-      L = N                                                             EIS0
-      GO TO 100                                                         EIS0
-C     .......... IN-LINE PROCEDURE FOR ROW AND                          EIS0
-C                COLUMN EXCHANGE ..........                             EIS0
-   20 SCALE(M) = J                                                      EIS0
-      IF (J .EQ. M) GO TO 50                                            EIS0
-C                                                                       EIS0
-      DO 30 I = 1, L                                                    EIS0
-         F = A(I,J)                                                     EIS0
-         A(I,J) = A(I,M)                                                EIS0
-         A(I,M) = F                                                     EIS0
-   30 CONTINUE                                                          EIS0
-C                                                                       EIS0
-      DO 40 I = K, N                                                    EIS0
-         F = A(J,I)                                                     EIS0
-         A(J,I) = A(M,I)                                                EIS0
-         A(M,I) = F                                                     EIS0
-   40 CONTINUE                                                          EIS0
-C                                                                       EIS0
-   50 GO TO (80,130), IEXC                                              EIS0
-C     .......... SEARCH FOR ROWS ISOLATING AN EIGENVALUE                EIS0
-C                AND PUSH THEM DOWN ..........                          EIS0
-   80 IF (L .EQ. 1) GO TO 280                                           EIS0
-      L = L - 1                                                         EIS0
-C     .......... FOR J=L STEP -1 UNTIL 1 DO -- ..........               EIS0
-  100 DO 120 JJ = 1, L                                                  EIS0
-         J = L + 1 - JJ                                                 EIS0
-C                                                                       EIS0
-         DO 110 I = 1, L                                                EIS0
-            IF (I .EQ. J) GO TO 110                                     EIS0
-            IF (A(J,I) .NE. 0.0D0) GO TO 120                            EIS0
-  110    CONTINUE                                                       EIS0
-C                                                                       EIS0
-         M = L                                                          EIS0
-         IEXC = 1                                                       EIS0
-         GO TO 20                                                       EIS0
-  120 CONTINUE                                                          EIS0
-C                                                                       EIS0
-      GO TO 140                                                         EIS0
-C     .......... SEARCH FOR COLUMNS ISOLATING AN EIGENVALUE             EIS0
-C                AND PUSH THEM LEFT ..........                          EIS0
-  130 K = K + 1                                                         EIS0
-C                                                                       EIS0
-  140 DO 170 J = K, L                                                   EIS0
-C                                                                       EIS0
-         DO 150 I = K, L                                                EIS0
-            IF (I .EQ. J) GO TO 150                                     EIS0
-            IF (A(I,J) .NE. 0.0D0) GO TO 170                            EIS0
-  150    CONTINUE                                                       EIS0
-C                                                                       EIS0
-         M = K                                                          EIS0
-         IEXC = 2                                                       EIS0
-         GO TO 20                                                       EIS0
-  170 CONTINUE                                                          EIS0
-C     .......... NOW BALANCE THE SUBMATRIX IN ROWS K TO L ..........    EIS0
-      DO 180 I = K, L                                                   EIS0
-  180 SCALE(I) = 1.0D0                                                  EIS0
-C     .......... ITERATIVE LOOP FOR NORM REDUCTION ..........           EIS0
-  190 NOCONV = .FALSE.                                                  EIS0
-C                                                                       EIS0
-      DO 270 I = K, L                                                   EIS0
-         C = 0.0D0                                                      EIS0
-         R = 0.0D0                                                      EIS0
-C                                                                       EIS0
-         DO 200 J = K, L                                                EIS0
-            IF (J .EQ. I) GO TO 200                                     EIS0
-            C = C + DABS(A(J,I))                                        EIS0
-            R = R + DABS(A(I,J))                                        EIS0
-  200    CONTINUE                                                       EIS0
-C     .......... GUARD AGAINST ZERO C OR R DUE TO UNDERFLOW ..........  EIS0
-         IF (C .EQ. 0.0D0 .OR. R .EQ. 0.0D0) GO TO 270                  EIS0
-         G = R / RADIX                                                  EIS0
-         F = 1.0D0                                                      EIS0
-         S = C + R                                                      EIS0
-  210    IF (C .GE. G) GO TO 220                                        EIS0
-         F = F * RADIX                                                  EIS0
-         C = C * B2                                                     EIS0
-         GO TO 210                                                      EIS0
-  220    G = R * RADIX                                                  EIS0
-  230    IF (C .LT. G) GO TO 240                                        EIS0
-         F = F / RADIX                                                  EIS0
-         C = C / B2                                                     EIS0
-         GO TO 230                                                      EIS0
-C     .......... NOW BALANCE ..........                                 EIS0
-  240    IF ((C + R) / F .GE. 0.95D0 * S) GO TO 270                     EIS0
-         G = 1.0D0 / F                                                  EIS0
-         SCALE(I) = SCALE(I) * F                                        EIS0
-         NOCONV = .TRUE.                                                EIS0
-C                                                                       EIS0
-         DO 250 J = K, N                                                EIS0
-  250    A(I,J) = A(I,J) * G                                            EIS0
-C                                                                       EIS0
-         DO 260 J = 1, L                                                EIS0
-  260    A(J,I) = A(J,I) * F                                            EIS0
-C                                                                       EIS0
-  270 CONTINUE                                                          EIS0
-C                                                                       EIS0
-      IF (NOCONV) GO TO 190                                             EIS0
-C                                                                       EIS0
-  280 LOW = K                                                           EIS0
-      IGH = L                                                           EIS0
-      RETURN                                                            EIS0
-      END                                                               EIS0

Copied: grass-addons/misc/m.eigensystem/balanc.f (from rev 30335, grass-addons/m.eigensystem/balanc.f)
===================================================================
--- grass-addons/misc/m.eigensystem/balanc.f	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/balanc.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,166 @@
+      SUBROUTINE BALANC(NM,N,A,LOW,IGH,SCALE)                           EIS0
+C                                                                       EIS0
+      INTEGER I,J,K,L,M,N,JJ,NM,IGH,LOW,IEXC                            EIS0
+      DOUBLE PRECISION A(NM,N),SCALE(N)                                 EIS0
+      DOUBLE PRECISION C,F,G,R,S,B2,RADIX                               EIS0
+      LOGICAL NOCONV                                                    EIS0
+C                                                                       EIS0
+C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE BALANCE,  EIS0
+C     NUM. MATH. 13, 293-304(1969) BY PARLETT AND REINSCH.              EIS0
+C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 315-326(1971).   EIS0
+C                                                                       EIS0
+C     THIS SUBROUTINE BALANCES A REAL MATRIX AND ISOLATES               EIS0
+C     EIGENVALUES WHENEVER POSSIBLE.                                    EIS0
+C                                                                       EIS0
+C     ON INPUT                                                          EIS0
+C                                                                       EIS0
+C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS0
+C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS0
+C          DIMENSION STATEMENT.                                         EIS0
+C                                                                       EIS0
+C        N IS THE ORDER OF THE MATRIX.                                  EIS0
+C                                                                       EIS0
+C        A CONTAINS THE INPUT MATRIX TO BE BALANCED.                    EIS0
+C                                                                       EIS0
+C     ON OUTPUT                                                         EIS0
+C                                                                       EIS0
+C        A CONTAINS THE BALANCED MATRIX.                                EIS0
+C                                                                       EIS0
+C        LOW AND IGH ARE TWO INTEGERS SUCH THAT A(I,J)                  EIS0
+C          IS EQUAL TO ZERO IF                                          EIS0
+C           (1) I IS GREATER THAN J AND                                 EIS0
+C           (2) J=1,...,LOW-1 OR I=IGH+1,...,N.                         EIS0
+C                                                                       EIS0
+C        SCALE CONTAINS INFORMATION DETERMINING THE                     EIS0
+C           PERMUTATIONS AND SCALING FACTORS USED.                      EIS0
+C                                                                       EIS0
+C     SUPPOSE THAT THE PRINCIPAL SUBMATRIX IN ROWS LOW THROUGH IGH      EIS0
+C     HAS BEEN BALANCED, THAT P(J) DENOTES THE INDEX INTERCHANGED       EIS0
+C     WITH J DURING THE PERMUTATION STEP, AND THAT THE ELEMENTS         EIS0
+C     OF THE DIAGONAL MATRIX USED ARE DENOTED BY D(I,J).  THEN          EIS0
+C        SCALE(J) = P(J),    FOR J = 1,...,LOW-1                        EIS0
+C                 = D(J,J),      J = LOW,...,IGH                        EIS0
+C                 = P(J)         J = IGH+1,...,N.                       EIS0
+C     THE ORDER IN WHICH THE INTERCHANGES ARE MADE IS N TO IGH+1,       EIS0
+C     THEN 1 TO LOW-1.                                                  EIS0
+C                                                                       EIS0
+C     NOTE THAT 1 IS RETURNED FOR IGH IF IGH IS ZERO FORMALLY.          EIS0
+C                                                                       EIS0
+C     THE ALGOL PROCEDURE EXC CONTAINED IN BALANCE APPEARS IN           EIS0
+C     BALANC  IN LINE.  (NOTE THAT THE ALGOL ROLES OF IDENTIFIERS       EIS0
+C     K,L HAVE BEEN REVERSED.)                                          EIS0
+C                                                                       EIS0
+C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS0
+C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS0
+C                                                                       EIS0
+C     THIS VERSION DATED AUGUST 1983.                                   EIS0
+C                                                                       EIS0
+C     ------------------------------------------------------------------EIS0
+C                                                                       EIS0
+      RADIX = 16.0D0                                                    EIS0
+C                                                                       EIS0
+      B2 = RADIX * RADIX                                                EIS0
+      K = 1                                                             EIS0
+      L = N                                                             EIS0
+      GO TO 100                                                         EIS0
+C     .......... IN-LINE PROCEDURE FOR ROW AND                          EIS0
+C                COLUMN EXCHANGE ..........                             EIS0
+   20 SCALE(M) = J                                                      EIS0
+      IF (J .EQ. M) GO TO 50                                            EIS0
+C                                                                       EIS0
+      DO 30 I = 1, L                                                    EIS0
+         F = A(I,J)                                                     EIS0
+         A(I,J) = A(I,M)                                                EIS0
+         A(I,M) = F                                                     EIS0
+   30 CONTINUE                                                          EIS0
+C                                                                       EIS0
+      DO 40 I = K, N                                                    EIS0
+         F = A(J,I)                                                     EIS0
+         A(J,I) = A(M,I)                                                EIS0
+         A(M,I) = F                                                     EIS0
+   40 CONTINUE                                                          EIS0
+C                                                                       EIS0
+   50 GO TO (80,130), IEXC                                              EIS0
+C     .......... SEARCH FOR ROWS ISOLATING AN EIGENVALUE                EIS0
+C                AND PUSH THEM DOWN ..........                          EIS0
+   80 IF (L .EQ. 1) GO TO 280                                           EIS0
+      L = L - 1                                                         EIS0
+C     .......... FOR J=L STEP -1 UNTIL 1 DO -- ..........               EIS0
+  100 DO 120 JJ = 1, L                                                  EIS0
+         J = L + 1 - JJ                                                 EIS0
+C                                                                       EIS0
+         DO 110 I = 1, L                                                EIS0
+            IF (I .EQ. J) GO TO 110                                     EIS0
+            IF (A(J,I) .NE. 0.0D0) GO TO 120                            EIS0
+  110    CONTINUE                                                       EIS0
+C                                                                       EIS0
+         M = L                                                          EIS0
+         IEXC = 1                                                       EIS0
+         GO TO 20                                                       EIS0
+  120 CONTINUE                                                          EIS0
+C                                                                       EIS0
+      GO TO 140                                                         EIS0
+C     .......... SEARCH FOR COLUMNS ISOLATING AN EIGENVALUE             EIS0
+C                AND PUSH THEM LEFT ..........                          EIS0
+  130 K = K + 1                                                         EIS0
+C                                                                       EIS0
+  140 DO 170 J = K, L                                                   EIS0
+C                                                                       EIS0
+         DO 150 I = K, L                                                EIS0
+            IF (I .EQ. J) GO TO 150                                     EIS0
+            IF (A(I,J) .NE. 0.0D0) GO TO 170                            EIS0
+  150    CONTINUE                                                       EIS0
+C                                                                       EIS0
+         M = K                                                          EIS0
+         IEXC = 2                                                       EIS0
+         GO TO 20                                                       EIS0
+  170 CONTINUE                                                          EIS0
+C     .......... NOW BALANCE THE SUBMATRIX IN ROWS K TO L ..........    EIS0
+      DO 180 I = K, L                                                   EIS0
+  180 SCALE(I) = 1.0D0                                                  EIS0
+C     .......... ITERATIVE LOOP FOR NORM REDUCTION ..........           EIS0
+  190 NOCONV = .FALSE.                                                  EIS0
+C                                                                       EIS0
+      DO 270 I = K, L                                                   EIS0
+         C = 0.0D0                                                      EIS0
+         R = 0.0D0                                                      EIS0
+C                                                                       EIS0
+         DO 200 J = K, L                                                EIS0
+            IF (J .EQ. I) GO TO 200                                     EIS0
+            C = C + DABS(A(J,I))                                        EIS0
+            R = R + DABS(A(I,J))                                        EIS0
+  200    CONTINUE                                                       EIS0
+C     .......... GUARD AGAINST ZERO C OR R DUE TO UNDERFLOW ..........  EIS0
+         IF (C .EQ. 0.0D0 .OR. R .EQ. 0.0D0) GO TO 270                  EIS0
+         G = R / RADIX                                                  EIS0
+         F = 1.0D0                                                      EIS0
+         S = C + R                                                      EIS0
+  210    IF (C .GE. G) GO TO 220                                        EIS0
+         F = F * RADIX                                                  EIS0
+         C = C * B2                                                     EIS0
+         GO TO 210                                                      EIS0
+  220    G = R * RADIX                                                  EIS0
+  230    IF (C .LT. G) GO TO 240                                        EIS0
+         F = F / RADIX                                                  EIS0
+         C = C / B2                                                     EIS0
+         GO TO 230                                                      EIS0
+C     .......... NOW BALANCE ..........                                 EIS0
+  240    IF ((C + R) / F .GE. 0.95D0 * S) GO TO 270                     EIS0
+         G = 1.0D0 / F                                                  EIS0
+         SCALE(I) = SCALE(I) * F                                        EIS0
+         NOCONV = .TRUE.                                                EIS0
+C                                                                       EIS0
+         DO 250 J = K, N                                                EIS0
+  250    A(I,J) = A(I,J) * G                                            EIS0
+C                                                                       EIS0
+         DO 260 J = 1, L                                                EIS0
+  260    A(J,I) = A(J,I) * F                                            EIS0
+C                                                                       EIS0
+  270 CONTINUE                                                          EIS0
+C                                                                       EIS0
+      IF (NOCONV) GO TO 190                                             EIS0
+C                                                                       EIS0
+  280 LOW = K                                                           EIS0
+      IGH = L                                                           EIS0
+      RETURN                                                            EIS0
+      END                                                               EIS0

Deleted: grass-addons/misc/m.eigensystem/balbak.f
===================================================================
--- grass-addons/m.eigensystem/balbak.f	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/balbak.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,75 +0,0 @@
-      SUBROUTINE BALBAK(NM,N,LOW,IGH,SCALE,M,Z)                         EIS0
-C                                                                       EIS0
-      INTEGER I,J,K,M,N,II,NM,IGH,LOW                                   EIS0
-      DOUBLE PRECISION SCALE(N),Z(NM,M)                                 EIS0
-      DOUBLE PRECISION S                                                EIS0
-C                                                                       EIS0
-C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE BALBAK,   EIS0
-C     NUM. MATH. 13, 293-304(1969) BY PARLETT AND REINSCH.              EIS0
-C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 315-326(1971).   EIS0
-C                                                                       EIS0
-C     THIS SUBROUTINE FORMS THE EIGENVECTORS OF A REAL GENERAL          EIS0
-C     MATRIX BY BACK TRANSFORMING THOSE OF THE CORRESPONDING            EIS0
-C     BALANCED MATRIX DETERMINED BY  BALANC.                            EIS0
-C                                                                       EIS0
-C     ON INPUT                                                          EIS0
-C                                                                       EIS0
-C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS0
-C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS0
-C          DIMENSION STATEMENT.                                         EIS0
-C                                                                       EIS0
-C        N IS THE ORDER OF THE MATRIX.                                  EIS0
-C                                                                       EIS0
-C        LOW AND IGH ARE INTEGERS DETERMINED BY  BALANC.                EIS0
-C                                                                       EIS0
-C        SCALE CONTAINS INFORMATION DETERMINING THE PERMUTATIONS        EIS0
-C          AND SCALING FACTORS USED BY  BALANC.                         EIS0
-C                                                                       EIS0
-C        M IS THE NUMBER OF COLUMNS OF Z TO BE BACK TRANSFORMED.        EIS0
-C                                                                       EIS0
-C        Z CONTAINS THE REAL AND IMAGINARY PARTS OF THE EIGEN-          EIS0
-C          VECTORS TO BE BACK TRANSFORMED IN ITS FIRST M COLUMNS.       EIS0
-C                                                                       EIS0
-C     ON OUTPUT                                                         EIS0
-C                                                                       EIS0
-C        Z CONTAINS THE REAL AND IMAGINARY PARTS OF THE                 EIS0
-C          TRANSFORMED EIGENVECTORS IN ITS FIRST M COLUMNS.             EIS0
-C                                                                       EIS0
-C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS0
-C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS0
-C                                                                       EIS0
-C     THIS VERSION DATED AUGUST 1983.                                   EIS0
-C                                                                       EIS0
-C     ------------------------------------------------------------------EIS0
-C                                                                       EIS0
-      IF (M .EQ. 0) GO TO 200                                           EIS0
-      IF (IGH .EQ. LOW) GO TO 120                                       EIS0
-C                                                                       EIS0
-      DO 110 I = LOW, IGH                                               EIS0
-         S = SCALE(I)                                                   EIS0
-C     .......... LEFT HAND EIGENVECTORS ARE BACK TRANSFORMED            EIS0
-C                IF THE FOREGOING STATEMENT IS REPLACED BY              EIS0
-C                S=1.0D0/SCALE(I). ..........                           EIS0
-         DO 100 J = 1, M                                                EIS0
-  100    Z(I,J) = Z(I,J) * S                                            EIS0
-C                                                                       EIS0
-  110 CONTINUE                                                          EIS0
-C     ......... FOR I=LOW-1 STEP -1 UNTIL 1,                            EIS0
-C               IGH+1 STEP 1 UNTIL N DO -- ..........                   EIS0
-  120 DO 140 II = 1, N                                                  EIS0
-         I = II                                                         EIS0
-         IF (I .GE. LOW .AND. I .LE. IGH) GO TO 140                     EIS0
-         IF (I .LT. LOW) I = LOW - II                                   EIS0
-         K = SCALE(I)                                                   EIS0
-         IF (K .EQ. I) GO TO 140                                        EIS0
-C                                                                       EIS0
-         DO 130 J = 1, M                                                EIS0
-            S = Z(I,J)                                                  EIS0
-            Z(I,J) = Z(K,J)                                             EIS0
-            Z(K,J) = S                                                  EIS0
-  130    CONTINUE                                                       EIS0
-C                                                                       EIS0
-  140 CONTINUE                                                          EIS0
-C                                                                       EIS0
-  200 RETURN                                                            EIS0
-      END                                                               EIS0

Copied: grass-addons/misc/m.eigensystem/balbak.f (from rev 30335, grass-addons/m.eigensystem/balbak.f)
===================================================================
--- grass-addons/misc/m.eigensystem/balbak.f	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/balbak.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,75 @@
+      SUBROUTINE BALBAK(NM,N,LOW,IGH,SCALE,M,Z)                         EIS0
+C                                                                       EIS0
+      INTEGER I,J,K,M,N,II,NM,IGH,LOW                                   EIS0
+      DOUBLE PRECISION SCALE(N),Z(NM,M)                                 EIS0
+      DOUBLE PRECISION S                                                EIS0
+C                                                                       EIS0
+C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE BALBAK,   EIS0
+C     NUM. MATH. 13, 293-304(1969) BY PARLETT AND REINSCH.              EIS0
+C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 315-326(1971).   EIS0
+C                                                                       EIS0
+C     THIS SUBROUTINE FORMS THE EIGENVECTORS OF A REAL GENERAL          EIS0
+C     MATRIX BY BACK TRANSFORMING THOSE OF THE CORRESPONDING            EIS0
+C     BALANCED MATRIX DETERMINED BY  BALANC.                            EIS0
+C                                                                       EIS0
+C     ON INPUT                                                          EIS0
+C                                                                       EIS0
+C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS0
+C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS0
+C          DIMENSION STATEMENT.                                         EIS0
+C                                                                       EIS0
+C        N IS THE ORDER OF THE MATRIX.                                  EIS0
+C                                                                       EIS0
+C        LOW AND IGH ARE INTEGERS DETERMINED BY  BALANC.                EIS0
+C                                                                       EIS0
+C        SCALE CONTAINS INFORMATION DETERMINING THE PERMUTATIONS        EIS0
+C          AND SCALING FACTORS USED BY  BALANC.                         EIS0
+C                                                                       EIS0
+C        M IS THE NUMBER OF COLUMNS OF Z TO BE BACK TRANSFORMED.        EIS0
+C                                                                       EIS0
+C        Z CONTAINS THE REAL AND IMAGINARY PARTS OF THE EIGEN-          EIS0
+C          VECTORS TO BE BACK TRANSFORMED IN ITS FIRST M COLUMNS.       EIS0
+C                                                                       EIS0
+C     ON OUTPUT                                                         EIS0
+C                                                                       EIS0
+C        Z CONTAINS THE REAL AND IMAGINARY PARTS OF THE                 EIS0
+C          TRANSFORMED EIGENVECTORS IN ITS FIRST M COLUMNS.             EIS0
+C                                                                       EIS0
+C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS0
+C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS0
+C                                                                       EIS0
+C     THIS VERSION DATED AUGUST 1983.                                   EIS0
+C                                                                       EIS0
+C     ------------------------------------------------------------------EIS0
+C                                                                       EIS0
+      IF (M .EQ. 0) GO TO 200                                           EIS0
+      IF (IGH .EQ. LOW) GO TO 120                                       EIS0
+C                                                                       EIS0
+      DO 110 I = LOW, IGH                                               EIS0
+         S = SCALE(I)                                                   EIS0
+C     .......... LEFT HAND EIGENVECTORS ARE BACK TRANSFORMED            EIS0
+C                IF THE FOREGOING STATEMENT IS REPLACED BY              EIS0
+C                S=1.0D0/SCALE(I). ..........                           EIS0
+         DO 100 J = 1, M                                                EIS0
+  100    Z(I,J) = Z(I,J) * S                                            EIS0
+C                                                                       EIS0
+  110 CONTINUE                                                          EIS0
+C     ......... FOR I=LOW-1 STEP -1 UNTIL 1,                            EIS0
+C               IGH+1 STEP 1 UNTIL N DO -- ..........                   EIS0
+  120 DO 140 II = 1, N                                                  EIS0
+         I = II                                                         EIS0
+         IF (I .GE. LOW .AND. I .LE. IGH) GO TO 140                     EIS0
+         IF (I .LT. LOW) I = LOW - II                                   EIS0
+         K = SCALE(I)                                                   EIS0
+         IF (K .EQ. I) GO TO 140                                        EIS0
+C                                                                       EIS0
+         DO 130 J = 1, M                                                EIS0
+            S = Z(I,J)                                                  EIS0
+            Z(I,J) = Z(K,J)                                             EIS0
+            Z(K,J) = S                                                  EIS0
+  130    CONTINUE                                                       EIS0
+C                                                                       EIS0
+  140 CONTINUE                                                          EIS0
+C                                                                       EIS0
+  200 RETURN                                                            EIS0
+      END                                                               EIS0

Deleted: grass-addons/misc/m.eigensystem/cdiv.f
===================================================================
--- grass-addons/m.eigensystem/cdiv.f	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/cdiv.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,16 +0,0 @@
-      SUBROUTINE CDIV(AR,AI,BR,BI,CR,CI)                                EIS0
-      DOUBLE PRECISION AR,AI,BR,BI,CR,CI                                EIS0
-C                                                                       EIS0
-C     COMPLEX DIVISION, (CR,CI) = (AR,AI)/(BR,BI)                       EIS0
-C                                                                       EIS0
-      DOUBLE PRECISION S,ARS,AIS,BRS,BIS                                EIS0
-      S = DABS(BR) + DABS(BI)                                           EIS0
-      ARS = AR/S                                                        EIS0
-      AIS = AI/S                                                        EIS0
-      BRS = BR/S                                                        EIS0
-      BIS = BI/S                                                        EIS0
-      S = BRS**2 + BIS**2                                               EIS0
-      CR = (ARS*BRS + AIS*BIS)/S                                        EIS0
-      CI = (AIS*BRS - ARS*BIS)/S                                        EIS0
-      RETURN                                                            EIS0
-      END                                                               EIS0

Copied: grass-addons/misc/m.eigensystem/cdiv.f (from rev 30335, grass-addons/m.eigensystem/cdiv.f)
===================================================================
--- grass-addons/misc/m.eigensystem/cdiv.f	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/cdiv.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,16 @@
+      SUBROUTINE CDIV(AR,AI,BR,BI,CR,CI)                                EIS0
+      DOUBLE PRECISION AR,AI,BR,BI,CR,CI                                EIS0
+C                                                                       EIS0
+C     COMPLEX DIVISION, (CR,CI) = (AR,AI)/(BR,BI)                       EIS0
+C                                                                       EIS0
+      DOUBLE PRECISION S,ARS,AIS,BRS,BIS                                EIS0
+      S = DABS(BR) + DABS(BI)                                           EIS0
+      ARS = AR/S                                                        EIS0
+      AIS = AI/S                                                        EIS0
+      BRS = BR/S                                                        EIS0
+      BIS = BI/S                                                        EIS0
+      S = BRS**2 + BIS**2                                               EIS0
+      CR = (ARS*BRS + AIS*BIS)/S                                        EIS0
+      CI = (AIS*BRS - ARS*BIS)/S                                        EIS0
+      RETURN                                                            EIS0
+      END                                                               EIS0

Deleted: grass-addons/misc/m.eigensystem/corr.7x7
===================================================================
--- grass-addons/m.eigensystem/corr.7x7	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/corr.7x7	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,8 +0,0 @@
-7
-1.000 0.954 0.932 0.729 0.843 0.365 0.840
-0.954 1.000 0.952 0.795 0.877 0.390 0.862
-0.932 0.952 1.000 0.697 0.892 0.416 0.908
-0.729 0.795 0.697 1.000 0.819 0.459 0.673
-0.843 0.877 0.892 0.819 1.000 0.582 0.948
-0.365 0.390 0.416 0.459 0.582 1.000 0.552
-0.840 0.862 0.908 0.673 0.948 0.552 1.000

Copied: grass-addons/misc/m.eigensystem/corr.7x7 (from rev 30335, grass-addons/m.eigensystem/corr.7x7)
===================================================================
--- grass-addons/misc/m.eigensystem/corr.7x7	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/corr.7x7	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,8 @@
+7
+1.000 0.954 0.932 0.729 0.843 0.365 0.840
+0.954 1.000 0.952 0.795 0.877 0.390 0.862
+0.932 0.952 1.000 0.697 0.892 0.416 0.908
+0.729 0.795 0.697 1.000 0.819 0.459 0.673
+0.843 0.877 0.892 0.819 1.000 0.582 0.948
+0.365 0.390 0.416 0.459 0.582 1.000 0.552
+0.840 0.862 0.908 0.673 0.948 0.552 1.000

Deleted: grass-addons/misc/m.eigensystem/elmhes.f
===================================================================
--- grass-addons/m.eigensystem/elmhes.f	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/elmhes.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,98 +0,0 @@
-      SUBROUTINE ELMHES(NM,N,LOW,IGH,A,INT)                             EIS3
-C                                                                       EIS3
-      INTEGER I,J,M,N,LA,NM,IGH,KP1,LOW,MM1,MP1                         EIS3
-      DOUBLE PRECISION A(NM,N)                                          EIS3
-      DOUBLE PRECISION X,Y                                              EIS3
-      INTEGER INT(IGH)                                                  EIS3
-C                                                                       EIS3
-C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE ELMHES,   EIS3
-C     NUM. MATH. 12, 349-368(1968) BY MARTIN AND WILKINSON.             EIS3
-C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971).   EIS3
-C                                                                       EIS3
-C     GIVEN A REAL GENERAL MATRIX, THIS SUBROUTINE                      EIS3
-C     REDUCES A SUBMATRIX SITUATED IN ROWS AND COLUMNS                  EIS3
-C     LOW THROUGH IGH TO UPPER HESSENBERG FORM BY                       EIS3
-C     STABILIZED ELEMENTARY SIMILARITY TRANSFORMATIONS.                 EIS3
-C                                                                       EIS3
-C     ON INPUT                                                          EIS3
-C                                                                       EIS3
-C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS3
-C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS3
-C          DIMENSION STATEMENT.                                         EIS3
-C                                                                       EIS3
-C        N IS THE ORDER OF THE MATRIX.                                  EIS3
-C                                                                       EIS3
-C        LOW AND IGH ARE INTEGERS DETERMINED BY THE BALANCING           EIS3
-C          SUBROUTINE  BALANC.  IF  BALANC  HAS NOT BEEN USED,          EIS3
-C          SET LOW=1, IGH=N.                                            EIS3
-C                                                                       EIS3
-C        A CONTAINS THE INPUT MATRIX.                                   EIS3
-C                                                                       EIS3
-C     ON OUTPUT                                                         EIS3
-C                                                                       EIS3
-C        A CONTAINS THE HESSENBERG MATRIX.  THE MULTIPLIERS             EIS3
-C          WHICH WERE USED IN THE REDUCTION ARE STORED IN THE           EIS3
-C          REMAINING TRIANGLE UNDER THE HESSENBERG MATRIX.              EIS3
-C                                                                       EIS3
-C        INT CONTAINS INFORMATION ON THE ROWS AND COLUMNS               EIS3
-C          INTERCHANGED IN THE REDUCTION.                               EIS3
-C          ONLY ELEMENTS LOW THROUGH IGH ARE USED.                      EIS3
-C                                                                       EIS3
-C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS3
-C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS3
-C                                                                       EIS3
-C     THIS VERSION DATED AUGUST 1983.                                   EIS3
-C                                                                       EIS3
-C     ------------------------------------------------------------------EIS3
-C                                                                       EIS3
-      LA = IGH - 1                                                      EIS3
-      KP1 = LOW + 1                                                     EIS3
-      IF (LA .LT. KP1) GO TO 200                                        EIS3
-C                                                                       EIS3
-      DO 180 M = KP1, LA                                                EIS3
-         MM1 = M - 1                                                    EIS3
-         X = 0.0D0                                                      EIS3
-         I = M                                                          EIS3
-C                                                                       EIS3
-         DO 100 J = M, IGH                                              EIS3
-            IF (DABS(A(J,MM1)) .LE. DABS(X)) GO TO 100                  EIS3
-            X = A(J,MM1)                                                EIS3
-            I = J                                                       EIS3
-  100    CONTINUE                                                       EIS3
-C                                                                       EIS3
-         INT(M) = I                                                     EIS3
-         IF (I .EQ. M) GO TO 130                                        EIS3
-C     .......... INTERCHANGE ROWS AND COLUMNS OF A ..........           EIS3
-         DO 110 J = MM1, N                                              EIS3
-            Y = A(I,J)                                                  EIS3
-            A(I,J) = A(M,J)                                             EIS3
-            A(M,J) = Y                                                  EIS3
-  110    CONTINUE                                                       EIS3
-C                                                                       EIS3
-         DO 120 J = 1, IGH                                              EIS3
-            Y = A(J,I)                                                  EIS3
-            A(J,I) = A(J,M)                                             EIS3
-            A(J,M) = Y                                                  EIS3
-  120    CONTINUE                                                       EIS3
-C     .......... END INTERCHANGE ..........                             EIS3
-  130    IF (X .EQ. 0.0D0) GO TO 180                                    EIS3
-         MP1 = M + 1                                                    EIS3
-C                                                                       EIS3
-         DO 160 I = MP1, IGH                                            EIS3
-            Y = A(I,MM1)                                                EIS3
-            IF (Y .EQ. 0.0D0) GO TO 160                                 EIS3
-            Y = Y / X                                                   EIS3
-            A(I,MM1) = Y                                                EIS3
-C                                                                       EIS3
-            DO 140 J = M, N                                             EIS3
-  140       A(I,J) = A(I,J) - Y * A(M,J)                                EIS3
-C                                                                       EIS3
-            DO 150 J = 1, IGH                                           EIS3
-  150       A(J,M) = A(J,M) + Y * A(J,I)                                EIS3
-C                                                                       EIS3
-  160    CONTINUE                                                       EIS3
-C                                                                       EIS3
-  180 CONTINUE                                                          EIS3
-C                                                                       EIS3
-  200 RETURN                                                            EIS3
-      END                                                               EIS3

Copied: grass-addons/misc/m.eigensystem/elmhes.f (from rev 30335, grass-addons/m.eigensystem/elmhes.f)
===================================================================
--- grass-addons/misc/m.eigensystem/elmhes.f	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/elmhes.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,98 @@
+      SUBROUTINE ELMHES(NM,N,LOW,IGH,A,INT)                             EIS3
+C                                                                       EIS3
+      INTEGER I,J,M,N,LA,NM,IGH,KP1,LOW,MM1,MP1                         EIS3
+      DOUBLE PRECISION A(NM,N)                                          EIS3
+      DOUBLE PRECISION X,Y                                              EIS3
+      INTEGER INT(IGH)                                                  EIS3
+C                                                                       EIS3
+C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE ELMHES,   EIS3
+C     NUM. MATH. 12, 349-368(1968) BY MARTIN AND WILKINSON.             EIS3
+C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971).   EIS3
+C                                                                       EIS3
+C     GIVEN A REAL GENERAL MATRIX, THIS SUBROUTINE                      EIS3
+C     REDUCES A SUBMATRIX SITUATED IN ROWS AND COLUMNS                  EIS3
+C     LOW THROUGH IGH TO UPPER HESSENBERG FORM BY                       EIS3
+C     STABILIZED ELEMENTARY SIMILARITY TRANSFORMATIONS.                 EIS3
+C                                                                       EIS3
+C     ON INPUT                                                          EIS3
+C                                                                       EIS3
+C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS3
+C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS3
+C          DIMENSION STATEMENT.                                         EIS3
+C                                                                       EIS3
+C        N IS THE ORDER OF THE MATRIX.                                  EIS3
+C                                                                       EIS3
+C        LOW AND IGH ARE INTEGERS DETERMINED BY THE BALANCING           EIS3
+C          SUBROUTINE  BALANC.  IF  BALANC  HAS NOT BEEN USED,          EIS3
+C          SET LOW=1, IGH=N.                                            EIS3
+C                                                                       EIS3
+C        A CONTAINS THE INPUT MATRIX.                                   EIS3
+C                                                                       EIS3
+C     ON OUTPUT                                                         EIS3
+C                                                                       EIS3
+C        A CONTAINS THE HESSENBERG MATRIX.  THE MULTIPLIERS             EIS3
+C          WHICH WERE USED IN THE REDUCTION ARE STORED IN THE           EIS3
+C          REMAINING TRIANGLE UNDER THE HESSENBERG MATRIX.              EIS3
+C                                                                       EIS3
+C        INT CONTAINS INFORMATION ON THE ROWS AND COLUMNS               EIS3
+C          INTERCHANGED IN THE REDUCTION.                               EIS3
+C          ONLY ELEMENTS LOW THROUGH IGH ARE USED.                      EIS3
+C                                                                       EIS3
+C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS3
+C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS3
+C                                                                       EIS3
+C     THIS VERSION DATED AUGUST 1983.                                   EIS3
+C                                                                       EIS3
+C     ------------------------------------------------------------------EIS3
+C                                                                       EIS3
+      LA = IGH - 1                                                      EIS3
+      KP1 = LOW + 1                                                     EIS3
+      IF (LA .LT. KP1) GO TO 200                                        EIS3
+C                                                                       EIS3
+      DO 180 M = KP1, LA                                                EIS3
+         MM1 = M - 1                                                    EIS3
+         X = 0.0D0                                                      EIS3
+         I = M                                                          EIS3
+C                                                                       EIS3
+         DO 100 J = M, IGH                                              EIS3
+            IF (DABS(A(J,MM1)) .LE. DABS(X)) GO TO 100                  EIS3
+            X = A(J,MM1)                                                EIS3
+            I = J                                                       EIS3
+  100    CONTINUE                                                       EIS3
+C                                                                       EIS3
+         INT(M) = I                                                     EIS3
+         IF (I .EQ. M) GO TO 130                                        EIS3
+C     .......... INTERCHANGE ROWS AND COLUMNS OF A ..........           EIS3
+         DO 110 J = MM1, N                                              EIS3
+            Y = A(I,J)                                                  EIS3
+            A(I,J) = A(M,J)                                             EIS3
+            A(M,J) = Y                                                  EIS3
+  110    CONTINUE                                                       EIS3
+C                                                                       EIS3
+         DO 120 J = 1, IGH                                              EIS3
+            Y = A(J,I)                                                  EIS3
+            A(J,I) = A(J,M)                                             EIS3
+            A(J,M) = Y                                                  EIS3
+  120    CONTINUE                                                       EIS3
+C     .......... END INTERCHANGE ..........                             EIS3
+  130    IF (X .EQ. 0.0D0) GO TO 180                                    EIS3
+         MP1 = M + 1                                                    EIS3
+C                                                                       EIS3
+         DO 160 I = MP1, IGH                                            EIS3
+            Y = A(I,MM1)                                                EIS3
+            IF (Y .EQ. 0.0D0) GO TO 160                                 EIS3
+            Y = Y / X                                                   EIS3
+            A(I,MM1) = Y                                                EIS3
+C                                                                       EIS3
+            DO 140 J = M, N                                             EIS3
+  140       A(I,J) = A(I,J) - Y * A(M,J)                                EIS3
+C                                                                       EIS3
+            DO 150 J = 1, IGH                                           EIS3
+  150       A(J,M) = A(J,M) + Y * A(J,I)                                EIS3
+C                                                                       EIS3
+  160    CONTINUE                                                       EIS3
+C                                                                       EIS3
+  180 CONTINUE                                                          EIS3
+C                                                                       EIS3
+  200 RETURN                                                            EIS3
+      END                                                               EIS3

Deleted: grass-addons/misc/m.eigensystem/eltran.f
===================================================================
--- grass-addons/m.eigensystem/eltran.f	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/eltran.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,78 +0,0 @@
-      SUBROUTINE ELTRAN(NM,N,LOW,IGH,A,INT,Z)                           EIS4
-C                                                                       EIS4
-      INTEGER I,J,N,KL,MM,MP,NM,IGH,LOW,MP1                             EIS4
-      DOUBLE PRECISION A(NM,IGH),Z(NM,N)                                EIS4
-      INTEGER INT(IGH)                                                  EIS4
-C                                                                       EIS4
-C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE ELMTRANS, EIS4
-C     NUM. MATH. 16, 181-204(1970) BY PETERS AND WILKINSON.             EIS4
-C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 372-395(1971).   EIS4
-C                                                                       EIS4
-C     THIS SUBROUTINE ACCUMULATES THE STABILIZED ELEMENTARY             EIS4
-C     SIMILARITY TRANSFORMATIONS USED IN THE REDUCTION OF A             EIS4
-C     REAL GENERAL MATRIX TO UPPER HESSENBERG FORM BY  ELMHES.          EIS4
-C                                                                       EIS4
-C     ON INPUT                                                          EIS4
-C                                                                       EIS4
-C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS4
-C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS4
-C          DIMENSION STATEMENT.                                         EIS4
-C                                                                       EIS4
-C        N IS THE ORDER OF THE MATRIX.                                  EIS4
-C                                                                       EIS4
-C        LOW AND IGH ARE INTEGERS DETERMINED BY THE BALANCING           EIS4
-C          SUBROUTINE  BALANC.  IF  BALANC  HAS NOT BEEN USED,          EIS4
-C          SET LOW=1, IGH=N.                                            EIS4
-C                                                                       EIS4
-C        A CONTAINS THE MULTIPLIERS WHICH WERE USED IN THE              EIS4
-C          REDUCTION BY  ELMHES  IN ITS LOWER TRIANGLE                  EIS4
-C          BELOW THE SUBDIAGONAL.                                       EIS4
-C                                                                       EIS4
-C        INT CONTAINS INFORMATION ON THE ROWS AND COLUMNS               EIS4
-C          INTERCHANGED IN THE REDUCTION BY  ELMHES.                    EIS4
-C          ONLY ELEMENTS LOW THROUGH IGH ARE USED.                      EIS4
-C                                                                       EIS4
-C     ON OUTPUT                                                         EIS4
-C                                                                       EIS4
-C        Z CONTAINS THE TRANSFORMATION MATRIX PRODUCED IN THE           EIS4
-C          REDUCTION BY  ELMHES.                                        EIS4
-C                                                                       EIS4
-C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS4
-C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS4
-C                                                                       EIS4
-C     THIS VERSION DATED AUGUST 1983.                                   EIS4
-C                                                                       EIS4
-C     ------------------------------------------------------------------EIS4
-C                                                                       EIS4
-C     .......... INITIALIZE Z TO IDENTITY MATRIX ..........             EIS4
-      DO 80 J = 1, N                                                    EIS4
-C                                                                       EIS4
-         DO 60 I = 1, N                                                 EIS4
-   60    Z(I,J) = 0.0D0                                                 EIS4
-C                                                                       EIS4
-         Z(J,J) = 1.0D0                                                 EIS4
-   80 CONTINUE                                                          EIS4
-C                                                                       EIS4
-      KL = IGH - LOW - 1                                                EIS4
-      IF (KL .LT. 1) GO TO 200                                          EIS4
-C     .......... FOR MP=IGH-1 STEP -1 UNTIL LOW+1 DO -- ..........      EIS4
-      DO 140 MM = 1, KL                                                 EIS4
-         MP = IGH - MM                                                  EIS4
-         MP1 = MP + 1                                                   EIS4
-C                                                                       EIS4
-         DO 100 I = MP1, IGH                                            EIS4
-  100    Z(I,MP) = A(I,MP-1)                                            EIS4
-C                                                                       EIS4
-         I = INT(MP)                                                    EIS4
-         IF (I .EQ. MP) GO TO 140                                       EIS4
-C                                                                       EIS4
-         DO 130 J = MP, IGH                                             EIS4
-            Z(MP,J) = Z(I,J)                                            EIS4
-            Z(I,J) = 0.0D0                                              EIS4
-  130    CONTINUE                                                       EIS4
-C                                                                       EIS4
-         Z(I,MP) = 1.0D0                                                EIS4
-  140 CONTINUE                                                          EIS4
-C                                                                       EIS4
-  200 RETURN                                                            EIS4
-      END                                                               EIS4

Copied: grass-addons/misc/m.eigensystem/eltran.f (from rev 30335, grass-addons/m.eigensystem/eltran.f)
===================================================================
--- grass-addons/misc/m.eigensystem/eltran.f	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/eltran.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,78 @@
+      SUBROUTINE ELTRAN(NM,N,LOW,IGH,A,INT,Z)                           EIS4
+C                                                                       EIS4
+      INTEGER I,J,N,KL,MM,MP,NM,IGH,LOW,MP1                             EIS4
+      DOUBLE PRECISION A(NM,IGH),Z(NM,N)                                EIS4
+      INTEGER INT(IGH)                                                  EIS4
+C                                                                       EIS4
+C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE ELMTRANS, EIS4
+C     NUM. MATH. 16, 181-204(1970) BY PETERS AND WILKINSON.             EIS4
+C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 372-395(1971).   EIS4
+C                                                                       EIS4
+C     THIS SUBROUTINE ACCUMULATES THE STABILIZED ELEMENTARY             EIS4
+C     SIMILARITY TRANSFORMATIONS USED IN THE REDUCTION OF A             EIS4
+C     REAL GENERAL MATRIX TO UPPER HESSENBERG FORM BY  ELMHES.          EIS4
+C                                                                       EIS4
+C     ON INPUT                                                          EIS4
+C                                                                       EIS4
+C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS4
+C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS4
+C          DIMENSION STATEMENT.                                         EIS4
+C                                                                       EIS4
+C        N IS THE ORDER OF THE MATRIX.                                  EIS4
+C                                                                       EIS4
+C        LOW AND IGH ARE INTEGERS DETERMINED BY THE BALANCING           EIS4
+C          SUBROUTINE  BALANC.  IF  BALANC  HAS NOT BEEN USED,          EIS4
+C          SET LOW=1, IGH=N.                                            EIS4
+C                                                                       EIS4
+C        A CONTAINS THE MULTIPLIERS WHICH WERE USED IN THE              EIS4
+C          REDUCTION BY  ELMHES  IN ITS LOWER TRIANGLE                  EIS4
+C          BELOW THE SUBDIAGONAL.                                       EIS4
+C                                                                       EIS4
+C        INT CONTAINS INFORMATION ON THE ROWS AND COLUMNS               EIS4
+C          INTERCHANGED IN THE REDUCTION BY  ELMHES.                    EIS4
+C          ONLY ELEMENTS LOW THROUGH IGH ARE USED.                      EIS4
+C                                                                       EIS4
+C     ON OUTPUT                                                         EIS4
+C                                                                       EIS4
+C        Z CONTAINS THE TRANSFORMATION MATRIX PRODUCED IN THE           EIS4
+C          REDUCTION BY  ELMHES.                                        EIS4
+C                                                                       EIS4
+C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS4
+C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS4
+C                                                                       EIS4
+C     THIS VERSION DATED AUGUST 1983.                                   EIS4
+C                                                                       EIS4
+C     ------------------------------------------------------------------EIS4
+C                                                                       EIS4
+C     .......... INITIALIZE Z TO IDENTITY MATRIX ..........             EIS4
+      DO 80 J = 1, N                                                    EIS4
+C                                                                       EIS4
+         DO 60 I = 1, N                                                 EIS4
+   60    Z(I,J) = 0.0D0                                                 EIS4
+C                                                                       EIS4
+         Z(J,J) = 1.0D0                                                 EIS4
+   80 CONTINUE                                                          EIS4
+C                                                                       EIS4
+      KL = IGH - LOW - 1                                                EIS4
+      IF (KL .LT. 1) GO TO 200                                          EIS4
+C     .......... FOR MP=IGH-1 STEP -1 UNTIL LOW+1 DO -- ..........      EIS4
+      DO 140 MM = 1, KL                                                 EIS4
+         MP = IGH - MM                                                  EIS4
+         MP1 = MP + 1                                                   EIS4
+C                                                                       EIS4
+         DO 100 I = MP1, IGH                                            EIS4
+  100    Z(I,MP) = A(I,MP-1)                                            EIS4
+C                                                                       EIS4
+         I = INT(MP)                                                    EIS4
+         IF (I .EQ. MP) GO TO 140                                       EIS4
+C                                                                       EIS4
+         DO 130 J = MP, IGH                                             EIS4
+            Z(MP,J) = Z(I,J)                                            EIS4
+            Z(I,J) = 0.0D0                                              EIS4
+  130    CONTINUE                                                       EIS4
+C                                                                       EIS4
+         Z(I,MP) = 1.0D0                                                EIS4
+  140 CONTINUE                                                          EIS4
+C                                                                       EIS4
+  200 RETURN                                                            EIS4
+      END                                                               EIS4

Deleted: grass-addons/misc/m.eigensystem/hqr.f
===================================================================
--- grass-addons/m.eigensystem/hqr.f	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/hqr.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,234 +0,0 @@
-      SUBROUTINE HQR(NM,N,LOW,IGH,H,WR,WI,IERR)                         EIS4
-C                                                                       EIS4
-      INTEGER I,J,K,L,M,N,EN,LL,MM,NA,NM,IGH,ITN,ITS,LOW,MP2,ENM2,IERR  EIS4
-      DOUBLE PRECISION H(NM,N),WR(N),WI(N)                              EIS4
-      DOUBLE PRECISION P,Q,R,S,T,W,X,Y,ZZ,NORM,TST1,TST2                EIS4
-      LOGICAL NOTLAS                                                    EIS4
-C                                                                       EIS4
-C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE HQR,      EIS4
-C     NUM. MATH. 14, 219-231(1970) BY MARTIN, PETERS, AND WILKINSON.    EIS4
-C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 359-371(1971).   EIS4
-C                                                                       EIS4
-C     THIS SUBROUTINE FINDS THE EIGENVALUES OF A REAL                   EIS4
-C     UPPER HESSENBERG MATRIX BY THE QR METHOD.                         EIS4
-C                                                                       EIS4
-C     ON INPUT                                                          EIS4
-C                                                                       EIS4
-C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS4
-C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS4
-C          DIMENSION STATEMENT.                                         EIS4
-C                                                                       EIS4
-C        N IS THE ORDER OF THE MATRIX.                                  EIS4
-C                                                                       EIS4
-C        LOW AND IGH ARE INTEGERS DETERMINED BY THE BALANCING           EIS4
-C          SUBROUTINE  BALANC.  IF  BALANC  HAS NOT BEEN USED,          EIS4
-C          SET LOW=1, IGH=N.                                            EIS4
-C                                                                       EIS4
-C        H CONTAINS THE UPPER HESSENBERG MATRIX.  INFORMATION ABOUT     EIS4
-C          THE TRANSFORMATIONS USED IN THE REDUCTION TO HESSENBERG      EIS4
-C          FORM BY  ELMHES  OR  ORTHES, IF PERFORMED, IS STORED         EIS4
-C          IN THE REMAINING TRIANGLE UNDER THE HESSENBERG MATRIX.       EIS4
-C                                                                       EIS4
-C     ON OUTPUT                                                         EIS4
-C                                                                       EIS4
-C        H HAS BEEN DESTROYED.  THEREFORE, IT MUST BE SAVED             EIS4
-C          BEFORE CALLING  HQR  IF SUBSEQUENT CALCULATION AND           EIS4
-C          BACK TRANSFORMATION OF EIGENVECTORS IS TO BE PERFORMED.      EIS4
-C                                                                       EIS4
-C        WR AND WI CONTAIN THE REAL AND IMAGINARY PARTS,                EIS4
-C          RESPECTIVELY, OF THE EIGENVALUES.  THE EIGENVALUES           EIS4
-C          ARE UNORDERED EXCEPT THAT COMPLEX CONJUGATE PAIRS            EIS4
-C          OF VALUES APPEAR CONSECUTIVELY WITH THE EIGENVALUE           EIS4
-C          HAVING THE POSITIVE IMAGINARY PART FIRST.  IF AN             EIS4
-C          ERROR EXIT IS MADE, THE EIGENVALUES SHOULD BE CORRECT        EIS4
-C          FOR INDICES IERR+1,...,N.                                    EIS4
-C                                                                       EIS4
-C        IERR IS SET TO                                                 EIS4
-C          ZERO       FOR NORMAL RETURN,                                EIS4
-C          J          IF THE LIMIT OF 30*N ITERATIONS IS EXHAUSTED      EIS4
-C                     WHILE THE J-TH EIGENVALUE IS BEING SOUGHT.        EIS4
-C                                                                       EIS4
-C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS4
-C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS4
-C                                                                       EIS4
-C     THIS VERSION DATED AUGUST 1983.                                   EIS4
-C                                                                       EIS4
-C     ------------------------------------------------------------------EIS4
-C                                                                       EIS4
-      IERR = 0                                                          EIS4
-      NORM = 0.0D0                                                      EIS4
-      K = 1                                                             EIS4
-C     .......... STORE ROOTS ISOLATED BY BALANC                         EIS4
-C                AND COMPUTE MATRIX NORM ..........                     EIS4
-      DO 50 I = 1, N                                                    EIS4
-C                                                                       EIS4
-         DO 40 J = K, N                                                 EIS4
-   40    NORM = NORM + DABS(H(I,J))                                     EIS4
-C                                                                       EIS4
-         K = I                                                          EIS4
-         IF (I .GE. LOW .AND. I .LE. IGH) GO TO 50                      EIS4
-         WR(I) = H(I,I)                                                 EIS4
-         WI(I) = 0.0D0                                                  EIS4
-   50 CONTINUE                                                          EIS4
-C                                                                       EIS4
-      EN = IGH                                                          EIS4
-      T = 0.0D0                                                         EIS4
-      ITN = 30*N                                                        EIS4
-C     .......... SEARCH FOR NEXT EIGENVALUES ..........                 EIS4
-   60 IF (EN .LT. LOW) GO TO 1001                                       EIS4
-      ITS = 0                                                           EIS4
-      NA = EN - 1                                                       EIS4
-      ENM2 = NA - 1                                                     EIS4
-C     .......... LOOK FOR SINGLE SMALL SUB-DIAGONAL ELEMENT             EIS4
-C                FOR L=EN STEP -1 UNTIL LOW DO -- ..........            EIS4
-   70 DO 80 LL = LOW, EN                                                EIS4
-         L = EN + LOW - LL                                              EIS4
-         IF (L .EQ. LOW) GO TO 100                                      EIS4
-         S = DABS(H(L-1,L-1)) + DABS(H(L,L))                            EIS4
-         IF (S .EQ. 0.0D0) S = NORM                                     EIS4
-         TST1 = S                                                       EIS4
-         TST2 = TST1 + DABS(H(L,L-1))                                   EIS4
-         IF (TST2 .EQ. TST1) GO TO 100                                  EIS4
-   80 CONTINUE                                                          EIS4
-C     .......... FORM SHIFT ..........                                  EIS4
-  100 X = H(EN,EN)                                                      EIS4
-      IF (L .EQ. EN) GO TO 270                                          EIS4
-      Y = H(NA,NA)                                                      EIS4
-      W = H(EN,NA) * H(NA,EN)                                           EIS4
-      IF (L .EQ. NA) GO TO 280                                          EIS4
-      IF (ITN .EQ. 0) GO TO 1000                                        EIS4
-      IF (ITS .NE. 10 .AND. ITS .NE. 20) GO TO 130                      EIS4
-C     .......... FORM EXCEPTIONAL SHIFT ..........                      EIS4
-      T = T + X                                                         EIS4
-C                                                                       EIS4
-      DO 120 I = LOW, EN                                                EIS4
-  120 H(I,I) = H(I,I) - X                                               EIS4
-C                                                                       EIS4
-      S = DABS(H(EN,NA)) + DABS(H(NA,ENM2))                             EIS4
-      X = 0.75D0 * S                                                    EIS4
-      Y = X                                                             EIS4
-      W = -0.4375D0 * S * S                                             EIS4
-  130 ITS = ITS + 1                                                     EIS4
-      ITN = ITN - 1                                                     EIS4
-C     .......... LOOK FOR TWO CONSECUTIVE SMALL                         EIS4
-C                SUB-DIAGONAL ELEMENTS.                                 EIS4
-C                FOR M=EN-2 STEP -1 UNTIL L DO -- ..........            EIS4
-      DO 140 MM = L, ENM2                                               EIS4
-         M = ENM2 + L - MM                                              EIS4
-         ZZ = H(M,M)                                                    EIS4
-         R = X - ZZ                                                     EIS4
-         S = Y - ZZ                                                     EIS4
-         P = (R * S - W) / H(M+1,M) + H(M,M+1)                          EIS4
-         Q = H(M+1,M+1) - ZZ - R - S                                    EIS4
-         R = H(M+2,M+1)                                                 EIS4
-         S = DABS(P) + DABS(Q) + DABS(R)                                EIS4
-         P = P / S                                                      EIS4
-         Q = Q / S                                                      EIS4
-         R = R / S                                                      EIS4
-         IF (M .EQ. L) GO TO 150                                        EIS4
-         TST1 = DABS(P)*(DABS(H(M-1,M-1)) + DABS(ZZ) + DABS(H(M+1,M+1)))EIS4
-         TST2 = TST1 + DABS(H(M,M-1))*(DABS(Q) + DABS(R))               EIS4
-         IF (TST2 .EQ. TST1) GO TO 150                                  EIS4
-  140 CONTINUE                                                          EIS4
-C                                                                       EIS4
-  150 MP2 = M + 2                                                       EIS4
-C                                                                       EIS4
-      DO 160 I = MP2, EN                                                EIS4
-         H(I,I-2) = 0.0D0                                               EIS4
-         IF (I .EQ. MP2) GO TO 160                                      EIS4
-         H(I,I-3) = 0.0D0                                               EIS4
-  160 CONTINUE                                                          EIS4
-C     .......... DOUBLE QR STEP INVOLVING ROWS L TO EN AND              EIS4
-C                COLUMNS M TO EN ..........                             EIS4
-      DO 260 K = M, NA                                                  EIS4
-         NOTLAS = K .NE. NA                                             EIS4
-         IF (K .EQ. M) GO TO 170                                        EIS4
-         P = H(K,K-1)                                                   EIS4
-         Q = H(K+1,K-1)                                                 EIS4
-         R = 0.0D0                                                      EIS4
-         IF (NOTLAS) R = H(K+2,K-1)                                     EIS4
-         X = DABS(P) + DABS(Q) + DABS(R)                                EIS4
-         IF (X .EQ. 0.0D0) GO TO 260                                    EIS4
-         P = P / X                                                      EIS4
-         Q = Q / X                                                      EIS4
-         R = R / X                                                      EIS4
-  170    S = DSIGN(DSQRT(P*P+Q*Q+R*R),P)                                EIS4
-         IF (K .EQ. M) GO TO 180                                        EIS4
-         H(K,K-1) = -S * X                                              EIS4
-         GO TO 190                                                      EIS4
-  180    IF (L .NE. M) H(K,K-1) = -H(K,K-1)                             EIS4
-  190    P = P + S                                                      EIS4
-         X = P / S                                                      EIS4
-         Y = Q / S                                                      EIS4
-         ZZ = R / S                                                     EIS4
-         Q = Q / P                                                      EIS4
-         R = R / P                                                      EIS4
-         IF (NOTLAS) GO TO 225                                          EIS4
-C     .......... ROW MODIFICATION ..........                            EIS4
-         DO 200 J = K, N                                                EIS4
-            P = H(K,J) + Q * H(K+1,J)                                   EIS4
-            H(K,J) = H(K,J) - P * X                                     EIS4
-            H(K+1,J) = H(K+1,J) - P * Y                                 EIS4
-  200    CONTINUE                                                       EIS4
-C                                                                       EIS4
-         J = MIN0(EN,K+3)                                               EIS4
-C     .......... COLUMN MODIFICATION ..........                         EIS4
-         DO 210 I = 1, J                                                EIS4
-            P = X * H(I,K) + Y * H(I,K+1)                               EIS4
-            H(I,K) = H(I,K) - P                                         EIS4
-            H(I,K+1) = H(I,K+1) - P * Q                                 EIS4
-  210    CONTINUE                                                       EIS4
-         GO TO 255                                                      EIS4
-  225    CONTINUE                                                       EIS4
-C     .......... ROW MODIFICATION ..........                            EIS4
-         DO 230 J = K, N                                                EIS4
-            P = H(K,J) + Q * H(K+1,J) + R * H(K+2,J)                    EIS4
-            H(K,J) = H(K,J) - P * X                                     EIS4
-            H(K+1,J) = H(K+1,J) - P * Y                                 EIS4
-            H(K+2,J) = H(K+2,J) - P * ZZ                                EIS4
-  230    CONTINUE                                                       EIS4
-C                                                                       EIS4
-         J = MIN0(EN,K+3)                                               EIS4
-C     .......... COLUMN MODIFICATION ..........                         EIS4
-         DO 240 I = 1, J                                                EIS4
-            P = X * H(I,K) + Y * H(I,K+1) + ZZ * H(I,K+2)               EIS4
-            H(I,K) = H(I,K) - P                                         EIS4
-            H(I,K+1) = H(I,K+1) - P * Q                                 EIS4
-            H(I,K+2) = H(I,K+2) - P * R                                 EIS4
-  240    CONTINUE                                                       EIS4
-  255    CONTINUE                                                       EIS4
-C                                                                       EIS4
-  260 CONTINUE                                                          EIS4
-C                                                                       EIS4
-      GO TO 70                                                          EIS4
-C     .......... ONE ROOT FOUND ..........                              EIS4
-  270 WR(EN) = X + T                                                    EIS4
-      WI(EN) = 0.0D0                                                    EIS4
-      EN = NA                                                           EIS4
-      GO TO 60                                                          EIS4
-C     .......... TWO ROOTS FOUND ..........                             EIS4
-  280 P = (Y - X) / 2.0D0                                               EIS4
-      Q = P * P + W                                                     EIS4
-      ZZ = DSQRT(DABS(Q))                                               EIS4
-      X = X + T                                                         EIS4
-      IF (Q .LT. 0.0D0) GO TO 320                                       EIS4
-C     .......... REAL PAIR ..........                                   EIS4
-      ZZ = P + DSIGN(ZZ,P)                                              EIS4
-      WR(NA) = X + ZZ                                                   EIS4
-      WR(EN) = WR(NA)                                                   EIS4
-      IF (ZZ .NE. 0.0D0) WR(EN) = X - W / ZZ                            EIS4
-      WI(NA) = 0.0D0                                                    EIS4
-      WI(EN) = 0.0D0                                                    EIS4
-      GO TO 330                                                         EIS4
-C     .......... COMPLEX PAIR ..........                                EIS4
-  320 WR(NA) = X + P                                                    EIS4
-      WR(EN) = X + P                                                    EIS4
-      WI(NA) = ZZ                                                       EIS4
-      WI(EN) = -ZZ                                                      EIS4
-  330 EN = ENM2                                                         EIS4
-      GO TO 60                                                          EIS4
-C     .......... SET ERROR -- ALL EIGENVALUES HAVE NOT                  EIS4
-C                CONVERGED AFTER 30*N ITERATIONS ..........             EIS4
- 1000 IERR = EN                                                         EIS4
- 1001 RETURN                                                            EIS4
-      END                                                               EIS4

Copied: grass-addons/misc/m.eigensystem/hqr.f (from rev 30335, grass-addons/m.eigensystem/hqr.f)
===================================================================
--- grass-addons/misc/m.eigensystem/hqr.f	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/hqr.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,234 @@
+      SUBROUTINE HQR(NM,N,LOW,IGH,H,WR,WI,IERR)                         EIS4
+C                                                                       EIS4
+      INTEGER I,J,K,L,M,N,EN,LL,MM,NA,NM,IGH,ITN,ITS,LOW,MP2,ENM2,IERR  EIS4
+      DOUBLE PRECISION H(NM,N),WR(N),WI(N)                              EIS4
+      DOUBLE PRECISION P,Q,R,S,T,W,X,Y,ZZ,NORM,TST1,TST2                EIS4
+      LOGICAL NOTLAS                                                    EIS4
+C                                                                       EIS4
+C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE HQR,      EIS4
+C     NUM. MATH. 14, 219-231(1970) BY MARTIN, PETERS, AND WILKINSON.    EIS4
+C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 359-371(1971).   EIS4
+C                                                                       EIS4
+C     THIS SUBROUTINE FINDS THE EIGENVALUES OF A REAL                   EIS4
+C     UPPER HESSENBERG MATRIX BY THE QR METHOD.                         EIS4
+C                                                                       EIS4
+C     ON INPUT                                                          EIS4
+C                                                                       EIS4
+C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS4
+C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS4
+C          DIMENSION STATEMENT.                                         EIS4
+C                                                                       EIS4
+C        N IS THE ORDER OF THE MATRIX.                                  EIS4
+C                                                                       EIS4
+C        LOW AND IGH ARE INTEGERS DETERMINED BY THE BALANCING           EIS4
+C          SUBROUTINE  BALANC.  IF  BALANC  HAS NOT BEEN USED,          EIS4
+C          SET LOW=1, IGH=N.                                            EIS4
+C                                                                       EIS4
+C        H CONTAINS THE UPPER HESSENBERG MATRIX.  INFORMATION ABOUT     EIS4
+C          THE TRANSFORMATIONS USED IN THE REDUCTION TO HESSENBERG      EIS4
+C          FORM BY  ELMHES  OR  ORTHES, IF PERFORMED, IS STORED         EIS4
+C          IN THE REMAINING TRIANGLE UNDER THE HESSENBERG MATRIX.       EIS4
+C                                                                       EIS4
+C     ON OUTPUT                                                         EIS4
+C                                                                       EIS4
+C        H HAS BEEN DESTROYED.  THEREFORE, IT MUST BE SAVED             EIS4
+C          BEFORE CALLING  HQR  IF SUBSEQUENT CALCULATION AND           EIS4
+C          BACK TRANSFORMATION OF EIGENVECTORS IS TO BE PERFORMED.      EIS4
+C                                                                       EIS4
+C        WR AND WI CONTAIN THE REAL AND IMAGINARY PARTS,                EIS4
+C          RESPECTIVELY, OF THE EIGENVALUES.  THE EIGENVALUES           EIS4
+C          ARE UNORDERED EXCEPT THAT COMPLEX CONJUGATE PAIRS            EIS4
+C          OF VALUES APPEAR CONSECUTIVELY WITH THE EIGENVALUE           EIS4
+C          HAVING THE POSITIVE IMAGINARY PART FIRST.  IF AN             EIS4
+C          ERROR EXIT IS MADE, THE EIGENVALUES SHOULD BE CORRECT        EIS4
+C          FOR INDICES IERR+1,...,N.                                    EIS4
+C                                                                       EIS4
+C        IERR IS SET TO                                                 EIS4
+C          ZERO       FOR NORMAL RETURN,                                EIS4
+C          J          IF THE LIMIT OF 30*N ITERATIONS IS EXHAUSTED      EIS4
+C                     WHILE THE J-TH EIGENVALUE IS BEING SOUGHT.        EIS4
+C                                                                       EIS4
+C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS4
+C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS4
+C                                                                       EIS4
+C     THIS VERSION DATED AUGUST 1983.                                   EIS4
+C                                                                       EIS4
+C     ------------------------------------------------------------------EIS4
+C                                                                       EIS4
+      IERR = 0                                                          EIS4
+      NORM = 0.0D0                                                      EIS4
+      K = 1                                                             EIS4
+C     .......... STORE ROOTS ISOLATED BY BALANC                         EIS4
+C                AND COMPUTE MATRIX NORM ..........                     EIS4
+      DO 50 I = 1, N                                                    EIS4
+C                                                                       EIS4
+         DO 40 J = K, N                                                 EIS4
+   40    NORM = NORM + DABS(H(I,J))                                     EIS4
+C                                                                       EIS4
+         K = I                                                          EIS4
+         IF (I .GE. LOW .AND. I .LE. IGH) GO TO 50                      EIS4
+         WR(I) = H(I,I)                                                 EIS4
+         WI(I) = 0.0D0                                                  EIS4
+   50 CONTINUE                                                          EIS4
+C                                                                       EIS4
+      EN = IGH                                                          EIS4
+      T = 0.0D0                                                         EIS4
+      ITN = 30*N                                                        EIS4
+C     .......... SEARCH FOR NEXT EIGENVALUES ..........                 EIS4
+   60 IF (EN .LT. LOW) GO TO 1001                                       EIS4
+      ITS = 0                                                           EIS4
+      NA = EN - 1                                                       EIS4
+      ENM2 = NA - 1                                                     EIS4
+C     .......... LOOK FOR SINGLE SMALL SUB-DIAGONAL ELEMENT             EIS4
+C                FOR L=EN STEP -1 UNTIL LOW DO -- ..........            EIS4
+   70 DO 80 LL = LOW, EN                                                EIS4
+         L = EN + LOW - LL                                              EIS4
+         IF (L .EQ. LOW) GO TO 100                                      EIS4
+         S = DABS(H(L-1,L-1)) + DABS(H(L,L))                            EIS4
+         IF (S .EQ. 0.0D0) S = NORM                                     EIS4
+         TST1 = S                                                       EIS4
+         TST2 = TST1 + DABS(H(L,L-1))                                   EIS4
+         IF (TST2 .EQ. TST1) GO TO 100                                  EIS4
+   80 CONTINUE                                                          EIS4
+C     .......... FORM SHIFT ..........                                  EIS4
+  100 X = H(EN,EN)                                                      EIS4
+      IF (L .EQ. EN) GO TO 270                                          EIS4
+      Y = H(NA,NA)                                                      EIS4
+      W = H(EN,NA) * H(NA,EN)                                           EIS4
+      IF (L .EQ. NA) GO TO 280                                          EIS4
+      IF (ITN .EQ. 0) GO TO 1000                                        EIS4
+      IF (ITS .NE. 10 .AND. ITS .NE. 20) GO TO 130                      EIS4
+C     .......... FORM EXCEPTIONAL SHIFT ..........                      EIS4
+      T = T + X                                                         EIS4
+C                                                                       EIS4
+      DO 120 I = LOW, EN                                                EIS4
+  120 H(I,I) = H(I,I) - X                                               EIS4
+C                                                                       EIS4
+      S = DABS(H(EN,NA)) + DABS(H(NA,ENM2))                             EIS4
+      X = 0.75D0 * S                                                    EIS4
+      Y = X                                                             EIS4
+      W = -0.4375D0 * S * S                                             EIS4
+  130 ITS = ITS + 1                                                     EIS4
+      ITN = ITN - 1                                                     EIS4
+C     .......... LOOK FOR TWO CONSECUTIVE SMALL                         EIS4
+C                SUB-DIAGONAL ELEMENTS.                                 EIS4
+C                FOR M=EN-2 STEP -1 UNTIL L DO -- ..........            EIS4
+      DO 140 MM = L, ENM2                                               EIS4
+         M = ENM2 + L - MM                                              EIS4
+         ZZ = H(M,M)                                                    EIS4
+         R = X - ZZ                                                     EIS4
+         S = Y - ZZ                                                     EIS4
+         P = (R * S - W) / H(M+1,M) + H(M,M+1)                          EIS4
+         Q = H(M+1,M+1) - ZZ - R - S                                    EIS4
+         R = H(M+2,M+1)                                                 EIS4
+         S = DABS(P) + DABS(Q) + DABS(R)                                EIS4
+         P = P / S                                                      EIS4
+         Q = Q / S                                                      EIS4
+         R = R / S                                                      EIS4
+         IF (M .EQ. L) GO TO 150                                        EIS4
+         TST1 = DABS(P)*(DABS(H(M-1,M-1)) + DABS(ZZ) + DABS(H(M+1,M+1)))EIS4
+         TST2 = TST1 + DABS(H(M,M-1))*(DABS(Q) + DABS(R))               EIS4
+         IF (TST2 .EQ. TST1) GO TO 150                                  EIS4
+  140 CONTINUE                                                          EIS4
+C                                                                       EIS4
+  150 MP2 = M + 2                                                       EIS4
+C                                                                       EIS4
+      DO 160 I = MP2, EN                                                EIS4
+         H(I,I-2) = 0.0D0                                               EIS4
+         IF (I .EQ. MP2) GO TO 160                                      EIS4
+         H(I,I-3) = 0.0D0                                               EIS4
+  160 CONTINUE                                                          EIS4
+C     .......... DOUBLE QR STEP INVOLVING ROWS L TO EN AND              EIS4
+C                COLUMNS M TO EN ..........                             EIS4
+      DO 260 K = M, NA                                                  EIS4
+         NOTLAS = K .NE. NA                                             EIS4
+         IF (K .EQ. M) GO TO 170                                        EIS4
+         P = H(K,K-1)                                                   EIS4
+         Q = H(K+1,K-1)                                                 EIS4
+         R = 0.0D0                                                      EIS4
+         IF (NOTLAS) R = H(K+2,K-1)                                     EIS4
+         X = DABS(P) + DABS(Q) + DABS(R)                                EIS4
+         IF (X .EQ. 0.0D0) GO TO 260                                    EIS4
+         P = P / X                                                      EIS4
+         Q = Q / X                                                      EIS4
+         R = R / X                                                      EIS4
+  170    S = DSIGN(DSQRT(P*P+Q*Q+R*R),P)                                EIS4
+         IF (K .EQ. M) GO TO 180                                        EIS4
+         H(K,K-1) = -S * X                                              EIS4
+         GO TO 190                                                      EIS4
+  180    IF (L .NE. M) H(K,K-1) = -H(K,K-1)                             EIS4
+  190    P = P + S                                                      EIS4
+         X = P / S                                                      EIS4
+         Y = Q / S                                                      EIS4
+         ZZ = R / S                                                     EIS4
+         Q = Q / P                                                      EIS4
+         R = R / P                                                      EIS4
+         IF (NOTLAS) GO TO 225                                          EIS4
+C     .......... ROW MODIFICATION ..........                            EIS4
+         DO 200 J = K, N                                                EIS4
+            P = H(K,J) + Q * H(K+1,J)                                   EIS4
+            H(K,J) = H(K,J) - P * X                                     EIS4
+            H(K+1,J) = H(K+1,J) - P * Y                                 EIS4
+  200    CONTINUE                                                       EIS4
+C                                                                       EIS4
+         J = MIN0(EN,K+3)                                               EIS4
+C     .......... COLUMN MODIFICATION ..........                         EIS4
+         DO 210 I = 1, J                                                EIS4
+            P = X * H(I,K) + Y * H(I,K+1)                               EIS4
+            H(I,K) = H(I,K) - P                                         EIS4
+            H(I,K+1) = H(I,K+1) - P * Q                                 EIS4
+  210    CONTINUE                                                       EIS4
+         GO TO 255                                                      EIS4
+  225    CONTINUE                                                       EIS4
+C     .......... ROW MODIFICATION ..........                            EIS4
+         DO 230 J = K, N                                                EIS4
+            P = H(K,J) + Q * H(K+1,J) + R * H(K+2,J)                    EIS4
+            H(K,J) = H(K,J) - P * X                                     EIS4
+            H(K+1,J) = H(K+1,J) - P * Y                                 EIS4
+            H(K+2,J) = H(K+2,J) - P * ZZ                                EIS4
+  230    CONTINUE                                                       EIS4
+C                                                                       EIS4
+         J = MIN0(EN,K+3)                                               EIS4
+C     .......... COLUMN MODIFICATION ..........                         EIS4
+         DO 240 I = 1, J                                                EIS4
+            P = X * H(I,K) + Y * H(I,K+1) + ZZ * H(I,K+2)               EIS4
+            H(I,K) = H(I,K) - P                                         EIS4
+            H(I,K+1) = H(I,K+1) - P * Q                                 EIS4
+            H(I,K+2) = H(I,K+2) - P * R                                 EIS4
+  240    CONTINUE                                                       EIS4
+  255    CONTINUE                                                       EIS4
+C                                                                       EIS4
+  260 CONTINUE                                                          EIS4
+C                                                                       EIS4
+      GO TO 70                                                          EIS4
+C     .......... ONE ROOT FOUND ..........                              EIS4
+  270 WR(EN) = X + T                                                    EIS4
+      WI(EN) = 0.0D0                                                    EIS4
+      EN = NA                                                           EIS4
+      GO TO 60                                                          EIS4
+C     .......... TWO ROOTS FOUND ..........                             EIS4
+  280 P = (Y - X) / 2.0D0                                               EIS4
+      Q = P * P + W                                                     EIS4
+      ZZ = DSQRT(DABS(Q))                                               EIS4
+      X = X + T                                                         EIS4
+      IF (Q .LT. 0.0D0) GO TO 320                                       EIS4
+C     .......... REAL PAIR ..........                                   EIS4
+      ZZ = P + DSIGN(ZZ,P)                                              EIS4
+      WR(NA) = X + ZZ                                                   EIS4
+      WR(EN) = WR(NA)                                                   EIS4
+      IF (ZZ .NE. 0.0D0) WR(EN) = X - W / ZZ                            EIS4
+      WI(NA) = 0.0D0                                                    EIS4
+      WI(EN) = 0.0D0                                                    EIS4
+      GO TO 330                                                         EIS4
+C     .......... COMPLEX PAIR ..........                                EIS4
+  320 WR(NA) = X + P                                                    EIS4
+      WR(EN) = X + P                                                    EIS4
+      WI(NA) = ZZ                                                       EIS4
+      WI(EN) = -ZZ                                                      EIS4
+  330 EN = ENM2                                                         EIS4
+      GO TO 60                                                          EIS4
+C     .......... SET ERROR -- ALL EIGENVALUES HAVE NOT                  EIS4
+C                CONVERGED AFTER 30*N ITERATIONS ..........             EIS4
+ 1000 IERR = EN                                                         EIS4
+ 1001 RETURN                                                            EIS4
+      END                                                               EIS4

Deleted: grass-addons/misc/m.eigensystem/hqr2.f
===================================================================
--- grass-addons/m.eigensystem/hqr2.f	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/hqr2.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,449 +0,0 @@
-      SUBROUTINE HQR2(NM,N,LOW,IGH,H,WR,WI,Z,IERR)                      EIS4
-C                                                                       EIS4
-      INTEGER I,J,K,L,M,N,EN,II,JJ,LL,MM,NA,NM,NN,                      EIS4
-     X        IGH,ITN,ITS,LOW,MP2,ENM2,IERR                             EIS4
-      DOUBLE PRECISION H(NM,N),WR(N),WI(N),Z(NM,N)                      EIS4
-      DOUBLE PRECISION P,Q,R,S,T,W,X,Y,RA,SA,VI,VR,ZZ,NORM,TST1,TST2    EIS4
-      LOGICAL NOTLAS                                                    EIS4
-C                                                                       EIS4
-C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE HQR2,     EIS4
-C     NUM. MATH. 16, 181-204(1970) BY PETERS AND WILKINSON.             EIS4
-C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 372-395(1971).   EIS4
-C                                                                       EIS4
-C     THIS SUBROUTINE FINDS THE EIGENVALUES AND EIGENVECTORS            EIS4
-C     OF A REAL UPPER HESSENBERG MATRIX BY THE QR METHOD.  THE          EIS4
-C     EIGENVECTORS OF A REAL GENERAL MATRIX CAN ALSO BE FOUND           EIS4
-C     IF  ELMHES  AND  ELTRAN  OR  ORTHES  AND  ORTRAN  HAVE            EIS4
-C     BEEN USED TO REDUCE THIS GENERAL MATRIX TO HESSENBERG FORM        EIS4
-C     AND TO ACCUMULATE THE SIMILARITY TRANSFORMATIONS.                 EIS4
-C                                                                       EIS4
-C     ON INPUT                                                          EIS4
-C                                                                       EIS4
-C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS4
-C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS4
-C          DIMENSION STATEMENT.                                         EIS4
-C                                                                       EIS4
-C        N IS THE ORDER OF THE MATRIX.                                  EIS4
-C                                                                       EIS4
-C        LOW AND IGH ARE INTEGERS DETERMINED BY THE BALANCING           EIS4
-C          SUBROUTINE  BALANC.  IF  BALANC  HAS NOT BEEN USED,          EIS4
-C          SET LOW=1, IGH=N.                                            EIS4
-C                                                                       EIS4
-C        H CONTAINS THE UPPER HESSENBERG MATRIX.                        EIS4
-C                                                                       EIS4
-C        Z CONTAINS THE TRANSFORMATION MATRIX PRODUCED BY  ELTRAN       EIS4
-C          AFTER THE REDUCTION BY  ELMHES, OR BY  ORTRAN  AFTER THE     EIS4
-C          REDUCTION BY  ORTHES, IF PERFORMED.  IF THE EIGENVECTORS     EIS4
-C          OF THE HESSENBERG MATRIX ARE DESIRED, Z MUST CONTAIN THE     EIS4
-C          IDENTITY MATRIX.                                             EIS4
-C                                                                       EIS4
-C     ON OUTPUT                                                         EIS4
-C                                                                       EIS4
-C        H HAS BEEN DESTROYED.                                          EIS4
-C                                                                       EIS4
-C        WR AND WI CONTAIN THE REAL AND IMAGINARY PARTS,                EIS4
-C          RESPECTIVELY, OF THE EIGENVALUES.  THE EIGENVALUES           EIS4
-C          ARE UNORDERED EXCEPT THAT COMPLEX CONJUGATE PAIRS            EIS4
-C          OF VALUES APPEAR CONSECUTIVELY WITH THE EIGENVALUE           EIS4
-C          HAVING THE POSITIVE IMAGINARY PART FIRST.  IF AN             EIS4
-C          ERROR EXIT IS MADE, THE EIGENVALUES SHOULD BE CORRECT        EIS4
-C          FOR INDICES IERR+1,...,N.                                    EIS4
-C                                                                       EIS4
-C        Z CONTAINS THE REAL AND IMAGINARY PARTS OF THE EIGENVECTORS.   EIS4
-C          IF THE I-TH EIGENVALUE IS REAL, THE I-TH COLUMN OF Z         EIS4
-C          CONTAINS ITS EIGENVECTOR.  IF THE I-TH EIGENVALUE IS COMPLEX EIS4
-C          WITH POSITIVE IMAGINARY PART, THE I-TH AND (I+1)-TH          EIS4
-C          COLUMNS OF Z CONTAIN THE REAL AND IMAGINARY PARTS OF ITS     EIS4
-C          EIGENVECTOR.  THE EIGENVECTORS ARE UNNORMALIZED.  IF AN      EIS4
-C          ERROR EXIT IS MADE, NONE OF THE EIGENVECTORS HAS BEEN FOUND. EIS4
-C                                                                       EIS4
-C        IERR IS SET TO                                                 EIS4
-C          ZERO       FOR NORMAL RETURN,                                EIS4
-C          J          IF THE LIMIT OF 30*N ITERATIONS IS EXHAUSTED      EIS4
-C                     WHILE THE J-TH EIGENVALUE IS BEING SOUGHT.        EIS4
-C                                                                       EIS4
-C     CALLS CDIV FOR COMPLEX DIVISION.                                  EIS4
-C                                                                       EIS4
-C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS4
-C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS4
-C                                                                       EIS4
-C     THIS VERSION DATED AUGUST 1983.                                   EIS4
-C                                                                       EIS4
-C     ------------------------------------------------------------------EIS4
-C                                                                       EIS4
-      IERR = 0                                                          EIS4
-      NORM = 0.0D0                                                      EIS4
-      K = 1                                                             EIS4
-C     .......... STORE ROOTS ISOLATED BY BALANC                         EIS4
-C                AND COMPUTE MATRIX NORM ..........                     EIS4
-      DO 50 I = 1, N                                                    EIS4
-C                                                                       EIS4
-         DO 40 J = K, N                                                 EIS4
-   40    NORM = NORM + DABS(H(I,J))                                     EIS4
-C                                                                       EIS4
-         K = I                                                          EIS4
-         IF (I .GE. LOW .AND. I .LE. IGH) GO TO 50                      EIS4
-         WR(I) = H(I,I)                                                 EIS4
-         WI(I) = 0.0D0                                                  EIS4
-   50 CONTINUE                                                          EIS4
-C                                                                       EIS4
-      EN = IGH                                                          EIS4
-      T = 0.0D0                                                         EIS4
-      ITN = 30*N                                                        EIS4
-C     .......... SEARCH FOR NEXT EIGENVALUES ..........                 EIS4
-   60 IF (EN .LT. LOW) GO TO 340                                        EIS4
-      ITS = 0                                                           EIS4
-      NA = EN - 1                                                       EIS4
-      ENM2 = NA - 1                                                     EIS4
-C     .......... LOOK FOR SINGLE SMALL SUB-DIAGONAL ELEMENT             EIS4
-C                FOR L=EN STEP -1 UNTIL LOW DO -- ..........            EIS4
-   70 DO 80 LL = LOW, EN                                                EIS4
-         L = EN + LOW - LL                                              EIS4
-         IF (L .EQ. LOW) GO TO 100                                      EIS4
-         S = DABS(H(L-1,L-1)) + DABS(H(L,L))                            EIS4
-         IF (S .EQ. 0.0D0) S = NORM                                     EIS4
-         TST1 = S                                                       EIS4
-         TST2 = TST1 + DABS(H(L,L-1))                                   EIS4
-         IF (TST2 .EQ. TST1) GO TO 100                                  EIS4
-   80 CONTINUE                                                          EIS4
-C     .......... FORM SHIFT ..........                                  EIS4
-  100 X = H(EN,EN)                                                      EIS4
-      IF (L .EQ. EN) GO TO 270                                          EIS4
-      Y = H(NA,NA)                                                      EIS4
-      W = H(EN,NA) * H(NA,EN)                                           EIS4
-      IF (L .EQ. NA) GO TO 280                                          EIS4
-      IF (ITN .EQ. 0) GO TO 1000                                        EIS4
-      IF (ITS .NE. 10 .AND. ITS .NE. 20) GO TO 130                      EIS4
-C     .......... FORM EXCEPTIONAL SHIFT ..........                      EIS4
-      T = T + X                                                         EIS4
-C                                                                       EIS4
-      DO 120 I = LOW, EN                                                EIS4
-  120 H(I,I) = H(I,I) - X                                               EIS4
-C                                                                       EIS4
-      S = DABS(H(EN,NA)) + DABS(H(NA,ENM2))                             EIS4
-      X = 0.75D0 * S                                                    EIS4
-      Y = X                                                             EIS4
-      W = -0.4375D0 * S * S                                             EIS4
-  130 ITS = ITS + 1                                                     EIS4
-      ITN = ITN - 1                                                     EIS4
-C     .......... LOOK FOR TWO CONSECUTIVE SMALL                         EIS4
-C                SUB-DIAGONAL ELEMENTS.                                 EIS4
-C                FOR M=EN-2 STEP -1 UNTIL L DO -- ..........            EIS4
-      DO 140 MM = L, ENM2                                               EIS4
-         M = ENM2 + L - MM                                              EIS4
-         ZZ = H(M,M)                                                    EIS4
-         R = X - ZZ                                                     EIS4
-         S = Y - ZZ                                                     EIS4
-         P = (R * S - W) / H(M+1,M) + H(M,M+1)                          EIS4
-         Q = H(M+1,M+1) - ZZ - R - S                                    EIS4
-         R = H(M+2,M+1)                                                 EIS4
-         S = DABS(P) + DABS(Q) + DABS(R)                                EIS4
-         P = P / S                                                      EIS4
-         Q = Q / S                                                      EIS4
-         R = R / S                                                      EIS4
-         IF (M .EQ. L) GO TO 150                                        EIS4
-         TST1 = DABS(P)*(DABS(H(M-1,M-1)) + DABS(ZZ) + DABS(H(M+1,M+1)))EIS4
-         TST2 = TST1 + DABS(H(M,M-1))*(DABS(Q) + DABS(R))               EIS4
-         IF (TST2 .EQ. TST1) GO TO 150                                  EIS4
-  140 CONTINUE                                                          EIS4
-C                                                                       EIS4
-  150 MP2 = M + 2                                                       EIS4
-C                                                                       EIS4
-      DO 160 I = MP2, EN                                                EIS4
-         H(I,I-2) = 0.0D0                                               EIS4
-         IF (I .EQ. MP2) GO TO 160                                      EIS4
-         H(I,I-3) = 0.0D0                                               EIS4
-  160 CONTINUE                                                          EIS4
-C     .......... DOUBLE QR STEP INVOLVING ROWS L TO EN AND              EIS4
-C                COLUMNS M TO EN ..........                             EIS4
-      DO 260 K = M, NA                                                  EIS4
-         NOTLAS = K .NE. NA                                             EIS4
-         IF (K .EQ. M) GO TO 170                                        EIS4
-         P = H(K,K-1)                                                   EIS4
-         Q = H(K+1,K-1)                                                 EIS4
-         R = 0.0D0                                                      EIS4
-         IF (NOTLAS) R = H(K+2,K-1)                                     EIS4
-         X = DABS(P) + DABS(Q) + DABS(R)                                EIS4
-         IF (X .EQ. 0.0D0) GO TO 260                                    EIS4
-         P = P / X                                                      EIS4
-         Q = Q / X                                                      EIS4
-         R = R / X                                                      EIS4
-  170    S = DSIGN(DSQRT(P*P+Q*Q+R*R),P)                                EIS4
-         IF (K .EQ. M) GO TO 180                                        EIS4
-         H(K,K-1) = -S * X                                              EIS4
-         GO TO 190                                                      EIS4
-  180    IF (L .NE. M) H(K,K-1) = -H(K,K-1)                             EIS4
-  190    P = P + S                                                      EIS4
-         X = P / S                                                      EIS4
-         Y = Q / S                                                      EIS4
-         ZZ = R / S                                                     EIS4
-         Q = Q / P                                                      EIS4
-         R = R / P                                                      EIS4
-         IF (NOTLAS) GO TO 225                                          EIS4
-C     .......... ROW MODIFICATION ..........                            EIS4
-         DO 200 J = K, N                                                EIS4
-            P = H(K,J) + Q * H(K+1,J)                                   EIS4
-            H(K,J) = H(K,J) - P * X                                     EIS4
-            H(K+1,J) = H(K+1,J) - P * Y                                 EIS4
-  200    CONTINUE                                                       EIS4
-C                                                                       EIS4
-         J = MIN0(EN,K+3)                                               EIS4
-C     .......... COLUMN MODIFICATION ..........                         EIS4
-         DO 210 I = 1, J                                                EIS4
-            P = X * H(I,K) + Y * H(I,K+1)                               EIS4
-            H(I,K) = H(I,K) - P                                         EIS4
-            H(I,K+1) = H(I,K+1) - P * Q                                 EIS4
-  210    CONTINUE                                                       EIS4
-C     .......... ACCUMULATE TRANSFORMATIONS ..........                  EIS4
-         DO 220 I = LOW, IGH                                            EIS4
-            P = X * Z(I,K) + Y * Z(I,K+1)                               EIS4
-            Z(I,K) = Z(I,K) - P                                         EIS4
-            Z(I,K+1) = Z(I,K+1) - P * Q                                 EIS4
-  220    CONTINUE                                                       EIS4
-         GO TO 255                                                      EIS4
-  225    CONTINUE                                                       EIS4
-C     .......... ROW MODIFICATION ..........                            EIS4
-         DO 230 J = K, N                                                EIS4
-            P = H(K,J) + Q * H(K+1,J) + R * H(K+2,J)                    EIS4
-            H(K,J) = H(K,J) - P * X                                     EIS4
-            H(K+1,J) = H(K+1,J) - P * Y                                 EIS4
-            H(K+2,J) = H(K+2,J) - P * ZZ                                EIS4
-  230    CONTINUE                                                       EIS4
-C                                                                       EIS4
-         J = MIN0(EN,K+3)                                               EIS4
-C     .......... COLUMN MODIFICATION ..........                         EIS4
-         DO 240 I = 1, J                                                EIS4
-            P = X * H(I,K) + Y * H(I,K+1) + ZZ * H(I,K+2)               EIS4
-            H(I,K) = H(I,K) - P                                         EIS4
-            H(I,K+1) = H(I,K+1) - P * Q                                 EIS4
-            H(I,K+2) = H(I,K+2) - P * R                                 EIS4
-  240    CONTINUE                                                       EIS4
-C     .......... ACCUMULATE TRANSFORMATIONS ..........                  EIS4
-         DO 250 I = LOW, IGH                                            EIS4
-            P = X * Z(I,K) + Y * Z(I,K+1) + ZZ * Z(I,K+2)               EIS4
-            Z(I,K) = Z(I,K) - P                                         EIS4
-            Z(I,K+1) = Z(I,K+1) - P * Q                                 EIS4
-            Z(I,K+2) = Z(I,K+2) - P * R                                 EIS4
-  250    CONTINUE                                                       EIS4
-  255    CONTINUE                                                       EIS4
-C                                                                       EIS4
-  260 CONTINUE                                                          EIS4
-C                                                                       EIS4
-      GO TO 70                                                          EIS4
-C     .......... ONE ROOT FOUND ..........                              EIS4
-  270 H(EN,EN) = X + T                                                  EIS4
-      WR(EN) = H(EN,EN)                                                 EIS4
-      WI(EN) = 0.0D0                                                    EIS4
-      EN = NA                                                           EIS4
-      GO TO 60                                                          EIS4
-C     .......... TWO ROOTS FOUND ..........                             EIS4
-  280 P = (Y - X) / 2.0D0                                               EIS4
-      Q = P * P + W                                                     EIS4
-      ZZ = DSQRT(DABS(Q))                                               EIS4
-      H(EN,EN) = X + T                                                  EIS4
-      X = H(EN,EN)                                                      EIS4
-      H(NA,NA) = Y + T                                                  EIS4
-      IF (Q .LT. 0.0D0) GO TO 320                                       EIS4
-C     .......... REAL PAIR ..........                                   EIS4
-      ZZ = P + DSIGN(ZZ,P)                                              EIS4
-      WR(NA) = X + ZZ                                                   EIS4
-      WR(EN) = WR(NA)                                                   EIS4
-      IF (ZZ .NE. 0.0D0) WR(EN) = X - W / ZZ                            EIS4
-      WI(NA) = 0.0D0                                                    EIS4
-      WI(EN) = 0.0D0                                                    EIS4
-      X = H(EN,NA)                                                      EIS4
-      S = DABS(X) + DABS(ZZ)                                            EIS4
-      P = X / S                                                         EIS4
-      Q = ZZ / S                                                        EIS4
-      R = DSQRT(P*P+Q*Q)                                                EIS4
-      P = P / R                                                         EIS4
-      Q = Q / R                                                         EIS4
-C     .......... ROW MODIFICATION ..........                            EIS4
-      DO 290 J = NA, N                                                  EIS4
-         ZZ = H(NA,J)                                                   EIS4
-         H(NA,J) = Q * ZZ + P * H(EN,J)                                 EIS4
-         H(EN,J) = Q * H(EN,J) - P * ZZ                                 EIS4
-  290 CONTINUE                                                          EIS4
-C     .......... COLUMN MODIFICATION ..........                         EIS4
-      DO 300 I = 1, EN                                                  EIS4
-         ZZ = H(I,NA)                                                   EIS4
-         H(I,NA) = Q * ZZ + P * H(I,EN)                                 EIS4
-         H(I,EN) = Q * H(I,EN) - P * ZZ                                 EIS4
-  300 CONTINUE                                                          EIS4
-C     .......... ACCUMULATE TRANSFORMATIONS ..........                  EIS4
-      DO 310 I = LOW, IGH                                               EIS4
-         ZZ = Z(I,NA)                                                   EIS4
-         Z(I,NA) = Q * ZZ + P * Z(I,EN)                                 EIS4
-         Z(I,EN) = Q * Z(I,EN) - P * ZZ                                 EIS4
-  310 CONTINUE                                                          EIS4
-C                                                                       EIS4
-      GO TO 330                                                         EIS4
-C     .......... COMPLEX PAIR ..........                                EIS4
-  320 WR(NA) = X + P                                                    EIS4
-      WR(EN) = X + P                                                    EIS4
-      WI(NA) = ZZ                                                       EIS4
-      WI(EN) = -ZZ                                                      EIS4
-  330 EN = ENM2                                                         EIS4
-      GO TO 60                                                          EIS4
-C     .......... ALL ROOTS FOUND.  BACKSUBSTITUTE TO FIND               EIS4
-C                VECTORS OF UPPER TRIANGULAR FORM ..........            EIS4
-  340 IF (NORM .EQ. 0.0D0) GO TO 1001                                   EIS4
-C     .......... FOR EN=N STEP -1 UNTIL 1 DO -- ..........              EIS4
-      DO 800 NN = 1, N                                                  EIS4
-         EN = N + 1 - NN                                                EIS4
-         P = WR(EN)                                                     EIS4
-         Q = WI(EN)                                                     EIS4
-         NA = EN - 1                                                    EIS4
-         IF (Q) 710, 600, 800                                           EIS4
-C     .......... REAL VECTOR ..........                                 EIS4
-  600    M = EN                                                         EIS4
-         H(EN,EN) = 1.0D0                                               EIS4
-         IF (NA .EQ. 0) GO TO 800                                       EIS4
-C     .......... FOR I=EN-1 STEP -1 UNTIL 1 DO -- ..........            EIS4
-         DO 700 II = 1, NA                                              EIS4
-            I = EN - II                                                 EIS4
-            W = H(I,I) - P                                              EIS4
-            R = 0.0D0                                                   EIS4
-C                                                                       EIS4
-            DO 610 J = M, EN                                            EIS4
-  610       R = R + H(I,J) * H(J,EN)                                    EIS4
-C                                                                       EIS4
-            IF (WI(I) .GE. 0.0D0) GO TO 630                             EIS4
-            ZZ = W                                                      EIS4
-            S = R                                                       EIS4
-            GO TO 700                                                   EIS4
-  630       M = I                                                       EIS4
-            IF (WI(I) .NE. 0.0D0) GO TO 640                             EIS4
-            T = W                                                       EIS4
-            IF (T .NE. 0.0D0) GO TO 635                                 EIS4
-               TST1 = NORM                                              EIS4
-               T = TST1                                                 EIS4
-  632          T = 0.01D0 * T                                           EIS4
-               TST2 = NORM + T                                          EIS4
-               IF (TST2 .GT. TST1) GO TO 632                            EIS4
-  635       H(I,EN) = -R / T                                            EIS4
-            GO TO 680                                                   EIS4
-C     .......... SOLVE REAL EQUATIONS ..........                        EIS4
-  640       X = H(I,I+1)                                                EIS4
-            Y = H(I+1,I)                                                EIS4
-            Q = (WR(I) - P) * (WR(I) - P) + WI(I) * WI(I)               EIS4
-            T = (X * S - ZZ * R) / Q                                    EIS4
-            H(I,EN) = T                                                 EIS4
-            IF (DABS(X) .LE. DABS(ZZ)) GO TO 650                        EIS4
-            H(I+1,EN) = (-R - W * T) / X                                EIS4
-            GO TO 680                                                   EIS4
-  650       H(I+1,EN) = (-S - Y * T) / ZZ                               EIS4
-C                                                                       EIS4
-C     .......... OVERFLOW CONTROL ..........                            EIS4
-  680       T = DABS(H(I,EN))                                           EIS4
-            IF (T .EQ. 0.0D0) GO TO 700                                 EIS4
-            TST1 = T                                                    EIS4
-            TST2 = TST1 + 1.0D0/TST1                                    EIS4
-            IF (TST2 .GT. TST1) GO TO 700                               EIS4
-            DO 690 J = I, EN                                            EIS4
-               H(J,EN) = H(J,EN)/T                                      EIS4
-  690       CONTINUE                                                    EIS4
-C                                                                       EIS4
-  700    CONTINUE                                                       EIS4
-C     .......... END REAL VECTOR ..........                             EIS4
-         GO TO 800                                                      EIS4
-C     .......... COMPLEX VECTOR ..........                              EIS4
-  710    M = NA                                                         EIS4
-C     .......... LAST VECTOR COMPONENT CHOSEN IMAGINARY SO THAT         EIS4
-C                EIGENVECTOR MATRIX IS TRIANGULAR ..........            EIS4
-         IF (DABS(H(EN,NA)) .LE. DABS(H(NA,EN))) GO TO 720              EIS4
-         H(NA,NA) = Q / H(EN,NA)                                        EIS4
-         H(NA,EN) = -(H(EN,EN) - P) / H(EN,NA)                          EIS4
-         GO TO 730                                                      EIS4
-  720    CALL CDIV(0.0D0,-H(NA,EN),H(NA,NA)-P,Q,H(NA,NA),H(NA,EN))      EIS4
-  730    H(EN,NA) = 0.0D0                                               EIS4
-         H(EN,EN) = 1.0D0                                               EIS4
-         ENM2 = NA - 1                                                  EIS4
-         IF (ENM2 .EQ. 0) GO TO 800                                     EIS4
-C     .......... FOR I=EN-2 STEP -1 UNTIL 1 DO -- ..........            EIS4
-         DO 795 II = 1, ENM2                                            EIS4
-            I = NA - II                                                 EIS4
-            W = H(I,I) - P                                              EIS4
-            RA = 0.0D0                                                  EIS4
-            SA = 0.0D0                                                  EIS4
-C                                                                       EIS4
-            DO 760 J = M, EN                                            EIS4
-               RA = RA + H(I,J) * H(J,NA)                               EIS4
-               SA = SA + H(I,J) * H(J,EN)                               EIS4
-  760       CONTINUE                                                    EIS4
-C                                                                       EIS4
-            IF (WI(I) .GE. 0.0D0) GO TO 770                             EIS4
-            ZZ = W                                                      EIS4
-            R = RA                                                      EIS4
-            S = SA                                                      EIS4
-            GO TO 795                                                   EIS4
-  770       M = I                                                       EIS4
-            IF (WI(I) .NE. 0.0D0) GO TO 780                             EIS4
-            CALL CDIV(-RA,-SA,W,Q,H(I,NA),H(I,EN))                      EIS4
-            GO TO 790                                                   EIS4
-C     .......... SOLVE COMPLEX EQUATIONS ..........                     EIS4
-  780       X = H(I,I+1)                                                EIS4
-            Y = H(I+1,I)                                                EIS4
-            VR = (WR(I) - P) * (WR(I) - P) + WI(I) * WI(I) - Q * Q      EIS4
-            VI = (WR(I) - P) * 2.0D0 * Q                                EIS4
-            IF (VR .NE. 0.0D0 .OR. VI .NE. 0.0D0) GO TO 784             EIS4
-               TST1 = NORM * (DABS(W) + DABS(Q) + DABS(X)               EIS4
-     X                      + DABS(Y) + DABS(ZZ))                       EIS4
-               VR = TST1                                                EIS4
-  783          VR = 0.01D0 * VR                                         EIS4
-               TST2 = TST1 + VR                                         EIS4
-               IF (TST2 .GT. TST1) GO TO 783                            EIS4
-  784       CALL CDIV(X*R-ZZ*RA+Q*SA,X*S-ZZ*SA-Q*RA,VR,VI,              EIS4
-     X                H(I,NA),H(I,EN))                                  EIS4
-            IF (DABS(X) .LE. DABS(ZZ) + DABS(Q)) GO TO 785              EIS4
-            H(I+1,NA) = (-RA - W * H(I,NA) + Q * H(I,EN)) / X           EIS4
-            H(I+1,EN) = (-SA - W * H(I,EN) - Q * H(I,NA)) / X           EIS4
-            GO TO 790                                                   EIS4
-  785       CALL CDIV(-R-Y*H(I,NA),-S-Y*H(I,EN),ZZ,Q,                   EIS4
-     X                H(I+1,NA),H(I+1,EN))                              EIS4
-C                                                                       EIS4
-C     .......... OVERFLOW CONTROL ..........                            EIS4
-  790       T = DMAX1(DABS(H(I,NA)), DABS(H(I,EN)))                     EIS4
-            IF (T .EQ. 0.0D0) GO TO 795                                 EIS4
-            TST1 = T                                                    EIS4
-            TST2 = TST1 + 1.0D0/TST1                                    EIS4
-            IF (TST2 .GT. TST1) GO TO 795                               EIS4
-            DO 792 J = I, EN                                            EIS4
-               H(J,NA) = H(J,NA)/T                                      EIS4
-               H(J,EN) = H(J,EN)/T                                      EIS4
-  792       CONTINUE                                                    EIS4
-C                                                                       EIS4
-  795    CONTINUE                                                       EIS4
-C     .......... END COMPLEX VECTOR ..........                          EIS4
-  800 CONTINUE                                                          EIS4
-C     .......... END BACK SUBSTITUTION.                                 EIS4
-C                VECTORS OF ISOLATED ROOTS ..........                   EIS4
-      DO 840 I = 1, N                                                   EIS4
-         IF (I .GE. LOW .AND. I .LE. IGH) GO TO 840                     EIS4
-C                                                                       EIS4
-         DO 820 J = I, N                                                EIS4
-  820    Z(I,J) = H(I,J)                                                EIS4
-C                                                                       EIS4
-  840 CONTINUE                                                          EIS4
-C     .......... MULTIPLY BY TRANSFORMATION MATRIX TO GIVE              EIS4
-C                VECTORS OF ORIGINAL FULL MATRIX.                       EIS4
-C                FOR J=N STEP -1 UNTIL LOW DO -- ..........             EIS4
-      DO 880 JJ = LOW, N                                                EIS4
-         J = N + LOW - JJ                                               EIS4
-         M = MIN0(J,IGH)                                                EIS4
-C                                                                       EIS4
-         DO 880 I = LOW, IGH                                            EIS4
-            ZZ = 0.0D0                                                  EIS4
-C                                                                       EIS4
-            DO 860 K = LOW, M                                           EIS4
-  860       ZZ = ZZ + Z(I,K) * H(K,J)                                   EIS4
-C                                                                       EIS4
-            Z(I,J) = ZZ                                                 EIS4
-  880 CONTINUE                                                          EIS4
-C                                                                       EIS4
-      GO TO 1001                                                        EIS4
-C     .......... SET ERROR -- ALL EIGENVALUES HAVE NOT                  EIS4
-C                CONVERGED AFTER 30*N ITERATIONS ..........             EIS4
- 1000 IERR = EN                                                         EIS4
- 1001 RETURN                                                            EIS4
-      END                                                               EIS4

Copied: grass-addons/misc/m.eigensystem/hqr2.f (from rev 30335, grass-addons/m.eigensystem/hqr2.f)
===================================================================
--- grass-addons/misc/m.eigensystem/hqr2.f	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/hqr2.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,449 @@
+      SUBROUTINE HQR2(NM,N,LOW,IGH,H,WR,WI,Z,IERR)                      EIS4
+C                                                                       EIS4
+      INTEGER I,J,K,L,M,N,EN,II,JJ,LL,MM,NA,NM,NN,                      EIS4
+     X        IGH,ITN,ITS,LOW,MP2,ENM2,IERR                             EIS4
+      DOUBLE PRECISION H(NM,N),WR(N),WI(N),Z(NM,N)                      EIS4
+      DOUBLE PRECISION P,Q,R,S,T,W,X,Y,RA,SA,VI,VR,ZZ,NORM,TST1,TST2    EIS4
+      LOGICAL NOTLAS                                                    EIS4
+C                                                                       EIS4
+C     THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE HQR2,     EIS4
+C     NUM. MATH. 16, 181-204(1970) BY PETERS AND WILKINSON.             EIS4
+C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 372-395(1971).   EIS4
+C                                                                       EIS4
+C     THIS SUBROUTINE FINDS THE EIGENVALUES AND EIGENVECTORS            EIS4
+C     OF A REAL UPPER HESSENBERG MATRIX BY THE QR METHOD.  THE          EIS4
+C     EIGENVECTORS OF A REAL GENERAL MATRIX CAN ALSO BE FOUND           EIS4
+C     IF  ELMHES  AND  ELTRAN  OR  ORTHES  AND  ORTRAN  HAVE            EIS4
+C     BEEN USED TO REDUCE THIS GENERAL MATRIX TO HESSENBERG FORM        EIS4
+C     AND TO ACCUMULATE THE SIMILARITY TRANSFORMATIONS.                 EIS4
+C                                                                       EIS4
+C     ON INPUT                                                          EIS4
+C                                                                       EIS4
+C        NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL         EIS4
+C          ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM          EIS4
+C          DIMENSION STATEMENT.                                         EIS4
+C                                                                       EIS4
+C        N IS THE ORDER OF THE MATRIX.                                  EIS4
+C                                                                       EIS4
+C        LOW AND IGH ARE INTEGERS DETERMINED BY THE BALANCING           EIS4
+C          SUBROUTINE  BALANC.  IF  BALANC  HAS NOT BEEN USED,          EIS4
+C          SET LOW=1, IGH=N.                                            EIS4
+C                                                                       EIS4
+C        H CONTAINS THE UPPER HESSENBERG MATRIX.                        EIS4
+C                                                                       EIS4
+C        Z CONTAINS THE TRANSFORMATION MATRIX PRODUCED BY  ELTRAN       EIS4
+C          AFTER THE REDUCTION BY  ELMHES, OR BY  ORTRAN  AFTER THE     EIS4
+C          REDUCTION BY  ORTHES, IF PERFORMED.  IF THE EIGENVECTORS     EIS4
+C          OF THE HESSENBERG MATRIX ARE DESIRED, Z MUST CONTAIN THE     EIS4
+C          IDENTITY MATRIX.                                             EIS4
+C                                                                       EIS4
+C     ON OUTPUT                                                         EIS4
+C                                                                       EIS4
+C        H HAS BEEN DESTROYED.                                          EIS4
+C                                                                       EIS4
+C        WR AND WI CONTAIN THE REAL AND IMAGINARY PARTS,                EIS4
+C          RESPECTIVELY, OF THE EIGENVALUES.  THE EIGENVALUES           EIS4
+C          ARE UNORDERED EXCEPT THAT COMPLEX CONJUGATE PAIRS            EIS4
+C          OF VALUES APPEAR CONSECUTIVELY WITH THE EIGENVALUE           EIS4
+C          HAVING THE POSITIVE IMAGINARY PART FIRST.  IF AN             EIS4
+C          ERROR EXIT IS MADE, THE EIGENVALUES SHOULD BE CORRECT        EIS4
+C          FOR INDICES IERR+1,...,N.                                    EIS4
+C                                                                       EIS4
+C        Z CONTAINS THE REAL AND IMAGINARY PARTS OF THE EIGENVECTORS.   EIS4
+C          IF THE I-TH EIGENVALUE IS REAL, THE I-TH COLUMN OF Z         EIS4
+C          CONTAINS ITS EIGENVECTOR.  IF THE I-TH EIGENVALUE IS COMPLEX EIS4
+C          WITH POSITIVE IMAGINARY PART, THE I-TH AND (I+1)-TH          EIS4
+C          COLUMNS OF Z CONTAIN THE REAL AND IMAGINARY PARTS OF ITS     EIS4
+C          EIGENVECTOR.  THE EIGENVECTORS ARE UNNORMALIZED.  IF AN      EIS4
+C          ERROR EXIT IS MADE, NONE OF THE EIGENVECTORS HAS BEEN FOUND. EIS4
+C                                                                       EIS4
+C        IERR IS SET TO                                                 EIS4
+C          ZERO       FOR NORMAL RETURN,                                EIS4
+C          J          IF THE LIMIT OF 30*N ITERATIONS IS EXHAUSTED      EIS4
+C                     WHILE THE J-TH EIGENVALUE IS BEING SOUGHT.        EIS4
+C                                                                       EIS4
+C     CALLS CDIV FOR COMPLEX DIVISION.                                  EIS4
+C                                                                       EIS4
+C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS4
+C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS4
+C                                                                       EIS4
+C     THIS VERSION DATED AUGUST 1983.                                   EIS4
+C                                                                       EIS4
+C     ------------------------------------------------------------------EIS4
+C                                                                       EIS4
+      IERR = 0                                                          EIS4
+      NORM = 0.0D0                                                      EIS4
+      K = 1                                                             EIS4
+C     .......... STORE ROOTS ISOLATED BY BALANC                         EIS4
+C                AND COMPUTE MATRIX NORM ..........                     EIS4
+      DO 50 I = 1, N                                                    EIS4
+C                                                                       EIS4
+         DO 40 J = K, N                                                 EIS4
+   40    NORM = NORM + DABS(H(I,J))                                     EIS4
+C                                                                       EIS4
+         K = I                                                          EIS4
+         IF (I .GE. LOW .AND. I .LE. IGH) GO TO 50                      EIS4
+         WR(I) = H(I,I)                                                 EIS4
+         WI(I) = 0.0D0                                                  EIS4
+   50 CONTINUE                                                          EIS4
+C                                                                       EIS4
+      EN = IGH                                                          EIS4
+      T = 0.0D0                                                         EIS4
+      ITN = 30*N                                                        EIS4
+C     .......... SEARCH FOR NEXT EIGENVALUES ..........                 EIS4
+   60 IF (EN .LT. LOW) GO TO 340                                        EIS4
+      ITS = 0                                                           EIS4
+      NA = EN - 1                                                       EIS4
+      ENM2 = NA - 1                                                     EIS4
+C     .......... LOOK FOR SINGLE SMALL SUB-DIAGONAL ELEMENT             EIS4
+C                FOR L=EN STEP -1 UNTIL LOW DO -- ..........            EIS4
+   70 DO 80 LL = LOW, EN                                                EIS4
+         L = EN + LOW - LL                                              EIS4
+         IF (L .EQ. LOW) GO TO 100                                      EIS4
+         S = DABS(H(L-1,L-1)) + DABS(H(L,L))                            EIS4
+         IF (S .EQ. 0.0D0) S = NORM                                     EIS4
+         TST1 = S                                                       EIS4
+         TST2 = TST1 + DABS(H(L,L-1))                                   EIS4
+         IF (TST2 .EQ. TST1) GO TO 100                                  EIS4
+   80 CONTINUE                                                          EIS4
+C     .......... FORM SHIFT ..........                                  EIS4
+  100 X = H(EN,EN)                                                      EIS4
+      IF (L .EQ. EN) GO TO 270                                          EIS4
+      Y = H(NA,NA)                                                      EIS4
+      W = H(EN,NA) * H(NA,EN)                                           EIS4
+      IF (L .EQ. NA) GO TO 280                                          EIS4
+      IF (ITN .EQ. 0) GO TO 1000                                        EIS4
+      IF (ITS .NE. 10 .AND. ITS .NE. 20) GO TO 130                      EIS4
+C     .......... FORM EXCEPTIONAL SHIFT ..........                      EIS4
+      T = T + X                                                         EIS4
+C                                                                       EIS4
+      DO 120 I = LOW, EN                                                EIS4
+  120 H(I,I) = H(I,I) - X                                               EIS4
+C                                                                       EIS4
+      S = DABS(H(EN,NA)) + DABS(H(NA,ENM2))                             EIS4
+      X = 0.75D0 * S                                                    EIS4
+      Y = X                                                             EIS4
+      W = -0.4375D0 * S * S                                             EIS4
+  130 ITS = ITS + 1                                                     EIS4
+      ITN = ITN - 1                                                     EIS4
+C     .......... LOOK FOR TWO CONSECUTIVE SMALL                         EIS4
+C                SUB-DIAGONAL ELEMENTS.                                 EIS4
+C                FOR M=EN-2 STEP -1 UNTIL L DO -- ..........            EIS4
+      DO 140 MM = L, ENM2                                               EIS4
+         M = ENM2 + L - MM                                              EIS4
+         ZZ = H(M,M)                                                    EIS4
+         R = X - ZZ                                                     EIS4
+         S = Y - ZZ                                                     EIS4
+         P = (R * S - W) / H(M+1,M) + H(M,M+1)                          EIS4
+         Q = H(M+1,M+1) - ZZ - R - S                                    EIS4
+         R = H(M+2,M+1)                                                 EIS4
+         S = DABS(P) + DABS(Q) + DABS(R)                                EIS4
+         P = P / S                                                      EIS4
+         Q = Q / S                                                      EIS4
+         R = R / S                                                      EIS4
+         IF (M .EQ. L) GO TO 150                                        EIS4
+         TST1 = DABS(P)*(DABS(H(M-1,M-1)) + DABS(ZZ) + DABS(H(M+1,M+1)))EIS4
+         TST2 = TST1 + DABS(H(M,M-1))*(DABS(Q) + DABS(R))               EIS4
+         IF (TST2 .EQ. TST1) GO TO 150                                  EIS4
+  140 CONTINUE                                                          EIS4
+C                                                                       EIS4
+  150 MP2 = M + 2                                                       EIS4
+C                                                                       EIS4
+      DO 160 I = MP2, EN                                                EIS4
+         H(I,I-2) = 0.0D0                                               EIS4
+         IF (I .EQ. MP2) GO TO 160                                      EIS4
+         H(I,I-3) = 0.0D0                                               EIS4
+  160 CONTINUE                                                          EIS4
+C     .......... DOUBLE QR STEP INVOLVING ROWS L TO EN AND              EIS4
+C                COLUMNS M TO EN ..........                             EIS4
+      DO 260 K = M, NA                                                  EIS4
+         NOTLAS = K .NE. NA                                             EIS4
+         IF (K .EQ. M) GO TO 170                                        EIS4
+         P = H(K,K-1)                                                   EIS4
+         Q = H(K+1,K-1)                                                 EIS4
+         R = 0.0D0                                                      EIS4
+         IF (NOTLAS) R = H(K+2,K-1)                                     EIS4
+         X = DABS(P) + DABS(Q) + DABS(R)                                EIS4
+         IF (X .EQ. 0.0D0) GO TO 260                                    EIS4
+         P = P / X                                                      EIS4
+         Q = Q / X                                                      EIS4
+         R = R / X                                                      EIS4
+  170    S = DSIGN(DSQRT(P*P+Q*Q+R*R),P)                                EIS4
+         IF (K .EQ. M) GO TO 180                                        EIS4
+         H(K,K-1) = -S * X                                              EIS4
+         GO TO 190                                                      EIS4
+  180    IF (L .NE. M) H(K,K-1) = -H(K,K-1)                             EIS4
+  190    P = P + S                                                      EIS4
+         X = P / S                                                      EIS4
+         Y = Q / S                                                      EIS4
+         ZZ = R / S                                                     EIS4
+         Q = Q / P                                                      EIS4
+         R = R / P                                                      EIS4
+         IF (NOTLAS) GO TO 225                                          EIS4
+C     .......... ROW MODIFICATION ..........                            EIS4
+         DO 200 J = K, N                                                EIS4
+            P = H(K,J) + Q * H(K+1,J)                                   EIS4
+            H(K,J) = H(K,J) - P * X                                     EIS4
+            H(K+1,J) = H(K+1,J) - P * Y                                 EIS4
+  200    CONTINUE                                                       EIS4
+C                                                                       EIS4
+         J = MIN0(EN,K+3)                                               EIS4
+C     .......... COLUMN MODIFICATION ..........                         EIS4
+         DO 210 I = 1, J                                                EIS4
+            P = X * H(I,K) + Y * H(I,K+1)                               EIS4
+            H(I,K) = H(I,K) - P                                         EIS4
+            H(I,K+1) = H(I,K+1) - P * Q                                 EIS4
+  210    CONTINUE                                                       EIS4
+C     .......... ACCUMULATE TRANSFORMATIONS ..........                  EIS4
+         DO 220 I = LOW, IGH                                            EIS4
+            P = X * Z(I,K) + Y * Z(I,K+1)                               EIS4
+            Z(I,K) = Z(I,K) - P                                         EIS4
+            Z(I,K+1) = Z(I,K+1) - P * Q                                 EIS4
+  220    CONTINUE                                                       EIS4
+         GO TO 255                                                      EIS4
+  225    CONTINUE                                                       EIS4
+C     .......... ROW MODIFICATION ..........                            EIS4
+         DO 230 J = K, N                                                EIS4
+            P = H(K,J) + Q * H(K+1,J) + R * H(K+2,J)                    EIS4
+            H(K,J) = H(K,J) - P * X                                     EIS4
+            H(K+1,J) = H(K+1,J) - P * Y                                 EIS4
+            H(K+2,J) = H(K+2,J) - P * ZZ                                EIS4
+  230    CONTINUE                                                       EIS4
+C                                                                       EIS4
+         J = MIN0(EN,K+3)                                               EIS4
+C     .......... COLUMN MODIFICATION ..........                         EIS4
+         DO 240 I = 1, J                                                EIS4
+            P = X * H(I,K) + Y * H(I,K+1) + ZZ * H(I,K+2)               EIS4
+            H(I,K) = H(I,K) - P                                         EIS4
+            H(I,K+1) = H(I,K+1) - P * Q                                 EIS4
+            H(I,K+2) = H(I,K+2) - P * R                                 EIS4
+  240    CONTINUE                                                       EIS4
+C     .......... ACCUMULATE TRANSFORMATIONS ..........                  EIS4
+         DO 250 I = LOW, IGH                                            EIS4
+            P = X * Z(I,K) + Y * Z(I,K+1) + ZZ * Z(I,K+2)               EIS4
+            Z(I,K) = Z(I,K) - P                                         EIS4
+            Z(I,K+1) = Z(I,K+1) - P * Q                                 EIS4
+            Z(I,K+2) = Z(I,K+2) - P * R                                 EIS4
+  250    CONTINUE                                                       EIS4
+  255    CONTINUE                                                       EIS4
+C                                                                       EIS4
+  260 CONTINUE                                                          EIS4
+C                                                                       EIS4
+      GO TO 70                                                          EIS4
+C     .......... ONE ROOT FOUND ..........                              EIS4
+  270 H(EN,EN) = X + T                                                  EIS4
+      WR(EN) = H(EN,EN)                                                 EIS4
+      WI(EN) = 0.0D0                                                    EIS4
+      EN = NA                                                           EIS4
+      GO TO 60                                                          EIS4
+C     .......... TWO ROOTS FOUND ..........                             EIS4
+  280 P = (Y - X) / 2.0D0                                               EIS4
+      Q = P * P + W                                                     EIS4
+      ZZ = DSQRT(DABS(Q))                                               EIS4
+      H(EN,EN) = X + T                                                  EIS4
+      X = H(EN,EN)                                                      EIS4
+      H(NA,NA) = Y + T                                                  EIS4
+      IF (Q .LT. 0.0D0) GO TO 320                                       EIS4
+C     .......... REAL PAIR ..........                                   EIS4
+      ZZ = P + DSIGN(ZZ,P)                                              EIS4
+      WR(NA) = X + ZZ                                                   EIS4
+      WR(EN) = WR(NA)                                                   EIS4
+      IF (ZZ .NE. 0.0D0) WR(EN) = X - W / ZZ                            EIS4
+      WI(NA) = 0.0D0                                                    EIS4
+      WI(EN) = 0.0D0                                                    EIS4
+      X = H(EN,NA)                                                      EIS4
+      S = DABS(X) + DABS(ZZ)                                            EIS4
+      P = X / S                                                         EIS4
+      Q = ZZ / S                                                        EIS4
+      R = DSQRT(P*P+Q*Q)                                                EIS4
+      P = P / R                                                         EIS4
+      Q = Q / R                                                         EIS4
+C     .......... ROW MODIFICATION ..........                            EIS4
+      DO 290 J = NA, N                                                  EIS4
+         ZZ = H(NA,J)                                                   EIS4
+         H(NA,J) = Q * ZZ + P * H(EN,J)                                 EIS4
+         H(EN,J) = Q * H(EN,J) - P * ZZ                                 EIS4
+  290 CONTINUE                                                          EIS4
+C     .......... COLUMN MODIFICATION ..........                         EIS4
+      DO 300 I = 1, EN                                                  EIS4
+         ZZ = H(I,NA)                                                   EIS4
+         H(I,NA) = Q * ZZ + P * H(I,EN)                                 EIS4
+         H(I,EN) = Q * H(I,EN) - P * ZZ                                 EIS4
+  300 CONTINUE                                                          EIS4
+C     .......... ACCUMULATE TRANSFORMATIONS ..........                  EIS4
+      DO 310 I = LOW, IGH                                               EIS4
+         ZZ = Z(I,NA)                                                   EIS4
+         Z(I,NA) = Q * ZZ + P * Z(I,EN)                                 EIS4
+         Z(I,EN) = Q * Z(I,EN) - P * ZZ                                 EIS4
+  310 CONTINUE                                                          EIS4
+C                                                                       EIS4
+      GO TO 330                                                         EIS4
+C     .......... COMPLEX PAIR ..........                                EIS4
+  320 WR(NA) = X + P                                                    EIS4
+      WR(EN) = X + P                                                    EIS4
+      WI(NA) = ZZ                                                       EIS4
+      WI(EN) = -ZZ                                                      EIS4
+  330 EN = ENM2                                                         EIS4
+      GO TO 60                                                          EIS4
+C     .......... ALL ROOTS FOUND.  BACKSUBSTITUTE TO FIND               EIS4
+C                VECTORS OF UPPER TRIANGULAR FORM ..........            EIS4
+  340 IF (NORM .EQ. 0.0D0) GO TO 1001                                   EIS4
+C     .......... FOR EN=N STEP -1 UNTIL 1 DO -- ..........              EIS4
+      DO 800 NN = 1, N                                                  EIS4
+         EN = N + 1 - NN                                                EIS4
+         P = WR(EN)                                                     EIS4
+         Q = WI(EN)                                                     EIS4
+         NA = EN - 1                                                    EIS4
+         IF (Q) 710, 600, 800                                           EIS4
+C     .......... REAL VECTOR ..........                                 EIS4
+  600    M = EN                                                         EIS4
+         H(EN,EN) = 1.0D0                                               EIS4
+         IF (NA .EQ. 0) GO TO 800                                       EIS4
+C     .......... FOR I=EN-1 STEP -1 UNTIL 1 DO -- ..........            EIS4
+         DO 700 II = 1, NA                                              EIS4
+            I = EN - II                                                 EIS4
+            W = H(I,I) - P                                              EIS4
+            R = 0.0D0                                                   EIS4
+C                                                                       EIS4
+            DO 610 J = M, EN                                            EIS4
+  610       R = R + H(I,J) * H(J,EN)                                    EIS4
+C                                                                       EIS4
+            IF (WI(I) .GE. 0.0D0) GO TO 630                             EIS4
+            ZZ = W                                                      EIS4
+            S = R                                                       EIS4
+            GO TO 700                                                   EIS4
+  630       M = I                                                       EIS4
+            IF (WI(I) .NE. 0.0D0) GO TO 640                             EIS4
+            T = W                                                       EIS4
+            IF (T .NE. 0.0D0) GO TO 635                                 EIS4
+               TST1 = NORM                                              EIS4
+               T = TST1                                                 EIS4
+  632          T = 0.01D0 * T                                           EIS4
+               TST2 = NORM + T                                          EIS4
+               IF (TST2 .GT. TST1) GO TO 632                            EIS4
+  635       H(I,EN) = -R / T                                            EIS4
+            GO TO 680                                                   EIS4
+C     .......... SOLVE REAL EQUATIONS ..........                        EIS4
+  640       X = H(I,I+1)                                                EIS4
+            Y = H(I+1,I)                                                EIS4
+            Q = (WR(I) - P) * (WR(I) - P) + WI(I) * WI(I)               EIS4
+            T = (X * S - ZZ * R) / Q                                    EIS4
+            H(I,EN) = T                                                 EIS4
+            IF (DABS(X) .LE. DABS(ZZ)) GO TO 650                        EIS4
+            H(I+1,EN) = (-R - W * T) / X                                EIS4
+            GO TO 680                                                   EIS4
+  650       H(I+1,EN) = (-S - Y * T) / ZZ                               EIS4
+C                                                                       EIS4
+C     .......... OVERFLOW CONTROL ..........                            EIS4
+  680       T = DABS(H(I,EN))                                           EIS4
+            IF (T .EQ. 0.0D0) GO TO 700                                 EIS4
+            TST1 = T                                                    EIS4
+            TST2 = TST1 + 1.0D0/TST1                                    EIS4
+            IF (TST2 .GT. TST1) GO TO 700                               EIS4
+            DO 690 J = I, EN                                            EIS4
+               H(J,EN) = H(J,EN)/T                                      EIS4
+  690       CONTINUE                                                    EIS4
+C                                                                       EIS4
+  700    CONTINUE                                                       EIS4
+C     .......... END REAL VECTOR ..........                             EIS4
+         GO TO 800                                                      EIS4
+C     .......... COMPLEX VECTOR ..........                              EIS4
+  710    M = NA                                                         EIS4
+C     .......... LAST VECTOR COMPONENT CHOSEN IMAGINARY SO THAT         EIS4
+C                EIGENVECTOR MATRIX IS TRIANGULAR ..........            EIS4
+         IF (DABS(H(EN,NA)) .LE. DABS(H(NA,EN))) GO TO 720              EIS4
+         H(NA,NA) = Q / H(EN,NA)                                        EIS4
+         H(NA,EN) = -(H(EN,EN) - P) / H(EN,NA)                          EIS4
+         GO TO 730                                                      EIS4
+  720    CALL CDIV(0.0D0,-H(NA,EN),H(NA,NA)-P,Q,H(NA,NA),H(NA,EN))      EIS4
+  730    H(EN,NA) = 0.0D0                                               EIS4
+         H(EN,EN) = 1.0D0                                               EIS4
+         ENM2 = NA - 1                                                  EIS4
+         IF (ENM2 .EQ. 0) GO TO 800                                     EIS4
+C     .......... FOR I=EN-2 STEP -1 UNTIL 1 DO -- ..........            EIS4
+         DO 795 II = 1, ENM2                                            EIS4
+            I = NA - II                                                 EIS4
+            W = H(I,I) - P                                              EIS4
+            RA = 0.0D0                                                  EIS4
+            SA = 0.0D0                                                  EIS4
+C                                                                       EIS4
+            DO 760 J = M, EN                                            EIS4
+               RA = RA + H(I,J) * H(J,NA)                               EIS4
+               SA = SA + H(I,J) * H(J,EN)                               EIS4
+  760       CONTINUE                                                    EIS4
+C                                                                       EIS4
+            IF (WI(I) .GE. 0.0D0) GO TO 770                             EIS4
+            ZZ = W                                                      EIS4
+            R = RA                                                      EIS4
+            S = SA                                                      EIS4
+            GO TO 795                                                   EIS4
+  770       M = I                                                       EIS4
+            IF (WI(I) .NE. 0.0D0) GO TO 780                             EIS4
+            CALL CDIV(-RA,-SA,W,Q,H(I,NA),H(I,EN))                      EIS4
+            GO TO 790                                                   EIS4
+C     .......... SOLVE COMPLEX EQUATIONS ..........                     EIS4
+  780       X = H(I,I+1)                                                EIS4
+            Y = H(I+1,I)                                                EIS4
+            VR = (WR(I) - P) * (WR(I) - P) + WI(I) * WI(I) - Q * Q      EIS4
+            VI = (WR(I) - P) * 2.0D0 * Q                                EIS4
+            IF (VR .NE. 0.0D0 .OR. VI .NE. 0.0D0) GO TO 784             EIS4
+               TST1 = NORM * (DABS(W) + DABS(Q) + DABS(X)               EIS4
+     X                      + DABS(Y) + DABS(ZZ))                       EIS4
+               VR = TST1                                                EIS4
+  783          VR = 0.01D0 * VR                                         EIS4
+               TST2 = TST1 + VR                                         EIS4
+               IF (TST2 .GT. TST1) GO TO 783                            EIS4
+  784       CALL CDIV(X*R-ZZ*RA+Q*SA,X*S-ZZ*SA-Q*RA,VR,VI,              EIS4
+     X                H(I,NA),H(I,EN))                                  EIS4
+            IF (DABS(X) .LE. DABS(ZZ) + DABS(Q)) GO TO 785              EIS4
+            H(I+1,NA) = (-RA - W * H(I,NA) + Q * H(I,EN)) / X           EIS4
+            H(I+1,EN) = (-SA - W * H(I,EN) - Q * H(I,NA)) / X           EIS4
+            GO TO 790                                                   EIS4
+  785       CALL CDIV(-R-Y*H(I,NA),-S-Y*H(I,EN),ZZ,Q,                   EIS4
+     X                H(I+1,NA),H(I+1,EN))                              EIS4
+C                                                                       EIS4
+C     .......... OVERFLOW CONTROL ..........                            EIS4
+  790       T = DMAX1(DABS(H(I,NA)), DABS(H(I,EN)))                     EIS4
+            IF (T .EQ. 0.0D0) GO TO 795                                 EIS4
+            TST1 = T                                                    EIS4
+            TST2 = TST1 + 1.0D0/TST1                                    EIS4
+            IF (TST2 .GT. TST1) GO TO 795                               EIS4
+            DO 792 J = I, EN                                            EIS4
+               H(J,NA) = H(J,NA)/T                                      EIS4
+               H(J,EN) = H(J,EN)/T                                      EIS4
+  792       CONTINUE                                                    EIS4
+C                                                                       EIS4
+  795    CONTINUE                                                       EIS4
+C     .......... END COMPLEX VECTOR ..........                          EIS4
+  800 CONTINUE                                                          EIS4
+C     .......... END BACK SUBSTITUTION.                                 EIS4
+C                VECTORS OF ISOLATED ROOTS ..........                   EIS4
+      DO 840 I = 1, N                                                   EIS4
+         IF (I .GE. LOW .AND. I .LE. IGH) GO TO 840                     EIS4
+C                                                                       EIS4
+         DO 820 J = I, N                                                EIS4
+  820    Z(I,J) = H(I,J)                                                EIS4
+C                                                                       EIS4
+  840 CONTINUE                                                          EIS4
+C     .......... MULTIPLY BY TRANSFORMATION MATRIX TO GIVE              EIS4
+C                VECTORS OF ORIGINAL FULL MATRIX.                       EIS4
+C                FOR J=N STEP -1 UNTIL LOW DO -- ..........             EIS4
+      DO 880 JJ = LOW, N                                                EIS4
+         J = N + LOW - JJ                                               EIS4
+         M = MIN0(J,IGH)                                                EIS4
+C                                                                       EIS4
+         DO 880 I = LOW, IGH                                            EIS4
+            ZZ = 0.0D0                                                  EIS4
+C                                                                       EIS4
+            DO 860 K = LOW, M                                           EIS4
+  860       ZZ = ZZ + Z(I,K) * H(K,J)                                   EIS4
+C                                                                       EIS4
+            Z(I,J) = ZZ                                                 EIS4
+  880 CONTINUE                                                          EIS4
+C                                                                       EIS4
+      GO TO 1001                                                        EIS4
+C     .......... SET ERROR -- ALL EIGENVALUES HAVE NOT                  EIS4
+C                CONVERGED AFTER 30*N ITERATIONS ..........             EIS4
+ 1000 IERR = EN                                                         EIS4
+ 1001 RETURN                                                            EIS4
+      END                                                               EIS4

Deleted: grass-addons/misc/m.eigensystem/m.eigensystem.html
===================================================================
--- grass-addons/m.eigensystem/m.eigensystem.html	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/m.eigensystem.html	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,180 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<title>GRASS GIS: m.eigensystem</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="grassdocs.css" type="text/css">
-</head>
-<body bgcolor="white">
-
-<img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
-
-<H2>NAME</H2>
-
-<EM><b>m.eigensystem</b></EM>  - Computes eigen values and eigen vectors
-for square matricies.
-
-<BR>
-
-<EM>(GRASS Data Import/Processing Program)</EM>
-
-<H2>SYNOPSIS</H2>
-
-<B>m.eigensystem &lt; </B><EM>inputfile </EM>
-
-<H2>DESCRIPTION</H2>
-
-<EM>m.eigensystem</EM>
-determines the eigen values and eigen vectors for square matricies.
-The
-<EM>inputfile</EM>
-must have the following format:
-the first line contains an integer K
-which is the number of rows and columns in the matrix;
-the remainder of the file is the matrix, i.e.,
-K lines, each containing K real numbers.
-For example:
-<P>
-<PRE>
-          3
-          462.876649   480.411218   281.758307
-          480.411218   513.015646   278.914813
-          281.758307   278.914813   336.326645
-
-</PRE>
-<P>
-
-The output will be K groups of lines;  each group will have the format:
-<PRE>
-          E   real part imaginary part   relative importance
-          V   real part imaginary part
-                   ... K lines ...
-          N   real part imaginary part
-                   ... K lines ...
-          W   real part imaginary part
-                   ... K lines ...
-
-</PRE>
-
-The
-<EM>E</EM>
-line is the eigen value.
-The
-<EM>V</EM>
-lines are the eigen vector associated with E.
-The
-<EM>N</EM>
-lines are the V vector normalized to have a magnitude of 1.
-The
-<EM>W</EM>
-lines are the N vector multiplied by the square root of the
-magnitude of the eigen value (E).
-
-
-<P>
-
-For the example input matrix, the output would be:
-<PRE>
-          E  1159.7452017844    0.0000000000   88.38
-          V     0.6910021591    0.0000000000
-          V     0.7205280412    0.0000000000
-          V     0.4805108400    0.0000000000
-          N     0.6236808478    0.0000000000
-          N     0.6503301526    0.0000000000
-          N     0.4336967751    0.0000000000
-          W    21.2394712045    0.0000000000
-          W    22.1470141296    0.0000000000
-          W    14.7695575384    0.0000000000
-
-          E     5.9705414972    0.0000000000    0.45
-          V     0.7119385973    0.0000000000
-          V    -0.6358200627    0.0000000000
-          V    -0.0703936743    0.0000000000
-          N     0.7438340890    0.0000000000
-          N    -0.6643053754    0.0000000000
-          N    -0.0735473745    0.0000000000
-          W     1.8175356507    0.0000000000
-          W    -1.6232096923    0.0000000000
-          W    -0.1797107407    0.0000000000
-
-          E   146.5031967184    0.0000000000   11.16
-          V     0.2265837636    0.0000000000
-          V     0.3474697082    0.0000000000
-          V    -0.8468727535    0.0000000000
-          N     0.2402770238    0.0000000000
-          N     0.3684685345    0.0000000000
-          N    -0.8980522763    0.0000000000
-          W     2.9082771721    0.0000000000
-          W     4.4598880523    0.0000000000
-          W   -10.8698904856    0.0000000000
-
-</PRE>
-
-<H2>PROGRAM NOTES</H2>
-
-The relative importance of the eigen value (E) is the ratio (percentage)
-of the eigen value to the sum of the eigen values.  Note that the output
-is not sorted by relative importance.
-
-
-<P>
-
-In general, the solution to the eigen system results in complex
-numbers (with both real and imaginary parts).  However, in the example
-above, since the input matrix is symmetric (i.e., inverting the rows and columns
-gives the same matrix) the eigen system has only real values (i.e., the
-imaginary part is zero).
-This fact makes it possible to use eigen vectors to perform principle component
-transformation of data sets.  The covariance or correlation
-matrix of any data set is symmetric
-and thus has only real eigen values and vectors.
-
-<H2>PRINCIPLE COMPONENTS</H2>
-
-To perform principle component transformation on GRASS data layers,
-one would use
-<EM>r.covar</EM>
-to get the covariance (or correlation) matrix for a set of data layers,
-<EM>m.eigensystem</EM>
-to extract the related eigen vectors, and
-<EM>r.mapcalc</EM>
-to form the desired components.
-For example, to get the eigen vectors for 3 layers:
-
-<PRE>
-<B>(echo 3; r.covar map.1,map.2,map.3) | m.eigensystem</B>
-</PRE>
-
-Note that since m.covar only outputs the matrix, we must manually prepend the matrix
-size (3) using the echo command.
-
-
-<P>
-
-Then, using the W vector, new maps are created:
-
-
-<PRE>
-<B>r.mapcalc</B> 'pc.1 = 21.2395*map.1 + 22.1470*map.2 + 14.7696*map.3'
-<B>r.mapcalc</B> 'pc.2 =  2.9083*map.1 +  4.4599*map.2  - 10.8699*map.3'
-<B>r.mapcalc</B> 'pc.3 =  1.8175*map.1  -  1.6232*map.2 \-  0.1797*map.3'
-</PRE>
-
-<H2>NOTES</H2>
-
-The source code for this program requires a Fortran compiler.
-
-<H2>SEE ALSO</H2>
-
-<EM><A HREF="r.covar.html">r.covar</A></EM><br>
-<EM><A HREF="r.mapcalc.html">r.mapcalc</A></EM><br>
-<EM><A HREF="r.rescale.html">r.rescale</A></EM>
-
-<H2>AUTHOR</H2>
-
-This code uses routines from the EISPACK system.  The interface was coded by
-Michael Shapiro, U.S.Army Construction Engineering 
-Research Laboratory
-<p><i>Last changed: $Date: 2002/01/25 05:45:33 $</i>
-</body>
-</html>

Copied: grass-addons/misc/m.eigensystem/m.eigensystem.html (from rev 30335, grass-addons/m.eigensystem/m.eigensystem.html)
===================================================================
--- grass-addons/misc/m.eigensystem/m.eigensystem.html	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/m.eigensystem.html	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,180 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>GRASS GIS: m.eigensystem</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link rel="stylesheet" href="grassdocs.css" type="text/css">
+</head>
+<body bgcolor="white">
+
+<img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
+
+<H2>NAME</H2>
+
+<EM><b>m.eigensystem</b></EM>  - Computes eigen values and eigen vectors
+for square matricies.
+
+<BR>
+
+<EM>(GRASS Data Import/Processing Program)</EM>
+
+<H2>SYNOPSIS</H2>
+
+<B>m.eigensystem &lt; </B><EM>inputfile </EM>
+
+<H2>DESCRIPTION</H2>
+
+<EM>m.eigensystem</EM>
+determines the eigen values and eigen vectors for square matricies.
+The
+<EM>inputfile</EM>
+must have the following format:
+the first line contains an integer K
+which is the number of rows and columns in the matrix;
+the remainder of the file is the matrix, i.e.,
+K lines, each containing K real numbers.
+For example:
+<P>
+<PRE>
+          3
+          462.876649   480.411218   281.758307
+          480.411218   513.015646   278.914813
+          281.758307   278.914813   336.326645
+
+</PRE>
+<P>
+
+The output will be K groups of lines;  each group will have the format:
+<PRE>
+          E   real part imaginary part   relative importance
+          V   real part imaginary part
+                   ... K lines ...
+          N   real part imaginary part
+                   ... K lines ...
+          W   real part imaginary part
+                   ... K lines ...
+
+</PRE>
+
+The
+<EM>E</EM>
+line is the eigen value.
+The
+<EM>V</EM>
+lines are the eigen vector associated with E.
+The
+<EM>N</EM>
+lines are the V vector normalized to have a magnitude of 1.
+The
+<EM>W</EM>
+lines are the N vector multiplied by the square root of the
+magnitude of the eigen value (E).
+
+
+<P>
+
+For the example input matrix, the output would be:
+<PRE>
+          E  1159.7452017844    0.0000000000   88.38
+          V     0.6910021591    0.0000000000
+          V     0.7205280412    0.0000000000
+          V     0.4805108400    0.0000000000
+          N     0.6236808478    0.0000000000
+          N     0.6503301526    0.0000000000
+          N     0.4336967751    0.0000000000
+          W    21.2394712045    0.0000000000
+          W    22.1470141296    0.0000000000
+          W    14.7695575384    0.0000000000
+
+          E     5.9705414972    0.0000000000    0.45
+          V     0.7119385973    0.0000000000
+          V    -0.6358200627    0.0000000000
+          V    -0.0703936743    0.0000000000
+          N     0.7438340890    0.0000000000
+          N    -0.6643053754    0.0000000000
+          N    -0.0735473745    0.0000000000
+          W     1.8175356507    0.0000000000
+          W    -1.6232096923    0.0000000000
+          W    -0.1797107407    0.0000000000
+
+          E   146.5031967184    0.0000000000   11.16
+          V     0.2265837636    0.0000000000
+          V     0.3474697082    0.0000000000
+          V    -0.8468727535    0.0000000000
+          N     0.2402770238    0.0000000000
+          N     0.3684685345    0.0000000000
+          N    -0.8980522763    0.0000000000
+          W     2.9082771721    0.0000000000
+          W     4.4598880523    0.0000000000
+          W   -10.8698904856    0.0000000000
+
+</PRE>
+
+<H2>PROGRAM NOTES</H2>
+
+The relative importance of the eigen value (E) is the ratio (percentage)
+of the eigen value to the sum of the eigen values.  Note that the output
+is not sorted by relative importance.
+
+
+<P>
+
+In general, the solution to the eigen system results in complex
+numbers (with both real and imaginary parts).  However, in the example
+above, since the input matrix is symmetric (i.e., inverting the rows and columns
+gives the same matrix) the eigen system has only real values (i.e., the
+imaginary part is zero).
+This fact makes it possible to use eigen vectors to perform principle component
+transformation of data sets.  The covariance or correlation
+matrix of any data set is symmetric
+and thus has only real eigen values and vectors.
+
+<H2>PRINCIPLE COMPONENTS</H2>
+
+To perform principle component transformation on GRASS data layers,
+one would use
+<EM>r.covar</EM>
+to get the covariance (or correlation) matrix for a set of data layers,
+<EM>m.eigensystem</EM>
+to extract the related eigen vectors, and
+<EM>r.mapcalc</EM>
+to form the desired components.
+For example, to get the eigen vectors for 3 layers:
+
+<PRE>
+<B>(echo 3; r.covar map.1,map.2,map.3) | m.eigensystem</B>
+</PRE>
+
+Note that since m.covar only outputs the matrix, we must manually prepend the matrix
+size (3) using the echo command.
+
+
+<P>
+
+Then, using the W vector, new maps are created:
+
+
+<PRE>
+<B>r.mapcalc</B> 'pc.1 = 21.2395*map.1 + 22.1470*map.2 + 14.7696*map.3'
+<B>r.mapcalc</B> 'pc.2 =  2.9083*map.1 +  4.4599*map.2  - 10.8699*map.3'
+<B>r.mapcalc</B> 'pc.3 =  1.8175*map.1  -  1.6232*map.2 \-  0.1797*map.3'
+</PRE>
+
+<H2>NOTES</H2>
+
+The source code for this program requires a Fortran compiler.
+
+<H2>SEE ALSO</H2>
+
+<EM><A HREF="r.covar.html">r.covar</A></EM><br>
+<EM><A HREF="r.mapcalc.html">r.mapcalc</A></EM><br>
+<EM><A HREF="r.rescale.html">r.rescale</A></EM>
+
+<H2>AUTHOR</H2>
+
+This code uses routines from the EISPACK system.  The interface was coded by
+Michael Shapiro, U.S.Army Construction Engineering 
+Research Laboratory
+<p><i>Last changed: $Date: 2002/01/25 05:45:33 $</i>
+</body>
+</html>

Deleted: grass-addons/misc/m.eigensystem/main.f
===================================================================
--- grass-addons/m.eigensystem/main.f	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/main.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,124 +0,0 @@
-       PROGRAM EIGEN
-C
-C Computes eigenvalues and eigenvectors for an NxN matrix
-C
-C AUTHOR: Michael Shapiro, U.S.Army Construction Engineering Research Laboratory
-C
-C COPYRIGHT:    (C) 1999 by the GRASS Development Team
-C
-C               This program is free software under the GNU General Public
-C               License (>=v2). Read the file COPYING that comes with GRASS
-C               for details.
-C
-C The input is from stdin and has the following format
-C
-C First line contains one positive integer N, the diminension of the matrix
-C The the matrix of real values follows N reals per line each separated by 
-C white space:
-C
-C   3
-C   1.2 2.3 3.4
-C   0.1 12.3 34.5676
-C   2 12.45 2
-C
-C
-C Currently, the max value for N is 30
-C
-C The output is N sets of values. One E line and N V lines
-C
-C  E   real  imaginary   percent-importance
-C  V   real  imaginary
-C  N   real  imaginary
-C      ...
-C
-C where E is the eigen value (and it relative importance)
-C and   V are the eigenvector for this eigenvalue.
-C       N are the normalized eigenvector for this eigenvalue.
-C
-       DOUBLE PRECISION A(30,30),W1,W2,WR(30),WI(30),Z(30,30),FV1(30)
-       DOUBLE PRECISION SUM1,SUM2
-       INTEGER          IV1(30),N
-
-C
-C read the matrix size
-       READ(5,*,END=1000) N
-       IF(N.LT.1) GOTO 2000
-       IF(N.GT.30) GOTO 3000
-C      PRINT *,"N=",N
-
-C
-C read the matrix
-       READ(5,*,END=1000) (( A(I,J),J=1,N),I=1,N)
-
-C
-C run the real-general eigen subroutine
-       CALL RG(30,N,A,WR,WI,1,Z,IV1,FV1,IERR)
-       IF (IERR.NE.0) WRITE(6,*) "? ERROR CODE",IERR
-
-
-C
-C WR and WI contain the real and imaginary parts of the eigenvalues
-C Z contains the vectors
-       SUM1 = 0.0
-       DO 1 I=1,N
-    1  SUM1 = SUM1 + SQRT(WR(I)*WR(I)+WI(I)*WI(I))
-       DO 2 I=1,N
-       W1 = SQRT(WR(I)*WR(I)+WI(I)*WI(I))
-       W2 = SQRT(W1)
-       WRITE(6,100) "E",WR(I),WI(I), W1/SUM1 * 100.0
-
-C
-C Normalize the eigenvectors before printing
-       SUM2 = 0.0
-       DO 6 J=1,N
-       IF(WI(I))3,4,5
-    3  SUM2 = SUM2 + Z(J,I-1) * Z(J,I-1) + Z(J,I) * Z(J,I)
-       GOTO 6
-    4  SUM2 = SUM2 + Z(J,I) * Z(J,I)
-       GOTO 6
-    5  SUM2 = SUM2 + Z(J,I+1) * Z(J,I+1) + Z(J,I) * Z(J,I)
-    6  CONTINUE
-       SUM2 = SQRT(SUM2)
-
-
-       DO 16 J=1,N
-       IF(WI(I))13,14,15
-   13  WRITE(6,100) "V",Z(J,I-1),-Z(J,I)
-       GOTO 16
-   14  WRITE(6,100) "V",Z(J,I),0.0
-       GOTO 16
-   15  WRITE(6,100) "V",Z(J,I),Z(J,I+1)
-   16  CONTINUE
-
-       DO 26 J=1,N
-       IF(WI(I))23,24,25
-   23  WRITE(6,100) "N",Z(J,I-1)/SUM2,-Z(J,I)/SUM2
-       GOTO 26
-   24  WRITE(6,100) "N",Z(J,I)/SUM2,0.0
-       GOTO 26
-   25  WRITE(6,100) "N",Z(J,I)/SUM2,Z(J,I+1)/SUM2
-   26  CONTINUE
-
-       DO 36 J=1,N
-       IF(WI(I))33,34,35
-   33  WRITE(6,100) "W",W2*Z(J,I-1)/SUM2,-W2*Z(J,I)/SUM2
-       GOTO 36
-   34  WRITE(6,100) "W",W2*Z(J,I)/SUM2,0.0
-       GOTO 36
-   35  WRITE(6,100) "W",W2*Z(J,I)/SUM2,W2*Z(J,I+1)/SUM2
-   36  CONTINUE
-
-    2  CONTINUE
-
-
-C
-       CALL EXIT(0)
- 1000  PRINT *,"Incomplete input file"
-       CALL EXIT(1)
- 2000  PRINT *,"N must be positive"
-       CALL EXIT(1)
- 3000  PRINT *,"Maximum array size is 30"
-       CALL EXIT(1)
-
-  100  FORMAT(A1,1x,F20.10,1x,F20.10,3x,F6.2)
-       END

Copied: grass-addons/misc/m.eigensystem/main.f (from rev 30335, grass-addons/m.eigensystem/main.f)
===================================================================
--- grass-addons/misc/m.eigensystem/main.f	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/main.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,124 @@
+       PROGRAM EIGEN
+C
+C Computes eigenvalues and eigenvectors for an NxN matrix
+C
+C AUTHOR: Michael Shapiro, U.S.Army Construction Engineering Research Laboratory
+C
+C COPYRIGHT:    (C) 1999 by the GRASS Development Team
+C
+C               This program is free software under the GNU General Public
+C               License (>=v2). Read the file COPYING that comes with GRASS
+C               for details.
+C
+C The input is from stdin and has the following format
+C
+C First line contains one positive integer N, the diminension of the matrix
+C The the matrix of real values follows N reals per line each separated by 
+C white space:
+C
+C   3
+C   1.2 2.3 3.4
+C   0.1 12.3 34.5676
+C   2 12.45 2
+C
+C
+C Currently, the max value for N is 30
+C
+C The output is N sets of values. One E line and N V lines
+C
+C  E   real  imaginary   percent-importance
+C  V   real  imaginary
+C  N   real  imaginary
+C      ...
+C
+C where E is the eigen value (and it relative importance)
+C and   V are the eigenvector for this eigenvalue.
+C       N are the normalized eigenvector for this eigenvalue.
+C
+       DOUBLE PRECISION A(30,30),W1,W2,WR(30),WI(30),Z(30,30),FV1(30)
+       DOUBLE PRECISION SUM1,SUM2
+       INTEGER          IV1(30),N
+
+C
+C read the matrix size
+       READ(5,*,END=1000) N
+       IF(N.LT.1) GOTO 2000
+       IF(N.GT.30) GOTO 3000
+C      PRINT *,"N=",N
+
+C
+C read the matrix
+       READ(5,*,END=1000) (( A(I,J),J=1,N),I=1,N)
+
+C
+C run the real-general eigen subroutine
+       CALL RG(30,N,A,WR,WI,1,Z,IV1,FV1,IERR)
+       IF (IERR.NE.0) WRITE(6,*) "? ERROR CODE",IERR
+
+
+C
+C WR and WI contain the real and imaginary parts of the eigenvalues
+C Z contains the vectors
+       SUM1 = 0.0
+       DO 1 I=1,N
+    1  SUM1 = SUM1 + SQRT(WR(I)*WR(I)+WI(I)*WI(I))
+       DO 2 I=1,N
+       W1 = SQRT(WR(I)*WR(I)+WI(I)*WI(I))
+       W2 = SQRT(W1)
+       WRITE(6,100) "E",WR(I),WI(I), W1/SUM1 * 100.0
+
+C
+C Normalize the eigenvectors before printing
+       SUM2 = 0.0
+       DO 6 J=1,N
+       IF(WI(I))3,4,5
+    3  SUM2 = SUM2 + Z(J,I-1) * Z(J,I-1) + Z(J,I) * Z(J,I)
+       GOTO 6
+    4  SUM2 = SUM2 + Z(J,I) * Z(J,I)
+       GOTO 6
+    5  SUM2 = SUM2 + Z(J,I+1) * Z(J,I+1) + Z(J,I) * Z(J,I)
+    6  CONTINUE
+       SUM2 = SQRT(SUM2)
+
+
+       DO 16 J=1,N
+       IF(WI(I))13,14,15
+   13  WRITE(6,100) "V",Z(J,I-1),-Z(J,I)
+       GOTO 16
+   14  WRITE(6,100) "V",Z(J,I),0.0
+       GOTO 16
+   15  WRITE(6,100) "V",Z(J,I),Z(J,I+1)
+   16  CONTINUE
+
+       DO 26 J=1,N
+       IF(WI(I))23,24,25
+   23  WRITE(6,100) "N",Z(J,I-1)/SUM2,-Z(J,I)/SUM2
+       GOTO 26
+   24  WRITE(6,100) "N",Z(J,I)/SUM2,0.0
+       GOTO 26
+   25  WRITE(6,100) "N",Z(J,I)/SUM2,Z(J,I+1)/SUM2
+   26  CONTINUE
+
+       DO 36 J=1,N
+       IF(WI(I))33,34,35
+   33  WRITE(6,100) "W",W2*Z(J,I-1)/SUM2,-W2*Z(J,I)/SUM2
+       GOTO 36
+   34  WRITE(6,100) "W",W2*Z(J,I)/SUM2,0.0
+       GOTO 36
+   35  WRITE(6,100) "W",W2*Z(J,I)/SUM2,W2*Z(J,I+1)/SUM2
+   36  CONTINUE
+
+    2  CONTINUE
+
+
+C
+       CALL EXIT(0)
+ 1000  PRINT *,"Incomplete input file"
+       CALL EXIT(1)
+ 2000  PRINT *,"N must be positive"
+       CALL EXIT(1)
+ 3000  PRINT *,"Maximum array size is 30"
+       CALL EXIT(1)
+
+  100  FORMAT(A1,1x,F20.10,1x,F20.10,3x,F6.2)
+       END

Deleted: grass-addons/misc/m.eigensystem/matrix.7x7
===================================================================
--- grass-addons/m.eigensystem/matrix.7x7	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/matrix.7x7	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,8 +0,0 @@
-7
-1 2 3 4 5 6 7
-3 4 2 5 1 6 7
-2 1 4 2 7 6 8
-4 0 0 2 8 9 1
-5 1 2 1 2 1 0
-6 9 8 7 6 5 4 
-7 0 9 8 0 5 7

Copied: grass-addons/misc/m.eigensystem/matrix.7x7 (from rev 30335, grass-addons/m.eigensystem/matrix.7x7)
===================================================================
--- grass-addons/misc/m.eigensystem/matrix.7x7	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/matrix.7x7	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,8 @@
+7
+1 2 3 4 5 6 7
+3 4 2 5 1 6 7
+2 1 4 2 7 6 8
+4 0 0 2 8 9 1
+5 1 2 1 2 1 0
+6 9 8 7 6 5 4 
+7 0 9 8 0 5 7

Deleted: grass-addons/misc/m.eigensystem/rg.f
===================================================================
--- grass-addons/m.eigensystem/rg.f	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/misc/m.eigensystem/rg.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,70 +0,0 @@
-      SUBROUTINE RG(NM,N,A,WR,WI,MATZ,Z,IV1,FV1,IERR)                   EIS8
-C                                                                       EIS8
-      INTEGER N,NM,IS1,IS2,IERR,MATZ                                    EIS8
-      DOUBLE PRECISION A(NM,N),WR(N),WI(N),Z(NM,N),FV1(N)               EIS8
-      INTEGER IV1(N)                                                    EIS8
-C                                                                       EIS8
-C     THIS SUBROUTINE CALLS THE RECOMMENDED SEQUENCE OF                 EIS8
-C     SUBROUTINES FROM THE EIGENSYSTEM SUBROUTINE PACKAGE (EISPACK)     EIS8
-C     TO FIND THE EIGENVALUES AND EIGENVECTORS (IF DESIRED)             EIS8
-C     OF A REAL GENERAL MATRIX.                                         EIS8
-C                                                                       EIS8
-C     ON INPUT                                                          EIS8
-C                                                                       EIS8
-C        NM  MUST BE SET TO THE ROW DIMENSION OF THE TWO-DIMENSIONAL    EIS8
-C        ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM            EIS8
-C        DIMENSION STATEMENT.                                           EIS8
-C                                                                       EIS8
-C        N  IS THE ORDER OF THE MATRIX  A.                              EIS8
-C                                                                       EIS8
-C        A  CONTAINS THE REAL GENERAL MATRIX.                           EIS8
-C                                                                       EIS8
-C        MATZ  IS AN INTEGER VARIABLE SET EQUAL TO ZERO IF              EIS8
-C        ONLY EIGENVALUES ARE DESIRED.  OTHERWISE IT IS SET TO          EIS8
-C        ANY NON-ZERO INTEGER FOR BOTH EIGENVALUES AND EIGENVECTORS.    EIS8
-C                                                                       EIS8
-C     ON OUTPUT                                                         EIS8
-C                                                                       EIS8
-C        WR  AND  WI  CONTAIN THE REAL AND IMAGINARY PARTS,             EIS8
-C        RESPECTIVELY, OF THE EIGENVALUES.  COMPLEX CONJUGATE           EIS8
-C        PAIRS OF EIGENVALUES APPEAR CONSECUTIVELY WITH THE             EIS8
-C        EIGENVALUE HAVING THE POSITIVE IMAGINARY PART FIRST.           EIS8
-C                                                                       EIS8
-C        Z  CONTAINS THE REAL AND IMAGINARY PARTS OF THE EIGENVECTORS   EIS8
-C        IF MATZ IS NOT ZERO.  IF THE J-TH EIGENVALUE IS REAL, THE      EIS8
-C        J-TH COLUMN OF  Z  CONTAINS ITS EIGENVECTOR.  IF THE J-TH      EIS8
-C        EIGENVALUE IS COMPLEX WITH POSITIVE IMAGINARY PART, THE        EIS8
-C        J-TH AND (J+1)-TH COLUMNS OF  Z  CONTAIN THE REAL AND          EIS8
-C        IMAGINARY PARTS OF ITS EIGENVECTOR.  THE CONJUGATE OF THIS     EIS8
-C        VECTOR IS THE EIGENVECTOR FOR THE CONJUGATE EIGENVALUE.        EIS8
-C                                                                       EIS8
-C        IERR  IS AN INTEGER OUTPUT VARIABLE SET EQUAL TO AN ERROR      EIS8
-C           COMPLETION CODE DESCRIBED IN THE DOCUMENTATION FOR HQR      EIS8
-C           AND HQR2.  THE NORMAL COMPLETION CODE IS ZERO.              EIS8
-C                                                                       EIS8
-C        IV1  AND  FV1  ARE TEMPORARY STORAGE ARRAYS.                   EIS8
-C                                                                       EIS8
-C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS8
-C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS8
-C                                                                       EIS8
-C     THIS VERSION DATED AUGUST 1983.                                   EIS8
-C                                                                       EIS8
-C     ------------------------------------------------------------------EIS8
-C                                                                       EIS8
-      IF (N .LE. NM) GO TO 10                                           EIS8
-      IERR = 10 * N                                                     EIS8
-      GO TO 50                                                          EIS8
-C                                                                       EIS8
-   10 CALL  BALANC(NM,N,A,IS1,IS2,FV1)                                  EIS8
-      CALL  ELMHES(NM,N,IS1,IS2,A,IV1)                                  EIS8
-      IF (MATZ .NE. 0) GO TO 20                                         EIS8
-C     .......... FIND EIGENVALUES ONLY ..........                       EIS8
-      CALL  HQR(NM,N,IS1,IS2,A,WR,WI,IERR)                              EIS8
-      GO TO 50                                                          EIS8
-C     .......... FIND BOTH EIGENVALUES AND EIGENVECTORS ..........      EIS8
-   20 CALL  ELTRAN(NM,N,IS1,IS2,A,IV1,Z)                                EIS8
-      CALL  HQR2(NM,N,IS1,IS2,A,WR,WI,Z,IERR)                           EIS8
-      IF (IERR .NE. 0) GO TO 50                                         EIS8
-      CALL  BALBAK(NM,N,IS1,IS2,FV1,N,Z)                                EIS8
-   50 RETURN                                                            EIS8
-      END                                                               EIS8

Copied: grass-addons/misc/m.eigensystem/rg.f (from rev 30335, grass-addons/m.eigensystem/rg.f)
===================================================================
--- grass-addons/misc/m.eigensystem/rg.f	                        (rev 0)
+++ grass-addons/misc/m.eigensystem/rg.f	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,70 @@
+      SUBROUTINE RG(NM,N,A,WR,WI,MATZ,Z,IV1,FV1,IERR)                   EIS8
+C                                                                       EIS8
+      INTEGER N,NM,IS1,IS2,IERR,MATZ                                    EIS8
+      DOUBLE PRECISION A(NM,N),WR(N),WI(N),Z(NM,N),FV1(N)               EIS8
+      INTEGER IV1(N)                                                    EIS8
+C                                                                       EIS8
+C     THIS SUBROUTINE CALLS THE RECOMMENDED SEQUENCE OF                 EIS8
+C     SUBROUTINES FROM THE EIGENSYSTEM SUBROUTINE PACKAGE (EISPACK)     EIS8
+C     TO FIND THE EIGENVALUES AND EIGENVECTORS (IF DESIRED)             EIS8
+C     OF A REAL GENERAL MATRIX.                                         EIS8
+C                                                                       EIS8
+C     ON INPUT                                                          EIS8
+C                                                                       EIS8
+C        NM  MUST BE SET TO THE ROW DIMENSION OF THE TWO-DIMENSIONAL    EIS8
+C        ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM            EIS8
+C        DIMENSION STATEMENT.                                           EIS8
+C                                                                       EIS8
+C        N  IS THE ORDER OF THE MATRIX  A.                              EIS8
+C                                                                       EIS8
+C        A  CONTAINS THE REAL GENERAL MATRIX.                           EIS8
+C                                                                       EIS8
+C        MATZ  IS AN INTEGER VARIABLE SET EQUAL TO ZERO IF              EIS8
+C        ONLY EIGENVALUES ARE DESIRED.  OTHERWISE IT IS SET TO          EIS8
+C        ANY NON-ZERO INTEGER FOR BOTH EIGENVALUES AND EIGENVECTORS.    EIS8
+C                                                                       EIS8
+C     ON OUTPUT                                                         EIS8
+C                                                                       EIS8
+C        WR  AND  WI  CONTAIN THE REAL AND IMAGINARY PARTS,             EIS8
+C        RESPECTIVELY, OF THE EIGENVALUES.  COMPLEX CONJUGATE           EIS8
+C        PAIRS OF EIGENVALUES APPEAR CONSECUTIVELY WITH THE             EIS8
+C        EIGENVALUE HAVING THE POSITIVE IMAGINARY PART FIRST.           EIS8
+C                                                                       EIS8
+C        Z  CONTAINS THE REAL AND IMAGINARY PARTS OF THE EIGENVECTORS   EIS8
+C        IF MATZ IS NOT ZERO.  IF THE J-TH EIGENVALUE IS REAL, THE      EIS8
+C        J-TH COLUMN OF  Z  CONTAINS ITS EIGENVECTOR.  IF THE J-TH      EIS8
+C        EIGENVALUE IS COMPLEX WITH POSITIVE IMAGINARY PART, THE        EIS8
+C        J-TH AND (J+1)-TH COLUMNS OF  Z  CONTAIN THE REAL AND          EIS8
+C        IMAGINARY PARTS OF ITS EIGENVECTOR.  THE CONJUGATE OF THIS     EIS8
+C        VECTOR IS THE EIGENVECTOR FOR THE CONJUGATE EIGENVALUE.        EIS8
+C                                                                       EIS8
+C        IERR  IS AN INTEGER OUTPUT VARIABLE SET EQUAL TO AN ERROR      EIS8
+C           COMPLETION CODE DESCRIBED IN THE DOCUMENTATION FOR HQR      EIS8
+C           AND HQR2.  THE NORMAL COMPLETION CODE IS ZERO.              EIS8
+C                                                                       EIS8
+C        IV1  AND  FV1  ARE TEMPORARY STORAGE ARRAYS.                   EIS8
+C                                                                       EIS8
+C     QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,    EIS8
+C     MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY EIS8
+C                                                                       EIS8
+C     THIS VERSION DATED AUGUST 1983.                                   EIS8
+C                                                                       EIS8
+C     ------------------------------------------------------------------EIS8
+C                                                                       EIS8
+      IF (N .LE. NM) GO TO 10                                           EIS8
+      IERR = 10 * N                                                     EIS8
+      GO TO 50                                                          EIS8
+C                                                                       EIS8
+   10 CALL  BALANC(NM,N,A,IS1,IS2,FV1)                                  EIS8
+      CALL  ELMHES(NM,N,IS1,IS2,A,IV1)                                  EIS8
+      IF (MATZ .NE. 0) GO TO 20                                         EIS8
+C     .......... FIND EIGENVALUES ONLY ..........                       EIS8
+      CALL  HQR(NM,N,IS1,IS2,A,WR,WI,IERR)                              EIS8
+      GO TO 50                                                          EIS8
+C     .......... FIND BOTH EIGENVALUES AND EIGENVECTORS ..........      EIS8
+   20 CALL  ELTRAN(NM,N,IS1,IS2,A,IV1,Z)                                EIS8
+      CALL  HQR2(NM,N,IS1,IS2,A,WR,WI,Z,IERR)                           EIS8
+      IF (IERR .NE. 0) GO TO 50                                         EIS8
+      CALL  BALBAK(NM,N,IS1,IS2,FV1,N,Z)                                EIS8
+   50 RETURN                                                            EIS8
+      END                                                               EIS8

Copied: grass-addons/raster/r.out.netcdf (from rev 30334, grass-addons/r.out.netcdf)

Deleted: grass-addons/raster/r.out.netcdf/COPYING
===================================================================
--- grass-addons/r.out.netcdf/COPYING	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.out.netcdf/COPYING	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,340 +0,0 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-	    How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) year  name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
-Public License instead of this License.

Copied: grass-addons/raster/r.out.netcdf/COPYING (from rev 30335, grass-addons/r.out.netcdf/COPYING)
===================================================================
--- grass-addons/raster/r.out.netcdf/COPYING	                        (rev 0)
+++ grass-addons/raster/r.out.netcdf/COPYING	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.

Deleted: grass-addons/raster/r.out.netcdf/LICENSE
===================================================================
--- grass-addons/r.out.netcdf/LICENSE	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.out.netcdf/LICENSE	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,5 +0,0 @@
-r.out.netcdf is made to be part of GRASS GIS and is relased under the 
-terms of General Public license ver.2. that comes together with this
-package (see GPL.txt)
-
-copyright - Alessandro Frigeri, 2003

Copied: grass-addons/raster/r.out.netcdf/LICENSE (from rev 30335, grass-addons/r.out.netcdf/LICENSE)
===================================================================
--- grass-addons/raster/r.out.netcdf/LICENSE	                        (rev 0)
+++ grass-addons/raster/r.out.netcdf/LICENSE	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,5 @@
+r.out.netcdf is made to be part of GRASS GIS and is relased under the 
+terms of General Public license ver.2. that comes together with this
+package (see GPL.txt)
+
+copyright - Alessandro Frigeri, 2003

Deleted: grass-addons/raster/r.out.netcdf/Makefile
===================================================================
--- grass-addons/r.out.netcdf/Makefile	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.out.netcdf/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,10 +0,0 @@
-MODULE_TOPDIR = ../..
-
-PGM = r.out.netcdf
-
-LIBES = $(GISLIB) -lnetcdf
-DEPENDENCIES = $(GISDEP)
-
-include $(MODULE_TOPDIR)/include/Make/Module.make
-
-default: cmd

Copied: grass-addons/raster/r.out.netcdf/Makefile (from rev 30335, grass-addons/r.out.netcdf/Makefile)
===================================================================
--- grass-addons/raster/r.out.netcdf/Makefile	                        (rev 0)
+++ grass-addons/raster/r.out.netcdf/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,10 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.out.netcdf
+
+LIBES = $(GISLIB) -lnetcdf
+DEPENDENCIES = $(GISDEP)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd

Deleted: grass-addons/raster/r.out.netcdf/NEWS
===================================================================
--- grass-addons/r.out.netcdf/NEWS	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.out.netcdf/NEWS	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,6 +0,0 @@
-18 Feb 2007 - M Neteler
-	updated to GRASS 6.3
-11 Feb 2003 - A Frigeri
-	r.out.netcdf (0.1) is out for testing!
-17 Mar 2003 - A Frigeri
-	added support for floating point and double precision raster maps

Copied: grass-addons/raster/r.out.netcdf/NEWS (from rev 30335, grass-addons/r.out.netcdf/NEWS)
===================================================================
--- grass-addons/raster/r.out.netcdf/NEWS	                        (rev 0)
+++ grass-addons/raster/r.out.netcdf/NEWS	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,6 @@
+18 Feb 2007 - M Neteler
+	updated to GRASS 6.3
+11 Feb 2003 - A Frigeri
+	r.out.netcdf (0.1) is out for testing!
+17 Mar 2003 - A Frigeri
+	added support for floating point and double precision raster maps

Deleted: grass-addons/raster/r.out.netcdf/TODO
===================================================================
--- grass-addons/r.out.netcdf/TODO	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.out.netcdf/TODO	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1 +0,0 @@
--Align netcdf and grass datatypes

Copied: grass-addons/raster/r.out.netcdf/TODO (from rev 30335, grass-addons/r.out.netcdf/TODO)
===================================================================
--- grass-addons/raster/r.out.netcdf/TODO	                        (rev 0)
+++ grass-addons/raster/r.out.netcdf/TODO	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1 @@
+-Align netcdf and grass datatypes

Deleted: grass-addons/raster/r.out.netcdf/description.html
===================================================================
--- grass-addons/r.out.netcdf/description.html	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.out.netcdf/description.html	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,19 +0,0 @@
-<H2>DESCRIPTION</H2>
-
-The <em>r.out.netcdf</em> module exports a GRASS raster map to a netcdf file. 
-Dimensions, Attributes and variables of netcdf file follow the scheme used 
-in Generic Mapping Tools (GMT) grid (.grd) files (-g flag) or are suitable 
-to be imported into IBM Data Explorer (-d flag).
-
-<H2>AUTHOR</H2>
-
-Alessandro Frigeri &lt;<A HREF="mailto:afrigeri unipg it">afrigeri unipg it</A>&gt;
-
-<H2>SEE ALSO</H2>
-
-<EM><A HREF="r.out.arc.html">r.out.arc</A></EM>,
-<EM><A HREF="r.out.ascii.html">r.out.ascii</A></EM>,
-<EM><A HREF="r.out.bin.html">r.out.bin</A></EM>,
-<EM><A HREF="r.out.tiff.html">r.out.tiff</A></EM>
-
-<p><i>Last changed: $Date: 2004/11/17 17:49:04 $</i>

Copied: grass-addons/raster/r.out.netcdf/description.html (from rev 30335, grass-addons/r.out.netcdf/description.html)
===================================================================
--- grass-addons/raster/r.out.netcdf/description.html	                        (rev 0)
+++ grass-addons/raster/r.out.netcdf/description.html	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,19 @@
+<H2>DESCRIPTION</H2>
+
+The <em>r.out.netcdf</em> module exports a GRASS raster map to a netcdf file. 
+Dimensions, Attributes and variables of netcdf file follow the scheme used 
+in Generic Mapping Tools (GMT) grid (.grd) files (-g flag) or are suitable 
+to be imported into IBM Data Explorer (-d flag).
+
+<H2>AUTHOR</H2>
+
+Alessandro Frigeri &lt;<A HREF="mailto:afrigeri unipg it">afrigeri unipg it</A>&gt;
+
+<H2>SEE ALSO</H2>
+
+<EM><A HREF="r.out.arc.html">r.out.arc</A></EM>,
+<EM><A HREF="r.out.ascii.html">r.out.ascii</A></EM>,
+<EM><A HREF="r.out.bin.html">r.out.bin</A></EM>,
+<EM><A HREF="r.out.tiff.html">r.out.tiff</A></EM>
+
+<p><i>Last changed: $Date: 2004/11/17 17:49:04 $</i>

Deleted: grass-addons/raster/r.out.netcdf/main.c
===================================================================
--- grass-addons/r.out.netcdf/main.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.out.netcdf/main.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,385 +0,0 @@
-/****************************************************************************
- *
- * MODULE:       r.out.netcdf
- * AUTHOR(S):    Alessandro Frigeri - afrigeri at unipg.it
- *               
- * PURPOSE:      Exports a raster map in a netCDF file.  
- *               Exported map can be imported easly into IBM data Explorer
- *               or Generic Mapping Tools (GMT)
- *
- * COPYRIGHT:    (C) 2003 Alessandro Frigeri for 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.
- *
- * LAST UPDATE:  10th Feb 2003 
- *
- * HISTORY:	 11th Feb 2003  - r.out.necdf is out			
- *
- *	         16th Mar 2003	- support for FCELL and DCELL added
- *****************************************************************************/
- 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <netcdf.h>
-
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-extern CELL  f_c(CELL);
-extern FCELL f_f(FCELL);
-extern DCELL f_d(DCELL);
-
-/* Stuff to make calculation on the raster values */
-
-CELL c_calc(CELL x)
-{
-  return x;
-}
-
-FCELL f_calc(FCELL x)
-{
-  return x;
-}
-
-DCELL d_calc(DCELL x)
-{
-  return x;
-}
-
-int
-main(int argc, char *argv[])
-{
-	struct Cell_head cellhd;
-	struct Cell_head region;
-	char *name, *result, *mapset;
-	void *inrast;
-	unsigned char *outrast;
-	int nrows, ncols;
-	int row,col;
-	int infd;
-	int dx,gmt;
-	RASTER_MAP_TYPE data_type;
-	struct GModule *module;
-	struct Option *input, *output;
-	struct Flag *flag1, *flag2;
-
-	/* netcdf stuff */
-	int ncols_dim,nrows_dim,naxes_dim,height_id,ndeltas_dim;
-	int errnc,ncID,zid,xrangeid,yrangeid,zrangeid,spacingid,dimensionid;
-	int fieldid,fielddimid;
-	int locations_id;
-	char title1[NC_MAX_NAME]="GRASS GIS raster map",history[NC_MAX_NAME];
-	static char title[] = "netCDF output from GRASS GIS";
-	static char remark[] = "netCDF output from GRASS GIS";
-	static char degrees[] = "degrees";
-	static char meter[] = "Meter";
-	static float scale_factor[]={1};
-	static int add_offset[]={0};
-	static int node_offset[]={1};
-	int sideid,xysizeid;
-	static size_t a[] = {0};
-	static size_t b[] = {1};
-	int xysize;
-	int vali;
-	float valf;
-	double vald;
-	size_t zstart[1];
-	size_t zcount[1];
-	double fmin,fmax;
-	double domin,domax;
-	int dmin,dmax;	
-	struct FPRange fprange;
-	struct Range range;
-	float longitude,latitude;	
-
-	
-	int locations_dims[2];
-	
-	int height_dims[2];
-			
-	static size_t index_height[]={0,0};
-	static size_t index_locations[]={0,0};
-
-	double ns;
-	
-	G_gisinit(argv[0]);
-
-	module = G_define_module();
-	module->description =
-		_("GRASS module for exporting netCDF data");
-					        
-	/* Define options */
-
-	input = G_define_standard_option(G_OPT_R_INPUT);
-
-	output = G_define_standard_option(G_OPT_R_OUTPUT);
-	output->gisprompt = "new_file,file,output";
-	output->description= "File name for new netCDF file";
-
-	/* Define the different flags */		
-	flag1 = G_define_flag() ;
-	flag1->key         = 'd' ;
-	flag1->description = _("OpenDX output") ;
-	
-	flag2 = G_define_flag() ;
-	flag2->key         = 'g' ;
-	flag2->description = _("GMT output") ;
-	
-	if (G_parser(argc, argv))
-		exit (EXIT_FAILURE);
-		
-	name    = input->answer;
-	result  = output->answer;
-	dx = flag1->answer;
-	gmt = flag2->answer;
-
-	/* find map in mapset */
-	mapset = G_find_cell2 (name, "");
-        if (mapset == NULL)
-                G_fatal_error ("cell file [%s] not found", name);
-
-        if (G_legal_filename (result) < 0)
-                G_fatal_error ("[%s] is an illegal name", result); 
-
-	/* determine the inputmap type (CELL/FCELL/DCELL) */
-	data_type = G_raster_map_type(name, mapset);
-
-	if ( (infd = G_open_cell_old (name, mapset)) < 0)
-		G_fatal_error ("Cannot open cell file [%s]", name);
-
-	if (G_get_cellhd (name, mapset, &cellhd) < 0)
-		G_fatal_error ("Cannot read file header of [%s]", name);
-
-	/* Allocate input buffer */
-	inrast = G_allocate_raster_buf(data_type);
-	
-	/* Allocate output buffer, use input map data_type */
-	
-	nrows = G_window_rows();
-	ncols = G_window_cols();
-	outrast = G_allocate_raster_buf(data_type);
-
-	/* Get window boundaries */ 
-	G_get_window(&region);
-	
-	/* Create the new netCDF file */
-	
-	errnc = nc_create(result, NC_WRITE, &ncID);
-  	if (errnc == NC_EEXIST)
-    		printf("Couldn't create NC file %s, NC file with that name already exists\n",result);
-	
-	
-	
-	/* Dimensions: xysize, side */ 
-	ncols=region.cols;
-	nrows=region.rows;
-	
-	xysize=ncols*nrows;
-	
-	if(gmt){	
-	nc_def_dim(ncID, "xysize", xysize, &xysizeid);
-	nc_def_dim(ncID, "side", 2, &sideid);
-	nc_def_var(ncID, "x_range", NC_DOUBLE,1, &sideid,&xrangeid);
-	nc_put_att_text(ncID, xrangeid, "units",strlen(degrees), degrees);
-	nc_def_var(ncID, "y_range", NC_DOUBLE,1, &sideid,&yrangeid);
-	nc_put_att_text(ncID, yrangeid, "units",strlen(degrees), degrees);
-	nc_def_var(ncID, "z_range", NC_DOUBLE,1, &sideid,&zrangeid);
-	nc_put_att_text(ncID, zrangeid, "units",strlen(meter), meter);
-	nc_def_var(ncID, "spacing", NC_DOUBLE,1, &sideid,&spacingid);
-	nc_def_var(ncID, "dimension", NC_INT,1, &sideid,&dimensionid);
-	
-	switch (data_type)
-			{
-			case CELL_TYPE:	
-				nc_def_var(ncID, "z", NC_INT,1, &xysizeid,&zid);
-				break;
-			case FCELL_TYPE:
-				nc_def_var(ncID, "z", NC_FLOAT,1, &xysizeid,&zid);
-				break;
-			case DCELL_TYPE:	
-				nc_def_var(ncID, "z", NC_DOUBLE,1, &xysizeid,&zid);
-				break;
-			}
-				
-	scale_factor[0]=1;
-	
-	nc_put_att_text(ncID, NC_GLOBAL, "title",strlen(title), title);
-	nc_put_att_text(ncID, NC_GLOBAL, "source",strlen(title), title);
-	nc_put_att_text(ncID, zid, "long_name",strlen(title), title);
-	nc_put_att_float(ncID, zid, "scale_factor",NC_FLOAT,1, scale_factor);
-	nc_put_att_int(ncID, zid, "add_offset",NC_INT,1, add_offset);
-	nc_put_att_int(ncID, zid, "node_offset",NC_INT,1, node_offset);
-	}
-
-	if(dx){
-	nc_def_dim(ncID, "lon", ncols , &ncols_dim); 
-	nc_def_dim(ncID, "lat", nrows , &nrows_dim);
-	nc_def_dim(ncID, "naxes",2, &naxes_dim);
-	nc_def_dim(ncID, "ndeltas",2, &ndeltas_dim);
-	
-    	locations_dims[0]=naxes_dim;
-	locations_dims[1]=ndeltas_dim;
-	nc_def_var(ncID, "locations",NC_FLOAT,2,locations_dims,&locations_id);
-	
-	height_dims[0]=ncols_dim;
-	height_dims[1]=nrows_dim;
-	
-	switch (data_type)
-			{
-			case CELL_TYPE:	
-				nc_def_var(ncID, "height",NC_INT,2,height_dims,&height_id);
-				break;
-			case FCELL_TYPE:
-				nc_def_var(ncID, "height",NC_FLOAT,2,height_dims,&height_id);
-				break;
-			case DCELL_TYPE:	
-				nc_def_var(ncID, "height",NC_DOUBLE,2,height_dims,&height_id);
-				break;
-			}
-	
-	
-	nc_put_att_text(ncID, height_id, "field",14,"height, scalar");
-	nc_put_att_text(ncID, height_id, "positions",18,"locations, regular");
-	
-	}
-	nc_enddef(ncID);
-	
-	if(gmt){
-	nc_put_var1_double(ncID,xrangeid,a,&region.west);
-	nc_put_var1_double(ncID,xrangeid,b,&region.east);
-	nc_put_var1_double(ncID,yrangeid,a,&region.south);
-	nc_put_var1_double(ncID,yrangeid,b,&region.north);
-	nc_put_var1_double(ncID,spacingid,a,&region.ew_res);
-	nc_put_var1_double(ncID,spacingid,b,&region.ns_res);	
-	nc_put_var1_int(ncID,dimensionid,a,&ncols);
-	nc_put_var1_int(ncID,dimensionid,b,&nrows);
-	}	
-	
-	if(dx){
-	
-	index_locations[0]=0;
-	index_locations[1]=0;
-	nc_put_var1_double(ncID,locations_id,index_locations,&region.west);
-	index_locations[0]=0;
-	index_locations[1]=1;
-	nc_put_var1_double(ncID,locations_id,index_locations,&region.ew_res);
-	
-	index_locations[0]=1;
-	index_locations[1]=0;
-	nc_put_var1_double(ncID,locations_id,index_locations,&region.north);
-	index_locations[0]=1;
-	index_locations[1]=1;
-	ns=-region.ns_res;
-	nc_put_var1_double(ncID,locations_id,index_locations,&ns);
-	
-	}
-        		
-	
-	for (row = 0; row < nrows; row++)
-	{
-		CELL c;
-		FCELL f;
-		DCELL d;
-
-		G_percent (row, nrows, 2);
-		
-		/* read input map */
-		if (G_get_raster_row (infd, inrast, row, data_type) < 0)
-			G_fatal_error (_("Could not read from <%s>"),name);
-		
-		
-		/*  put the NetCDF data 
-		    CELL  -> int
-		    FCELL -> float
-		    DCELL -> double
-		*/
-		for (col=0; col < ncols; col++)
-		{
-			longitude=region.west+col*region.ew_res;
-			latitude=region.south+row*region.ns_res;
-			index_height[0]=col;
-			index_height[1]=row;
-				
-			switch (data_type)
-			{
-			case CELL_TYPE:
-				c = ((CELL *) inrast)[col];
-				c = c_calc(c);			/* calculate */
-				zstart[0]=col+(row*ncols);	/* position  */
-				zcount[0]=1;		 	/* extension */
-							
-				vali=c;
-				if(gmt){
-				nc_put_vara_int(ncID,zid,zstart,zcount,&vali);
-				}
-				if(dx){																
-				nc_put_var1_int(ncID,height_id,index_height,&vali);
-				}												
-				break;
-			case FCELL_TYPE:
-				f = ((FCELL *) inrast)[col];
-				f = f_calc(f); 			/* calculate */
-				zstart[0]=col+(row*ncols);	/* position  */
-				zcount[0]=1;			/* extension */
-				valf=f;
-				if(gmt){
-				nc_put_vara_float(ncID,zid,zstart,zcount,&valf);
-				}
-				if(dx){																
-				nc_put_var1_float(ncID,height_id,index_height,&valf);
-				}
-				break;
-			case DCELL_TYPE:
-				d = ((DCELL *) inrast)[col];
-				d = d_calc(d); 			/* calculate */
-				zstart[0]=col+(row*ncols);	/* position  */
-				zcount[0]=1;			/* extension */
-				vald=d;
-				if(gmt){
-				nc_put_vara_double(ncID,zid,zstart,zcount,&vald);
-				}
-				if(dx){																
-				nc_put_var1_double(ncID,height_id,index_height,&vald);
-				}
-				break;
-			}
-		}
-
-	}
-
-
-	if(gmt)
-	{
-	switch(data_type)	
-	{
-		case CELL_TYPE:
-			G_read_range(name, mapset, &range);
-      			G_get_range_min_max(&range, &dmin, &dmax);
-			nc_put_var1_int(ncID,zrangeid,a,&dmin);
-			nc_put_var1_int(ncID,zrangeid,b,&dmax);
-		case FCELL_TYPE:
-			G_read_fp_range(name, mapset, &fprange);
-      			G_get_fp_range_min_max(&fprange, &fmin, &fmax);
-			nc_put_var1_double(ncID,zrangeid,a,&fmin);
-			nc_put_var1_double(ncID,zrangeid,b,&fmax);
-		case DCELL_TYPE:
-			G_read_fp_range(name, mapset, &fprange);
-      			G_get_fp_range_min_max(&fprange, &domin, &domax);
-			nc_put_var1_double(ncID,zrangeid,a,&domin);
-		        nc_put_var1_double(ncID,zrangeid,b,&domax);
-	}
-
-	}
-		
-	/* Close the netcdf file */	
-	nc_close(ncID);
-
-	G_free(inrast);
-	G_close_cell (infd);
-	
-	exit(EXIT_SUCCESS);
-}

Copied: grass-addons/raster/r.out.netcdf/main.c (from rev 30335, grass-addons/r.out.netcdf/main.c)
===================================================================
--- grass-addons/raster/r.out.netcdf/main.c	                        (rev 0)
+++ grass-addons/raster/r.out.netcdf/main.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,385 @@
+/****************************************************************************
+ *
+ * MODULE:       r.out.netcdf
+ * AUTHOR(S):    Alessandro Frigeri - afrigeri at unipg.it
+ *               
+ * PURPOSE:      Exports a raster map in a netCDF file.  
+ *               Exported map can be imported easly into IBM data Explorer
+ *               or Generic Mapping Tools (GMT)
+ *
+ * COPYRIGHT:    (C) 2003 Alessandro Frigeri for 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.
+ *
+ * LAST UPDATE:  10th Feb 2003 
+ *
+ * HISTORY:	 11th Feb 2003  - r.out.necdf is out			
+ *
+ *	         16th Mar 2003	- support for FCELL and DCELL added
+ *****************************************************************************/
+ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netcdf.h>
+
+#include <grass/gis.h>
+#include <grass/glocale.h>
+
+extern CELL  f_c(CELL);
+extern FCELL f_f(FCELL);
+extern DCELL f_d(DCELL);
+
+/* Stuff to make calculation on the raster values */
+
+CELL c_calc(CELL x)
+{
+  return x;
+}
+
+FCELL f_calc(FCELL x)
+{
+  return x;
+}
+
+DCELL d_calc(DCELL x)
+{
+  return x;
+}
+
+int
+main(int argc, char *argv[])
+{
+	struct Cell_head cellhd;
+	struct Cell_head region;
+	char *name, *result, *mapset;
+	void *inrast;
+	unsigned char *outrast;
+	int nrows, ncols;
+	int row,col;
+	int infd;
+	int dx,gmt;
+	RASTER_MAP_TYPE data_type;
+	struct GModule *module;
+	struct Option *input, *output;
+	struct Flag *flag1, *flag2;
+
+	/* netcdf stuff */
+	int ncols_dim,nrows_dim,naxes_dim,height_id,ndeltas_dim;
+	int errnc,ncID,zid,xrangeid,yrangeid,zrangeid,spacingid,dimensionid;
+	int fieldid,fielddimid;
+	int locations_id;
+	char title1[NC_MAX_NAME]="GRASS GIS raster map",history[NC_MAX_NAME];
+	static char title[] = "netCDF output from GRASS GIS";
+	static char remark[] = "netCDF output from GRASS GIS";
+	static char degrees[] = "degrees";
+	static char meter[] = "Meter";
+	static float scale_factor[]={1};
+	static int add_offset[]={0};
+	static int node_offset[]={1};
+	int sideid,xysizeid;
+	static size_t a[] = {0};
+	static size_t b[] = {1};
+	int xysize;
+	int vali;
+	float valf;
+	double vald;
+	size_t zstart[1];
+	size_t zcount[1];
+	double fmin,fmax;
+	double domin,domax;
+	int dmin,dmax;	
+	struct FPRange fprange;
+	struct Range range;
+	float longitude,latitude;	
+
+	
+	int locations_dims[2];
+	
+	int height_dims[2];
+			
+	static size_t index_height[]={0,0};
+	static size_t index_locations[]={0,0};
+
+	double ns;
+	
+	G_gisinit(argv[0]);
+
+	module = G_define_module();
+	module->description =
+		_("GRASS module for exporting netCDF data");
+					        
+	/* Define options */
+
+	input = G_define_standard_option(G_OPT_R_INPUT);
+
+	output = G_define_standard_option(G_OPT_R_OUTPUT);
+	output->gisprompt = "new_file,file,output";
+	output->description= "File name for new netCDF file";
+
+	/* Define the different flags */		
+	flag1 = G_define_flag() ;
+	flag1->key         = 'd' ;
+	flag1->description = _("OpenDX output") ;
+	
+	flag2 = G_define_flag() ;
+	flag2->key         = 'g' ;
+	flag2->description = _("GMT output") ;
+	
+	if (G_parser(argc, argv))
+		exit (EXIT_FAILURE);
+		
+	name    = input->answer;
+	result  = output->answer;
+	dx = flag1->answer;
+	gmt = flag2->answer;
+
+	/* find map in mapset */
+	mapset = G_find_cell2 (name, "");
+        if (mapset == NULL)
+                G_fatal_error ("cell file [%s] not found", name);
+
+        if (G_legal_filename (result) < 0)
+                G_fatal_error ("[%s] is an illegal name", result); 
+
+	/* determine the inputmap type (CELL/FCELL/DCELL) */
+	data_type = G_raster_map_type(name, mapset);
+
+	if ( (infd = G_open_cell_old (name, mapset)) < 0)
+		G_fatal_error ("Cannot open cell file [%s]", name);
+
+	if (G_get_cellhd (name, mapset, &cellhd) < 0)
+		G_fatal_error ("Cannot read file header of [%s]", name);
+
+	/* Allocate input buffer */
+	inrast = G_allocate_raster_buf(data_type);
+	
+	/* Allocate output buffer, use input map data_type */
+	
+	nrows = G_window_rows();
+	ncols = G_window_cols();
+	outrast = G_allocate_raster_buf(data_type);
+
+	/* Get window boundaries */ 
+	G_get_window(&region);
+	
+	/* Create the new netCDF file */
+	
+	errnc = nc_create(result, NC_WRITE, &ncID);
+  	if (errnc == NC_EEXIST)
+    		printf("Couldn't create NC file %s, NC file with that name already exists\n",result);
+	
+	
+	
+	/* Dimensions: xysize, side */ 
+	ncols=region.cols;
+	nrows=region.rows;
+	
+	xysize=ncols*nrows;
+	
+	if(gmt){	
+	nc_def_dim(ncID, "xysize", xysize, &xysizeid);
+	nc_def_dim(ncID, "side", 2, &sideid);
+	nc_def_var(ncID, "x_range", NC_DOUBLE,1, &sideid,&xrangeid);
+	nc_put_att_text(ncID, xrangeid, "units",strlen(degrees), degrees);
+	nc_def_var(ncID, "y_range", NC_DOUBLE,1, &sideid,&yrangeid);
+	nc_put_att_text(ncID, yrangeid, "units",strlen(degrees), degrees);
+	nc_def_var(ncID, "z_range", NC_DOUBLE,1, &sideid,&zrangeid);
+	nc_put_att_text(ncID, zrangeid, "units",strlen(meter), meter);
+	nc_def_var(ncID, "spacing", NC_DOUBLE,1, &sideid,&spacingid);
+	nc_def_var(ncID, "dimension", NC_INT,1, &sideid,&dimensionid);
+	
+	switch (data_type)
+			{
+			case CELL_TYPE:	
+				nc_def_var(ncID, "z", NC_INT,1, &xysizeid,&zid);
+				break;
+			case FCELL_TYPE:
+				nc_def_var(ncID, "z", NC_FLOAT,1, &xysizeid,&zid);
+				break;
+			case DCELL_TYPE:	
+				nc_def_var(ncID, "z", NC_DOUBLE,1, &xysizeid,&zid);
+				break;
+			}
+				
+	scale_factor[0]=1;
+	
+	nc_put_att_text(ncID, NC_GLOBAL, "title",strlen(title), title);
+	nc_put_att_text(ncID, NC_GLOBAL, "source",strlen(title), title);
+	nc_put_att_text(ncID, zid, "long_name",strlen(title), title);
+	nc_put_att_float(ncID, zid, "scale_factor",NC_FLOAT,1, scale_factor);
+	nc_put_att_int(ncID, zid, "add_offset",NC_INT,1, add_offset);
+	nc_put_att_int(ncID, zid, "node_offset",NC_INT,1, node_offset);
+	}
+
+	if(dx){
+	nc_def_dim(ncID, "lon", ncols , &ncols_dim); 
+	nc_def_dim(ncID, "lat", nrows , &nrows_dim);
+	nc_def_dim(ncID, "naxes",2, &naxes_dim);
+	nc_def_dim(ncID, "ndeltas",2, &ndeltas_dim);
+	
+    	locations_dims[0]=naxes_dim;
+	locations_dims[1]=ndeltas_dim;
+	nc_def_var(ncID, "locations",NC_FLOAT,2,locations_dims,&locations_id);
+	
+	height_dims[0]=ncols_dim;
+	height_dims[1]=nrows_dim;
+	
+	switch (data_type)
+			{
+			case CELL_TYPE:	
+				nc_def_var(ncID, "height",NC_INT,2,height_dims,&height_id);
+				break;
+			case FCELL_TYPE:
+				nc_def_var(ncID, "height",NC_FLOAT,2,height_dims,&height_id);
+				break;
+			case DCELL_TYPE:	
+				nc_def_var(ncID, "height",NC_DOUBLE,2,height_dims,&height_id);
+				break;
+			}
+	
+	
+	nc_put_att_text(ncID, height_id, "field",14,"height, scalar");
+	nc_put_att_text(ncID, height_id, "positions",18,"locations, regular");
+	
+	}
+	nc_enddef(ncID);
+	
+	if(gmt){
+	nc_put_var1_double(ncID,xrangeid,a,&region.west);
+	nc_put_var1_double(ncID,xrangeid,b,&region.east);
+	nc_put_var1_double(ncID,yrangeid,a,&region.south);
+	nc_put_var1_double(ncID,yrangeid,b,&region.north);
+	nc_put_var1_double(ncID,spacingid,a,&region.ew_res);
+	nc_put_var1_double(ncID,spacingid,b,&region.ns_res);	
+	nc_put_var1_int(ncID,dimensionid,a,&ncols);
+	nc_put_var1_int(ncID,dimensionid,b,&nrows);
+	}	
+	
+	if(dx){
+	
+	index_locations[0]=0;
+	index_locations[1]=0;
+	nc_put_var1_double(ncID,locations_id,index_locations,&region.west);
+	index_locations[0]=0;
+	index_locations[1]=1;
+	nc_put_var1_double(ncID,locations_id,index_locations,&region.ew_res);
+	
+	index_locations[0]=1;
+	index_locations[1]=0;
+	nc_put_var1_double(ncID,locations_id,index_locations,&region.north);
+	index_locations[0]=1;
+	index_locations[1]=1;
+	ns=-region.ns_res;
+	nc_put_var1_double(ncID,locations_id,index_locations,&ns);
+	
+	}
+        		
+	
+	for (row = 0; row < nrows; row++)
+	{
+		CELL c;
+		FCELL f;
+		DCELL d;
+
+		G_percent (row, nrows, 2);
+		
+		/* read input map */
+		if (G_get_raster_row (infd, inrast, row, data_type) < 0)
+			G_fatal_error (_("Could not read from <%s>"),name);
+		
+		
+		/*  put the NetCDF data 
+		    CELL  -> int
+		    FCELL -> float
+		    DCELL -> double
+		*/
+		for (col=0; col < ncols; col++)
+		{
+			longitude=region.west+col*region.ew_res;
+			latitude=region.south+row*region.ns_res;
+			index_height[0]=col;
+			index_height[1]=row;
+				
+			switch (data_type)
+			{
+			case CELL_TYPE:
+				c = ((CELL *) inrast)[col];
+				c = c_calc(c);			/* calculate */
+				zstart[0]=col+(row*ncols);	/* position  */
+				zcount[0]=1;		 	/* extension */
+							
+				vali=c;
+				if(gmt){
+				nc_put_vara_int(ncID,zid,zstart,zcount,&vali);
+				}
+				if(dx){																
+				nc_put_var1_int(ncID,height_id,index_height,&vali);
+				}												
+				break;
+			case FCELL_TYPE:
+				f = ((FCELL *) inrast)[col];
+				f = f_calc(f); 			/* calculate */
+				zstart[0]=col+(row*ncols);	/* position  */
+				zcount[0]=1;			/* extension */
+				valf=f;
+				if(gmt){
+				nc_put_vara_float(ncID,zid,zstart,zcount,&valf);
+				}
+				if(dx){																
+				nc_put_var1_float(ncID,height_id,index_height,&valf);
+				}
+				break;
+			case DCELL_TYPE:
+				d = ((DCELL *) inrast)[col];
+				d = d_calc(d); 			/* calculate */
+				zstart[0]=col+(row*ncols);	/* position  */
+				zcount[0]=1;			/* extension */
+				vald=d;
+				if(gmt){
+				nc_put_vara_double(ncID,zid,zstart,zcount,&vald);
+				}
+				if(dx){																
+				nc_put_var1_double(ncID,height_id,index_height,&vald);
+				}
+				break;
+			}
+		}
+
+	}
+
+
+	if(gmt)
+	{
+	switch(data_type)	
+	{
+		case CELL_TYPE:
+			G_read_range(name, mapset, &range);
+      			G_get_range_min_max(&range, &dmin, &dmax);
+			nc_put_var1_int(ncID,zrangeid,a,&dmin);
+			nc_put_var1_int(ncID,zrangeid,b,&dmax);
+		case FCELL_TYPE:
+			G_read_fp_range(name, mapset, &fprange);
+      			G_get_fp_range_min_max(&fprange, &fmin, &fmax);
+			nc_put_var1_double(ncID,zrangeid,a,&fmin);
+			nc_put_var1_double(ncID,zrangeid,b,&fmax);
+		case DCELL_TYPE:
+			G_read_fp_range(name, mapset, &fprange);
+      			G_get_fp_range_min_max(&fprange, &domin, &domax);
+			nc_put_var1_double(ncID,zrangeid,a,&domin);
+		        nc_put_var1_double(ncID,zrangeid,b,&domax);
+	}
+
+	}
+		
+	/* Close the netcdf file */	
+	nc_close(ncID);
+
+	G_free(inrast);
+	G_close_cell (infd);
+	
+	exit(EXIT_SUCCESS);
+}

Copied: grass-addons/raster/r.rast4d (from rev 30334, grass-addons/r.rast4d)

Deleted: grass-addons/raster/r.rast4d/QuickStart.txt
===================================================================
--- grass-addons/r.rast4d/QuickStart.txt	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.rast4d/QuickStart.txt	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,75 +0,0 @@
-You need:
- - grass63
- - sqlite3
- - a valid grass location
-and the will to read sql and bash code if an error occures :)
-
-Be sure you are in a GRASS location!
-Stay in the directory containing the QuickStart file you are reading now,
-this is very important!
-The sqlite3 database will be created in the ./db/ directory.
-Use a graphical frontend to explore the database structure or read the 
-code in the sql directory.
-
-* ./r.rast4d.init
-Start r.rast4d.init to create the database,
-- if the database already exists, nothing will be performed
-- if you want to create a new database just remove the one in 
-  the ./db/ directory and run r.rast4d.init again
-
-* bin/tg.update
-Use tg.update to register/update your raster maps in the sqlite table
-
-* bin/tg.list
-Use tg.list to show the registered maps, performe sql where statements on the view
-and use the order option to order your data
-
-* bin/tg.remove
-Remove the raster map entries from the database
-The maps are not removed from grass!
-
-###########################################
-
-How to upload many raster maps?
-
-The maps need to have a valid time stamp (r.timestamp).
-Then (we assume a wildcard for raster names):
-
- for i in `g.mlist type=rast pat="rastname*"` ; do
-   bin/tg.update $i
- done
-
-###########################################
-Sören Gebbert 	
-to Markus, me
-Apr 5 2007
-
-Fertig,
-ich habe den Prototypen hoffentlich so modifiziert dass er mit Punkten im Namen umgehen kann.
-Außerdem werden die Raster timestamps (erzeugt mit r.timestamp) ausgewertet
-und die vtime_start mit dem ersten auftretenden timestamp gesetzt.
-
-Der erste timestamp sollte vollständig sein, sonst funzt es nicht.
-Es ist ein ziemlicher Hack weil ich in Eile bin. :/
-
-Beispiel mit 4 registrierten Maps:
-
-GRASS 6.3.cvs > bin/tg.list rast select=name,vtime_start
-select name,vtime_start from raster_view where ctime > DATETIME('1950-01-01 10:00:00') order by name
-test.1.1|1999-06-08 13:10:20
-test.1.2|1999-06-09 13:10:20
-test.1.3|2000-01-14 13:10:20
-test.1.4|2000-01-24 13:10:20
-
-GRASS 6.3.cvs > r.timestamp test.1.1
-8 Jun 1999 13:10:20
-
-GRASS 6.3.cvs > r.timestamp test.1.2
-9 Jun 1999 13:10:20
-
-GRASS 6.3.cvs > r.timestamp test.1.3
-14 Jan 2000 13:10:20
-
-GRASS 6.3.cvs > r.timestamp test.1.4
-24 Jan 2000 13:10:20
-

Copied: grass-addons/raster/r.rast4d/QuickStart.txt (from rev 30335, grass-addons/r.rast4d/QuickStart.txt)
===================================================================
--- grass-addons/raster/r.rast4d/QuickStart.txt	                        (rev 0)
+++ grass-addons/raster/r.rast4d/QuickStart.txt	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,75 @@
+You need:
+ - grass63
+ - sqlite3
+ - a valid grass location
+and the will to read sql and bash code if an error occures :)
+
+Be sure you are in a GRASS location!
+Stay in the directory containing the QuickStart file you are reading now,
+this is very important!
+The sqlite3 database will be created in the ./db/ directory.
+Use a graphical frontend to explore the database structure or read the 
+code in the sql directory.
+
+* ./r.rast4d.init
+Start r.rast4d.init to create the database,
+- if the database already exists, nothing will be performed
+- if you want to create a new database just remove the one in 
+  the ./db/ directory and run r.rast4d.init again
+
+* bin/tg.update
+Use tg.update to register/update your raster maps in the sqlite table
+
+* bin/tg.list
+Use tg.list to show the registered maps, performe sql where statements on the view
+and use the order option to order your data
+
+* bin/tg.remove
+Remove the raster map entries from the database
+The maps are not removed from grass!
+
+###########################################
+
+How to upload many raster maps?
+
+The maps need to have a valid time stamp (r.timestamp).
+Then (we assume a wildcard for raster names):
+
+ for i in `g.mlist type=rast pat="rastname*"` ; do
+   bin/tg.update $i
+ done
+
+###########################################
+Sören Gebbert 	
+to Markus, me
+Apr 5 2007
+
+Fertig,
+ich habe den Prototypen hoffentlich so modifiziert dass er mit Punkten im Namen umgehen kann.
+Außerdem werden die Raster timestamps (erzeugt mit r.timestamp) ausgewertet
+und die vtime_start mit dem ersten auftretenden timestamp gesetzt.
+
+Der erste timestamp sollte vollständig sein, sonst funzt es nicht.
+Es ist ein ziemlicher Hack weil ich in Eile bin. :/
+
+Beispiel mit 4 registrierten Maps:
+
+GRASS 6.3.cvs > bin/tg.list rast select=name,vtime_start
+select name,vtime_start from raster_view where ctime > DATETIME('1950-01-01 10:00:00') order by name
+test.1.1|1999-06-08 13:10:20
+test.1.2|1999-06-09 13:10:20
+test.1.3|2000-01-14 13:10:20
+test.1.4|2000-01-24 13:10:20
+
+GRASS 6.3.cvs > r.timestamp test.1.1
+8 Jun 1999 13:10:20
+
+GRASS 6.3.cvs > r.timestamp test.1.2
+9 Jun 1999 13:10:20
+
+GRASS 6.3.cvs > r.timestamp test.1.3
+14 Jan 2000 13:10:20
+
+GRASS 6.3.cvs > r.timestamp test.1.4
+24 Jan 2000 13:10:20
+

Deleted: grass-addons/raster/r.rast4d/README
===================================================================
--- grass-addons/r.rast4d/README	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.rast4d/README	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,15 +0,0 @@
-/****************************************************************************
- *
- * MODULE:       r.rast4d, tg.*
- * AUTHOR(S):    Sören Gebbert
- * PURPOSE:      To provide SQL based time series support for raster maps.
- *               Raster maps are registered in a SQLite table for easy retrieval
- *
- * COPYRIGHT:    (C) 2007 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.
- *
- *****************************************************************************/
-

Copied: grass-addons/raster/r.rast4d/README (from rev 30335, grass-addons/r.rast4d/README)
===================================================================
--- grass-addons/raster/r.rast4d/README	                        (rev 0)
+++ grass-addons/raster/r.rast4d/README	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,15 @@
+/****************************************************************************
+ *
+ * MODULE:       r.rast4d, tg.*
+ * AUTHOR(S):    Sören Gebbert
+ * PURPOSE:      To provide SQL based time series support for raster maps.
+ *               Raster maps are registered in a SQLite table for easy retrieval
+ *
+ * COPYRIGHT:    (C) 2007 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.
+ *
+ *****************************************************************************/
+

Deleted: grass-addons/raster/r.rast4d/TODO
===================================================================
--- grass-addons/r.rast4d/TODO	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.rast4d/TODO	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,20 +0,0 @@
-The following modules must be implemented:
- tg.copy -- to copy raster table entries + time + metadata
- tg.rename -- rename existing raster table entries + metadata + time
- t.info -- infos about temproal raster maps
- t.create -- to create temporal raster maps
- t.register -- register raster maps in the temporal datatypeas (temporal raster map)
- t.unregister -- unregister raster maps from temporal datatypes (temporal raster map)
-
-See also: lib/TODO
-
-FIXME
- VTIME_END: make controllable by user
-
-    lib/insert_raster.sh
-    ...
-    VTIME_START=$GLOBAL_DATE_VAR
-    VTIME_END="DATETIME('$VTIME_START', '+10 years')"
-
-    -> als Parameter in tg.update einbauen.
-

Copied: grass-addons/raster/r.rast4d/TODO (from rev 30335, grass-addons/r.rast4d/TODO)
===================================================================
--- grass-addons/raster/r.rast4d/TODO	                        (rev 0)
+++ grass-addons/raster/r.rast4d/TODO	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,20 @@
+The following modules must be implemented:
+ tg.copy -- to copy raster table entries + time + metadata
+ tg.rename -- rename existing raster table entries + metadata + time
+ t.info -- infos about temproal raster maps
+ t.create -- to create temporal raster maps
+ t.register -- register raster maps in the temporal datatypeas (temporal raster map)
+ t.unregister -- unregister raster maps from temporal datatypes (temporal raster map)
+
+See also: lib/TODO
+
+FIXME
+ VTIME_END: make controllable by user
+
+    lib/insert_raster.sh
+    ...
+    VTIME_START=$GLOBAL_DATE_VAR
+    VTIME_END="DATETIME('$VTIME_START', '+10 years')"
+
+    -> als Parameter in tg.update einbauen.
+

Copied: grass-addons/raster/r.rast4d/bin (from rev 30335, grass-addons/r.rast4d/bin)

Copied: grass-addons/raster/r.rast4d/db (from rev 30335, grass-addons/r.rast4d/db)

Copied: grass-addons/raster/r.rast4d/globals (from rev 30335, grass-addons/r.rast4d/globals)

Copied: grass-addons/raster/r.rast4d/lib (from rev 30335, grass-addons/r.rast4d/lib)

Deleted: grass-addons/raster/r.rast4d/r.rast4d.init
===================================================================
--- grass-addons/r.rast4d/r.rast4d.init	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.rast4d/r.rast4d.init	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-source globals/defines.sh
-
-if [ ! -f $DATABASE ]
-  then
-  init_db.sh
-else
-  echo "$DATABASE already exists. Doing nothing. Remove that DB file to start over"
-fi

Copied: grass-addons/raster/r.rast4d/r.rast4d.init (from rev 30335, grass-addons/r.rast4d/r.rast4d.init)
===================================================================
--- grass-addons/raster/r.rast4d/r.rast4d.init	                        (rev 0)
+++ grass-addons/raster/r.rast4d/r.rast4d.init	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+source globals/defines.sh
+
+if [ ! -f $DATABASE ]
+  then
+  init_db.sh
+else
+  echo "$DATABASE already exists. Doing nothing. Remove that DB file to start over"
+fi

Copied: grass-addons/raster/r.rast4d/sql (from rev 30335, grass-addons/r.rast4d/sql)

Deleted: grass-addons/raster/r.rast4d/test.csv
===================================================================
--- grass-addons/r.rast4d/test.csv	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/raster/r.rast4d/test.csv	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,21 +0,0 @@
-year|month|m_decade|obs_m_decade_days|precip_mean_daily_md|precip_days_md|tmin_mean_md|obs_tmin_mean_md|tmax_mean_md|obs_tmax_mean_md
-1961|1|1|10|6.2|6|2.5|10|6.8|10
-1961|1|2|10|6.48|3|-0.7|10|5.2|10
-1961|1|3|11|0.04|2|-1.27|11|4.82|11
-1961|2|1|10|2.2|3|1.3|10|8.7|10
-1961|2|2|10|0|0|3.6|10|14.4|10
-1961|2|3|8|0|0|4.25|8|13.63|8
-1961|3|1|10|0.22|2|4.9|10|16.5|10
-1961|3|2|10|1.6|2|7.1|10|18.4|10
-1961|3|3|11|0|0|4.45|11|14.82|11
-1961|4|1|10|2.62|5|11|10|19.1|10
-1961|4|2|10|5.74|7|11.5|10|20.8|10
-1961|4|3|10|5.9|8|11.5|10|19.8|10
-1961|5|1|10|5.6|4|12.5|10|22.7|10
-1961|5|2|10|3.38|3|10.2|10|20.3|10
-1961|5|3|11|10.73|8|12.18|11|21.18|11
-1961|6|1|10|7.88|9|14.1|10|22.3|10
-1961|6|2|10|3.38|5|16.1|10|26.6|10
-1961|6|3|10|11.34|4|18.7|10|29.6|10
-1961|7|1|10|2.54|1|17.2|10|27.5|10
-1961|7|2|10|8.56|7|16.1|10|26.1|10

Copied: grass-addons/raster/r.rast4d/test.csv (from rev 30335, grass-addons/r.rast4d/test.csv)
===================================================================
--- grass-addons/raster/r.rast4d/test.csv	                        (rev 0)
+++ grass-addons/raster/r.rast4d/test.csv	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,21 @@
+year|month|m_decade|obs_m_decade_days|precip_mean_daily_md|precip_days_md|tmin_mean_md|obs_tmin_mean_md|tmax_mean_md|obs_tmax_mean_md
+1961|1|1|10|6.2|6|2.5|10|6.8|10
+1961|1|2|10|6.48|3|-0.7|10|5.2|10
+1961|1|3|11|0.04|2|-1.27|11|4.82|11
+1961|2|1|10|2.2|3|1.3|10|8.7|10
+1961|2|2|10|0|0|3.6|10|14.4|10
+1961|2|3|8|0|0|4.25|8|13.63|8
+1961|3|1|10|0.22|2|4.9|10|16.5|10
+1961|3|2|10|1.6|2|7.1|10|18.4|10
+1961|3|3|11|0|0|4.45|11|14.82|11
+1961|4|1|10|2.62|5|11|10|19.1|10
+1961|4|2|10|5.74|7|11.5|10|20.8|10
+1961|4|3|10|5.9|8|11.5|10|19.8|10
+1961|5|1|10|5.6|4|12.5|10|22.7|10
+1961|5|2|10|3.38|3|10.2|10|20.3|10
+1961|5|3|11|10.73|8|12.18|11|21.18|11
+1961|6|1|10|7.88|9|14.1|10|22.3|10
+1961|6|2|10|3.38|5|16.1|10|26.6|10
+1961|6|3|10|11.34|4|18.7|10|29.6|10
+1961|7|1|10|2.54|1|17.2|10|27.5|10
+1961|7|2|10|8.56|7|16.1|10|26.1|10

Copied: grass-addons/raster/r.sun_horizon (from rev 30334, grass-addons/r.sun_horizon)

Copied: grass-addons/raster/r.sun_horizon/r.horizon (from rev 30335, grass-addons/r.sun_horizon/r.horizon)

Copied: grass-addons/raster/r.sun_horizon/r.sun2 (from rev 30335, grass-addons/r.sun_horizon/r.sun2)

Copied: grass-addons/vector/v.curvature (from rev 30334, grass-addons/v.curvature)

Deleted: grass-addons/vector/v.curvature/Makefile
===================================================================
--- grass-addons/v.curvature/Makefile	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/vector/v.curvature/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,13 +0,0 @@
-MODULE_TOPDIR = ../..
-
-PGM = v.curvature
-
-LIBES = $(VECTLIB) $(GISLIB)
-DEPENDENCIES= $(VECTDEP) $(GISDEP)
-EXTRA_INC = $(VECT_INC)
-EXTRA_CFLAGS = $(VECT_CFLAGS)
-
-include $(MODULE_TOPDIR)/include/Make/Module.make
-
-default: cmd
-

Copied: grass-addons/vector/v.curvature/Makefile (from rev 30335, grass-addons/v.curvature/Makefile)
===================================================================
--- grass-addons/vector/v.curvature/Makefile	                        (rev 0)
+++ grass-addons/vector/v.curvature/Makefile	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,13 @@
+MODULE_TOPDIR = ../..
+
+PGM = v.curvature
+
+LIBES = $(VECTLIB) $(GISLIB)
+DEPENDENCIES= $(VECTDEP) $(GISDEP)
+EXTRA_INC = $(VECT_INC)
+EXTRA_CFLAGS = $(VECT_CFLAGS)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd
+

Deleted: grass-addons/vector/v.curvature/description.html
===================================================================
--- grass-addons/v.curvature/description.html	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/vector/v.curvature/description.html	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,49 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>v.curvature</em> calculates average curvature along a segment
-given by from/to distance measured along the line specified by
-category.
-<P>
-For individual straight parts of the line, the average curvature as
-calculated from directions of adjacent parts. An average of specified
-segment is then calculated as average from curvatures of line parts
-(lengths of line parts overlapped by specified segment are taken into
-acount).
-<P>
-This method may be used only if line data digitized with appropriate
-accuracy, where 'appropriate' depend on an application we want to use
-it for and on the length of the segment we want to calculate the
-curvature for.
-<P>
-If user needs curvature for too small segments compared to the density
-of vertices on lines, the lines should be smoothed beforehand with
-some other module (this approach is preferred to internal smoothing
-(interpolating) within v.curvature, because automatic smoothing may
-often result in unexpected, unwanted shapes, and user should see which
-data are really processed).
-<P>
-With the 'segment' option, the module reads from 'stdin':
-<ul>
-<li> segment_id line_category from to
-<li> segment_id - identifier for one segment we need curvature for
-<ul>
-  <li>line_category - category of line the segment is on:
-  <ul>
-    <li>from - distance of segment start from the beginnig of the line
-    <li>to - distance of end of segment from the beginnig of the line
-  </ul>
-</ul>
-Note that if segment limits may exceed the line, segment is cut
-by line ends.
-</ul>
-
-Output is written to 'stdout' in format:
-<div class="code"><pre>
-  segment_id average_curvature average_radius
-</pre></div>
-
-<h2>AUTHOR</h2>
-
-Radim Blazek, ITC-Irst, Trento, Italy
-
-<p><i>Last changed: $Date: 2006/01/02 14:44:51 $</i>

Copied: grass-addons/vector/v.curvature/description.html (from rev 30335, grass-addons/v.curvature/description.html)
===================================================================
--- grass-addons/vector/v.curvature/description.html	                        (rev 0)
+++ grass-addons/vector/v.curvature/description.html	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,49 @@
+<h2>DESCRIPTION</h2>
+
+<em>v.curvature</em> calculates average curvature along a segment
+given by from/to distance measured along the line specified by
+category.
+<P>
+For individual straight parts of the line, the average curvature as
+calculated from directions of adjacent parts. An average of specified
+segment is then calculated as average from curvatures of line parts
+(lengths of line parts overlapped by specified segment are taken into
+acount).
+<P>
+This method may be used only if line data digitized with appropriate
+accuracy, where 'appropriate' depend on an application we want to use
+it for and on the length of the segment we want to calculate the
+curvature for.
+<P>
+If user needs curvature for too small segments compared to the density
+of vertices on lines, the lines should be smoothed beforehand with
+some other module (this approach is preferred to internal smoothing
+(interpolating) within v.curvature, because automatic smoothing may
+often result in unexpected, unwanted shapes, and user should see which
+data are really processed).
+<P>
+With the 'segment' option, the module reads from 'stdin':
+<ul>
+<li> segment_id line_category from to
+<li> segment_id - identifier for one segment we need curvature for
+<ul>
+  <li>line_category - category of line the segment is on:
+  <ul>
+    <li>from - distance of segment start from the beginnig of the line
+    <li>to - distance of end of segment from the beginnig of the line
+  </ul>
+</ul>
+Note that if segment limits may exceed the line, segment is cut
+by line ends.
+</ul>
+
+Output is written to 'stdout' in format:
+<div class="code"><pre>
+  segment_id average_curvature average_radius
+</pre></div>
+
+<h2>AUTHOR</h2>
+
+Radim Blazek, ITC-Irst, Trento, Italy
+
+<p><i>Last changed: $Date: 2006/01/02 14:44:51 $</i>

Deleted: grass-addons/vector/v.curvature/main.c
===================================================================
--- grass-addons/v.curvature/main.c	2008-02-24 22:04:08 UTC (rev 30334)
+++ grass-addons/vector/v.curvature/main.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -1,358 +0,0 @@
-/****************************************************************
-* 
-*  MODULE:       v.curvature
-*  
-*  AUTHOR(S):    Radim Blazek
-*                
-*  PURPOSE:      Calculate something similar to curvature of line
-*                in specified segment. Module reads from stdin:
-*                
-*                  segment_id line_category from to
-*                
-*                  segment_id - identifier for one segment we need curvature for 
-*                  line_category - category of line the segment is on
-*                  from - distance of segment start from the beginnig of the line
-*                  to - distance of end of segment from the beginnig of the line
-*
-*                Note that if segment limits may exceed the line, segment is cuted
-*                by line ends.
-*
-*                Output is written to stdout in format:
-*
-*                  segment_id average_curvature average_radius
-*                
-*                
-*  COPYRIGHT:    (C) 2001 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.
-* 
-****************************************************************/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <grass/gis.h>
-#include <grass/Vect.h>
-#include <grass/glocale.h>
-
-#define OPTION_SEGMENT 1
-#define OPTION_LINES   2
-
-
-double calc_curv (struct line_pnts *Points, int part);
-double part_length (struct line_pnts *Points, int part);
-
-int 
-main (int argc, char *argv[])
-{
-    int    i, row;
-    char   buf[1024];
-    struct Map_info Map;
-    struct line_pnts *Points;
-    struct line_cats *Cats;
-    int    field, type, ctype, action;
-    int    id, cat, ccat, part, end;
-    double from, to, rad;
-    double line_len, seg_len, calc_len, part_len, rest_len, dist, len;
-    double x, y, z, dx, dy, dz;
-    double cur, curva;
-    int field_index, cinlines;
-    struct GModule *module;
-    struct Option *map_opt, *type_opt, *field_opt, *act_opt;
-    struct Flag *abs_flag;
-
-    module = G_define_module();
-    module->keywords = _("vector, segment, curvature");
-    module->description = _("Calculate curvature. With segment option it reads from standard input:\n"
-			  "segment_id line_category from to\n"
-			  "and writes to standard output:\n"
-			  "segment_id average_curvature average_radius\n"
-			  "If a segment given runs outside the line, it is cut. "
-			  "If more lines with the same category "
-			  "are found, curvature is not calculated and warning is printed.");
-
-    map_opt = G_define_standard_option(G_OPT_V_INPUT);
-    map_opt->key = "map";
-    
-    type_opt = G_define_standard_option(G_OPT_V_TYPE) ;
-    type_opt->options = "line,boundary";
-    type_opt->answer = "line";
-
-    field_opt = G_define_standard_option(G_OPT_V_FIELD);
-
-    act_opt = G_define_option() ;
-    act_opt->key        = "option" ;
-    act_opt->type       = TYPE_STRING ;
-    act_opt->required   = NO ;
-    act_opt->multiple   = NO;
-    act_opt->answer     = "segment" ;
-    act_opt->options    = "segment,lines";
-    act_opt->description= _("Option");
-    act_opt->descriptions= _("segment; reads segments from standard input;"
-			   "lines; calculate curvature for all sements of all lines");
-    
-    abs_flag = G_define_flag ();
-    abs_flag->key         = 'a';
-    abs_flag->description = _("Calculate average from absolute values "
-			    "(if not used, segment over 2 successive contrary "
-			    "curves can result in curvature near 0).");
-    
-    G_gisinit(argv[0]);
-    if (G_parser (argc, argv))
-	exit(EXIT_FAILURE); 
-    
-    field = atoi( field_opt->answer );
-    
-    i = 0;
-    ctype = 0;
-    while (type_opt->answers[i])
-    {
-	switch ( type_opt->answers[i][0] )
-	{
-	    case 'l':
-		ctype |= GV_LINE;
-		break;
-	    case 'b':
-		ctype |= GV_BOUNDARY;
-		break;
-	}
-	i++;
-    }
-
-    action = OPTION_SEGMENT;
-    if ( act_opt->answer[0] == 'l' )
-        action = OPTION_LINES;
-
-    Points = Vect_new_line_struct ();
-    Cats = Vect_new_cats_struct ();
-    
-    /* open input vector */
-    Vect_set_open_level (2); 
-    Vect_open_old (&Map, map_opt->answer, "");
-
-    cinlines = Vect_cidx_get_type_count ( &Map, field, ctype);
-
-    if ( cinlines == 0 ) 
-    { 
-	G_warning ( _("No lines in layer %d"), field );
-    }
-
-    if ( action == OPTION_SEGMENT && cinlines > 0 ) {
-	int idx, line, type, cincats, dummy1, dummy2;
-
-	field_index = Vect_cidx_get_field_index ( &Map, field );
-	cincats = Vect_cidx_get_num_cats_by_index ( &Map, field_index );
-        G_debug ( 3, "cincats = %d", cincats );
-
-	row = 0;
-	while ( fgets(buf,1024,stdin) != NULL ) {
-	    row++;
-	    if ( sscanf(buf, "%d %d %lf %lf", &id, &ccat, &from, &to) != 4 ) {
-		 G_warning (_("Incorrect format on row %d: %s"), row, buf); 
-		 continue;
-	    }
-
-	    G_debug (2, "read: %d %d %f %f", id, ccat, from, to);
-
-	    /* Find line by category */
-	    idx = Vect_cidx_find_next ( &Map, field_index, ccat, ctype, 0, &type, &line );
-	
-            if ( idx < 0 ) {
-		G_warning ( _("Line with category %d not found"), ccat );
-		fprintf (stdout, "%d - -\n", id);
-		continue;
-	    }
-        
-            if ( (idx + 1 < cincats) &&
-		 Vect_cidx_find_next ( &Map, field_index, ccat, ctype, idx+1, &dummy1, &dummy2 ) >= 0 )
-            {
-		/* Second line found */
-		G_warning ( _("More lines with category %d found"), ccat );
-		fprintf (stdout, "%d - -\n", id);
-		continue;
-	    }
-	    
-	    Vect_read_line ( &Map, Points, Cats, line );
-		
-	    G_debug (2, "n_points = %d", Points->n_points );
-	    if ( Points->n_points < 2 ) {
-		G_warning ( _("Degenerated line with category %d"), ccat );
-		fprintf (stdout, "%d - -\n", id);
-		continue; 
-	    }
-
-	    line_len = Vect_line_length (Points);
-	    
-	    if ( from > line_len || to < 0 ) { 
-		G_warning ( _("Segment outside the line (id = %d)"), id );
-		fprintf (stdout, "%d - -\n", id);
-		continue;
-	    }
-	    
-	    if ( from < 0 ) {
-		G_warning ( _("Start of segment %d < 0"), id );
-		from = 0.;
-	    }
-	    if ( to > line_len ) {
-		G_warning ( _("End of segment %d > line length"), id );
-		to = line_len;
-	    }	
-	    seg_len = to - from;
-	    G_debug (2, "seg_len = %f", seg_len);
-	    
-	    /* first segment */
-	    part = Vect_point_on_line ( Points, from, &x, &y, &z, NULL, NULL );
-	    G_debug (2, "first part = %d", part);
-
-	    /* distance from the beginnig of line part */
-	    dx = x - Points->x[part-1];
-	    dy = y - Points->y[part-1];
-	    dz = z - Points->z[part-1];
-	    dist = hypot (dx, dy);
-	    dist = hypot (dist, dz);
-	    
-	    calc_len = 0; curva = 0; end = 0;
-	    for ( i = part; i < Points->n_points; i++ ) {
-		G_debug (2, "i = %d", i);
-		
-		part_len = part_length (Points, i);
-		cur = calc_curv (Points, i);
-		if (abs_flag->answer && (cur < 0) ) cur = -cur;
-		
-		rest_len = seg_len - calc_len;
-
-		/* length of used part of part */	
-		if ( part_len >= (rest_len + dist) ) { /* end of segment reached */
-		    len =  rest_len;
-		    end = 1;
-		} else {
-		    len = part_len - dist;
-		}
-		G_debug (2, "part_len = %f len = %f", part_len, len);
-	
-	  
-		/* cumulate curvature */
-		curva += cur * len; 
-		G_debug (2, "curva = %f", curva );
-		
-		calc_len += len; 
-		
-		if ( end ) break;
-		
-		dist = 0; /* start of segment from the beginnig of part for next parts */
-	    }
-
-	    curva /= seg_len; 
-	    rad = 1 / curva;        
-	   
-	    fprintf (stdout, "%d %f %f\n", id, curva, rad);
-	    fflush (stdout);
-	}
-    } else if ( OPTION_LINES && cinlines > 0 ) { 
-	Vect_rewind ( &Map );
-	while ( (type = Vect_read_next_line (&Map, Points, Cats)) > 0) {
-	    if ( !(type & ctype) ) continue;
-	    
-            /* TODO: more cats int the same layer */ 
-	    cat = 0;
-	    if( Vect_cat_get(Cats, field, &cat) == 0 ) {
-		continue;
-	    }
-       
-	    G_debug (2, "n_points = %d", Points->n_points );
-	    if ( Points->n_points < 2 ) {
-		G_warning ( _("Degenerated line with category %d"), ccat );
-		continue; 
-	    }
-
-	    for ( part = 1; part < Points->n_points; part++ ) {
-		G_debug (2, "part = %d", part);
-		
-		part_len = part_length (Points, part);
-		cur = calc_curv (Points, part);
-                if (abs_flag->answer && (cur < 0) ) cur = -cur;
-
-		rad = 1 / cur;        
-	       
-		fprintf (stdout, "%d %f %f %f\n", cat, part_len, cur, rad);
-		fflush (stdout);
-	    }
-	}
-    }
-
-    Vect_close (&Map);
-
-    exit(EXIT_SUCCESS) ;
-}
-
-/* Calculate curvature of segment */
-double calc_curv (struct line_pnts *Points, int part)
-{
-    double part_len;
-    double dx, dy;
-    double ang, ang1, ang2, part_ang, cur;
-
-    /* segment angle */     
-    dx = Points->x[part] - Points->x[part-1];
-    dy = Points->y[part] - Points->y[part-1];
-    part_ang = atan2 ( dy, dx );  
-    G_debug (2, "part: dx = %f dy = %f part_ang = %f", dx, dy, part_ang);
-    
-    /* angle 1 */
-    if ( part == 1 ) { /* first segment */
-	ang1 = 0;
-	G_debug (2, "1: first seg ang1 = 0");
-    } else { 
-	dx = Points->x[part-1] - Points->x[part-2];
-	dy = Points->y[part-1] - Points->y[part-2];
-	ang = atan2 ( dy, dx );  
-	ang1 = part_ang - ang;  
-	G_debug (2, "1: %d->%d: %f, %f -> %f, %f",part-2,part-1,
-		    Points->x[part-2], Points->y[part-2],  Points->x[part-1], Points->y[part-1] );
-	G_debug (2, "1: dx = %f dy = %.10f ang = %f, ang1 = %f", dx, dy, ang, ang1);
-	if ( ang1 < -M_PI ) ang1 += 2 * M_PI;
-	if ( ang1 >  M_PI ) ang1 -= 2 * M_PI;
-	G_debug (2, "1: -> ang1 = %f", ang1);
-    }
-    /* angle 2 */
-    if ( part == Points->n_points - 1 ) { /* last segment */
-	ang2 = 0;
-	G_debug (2, "2: last seg ang2 = 0");
-    } else { 
-	dx = Points->x[part+1] - Points->x[part];
-	dy = Points->y[part+1] - Points->y[part];
-	ang = atan2 ( dy, dx );
-	ang2 = ang - part_ang;
-	G_debug (2, "2: %d->%d: %f, %f -> %f, %f",part,part+1,
-		    Points->x[part+1], Points->y[part+1],  Points->x[part], Points->y[part] );
-	G_debug (2, "2: dx = %f dy = %.10f ang = %f ang2 = %f", dx, dy, ang, ang2);
-	if ( ang2 < -M_PI ) ang2 += 2 * M_PI;
-	if ( ang2 >  M_PI ) ang2 -= 2 * M_PI;
-	G_debug (2, "2: -> ang2 = %f", ang2);
-    }
-    
-    /* curvature */
-    part_len = part_length (Points, part);
-    cur =  2 * sin ( (ang1 + ang2) / 4 ) / part_len ;
-
-    G_debug (2, "cur = %f R = %f", cur, 1/cur );
-
-    return cur;
-}
-
-double part_length (struct line_pnts *Points, int part) {
-    double dx, dy, dz, len;
-    
-    /* length of segment */
-    dx = Points->x[part] - Points->x[part-1];
-    dy = Points->y[part] - Points->y[part-1];
-    dz = Points->z[part] - Points->z[part-1];
-    len = hypot (dx, dy);
-    len = hypot (len, dz);
-
-    return len;
-}
-

Copied: grass-addons/vector/v.curvature/main.c (from rev 30335, grass-addons/v.curvature/main.c)
===================================================================
--- grass-addons/vector/v.curvature/main.c	                        (rev 0)
+++ grass-addons/vector/v.curvature/main.c	2008-02-24 22:17:58 UTC (rev 30336)
@@ -0,0 +1,358 @@
+/****************************************************************
+* 
+*  MODULE:       v.curvature
+*  
+*  AUTHOR(S):    Radim Blazek
+*                
+*  PURPOSE:      Calculate something similar to curvature of line
+*                in specified segment. Module reads from stdin:
+*                
+*                  segment_id line_category from to
+*                
+*                  segment_id - identifier for one segment we need curvature for 
+*                  line_category - category of line the segment is on
+*                  from - distance of segment start from the beginnig of the line
+*                  to - distance of end of segment from the beginnig of the line
+*
+*                Note that if segment limits may exceed the line, segment is cuted
+*                by line ends.
+*
+*                Output is written to stdout in format:
+*
+*                  segment_id average_curvature average_radius
+*                
+*                
+*  COPYRIGHT:    (C) 2001 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.
+* 
+****************************************************************/
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <grass/gis.h>
+#include <grass/Vect.h>
+#include <grass/glocale.h>
+
+#define OPTION_SEGMENT 1
+#define OPTION_LINES   2
+
+
+double calc_curv (struct line_pnts *Points, int part);
+double part_length (struct line_pnts *Points, int part);
+
+int 
+main (int argc, char *argv[])
+{
+    int    i, row;
+    char   buf[1024];
+    struct Map_info Map;
+    struct line_pnts *Points;
+    struct line_cats *Cats;
+    int    field, type, ctype, action;
+    int    id, cat, ccat, part, end;
+    double from, to, rad;
+    double line_len, seg_len, calc_len, part_len, rest_len, dist, len;
+    double x, y, z, dx, dy, dz;
+    double cur, curva;
+    int field_index, cinlines;
+    struct GModule *module;
+    struct Option *map_opt, *type_opt, *field_opt, *act_opt;
+    struct Flag *abs_flag;
+
+    module = G_define_module();
+    module->keywords = _("vector, segment, curvature");
+    module->description = _("Calculate curvature. With segment option it reads from standard input:\n"
+			  "segment_id line_category from to\n"
+			  "and writes to standard output:\n"
+			  "segment_id average_curvature average_radius\n"
+			  "If a segment given runs outside the line, it is cut. "
+			  "If more lines with the same category "
+			  "are found, curvature is not calculated and warning is printed.");
+
+    map_opt = G_define_standard_option(G_OPT_V_INPUT);
+    map_opt->key = "map";
+    
+    type_opt = G_define_standard_option(G_OPT_V_TYPE) ;
+    type_opt->options = "line,boundary";
+    type_opt->answer = "line";
+
+    field_opt = G_define_standard_option(G_OPT_V_FIELD);
+
+    act_opt = G_define_option() ;
+    act_opt->key        = "option" ;
+    act_opt->type       = TYPE_STRING ;
+    act_opt->required   = NO ;
+    act_opt->multiple   = NO;
+    act_opt->answer     = "segment" ;
+    act_opt->options    = "segment,lines";
+    act_opt->description= _("Option");
+    act_opt->descriptions= _("segment; reads segments from standard input;"
+			   "lines; calculate curvature for all sements of all lines");
+    
+    abs_flag = G_define_flag ();
+    abs_flag->key         = 'a';
+    abs_flag->description = _("Calculate average from absolute values "
+			    "(if not used, segment over 2 successive contrary "
+			    "curves can result in curvature near 0).");
+    
+    G_gisinit(argv[0]);
+    if (G_parser (argc, argv))
+	exit(EXIT_FAILURE); 
+    
+    field = atoi( field_opt->answer );
+    
+    i = 0;
+    ctype = 0;
+    while (type_opt->answers[i])
+    {
+	switch ( type_opt->answers[i][0] )
+	{
+	    case 'l':
+		ctype |= GV_LINE;
+		break;
+	    case 'b':
+		ctype |= GV_BOUNDARY;
+		break;
+	}
+	i++;
+    }
+
+    action = OPTION_SEGMENT;
+    if ( act_opt->answer[0] == 'l' )
+        action = OPTION_LINES;
+
+    Points = Vect_new_line_struct ();
+    Cats = Vect_new_cats_struct ();
+    
+    /* open input vector */
+    Vect_set_open_level (2); 
+    Vect_open_old (&Map, map_opt->answer, "");
+
+    cinlines = Vect_cidx_get_type_count ( &Map, field, ctype);
+
+    if ( cinlines == 0 ) 
+    { 
+	G_warning ( _("No lines in layer %d"), field );
+    }
+
+    if ( action == OPTION_SEGMENT && cinlines > 0 ) {
+	int idx, line, type, cincats, dummy1, dummy2;
+
+	field_index = Vect_cidx_get_field_index ( &Map, field );
+	cincats = Vect_cidx_get_num_cats_by_index ( &Map, field_index );
+        G_debug ( 3, "cincats = %d", cincats );
+
+	row = 0;
+	while ( fgets(buf,1024,stdin) != NULL ) {
+	    row++;
+	    if ( sscanf(buf, "%d %d %lf %lf", &id, &ccat, &from, &to) != 4 ) {
+		 G_warning (_("Incorrect format on row %d: %s"), row, buf); 
+		 continue;
+	    }
+
+	    G_debug (2, "read: %d %d %f %f", id, ccat, from, to);
+
+	    /* Find line by category */
+	    idx = Vect_cidx_find_next ( &Map, field_index, ccat, ctype, 0, &type, &line );
+	
+            if ( idx < 0 ) {
+		G_warning ( _("Line with category %d not found"), ccat );
+		fprintf (stdout, "%d - -\n", id);
+		continue;
+	    }
+        
+            if ( (idx + 1 < cincats) &&
+		 Vect_cidx_find_next ( &Map, field_index, ccat, ctype, idx+1, &dummy1, &dummy2 ) >= 0 )
+            {
+		/* Second line found */
+		G_warning ( _("More lines with category %d found"), ccat );
+		fprintf (stdout, "%d - -\n", id);
+		continue;
+	    }
+	    
+	    Vect_read_line ( &Map, Points, Cats, line );
+		
+	    G_debug (2, "n_points = %d", Points->n_points );
+	    if ( Points->n_points < 2 ) {
+		G_warning ( _("Degenerated line with category %d"), ccat );
+		fprintf (stdout, "%d - -\n", id);
+		continue; 
+	    }
+
+	    line_len = Vect_line_length (Points);
+	    
+	    if ( from > line_len || to < 0 ) { 
+		G_warning ( _("Segment outside the line (id = %d)"), id );
+		fprintf (stdout, "%d - -\n", id);
+		continue;
+	    }
+	    
+	    if ( from < 0 ) {
+		G_warning ( _("Start of segment %d < 0"), id );
+		from = 0.;
+	    }
+	    if ( to > line_len ) {
+		G_warning ( _("End of segment %d > line length"), id );
+		to = line_len;
+	    }	
+	    seg_len = to - from;
+	    G_debug (2, "seg_len = %f", seg_len);
+	    
+	    /* first segment */
+	    part = Vect_point_on_line ( Points, from, &x, &y, &z, NULL, NULL );
+	    G_debug (2, "first part = %d", part);
+
+	    /* distance from the beginnig of line part */
+	    dx = x - Points->x[part-1];
+	    dy = y - Points->y[part-1];
+	    dz = z - Points->z[part-1];
+	    dist = hypot (dx, dy);
+	    dist = hypot (dist, dz);
+	    
+	    calc_len = 0; curva = 0; end = 0;
+	    for ( i = part; i < Points->n_points; i++ ) {
+		G_debug (2, "i = %d", i);
+		
+		part_len = part_length (Points, i);
+		cur = calc_curv (Points, i);
+		if (abs_flag->answer && (cur < 0) ) cur = -cur;
+		
+		rest_len = seg_len - calc_len;
+
+		/* length of used part of part */	
+		if ( part_len >= (rest_len + dist) ) { /* end of segment reached */
+		    len =  rest_len;
+		    end = 1;
+		} else {
+		    len = part_len - dist;
+		}
+		G_debug (2, "part_len = %f len = %f", part_len, len);
+	
+	  
+		/* cumulate curvature */
+		curva += cur * len; 
+		G_debug (2, "curva = %f", curva );
+		
+		calc_len += len; 
+		
+		if ( end ) break;
+		
+		dist = 0; /* start of segment from the beginnig of part for next parts */
+	    }
+
+	    curva /= seg_len; 
+	    rad = 1 / curva;        
+	   
+	    fprintf (stdout, "%d %f %f\n", id, curva, rad);
+	    fflush (stdout);
+	}
+    } else if ( OPTION_LINES && cinlines > 0 ) { 
+	Vect_rewind ( &Map );
+	while ( (type = Vect_read_next_line (&Map, Points, Cats)) > 0) {
+	    if ( !(type & ctype) ) continue;
+	    
+            /* TODO: more cats int the same layer */ 
+	    cat = 0;
+	    if( Vect_cat_get(Cats, field, &cat) == 0 ) {
+		continue;
+	    }
+       
+	    G_debug (2, "n_points = %d", Points->n_points );
+	    if ( Points->n_points < 2 ) {
+		G_warning ( _("Degenerated line with category %d"), ccat );
+		continue; 
+	    }
+
+	    for ( part = 1; part < Points->n_points; part++ ) {
+		G_debug (2, "part = %d", part);
+		
+		part_len = part_length (Points, part);
+		cur = calc_curv (Points, part);
+                if (abs_flag->answer && (cur < 0) ) cur = -cur;
+
+		rad = 1 / cur;        
+	       
+		fprintf (stdout, "%d %f %f %f\n", cat, part_len, cur, rad);
+		fflush (stdout);
+	    }
+	}
+    }
+
+    Vect_close (&Map);
+
+    exit(EXIT_SUCCESS) ;
+}
+
+/* Calculate curvature of segment */
+double calc_curv (struct line_pnts *Points, int part)
+{
+    double part_len;
+    double dx, dy;
+    double ang, ang1, ang2, part_ang, cur;
+
+    /* segment angle */     
+    dx = Points->x[part] - Points->x[part-1];
+    dy = Points->y[part] - Points->y[part-1];
+    part_ang = atan2 ( dy, dx );  
+    G_debug (2, "part: dx = %f dy = %f part_ang = %f", dx, dy, part_ang);
+    
+    /* angle 1 */
+    if ( part == 1 ) { /* first segment */
+	ang1 = 0;
+	G_debug (2, "1: first seg ang1 = 0");
+    } else { 
+	dx = Points->x[part-1] - Points->x[part-2];
+	dy = Points->y[part-1] - Points->y[part-2];
+	ang = atan2 ( dy, dx );  
+	ang1 = part_ang - ang;  
+	G_debug (2, "1: %d->%d: %f, %f -> %f, %f",part-2,part-1,
+		    Points->x[part-2], Points->y[part-2],  Points->x[part-1], Points->y[part-1] );
+	G_debug (2, "1: dx = %f dy = %.10f ang = %f, ang1 = %f", dx, dy, ang, ang1);
+	if ( ang1 < -M_PI ) ang1 += 2 * M_PI;
+	if ( ang1 >  M_PI ) ang1 -= 2 * M_PI;
+	G_debug (2, "1: -> ang1 = %f", ang1);
+    }
+    /* angle 2 */
+    if ( part == Points->n_points - 1 ) { /* last segment */
+	ang2 = 0;
+	G_debug (2, "2: last seg ang2 = 0");
+    } else { 
+	dx = Points->x[part+1] - Points->x[part];
+	dy = Points->y[part+1] - Points->y[part];
+	ang = atan2 ( dy, dx );
+	ang2 = ang - part_ang;
+	G_debug (2, "2: %d->%d: %f, %f -> %f, %f",part,part+1,
+		    Points->x[part+1], Points->y[part+1],  Points->x[part], Points->y[part] );
+	G_debug (2, "2: dx = %f dy = %.10f ang = %f ang2 = %f", dx, dy, ang, ang2);
+	if ( ang2 < -M_PI ) ang2 += 2 * M_PI;
+	if ( ang2 >  M_PI ) ang2 -= 2 * M_PI;
+	G_debug (2, "2: -> ang2 = %f", ang2);
+    }
+    
+    /* curvature */
+    part_len = part_length (Points, part);
+    cur =  2 * sin ( (ang1 + ang2) / 4 ) / part_len ;
+
+    G_debug (2, "cur = %f R = %f", cur, 1/cur );
+
+    return cur;
+}
+
+double part_length (struct line_pnts *Points, int part) {
+    double dx, dy, dz, len;
+    
+    /* length of segment */
+    dx = Points->x[part] - Points->x[part-1];
+    dy = Points->y[part] - Points->y[part-1];
+    dz = Points->z[part] - Points->z[part-1];
+    len = hypot (dx, dy);
+    len = hypot (len, dz);
+
+    return len;
+}
+



More information about the grass-commit mailing list