From neteler at grass.itc.it Fri Jun 1 01:50:14 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Fri Jun 1 01:50:24 2007 Subject: [grass-addons] r763 - in trunk/grassaddons: . i.pr i.pr/PRLIB i.pr/doc i.pr/i.pr_blob i.pr/i.pr_classify i.pr/i.pr_features i.pr/i.pr_features_additional i.pr/i.pr_features_extract i.pr/i.pr_features_selection i.pr/i.pr_model i.pr/i.pr_sites_aggregate i.pr/i.pr_statistics i.pr/i.pr_subsets i.pr/i.pr_subsets/old i.pr/i.pr_training i.pr/i.pr_uxb i.pr/include Message-ID: <200705312350.l4VNoEs3004219@grass.itc.it> Author: neteler Date: 2007-06-01 01:49:13 +0200 (Fri, 01 Jun 2007) New Revision: 763 Added: trunk/grassaddons/i.pr/ trunk/grassaddons/i.pr/Makefile trunk/grassaddons/i.pr/PRLIB/ trunk/grassaddons/i.pr/PRLIB/.so trunk/grassaddons/i.pr/PRLIB/Makefile trunk/grassaddons/i.pr/PRLIB/blob.c trunk/grassaddons/i.pr/PRLIB/bootstrap.c trunk/grassaddons/i.pr/PRLIB/dist.c trunk/grassaddons/i.pr/PRLIB/eigen.c trunk/grassaddons/i.pr/PRLIB/entropy.c trunk/grassaddons/i.pr/PRLIB/extract_functions.pl trunk/grassaddons/i.pr/PRLIB/extract_ps.pl trunk/grassaddons/i.pr/PRLIB/features.c trunk/grassaddons/i.pr/PRLIB/features_selection.c trunk/grassaddons/i.pr/PRLIB/getline.c trunk/grassaddons/i.pr/PRLIB/gm.c trunk/grassaddons/i.pr/PRLIB/integration.c trunk/grassaddons/i.pr/PRLIB/lu.c trunk/grassaddons/i.pr/PRLIB/matrix.c trunk/grassaddons/i.pr/PRLIB/min_quadratic.c trunk/grassaddons/i.pr/PRLIB/nn.c trunk/grassaddons/i.pr/PRLIB/open.c trunk/grassaddons/i.pr/PRLIB/pca.c trunk/grassaddons/i.pr/PRLIB/percent.c trunk/grassaddons/i.pr/PRLIB/random.c trunk/grassaddons/i.pr/PRLIB/read_models.c trunk/grassaddons/i.pr/PRLIB/soft_margin_boosting.c trunk/grassaddons/i.pr/PRLIB/sort.c trunk/grassaddons/i.pr/PRLIB/stats.c trunk/grassaddons/i.pr/PRLIB/svm.c trunk/grassaddons/i.pr/PRLIB/test.c trunk/grassaddons/i.pr/PRLIB/training.c trunk/grassaddons/i.pr/PRLIB/tree.c trunk/grassaddons/i.pr/PRLIB/write_matrix.c trunk/grassaddons/i.pr/README trunk/grassaddons/i.pr/doc/ trunk/grassaddons/i.pr/doc/psfig.sty trunk/grassaddons/i.pr/doc/usage.tex trunk/grassaddons/i.pr/i.pr_blob/ trunk/grassaddons/i.pr/i.pr_blob/Makefile trunk/grassaddons/i.pr/i.pr_blob/main.c trunk/grassaddons/i.pr/i.pr_classify/ trunk/grassaddons/i.pr/i.pr_classify/Makefile trunk/grassaddons/i.pr/i.pr_classify/main.c trunk/grassaddons/i.pr/i.pr_features/ trunk/grassaddons/i.pr/i.pr_features/Makefile trunk/grassaddons/i.pr/i.pr_features/main.c trunk/grassaddons/i.pr/i.pr_features_additional/ trunk/grassaddons/i.pr/i.pr_features_additional/Makefile trunk/grassaddons/i.pr/i.pr_features_additional/main.c trunk/grassaddons/i.pr/i.pr_features_extract/ trunk/grassaddons/i.pr/i.pr_features_extract/Makefile trunk/grassaddons/i.pr/i.pr_features_extract/main.c trunk/grassaddons/i.pr/i.pr_features_selection/ trunk/grassaddons/i.pr/i.pr_features_selection/Makefile trunk/grassaddons/i.pr/i.pr_features_selection/main.c trunk/grassaddons/i.pr/i.pr_model/ trunk/grassaddons/i.pr/i.pr_model/Makefile trunk/grassaddons/i.pr/i.pr_model/main.c trunk/grassaddons/i.pr/i.pr_sites_aggregate/ trunk/grassaddons/i.pr/i.pr_sites_aggregate/Makefile trunk/grassaddons/i.pr/i.pr_sites_aggregate/main.c trunk/grassaddons/i.pr/i.pr_statistics/ trunk/grassaddons/i.pr/i.pr_statistics/Makefile trunk/grassaddons/i.pr/i.pr_statistics/main.c trunk/grassaddons/i.pr/i.pr_subsets/ trunk/grassaddons/i.pr/i.pr_subsets/Makefile trunk/grassaddons/i.pr/i.pr_subsets/main.c trunk/grassaddons/i.pr/i.pr_subsets/old/ trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig.c trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig_2.c trunk/grassaddons/i.pr/i.pr_training/ trunk/grassaddons/i.pr/i.pr_training/Makefile trunk/grassaddons/i.pr/i.pr_training/conv.c trunk/grassaddons/i.pr/i.pr_training/defs.h trunk/grassaddons/i.pr/i.pr_training/globals.h trunk/grassaddons/i.pr/i.pr_training/graphics.c trunk/grassaddons/i.pr/i.pr_training/loc_func.h trunk/grassaddons/i.pr/i.pr_training/main.c trunk/grassaddons/i.pr/i.pr_training/mouse.c trunk/grassaddons/i.pr/i.pr_training/points.c trunk/grassaddons/i.pr/i.pr_training/sites.c trunk/grassaddons/i.pr/i.pr_training/title.c trunk/grassaddons/i.pr/i.pr_training/view.c trunk/grassaddons/i.pr/i.pr_training/write_map.c trunk/grassaddons/i.pr/i.pr_training/zoom.c trunk/grassaddons/i.pr/i.pr_training/zoom2.c trunk/grassaddons/i.pr/i.pr_uxb/ trunk/grassaddons/i.pr/i.pr_uxb/Makefile trunk/grassaddons/i.pr/i.pr_uxb/main.c trunk/grassaddons/i.pr/include/ trunk/grassaddons/i.pr/include/func.h trunk/grassaddons/i.pr/include/func_help trunk/grassaddons/i.pr/include/global.h Log: Stefano Merler : C code for classification problems Added: trunk/grassaddons/i.pr/Makefile =================================================================== --- trunk/grassaddons/i.pr/Makefile (rev 0) +++ trunk/grassaddons/i.pr/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,23 @@ +#MODULE_TOPDIR = ../.. +MODULE_TOPDIR = /home/neteler/grass63 + +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 Property changes on: trunk/grassaddons/i.pr/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/.so =================================================================== --- trunk/grassaddons/i.pr/PRLIB/.so (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/.so 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1 @@ +link .6.1.cvs.so \ No newline at end of file Property changes on: trunk/grassaddons/i.pr/PRLIB/.so ___________________________________________________________________ Name: svn:special + * Added: trunk/grassaddons/i.pr/PRLIB/Makefile =================================================================== --- trunk/grassaddons/i.pr/PRLIB/Makefile (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,13 @@ +MODULE_TOPDIR = ../../.. + +PRINCLUDE = ../include/ +EXTRA_CFLAGS = -I$(PRINCLUDE) + +EXTRA_LIBS=$(GISLIB) + +LIB_NAME = grass_pr + +include $(MODULE_TOPDIR)/include/Make/Lib.make + +default: lib + Property changes on: trunk/grassaddons/i.pr/PRLIB/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/blob.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/blob.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/blob.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,238 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + Blob and BlobSites structure management +*/ + +#include +#include +#include +#include +#include "global.h" + +static void add_points_to_blob(); +static int in_blob(); + +void extract_sites_from_blob(blobs,npoints,nblobs,cellhd,sites,matrix) + /*extract geographical coordinates of the blob centers + and store results in a BlobSites structure, containing the minimum + value of the blob too (computation based on matrix)*/ + Blob *blobs; + int npoints,nblobs; + struct Cell_head *cellhd; + BlobSites *sites; + double **matrix; +{ + int index,j,intindex; + double barix,bariy; + + index = 0; + for(j = 0; j < nblobs; j++){ + if(index < npoints){ + barix = .0; + bariy = .0; + intindex=0; + sites[j].max=sites[j].min=matrix[blobs[index].row][blobs[index].col]; + while(blobs[index].number == j){ + if(matrix[blobs[index].row][blobs[index].col]>sites[j].max) + sites[j].max=matrix[blobs[index].row][blobs[index].col]; + if(matrix[blobs[index].row][blobs[index].col]0){ + if(blobs[npoints-1].row == row) + if(blobs[npoints-1].col == col) + return TRUE; + npoints -= 1; + } + return FALSE; +} + +void find_blob(matrix,r,c,blobs,npoints,nblobs,tm,tM) + /*find blobs within a matrix and add to structure blob. A blob is + a set of contiguous cells of a matrix, all of them with value <= + tM and >= tm. npoints is just a counter of cells belonging to the blob. + nblobs is the total number of blobs.*/ + double **matrix; + int r,c; + Blob **blobs; + double tm,tM; + int *nblobs; + int *npoints; +{ + int i,j; + + for(i=0;i=tm)){ + if(!in_blob(i,j,*blobs,*npoints)){ + if(*npoints==0) + *blobs=(Blob *)G_calloc(*npoints+1,sizeof(Blob)); + else + *blobs=(Blob *)realloc(*blobs,(*npoints+1)*sizeof(Blob)); + (*blobs)[*npoints].row=i; + (*blobs)[*npoints].col=j; + (*blobs)[*npoints].number=*nblobs; + (*npoints)+=1; + add_points_to_blob(&blobs,npoints,*nblobs,matrix,r,c,i,j,tm,tM); + (*nblobs)+=1; + } + } + } + } +} + +static void add_points_to_blob(blobs,npoints,nblobs,matrix,r,c,i,j,tm,tM) + Blob ***blobs; + int *npoints; + int nblobs; + double **matrix; + int r,c,i,j; + double tm,tM; +{ + int s; + int points_in_blob; + int *row,*col; + + points_in_blob=0; + row=(int*)calloc(points_in_blob+1,sizeof(int)); + col=(int*)calloc(points_in_blob+1,sizeof(int)); + + row[points_in_blob]=i; + col[points_in_blob]=j; + + for(s=0;s<=points_in_blob;s++){ + if(row[s]>0 && row[s] < r && col[s]>0 && col[s] < c){ + if((matrix[row[s]-1][col[s]-1]<=tM) && (matrix[row[s]-1][col[s]-1]>=tm)){ + if(!in_blob(row[s]-1,col[s]-1,**blobs,*npoints)){ + **blobs=(Blob *)realloc(**blobs,(*npoints+1)*sizeof(Blob)); + (**blobs)[*npoints].row=row[s]-1; + (**blobs)[*npoints].col=col[s]-1; + (**blobs)[*npoints].number=nblobs; + *npoints+=1; + points_in_blob += 1; + row=(int*)realloc(row,(points_in_blob+1)*sizeof(int)); + col=(int*)realloc(col,(points_in_blob+1)*sizeof(int)); + row[points_in_blob]=row[s]-1; + col[points_in_blob]=col[s]-1; + } + } + if((matrix[row[s]-1][col[s]]<=tM) && (matrix[row[s]-1][col[s]]>=tm)){ + if(!in_blob(row[s]-1,col[s],**blobs,*npoints)){ + **blobs=(Blob *)realloc(**blobs,(*npoints+1)*sizeof(Blob)); + (**blobs)[*npoints].row=row[s]-1; + (**blobs)[*npoints].col=col[s]; + (**blobs)[*npoints].number=nblobs; + *npoints+=1; + points_in_blob += 1; + row=(int*)realloc(row,(points_in_blob+1)*sizeof(int)); + col=(int*)realloc(col,(points_in_blob+1)*sizeof(int)); + row[points_in_blob]=row[s]-1; + col[points_in_blob]=col[s]; + } + } + if((matrix[row[s]-1][col[s]+1]<=tM) && (matrix[row[s]-1][col[s]+1]>=tm)){ + if(!in_blob(row[s]-1,col[s]+1,**blobs,*npoints)){ + **blobs=(Blob *)realloc(**blobs,(*npoints+1)*sizeof(Blob)); + (**blobs)[*npoints].row=row[s]-1; + (**blobs)[*npoints].col=col[s]+1; + (**blobs)[*npoints].number=nblobs; + *npoints+=1; + points_in_blob += 1; + row=(int*)realloc(row,(points_in_blob+1)*sizeof(int)); + col=(int*)realloc(col,(points_in_blob+1)*sizeof(int)); + row[points_in_blob]=row[s]-1; + col[points_in_blob]=col[s]+1; + } + } + if((matrix[row[s]][col[s]-1]<=tM) && (matrix[row[s]][col[s]-1]>=tm)){ + if(!in_blob(row[s],col[s]-1,**blobs,*npoints)){ + **blobs=(Blob *)realloc(**blobs,(*npoints+1)*sizeof(Blob)); + (**blobs)[*npoints].row=row[s]; + (**blobs)[*npoints].col=col[s]-1; + (**blobs)[*npoints].number=nblobs; + *npoints+=1; + points_in_blob += 1; + row=(int*)realloc(row,(points_in_blob+1)*sizeof(int)); + col=(int*)realloc(col,(points_in_blob+1)*sizeof(int)); + row[points_in_blob]=row[s]; + col[points_in_blob]=col[s]-1; + } + } + if((matrix[row[s]][col[s]+1]<=tM) && (matrix[row[s]][col[s]+1]>=tm)){ + if(!in_blob(row[s],col[s]+1,**blobs,*npoints)){ + **blobs=(Blob *)realloc(**blobs,(*npoints+1)*sizeof(Blob)); + (**blobs)[*npoints].row=row[s]; + (**blobs)[*npoints].col=col[s]+1; + (**blobs)[*npoints].number=nblobs; + *npoints+=1; + points_in_blob += 1; + row=(int*)realloc(row,(points_in_blob+1)*sizeof(int)); + col=(int*)realloc(col,(points_in_blob+1)*sizeof(int)); + row[points_in_blob]=row[s]; + col[points_in_blob]=col[s]+1; + } + } + if((matrix[row[s]+1][col[s]-1]<=tM) && (matrix[row[s]+1][col[s]-1]>=tm)){ + if(!in_blob(row[s]+1,col[s]-1,**blobs,*npoints)){ + **blobs=(Blob *)realloc(**blobs,(*npoints+1)*sizeof(Blob)); + (**blobs)[*npoints].row=row[s]+1; + (**blobs)[*npoints].col=col[s]-1; + (**blobs)[*npoints].number=nblobs; + *npoints+=1; + points_in_blob += 1; + row=(int*)realloc(row,(points_in_blob+1)*sizeof(int)); + col=(int*)realloc(col,(points_in_blob+1)*sizeof(int)); + row[points_in_blob]=row[s]+1; + col[points_in_blob]=col[s]-1; + } + } + if((matrix[row[s]+1][col[s]]<=tM) && (matrix[row[s]+1][col[s]]>=tm)){ + if(!in_blob(row[s]+1,col[s],**blobs,*npoints)){ + **blobs=(Blob *)realloc(**blobs,(*npoints+1)*sizeof(Blob)); + (**blobs)[*npoints].row=row[s]+1; + (**blobs)[*npoints].col=col[s]; + (**blobs)[*npoints].number=nblobs; + *npoints+=1; + points_in_blob += 1; + row=(int*)realloc(row,(points_in_blob+1)*sizeof(int)); + col=(int*)realloc(col,(points_in_blob+1)*sizeof(int)); + row[points_in_blob]=row[s]+1; + col[points_in_blob]=col[s]; + } + } + if((matrix[row[s]+1][col[s]+1]<=tM) && (matrix[row[s]+1][col[s]+1]>=tm)){ + if(!in_blob(row[s]+1,col[s]+1,**blobs,*npoints)){ + **blobs=(Blob *)realloc(**blobs,(*npoints+1)*sizeof(Blob)); + (**blobs)[*npoints].row=row[s]+1; + (**blobs)[*npoints].col=col[s]+1; + (**blobs)[*npoints].number=nblobs; + *npoints+=1; + points_in_blob += 1; + row=(int*)realloc(row,(points_in_blob+1)*sizeof(int)); + col=(int*)realloc(col,(points_in_blob+1)*sizeof(int)); + row[points_in_blob]=row[s]+1; + col[points_in_blob]=col[s]+1; + } + } + } + } +} Property changes on: trunk/grassaddons/i.pr/PRLIB/blob.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/bootstrap.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/bootstrap.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/bootstrap.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,129 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + bootstrap, probabily based, samples estraction +*/ + +#include +#include +#include +#include +#include "global.h" + +void Bootsamples(n,prob,random_labels) + /* + given an array of probabilities of length n, extract a bootstrap sample + of n elements according to the vector of probabilities + */ + int n; + double *prob; + int *random_labels; + +{ + int i,j; + int *random_labels_flag; + double *random; + double *cumprob; + double probtot = .0; + + for(i = 0; i < n; i++) + probtot += prob[i]; + for(i = 0; i < n; i++) + prob[i] /= probtot; + + random_labels_flag = (int*)calloc(n, sizeof(int)); + random = (double*)calloc(n, sizeof(double)); + cumprob = (double*)calloc(n, sizeof(double)); + + for(i = 0; i < n; ++i) + { + random[i]=(double)drand48(); + random_labels[i]=n-1; + random_labels_flag[i]=0; + } + + + for(i = 0; i < n; i++) + { + if(i>0) + cumprob[i] = cumprob[i-1] + prob[i]; + else + cumprob[0] = prob[0]; + + for(j = 0; j < n; j++) + { + + if(random[j] < cumprob[i]) + if(random_labels_flag[j] == 0) + { + random_labels[j]=i; + random_labels_flag[j] = 1; + } + } + } + + free(random); + free(cumprob); + free(random_labels_flag); +} + + +void Bootsamples_rseed(n,prob,random_labels,idum) + /* + given an array of probabilities of length n, extract a bootstrap sample + of n elements according to the vector of probabilities + */ + int n; + double *prob; + int *random_labels; + int *idum; + +{ + int i,j; + int *random_labels_flag; + double *random; + double *cumprob; + double probtot = .0; + + for(i = 0; i < n; i++) + probtot += prob[i]; + for(i = 0; i < n; i++) + prob[i] /= probtot; + + random_labels_flag = (int*)calloc(n, sizeof(int)); + random = (double*)calloc(n, sizeof(double)); + cumprob = (double*)calloc(n, sizeof(double)); + + for(i = 0; i < n; ++i) + { + random[i]=(double)ran1(idum); + random_labels[i]=n-1; + random_labels_flag[i]=0; + } + + + for(i = 0; i < n; i++) + { + if(i>0) + cumprob[i] = cumprob[i-1] + prob[i]; + else + cumprob[0] = prob[0]; + + for(j = 0; j < n; j++) + { + + if(random[j] < cumprob[i]) + if(random_labels_flag[j] == 0) + { + random_labels[j]=i; + random_labels_flag[j] = 1; + } + } + } + + free(random); + free(cumprob); + free(random_labels_flag); +} Property changes on: trunk/grassaddons/i.pr/PRLIB/bootstrap.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/dist.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/dist.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/dist.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,83 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + Distance between arrays computation +*/ + +#include "global.h" +#include + + +double squared_distance(x,y,n) + /* + squared euclidean distance between vectors x and y of length n + */ + double *x; + double *y; + int n; +{ + int j; + double out = 0.0; + double tmp; + + + for(j=0;j +#include + + +#define MAX_ITERS 30 +#define SIGN(a,b) ((b)<0 ? -fabs(a) : fabs(a)) + + + +void tred2(a,n,d,e) + /* + Houserholder method for reduction of simmetric n x n matrix a to + tridiagonal form: on output a contains the ortogonal transformation + matrix, d contains the diagonal elements, and e the off-diagonal. + */ + double **a,d[],e[]; + int n; +{ + int l,k,j,i; + double scale,hh,h,g,f; + + for (i=n-1;i>=1;i--) { + l=i-1; + h=scale=0.0; + if (l > 0) { + for (k=0;k<=l;k++) + scale += fabs(a[i][k]); + if (scale == 0.0) + e[i]=a[i][l]; + else { + for (k=0;k<=l;k++) { + a[i][k] /= scale; + h += a[i][k]*a[i][k]; + } + f=a[i][l]; + g = f>0 ? -sqrt(h) : sqrt(h); + e[i]=scale*g; + h -= f*g; + a[i][l]=f-g; + f=0.0; + for (j=0;j<=l;j++) { + /* Next statement can be omitted if eigenvectors not wanted */ + a[j][i]=a[i][j]/h; + g=0.0; + for (k=0;k<=j;k++) + g += a[j][k]*a[i][k]; + for (k=j+1;k<=l;k++) + g += a[k][j]*a[i][k]; + e[j]=g/h; + f += e[j]*a[i][j]; + } + hh=f/(h+h); + for (j=0;j<=l;j++) { + f=a[i][j]; + e[j]=g=e[j]-hh*f; + for (k=0;k<=j;k++) + a[j][k] -= (f*e[k]+g*a[i][k]); + } + } + } else + e[i]=a[i][l]; + d[i]=h; + } + /* Next statement can be omitted if eigenvectors not wanted */ + d[0]=0.0; + e[0]=0.0; + /* Contents of this loop can be omitted if eigenvectors not + wanted except for statement d[i]=a[i][i]; */ + for (i=0;i=l;i--) { + f=s*e[i]; + b=c*e[i]; + if (fabs(f) >= fabs(g)) { + c=g/f; + r=sqrt((c*c)+1.0); + e[i+1]=f*r; + c *= (s=1.0/r); + } else { + s=f/g; + r=sqrt((s*s)+1.0); + e[i+1]=g*r; + s *= (c=1.0/r); + } + g=d[i+1]-p; + r=(d[i]-g)*s+2.0*c*b; + p=s*r; + d[i+1]=g+p; + g=c*r-b; + /* Next loop can be omitted if eigenvectors not wanted */ + for (k=0;k= p) p=d[k=j]; + /* + interchange eigen values i and k and corresponding eigen vectors + */ + if (k != i) + { + d[k] = d[i]; + d[i] = p; + for (j = 0; j + +double Entropy(data,n,zero) + double *data; + int n; + double zero; +{ + int i; + double sum; + double e; + + sum=0.0; + for(i=0;i zero) + return(-1.0); + else{ + e=0.0; + for(i=0;i0.0) + return(-1.0*x*log(x)/log(2)); + else + return(0.0); +} + +void histo(data,n,h,nbin) + double *data, *h; + int n,nbin; +{ + int i; + for(i=0;i=0){ + ($name,$extension)= split(/\./,$files[$nfiles]); + if($extension eq "c" || $extension eq "h"){ + if(!$done){ + print "#########################\n$files[$nfiles]\n#########################\n\n";} else { + print "\n#########################\n$files[$nfiles]\n#########################\n\n"; + } + $done = 1; + open(FILE,$files[$nfiles]); + while(){ + if(!/\#/){ + print $_; + }else{ + goto START; + } + } + START: + while(){ + NEWfun: + if(!/;/ && !/static/){ + if(/void /){ + print $_; + while(){ + if(!/\{/){ + print $_; + }else{ + goto NEWfun; + } + } + } + if(/double /){ + print $_; + while(){ + if(!/\{/){ + print $_; + }else{ + goto NEWfun; + } + } + } + if(/float /){ + print $_; + while(){ + if(!/\{/){ + print $_; + }else{ + goto NEWfun; + } + } + } + if(/int /){ + print $_; + while(){ + if(!/\{/){ + print $_; + }else{ + goto NEWfun; + } + } + } + if(/char /){ + print $_; + while(){ + if(!/\{/){ + print $_; + }else{ + goto NEWfun; + } + } + } + } + } + close(FILE); + + } + $nfiles = $nfiles - 1; + } +} else{ + while($nfiles>=0){ + ($name,$extension)= split(/\./,$files[$nfiles]); + if($extension eq "c"){ + if(!$done){ + print "/*\n$files[$nfiles]\n*/\n\n";} else { + print "\n/*\n$files[$nfiles]\n*/\n\n"; + } + $done = 1; + open(FILE,$files[$nfiles]); + while(){ + NEWfun: + if(!/;/ && !/static/){ + if(/void /){ + ($func,$param)=split(/\(/,$_); + print $func,"();\n"; + while(){ + if(!/\{/){ + }else{ + goto NEWfun; + } + } + } + if(/double /){ + ($func,$param)=split(/\(/,$_); + print $func,"();\n"; + while(){ + if(!/\{/){ + }else{ + goto NEWfun; + } + } + } + if(/float /){ + ($func,$param)=split(/\(/,$_); + print $func,"();\n"; + while(){ + if(!/\{/){ + }else{ + goto NEWfun; + } + } + } + if(/int /){ + ($func,$param)=split(/\(/,$_); + print $func,"();\n"; + while(){ + if(!/\{/){ + }else{ + goto NEWfun; + } + } + } + if(/char /){ + ($func,$param)=split(/\(/,$_); + print $func,"();\n"; + while(){ + if(!/\{/){ + }else{ + goto NEWfun; + } + } + } + } + } + close(FILE); + + } + $nfiles = $nfiles - 1; + } +} Property changes on: trunk/grassaddons/i.pr/PRLIB/extract_functions.pl ___________________________________________________________________ Name: svn:executable + * Added: trunk/grassaddons/i.pr/PRLIB/extract_ps.pl =================================================================== --- trunk/grassaddons/i.pr/PRLIB/extract_ps.pl (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/extract_ps.pl 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,18 @@ +#!/usr/local/bin/perl + +opendir DIR, "./"; +@files=readdir DIR; +closedir DIR; +$nfiles=$#files; + + +while($nfiles>=0){ + ($name,$extension)= split(/\./,$files[$nfiles]); + if($extension eq "c" || $extension eq "h"){ + $out = join(".",$name,"ps"); + system("a2ps $files[$nfiles] -o $out"); + system("lpr -PNE.PP.Sud $out"); + } + $nfiles = $nfiles - 1; +} + Property changes on: trunk/grassaddons/i.pr/PRLIB/extract_ps.pl ___________________________________________________________________ Name: svn:executable + * Added: trunk/grassaddons/i.pr/PRLIB/features.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/features.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/features.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,1109 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + structure Feature management +*/ +#include "gis.h" +#include "global.h" +#include +#include + +void compute_features(features) + /* + given a training structure in input, fill the features structure + according to specification lyke + features->f_mean + features->f_variance + features->f_pca + features->f_texture (not yet implemented) + */ + Features *features; +{ + int i,j,k,l; + char *mapset; + int fp; + struct Cell_head cellhd; + DCELL *rowbuf; + DCELL *tf; + DCELL **matrix; + int r,c; + char tempbuf[500]; + int *compute_features; + int dim; + DCELL *mean = NULL,*sd = NULL; + int corrent_feature; + int *space_for_each_layer; + DCELL *projected = NULL; + DCELL **pca_matrix=NULL; + int ndata_for_pca=0; + int index; + int thisclassok; + int addclass; + + compute_features=(int *)G_calloc(features->training.nlayers,sizeof(int)); + + features->nexamples = features->training.nexamples; + dim=features->training.rows * features->training.cols; + + /*compute space*/ + space_for_each_layer=(int *)G_calloc(features->training.nlayers, + sizeof(int)); + + features->examples_dim = 0; + for(j=0;jtraining.nlayers;j++){ + if(features->f_mean[0]){ + for(i=2;i<2+features->f_mean[1];i++){ + if(features->f_mean[i]==j){ + compute_features[j]=TRUE; + space_for_each_layer[j] += 1; + } + } + } + if(features->f_variance[0]){ + for(i=2;i<2+features->f_variance[1];i++){ + if(features->f_variance[i]==j){ + compute_features[j]=TRUE; + space_for_each_layer[j] += 1; + } + } + } + if(features->f_pca[0]){ + for(i=2;i<2+features->f_pca[1];i++){ + if(features->f_pca[i]==j){ + compute_features[j]=TRUE; + space_for_each_layer[j] += dim; + } + } + } + if(space_for_each_layer[j]==0){ + space_for_each_layer[j]=dim; + } + features->examples_dim += space_for_each_layer[j]; + } + + /*alloc memory*/ + features->value=(double **)G_calloc(features->nexamples,sizeof(double*)); + for(i=0;inexamples;i++){ + features->value[i]=(double *)G_calloc(features->examples_dim,sizeof(double)); + } + features->class=(int *)G_calloc(features->nexamples,sizeof(int)); + + matrix=(double **)G_calloc(features->nexamples,sizeof(double *)); + for(i=0;inexamples;i++){ + matrix[i]=(double *)G_calloc(dim,sizeof(double)); + } + + mean=(double*)G_calloc(features->nexamples,sizeof(double)); + sd=(double*)G_calloc(features->nexamples,sizeof(double)); + + /*copy classes*/ + for(i=0;inexamples;i++){ + features->class[i]=features->training.class[i]; + } + + /*compute p_classes*/ + features->p_classes=(int *) G_calloc(1,sizeof(int)); + features->nclasses=1; + features->p_classes[0] = features->class[0]; + for(i=1;inexamples;i++){ + addclass=TRUE; + for(j=0;jnclasses;j++){ + if(features->class[i] == features->p_classes[j]){ + addclass=FALSE; + } + } + if(addclass){ + features->nclasses += 1; + features->p_classes=(int *)realloc(features->p_classes, + features->nclasses * sizeof(int)); + features->p_classes[features->nclasses-1] = features->class[i]; + } + } + + /*space for pca*/ + if(features->f_pca[0]){ + features->pca=(Pca *)G_calloc(features->training.nlayers,sizeof(Pca)); + for(i=0;itraining.nlayers;i++){ + inizialize_pca(&(features->pca[i]),dim); + } + projected=(double*)G_calloc(dim,sizeof(double)); + + if(features->pca_class[0]==0){ + fprintf(stderr,"principal components computed on all training data\n"); + }else{ + fprintf(stderr,"principal components computed on data of classes"); + for(l=1;l<=features->pca_class[1];l++){ + thisclassok=FALSE; + for(k=0;knclasses;k++){ + if(features->pca_class[1+l] == features->p_classes[k]){ + thisclassok=TRUE; + fprintf(stderr," %d",features->p_classes[k]); + break; + } + } + if(!thisclassok){ + sprintf(tempbuf,"compute_features-> Class %d for pc not recognized", + features->pca_class[1+l]); + G_fatal_error(tempbuf); + } + } + fprintf(stderr,"\n"); + } + + ndata_for_pca = 0; + for(l=0;lnexamples;l++){ + for(r=2;r<(2+features->pca_class[1]);r++){ + if(features->class[l]==features->pca_class[r]){ + ndata_for_pca += 1; + } + } + } + pca_matrix=(double **)G_calloc(ndata_for_pca,sizeof(double *)); + for(l=0;ltraining.nlayers;j++){ + for(i=0;inexamples;i++){ + switch(features->training.data_type){ + case GRASS_data: + fprintf(stdout,"%s\n",features->training.mapnames[i][j]); + if ((mapset=G_find_cell(features->training.mapnames[i][j], "")) == NULL) { + sprintf(tempbuf, "compute_features-> Can't find raster map <%s>", features->training.mapnames[i][j]); + G_fatal_error(tempbuf); + } + if ((fp =G_open_cell_old(features->training.mapnames[i][j], mapset))< 0){ + sprintf(tempbuf,"compute_features-> Can't open raster map <%s> for reading",features->training.mapnames[i][j]); + G_fatal_error(tempbuf); + } + + G_get_cellhd (features->training.mapnames[i][j], mapset, &cellhd); + G_set_window(&cellhd); + if((cellhd.rows != features->training.rows) || (cellhd.cols != features->training.cols)){ + sprintf(tempbuf, "compute_features-> Dimension Error"); + G_fatal_error(tempbuf); + } + rowbuf = (DCELL *)G_calloc(dim,sizeof(DCELL)); + tf = rowbuf; + + + for(r = 0; r < features->training.rows; r++){ + G_get_d_raster_row(fp, tf, r); + for(c = 0; c < features->training.cols; c++){ + if (G_is_d_null_value (tf)) + *tf = 0.0; + matrix[i][c + (r * features->training.cols)] = *tf; + tf++; + } + } + free(rowbuf); + + G_close_cell(fp); + + break; + case TABLE_data: + matrix[i]=features->training.data[i]; + break; + default: + sprintf(tempbuf, "compute_features-> Format not recognized"); + G_fatal_error(tempbuf); + break; + } + } + + for(k=0;knexamples;k++){ + mean[k] = sd[k] = 0.0; + } + mean_and_sd_of_double_matrix_by_row(matrix,features->nexamples, + dim,mean,sd); + + if(features->f_normalize[0]){ + for(i=2;i<2+features->f_normalize[1];i++){ + if(features->f_normalize[i]==j){ + for(k=0;knexamples;k++){ + for(r = 0; r < dim; r++){ + matrix[k][r] = (matrix[k][r] - mean[k])/sd[k]; + } + } + } + } + } + + + if(!compute_features[j]){ + for(i=0;inexamples;i++){ + for(r = 0; r < dim; r++){ + features->value[i][corrent_feature+r] = matrix[i][r]; + } + } + corrent_feature+=dim; + }else{ + if(features->f_mean[0]){ + for(i=2;i<2+features->f_mean[1];i++){ + if(features->f_mean[i]==j){ + for(k=0;knexamples;k++){ + features->value[k][corrent_feature]=mean[k]; + } + corrent_feature+=1; + } + } + } + + if(features->f_variance[0]){ + for(i=2;i<2+features->f_variance[1];i++){ + if(features->f_variance[i]==j){ + for(k=0;knexamples;k++){ + features->value[k][corrent_feature]=sd[k]*sd[k]; + } + corrent_feature+=1; + } + } + } + + if(features->f_pca[0]){ + for(i=2;i<2+features->f_pca[1];i++){ + if(features->f_pca[i]==j){ + if(features->pca_class[0]==0){ + covariance_of_double_matrix(matrix,features->nexamples,dim, + features->pca[j].covar); + }else{ + index=0; + for(l=0;lnexamples;l++){ + for(r=2;r<(2+features->pca_class[1]);r++){ + if(features->training.class[l]==features->pca_class[r]){ + pca_matrix[index++]=matrix[l]; + } + } + } + covariance_of_double_matrix(pca_matrix,ndata_for_pca,dim, + features->pca[j].covar); + } + eigen_of_double_matrix(features->pca[j].covar, features->pca[j].eigmat, + features->pca[j].eigval, dim); + eigsrt(features->pca[j].eigval,features->pca[j].eigmat,dim); + for(l=0;lnexamples;l++){ + product_double_vector_double_matrix(features->pca[j].eigmat,matrix[l], + dim,dim,projected); + for(r=0;rvalue[l][corrent_feature+r]=projected[r]; + } + } + corrent_feature+=dim; + } + } + } + } + } + + + free(mean); + free(sd); + free(compute_features); +} + +void write_features(file,features) + /* + write the features into a file + */ + char *file; + Features *features; +{ + FILE *fp; + int i,j,l,k; + int dim; + char tempbuf[500]; + int write_x; + + fp=fopen(file,"w"); + if(fp == NULL){ + sprintf(tempbuf, "write_features-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + fprintf(fp,"#####################\n"); + fprintf(fp,"TRAINING: (%s)\n",features->training.file); + fprintf(fp,"#####################\n"); + + fprintf(fp,"Type of data:\n"); + fprintf(fp,"%d\n",features->training.data_type); + + fprintf(fp,"Number of layers:\n"); + fprintf(fp,"%d\n",features->training.nlayers); + + fprintf(fp,"Training dimensions:\n"); + fprintf(fp,"%d\t%d\n",features->training.rows,features->training.cols); + + dim=features->training.rows*features->training.cols; + + fprintf(fp,"EW-res\tNS-res\n"); + fprintf(fp,"%f\t%f\n",features->training.ew_res,features->training.ns_res); + + fprintf(fp,"#####################\n"); + fprintf(fp,"FEATURES:\n"); + fprintf(fp,"#####################\n"); + + fprintf(fp,"normalize:\n"); + if(features->f_normalize[0]){ + fprintf(fp,"%d\t%d\t%d",features->f_normalize[0],features->f_normalize[1], + features->f_normalize[2]+1); + for(i=3;i<2+features->f_normalize[1];i++){ + fprintf(fp,"\t%d",features->f_normalize[2]+1); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"0\n"); + } + + fprintf(fp,"standardize:\n"); + if(features->f_standardize[0]){ + fprintf(fp,"%d\t%d\t%d",features->f_standardize[0],features->f_standardize[1], + features->f_standardize[2]+1); + for(i=3;i<2+features->f_standardize[1];i++){ + fprintf(fp,"\t%d",features->f_standardize[i]+1); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"0\n"); + } + + fprintf(fp,"mean:\n"); + if(features->f_mean[0]){ + fprintf(fp,"%d\t%d\t%d",features->f_mean[0],features->f_mean[1],features->f_mean[2]+1); + for(i=3;i<2+features->f_mean[1];i++){ + fprintf(fp,"\t%d",features->f_mean[i]+1); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"0\n"); + } + + fprintf(fp,"variance:\n"); + if(features->f_variance[0]){ + fprintf(fp,"%d\t%d\t%d",features->f_variance[0],features->f_variance[1], + features->f_variance[2]+1); + for(i=3;i<2+features->f_variance[1];i++){ + fprintf(fp,"\t%d",features->f_variance[i]+1); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"0\n"); + } + + fprintf(fp,"pca:\n"); + if(features->f_pca[0]){ + fprintf(fp,"%d\t%d\t%d",features->f_pca[0],features->f_pca[1],features->f_pca[2]+1); + for(i=3;i<2+features->f_pca[1];i++){ + fprintf(fp,"\t%d",features->f_pca[i]+1); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"0\n"); + } + + fprintf(fp,"Number of classes:\n"); + fprintf(fp,"%d\n",features->nclasses); + + fprintf(fp,"Classes:\n"); + fprintf(fp,"%d",features->p_classes[0]); + for(i=1;inclasses;i++){ + fprintf(fp,"\t%d",features->p_classes[i]); + } + fprintf(fp,"\n"); + + fprintf(fp,"Standardization values:\n"); + if(features->f_standardize[0]){ + fprintf(fp,"%f",features->mean[0]); + for(i=1;if_standardize[1];i++){ + fprintf(fp,"\t%f",features->mean[i]); + } + fprintf(fp,"\n"); + fprintf(fp,"%f",features->sd[0]); + for(i=1;if_standardize[1];i++){ + fprintf(fp,"\t%f",features->sd[i]); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"NULL\n"); + fprintf(fp,"NULL\n"); + } + + fprintf(fp,"Features dimensions:\n"); + fprintf(fp,"%d\t%d\n",features->nexamples,features->examples_dim); + + fprintf(fp,"Features:\n"); + + for(i=0;itraining.nlayers;i++){ + write_x=TRUE; + if(features->f_mean[0]){ + for(j=2;j<2+features->f_mean[1];j++){ + if(features->f_mean[j]==i){ + write_x=FALSE; + fprintf(fp,"l%d_mean\t",i+1); + } + } + } + if(features->f_variance[0]){ + for(j=2;j<2+features->f_variance[1];j++){ + if(features->f_variance[j]==i){ + write_x=FALSE; + fprintf(fp,"l%d_variance\t",i+1); + } + } + } + if(features->f_pca[0]){ + for(j=2;j<2+features->f_pca[1];j++){ + if(features->f_pca[j]==i){ + write_x=FALSE; + for(k=0;ktraining.nlayers){ + fprintf(fp,"class\n"); + } + } + + for(i=0;inexamples;i++){ + for(j=0;jexamples_dim;j++){ + fprintf(fp,"%f\t",features->value[i][j]); + } + fprintf(fp,"%d\n",features->class[i]); + } + + if(features->f_pca[0]){ + + fprintf(fp,"#####################\n"); + fprintf(fp,"PRINC. COMP.:"); + if(features->pca_class[0]==0){ + fprintf(fp," all classes used\n"); + }else{ + for(i=0;ipca_class[1];i++){ + fprintf(fp," %d",features->pca_class[2+i]); + } + fprintf(fp," classes used\n"); + } + fprintf(fp,"#####################\n"); + for(l=2;l<2+features->f_pca[1];l++){ + fprintf(fp,"PCA: Layer %d\n",features->f_pca[l]+1); + write_pca(fp,&(features->pca[l-2])); + } + } + fclose(fp); +} + +void standardize_features(features) + /* + standardize fetures accordining to the fetures.f_standardize array + */ + Features *features; +{ + int j,k; + + double *tmparray; + char tempbuf[500]; + + for(j=2;j<2+features->f_standardize[1];j++){ + if((features->f_standardize[j] <0) || + (features->f_standardize[j] >= features->examples_dim)){ + sprintf(tempbuf,"standardize_features-> Can't standardize var number %d: no such variable", + features->f_standardize[j]+1); + G_fatal_error(tempbuf); + } + } + + tmparray=(double *)G_calloc(features->nexamples,sizeof(double)); + + features->mean=(double *)G_calloc(features->f_standardize[1],sizeof(double)); + features->sd=(double *)G_calloc(features->f_standardize[1],sizeof(double)); + + for(j=2;j<2+features->f_standardize[1];j++){ + for(k=0;knexamples;k++){ + tmparray[k] = features->value[k][features->f_standardize[j]]; + } + features->mean[j-2]=mean_of_double_array(tmparray,features->nexamples); + features->sd[j-2]=sd_of_double_array_given_mean(tmparray,features->nexamples, + features->mean[j-2]); + if(features->sd[j-2]==0){ + sprintf(tempbuf,"standardize_features-> Can't standardize var number %d: sd=0", + features->f_standardize[j]+1); + G_fatal_error(tempbuf); + } + for(k=0;knexamples;k++){ + features->value[k][features->f_standardize[j]] = + (tmparray[k]-features->mean[j-2])/features->sd[j-2]; + } + } + + free(tmparray); +} + + +void write_header_features(fp,features) + /* + write the header features into the pointed file + */ + FILE *fp; + Features *features; +{ + int i; + int dim; + + fprintf(fp,"#####################\n"); + fprintf(fp,"TRAINING:\n"); + fprintf(fp,"#####################\n"); + + fprintf(fp,"Type of data:\n"); + fprintf(fp,"%d\n",features->training.data_type); + + fprintf(fp,"Number of layers:\n"); + fprintf(fp,"%d\n",features->training.nlayers); + + fprintf(fp,"Training dimensions:\n"); + fprintf(fp,"%d\t%d\n",features->training.rows,features->training.cols); + + dim=features->training.rows*features->training.cols; + + fprintf(fp,"EW-res\tNS-res\n"); + fprintf(fp,"%f\t%f\n",features->training.ew_res,features->training.ns_res); + + fprintf(fp,"#####################\n"); + fprintf(fp,"FEATURES: (%s)\n",features->file); + fprintf(fp,"#####################\n"); + + fprintf(fp,"normalize:\n"); + if(features->f_normalize[0]){ + fprintf(fp,"%d\t%d\t%d",features->f_normalize[0],features->f_normalize[1], + features->f_normalize[2]+1); + for(i=3;i<2+features->f_normalize[1];i++){ + fprintf(fp,"\t%d",features->f_normalize[2]+1); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"0\n"); + } + + fprintf(fp,"standardize:\n"); + if(features->f_standardize[0]){ + fprintf(fp,"%d\t%d\t%d",features->f_standardize[0], + features->f_standardize[1], features->f_standardize[2]+1); + for(i=3;i<2+features->f_standardize[1];i++){ + fprintf(fp,"\t%d",features->f_standardize[i]+1); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"0\n"); + } + + fprintf(fp,"mean:\n"); + if(features->f_mean[0]){ + fprintf(fp,"%d\t%d\t%d",features->f_mean[0],features->f_mean[1], + features->f_mean[2]+1); + for(i=3;i<2+features->f_mean[1];i++){ + fprintf(fp,"\t%d",features->f_mean[i]+1); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"0\n"); + } + + fprintf(fp,"variance:\n"); + if(features->f_variance[0]){ + fprintf(fp,"%d\t%d\t%d",features->f_variance[0],features->f_variance[1], + features->f_variance[2]+1); + for(i=3;i<2+features->f_variance[1];i++){ + fprintf(fp,"\t%d",features->f_variance[i]+1); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"0\n"); + } + + fprintf(fp,"pca:\n"); + if(features->f_pca[0]){ + fprintf(fp,"%d\t%d\t%d",features->f_pca[0],features->f_pca[1], + features->f_pca[2]+1); + for(i=3;i<2+features->f_pca[1];i++){ + fprintf(fp,"\t%d",features->f_pca[i]+1); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"0\n"); + } + + fprintf(fp,"Number of classes:\n"); + fprintf(fp,"%d\n",features->nclasses); + + fprintf(fp,"Classes:\n"); + fprintf(fp,"%d",features->p_classes[0]); + for(i=1;inclasses;i++){ + fprintf(fp,"\t%d",features->p_classes[i]); + } + fprintf(fp,"\n"); + + fprintf(fp,"Standardization values:\n"); + if(features->f_standardize[0]){ + fprintf(fp,"%f",features->mean[0]); + for(i=1;if_standardize[1];i++){ + fprintf(fp,"\t%f",features->mean[i]); + } + fprintf(fp,"\n"); + fprintf(fp,"%f",features->sd[0]); + for(i=1;if_standardize[1];i++){ + fprintf(fp,"\t%f",features->sd[i]); + } + fprintf(fp,"\n"); + }else{ + fprintf(fp,"NULL\n"); + fprintf(fp,"NULL\n"); + } + + + fprintf(fp,"Features dimensions:\n"); + fprintf(fp,"%d\t%d\n",features->nexamples,features->examples_dim); + + +} + + + +void read_features(file,features,npc) + /* + read the features from a file. If pc structure is contained + within features, only load the first npc component. If npc < 0 + all the pc will be loaded. + */ + char *file; + Features *features; + int npc; +{ + FILE *fp; + char tempbuf[500]; + char *line = NULL; + int i,j,l,r; + int dim; + int *features_to_be_loaded; + int orig_dim; + int index; + int corrent_feature; + + fp = fopen(file, "r"); + if(fp == NULL){ + sprintf(tempbuf,"read_features-> Can't open file %s for reading", file); + G_fatal_error(tempbuf); + } + + features->file=file; + + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d",&(features->training.data_type)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d",&(features->training.nlayers)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d%d",&(features->training.rows),&(features->training.cols)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%lf%lf",&(features->training.ew_res),&(features->training.ns_res)); + + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + features->f_normalize=(int *)G_calloc(2,sizeof(int)); + sscanf(line,"%d",&(features->f_normalize[0])); + if(features->f_normalize[0]){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_normalize[1])); + features->f_normalize=(int*)realloc(features->f_normalize, + (2+features->f_normalize[1])*sizeof(int)); + for(i=0;if_normalize[1];i++){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_normalize[i+2])); + features->f_normalize[i+2] -= 1; + } + } + + line=GetLine(fp); + line=GetLine(fp); + features->f_standardize=(int *)G_calloc(2,sizeof(int)); + sscanf(line,"%d",&(features->f_standardize[0])); + if(features->f_standardize[0]){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_standardize[1])); + features->f_standardize=(int*)realloc(features->f_standardize, + (2+features->f_standardize[1])*sizeof(int)); + for(i=0;if_standardize[1];i++){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_standardize[i+2])); + features->f_standardize[i+2] -= 1; + } + } + + line=GetLine(fp); + line=GetLine(fp); + features->f_mean=(int *)G_calloc(2,sizeof(int)); + sscanf(line,"%d",&(features->f_mean[0])); + if(features->f_mean[0]){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_mean[1])); + features->f_mean=(int*)realloc(features->f_mean, + (2+features->f_mean[1])*sizeof(int)); + for(i=0;if_mean[1];i++){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_mean[i+2])); + features->f_mean[i+2] -= 1; + } + } + + line=GetLine(fp); + line=GetLine(fp); + features->f_variance=(int *)G_calloc(2,sizeof(int)); + sscanf(line,"%d",&(features->f_variance[0])); + if(features->f_variance[0]){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_variance[1])); + features->f_variance=(int*)realloc(features->f_variance, + (2+features->f_variance[1])*sizeof(int)); + for(i=0;if_variance[1];i++){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_variance[i+2])); + features->f_variance[i+2] -= 1; + } + } + + line=GetLine(fp); + line=GetLine(fp); + features->f_pca=(int *)G_calloc(2,sizeof(int)); + sscanf(line,"%d",&(features->f_pca[0])); + if(features->f_pca[0]){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_pca[1])); + features->f_pca=(int*)realloc(features->f_pca, + (2+features->f_pca[1])*sizeof(int)); + for(i=0;if_pca[1];i++){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_pca[i+2])); + features->f_pca[i+2] -= 1; + } + } + + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d",&(features->nclasses)); + features->p_classes=(int *)G_calloc(features->nclasses,sizeof(int)); + line=GetLine(fp); + line=GetLine(fp); + for(i=0;inclasses;i++){ + sscanf(line,"%d", &(features->p_classes[i])); + line = (char *)strchr(line, '\t'); + *line++; + } + + if(!features->f_standardize[0]){ + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + }else{ + features->mean=(double *)G_calloc(features->f_standardize[1],sizeof(double)); + features->sd=(double *)G_calloc(features->f_standardize[1],sizeof(double)); + line=GetLine(fp); + line=GetLine(fp); + for(i=0;if_standardize[1];i++){ + sscanf(line,"%lf", &(features->mean[i])); + line = (char *)strchr(line, '\t'); + *line++; + } + line=GetLine(fp); + for(i=0;if_standardize[1];i++){ + sscanf(line,"%lf", &(features->sd[i])); + line = (char *)strchr(line, '\t'); + *line++; + } + } + + + if(features->f_pca[0]){ + features->pca=(Pca *)G_calloc(features->f_pca[1],sizeof(Pca)); + } + + + if(npc>(features->training.rows*features->training.cols)){ + npc=features->training.rows*features->training.cols; + } + + dim=features->training.rows * features->training.cols; + line=GetLine(fp); + line=GetLine(fp); + if((!features->f_pca[0]) || (features->f_pca[0] && npc<0)){ + sscanf(line,"%d%d",&(features->nexamples),&(features->examples_dim)); + + features->value=(double **)G_calloc(features->nexamples,sizeof(double *)); + for(i=0;inexamples;i++){ + features->value[i]=(double *)G_calloc(features->examples_dim,sizeof(double)); + } + features->class=(int *)G_calloc(features->nexamples,sizeof(int)); + + line=GetLine(fp); + line=GetLine(fp); + for(i=0;inexamples;i++){ + line=GetLine(fp); + for(j=0;jexamples_dim;j++){ + sscanf(line,"%lf", &(features->value[i][j])); + line = (char *)strchr(line, '\t'); + *line++; + } + sscanf(line,"%d", &(features->class[i])); + } + }else{ + sscanf(line,"%d%d",&(features->nexamples),&orig_dim); + + features_to_be_loaded=(int *)G_calloc(orig_dim,sizeof(int)); + + corrent_feature=0; + features->examples_dim=0; + for(i=0;itraining.nlayers;i++){ + if(features->f_mean[0]){ + for(j=2;j<2+features->f_mean[1];j++){ + if(features->f_mean[j] == i){ + features_to_be_loaded[corrent_feature] = 1; + corrent_feature += 1; + features->examples_dim += 1; + } + } + } + if(features->f_variance[0]){ + for(j=2;j<2+features->f_variance[1];j++){ + if(features->f_variance[j] == i){ + features_to_be_loaded[corrent_feature] = 1; + corrent_feature += 1; + features->examples_dim += 1; + } + } + } + if(features->f_pca[0]){ + for(j=2;j<2+features->f_pca[1];j++){ + if(features->f_pca[j] == i){ + for(r=0;rexamples_dim += npc; + } + } + } + + } + + features->value=(double **)G_calloc(features->nexamples,sizeof(double *)); + for(i=0;inexamples;i++){ + features->value[i]=(double *)G_calloc(features->examples_dim, + sizeof(double)); + } + features->class=(int *)G_calloc(features->nexamples,sizeof(int)); + + line=GetLine(fp); + line=GetLine(fp); + for(i=0;inexamples;i++){ + line=GetLine(fp); + index=0; + for(j=0;jvalue[i][index++])); + } + line = (char *)strchr(line, '\t'); + *line++; + } + sscanf(line,"%d", &(features->class[i])); + } + + } + if(features->f_pca[0]){ + line=GetLine(fp); + + for(l=0;lf_pca[1];l++){ + features->pca[l].n=features->training.rows * features->training.cols; + read_pca(fp,&(features->pca[l])); + } + } + fclose(fp); +} + + +void read_header_features(fp,features) + /* + read the hearder features from the file pointed + */ + FILE *fp; + Features *features; +{ + char *line = NULL; + int i; + + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d",&(features->training.data_type)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d",&(features->training.nlayers)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d%d",&(features->training.rows),&(features->training.cols)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%lf%lf",&(features->training.ew_res),&(features->training.ns_res)); + + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + features->f_normalize=(int *)G_calloc(2,sizeof(int)); + sscanf(line,"%d",&(features->f_normalize[0])); + if(features->f_normalize[0]){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_normalize[1])); + features->f_normalize=(int*)realloc(features->f_normalize, + (2+features->f_normalize[1])*sizeof(int)); + for(i=0;if_normalize[1];i++){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_normalize[i+2])); + features->f_normalize[i+2] -= 1; + } + } + + line=GetLine(fp); + line=GetLine(fp); + features->f_standardize=(int *)G_calloc(2,sizeof(int)); + sscanf(line,"%d",&(features->f_standardize[0])); + if(features->f_standardize[0]){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_standardize[1])); + features->f_standardize=(int*)realloc(features->f_standardize, + (2+features->f_standardize[1])*sizeof(int)); + for(i=0;if_standardize[1];i++){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_standardize[i+2])); + features->f_standardize[i+2] -= 1; + } + } + + line=GetLine(fp); + line=GetLine(fp); + features->f_mean=(int *)G_calloc(2,sizeof(int)); + sscanf(line,"%d",&(features->f_mean[0])); + if(features->f_mean[0]){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_mean[1])); + features->f_mean=(int*)realloc(features->f_mean, + (2+features->f_mean[1])*sizeof(int)); + for(i=0;if_mean[1];i++){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_mean[i+2])); + features->f_mean[i+2] -= 1; + } + } + + line=GetLine(fp); + line=GetLine(fp); + features->f_variance=(int *)G_calloc(2,sizeof(int)); + sscanf(line,"%d",&(features->f_variance[0])); + if(features->f_variance[0]){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_variance[1])); + features->f_variance=(int*)realloc(features->f_variance, + (2+features->f_variance[1])*sizeof(int)); + for(i=0;if_variance[1];i++){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_variance[i+2])); + features->f_variance[i+2] -= 1; + } + } + + line=GetLine(fp); + line=GetLine(fp); + features->f_pca=(int *)G_calloc(2,sizeof(int)); + sscanf(line,"%d",&(features->f_pca[0])); + if(features->f_pca[0]){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_pca[1])); + features->f_pca=(int*)realloc(features->f_pca, + (2+features->f_pca[1])*sizeof(int)); + for(i=0;if_pca[1];i++){ + line = (char *)strchr(line, '\t'); + line++; + sscanf(line,"%d",&(features->f_pca[i+2])); + features->f_pca[i+2] -= 1; + } + } + + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d",&(features->nclasses)); + features->p_classes=(int *)G_calloc(features->nclasses,sizeof(int)); + line=GetLine(fp); + line=GetLine(fp); + for(i=0;inclasses;i++){ + sscanf(line,"%d", &(features->p_classes[i])); + line = (char *)strchr(line, '\t'); + *line++; + } + + if(!features->f_standardize[0]){ + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + }else{ + features->mean=(double *)G_calloc(features->f_standardize[1],sizeof(double)); + features->sd=(double *)G_calloc(features->f_standardize[1],sizeof(double)); + line=GetLine(fp); + line=GetLine(fp); + for(i=0;if_standardize[1];i++){ + sscanf(line,"%lf", &(features->mean[i])); + line = (char *)strchr(line, '\t'); + *line++; + } + line=GetLine(fp); + for(i=0;if_standardize[1];i++){ + sscanf(line,"%lf", &(features->sd[i])); + line = (char *)strchr(line, '\t'); + *line++; + } + } + + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d%d",&(features->nexamples),&(features->examples_dim)); +} Property changes on: trunk/grassaddons/i.pr/PRLIB/features.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/features_selection.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/features_selection.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/features_selection.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,700 @@ +/* + The following routines are written and tested by Stefano Merler + + and Maria Serafini + + for + + Features Selction with SVM +*/ + +#include "gis.h" +#include "global.h" +#include +#include +#include +#include + + +void compute_valoriDJ(svm,features,H_tot,H_tmp,valoriDJ) + SupportVectorMachine *svm; + Features *features; + double **H_tot,**H_tmp,**valoriDJ; +{ + double diag,resto; + int i,j,t; + double DJ; + + (*valoriDJ)=(double*)calloc(svm->d,sizeof(double)); + + + diag=0; + resto=0; + + for(i=0;inexamples;i++){ + if(svm->alph[i]!=0){ + diag=diag+svm->alph[i]*svm->alph[i]*H_tot[i][i]; + for(j=i+1;jnexamples;j++){ + if(svm->alph[j]!=0){ + resto=resto+svm->alph[i]*svm->alph[j]*H_tot[i][j]; + } + } + } + } + + DJ=0.5*diag+resto; + + for(i=0;id;i++){ + compute_H_perdiff(H_tot,H_tmp,features->value, + features->nexamples,svm->two_sigma_squared,i); + + (*valoriDJ)[i]=0; + + diag=0; + resto=0; + + for(t=0;tnexamples;t++){ + if(svm->alph[t]!=0){ + diag=diag+svm->alph[t]*svm->alph[t]*H_tmp[t][t]; + for(j=t+1;jnexamples;j++){ + if(svm->alph[j]!=0){ + resto=resto+svm->alph[t]*svm->alph[j]*H_tmp[t][j]; + } + } + } + } + + (*valoriDJ)[i]=0.5*diag+resto; + + (*valoriDJ)[i]=DJ-(*valoriDJ)[i]; + } + +} + +void free_svm(svm) + SupportVectorMachine *svm; +{ + int j; + + for(j=0;jN;j++){ + free(svm->dense_points[j]); + } + free(svm->target); + free(svm->Cw); + free(svm->alph); + free(svm->w); + free(svm->error_cache); + free(svm->precomputed_self_dot_product); +} + + +void e_rfe_lin(svm,features,names,selected,i,rimanenti,fp_fs_w,fp_fs_stats) + SupportVectorMachine *svm; + Features *features; + int *names, *selected; + int i; + int *rimanenti; + FILE *fp_fs_w,*fp_fs_stats; +{ + double *wsquare; + int j; + int *h; + int nbin; + double *pi; + double entro; + double maxentro,media; + int nel; + int *eliminati; + double *valoriDJ; + int index; + double lim; + double *wlog; + int minorimedia; + double mediamod; + int conv; + int *sortindex,*indexordinati; + int k,t; + + wsquare=(double*)calloc(*rimanenti,sizeof(double)); + + for(j=0;j<*rimanenti;j++){ + wsquare[j]=svm->w[j]*svm->w[j]; + } + + + if(fp_fs_w!=NULL){ + fprintf(fp_fs_w,"%6.10f",wsquare[0]); + for(j=1;j<*rimanenti;j++){ + fprintf(fp_fs_w,"\t%f",wsquare[j]); + } + fprintf(fp_fs_w,"\n"); + } + + nbin=(int) floor(sqrt(*rimanenti)); + traslo(wsquare,*rimanenti); + h=(int*)calloc(nbin,sizeof(int)); + histo1(wsquare,*rimanenti,h,nbin); + pi=(double*)calloc(nbin,sizeof(double)); + for(j=0;j0.5*maxentro && media >0.2){ + + nel=h[0]; + + if(fp_fs_stats!=NULL) + fprintf(fp_fs_stats,"%d\tunif\t%f\t%f\t%d\n", + *rimanenti,entro,maxentro,nel); + + eliminati=(int*)calloc(nel,sizeof(int)); + valoriDJ=(double*)calloc(nel,sizeof(double)); + + index=0; + + lim= (double) 1/nbin; + + for(j=0;j<*rimanenti;j++){ + if(wsquare[j]<=lim){ + eliminati[index]=j; + valoriDJ[index]=wsquare[j]; + index +=1; + } + } + + }else{ + + wlog=(double*)calloc(*rimanenti,sizeof(double)); + + for(j=0;j<*rimanenti;j++){ + wlog[j]=log(wsquare[j]+1.0); + } + + media=0.0; + + for(j=0;j<*rimanenti;j++){ + media += wlog[j]; + } + + media /= *rimanenti; + + minorimedia=0; + + for(j=0;j<*rimanenti;j++){ + if(wlog[j]nexamples;t++){ + features->value[t][k]=features->value[t][k+1]; + } + names[k]=names[k+1]; + } + for(k=j+1;k0.5*maxentro && media >0.2){ + + nel=h[0]; + + if(fp_fs_stats!=NULL) + fprintf(fp_fs_stats,"%d\tunif\t%f\t%f\t%d\n", + *rimanenti,entro,maxentro,nel); + + eliminati=(int*)calloc(nel,sizeof(int)); + valorieliminati=(double*)calloc(nel,sizeof(double)); + + index=0; + + lim= (double) 1/nbin; + + for(j=0;j<*rimanenti;j++){ + if(valoriDJ[j]<=lim){ + eliminati[index]=j; + valorieliminati[index]=valoriDJ[j]; + index +=1; + } + } + + }else{ + + wlog=(double*)calloc(*rimanenti,sizeof(double)); + + for(j=0;j<*rimanenti;j++){ + wlog[j]=log(valoriDJ[j]+1.0); + } + + media=0.0; + + for(j=0;j<*rimanenti;j++){ + media += wlog[j]; + } + + media /= *rimanenti; + + minorimedia=0; + + for(j=0;j<*rimanenti;j++){ + if(wlog[j]value,features->nexamples, + svm_kp,eliminati[k]); + + for(j=0;jnexamples;j++){ + for(t=0;tnexamples;t++){ + H_tot[j][t]=H_tmp[j][t]; + } + } + } + + + for(j=0;jnexamples;t++){ + features->value[t][k]=features->value[t][k+1]; + } + names[k]=names[k+1]; + } + for(k=j+1;kd,sizeof(double)); + sortindex=(int*)calloc(svm->d,sizeof(int)); + + + for(j=0;jd;j++){ + wsquare[j]=svm->w[j]*svm->w[j]; + } + + if(fp_fs_w!=NULL){ + fprintf(fp_fs_w,"%6.10f",wsquare[0]); + for(j=1;jd;j++){ + fprintf(fp_fs_w,"\t%6.10f",wsquare[j]); + } + fprintf(fp_fs_w,"\n"); + } + + indexx_1(svm->d,wsquare,sortindex); + + for(i=0;id;i++){ + selected[svm->d-i-1]=names[sortindex[i]]; + } + + free(wsquare); + free(sortindex); +} + +void one_rfe_gauss(valoriDJ,names,selected,n,fp_fs_w) + double *valoriDJ; + int *names, *selected; + int n; + FILE *fp_fs_w; +{ + int i,j; + int *sortindex; + + if(fp_fs_w!=NULL){ + fprintf(fp_fs_w,"%6.10f",valoriDJ[0]); + for(j=1;jd,sizeof(double)); + + for(j=0;jd;j++){ + wsquare[j]=svm->w[j]*svm->w[j]; + } + + + if(fp_fs_w!=NULL){ + fprintf(fp_fs_w,"%6.10f",wsquare[0]); + for(j=1;jd;j++){ + fprintf(fp_fs_w,"\t%6.10f",wsquare[j]); + } + fprintf(fp_fs_w,"\n"); + } + + wmin=wsquare[0]; + wmin_index=0; + + for(j=1;jd;j++){ + if(wmin>wsquare[j]){ + wmin=wsquare[j]; + wmin_index=j; + } + } + + selected[features->examples_dim-i-1]=names[wmin_index]; + + for(j=wmin_index;jexamples_dim;j++){ + for(t=0;tnexamples;t++){ + features->value[t][j]=features->value[t][j+1]; + } + names[j]=names[j+1]; + } + free(wsquare); +} + +void rfe_gauss(valoriDJ,features,names,selected,i,H_tot,H_tmp,svm_kp,fp_fs_w) + Features *features; + double *valoriDJ; + int *names, *selected; + double **H_tot,**H_tmp; + int i; + double svm_kp; + FILE *fp_fs_w; +{ + double wmin; + int wmin_index; + int j,t; + + + if(fp_fs_w!=NULL){ + fprintf(fp_fs_w,"%6.10f",valoriDJ[0]); + for(j=1;jexamples_dim-i;j++){ + fprintf(fp_fs_w,"\t%6.10f",valoriDJ[j]); + } + fprintf(fp_fs_w,"\n"); + } + + wmin=valoriDJ[0]; + wmin_index=0; + + for(j=1;jexamples_dim-i;j++){ + if(wmin>valoriDJ[j]){ + wmin=valoriDJ[j]; + wmin_index=j; + } + } + + selected[features->examples_dim-i-1]=names[wmin_index]; + + + compute_H_perdiff(H_tot,H_tmp,features->value,features->nexamples, + svm_kp,wmin_index); + + for(j=0;jnexamples;j++){ + for(t=0;tnexamples;t++){ + H_tot[j][t]=H_tmp[j][t]; + } + } + + + for(j=wmin_index;jexamples_dim-i-1;j++){ + for(t=0;tnexamples;t++){ + features->value[t][j]=features->value[t][j+1]; + } + names[j]=names[j+1]; + } + +} + +void compute_H(matrix,XX,y,ndati,nfeat,sigma) + double **matrix,**XX; + int *y; + double sigma; + int ndati,nfeat; +{ + int r,s; + + + for(r=0;r +#include +#include "global.h" + +char *GetLine(fp) + /* + get a line from a buffered stream (pointed from fp) + */ + FILE *fp; +{ + char line[BUFFSIZE], *p=NULL; + strcpy(line,""); + + while(strlen(line) == 0 && !feof(fp)){ + p = fgets(line, BUFFSIZE, fp); + if(*line == '#' || strlen(line) == 1) + strcpy(line, ""); + } + + if(p){ + line[strlen(line)-1] = '\0'; + return (char *) strdup(line); + } + else + return NULL; + +} + Property changes on: trunk/grassaddons/i.pr/PRLIB/getline.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/gm.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/gm.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/gm.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,435 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + structure GaussianMixture management +*/ + +#include "gis.h" +#include "global.h" +#include +#include +#include + +static void compute_covar(); +static void compute_mean(); + +void compute_gm(gm,nsamples,nvar,data,data_class,nclasses,classes) + /* + Compute gm model, given a matrix of examples data of dimension + nsamples x nvar. Classes of each example are contained in data_class. + the array classes (of length nclasses) shall contain all the possible + classes of the array data_class + */ + GaussianMixture *gm; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; +{ + double ***tmpMat; + int *index2; + int i,j,k; + + gm->classes=classes; + gm->nclasses=nclasses; + + gm->npoints_for_class=(int *) G_calloc(gm->nclasses,sizeof(int)); + for(i=0;inclasses;j++){ + if(data_class[i] == gm->classes[j]){ + gm->npoints_for_class[j]+=1; + } + } + } + + gm->nvars = nvar; + gm->priors = (double *) G_calloc(gm->nclasses, sizeof(double)); + gm->mean=(double **) G_calloc(gm->nclasses, sizeof(double *)); + for(i=0;inclasses;i++) + gm->mean[i] = (double *) G_calloc(gm->nvars, sizeof(double)); + gm->det = (double *) G_calloc(gm->nclasses, sizeof(double)); + gm->covar = (double ***) G_calloc(gm->nclasses, sizeof(double **)); + for(i=0;inclasses;i++){ + gm->covar[i] = (double **) G_calloc(gm->nvars, sizeof(double *)); + for(j=0;jnvars;j++) + gm->covar[i][j] = (double *) G_calloc(gm->nvars, sizeof(double)); + } + tmpMat = (double ***) G_calloc(gm->nclasses, sizeof(double **)); + for(i=0;inclasses;i++){ + tmpMat[i] = (double **) G_calloc(gm->npoints_for_class[i], sizeof(double *)); + for(j=0;jnpoints_for_class[i];j++) + tmpMat[i][j] = (double *) G_calloc(gm->nvars, sizeof(double)); + } + + index2 = (int *) G_calloc(gm->nclasses,sizeof(int)); + for(i=0;inclasses;j++) + if(data_class[i]==gm->classes[j]){ + for(k=0;knvars;k++) + tmpMat[j][index2[j]][k] = data[i][k]; + index2[j] += 1; + } + + for(i=0;inclasses;i++) + compute_mean(tmpMat,gm,i); + + for(i=0;inclasses;i++) + compute_covar(tmpMat,gm,i); + + for(i=0;inclasses;i++) + gm->priors[i] = (double)gm->npoints_for_class[i] / (double)nsamples; + + for(i=0;inclasses;i++) + for(j=0;jnpoints_for_class[i];j++) + free(tmpMat[i][j]); + free(tmpMat); + free(index2); +} + + +static void compute_covar(mat,gm,class) + /* + compute covariance matrix of all the classes + */ + double ***mat; + int class; + GaussianMixture *gm; +{ + int i, j, k; + + for(i = 0; i < gm->nvars; i++) + for(j = i; j < gm->nvars; j++){ + for(k = 0; k < gm->npoints_for_class[class]; k++){ + gm->covar[class][i][j] += (mat[class][k][i] - gm->mean[class][i]) * + (mat[class][k][j] - gm->mean[class][j]); + } + gm->covar[class][j][i] = gm->covar[class][i][j]; + } + for(i = 0; i < gm->nvars; i++) + for(j = 0; j < gm->nvars; j++) + gm->covar[class][i][j] /= ((double)gm->npoints_for_class[class] - 1.); +} + +static void compute_mean(mat,gm,class) + /* + compute the mean of each variable for all the classes + */ + double ***mat; + int class; + GaussianMixture *gm; +{ + int i,j; + + for(i=0;i < gm->nvars;i++) + for(j=0;j< gm->npoints_for_class[class];j++) + gm->mean[class][i] += mat[class][j][i]; + + for(i=0;i < gm->nvars;i++) + gm->mean[class][i] /= gm->npoints_for_class[class]; +} + +void write_gm(file,gm,features) + /* + write gm structure to a file + */ + char *file; + GaussianMixture *gm; + Features *features; +{ + FILE *fpout; + int i,j,k; + char tempbuf[500]; + + fpout = fopen(file, "w"); + if(fpout == NULL){ + sprintf(tempbuf, "write_gm-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + write_header_features(fpout,features); + fprintf(fpout,"#####################\n"); + fprintf(fpout,"MODEL:\n"); + fprintf(fpout,"#####################\n"); + + fprintf(fpout,"Model:\n"); + fprintf(fpout,"GaussianMixture\n"); + fprintf(fpout,"nclasses:\n"); + fprintf(fpout,"%d\n",gm->nclasses); + + fprintf(fpout,"nvars:\n"); + fprintf(fpout,"%d\n",gm->nvars); + + fprintf(fpout,"classes:\n"); + fprintf(fpout,"%d",gm->classes[0]); + for(i=1;inclasses;i++) + fprintf(fpout,"\t%d",gm->classes[i]); + fprintf(fpout,"\n"); + + fprintf(fpout,"priors:\n"); + fprintf(fpout,"%f",gm->priors[0]); + for(i=1;inclasses;i++) + fprintf(fpout,"\t%f",gm->priors[i]); + fprintf(fpout,"\n"); + + for(i=0;inclasses;i++){ + fprintf(fpout,"CLASS %d:\n",gm->classes[i]); + fprintf(fpout,"mean:\n"); + fprintf(fpout,"%f",gm->mean[i][0]); + for(j=1;jnvars;j++) + fprintf(fpout,"\t%f",gm->mean[i][j]); + fprintf(fpout,"\n"); + fprintf(fpout,"covar:\n"); + for(j = 0; j < gm->nvars; j++){ + fprintf(fpout,"%f",gm->covar[i][j][0]); + for(k = 1; k < gm->nvars; k++) + fprintf(fpout,"\t%f",gm->covar[i][j][k]); + fprintf(fpout,"\n"); + } + } + + if(features->f_pca[0]){ + fprintf(fpout,"#####################\n"); + fprintf(fpout,"PRINC. COMP.:\n"); + fprintf(fpout,"#####################\n"); + + fprintf(fpout,"Number of pc:\n"); + fprintf(fpout,"%d\n",features->npc); + + for(i=0;if_pca[1];i++){ + fprintf(fpout,"PCA: Layer %d\n",i+1); + write_pca(fpout,&(features->pca[i])); + } + } + + fclose(fpout); +} + + +void test_gm(gm,features,file) + /* + test gm model on a set of data (features) and write the results + into a file. To standard output accuracy and error on each class + */ + GaussianMixture *gm; + Features *features; + char *file; +{ + int i,j; + int *data_in_each_class; + FILE *fp; + char tempbuf[500]; + int predI; + double predD; + double *error; + double accuracy; + + + fp = fopen(file, "w"); + if(fp == NULL){ + sprintf(tempbuf, "test_gm-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + data_in_each_class=(int *)G_calloc(features->nclasses,sizeof(int)); + error=(double *)G_calloc(features->nclasses,sizeof(double)); + + accuracy = 0.0; + for(i=0;inexamples;i++){ + for(j=0;jnclasses;j++){ + if(features->class[i] == features->p_classes[j]){ + data_in_each_class[j] += 1; + if(features->nclasses==2){ + if((predD=predict_gm_2class(gm,features->value[i])) * features->class[i] <= 0){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%f\n",features->class[i],predD); + }else{ + if((predI=predict_gm_multiclass(gm,features->value[i])) != features->class[i]){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%d\n",features->class[i],predI); + } + break; + } + } + } + + accuracy /= features->nexamples; + accuracy = 1.0-accuracy; + + fclose(fp); + + fprintf(stdout,"Accuracy: %f\n",accuracy); + fprintf(stdout,"Class\t%d",features->p_classes[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",features->p_classes[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Ndata\t%d",data_in_each_class[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",data_in_each_class[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Nerrors\t%d",(int)error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",(int)error[j]); + } + fprintf(stdout,"\n"); + + for(j=0;jnclasses;j++){ + error[j] /= data_in_each_class[j]; + } + + fprintf(stdout,"Perrors\t%f",error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%f",error[j]); + } + fprintf(stdout,"\n"); + free(data_in_each_class); + free(error); +} + + +void compute_test_gm(gm) + /* + compute inverse and determinant of each covariance matrix of a gm model + */ + GaussianMixture *gm; +{ + int i,j; + + gm->det = (double *) G_calloc(gm->nclasses, sizeof(double)); + gm->inv_covar = (double ***) G_calloc(gm->nclasses, sizeof(double **)); + for(i=0;inclasses;i++){ + gm->inv_covar[i] = (double **) G_calloc(gm->nvars, sizeof(double *)); + for(j=0;jnvars;j++) + gm->inv_covar[i][j] = (double *) G_calloc(gm->nvars, sizeof(double)); + } + + for(j=0;jnclasses;j++){ + gm->det[j] = determinant_of_double_matrix(gm->covar[j],gm->nvars); + inverse_of_double_matrix(gm->covar[j],gm->inv_covar[j],gm->nvars); + } +} + + +int predict_gm_multiclass(gm,x) + /* + multiclass problems: given a gm model, return the predicted class + of a test point x + */ + GaussianMixture *gm; + double *x; +{ + int i,j,c; + double *tmpVect; + double *distmean; + double *posteriors; + double delta; + double max_posterior; + int max_posterior_index; + char tempbuf[500]; + + tmpVect = (double *)G_calloc(gm->nvars,sizeof(double)); + distmean= (double *)G_calloc(gm->nvars,sizeof(double)); + posteriors= (double *)G_calloc(gm->nclasses,sizeof(double)); + + for(c=0;cnclasses;c++){ + for(i=0;invars;i++) + distmean[i] = x[i] - gm->mean[c][i]; + + for(i=0;invars;i++) + tmpVect[i] = 0.0; + + for(i=0;invars;i++) + for(j=0;jnvars;j++) + tmpVect[i] += distmean[j] * gm->inv_covar[c][j][i]; + + delta=0.0; + for(i=0;invars;i++) + delta += tmpVect[i] * distmean[i]; + + if(gm->det[c] > 0.0){ + posteriors[c] = exp(-0.5 * delta)/ sqrt(gm->det[c]); + }else{ + sprintf(tempbuf, "predict_gm_multiclass-> det. of cov. matrix of class %d = 0",c); + G_fatal_error(tempbuf); + } + posteriors[c] = posteriors[c] * gm->priors[c]; + } + + max_posterior = 0.0; + max_posterior_index =0; + for(c=0;cnclasses;c++) + if(posteriors[c] > max_posterior){ + max_posterior = posteriors[c]; + max_posterior_index = c; + } + + free(tmpVect); + free(distmean); + free(posteriors); + + return gm->classes[max_posterior_index]; + +} + +double predict_gm_2class(gm,x) + /* + 2 class problems: given a gm model , return the posterior of class (with sign) for + a test point x + */ + GaussianMixture *gm; + double *x; +{ + int i,j,c; + double *tmpVect; + double *distmean; + double *posteriors; + double delta; + char tempbuf[500]; + + tmpVect = (double *)G_calloc(gm->nvars,sizeof(double)); + distmean= (double *)G_calloc(gm->nvars,sizeof(double)); + posteriors= (double *)G_calloc(gm->nclasses,sizeof(double)); + + for(c=0;cnclasses;c++){ + for(i=0;invars;i++) + distmean[i] = x[i] - gm->mean[c][i]; + + for(i=0;invars;i++) + tmpVect[i] = 0.0; + + for(i=0;invars;i++) + for(j=0;jnvars;j++) + tmpVect[i] += distmean[j] * gm->inv_covar[c][j][i]; + + delta=0.0; + for(i=0;invars;i++) + delta += tmpVect[i] * distmean[i]; + + if(gm->det[c] > 0.0){ + posteriors[c] = exp(-0.5 * delta)/ sqrt(gm->det[c]); + }else{ + sprintf(tempbuf, "predict_gm_2class-> det. of cov. matrix of class %d = 0",c); + G_fatal_error(tempbuf); + } + posteriors[c] = posteriors[c] * gm->priors[c]; + } + + + free(tmpVect); + free(distmean); + + if(posteriors[0]>posteriors[1]){ + return posteriors[0]/(posteriors[0]+posteriors[1])*gm->classes[0]; + }else{ + return posteriors[1]/(posteriors[0]+posteriors[1])*gm->classes[1]; + } +} + Property changes on: trunk/grassaddons/i.pr/PRLIB/gm.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/integration.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/integration.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/integration.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,182 @@ +/* + Same of the following routines are borrowed from "Numerical Recipes in C" + other are written and tested by Stefano Merler + + for + + integration of function using the trapezoidal rule + + Supported function for + - non-parametric functions + - functions depending from 1 parameter + - functions depending from 2 parameters +*/ + + +#include +#include + +#define FUNC(x) ((*func)(x)) +#define EPS 1.0e-5 +#define JMAX 1000 + +double trapzd(func,a,b,n) + /* + trapezoidal rule for func=func(x) on interval [a,b] + n = steps number + */ + double a,b; + double (*func)(); + int n; +{ + double x,tnm,sum,del; + double s; + int j; + + if(n==1){ + return (s=0.5*(b-a)*(FUNC(a)+FUNC(b))); + } + else{ + tnm=n; + del=(b-a)/tnm; + x=a+0.5*del; + for(sum=0.0,j=1;j<=n;j++,x+=del) sum += FUNC(x); + s=(b-a)*sum/tnm; + return s; + } +} + +double trapzd1(func,p1,a,b,n) + /* + trapezoidal rule for func=func(x; p1) on interval [a,b] + p1 free parameter + n = steps number + */ + double a,b; + double p1; + double (*func)(); + int n; +{ + double x,tnm,sum,del; + double s; + int j; + + if(n==1){ + return (s=0.5*(b-a)*(func(a,p1)+func(b,p1))); + } + else{ + tnm=n; + del=(b-a)/tnm; + x=a+0.5*del; + for(sum=0.0,j=1;j<=n;j++,x+=del) sum += func(x,p1); + s=(b-a)*sum/tnm; + return s; + } +} + +double trapzd2(func,p1,p2,a,b,n) + /* + trapezoidal rule for func=func(x; p1,p2) on interval [a,b] + p1 and p2 free parameters + n = steps number + */ + double a,b; + double p1,p2; + double (*func)(); + int n; +{ + double x,tnm,sum,del; + double s; + int j; + + if(n==1){ + return (s=0.5*(b-a)*(func(a,p1,p2)+func(b,p1,p2))); + } + else{ + tnm=n; + del=(b-a)/tnm; + x=a+0.5*del; + for(sum=0.0,j=1;j<=n;j++,x+=del) sum += func(x,p1,p2); + s=(b-a)*sum/tnm; + return s; + } +} + +double qtrap(func,a,b) + /* + trapezoidal rule for func=func(x) with stopping rule + */ + double a,b; + double (*func)(); +{ + int j; + double s, olds; + + olds = -1.0e-30; + + for(j=1;j<=JMAX;j++){ + s = trapzd(func,a,b,j); + if(fabs(s - olds) < EPS * fabs(olds)) + return s; + olds=s; + } + + fprintf(stderr,"Too many steps in routine qtrap\n"); + return s; +} + + +double qtrap1(func,p1,a,b) + /* + trapezoidal rule for func=func(x) on interval [a,b] + with internal stopping rule + p1 free parameter + */ + double a,b; + double p1; + double (*func)(); +{ + int j; + double s, olds; + + olds = -1.0e-30; + + for(j=1;j<=JMAX;j++){ + s = trapzd(func,p1,a,b,j); + if(fabs(s - olds) < EPS * fabs(olds)) + return s; + olds=s; + } + + fprintf(stderr,"Too many steps in routine qtrap\n"); + return s; +} + +double qtrap2(func,p1,p2,a,b) + /* + trapezoidal rule for func=func(x) on interval [a,b] + with internal stopping rule + p1 and p2 free parameters + */ + double a,b; + double p1,p2; + double (*func)(); +{ + int j; + double s, olds; + + olds = -1.0e-30; + + for(j=1;j<=JMAX;j++){ + s = trapzd(func,p1,p2,a,b,j); + if(fabs(s - olds) < EPS * fabs(olds)) + return s; + olds=s; + } + + fprintf(stderr,"Too many steps in routine qtrap\n"); + return s; +} + +#undef EPS +#undef JMAX Property changes on: trunk/grassaddons/i.pr/PRLIB/integration.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/lu.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/lu.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/lu.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,193 @@ +/* + Same 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 +#include +#include + + +#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;ibig) 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=big) + { + big=dum; + imax=i; + } + } + if (j!=imax) + { + for (k=0;k=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 +#include + +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 +#include +#include +#include "func.h" + +void mqc(M,m,n,H,h,mH,K,k,mK,eps,x,minvalue) + double **M,*m; + double **H,*h; + double **K,*k; + int n,mH,mK; + double eps; + double *x; + double *minvalue; +{ + int i,j,l; + + double **invM; + double **HM,**HMH,*tnH,**HMK,**KM,**KMK,*tnK,**tH,**tK; + double mMm; + double gap; + double *alpha,*beta; + double L,f; + double tmpalpha,tmpbeta,tmpL,tmpf; + + /*alloc memory*/ + invM=(double**)calloc(n,sizeof(double*)); + for(i=0;i0){ + HM=(double**)calloc(mH,sizeof(double*)); + for(i=0;i0 && mK>0){ + HMK=(double**)calloc(mH,sizeof(double*)); + for(i=0;i0){ + KM=(double**)calloc(mK,sizeof(double*)); + for(i=0;i0){ + product_double_matrix_double_matrix(H,invM,mH,n,n,HM); + product_double_matrix_double_matrix(HM,tH,mH,n,mH,HMH); + product_double_matrix_double_vector(HM,m,mH,n,tnH); + for(i=0;i0 && mK>0) + product_double_matrix_double_matrix(HM,tK,mH,n,mK,HMK); + + if(mK>0){ + product_double_matrix_double_matrix(K,invM,mK,n,n,KM); + product_double_matrix_double_matrix(KM,tK,mK,n,mK,KMK); + product_double_matrix_double_vector(KM,m,mK,n,tnK); + for(i=0;i0) + alpha=(double*)calloc(mH,sizeof(double)); + if(mK>0) + beta=(double*)calloc(mK,sizeof(double)); + + gap=eps+1; + /*gradient ascendent on the dual Lagrangian*/ + while(gap>eps){ + if(mH>0 && mK>0){ + for(l=0;l0) + tmpalpha += HMH[i][l]*alpha[i]; + + tmpalpha += tnH[l]; + + + for(i=0;i0) + tmpbeta += HMK[i][l]*alpha[i]; + + beta[l] -= tmpbeta/KMK[l][l]; + + } + }else if(mH>0 && mK==0){ + for(l=0;l0) + tmpalpha += HMH[i][l]*alpha[i]; + + tmpalpha += tnH[l]; + + alpha[l] -= tmpalpha/HMH[l][l]; + if(alpha[l] < .0) + alpha[l] = .0; + } + }else if(mH==0 && mK>0){ + for(l=0;l0) + for(j=0;j0) + tmpL += alpha[i]*alpha[j]*HMH[i][j]; + L -= .5*tmpL; + + tmpL=.0; + for(i=0;i0) + tmpL += alpha[i]*tnH[i]; + L -= tmpL; + + tmpL=.0; + for(i=0;i0) + for(j=0;j0) + tmpf += alpha[i]*tnH[i]; + f -= .5*tmpf; + + tmpf=.0; + for(i=0;i0) + x[l] +=HM[i][l]*alpha[i]; + + for(i=0;i0){ + free(alpha); + free(tnH); + for(i=0;i0){ + free(beta); + free(tnK); + for(i=0;i0 && mH>0){ + for(i=0;i +#include + +void compute_nn(nn,nsamples,nvar,data,data_class) + /* + Compute nn model, given a matrix of examples data of dimension + nsamples x nvar. Classes of each example are contained in data_class. + */ + NearestNeighbor *nn; + int nsamples,nvar; + double **data; + int *data_class; +{ + int i,j; + + + nn->nsamples=nsamples; + nn->nvars=nvar; + + nn->data=(double **)G_calloc(nn->nsamples,sizeof(double *)); + for(i=0;insamples;i++){ + nn->data[i]=(double *)G_calloc(nn->nvars,sizeof(double)); + } + nn->class=(int *)G_calloc(nn->nsamples,sizeof(int)); + + for(i=0;insamples;i++){ + for(j=0;jnvars;j++){ + nn->data[i][j]=data[i][j]; + } + nn->class[i]=data_class[i]; + } +} + + +void write_nn(file,nn,features) + /* + write nn structure to a file + */ + char *file; + NearestNeighbor *nn; + Features *features; +{ + FILE *fpout; + int i,j; + char tempbuf[500]; + + fpout = fopen(file, "w"); + if(fpout == NULL){ + sprintf(tempbuf, "write_nn-> Can't open file <%s> for writing", file); + G_fatal_error(tempbuf); + } + + write_header_features(fpout,features); + fprintf(fpout,"#####################\n"); + fprintf(fpout,"MODEL:\n"); + fprintf(fpout,"#####################\n"); + + fprintf(fpout,"Model:\n"); + fprintf(fpout,"NearestNeighbor\n"); + fprintf(fpout,"k:\n"); + fprintf(fpout,"%d\n",nn->k); + fprintf(fpout,"number of samples:\n"); + fprintf(fpout,"%d\n",nn->nsamples); + + fprintf(fpout,"number of variables:\n"); + fprintf(fpout,"%d\n",nn->nvars); + + for(i=0;insamples;i++){ + for(j=0;jnvars;j++){ + fprintf(fpout,"%f\t",nn->data[i][j]); + } + fprintf(fpout,"%d\n",nn->class[i]); + } + + if(features->f_pca[0]){ + fprintf(fpout,"#####################\n"); + fprintf(fpout,"PRINC. COMP.:\n"); + fprintf(fpout,"#####################\n"); + + fprintf(fpout,"Number of pc:\n"); + fprintf(fpout,"%d\n",features->npc); + + for(i=0;if_pca[1];i++){ + fprintf(fpout,"PCA: Layer %d\n",i+1); + write_pca(fpout,&(features->pca[i])); + } + } + + fclose(fpout); +} + + +int predict_nn_multiclass(nn,x,k,nclasses,classes) + /* + multiclass problems: given a nn model, return the predicted class of a test point x + using k-nearest neighbor for the prediction. the array classes (of length nclasses) + shall contain all the possible classes to be predicted + */ + NearestNeighbor *nn; + double *x; + int k; + int *classes; + int nclasses; +{ + int i,j; + double *dist; + int *pres_class,*pred_class,*index; + int max_class; + int max; + + dist=(double *)G_calloc(nn->nsamples,sizeof(double)); + index=(int *)G_calloc(nn->nsamples,sizeof(int)); + pred_class=(int *)G_calloc(k,sizeof(int)); + pres_class=(int *)G_calloc(nclasses,sizeof(int)); + + + for(i=0;insamples;i++){ + dist[i] = squared_distance(x,nn->data[i],nn->nvars); + } + + indexx_1(nn->nsamples,dist,index); + + for(i=0;iclass[index[i]]; + } + + for(j=0;jmax){ + max=pres_class[i]; + max_class=i; + } + } + + free(dist); + free(index); + free(pred_class); + free(pres_class); + + return classes[max_class]; + +} + + +double predict_nn_2class(nn,x,k,nclasses,classes) + /* + 2 class problems: given a nn model, return the majority of the class (with sign) + of a test point x using k-nearest neighbor for the prediction. + the array classes (of length nclasses) shall contain all the possible + classes to be predicted + */ + NearestNeighbor *nn; + double *x; + int k; + int *classes; + int nclasses; +{ + int i,j; + double *dist; + int *pres_class,*pred_class,*index; + + dist=(double *)G_calloc(nn->nsamples,sizeof(double)); + index=(int *)G_calloc(nn->nsamples,sizeof(int)); + pred_class=(int *)G_calloc(k,sizeof(int)); + pres_class=(int *)G_calloc(nclasses,sizeof(int)); + + + for(i=0;insamples;i++){ + dist[i] = squared_distance(x,nn->data[i],nn->nvars); + } + + indexx_1(nn->nsamples,dist,index); + + for(i=0;iclass[index[i]]; + } + + for(j=0;jpres_class[1]){ + return (double) pres_class[0] / (double) (k * classes[0]); + }else{ + return (double) pres_class[1]/ (double) (k * classes[1]); + } + +} + + + +void test_nn(nn,features,k,file) + /* + test nn model on a set of data (features) using k-nearest neighbor + and write the results into a file. To standard output accuracy + and error on each class + */ + NearestNeighbor *nn; + Features *features; + char *file; + int k; +{ + int i,j; + int *data_in_each_class; + FILE *fp; + char tempbuf[500]; + int predI; + double predD; + double *error; + double accuracy; + + + fp = fopen(file, "w"); + if(fp == NULL){ + sprintf(tempbuf, "test_nn-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + data_in_each_class=(int *)G_calloc(features->nclasses,sizeof(int)); + error=(double *)G_calloc(features->nclasses,sizeof(double)); + + accuracy = 0.0; + for(i=0;inexamples;i++){ + for(j=0;jnclasses;j++){ + if(features->class[i] == features->p_classes[j]){ + data_in_each_class[j] += 1; + if(features->nclasses==2){ + if((predD=predict_nn_2class(nn,features->value[i],k,features->nclasses, + features->p_classes)) * features->class[i] <= 0){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%f\n",features->class[i],predD); + }else{ + if((predI=predict_nn_multiclass(nn,features->value[i],k,features->nclasses, + features->p_classes)) != features->class[i]){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%d\n",features->class[i],predI); + } + break; + } + } + } + + accuracy /= features->nexamples; + accuracy = 1.0-accuracy; + + fclose(fp); + + fprintf(stdout,"Accuracy: %f\n",accuracy); + fprintf(stdout,"Class\t%d",features->p_classes[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",features->p_classes[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Ndata\t%d",data_in_each_class[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",data_in_each_class[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Nerrors\t%d",(int)error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",(int)error[j]); + } + fprintf(stdout,"\n"); + + for(j=0;jnclasses;j++){ + error[j] /= data_in_each_class[j]; + } + + fprintf(stdout,"Perrors\t%f",error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%f",error[j]); + } + fprintf(stdout,"\n"); + free(data_in_each_class); + free(error); +} Property changes on: trunk/grassaddons/i.pr/PRLIB/nn.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/open.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/open.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/open.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,64 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + open new raster maps +*/ + +#include "gis.h" +#include + +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, "open_new_CELL-> %s - ** illegal name **", name); + G_fatal_error (err); + exit(1); + } + + fd = G_open_raster_new (name, CELL_TYPE); + if (fd < 0) + { + sprintf (err, "open_new_CELL-> 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, "open_new_DCELL-> %s - ** illegal name **", name); + G_fatal_error (err); + exit(1); + } + + fd = G_open_raster_new (name, DCELL_TYPE); + if (fd < 0) + { + sprintf (err, "open_new_DCELL-> failed in attempt to open %s\n", name); + G_fatal_error (err); + exit(1); + } + + return fd; +} Property changes on: trunk/grassaddons/i.pr/PRLIB/open.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/pca.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/pca.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/pca.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,90 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + structure Pca management +*/ + + +#include "gis.h" +#include "global.h" +#include +#include + + +void inizialize_pca(pca,dim) + /* + alloc memory for Pca structure pca of dimension dim + */ + Pca *pca; + int dim; +{ + int i; + + pca->n=dim; + pca->mean = (double *) G_calloc(dim,sizeof(double)); + pca->sd = (double *) G_calloc(dim,sizeof(double)); + pca->covar = (double **) G_calloc(dim,sizeof(double *)); + for(i=0;icovar[i] = (double *) G_calloc(dim,sizeof(double)); + pca->eigmat = (double **) G_calloc(dim,sizeof(double *)); + for(i=0;ieigmat[i] = (double *) G_calloc(dim,sizeof(double)); + pca->eigval = (double *) G_calloc(dim,sizeof(double)); +} + +void write_pca(fp,pca) + /* write a pca structure into the file pointed*/ + FILE *fp; + Pca *pca; +{ + int i,j; + + fprintf(fp,"eigenvalues:\n"); + fprintf(fp,"%f",pca->eigval[0]); + for(i = 1; i < pca->n; i++){ + fprintf(fp,"\t%f",pca->eigval[i]); + } + fprintf(fp,"\n"); + fprintf(fp,"eigenvectors (by column):\n"); + for(i = 0; i < pca->n; i++){ + fprintf(fp,"%f",pca->eigmat[i][0]); + for(j = 1; j < pca->n; j++) + fprintf(fp,"\t%f",pca->eigmat[i][j]); + fprintf(fp,"\n"); + } +} + +void read_pca(fp,pca) + /* raed a pca structure from the file pointed*/ + FILE *fp; + Pca *pca; +{ + int i,j; + char *line = NULL; + + pca->eigval=(double *)G_calloc(pca->n,sizeof(double)); + pca->eigmat=(double **)G_calloc(pca->n,sizeof(double *)); + for(i=0;in;i++){ + pca->eigmat[i]=(double *)G_calloc(pca->n,sizeof(double)); + } + + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + for(i=0;in;i++){ + sscanf(line,"%lf", &(pca->eigval[i])); + line = (char *)strchr(line, '\t'); + *line++; + } + line=GetLine(fp); + for(j=0;jn;j++){ + line=GetLine(fp); + for(i=0;in;i++){ + sscanf(line,"%lf", &(pca->eigmat[j][i])); + line = (char *)strchr(line, '\t'); + *line++; + } + } +} Property changes on: trunk/grassaddons/i.pr/PRLIB/pca.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/percent.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/percent.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/percent.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,43 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + status of a loop computation +*/ + +#include + +static int prev = -1; + +void percent (n,d,s) + /* + compute percentage (and print to stderr) + of work done within a loop. + n actual number, d total number, s step + */ + int n,d,s; + +{ + register int x; + + if (d <= 0 || s <= 0) + x = 100; + else + { + x = n*100/d ; + if (x % s) return; + } + if (n <= 0 || n >= d || x != prev) + { + prev = x; + fprintf (stderr,"%4d%%\b\b\b\b\b",x); + fflush (stderr); + } + if (x >= 100) + { + fprintf (stderr,"\n"); + prev = -1; + } +} + Property changes on: trunk/grassaddons/i.pr/PRLIB/percent.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/random.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/random.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/random.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,146 @@ +/* + The following routines are borrowed from "Numerical Recipes in C" + + for + + extraction of samples from normal and uniform distributions +*/ + +#include +#include +#include + +#define M1 259200 +#define IA1 7141 +#define IC1 54773 +#define RM1 (1.0/M1) +#define M2 134456 +#define IA2 8121 +#define IC2 28411 +#define RM2 (1.0/M2) +#define M3 243000 +#define IA3 4561 +#define IC3 51349 + +double ran1(idum) + /* + return a double from a uniform distributio over [0,1]. + Idum inizialize the procedure + */ + int *idum; +{ + static long ix1,ix2,ix3; + static double r[98]; + double temp; + static int iff=0; + int j; + + if(*idum < 0 || iff==0){ + iff=1; + ix1=(IC1-(*idum)) % M1; + ix1=(IA1*ix1+IC1) % M1; + ix2=ix1 % M2; + ix1=(IA1*ix1+IC1) % M1; + ix3=ix1 % M3; + for(j=1;j<=97;j++){ + ix1=(IA1*ix1+IC1) % M1; + ix2=(IA2*ix2+IC2) % M2; + r[j]=(ix1+ix2*RM2)*RM1; + } + *idum=1; + } + ix1=(IA1*ix1+IC1) % M1; + ix2=(IA2*ix2+IC2) % M2; + ix3=(IA3*ix3+IC3) % M3; + j=1+((97*ix3)/M3); + if(j>97|| j< 1){ + fprintf(stderr,"RAN1: this cannot happen\n"); + exit(-1); + } + temp=r[j]; + r[j]=(ix1+ix2*RM2)*RM1; + return temp; +} + + +double gasdev(idum) + /* + return a double from a normal distribution (m=0, v=1). + Idum inizialize the procedure + */ + int *idum; +{ + static int iset=0; + static double gset; + double fac,r,v1,v2; + + if(iset==0){ + do{ + v1=2.0*ran1(idum)-1.0; + v2=2.0*ran1(idum)-1.0; + r=v1*v1+v2*v2; + }while (r>=1.0|| r==0.0); + fac=sqrt(-2.0*log(r)/r); + gset=v1*fac; + iset=1; + return v2*fac; + }else{ + iset=0; + return gset; + } +} + +double expdev(idum) +int *idum; +{ + return -log(ran1(idum)); +} + + +double gamdev(A,B,idum) + double A,B; + int *idum; +{ + int j,ia; + double am,e,s,v1,v2,x,y,p; + const double exp_m1 = 0.36787944117144232159; + + ia=(int) A; + if (ia < 1){ + e = 1.0 + exp_m1 * A; + for(;;){ + p = e * ran1(idum); + if (p >= 1.0) { + x = -log((e - p) / A); + if (expdev(idum) >= (1.0 - A) * log(x)) + break; + }else{ + x = exp(log(p) / A); + if (expdev(idum) >= x) + break; + } + } + return x*B; + } + if (ia < 6) { + x=1.0; + for (j=1;j<=ia;j++) x *= ran1(idum); + x = -log(x); + } else { + do { + do { + do { + v1=2.0*ran1(idum)-1.0; + v2=2.0*ran1(idum)-1.0; + } while (v1*v1+v2*v2 > 1.0); + y=v2/v1; + am=ia-1; + s=sqrt(2.0*am+1.0); + x=s*y+am; + } while (x <= 0.0); + e=(1.0+y*y)*exp(am*log(x/am)-s*y); + } while (ran1(idum) > e); + } + return x*B; +} + Property changes on: trunk/grassaddons/i.pr/PRLIB/random.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/read_models.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/read_models.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/read_models.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,430 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + loading different model types +*/ + +#include "gis.h" +#include "global.h" +#include +#include + + +static void read_bsvm(); +static void read_btree(); +static void read_tree(); +static void read_svm(); +static void read_gm(); +static void read_nn(); + +int read_model(file,features,nn,gm,tree,svm,btree,bsvm) + /*read a model from file and fill the structure according to the + model type. Moreover load the features*/ + char *file; + NearestNeighbor *nn; + GaussianMixture *gm; + Tree *tree; + SupportVectorMachine *svm; + BTree *btree; + BSupportVectorMachine *bsvm; + Features *features; +{ + int model_type; + FILE *fp; + char tempbuf[500]; + char *line=NULL; + int i; + + fp = fopen(file, "r"); + if(fp == NULL){ + sprintf(tempbuf, "read_model-> Can't open file %s for reading", file); + G_fatal_error(tempbuf); + } + + read_header_features(fp,features); + + /* scan model type */ + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + if(strcmp(line,"GaussianMixture")==0){ + model_type = GM_model; + }else if(strcmp(line,"NearestNeighbor")==0){ + model_type = NN_model; + }else if(strcmp(line,"ClassificationTree")==0){ + model_type = CT_model; + }else if(strcmp(line,"SupportVectorMachine")==0){ + model_type = SVM_model; + }else if(strcmp(line,"B-ClassificationTree")==0){ + model_type = BCT_model; + }else if(strcmp(line,"B-SupportVectorMachine")==0){ + model_type = BSVM_model; + }else{ + return 0; + } + + /* read model*/ + switch(model_type){ + case NN_model: + read_nn(fp,&nn); + break; + case GM_model: + read_gm(fp,&gm); + break; + case CT_model: + read_tree(fp,&tree); + break; + case SVM_model: + read_svm(fp,&svm); + break; + case BCT_model: + read_btree(fp,&btree); + break; + case BSVM_model: + read_bsvm(fp,&bsvm); + break; + case 0: + return 0; + break; + } + + if(features->f_pca[0]){ + features->pca=(Pca *)G_calloc(features->f_pca[1],sizeof(Pca)); + + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &(features->npc)); + + for(i=0;if_pca[1];i++){ + features->pca[i].n=features->training.rows * features->training.cols; + read_pca(fp,&(features->pca[i])); + } + } + + fclose(fp); + + return model_type; +} + + +static void read_bsvm(fp,bsvm) + FILE *fp; + BSupportVectorMachine **bsvm; +{ + char *line=NULL; + int i; + SupportVectorMachine *tmp_svm; + + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%lf", &((*bsvm)->w)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &((*bsvm)->nsvm)); + + (*bsvm)->weights=(double *)G_calloc((*bsvm)->nsvm,sizeof(double)); + (*bsvm)->svm=(SupportVectorMachine *) + G_calloc((*bsvm)->nsvm,sizeof(SupportVectorMachine)); + + line=GetLine(fp); + line=GetLine(fp); + for(i=0;i<(*bsvm)->nsvm;i++){ + sscanf(line,"%lf", &((*bsvm)->weights[i])); + line = (char *)strchr(line, '\t'); + *line++; + } + + for(i=0;i<(*bsvm)->nsvm;i++){ + tmp_svm=&((*bsvm)->svm[i]); + read_svm(fp,&tmp_svm); + } +} + + +static void read_btree(fp,btree) + FILE *fp; + BTree **btree; +{ + char *line=NULL; + int i; + Tree *tmp_tree; + + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%lf", &((*btree)->w)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &((*btree)->ntrees)); + + (*btree)->weights=(double *)G_calloc((*btree)->ntrees,sizeof(double)); + (*btree)->tree=(Tree *)G_calloc((*btree)->ntrees,sizeof(Tree)); + + line=GetLine(fp); + line=GetLine(fp); + for(i=0;i<(*btree)->ntrees;i++){ + sscanf(line,"%lf", &((*btree)->weights[i])); + line = (char *)strchr(line, '\t'); + *line++; + } + + for(i=0;i<(*btree)->ntrees;i++){ + tmp_tree=&((*btree)->tree[i]); + read_tree(fp,&tmp_tree); + } +} + +static void read_tree(fp,tree) + FILE *fp; + Tree **tree; +{ + char *line=NULL; + int i,j; + int nclasses; + int nvar; + + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &((*tree)->nnodes)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &nclasses); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &nvar); + + (*tree)->node=(Node *)G_calloc((*tree)->nnodes,sizeof(Node)); + + for(i=0;i<(*tree)->nnodes;i++){ + (*tree)->node[i].npoints_for_class=(int *)calloc(nclasses,sizeof(int)); + (*tree)->node[i].priors=(double *)calloc(nclasses,sizeof(double)); + } + + line=GetLine(fp); + line=GetLine(fp); + for(i=0;i<(*tree)->nnodes;i++){ + line=GetLine(fp); + (*tree)->node[i].nclasses=nclasses; + (*tree)->node[i].nvar=nvar; + sscanf(line,"%d",&((*tree)->node[i].terminal)); + line = (char *)strchr(line, '\t'); + *line++; + sscanf(line,"%d",&((*tree)->node[i].npoints)); + line = (char *)strchr(line, '\t'); + *line++; + for(j=0;jnode[i].npoints_for_class[j])); + line = (char *)strchr(line, '\t'); + *line++; + } + for(j=0;jnode[i].priors[j])); + line = (char *)strchr(line, '\t'); + *line++; + } + sscanf(line,"%d",&(*tree)->node[i].class); + line = (char *)strchr(line, '\t'); + *line++; + if(!(*tree)->node[i].terminal){ + sscanf(line,"%d",&((*tree)->node[i].left)); + line = (char *)strchr(line, '\t'); + *line++; + sscanf(line,"%d",&((*tree)->node[i].right)); + line = (char *)strchr(line, '\t'); + *line++; + sscanf(line,"%d",&((*tree)->node[i].var)); + line = (char *)strchr(line, '\t'); + *line++; + sscanf(line,"%lf",&((*tree)->node[i].value)); + } + } + +} + +static void read_svm(fp,svm) + FILE *fp; + SupportVectorMachine **svm; +{ + char *line=NULL; + int i,j; + + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &((*svm)->convergence)); + line=GetLine(fp); + line=GetLine(fp); + if(strcmp(line,"gaussian_kernel")==0){ + (*svm)->kernel_type=SVM_KERNEL_GAUSSIAN; + }else if(strcmp(line,"linear_kernel")==0){ + (*svm)->kernel_type=SVM_KERNEL_LINEAR; + }else{ + G_fatal_error("kernel not recognized\n"); + } + + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%lf", &((*svm)->two_sigma_squared)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%lf", &((*svm)->C)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%lf", &((*svm)->cost)); + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%lf%lf%%d", &((*svm)->tolerance),&((*svm)->eps), + &((*svm)->maxloops)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &((*svm)->N)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &((*svm)->d)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%lf", &((*svm)->b)); + line=GetLine(fp); + + + if((*svm)->kernel_type==SVM_KERNEL_GAUSSIAN){ + (*svm)->dense_points=(double **)G_calloc((*svm)->N,sizeof(double*)); + for(i=0;i<(*svm)->N;i++){ + (*svm)->dense_points[i]=(double *)G_calloc((*svm)->d,sizeof(double)); + } + (*svm)->target=(int *)G_calloc((*svm)->N,sizeof(int)); + (*svm)->alph=(double *)G_calloc((*svm)->N,sizeof(double)); + + for(i=0;i<(*svm)->N;i++){ + line=GetLine(fp); + for(j=0;j<(*svm)->d;j++){ + sscanf(line,"%lf", &((*svm)->dense_points[i][j])); + line = (char *)strchr(line, '\t'); + *line++; + } + sscanf(line,"%d", &((*svm)->target[i])); + line = (char *)strchr(line, '\t'); + *line++; + sscanf(line,"%lf", &((*svm)->alph[i])); + } + } + if((*svm)->kernel_type==SVM_KERNEL_LINEAR){ + (*svm)->w=(double *)G_calloc((*svm)->d,sizeof(double)); + line=GetLine(fp); + for(j=0;j<(*svm)->d;j++){ + sscanf(line,"%lf", &((*svm)->w[j])); + line = (char *)strchr(line, '\t'); + *line++; + } + } + +} + + + +static void read_gm(fp,gm) + FILE *fp; + GaussianMixture **gm; +{ + char *line=NULL; + int i,j,k; + + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &((*gm)->nclasses)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &((*gm)->nvars)); + + (*gm)->classes = (int *) G_calloc((*gm)->nclasses,sizeof(int)); + (*gm)->priors = (double *) G_calloc((*gm)->nclasses,sizeof(double)); + + + (*gm)->mean=(double **) G_calloc((*gm)->nclasses, sizeof(double *)); + for(i=0;i<(*gm)->nclasses;i++) + (*gm)->mean[i] = (double *) G_calloc((*gm)->nvars, sizeof(double)); + + (*gm)->covar = (double ***) G_calloc((*gm)->nclasses, sizeof(double **)); + for(i=0;i<(*gm)->nclasses;i++){ + (*gm)->covar[i] = (double **) G_calloc((*gm)->nvars, sizeof(double *)); + for(j=0;j<(*gm)->nvars;j++) + (*gm)->covar[i][j] = (double *) G_calloc((*gm)->nvars, sizeof(double)); + } + + + line=GetLine(fp); + line=GetLine(fp); + for(i=0;i<(*gm)->nclasses;i++){ + sscanf(line,"%d", &((*gm)->classes[i])); + line = (char *)strchr(line, '\t'); + *line++; + } + + line=GetLine(fp); + line=GetLine(fp); + for(i=0;i<(*gm)->nclasses;i++){ + sscanf(line,"%lf", &((*gm)->priors[i])); + line = (char *)strchr(line, '\t'); + *line++; + } + + + for(i=0;i<(*gm)->nclasses;i++){ + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + for(j=0;j<(*gm)->nvars;j++){ + sscanf(line,"%lf", &((*gm)->mean[i][j])); + line = (char *)strchr(line, '\t'); + *line++; + } + line=GetLine(fp); + for(k=0;k<(*gm)->nvars;k++){ + line=GetLine(fp); + for(j=0;j<(*gm)->nvars;j++){ + sscanf(line,"%lf", &((*gm)->covar[i][k][j])); + line = (char *)strchr(line, '\t'); + *line++; + } + } + } + + +} + +static void read_nn(fp,nn) + FILE *fp; + NearestNeighbor **nn; +{ + char *line=NULL; + int i,j; + + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &((*nn)->k)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &((*nn)->nsamples)); + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &((*nn)->nvars)); + + (*nn)->data=(double **)G_calloc((*nn)->nsamples,sizeof(double *)); + for(i=0;i<(*nn)->nsamples;i++) + (*nn)->data[i]=(double *)G_calloc((*nn)->nvars,sizeof(double)); + + (*nn)->class=(int *)G_calloc((*nn)->nsamples,sizeof(int)); + + for(i=0;i<(*nn)->nsamples;i++){ + line=GetLine(fp); + for(j=0;j<(*nn)->nvars;j++){ + sscanf(line,"%lf", &((*nn)->data[i][j])); + line = (char *)strchr(line, '\t'); + *line++; + } + sscanf(line,"%d", &((*nn)->class[i])); + } + +} Property changes on: trunk/grassaddons/i.pr/PRLIB/read_models.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/soft_margin_boosting.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/soft_margin_boosting.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/soft_margin_boosting.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,115 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + Soft Boosting implementation (quadratic programming) +*/ + +#include "gis.h" +#include "global.h" +#include +#include +#include + +void maximize(alpha,N,beta,T,M) + double *alpha,*beta,**M; + int N,T; +{ + int i,l,t,s; + int convergence=FALSE; + double detetaalpha,detetabeta; + double *alpha_old; + double *beta_old; + double eps=0.00001; + double *eta; + double tmp; + + alpha_old=(double*)calloc(N,sizeof(double)); + beta_old=(double*)calloc(T,sizeof(double)); + eta=(double*)calloc(N,sizeof(double)); + + for(l=0;l100./N) + alpha[l]=100./N; + + } + + for(s=0;seps){ + fprintf(stderr,"ALPHA %d %f %f\n",l,alpha_old[l],alpha[l]); + convergence=FALSE; + break; + } + } + if(convergence) + for(s=0;seps){ + fprintf(stderr,"BETA %d %f %f\n",s,beta_old[s],beta[s]); + convergence=FALSE; + break; + } + } + } + free(alpha_old); + free(beta_old); + free(eta); + + + +} + Property changes on: trunk/grassaddons/i.pr/PRLIB/soft_margin_boosting.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/sort.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/sort.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/sort.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,118 @@ +/* + The following routines is borrowed from "Numerical Recipes in C" + + for + + sortinf of an array +*/ + +#include +#include +#include "global.h" + +#define ALN2I 1.442695022 +#define TINY 1.0e-5 + +static void indexx(); + +void shell(n,arr) + /* + sort and rearranges an array arr of length n + into ascending order + */ + double *arr; + int n; +{ + int nn,m,j,i,lognb2; + double t; + + lognb2=(log((double) n)*ALN2I+TINY); + m=n; + for(nn=1;nn<=lognb2;nn++){ + m >>= 1; + for(j=m+1;j<=n;j++){ + i=j-m; + t=arr[j-1]; + while(i>=1 && arr[i-1]>t){ + arr[i+m-1]=arr[i-1]; + i-=m; + } + arr[i+m-1]=t; + } + } +} + +#undef ALN2I +#undef TINY + + + +void indexx_1(n,arrin,indx) + /* + sort array arrin of length n into ascending order, + without modify it. The order of the sording will be + contained into the indx array + */ + int n, indx[]; + double arrin[]; +{ + int i; + double *tmparrin; + int *tmpindx; + + tmpindx=(int *)calloc(n+1,sizeof(int)); + tmparrin=(double *)calloc(n+1,sizeof(double)); + + for(i=0;i>1) +1; + ir=n; + for(;;){ + if(l>1) + q=arrin[(indxt=indx[--l])]; + else{ + q=arrin[(indxt=indx[ir])]; + indx[ir]=indx[1]; + if(--ir==1){ + indx[1]=indxt; + return; + } + } + i=l; + j=l<<1; + while(j<=ir){ + if(j +#include +#include + +double mean_of_double_array(x,n) + /* + compute the mean of an array x of lenth n + */ + double *x; + int n; +{ + int i; + double mean = .0; + + for(i = 0; i < n; i++) + mean += x[i]; + + mean /= n; + + return mean; + +} + +double var_of_double_array(x,n) + /* + compute the var of an array x of length n + */ + double *x; + int n; +{ + int i; + double deviation; + double mean = .0; + double var = .0; + + for(i = 0; i < n; i++) + mean += x[i]; + + mean /= n; + + for(i = 0; i < n; i++){ + deviation = x[i] - mean; + var += deviation * deviation; + } + + var /= (n - 1.0); + + return var; + +} + +double sd_of_double_array(x,n) + /* + compute the sd of an array x of length n + */ + double *x; + int n; +{ + int i; + double deviation; + double mean = .0; + double var = .0; + + for(i = 0; i < n; i++) + mean += x[i]; + + mean /= n; + + for(i = 0; i < n; i++){ + deviation = x[i] - mean; + var += deviation * deviation; + } + + var /= (n - 1.0); + + return sqrt(var); + +} + + +double var_of_double_array_given_mean(x,n,mean) + /* + compute the var of an array x of length n + without computation of the mean mean, + given in input + */ + double *x; + double mean; + int n; +{ + int i; + double deviation; + double var = .0; + + for(i = 0; i < n; i++){ + deviation = x[i] - mean; + var += deviation * deviation; + } + + var /= (n - 1.0); + + return var; + +} + + +double sd_of_double_array_given_mean(x,n,mean) + /* + compute the sd of an array x of length n + without computation of the mean, + given in input + */ + double *x; + double mean; + int n; +{ + int i; + double deviation; + double var = .0; + + for(i = 0; i < n; i++){ + deviation = x[i] - mean; + var += deviation * deviation; + } + + var /= (n - 1.0); + + return sqrt(var); + +} + + +void mean_and_var_of_double_matrix_by_row(x,n,m,mean,var) + /* + each row of the input matrix x (dimension n x m) + is considered an independent array of data. + The function compute mean and var of each row, + stored within the array mean and var. + */ + double **x; + int n; + int m; + double *mean; + double *var; +{ + int i,j; + double deviation; + + for(j = 0; j < n; j++) + for(i = 0; i < m; i++){ + mean[j] += x[j][i]; + } + for(i = 0; i < n; i++) + mean[i] /= m; + for(j = 0; j < n; j++){ + for(i = 0; i < m; i++){ + deviation = x[j][i] - mean[j]; + var[j] += deviation * deviation; + } + } + for(i = 0; i < n; i++) + var[i] = var[i] / (m - 1.); +} + +void mean_and_sd_of_double_matrix_by_row(x,n,m,mean,sd) + /* + each row of the input matrix x (dimension n x m) + is considered an independent array of data. + The function compute mean and sd of each row, + stored within the array mean and sd. + */ + double **x; + int n; + int m; + double *mean; + double *sd; +{ + int i,j; + double deviation; + + for(j = 0; j < n; j++) + for(i = 0; i < m; i++){ + mean[j] += x[j][i]; + } + for(i = 0; i < n; i++) + mean[i] /= m; + for(j = 0; j < n; j++){ + for(i = 0; i < m; i++){ + deviation = x[j][i] - mean[j]; + sd[j] += deviation * deviation; + } + } + for(i = 0; i < n; i++) + sd[i] = sqrt(sd[i] / (m - 1.)); +} + +void mean_and_var_of_double_matrix_by_col(x,n,m,mean,var) + /* + each col of the input matrix x (dimension n x m) + is considered an independent array of data. + The function compute mean and var of each col, + stored within the array mean and sd. + */ + double **x; + int n; + int m; + double *mean; + double *var; +{ + int i,j; + double deviation; + + for(i = 0; i < m; i++){ + for(j = 0; j < n; j++) + mean[i] += x[j][i]; + } + for(i = 0; i < m; i++) + mean[i] /= n; + + for(i = 0; i < m; i++){ + for(j = 0; j < n; j++){ + deviation = x[j][i] - mean[i]; + var[i] += deviation * deviation; + } + } + for(i = 0; i < m; i++) + var[i] = var[i] / (n - 1.); +} + +void mean_and_sd_of_double_matrix_by_col(x,n,m,mean,sd) + /* + each col of the input matrix x (dimension n x m) + is considered an independent array of data. + The function compute mean and sd of each col, + stored within the array mean and sd. + */ + double **x; + int n; + int m; + double *mean; + double *sd; +{ + int i,j; + double deviation; + + for(i = 0; i < m; i++){ + for(j = 0; j < n; j++) + mean[i] += x[j][i]; + } + for(i = 0; i < m; i++) + mean[i] /= n; + + for(i = 0; i < m; i++){ + for(j = 0; j < n; j++){ + deviation = x[j][i] - mean[i]; + sd[i] += deviation * deviation; + } + } + for(i = 0; i < m; i++) + sd[i] = sqrt(sd[i] / (n - 1.)); +} + +double auto_covariance_of_2_double_array(x,y,n) + /* + compute the auto covariance of 2 array x and y of length n + */ + double *x; + double *y; + int n; +{ + int i; + double mx=.0; + double my=.0; + double cc=.0; + + for(i=0;i0) + entropy += p[i] * log(p[i]); + + return -1.0*entropy; + +} + +double gaussian_kernel(x,y,n,kp) + /* + compute e return gaussian kernel exp(-sqrt(||x-y||)/kp), + x and y array of length n + */ + double *x,*y; + int n; + double kp; +{ + int j; + double out =0.0; + double tmp; + + for(j=0;jx[j]){ + out=x[j]; + } + } + return out; +} + + +double max(x,n) + double *x; + int n; +{ + int j; + double out; + + out=x[0]; + + for(j=1;j +#include +#include + +static void svm_smo(); +static double learned_func_linear(); +static double learned_func_nonlinear(); +static double rbf_kernel(); +static double direct_kernel(); +static double dot_product_func(); +static int examineExample(); +static int takeStep(); +static int distance_from_span_sv(); +double dot_product(); + +void compute_svm(svm,n,d,x,y,svm_kernel,svm_kp,svm_C,svm_tol,svm_eps, + svm_maxloops,svm_verbose,svm_W) + SupportVectorMachine *svm; + int n,d; + double **x; + int *y; + int svm_kernel,svm_verbose; + double svm_kp,svm_C,svm_tol,svm_eps; + int svm_maxloops; + double *svm_W; +{ + int i,j; + + svm->N=n; + svm->d=d; + svm->C=svm_C; + svm->tolerance=svm_tol; + svm->eps=svm_eps; + svm->two_sigma_squared=svm_kp; + svm->kernel_type=svm_kernel; + svm->maxloops=svm_maxloops; + svm->verbose=svm_verbose; + svm->b=.0; + + if(svm_kernel!=SVM_KERNEL_DIRECT){ + svm->dense_points=(double**)calloc(n,sizeof(double*)); + for(i=0;idense_points[i]=(double*)calloc(d,sizeof(double)); + + for(i=0;idense_points[i][j]=x[i][j]; + + svm->w=(double*)calloc(d,sizeof(double)); + } + + svm->target=(int*)calloc(n,sizeof(int)); + for(i=0;itarget[i]=y[i]; + + svm->Cw=(double*)calloc(n,sizeof(double)); + svm->alph=(double*)calloc(n,sizeof(double)); + svm->error_cache=(double*)calloc(n,sizeof(double)); + for(i=0;ierror_cache[i]=-y[i]; + + svm->precomputed_self_dot_product=(double*)calloc(n,sizeof(double)); + + for(i=0;iCw[i]=svm->C*svm_W[i]; + + if(svm_kernel==SVM_KERNEL_DIRECT){ + int p_class; + int n_class=0; + int index; + int i1,i2; + + for(i=0;id=p_class*n_class; + svm->orig_d=d; + + svm->dense_points=(double**)calloc(n,sizeof(double*)); + for(i=0;idense_points[i]=(double*)calloc(svm->d,sizeof(double)); + + svm->w=(double*)calloc(svm->d,sizeof(double)); + + svm->dot_prod=(double**)calloc(n,sizeof(double*)); + for(i=0;idot_prod[i]=(double*)calloc(n,sizeof(double)); + + for(i=0;idot_prod[i][i]=dot_product(x[i],x[i],d); + + for(i=0;idot_prod[j][i]=svm->dot_prod[i][j]=dot_product(x[i],x[j],d); + + svm->models=(SVM_direct_kernel*) + calloc(svm->d,sizeof(SVM_direct_kernel)); + + index=0; + for(i=0;imodels[index].i1=i; + svm->models[index].x1=x[i]; + svm->models[index].y1=y[i]; + svm->models[index].i2=j; + svm->models[index].x2=x[j]; + svm->models[index].y2=y[j]; + svm->models[index].d=d; + svm->models[index].w_coeff=(y[j]-y[i])/ + (y[j]*svm->dot_prod[j][j]-y[i]*svm->dot_prod[i][i]-(y[j]-y[i]) + *svm->dot_prod[i][j]); + svm->models[index].b=y[i]-svm->models[index].w_coeff* + (y[i]*svm->dot_prod[i][i]+y[j]*svm->dot_prod[i][j]); + index++; + } + + for(i=0;id;j++){ + i1=svm->models[j].i1; + i2=svm->models[j].i2; + + svm->dense_points[i][j]=svm->models[j].w_coeff* + (y[i1]*svm->dot_prod[i1][i]+y[i2]*svm->dot_prod[i2][i]) + +svm->models[j].b; + + if(svm->dense_points[i][j]>1.0) + svm->dense_points[i][j]=1.0; + else if(svm->dense_points[i][j]<-1.0) + svm->dense_points[i][j]=-1.0; + } + + svm->H=(double**)calloc(n,sizeof(double*)); + for(j=0;jH[j]=(double*)calloc(n,sizeof(double)); + + for(i=0;iH[i][i]=dot_product_func(i,i,svm); + + for(i=0;iH[j][i]=svm->H[i][j]=dot_product_func(i,j,svm); + + } + + svm_smo(svm); + + svm->non_bound_support=svm->bound_support=0; + for(i=0;ialph[i]>0){ + if(svm->alph[i]< svm->Cw[i]) + svm->non_bound_support++; + else + svm->bound_support++; + } + } +} + + +static void svm_smo(SVM) + SupportVectorMachine *SVM; +{ + int i,k; + int numChanged; + int examineAll; + int nloops=0; + + SVM->end_support_i=SVM->N; + + if(SVM->kernel_type==SVM_KERNEL_LINEAR){ + SVM->kernel_func=dot_product_func; + SVM->learned_func=learned_func_linear; + } + + if(SVM->kernel_type==SVM_KERNEL_GAUSSIAN){ + /* + SVM->precomputed_self_dot_product=(double *)calloc(SVM->N,sizeof(double)); + */ + for(i=0;iN;i++) + SVM->precomputed_self_dot_product[i] = dot_product_func(i,i,SVM); + SVM->kernel_func=rbf_kernel; + SVM->learned_func=learned_func_nonlinear; + } + + if(SVM->kernel_type==SVM_KERNEL_DIRECT){ + SVM->kernel_func=dot_product_func; + SVM->learned_func=learned_func_linear; + } + + numChanged=0; + examineAll=1; + + SVM->convergence=1; + while(SVM->convergence==1 &&(numChanged>0 || examineAll)){ + numChanged=0; + if(examineAll){ + for(k=0;kN;k++) + numChanged += examineExample(k,SVM); + }else{ + for(k=0;kN;k++) + if(SVM->alph[k] > 0 && SVM->alph[k] < SVM->Cw[k]) + numChanged += examineExample(k,SVM); + } + if(examineAll==1) + examineAll=0; + else if(numChanged==0) + examineAll=1; + + nloops+=1; + if(nloops==SVM->maxloops) + SVM->convergence=0; + if(SVM->verbose==1) + fprintf(stderr,"%6d\b\b\b\b\b\b\b",nloops); + } +} + + +static double learned_func_linear(k,SVM) + int k; + SupportVectorMachine *SVM; + +{ + double s=0.0; + int i; + + for(i=0;id;i++) + s += SVM->w[i] * SVM->dense_points[k][i]; + + s -= SVM->b; + + return s; +} + +static double learned_func_nonlinear(k,SVM) + int k; + SupportVectorMachine *SVM; +{ + double s=0.0; + int i; + + for(i=0;iend_support_i;i++) + if(SVM->alph[i]>0) + s += SVM->alph[i]*SVM->target[i]*SVM->kernel_func(i,k,SVM); + + s -= SVM->b; + + return s; +} + +static double rbf_kernel(i1,i2,SVM) + int i1,i2; + SupportVectorMachine *SVM; +{ + double s; + + s = dot_product_func(i1,i2,SVM); + + s *= -2; + + s += SVM->precomputed_self_dot_product[i1] + SVM->precomputed_self_dot_product[i2]; + + return exp(-s/SVM->two_sigma_squared); +} + + +static double dot_product_func(i1,i2,SVM) + int i1,i2; + SupportVectorMachine *SVM; +{ + double dot = 0.0; + int i; + + for(i=0;id;i++) + dot += SVM->dense_points[i1][i] * SVM->dense_points[i2][i]; + + return dot; +} + +static int examineExample(i1,SVM) + int i1; + SupportVectorMachine *SVM; +{ + double y1, alph1, E1, r1; + + y1=SVM->target[i1]; + alph1=SVM->alph[i1]; + + if(alph1>0 && alph1Cw[i1]) + E1 = SVM->error_cache[i1]; + else + E1 = SVM->learned_func(i1,SVM)-y1; + + r1 = y1 *E1; + + if((r1<-SVM->tolerance && alph1Cw[i1]) ||(r1>SVM->tolerance && alph1>0)){ + { + int k, i2; + double tmax; + + for(i2=(-1),tmax=0,k=0;kend_support_i;k++) + if(SVM->alph[k]>0 && SVM->alph[k]Cw[k]){ + double E2,temp; + + E2=SVM->error_cache[k]; + + temp=fabs(E1-E2); + + if(temp>tmax){ + tmax=temp; + i2=k; + } + } + + if(i2>=0){ + if(takeStep(i1,i2,SVM)) + return 1; + } + } + { + int k0,k,i2; + for(k0=(int)(drand48()*SVM->end_support_i),k=k0;kend_support_i+k0;k++){ + i2 = k % SVM->end_support_i; + if(SVM->alph[i2]>0 && SVM->alph[i2]Cw[i2]){ + if(takeStep(i1,i2,SVM)) + return 1; + } + } + } + { + int k0,k,i2; + + for(k0=(int)(drand48()*SVM->end_support_i),k=k0;kend_support_i+k0;k++){ + i2 = k % SVM->end_support_i; + if(takeStep(i1,i2,SVM)) + return 1; + } + } + } + return 0; +} + + +static int takeStep(i1,i2,SVM) + int i1,i2; + SupportVectorMachine *SVM; +{ + int y1,y2,s; + double alph1,alph2; + double a1,a2; + double E1,E2,L,H,k11,k12,k22,eta,Lobj,Hobj; + + if(i1==i2) + return 0; + + alph1=SVM->alph[i1]; + y1=SVM->target[i1]; + if(alph1>0 && alph1Cw[i1]) + E1=SVM->error_cache[i1]; + else + E1=SVM->learned_func(i1,SVM)-y1; + + + alph2=SVM->alph[i2]; + y2=SVM->target[i2]; + if(alph2>0 && alph2Cw[i2]) + E2=SVM->error_cache[i2]; + else + E2=SVM->learned_func(i2,SVM)-y2; + + s=y1*y2; + + if(y1==y2){ + double gamma; + + gamma = alph1+alph2; + if(gamma-SVM->Cw[i1]>0) + L=gamma-SVM->Cw[i1]; + else + L=0.0; + + if(gammaCw[i2]) + H=gamma; + else + H=SVM->Cw[i2]; + + + }else{ + double gamma; + + gamma = alph2-alph1; + + if(gamma>0) + L=gamma; + else + L=0.0; + + if(SVM->Cw[i1]+gammaCw[i2]) + H=SVM->Cw[i1]+gamma; + else + H=SVM->Cw[i2]; + } + + if(L==H) + return 0; + + if(SVM->kernel_type!=SVM_KERNEL_DIRECT){ + k11=SVM->kernel_func(i1,i1,SVM); + k12=SVM->kernel_func(i1,i2,SVM); + k22=SVM->kernel_func(i2,i2,SVM); + }else{ + k11=SVM->H[i1][i1]; + k12=SVM->H[i1][i2]; + k22=SVM->H[i2][i2]; + } + + + eta=2*k12-k11-k22; + + if(eta<0){ + a2=alph2+y2*(E2-E1)/eta; + if(a2H) + a2=H; + }else{ + { + double c1,c2; + + c1=eta/2; + c2=y2*(E1-E2)-eta*alph2; + Lobj=c1*L*L+c2*L; + Hobj=c1*H*H+c2*H; + } + if(Lobj>Hobj+SVM->eps) + a2=L; + else if(Lobjeps) + a2=H; + else + a2=alph2; + } + + if(fabs(a2-alph2)eps*(a2+alph2+SVM->eps)) + return 0; + + a1=alph1-s*(a2-alph2); + + if(a1<0){ + a2 += s*a1; + a1=0; + }else if(a1>SVM->Cw[i1]){ + double t; + + t=a1-SVM->Cw[i1]; + a2 += s*t; + a1=SVM->Cw[i1]; + } + + { + double b1,b2,bnew; + + if(a1>0 && a1 Cw[i1]) + bnew=SVM->b+E1+y1*(a1-alph1)*k11+y2*(a2-alph2)*k12; + else{ + if(a2>0 && a2 Cw[i2]) + bnew=SVM->b+E2+y1*(a1-alph1)*k12+y2*(a2-alph2)*k22; + else{ + b1=SVM->b+E1+y1*(a1-alph1)*k11+y2*(a2-alph2)*k12; + b2=SVM->b+E2+y1*(a1-alph1)*k12+y2*(a2-alph2)*k22; + bnew=(b1+b2)/2; + } + } + + SVM->delta_b=bnew-SVM->b; + SVM->b=bnew; + } + + if(SVM->kernel_type==SVM_KERNEL_LINEAR||SVM->kernel_type==SVM_KERNEL_DIRECT){ + double t1,t2; + int i; + + t1=y1*(a1-alph1); + t2=y2*(a2-alph2); + + for(i=0;id;i++) + SVM->w[i] += SVM->dense_points[i1][i]*t1+SVM->dense_points[i2][i]*t2; + } + + { + double t1,t2; + int i; + + t1=y1*(a1-alph1); + t2=y2*(a2-alph2); + + if(SVM->kernel_type!=SVM_KERNEL_DIRECT){ + for(i=0;iend_support_i;i++) + SVM->error_cache[i] += t1*SVM->kernel_func(i1,i,SVM)+t2*SVM->kernel_func(i2,i,SVM)-SVM->delta_b; + }else{ + for(i=0;iend_support_i;i++) + SVM->error_cache[i] += t1*SVM->H[i1][i]+t2*SVM->H[i2][i]-SVM->delta_b; + } + + } + + SVM->alph[i1]=a1; + SVM->alph[i2]=a2; + + return 1; + + +} + +static int distance_from_span_sv(M,m,n,Const,H,h,mH,K,k,mK,eps,threshold) + double **M,*m; + double **H,*h; + double **K,*k; + int n,mH,mK; + double eps; + double Const; + double threshold; +{ + int i,j,l; + + double **invM=NULL; + double **HM=NULL,**HMH=NULL,*tnH=NULL,**HMK=NULL,**KM=NULL,**KMK=NULL,*tnK=NULL,**tH=NULL,**tK=NULL; + double mMm; + double gap; + double *alpha=NULL,*beta=NULL; + double L,f; + double tmpalpha,tmpbeta,tmpL,tmpf; + + /*alloc memory*/ + invM=(double**)calloc(n,sizeof(double*)); + for(i=0;i0){ + HM=(double**)calloc(mH,sizeof(double*)); + for(i=0;i0 && mK>0){ + HMK=(double**)calloc(mH,sizeof(double*)); + for(i=0;i0){ + KM=(double**)calloc(mK,sizeof(double*)); + for(i=0;i0){ + product_double_matrix_double_matrix(H,invM,mH,n,n,HM); + product_double_matrix_double_matrix(HM,tH,mH,n,mH,HMH); + product_double_matrix_double_vector(HM,m,mH,n,tnH); + for(i=0;i0 && mK>0) + product_double_matrix_double_matrix(HM,tK,mH,n,mK,HMK); + + if(mK>0){ + product_double_matrix_double_matrix(K,invM,mK,n,n,KM); + product_double_matrix_double_matrix(KM,tK,mK,n,mK,KMK); + product_double_matrix_double_vector(KM,m,mK,n,tnK); + for(i=0;i0) + alpha=(double*)calloc(mH,sizeof(double)); + if(mK>0) + beta=(double*)calloc(mK,sizeof(double)); + + gap=eps+1; + /*gradient ascendent on the dual Lagrangian*/ + while(gap>eps){ + if(mH>0 && mK>0){ + for(l=0;l0) + tmpalpha += HMH[i][l]*alpha[i]; + + tmpalpha += tnH[l]; + + + for(i=0;i0) + tmpbeta += HMK[i][l]*alpha[i]; + + beta[l] -= tmpbeta/KMK[l][l]; + + } + }else if(mH>0 && mK==0){ + for(l=0;l0) + tmpalpha += HMH[i][l]*alpha[i]; + + tmpalpha += tnH[l]; + + alpha[l] -= tmpalpha/HMH[l][l]; + if(alpha[l] < .0) + alpha[l] = .0; + } + }else if(mH==0 && mK>0){ + for(l=0;l0) + for(j=0;j0) + tmpL += alpha[i]*alpha[j]*HMH[i][j]; + L -= .5*tmpL; + + tmpL=.0; + for(i=0;i0) + tmpL += alpha[i]*tnH[i]; + L -= tmpL; + + tmpL=.0; + for(i=0;i0) + for(j=0;j0) + tmpf += alpha[i]*tnH[i]; + f -= .5*tmpf; + + tmpf=.0; + for(i=0;i0){ + free(alpha); + free(tnH); + for(i=0;i0){ + free(beta); + free(tnK); + for(i=0;i0 && mH>0){ + for(i=0;inon_bound_support,sizeof(double*)); + for(i=0;inon_bound_support;i++) + M[i]=(double*)calloc(SVM->non_bound_support,sizeof(double)); + m=(double*)calloc(SVM->non_bound_support,sizeof(double)); + H=(double**)calloc(2*SVM->non_bound_support,sizeof(double*)); + for(i=0;i<2*SVM->non_bound_support;i++) + H[i]=(double*)calloc(SVM->non_bound_support,sizeof(double)); + h=(double*)calloc(2*SVM->non_bound_support,sizeof(double)); + K=(double**)calloc(1,sizeof(double*)); + K[0]=(double*)calloc(SVM->non_bound_support,sizeof(double)); + k=(double*)calloc(1,sizeof(double)); + for(i=0;inon_bound_support;i++) + K[0][i]=1.; + k[0]=1.; + + et=en=ep=.0; + neg_samples=0; + for(p=0;pN;p++){ + if(SVM->target[p]<0) + neg_samples+=1; + if(SVM->alph[p]>0){ + if(SVM->learned_func(p,SVM)*SVM->target[p]<0){ + fprintf(stderr,"Data %d: training error\n",p); + et += 1.; + if(SVM->target[p]<0) + en += 1.; + else + ep += 1.; + } + else{ + if(SVM->alph[p]Cw[p]) + n_span=SVM->non_bound_support-1; + else + n_span=SVM->non_bound_support; + indx1=0; + indx2=0; + for(i=0;iN;i++) + if(i!=p && SVM->alph[i]>0 && SVM->alph[i]Cw[i]){ + for(j=i;jN;j++) + if(j!=p && SVM->alph[j]>0 && SVM->alph[j]Cw[j]){ + M[indx1][indx2]=M[indx2][indx1]=SVM->kernel_func(i,j,SVM); + indx2++; + } + indx1++; + indx2=indx1; + } + + if(n_span>SVM->d) + for(i=0;iN;i++) + if(i!=p && SVM->alph[i]>0 && SVM->alph[i]Cw[i]){ + m[indx1]=-2.*SVM->kernel_func(i,p,SVM); + indx1++; + } + + indx1=0; + for(i=0;i<2*n_span;i++) + for(j=0;jN;i++) + if(i!=p && SVM->alph[i]>0 && SVM->alph[i]Cw[i]){ + H[indx1][indx1]=1.; + H[indx1+n_span][indx1]=-1.; + if(SVM->target[i]==SVM->target[p]){ + h[indx1]=(SVM->Cw[i]-SVM->alph[i])/SVM->alph[p]; + h[indx1+n_span]=SVM->alph[i]/SVM->alph[p]; + indx1++; + }else{ + h[indx1]=SVM->alph[i]/SVM->alph[p]; + h[indx1+n_span]=(SVM->Cw[i]-SVM->alph[i])/SVM->alph[p]; + indx1++; + } + } + + threshold=SVM->learned_func(p,SVM)*SVM->target[p]/SVM->alph[p]; + Const=SVM->kernel_func(p,p,SVM); + if(distance_from_span_sv(M,m,n_span,Const,H,h,2*n_span, + K,k,1,SVM->eps, threshold)==1){ + fprintf(stderr,"Data %d: cv error\n",p); + et += 1.; + if(SVM->target[p]<0) + en += 1.; + else + ep += 1.; + }else + fprintf(stderr,"Data %d: correctly classified\n",p); + } + } + } + et/=SVM->N; + en/=neg_samples; + ep/=(SVM->N-neg_samples); + + fprintf(stdout,"Accuracy: %f\n",1-et); + fprintf(stdout,"Perrors\tclass +1: %f\tclass -1: %f\n",ep,en); + +} + +void write_svm(file,svm,features) + /* + write svm structure to a file + */ + SupportVectorMachine *svm; + char *file; + Features *features; +{ + FILE *fpout; + int i, j; + char tempbuf[500]; + int np_weights=0; + + for(i=0;iN;i++){ + if(svm->alph[i]>0.0){ + np_weights += 1; + } + } + + if((fpout = fopen(file, "w")) == NULL){ + sprintf(tempbuf, "write_svm-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + write_header_features(fpout,features); + fprintf(fpout,"#####################\n"); + fprintf(fpout,"MODEL:\n"); + fprintf(fpout,"#####################\n"); + + fprintf(fpout,"Model:\n"); + fprintf(fpout,"SupportVectorMachine\n"); + fprintf(fpout,"Convergence:\n"); + fprintf(fpout,"%d\n",svm->convergence); + fprintf(fpout,"Kernel Type:\n"); + if(svm->kernel_type == SVM_KERNEL_LINEAR){ + fprintf(fpout,"linear_kernel\n"); + } + if(svm->kernel_type == SVM_KERNEL_GAUSSIAN){ + fprintf(fpout,"gaussian_kernel\n"); + } + if(svm->kernel_type == SVM_KERNEL_DIRECT){ + fprintf(fpout,"2pbk_kernel\n"); + } + fprintf(fpout,"Kernel parameter:\n"); + fprintf(fpout,"%f\n",svm->two_sigma_squared); + + fprintf(fpout,"Optimization parameter:\n"); + fprintf(fpout,"%f\n",svm->C); + + fprintf(fpout,"Cost parameter:\n"); + fprintf(fpout,"%f\n",svm->cost); + + fprintf(fpout,"Convergence parameters:\n"); + fprintf(fpout,"tol\teps\tmaxloops\n"); + fprintf(fpout,"%e\t%e\t%d\n",svm->tolerance,svm->eps, svm->maxloops); + + fprintf(fpout,"Number of kernel:\n"); + fprintf(fpout,"%d\n",np_weights); + fprintf(fpout,"Dimension:\n"); + fprintf(fpout,"%d\n",svm->d); + + fprintf(fpout,"Offset:\n"); + fprintf(fpout,"%f\n",svm->b); + + if(svm->kernel_type==SVM_KERNEL_GAUSSIAN){ + fprintf(fpout,"Kernel - Label - Weight:\n"); + for(i=0;iN;i++){ + if(svm->alph[i]>0.0){ + for(j=0;jd;j++){ + fprintf(fpout,"%f\t",svm->dense_points[i][j]); + } + fprintf(fpout,"%d\t%e\n",svm->target[i],svm->alph[i]); + } + } + } + if(svm->kernel_type==SVM_KERNEL_LINEAR|| + svm->kernel_type==SVM_KERNEL_DIRECT){ + fprintf(fpout,"Weight:\n"); + fprintf(fpout,"%f",svm->w[0]); + for(i=1;id;i++){ + fprintf(fpout,"\t%f",svm->w[i]); + } + fprintf(fpout,"\n"); + } + + if(svm->kernel_type==SVM_KERNEL_DIRECT){ + fprintf(fpout,"Support Vector:\n"); + for(i=0;iN;i++) + fprintf(fpout,"%f\n",svm->alph[i]); + } + + if(features->f_pca[0]){ + fprintf(fpout,"#####################\n"); + fprintf(fpout,"PRINC. COMP.:\n"); + fprintf(fpout,"#####################\n"); + + fprintf(fpout,"Number of pc:\n"); + fprintf(fpout,"%d\n",features->npc); + + for(i=0;if_pca[1];i++){ + fprintf(fpout,"PCA: Layer %d\n",i+1); + write_pca(fpout,&(features->pca[i])); + } + } + fclose(fpout); +} + +void test_svm(svm,features,file) + /* + test svm model on a set of data (features) and write the results + into a file. To standard output accuracy and error on each class + */ + SupportVectorMachine *svm; + Features *features; + char *file; +{ + int i,j; + int *data_in_each_class; + FILE *fp; + char tempbuf[500]; + double pred; + double *error; + double accuracy; + + + fp = fopen(file, "w"); + if(fp == NULL){ + sprintf(tempbuf, "test_svm-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + data_in_each_class=(int *)G_calloc(features->nclasses,sizeof(int)); + error=(double *)G_calloc(features->nclasses,sizeof(double)); + + accuracy = 0.0; + for(i=0;inexamples;i++){ + for(j=0;jnclasses;j++){ + if(features->class[i] == features->p_classes[j]){ + data_in_each_class[j] += 1; + if((pred=predict_svm(svm,features->value[i]))*features->class[i]<=0.0){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%f\n",features->class[i],pred); + break; + } + } + } + + accuracy /= features->nexamples; + accuracy = 1.0-accuracy; + + fclose(fp); + + fprintf(stdout,"Accuracy: %f\n",accuracy); + fprintf(stdout,"Class\t%d",features->p_classes[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",features->p_classes[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Ndata\t%d",data_in_each_class[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",data_in_each_class[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Nerrors\t%d",(int)error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",(int)error[j]); + } + fprintf(stdout,"\n"); + + for(j=0;jnclasses;j++){ + error[j] /= data_in_each_class[j]; + } + + fprintf(stdout,"Perrors\t%f",error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%f",error[j]); + } + fprintf(stdout,"\n"); + free(data_in_each_class); + free(error); +} + +double predict_svm(svm,x) + /* + given a svm model, return the predicted margin of a test point x + */ + SupportVectorMachine *svm; + double *x; +{ + int i,j; + double y = 0.0; + double K; + + if(svm->kernel_type==SVM_KERNEL_GAUSSIAN){ + for(i = 0; i < svm->N; i++){ + if(svm->alph[i] > 0){ + K=0.0; + for(j=0;jd;j++) + K+=(svm->dense_points[i][j]-x[j])*(svm->dense_points[i][j]-x[j]); + y += svm->alph[i] * svm->target[i] * exp(-K/svm->two_sigma_squared); + } + } + y -= svm->b; + } + + if(svm->kernel_type==SVM_KERNEL_LINEAR){ + K=0.0; + for(j=0;jd;j++) + K+=svm->w[j]*x[j]; + y=K-svm->b; + } + + if(svm->kernel_type==SVM_KERNEL_DIRECT){ + double *models; + double x1,x2; + int t; + + models=(double*)calloc(svm->d,sizeof(double)); + + + for(t=0;td;t++){ + models[t]=0.0; + x1=dot_product(x,svm->models[t].x1,svm->orig_d); + x2=dot_product(x,svm->models[t].x2,svm->orig_d); + models[t]=svm->models[t].w_coeff* + (svm->models[t].y1*x1+svm->models[t].y2*x2)+svm->models[t].b; + if(models[t]>1) + models[t]=1.0; + else if(models[t]<-1) + models[t]=-1.0; + } + + y=0.0; + for(i=0;iN;i++) + if(svm->alph[i]>0) + for(t=0;td;t++) + y+=svm->alph[i]*svm->target[i]*svm->dense_points[i][t]*models[t]; + + y -= svm->b; + free(models); + } + + return y; +} + + + +void compute_svm_bagging(bsvm,bagging,nsamples,nvar,data,data_class, + svm_kernel,kp,C,tol,eps,maxloops,svm_verbose,svm_W) + BSupportVectorMachine *bsvm; + int bagging; + int nsamples,nvar; + double **data; + int *data_class; + int svm_kernel,svm_verbose; + double kp; + double C; + double tol; + double eps; + int maxloops; + double *svm_W; +{ + int i,b; + int *bsamples; + double **xdata_training; + int *xclasses_training; + double *prob; + int nk; + int *extracted; + int index; + + + bsvm->svm=(SupportVectorMachine *)G_calloc(bagging, + sizeof(SupportVectorMachine)); + bsvm->nsvm=bagging; + bsvm->weights=(double *)G_calloc(bsvm->nsvm,sizeof(double)); + + for(b=0;bnsvm;b++){ + bsvm->weights[b]=1.0/bsvm->nsvm; + } + + + extracted=(int *) G_calloc(nsamples,sizeof(int)); + prob=(double *)calloc(nsamples,sizeof(double)); + bsamples=(int *) G_calloc(nsamples,sizeof(int)); + xdata_training=(double **) G_calloc(nsamples,sizeof(double *)); + xclasses_training=(int *) G_calloc(nsamples,sizeof(int)); + + for(i=0;insvm;b++){ + for(i=0;isvm[b]),nk,nvar,xdata_training, + xclasses_training, svm_kernel,kp,C,tol, + eps, maxloops,svm_verbose,svm_W); + + } + + free(bsamples); + free(xclasses_training); + free(prob); + free(extracted); + free(xdata_training); +} + + +void write_bagging_boosting_svm(file,bsvm,features) + /* + write a bagging or boosting svm to a file + */ + char *file; + BSupportVectorMachine *bsvm; + Features *features; +{ + int i,j; + FILE *fp; + char tempbuf[500]; + int b; + int np_weights; + + fp = fopen(file, "w"); + if(fp == NULL){ + sprintf(tempbuf, "write_bagging_boosting_svm-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + write_header_features(fp,features); + fprintf(fp,"#####################\n"); + fprintf(fp,"MODEL:\n"); + fprintf(fp,"#####################\n"); + + fprintf(fp,"Model:\n"); + fprintf(fp,"B-SupportVectorMachine\n"); + fprintf(fp,"Cost parameter:\n"); + fprintf(fp,"%f\n",bsvm->w); + fprintf(fp,"Number of models:\n"); + fprintf(fp,"%d\n",bsvm->nsvm); + fprintf(fp,"Weights:\n"); + fprintf(fp,"%f",bsvm->weights[0]); + for(b=1;bnsvm;b++){ + fprintf(fp,"\t%f",bsvm->weights[b]); + } + fprintf(fp,"\n"); + for(b=0;bnsvm;b++){ + + np_weights=0; + for(i=0;isvm[b].N;i++){ + if(bsvm->svm[b].alph[i]>0.0){ + np_weights += 1; + } + } + fprintf(fp,"Convergence:\n"); + fprintf(fp,"%d\n",bsvm->svm[b].convergence); + + fprintf(fp,"Kernel Type:\n"); + if(bsvm->svm[b].kernel_type == SVM_KERNEL_GAUSSIAN){ + fprintf(fp,"gaussian_kernel\n"); + } + if(bsvm->svm[b].kernel_type == SVM_KERNEL_LINEAR){ + fprintf(fp,"linear_kernel\n"); + } + fprintf(fp,"Kernel parameter:\n"); + fprintf(fp,"%f\n",bsvm->svm[b].two_sigma_squared); + + fprintf(fp,"Optimization parameter:\n"); + fprintf(fp,"%f\n",bsvm->svm[b].C); + + fprintf(fp,"Cost parameter:\n"); + fprintf(fp,"%f\n",bsvm->svm[b].cost); + + fprintf(fp,"Convergence parameters:\n"); + fprintf(fp,"tol\teps\tmaxloops\n"); + fprintf(fp,"%e\t%e\t%d\n",bsvm->svm[b].tolerance, + bsvm->svm[b].eps, bsvm->svm[b].maxloops); + + fprintf(fp,"Number of kernel:\n"); + fprintf(fp,"%d\n",np_weights); + fprintf(fp,"Dimension:\n"); + fprintf(fp,"%d\n",bsvm->svm[b].d); + + fprintf(fp,"Offset:\n"); + fprintf(fp,"%f\n",bsvm->svm[b].b); + + + + if(bsvm->svm[b].kernel_type==SVM_KERNEL_GAUSSIAN){ + fprintf(fp,"Kernel - Label - Weight:\n"); + for(i=0;isvm[b].N;i++){ + if(bsvm->svm[b].alph[i]>0.0){ + for(j=0;jsvm[b].d;j++){ + fprintf(fp,"%f\t",bsvm->svm[b].dense_points[i][j]); + } + fprintf(fp,"%d\t%f\n",bsvm->svm[b].target[i],bsvm->svm[b].alph[i]); + } + } + } + if(bsvm->svm[b].kernel_type==SVM_KERNEL_LINEAR){ + fprintf(fp,"Weight:\n"); + fprintf(fp,"%f",bsvm->svm[b].w[0]); + for(i=1;isvm[b].d;i++){ + fprintf(fp,"\t%f",bsvm->svm[b].w[i]); + } + fprintf(fp,"\n"); + } + + } + + if(features->f_pca[0]){ + fprintf(fp,"#####################\n"); + fprintf(fp,"PRINC. COMP.:\n"); + fprintf(fp,"#####################\n"); + + fprintf(fp,"Number of pc:\n"); + fprintf(fp,"%d\n",features->npc); + + for(i=0;if_pca[1];i++){ + fprintf(fp,"PCA: Layer %d\n",i+1); + write_pca(fp,&(features->pca[i])); + } + } + + fclose(fp); +} + + +void compute_svm_boosting(bsvm,boosting,w,nsamples,nvar,data,data_class, + nclasses,classes, svm_kernel,kp,C,tol,svm_eps, + maxloops,svm_verbose,svm_W,weights_boosting) + + BSupportVectorMachine *bsvm; + int boosting; + double w; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; + int svm_kernel,svm_verbose; + double kp; + double C; + double svm_eps; + double tol; + int maxloops; + double *svm_W; + int weights_boosting; + +{ + int i,b; + int *bsamples; + double **xdata_training; + int *xclasses_training; + double *prob; + double e00,e01,e10,e11,prior0,prior1; + int *error; + double eps, totprob; + double totbeta; + int nk; + int *extracted; + int index; + + if(weights_boosting==1){ + bsvm->w_evolution=(double**)G_calloc(nsamples,sizeof(double*)); + for(i=0;iw_evolution[i]=(double*)G_calloc(boosting+3,sizeof(double)); + } + + bsvm->svm=(SupportVectorMachine *)G_calloc(boosting, + sizeof(SupportVectorMachine)); + bsvm->nsvm=boosting; + bsvm->weights=(double *)G_calloc(bsvm->nsvm,sizeof(double)); + bsvm->w = w; + + extracted=(int *) G_calloc(nsamples,sizeof(int)); + prob=(double *)calloc(nsamples,sizeof(double)); + bsamples=(int *) G_calloc(nsamples,sizeof(int)); + xdata_training=(double **) G_calloc(nsamples,sizeof(double *)); + xclasses_training=(int *) G_calloc(nsamples,sizeof(int)); + error=(int *) G_calloc(nsamples,sizeof(int)); + + for(i=0;insvm;b++){ + if(weights_boosting==1) + for(i=0;iw_evolution[i][b]=prob[i]; + + + for(i=0;isvm[b]),nk,nvar,xdata_training, + xclasses_training, svm_kernel,kp,C,tol, + svm_eps, maxloops,svm_verbose,svm_W); + + e00=e01=e10=e11=prior0=prior1=0.0; + for(i=0;isvm[b]),data[i])*data_class[i]<=0.0){ + error[i] = TRUE; + e01 += prob[i]; + }else{ + error[i] = FALSE; + e00 += prob[i]; + } + prior0 += prob[i]; + }else{ + if(predict_svm(&(bsvm->svm[b]),data[i])*data_class[i]<=0.0){ + error[i] = TRUE; + e10 += prob[i]; + }else{ + error[i] = FALSE; + e11 += prob[i]; + } + prior1 += prob[i]; + } + } + eps = (1.0 - e00 / (e00+e01)) * prior0 *bsvm->w + + (1.0 - e11 / (e10+e11)) * prior1 * (2.0 - bsvm->w); + if(eps > 0.0 && eps < 0.5){ + bsvm->weights[b] = 0.5 * log((1.0 - eps) / eps); + totprob=0.0; + for(i=0;iweights[b] * bsvm->w); + }else{ + prob[i] = prob[i]* exp(bsvm->weights[b] * (2.0-bsvm->w)); + } + }else{ + if(data_class[i] == classes[0]){ + prob[i] = prob[i] * exp(-bsvm->weights[b] * (2.0-bsvm->w)); + }else{ + prob[i] = prob[i] * exp(-bsvm->weights[b] * bsvm->w); + } + } + totprob += prob[i]; + } + for(i=0;iweights[b] = 0.0; + for(i=0;insvm;b++){ + totbeta += bsvm->weights[b]; + } + for(b=0;bnsvm;b++){ + bsvm->weights[b] /= totbeta; + } + + + free(bsamples); + free(xclasses_training); + free(prob); + free(extracted); + free(xdata_training); + free(error); + +} + +double predict_bsvm(bsvm,x) + /* + given a bsvm model, return the predicted margin of a test point x + */ + BSupportVectorMachine *bsvm; + double *x; +{ + int b; + int predict; + double out; + double pred; + + out = 0.0; + for(b=0;bnsvm;b++){ + pred=predict_svm(&(bsvm->svm[b]),x); + if(pred<0.0){ + predict=-1; + }else if(pred>0.0){ + predict=1; + }else{ + predict=0; + } + out += predict * bsvm->weights[b]; + } + return out; +} + +void test_bsvm(bsvm,features,file) + /* + test bagging or boosting svm model on a set of data (features) + and write the results into a file. To standard output accuracy + and error on each class + */ + BSupportVectorMachine *bsvm; + Features *features; + char *file; +{ + int i,j; + int *data_in_each_class; + FILE *fp; + char tempbuf[500]; + double pred; + double *error; + double accuracy; + + + fp = fopen(file, "w"); + if(fp == NULL){ + sprintf(tempbuf, "test_bsvm-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + data_in_each_class=(int *)G_calloc(features->nclasses,sizeof(int)); + error=(double *)G_calloc(features->nclasses,sizeof(double)); + + accuracy = 0.0; + for(i=0;inexamples;i++){ + for(j=0;jnclasses;j++){ + if(features->class[i] == features->p_classes[j]){ + data_in_each_class[j] += 1; + if((pred=predict_bsvm(bsvm,features->value[i]))*features->class[i]<=0.0){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%f\n",features->class[i],pred); + break; + } + } + } + + accuracy /= features->nexamples; + accuracy = 1.0-accuracy; + + fclose(fp); + + fprintf(stdout,"Accuracy: %f\n",accuracy); + fprintf(stdout,"Class\t%d",features->p_classes[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",features->p_classes[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Ndata\t%d",data_in_each_class[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",data_in_each_class[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Nerrors\t%d",(int)error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",(int)error[j]); + } + fprintf(stdout,"\n"); + + for(j=0;jnclasses;j++){ + error[j] /= data_in_each_class[j]; + } + + fprintf(stdout,"Perrors\t%f",error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%f",error[j]); + } + fprintf(stdout,"\n"); + free(data_in_each_class); + free(error); +} + + +void test_bsvm_progressive(bsvm,features,file) + /* + test bagging or boosting svm model on a set of data (features) + and write the results into a file. To standard output accuracy + and error on each class + */ + BSupportVectorMachine *bsvm; + Features *features; + char *file; +{ + int i,j; + int *data_in_each_class; + FILE *fp; + char tempbuf[500]; + double pred; + double *error; + double accuracy; + int b; + + fp = fopen(file, "w"); + if(fp == NULL){ + sprintf(tempbuf, "test_bsvm-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + data_in_each_class=(int *)G_calloc(features->nclasses,sizeof(int)); + error=(double *)G_calloc(features->nclasses,sizeof(double)); + + for(b=1;b<=bsvm->nsvm;b++){ + if((b<100 &&b%2==1) || (b>=100) || (b==bsvm->nsvm)){ + accuracy = 0.0; + for(j=0;jnclasses;j++){ + error[j]=.0; + data_in_each_class[j]=0; + } + for(i=0;inexamples;i++){ + for(j=0;jnclasses;j++){ + if(features->class[i] == features->p_classes[j]){ + data_in_each_class[j] += 1; + if((pred=predict_bsvm_progressive(bsvm,features->value[i],b)) + *features->class[i]<=0.0){ + error[j] += 1.0; + accuracy += 1.0; + } + if(b==bsvm->nsvm) + fprintf(fp,"%d\t%f\n",features->class[i],pred); + break; + } + } + } + + accuracy /= features->nexamples; + accuracy = 1.0-accuracy; + + if(b==bsvm->nsvm) + fclose(fp); + + fprintf(stdout,"nmodels = %d\n",b); + fprintf(stdout,"Accuracy: %f\n",accuracy); + fprintf(stdout,"Class\t%d",features->p_classes[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",features->p_classes[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Ndata\t%d",data_in_each_class[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",data_in_each_class[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Nerrors\t%d",(int)error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",(int)error[j]); + } + fprintf(stdout,"\n"); + + for(j=0;jnclasses;j++){ + error[j] /= data_in_each_class[j]; + } + + fprintf(stdout,"Perrors\t%f",error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%f",error[j]); + } + fprintf(stdout,"\n"); + } + } + free(data_in_each_class); + free(error); +} + +double predict_bsvm_progressive(bsvm,x,bmax) + /* + given a bsvm model, return the predicted margin of a test point x + */ + BSupportVectorMachine *bsvm; + double *x; + int bmax; +{ + int b; + int predict; + double out; + double pred; + + out = 0.0; + for(b=0;bsvm[b]),x); + if(pred<0.0){ + predict=-1; + }else if(pred>0.0){ + predict=1; + }else{ + predict=0; + } + out += predict * bsvm->weights[b]; + } + return out; +} + +double dot_product(x,y,n) + double *x,*y; + int n; + +{ + double out=.0; + + n--; + while(n>=0) + out += x[n]*y[n--]; + + return out; +} + Property changes on: trunk/grassaddons/i.pr/PRLIB/svm.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/test.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/test.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/test.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,266 @@ +/* + The following routines are borrowed from "Numerical Recipes in C" + and rearranged by Stefano Merler + + for + + statistical test computation + + Supported functions for: + - KS test the normal distribution of data + - KS test for equality of 2 distribution + - t-test for mean +*/ + +#include +#include "gis.h" +#include "global.h" + +#define EPS1 0.001 +#define EPS2 1.0e-8 +#define MAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1)>(maxarg2)?(maxarg1):(maxarg2)) + + double maxarg1,maxarg2; + + double probks(); + double probks2(); + double betai(); + double gammln(); + double betacf(); + +void ksone_normal(data,n,p1,p2,d,prob) + /* + KS test for normal distribution. data is the array of data + of length n. p1 and p2 mean and sd of the normal distribution + tested. On output d is the value of the test and prob + the p-value + */ + double *data,*d,*prob; + int n; + double p1,p2; + +{ + int j; + double fo=0.0,fn,ff,en,dt; + + shell(n,data); + en=(double) n; + + *d=0.0; + + for(j=1;j<=n;j++){ + fn=j/en; + ff=cumulative_normal_distribution(p1,p2,data[j-1]); + dt=MAX(fabs(fo-ff),fabs(fn-ff)); + if(dt>*d) *d=dt; + fo=fn; + } + *prob=probks2(*d,n); + +} + +void kstwo(data1,n1,data2,n2,d,prob) + /* + KS test for testing 2 distribution. data1 is the first + array of data of length n1. data2 is the second array + of data of length n2. On output d is the value of the + test and prob the p-value + */ + double *data1, *data2, *d, *prob; + int n1,n2; +{ + int j1=1,j2=1; + double en1,en2,fn1=0.0,fn2=0.0,dt,d1,d2; + + en1=n1; + en2=n2; + *d=0.0; + shell(n1,data1); + shell(n2,data2); + while(j1 <= n1 && j2<=n2){ + if((d1=data1[j1-1]) <= (d2=data2[j2-1])){ + fn1=(j1++)/en1; + } + if(d2<=d1){ + fn2=(j2++)/en2; + } + if ((dt=fabs(fn2-fn1)) > *d) *d=dt; + } + *prob=probks(sqrt(en1*en2/(en1+en2))*(*d)); +} + + double probks(alam) + /* + evaluate Q(KS) function i.e significance + */ + double alam; +{ + int j; + double a2,fac=2.0,sum=0.0,term,termbf=0.0; + + a2=-2.0*alam*alam; + for(j=1;j<=100;j++){ + term=fac*exp(a2*j*j); + sum+=term; + if(fabs(term)<=EPS1*termbf || fabs(term) <=EPS2*sum)return sum; + fac = -fac; + termbf=fabs(term); + } + return 1.0; +} + + double probks2(alam,ndata) + /* + evaluate Q(KS) function (Dallal-Wilkinson approx.) + i.e significance depending from the number of + data ndata + */ + double alam; + int ndata; +{ + double ks,p,n; + + n=(double) ndata; + ks=alam; + + if(ndata>100){ + ks=ks*pow(n/100.,0.49); + n=100.; + } + p=exp(-7.01256*ks*ks*(n+2.78019) + 2.99587*ks*sqrt(n+ 2.78019) - 0.122119 + + 0.974598/sqrt(n) + 1.67997/n); + return(p); +} + +double normal_distribution(x,mu,sigma) + /* + normal distribution with mean mu and + standard deviation sigma computed at point x + + 1/(sigma*sqrt(PIG) exp(-(x-mu)^2/2sigma^2) + */ + double x,mu,sigma; +{ + return exp(-1*(x-mu)*(x-mu)/(2.0*sigma*sigma))/(sigma*sqrt(2*PIG)); + + +} + +double cumulative_normal_distribution(mu,sigma,x) + /* + cumulative probability of the normal + distribution with mean mu and + standard deviation sigma, i.e. + integral from -Inf to x + + */ + double mu,sigma,x; +{ + return trapzd2(normal_distribution,mu,sigma,-10.,x,1000); +} + +#undef EPS1 +#undef EPS2 + + double gammln(xx) + double xx; +{ + double x,tmp,ser; + static double cof[6]={76.18009173,-86.50532033,24.01409822, + -1.231739516,0.120858003e-2,-0.536382e-5}; + int j; + + x=xx-1.0; + tmp=x+5.5; + tmp -= (x+0.5)*log(tmp); + ser=1.0; + for(j=0;j<=5;j++){ + x += 1.0; + ser += cof[j]/x; + } + return -tmp+log(2.50662827465*ser); +} + +#define ITMAX 1000000 +#define EPS 3.0e-7 + + double betacf(a,b,x) + double a,b,x; +{ + double qap,qam,qab,em,tem,d; + double bz,bm=1.0,bp,bpp; + double az=1.0,am=1.0,ap,app,aold; + int m; + + qab=a+b; + qap=a+1.0; + qam=a-1.0; + + bz=1.0-qab*x/qap; + + for(m=1;m<=ITMAX;m++){ + em=(double)m; + tem=em+em; + d=em*(b-em)*x/((qam+tem)*(a+tem)); + ap=az+d*am; + bp=bz+d*bm; + d = -(a+em)*(qab+em)*x/((qap+tem)*(a+tem)); + app=ap+d*az; + bpp=bp+d*bz; + aold=az; + am=ap/bpp; + bm=bp/bpp; + az=app/bpp; + bz=1.0; + if(fabs(az-aold)<(EPS*fabs(az))) + return az; + } + G_warning("a or b tto big, or ITMAX too small in BETACF\n"); +} + +#undef ITMAX +#undef EPS + + double betai(a,b,x) + double a,b,x; +{ + double bt; + + if(x<0.0 || x> 1.0){ + G_warning("bad x in BETAI\n"); + } + if(x==0.0 || x == 1.0){ + bt = 0.0; + }else{ + bt=exp(gammln(a+b)-gammln(a)-gammln(b)+a*log(x)+b*log(1.0-x)); + } + if(x< (a+1.0)/(a+b+2.0)){ + return bt*betacf(a,b,x)/a; + }else{ + return 1.0-bt*betacf(b,a,1.0-x)/b; + } +} + + double sqrarg; + +#define SQR(a) (sqrarg=(a),sqrarg*sqrarg) + +void tutest(data1,n1,data2,n2,t,prob) + /* + */ + double *data1, *data2, *t, *prob; + int n1,n2; +{ + double var1,var2,df,ave1,ave2; + + + ave1=mean_of_double_array(data1,n1); + var1=var_of_double_array_given_mean(data1,n1,ave1); + + ave2=mean_of_double_array(data2,n2); + var2=var_of_double_array_given_mean(data2,n2,ave2); + + *t=(ave1-ave2)/sqrt(var1/n1+var2/n2); + df=SQR(var1/n1+var2/n2)/(SQR(var1/n1)/(n1-1)+SQR(var2/n2)/(n2-1)); + *prob=betai(0.5*df,0.5,df/(df+SQR(*t))); +} Property changes on: trunk/grassaddons/i.pr/PRLIB/test.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/training.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/training.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/training.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,229 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + structure Training management +*/ + +#include "gis.h" +#include "global.h" +#include +#include +#include + +void inizialize_training(training) + /* + alloc memory for training (see global.h for details) + */ + Training *training; +{ + int i; + + training->nexamples = 0; + training->east=(double *)G_calloc(TRAINING_MAX_EXAMPLES,sizeof(double)); + training->north=(double *)G_calloc(TRAINING_MAX_EXAMPLES,sizeof(double)); + training->class=(int *)G_calloc(TRAINING_MAX_EXAMPLES,sizeof(int)); + training->mapnames=(char ***)G_calloc(TRAINING_MAX_EXAMPLES,sizeof(char **)); + for(i=0;imapnames[i]= (char **)G_calloc(TRAINING_MAX_LAYERS,sizeof(char *)); + } + training->data=(double **)G_calloc(TRAINING_MAX_EXAMPLES,sizeof(double *)); +} + +void read_training(file,training) + /* + read training structure from a file. Supported formats + GRASS_data:list of labelled raster maps + TABLE_data:list of labelled vecors + */ + char *file; + Training *training; +{ + FILE *fp; + char tempbuf[500]; + char *line = NULL; + int i,j; + int index; + int tmprow,tmpcol; + double tmpew,tmpns; + int nlayers; + int training_type=0; + int tmpc; + + fp = fopen(file, "r"); + if(fp == NULL){ + sprintf(tempbuf, "read_training-> Can't open file %s for reading", file); + G_fatal_error(tempbuf); + } + + + training->file=file; + + line=GetLine(fp); + line=GetLine(fp); + + + if(strcmp(line,"GrassTraining") == 0){ + training_type = GRASS_data; + } + if(strcmp(line,"TableTraining") == 0){ + training_type = TABLE_data; + } + + switch(training_type){ + case GRASS_data: + training->data_type=training_type; + if(training->nexamples == 0){ + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d",&(training->nlayers)); + if(training->nlayers > TRAINING_MAX_LAYERS){ + sprintf(tempbuf,"read_training-> Maximum number of layers is %d", + TRAINING_MAX_LAYERS); + G_fatal_error(tempbuf); + } + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + }else{ + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d",&nlayers); + if(nlayers != training->nlayers){ + sprintf(tempbuf, "read_training-> Training files must contain same number of layers"); + G_fatal_error(tempbuf); + } + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + line=GetLine(fp); + } + while((line=GetLine(fp))!= NULL){ + for(i=0;inlayers;i++){ + j = 0; + training->mapnames[training->nexamples][i] = + (char *) G_calloc(strlen(line) - 1, sizeof(char)); + index=0; + while(line[j] > 44 && line[j] < 123) + training->mapnames[training->nexamples][i][index++]=line[j++]; + training->mapnames[training->nexamples][i] + [strlen(training->mapnames[training->nexamples][i])]='\0'; + line = (char *)strchr(line, '\t'); + line++; + } + sscanf(line,"%d",&(training->class[training->nexamples])); + + line = (char *)strchr(line, '\t'); + *line++; + sscanf(line,"%lf",&(training->east[training->nexamples])); + + line = (char *)strchr(line, '\t'); + *line++; + sscanf(line,"%lf",&(training->north[training->nexamples])); + + line = (char *)strchr(line, '\t'); + *line++; + if(training->nexamples == 0){ + sscanf(line,"%d",&(training->rows)); + }else{ + sscanf(line,"%d",&tmprow); + } + + line = (char *)strchr(line, '\t'); + *line++; + if(training->nexamples == 0){ + sscanf(line,"%d",&(training->cols)); + }else{ + sscanf(line,"%d",&tmpcol); + } + + line = (char *)strchr(line, '\t'); + *line++; + if(training->nexamples == 0){ + sscanf(line,"%lf",&(training->ew_res)); + }else{ + sscanf(line,"%lf",&tmpew); + } + + line = (char *)strchr(line, '\t'); + *line++; + if(training->nexamples == 0){ + sscanf(line,"%lf",&(training->ns_res)); + }else{ + sscanf(line,"%lf",&tmpns); + } + + if(training->nexamples>0){ + if((tmprow != training->rows) || (tmpcol != training->cols)){ + sprintf(tempbuf, "read_training-> Example %d: different number of rows or cols", + training->nexamples+1); + G_fatal_error(tempbuf); + } + if(fabs((tmpew- training->ew_res)/training->ew_res)>0.1){ + sprintf(tempbuf, "read_training-> Example %d: EW-resolution differs more than 10%%", + training->nexamples+1); + G_warning(tempbuf); + } + if(fabs((tmpns- training->ns_res)/training->ns_res)>0.1){ + sprintf(tempbuf, "read_training-> Example %d: NS-resolution differs more than 10%%", + training->nexamples+1); + G_warning(tempbuf); + } + + } + training->nexamples += 1; + if(training->nexamples == TRAINING_MAX_EXAMPLES){ + sprintf(tempbuf,"read_training-> Maximum number of training data is %d", + TRAINING_MAX_EXAMPLES); + G_fatal_error(tempbuf); + } + + } + break; + case TABLE_data: + training->data_type=training_type; + training->rows=1; + training->ew_res=0.0; + training->ns_res=0.0; + training->nlayers=1; + if(training->nexamples == 0){ + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &(training->cols)); + }else{ + line=GetLine(fp); + line=GetLine(fp); + sscanf(line,"%d", &(tmpc)); + if(tmpc != training->cols){ + sprintf(tempbuf,"read_training-> training data must have same number of columns"); + G_fatal_error(tempbuf); + } + } + line=GetLine(fp); + while((line=GetLine(fp))!= NULL){ + training->data[training->nexamples]=(double *)G_calloc(training->cols, + sizeof(double)); + for(i=0;icols;i++){ + sscanf(line,"%lf", &(training->data[training->nexamples][i])); + line = (char *)strchr(line, '\t'); + *line++; + } + sscanf(line,"%d", &(training->class[training->nexamples])); + training->nexamples += 1; + if(training->nexamples == TRAINING_MAX_EXAMPLES){ + sprintf(tempbuf,"read_training-> Maximum number of training data is %d", + TRAINING_MAX_EXAMPLES); + G_fatal_error(tempbuf); + } + } + break; + + default: + sprintf(tempbuf, "read_training-> Format not recognized"); + G_fatal_error(tempbuf); + break; + } + fclose(fp); +} Property changes on: trunk/grassaddons/i.pr/PRLIB/training.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/tree.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/tree.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/tree.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,2054 @@ +/* + The following routines are written and tested by Stefano Merler + + for + + structure Tree and BTree management +*/ + +#include "gis.h" +#include "global.h" +#include +#include +#include + +static void split_node(); + +void compute_tree(tree,nsamples,nvar,data,data_class,nclasses, + classes,stamps,minsize,costs) + /* + receives in input training data of dimensions nsamples x nvar, + with class labels data_class, the possible classes (of length nclasses) + and computes a tree model; optionally, the user can build stamps + and decide the minimal number of cases within a node as + stopping criteria. + */ + Tree *tree; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; + int stamps; + int minsize; + double *costs; +{ + + int i,j; + int node_class_index; + int max_node_points; + int xx; + double sumpriors; + + tree->stamps = stamps; + tree->minsize = minsize; + + + tree->node=(Node *)malloc(sizeof(Node)); + tree->node[0].nclasses=nclasses; + + + tree->node[0].npoints = nsamples; + tree->node[0].nvar = nvar; + tree->node[0].data=data; + tree->node[0].classes=data_class; + + + tree->node[0].npoints_for_class=(int *)calloc(nclasses,sizeof(int)); + tree->node[0].priors=(double *)calloc(nclasses,sizeof(double)); + + + for(i=0;inode[0].npoints;i++){ + for(j = 0; j < nclasses;j++) + if(classes[j]==tree->node[0].classes[i]){ + tree->node[0].npoints_for_class[j] += 1; + break; + } + } + + node_class_index=0; + max_node_points=0; + for(j = 0; j < nclasses;j++) + if(tree->node[0].npoints_for_class[j] > max_node_points){ + max_node_points = tree->node[0].npoints_for_class[j]; + node_class_index = j; + } + tree->node[0].class = classes[node_class_index]; + + sumpriors=.0; + for(j=0;jnode[0].npoints_for_class[j]; + for(j = 0; j < nclasses;j++) + tree->node[0].priors[j] = costs[j] * tree->node[0].npoints_for_class[j]/sumpriors; + + tree->node[0].terminal=TRUE; + if(entropy(tree->node[0].priors,nclasses)>0) + tree->node[0].terminal=FALSE; + + tree->nnodes=1; + for(xx=0;xxnnodes;xx++) + if(!tree->node[xx].terminal){ + tree->node[xx].left=tree->nnodes; + tree->node[xx].right=tree->nnodes+1; + tree->node=(Node *)realloc(tree->node,(tree->nnodes+2)*sizeof(Node)); + split_node(&(tree->node[xx]),&(tree->node[tree->nnodes]), + &(tree->node[tree->nnodes+1]),classes,nclasses,costs); + if(tree->minsize>0){ + if(tree->node[tree->nnodes].npoints < tree->minsize) + tree->node[tree->nnodes].terminal = TRUE; + if(tree->node[tree->nnodes+1].npoints < tree->minsize) + tree->node[tree->nnodes+1].terminal = TRUE; + } + if(tree->stamps){ + tree->node[tree->nnodes].terminal = TRUE; + tree->node[tree->nnodes+1].terminal = TRUE; + } + tree->nnodes += 2; + } + +} + + +static void split_node(node,nodeL,nodeR,classes,nclasses,costs) + Node *node,*nodeL,*nodeR; + int *classes; + int nclasses; + double *costs; +{ + int **indx; + double *tmpvar; + int i,j,k; + int **npL , **npR; + double **prL , **prR; + int totL,totR; + double a,b; + double *decrease_in_inpurity; + double max_decrease; + int splitvar=0; + int splitvalue=0; + int morenumerous; + double sumpriors; + + nodeL->priors=(double *) calloc(nclasses,sizeof(double)); + nodeR->priors=(double *) calloc(nclasses,sizeof(double)); + nodeL->npoints_for_class=(int *) calloc(nclasses,sizeof(int)); + nodeR->npoints_for_class=(int *) calloc(nclasses,sizeof(int)); + + indx=(int **)calloc(node->nvar,sizeof(int *)); + for(i=0;invar;i++) + indx[i]=(int *)calloc(node->npoints,sizeof(int)); + + tmpvar=(double *) calloc(node->npoints,sizeof(double)); + decrease_in_inpurity=(double *) calloc(node->npoints-1,sizeof(double)); + + npL=(int **)calloc(node->npoints,sizeof(int *)); + for(i=0;inpoints;i++) + npL[i]=(int *)calloc(nclasses,sizeof(int)); + npR=(int **)calloc(node->npoints,sizeof(int *)); + for(i=0;inpoints;i++) + npR[i]=(int *)calloc(nclasses,sizeof(int)); + + prL=(double **)calloc(node->npoints,sizeof(double *)); + for(i=0;inpoints;i++) + prL[i]=(double *)calloc(nclasses,sizeof(double)); + prR=(double **)calloc(node->npoints,sizeof(double *)); + for(i=0;inpoints;i++) + prR[i]=(double *)calloc(nclasses,sizeof(double)); + + for(i=0;invar;i++){ + for(j=0;jnpoints;j++) + tmpvar[j]=node->data[j][i]; + + indexx_1(node->npoints,tmpvar,indx[i]); + + for(k=0;kclasses[indx[i][0]]==classes[k]){ + npL[0][k] = 1; + npR[0][k] = node->npoints_for_class[k]-npL[0][k]; + } else{ + npL[0][k] = 0; + npR[0][k] = node->npoints_for_class[k]; + } + + + for(j=1;jnpoints-1;j++) + for(k=0;kclasses[indx[i][j]]==classes[k]){ + npL[j][k] = npL[j-1][k] +1; + npR[j][k] = node->npoints_for_class[k] - npL[j][k]; + } + else { + npL[j][k] = npL[j-1][k]; + npR[j][k] = node->npoints_for_class[k] - npL[j][k]; + } + + + for(j=0;jnpoints-1;j++){ + totL = totR = 0; + for(k=0;knpoints; + b = (double) totR/(double)node->npoints ; + + decrease_in_inpurity[j] = entropy(node->priors,nclasses) - + a * entropy(prL[j],nclasses) - b * entropy(prR[j],nclasses); + } + + if(i==0){ + splitvar=0; + splitvalue=0; + max_decrease=decrease_in_inpurity[0]; + + for(k=0;kpriors[k]=prL[splitvalue][k]; + for(k=0;kpriors[k]=prR[splitvalue][k]; + + for(k=0;knpoints_for_class[k]=npL[splitvalue][k]; + for(k=0;knpoints_for_class[k]=npR[splitvalue][k]; + } + + for(j=0;jnpoints-1;j++) + if(decrease_in_inpurity[j] > max_decrease){ + max_decrease = decrease_in_inpurity[j]; + + splitvar=i; + splitvalue=j; + + for(k=0;kpriors[k]=prL[splitvalue][k]; + for(k=0;kpriors[k]=prR[splitvalue][k]; + + for(k=0;knpoints_for_class[k]=npL[splitvalue][k]; + for(k=0;knpoints_for_class[k]=npR[splitvalue][k]; + + + } + + } + + if(splitvar<0 && splitvalue<0){ + node->value=0; + node->terminal=TRUE; + nodeL->nclasses=node->nclasses; + nodeL->npoints=0; + nodeL->terminal=TRUE; + nodeL->class=-9999; + nodeR->nclasses=node->nclasses; + nodeR->npoints=0; + nodeR->terminal=TRUE; + nodeR->class=-9999; + return; + } + + node->var=splitvar; + node->value=(node->data[indx[splitvar][splitvalue]][node->var]+ + node->data[indx[splitvar][splitvalue+1]][node->var])/2.; + + + nodeL->nvar=node->nvar; + nodeL->nclasses=node->nclasses; + nodeL->npoints=splitvalue+1; + + nodeL->terminal=TRUE; + if(entropy(nodeL->priors,nclasses)>0) + nodeL->terminal=FALSE; + + nodeL->data=(double **) calloc(nodeL->npoints,sizeof(double *)); + nodeL->classes=(int *)calloc(nodeL->npoints, sizeof(int)); + + for(i=0;inpoints;i++){ + nodeL->data[i] = node->data[indx[splitvar][i]]; + nodeL->classes[i] = node->classes[indx[splitvar][i]]; + } + + + morenumerous=0; + for(k=0;knpoints_for_class[k] > morenumerous){ + morenumerous = nodeL->npoints_for_class[k]; + nodeL->class=classes[k]; + } + + + + nodeR->nvar=node->nvar; + nodeR->nclasses=node->nclasses; + nodeR->npoints=node->npoints-nodeL->npoints; + + nodeR->terminal=TRUE; + if(entropy(nodeR->priors,nclasses)>0) + nodeR->terminal=FALSE; + + + nodeR->data=(double **) calloc(nodeR->npoints,sizeof(double *)); + nodeR->classes=(int *)calloc(nodeR->npoints, sizeof(int)); + + for(i=0;inpoints;i++){ + nodeR->data[i] = node->data[indx[splitvar][nodeL->npoints+i]]; + nodeR->classes[i] = node->classes[indx[splitvar][nodeL->npoints+i]]; + } + + morenumerous=0; + for(k=0;knpoints_for_class[k] > morenumerous){ + morenumerous = nodeR->npoints_for_class[k]; + nodeR->class=classes[k]; + } + + + for(i=0;invar;i++) + free(indx[i]); + free(indx); + + for(i=0;inpoints;i++) + free(npL[i]); + free(npL); + for(i=0;inpoints;i++) + free(npR[i]); + free(npR); + + for(i=0;inpoints;i++) + free(prL[i]); + free(prL); + for(i=0;inpoints;i++) + free(prR[i]); + free(prR); + + free(tmpvar); + free(decrease_in_inpurity); +} + + +void write_tree(file,tree,features) + /* + write a tree model to a file + */ + char *file; + Tree *tree; + Features *features; +{ + int i,j; + FILE *fp; + char tempbuf[500]; + + + fp = fopen(file, "w"); + if(fp == NULL){ + sprintf(tempbuf, "write_tree-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + + write_header_features(fp,features); + fprintf(fp,"#####################\n"); + fprintf(fp,"MODEL:\n"); + fprintf(fp,"#####################\n"); + fprintf(fp,"Model:\n"); + fprintf(fp,"ClassificationTree\n"); + fprintf(fp,"Number of nodes:\n"); + fprintf(fp,"%d\n",tree->nnodes); + fprintf(fp,"Number of classes:\n"); + fprintf(fp,"%d\n",tree->node[0].nclasses); + fprintf(fp,"Number of features:\n"); + fprintf(fp,"%d\n\n",tree->node[0].nvar); + fprintf(fp,"Tree structure:\n"); + fprintf(fp,"terminal\tndata\t"); + for(j=0;jnode[0].nclasses;j++) + fprintf(fp,"data_cl%d\t",j+1); + for(j=0;jnode[0].nclasses;j++) + fprintf(fp,"prior_cl%d\t",j+1); + fprintf(fp,"class\tchild_left\tchild_right\tsplit_variable\tsplit_value\n"); + for(i=0;innodes;i++){ + fprintf(fp,"%d\t%d\t", tree->node[i].terminal,tree->node[i].npoints); + for(j=0;jnode[i].nclasses;j++) + fprintf(fp,"%d\t",tree->node[i].npoints_for_class[j]); + for(j=0;jnode[i].nclasses;j++) + fprintf(fp,"%f\t",tree->node[i].priors[j]); + if(tree->node[i].terminal) + fprintf(fp,"%d\n",tree->node[i].class); + else + fprintf(fp,"%d\t%d\t%d\t%d\t%f\n",tree->node[i].class,tree->node[i].left, + tree->node[i].right,tree->node[i].var,tree->node[i].value); + } + if(features->f_pca[0]){ + fprintf(fp,"#####################\n"); + fprintf(fp,"PRINC. COMP.:\n"); + fprintf(fp,"#####################\n"); + fprintf(fp,"Number of pc:\n"); + fprintf(fp,"%d\n",features->npc); + + + for(i=0;if_pca[1];i++){ + fprintf(fp,"PCA: Layer %d\n",i+1); + write_pca(fp,&(features->pca[i])); + } + } + + fclose(fp); +} + + +void compute_tree_boosting(btree,boosting,w,nsamples,nvar,data,data_class, + nclasses,classes, stamps,minsize,weights_boosting, + costs) + /* + receives in input training data of dimensions nsamples x nvar, + with class labels data_class, the possible classes (of length nclasses) + and computes a boosting tree model (number of models = boosting) using w + as parameter for the cost sensitive procedure; + optionally, the user can build stamps and decide the + minimal number of cases within a node as stopping criteria. + */ + BTree *btree; + int boosting; + double w; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; + int stamps; + int minsize; + int weights_boosting; + double *costs; +{ + int i,b; + int *bsamples; + double **xdata_training; + int *xclasses_training; + double *prob; + double e00,e01,e10,e11,prior0,prior1; + int *error; + double eps, totprob; + double totbeta; + + if(weights_boosting==1){ + btree->w_evolution=(double**)G_calloc(nsamples,sizeof(double*)); + for(i=0;iw_evolution[i]=(double*)G_calloc(boosting+3,sizeof(double)); + } + + btree->tree=(Tree *)G_calloc(boosting,sizeof(Tree)); + btree->ntrees=boosting; + btree->weights=(double *)G_calloc(btree->ntrees,sizeof(double)); + btree->w = w; + + prob=(double *)calloc(nsamples,sizeof(double)); + bsamples=(int *) G_calloc(nsamples,sizeof(int)); + xdata_training=(double **) G_calloc(nsamples,sizeof(double *)); + xclasses_training=(int *) G_calloc(nsamples,sizeof(int)); + error=(int *) G_calloc(nsamples,sizeof(int)); + + for(i=0;intrees;b++){ + if(weights_boosting==1) + for(i=0;iw_evolution[i][b]=prob[i]; + + Bootsamples(nsamples,prob,bsamples); + /* QUESTA PARTE SERVE PER VEDERE GLI ESTRATTI + AD OGNI RIPETIZIONE: AL MOMENTO LA DISABILITO, + AGGIUNGERE OPZIONE NEL MAIN DI i.pr_model PER ATTIVARLA + { + int out,j; + + out=0; + for(j=0;jtree[b]),nsamples,nvar,xdata_training, + xclasses_training, nclasses,classes,stamps,minsize,costs); + + e00=e01=e10=e11=prior0=prior1=0.0; + for(i=0;itree[b]),data[i]) != data_class[i]){ + error[i] = TRUE; + e01 += prob[i]; + }else{ + error[i] = FALSE; + e00 += prob[i]; + } + prior0 += prob[i]; + }else{ + if(predict_tree_multiclass(&(btree->tree[b]),data[i]) != data_class[i]){ + error[i] = TRUE; + e10 += prob[i]; + }else{ + error[i] = FALSE; + e11 += prob[i]; + } + prior1 += prob[i]; + } + } + eps = (1.0 - e00 / (e00+e01)) * prior0 *btree->w + + (1.0 - e11 / (e10+e11)) * prior1 * (2.0 - btree->w); + if(eps > 0.0 && eps < 0.5){ + btree->weights[b] = 0.5 * log((1.0 - eps) / eps); + totprob=0.0; + for(i=0;iweights[b] * btree->w); + }else{ + prob[i] = prob[i]* exp(btree->weights[b] * (2.0-btree->w)); + } + }else{ + if(data_class[i] == classes[0]){ + prob[i] = prob[i] * exp(-btree->weights[b] * (2.0-btree->w)); + }else{ + prob[i] = prob[i] * exp(-btree->weights[b] * btree->w); + } + } + totprob += prob[i]; + } + for(i=0;iweights[b] = 0.0; + for(i=0;intrees;b++){ + totbeta += btree->weights[b]; + } + if(totbeta>0){ + for(b=0;bntrees;b++){ + btree->weights[b] /= totbeta; + } + }else{ + fprintf(stderr,"WARNING: weights all null, set to 1/nmodels\n"); + for(b=0;bntrees;b++){ + btree->weights[b] = 1./btree->ntrees; + } + } + + free(bsamples); + free(xclasses_training); + free(prob); + free(error); + free(xdata_training); +} + +/*########################Regularized adaboost################################ */ +/* The following routines are written and tested by Mauro Martinelli */ +void compute_tree_boosting_reg(btree,boosting,w,nsamples,nvar,data,data_class, + nclasses,classes, stamps,minsize,weights_boosting, + costs,misratio) + /* + receives in input training data of dimensions nsamples x nvar, + with class labels data_class, the possible classes (of length nclasses) + and computes a boosting tree model (number of models = boosting) using w + as parameter for the cost sensitive procedure; + optionally, the user can build stamps and decide the + minimal number of cases within a node as stopping criteria. + It calculates the misclassification ratio for every training data. + + */ + BTree *btree; + int boosting; + double w; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; + int stamps; + int minsize; + int weights_boosting; + double *costs; + double *misratio; +{ + int i,b,j; + int *bsamples; + double **xdata_training; + int *xclasses_training; + double *prob; + double e00,e01,e10,e11,prior0,prior1; + int *error; + double eps, totprob; + double totbeta; + double *mis; + double *notextracted; + int *extracted; + + + if(weights_boosting==1){ + btree->w_evolution=(double**)G_calloc(nsamples,sizeof(double*)); + for(i=0;iw_evolution[i]=(double*)G_calloc(boosting+3,sizeof(double)); + } + + btree->tree=(Tree *)G_calloc(boosting,sizeof(Tree)); + btree->ntrees=boosting; + btree->weights=(double *)G_calloc(btree->ntrees,sizeof(double)); + btree->w = w; + + notextracted=(double *)G_calloc(nsamples,sizeof(double)); + extracted=(int *) G_calloc(nsamples,sizeof(int)); + mis=(double *)G_calloc(nsamples,sizeof(double)); + prob=(double *)G_calloc(nsamples,sizeof(double)); + bsamples=(int *) G_calloc(nsamples,sizeof(int)); + xdata_training=(double **) G_calloc(nsamples,sizeof(double *)); + xclasses_training=(int *) G_calloc(nsamples,sizeof(int)); + error=(int *) G_calloc(nsamples,sizeof(int)); + + for(i=0;intrees;b++){ + if(weights_boosting==1) + for(i=0;iw_evolution[i][b]=prob[i]; + + Bootsamples(nsamples,prob,bsamples); + for(i=0;itree[b]),nsamples,nvar,xdata_training, + xclasses_training, nclasses,classes,stamps,minsize,costs); + + e00=e01=e10=e11=prior0=prior1=0.0; + for(i=0;itree[b]),data[i]) != data_class[i]){ + error[i] = TRUE; + e01 += prob[i]; + }else{ + error[i] = FALSE; + e00 += prob[i]; + } + prior0 += prob[i]; + }else{ + if(predict_tree_multiclass(&(btree->tree[b]),data[i]) != data_class[i]){ + error[i] = TRUE; + e10 += prob[i]; + }else{ + error[i] = FALSE; + e11 += prob[i]; + } + prior1 += prob[i]; + } + } + eps = (1.0 - e00 / (e00+e01)) * prior0 *btree->w + + (1.0 - e11 / (e10+e11)) * prior1 * (2.0 - btree->w); + if(eps > 0.0 && eps < 0.5){ + btree->weights[b] = 0.5 * log((1.0 - eps) / eps); + totprob=0.0; + for(i=0;iweights[b] * btree->w); + }else{ + prob[i] = prob[i]* exp(btree->weights[b] * (2.0-btree->w)); + } + }else{ + if(data_class[i] == classes[0]){ + prob[i] = prob[i] * exp(-btree->weights[b] * (2.0-btree->w)); + }else{ + prob[i] = prob[i] * exp(-btree->weights[b] * btree->w); + } + } + totprob += prob[i]; + } + for(i=0;iweights[b] = 0.0; + for(i=0;intrees;b++){ + totbeta += btree->weights[b]; + } + if(totbeta>0){ + for(b=0;bntrees;b++){ + btree->weights[b] /= totbeta; + } + }else{ + fprintf(stderr,"WARNING: weights all null, set to 1/nmodels\n"); + for(b=0;bntrees;b++){ + btree->weights[b] = 1./btree->ntrees; + } + } + + free(bsamples); + free(xclasses_training); + free(prob); + free(error); + free(xdata_training); + free(mis); + free(notextracted); + free(extracted); +} + + +void regularized_boosting(boosting,w,nsamples,nvar,data,data_class, + nclasses,classes, stamps,minsize,weights_boosting, + costs,misratio,reg,test_features,file,validation_features, + reg_verbose,nametest,nameval,modelout,train_features,testset) + /* + compute btree model on the new trainng set extracted, test the btree model on the validation + set and it calculates the best tree model. Write into the output file the best tree model. + */ + int boosting; + double w; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; + int stamps; + int minsize; + int weights_boosting; + double *costs; + double *misratio; + int reg,reg_verbose; + Features test_features; + char *file; + Features validation_features; + char nametest[150]; + char nameval[150]; + char modelout[150]; + Features train_features; + int testset; +{ + BTree *btree; + int i,j,k,run,t,z; + double **xdata_training; + int *xclasses_training; + int *ncampioni; + double r,regd,bestr; + double *accuracy; + double *toterror; + double bestaccuracy; + int vet; + char testtrain[150]; + + fprintf(stdout,"-----------------------------------\n"); + fprintf(stdout,"Training and prediction on validation data: %s\n",nameval); + if(reg_verbose>1){ + fprintf(stdout,"Class of validation features (regularized boosting):%d\n",validation_features.nclasses); + fprintf (stdout,"Interval number of misclassification ratio (regularized boosting):%d\n",reg); + fprintf(stdout,"-----------------------------------\n"); + } + + btree=(BTree*)G_calloc(reg,sizeof(BTree)); + ncampioni=(int *) G_calloc(reg,sizeof(int)); + accuracy=(double *) G_calloc(reg,sizeof(double)); + toterror=(double *) G_calloc(reg,sizeof(double)); + + xclasses_training=(int *) G_calloc(nsamples,sizeof(int)); + xdata_training=(double **) G_calloc(nsamples,sizeof(double *)); + for (k=0;k1){ + fprintf(stdout,"WARNING:at run %d the training set is too small\n",i);} + break; + } + else{ + if(reg_verbose>1){ + fprintf(stdout,"%d samples extracted at run %d and 'r' is: %e\n",ncampioni[i],i,r); + } + vet=0; + for(j=0;j1){ + fprintf(stdout,"Accuracy at run :%d is :%e\n",i,accuracy[i]); + fprintf(stdout,"-----------------------------------\n");} + + if(accuracy[i]>bestaccuracy){ + bestaccuracy=accuracy[i]; + run=i; + bestr=r; + } + else { + for(t=0;t0){ + sprintf(testtrain,"%s_tr_predshaved",modelout); + + fprintf(stdout,"Prediction on training data after shave:\n"); + test_btree(&btree[run],&train_features,testtrain); + fprintf(stdout,"-----------------------------------\n");} + + + + if (testset==1){ + + fprintf(stdout,"Test the standard tree model ('r'=1) on test data: %s\n",nametest); + test_btree(&btree[0],&test_features,file); + fprintf(stdout,"Test the best tree model on test data: %s\n",nametest); + test_btree(&btree[run],&test_features,file);} + + + fprintf(stdout,"Output file: %s\n",modelout); + write_bagging_boosting_tree(modelout,&btree[run],&train_features); + + + free(ncampioni); + free(accuracy); + free(xdata_training); + free(xclasses_training); + +} + + + +double test_regularized_boosting(btree,features) + /* + test a btree model on a reduced set of original data + (features) and return the accuracy of the btree model + */ + BTree *btree; + Features *features; + + +{ + int i,j; + int *data_in_each_class; + int predI; + double predD; + double accuracy; + + data_in_each_class=(int *)G_calloc(features->nclasses,sizeof(int)); + + + + accuracy = 0.0; + for(i=0;inexamples;i++){ + for(j=0;jnclasses;j++){ + if(features->class[i] == features->p_classes[j]){ + data_in_each_class[j] += 1; + if(features->nclasses==2){ + if((predD=predict_btree_2class(btree,features->value[i])) *features->class[i] <= 0){ + accuracy += 1.0; + } + }else{ + if((predI=predict_btree_multiclass(btree,features->value[i],features->nclasses, + features->p_classes)) != features->class[i]){ + accuracy += 1.0; + } + } + break; + } + } + } + + accuracy /=features->nexamples; + accuracy = 1.0-accuracy; + + free(data_in_each_class); + return accuracy; +} + +void test_btree_reg(btree,features,file,misratio) + /* + test a btree model on a set of data + (features) and write the results into a file. To standard output + accuracy and error on each class + */ + BTree *btree; + Features *features; + char *file; + double *misratio; +{ + int i,j; + int *data_in_each_class; + FILE *fp; + int predI; + double predD; + double *error; + double accuracy; + + + fp = fopen(file, "w"); + if(fp == NULL){ + fprintf(stderr, "test_btree_reg-> Can't open file %s for writing", file); + exit(-1); + } + data_in_each_class=(int *)G_calloc(features->nclasses,sizeof(int)); + error=(double *)G_calloc(features->nclasses,sizeof(double)); + + accuracy = 0.0; + for(i=0;inexamples;i++){ + if ( features->examples_dim< 3){ /*if examples_dim is small it's printing the training feature on the outpu file*/ + for(j=0;jexamples_dim;j++){ + fprintf(fp,"%e\t",features->value[i][j]);}} + for(j=0;jnclasses;j++){ + if(features->class[i] == features->p_classes[j]){ + data_in_each_class[j] += 1; + if(features->nclasses==2){ + if((predD=predict_btree_2class(btree,features->value[i])) *features->class[i] <= 0){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%f",features->class[i],predD); + }else{ + if((predI=predict_btree_multiclass(btree,features->value[i],features->nclasses, + features->p_classes)) != features->class[i]){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%d",features->class[i],predI); + } + break; + } + } + fprintf(fp,"\t%e\n",misratio[i]); + } + + accuracy /= features->nexamples; + accuracy = 1.0-accuracy; + + fclose(fp); + + fprintf(stdout,"Accuracy: %f\n",accuracy); + fprintf(stdout,"Class\t%d",features->p_classes[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",features->p_classes[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Ndata\t%d",data_in_each_class[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",data_in_each_class[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Nerrors\t%d",(int)error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",(int)error[j]); + } + fprintf(stdout,"\n"); + + for(j=0;jnclasses;j++){ + error[j] /= data_in_each_class[j]; + } + + fprintf(stdout,"Perrors\t%f",error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%f",error[j]); + } + fprintf(stdout,"\n"); + free(data_in_each_class); + free(error); +} + +void shaving_and_compute(boosting,w,nsamples,nvar,data,data_class, + nclasses,classes, stamps,minsize,weights_boosting, + costs,misratio, reg_verbose,misclass_ratio, + outfile,modello,features,test_features,outfile1,testfile) + /* + compute btree model on the shaved trainng set, test and write into the output file the tree model + */ + + int boosting; + double w; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; + int stamps; + int minsize; + int weights_boosting; + double *costs; + double *misratio; + int reg_verbose; + double misclass_ratio; + char *outfile; + Features features; + char modello[150]; + Features test_features; + char *outfile1; + int testfile; +{ + BTree *btree; + int j,k,n,t; + double **xdata_training; + int *xclasses_training; + int ncampioni; + int vet,ind; + int *shaved; + int nshaved; + + fprintf(stdout,"-----------------------------------\n"); + + if(reg_verbose>0){ + fprintf (stdout,"Max misclassification ratio on the new training set(regularized boosting):%f\n",misclass_ratio); + fprintf(stdout,"-----------------------------------\n"); + } + + + xclasses_training=(int *) G_calloc(nsamples,sizeof(int)); + xdata_training=(double **) G_calloc(nsamples,sizeof(double *)); + for (k=0;k0){ + fprintf(stdout,"WARNING:the training set is too small\n");} + exit(1); } + else{ + if(reg_verbose>0){ + fprintf(stdout,"%d samples extracted \n",ncampioni); + } + for(j=0;j0){ + fprintf(stdout,"shaved %d samples :\n",nshaved); + for(t=0;ttree=(Tree *)G_calloc(bagging,sizeof(Tree)); + btree->ntrees=bagging; + btree->weights=(double *)G_calloc(btree->ntrees,sizeof(double)); + btree->w=-1.0; + + for(b=0;bntrees;b++){ + btree->weights[b]=1.0/btree->ntrees; + } + + prob=(double *)calloc(nsamples,sizeof(double)); + bsamples=(int *) G_calloc(nsamples,sizeof(int)); + xdata_training=(double **) G_calloc(nsamples,sizeof(double *)); + xclasses_training=(int *) G_calloc(nsamples,sizeof(int)); + + for(i=0;intrees;b++){ + Bootsamples(nsamples,prob,bsamples); + for(i =0;itree[b]),nsamples,nvar,xdata_training, + xclasses_training, nclasses,classes,stamps,minsize,costs); + } + + + free(bsamples); + free(xclasses_training); + free(prob); + free(xdata_training); +} + +void write_bagging_boosting_tree(file,btree,features) + /* + write a bagging or boosting tree model to a file + */ + char *file; + BTree *btree; + Features *features; +{ + int i,j; + FILE *fp; + char tempbuf[500]; + int b; + + fp = fopen(file, "w"); + if(fp == NULL){ + sprintf(tempbuf, "write_bagging_boosting_tree-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + write_header_features(fp,features); + fprintf(fp,"#####################\n"); + fprintf(fp,"MODEL:\n"); + fprintf(fp,"#####################\n"); + + fprintf(fp,"Model:\n"); + fprintf(fp,"B-ClassificationTree\n"); + fprintf(fp,"Cost parameter:\n"); + fprintf(fp,"%f\n",btree->w); + fprintf(fp,"Number of models:\n"); + fprintf(fp,"%d\n",btree->ntrees); + fprintf(fp,"Weights:\n"); + fprintf(fp,"%f",btree->weights[0]); + for(b=1;bntrees;b++){ + fprintf(fp,"\t%f",btree->weights[b]); + } + fprintf(fp,"\n"); + + for(b=0;bntrees;b++){ + fprintf(fp,"Number of nodes:\n"); + fprintf(fp,"%d\n",btree->tree[b].nnodes); + fprintf(fp,"Number of classes:\n"); + fprintf(fp,"%d\n",btree->tree[b].node[0].nclasses); + fprintf(fp,"Number of features:\n"); + fprintf(fp,"%d\n",btree->tree[b].node[0].nvar); + fprintf(fp,"Tree structure:\n"); + fprintf(fp,"terminal\tndata\t"); + for(j=0;jtree[b].node[0].nclasses;j++) + fprintf(fp,"data_cl%d\t",j+1); + for(j=0;jtree[b].node[0].nclasses;j++) + fprintf(fp,"prior_cl%d\t",j+1); + fprintf(fp,"class\tchild_left\tchild_right\tsplit_variable\tsplit_value\n"); + for(i=0;itree[b].nnodes;i++){ + fprintf(fp,"%d\t%d\t", btree->tree[b].node[i].terminal, + btree->tree[b].node[i].npoints); + for(j=0;jtree[b].node[i].nclasses;j++) + fprintf(fp,"%d\t",btree->tree[b].node[i].npoints_for_class[j]); + for(j=0;jtree[b].node[i].nclasses;j++) + fprintf(fp,"%f\t",btree->tree[b].node[i].priors[j]); + if(btree->tree[b].node[i].terminal) + fprintf(fp,"%d\n",btree->tree[b].node[i].class); + else + fprintf(fp,"%d\t%d\t%d\t%d\t%f\n",btree->tree[b].node[i].class, + btree->tree[b].node[i].left, + btree->tree[b].node[i].right,btree->tree[b].node[i].var, + btree->tree[b].node[i].value); + } + } + + + if(features->f_pca[0]){ + fprintf(fp,"#####################\n"); + fprintf(fp,"PRINC. COMP.:\n"); + fprintf(fp,"#####################\n"); + + fprintf(fp,"Number of pc:\n"); + fprintf(fp,"%d\n",features->npc); + + for(i=0;if_pca[1];i++){ + fprintf(fp,"PCA: Layer %d\n",i+1); + write_pca(fp,&(features->pca[i])); + } + } + fclose(fp); +} + +int predict_tree_multiclass(tree,x) + /* + multiclass problems: given a tree model, return the predicted class + of a test point x + */ + Tree *tree; + double *x; +{ + int act_node; + + act_node=0; + + for(;;){ + if(tree->node[act_node].terminal){ + return tree->node[act_node].class; + } + else{ + if(x[tree->node[act_node].var]<=tree->node[act_node].value) + act_node=tree->node[act_node].left; + else + act_node=tree->node[act_node].right; + } + } +} + +double predict_tree_2class(tree,x) + /* + 2 class problems: given a tree model, return the proportion of data + in the terminal node (with sign) of a test point x + */ + Tree *tree; + double *x; +{ + int act_node; + + act_node=0; + + for(;;){ + if(tree->node[act_node].terminal){ + if(tree->node[act_node].priors[0]>tree->node[act_node].priors[1]){ + return tree->node[act_node].priors[0]*tree->node[act_node].class; + }else{ + return tree->node[act_node].priors[1]*tree->node[act_node].class; + } + } + else{ + if(x[tree->node[act_node].var]<=tree->node[act_node].value) + act_node=tree->node[act_node].left; + else + act_node=tree->node[act_node].right; + } + } +} + +void test_tree(tree,features,file) + /* + test a tree model on a set of data (features) and write the results + into a file. To standard output accuracy and error on each class + */ + Tree *tree; + Features *features; + char *file; +{ + int i,j; + int *data_in_each_class; + FILE *fp; + char tempbuf[500]; + int predI; + double predD; + double *error; + double accuracy; + + + fp = fopen(file, "w"); + if(fp == NULL){ + sprintf(tempbuf, "test_tree-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + data_in_each_class=(int *)G_calloc(features->nclasses,sizeof(int)); + error=(double *)G_calloc(features->nclasses,sizeof(double)); + accuracy = 0.0; + for(i=0;inexamples;i++){ + for(j=0;jnclasses;j++){ + if(features->class[i] == features->p_classes[j]){ + data_in_each_class[j] += 1; + if(features->nclasses==2){ + if((predD=predict_tree_2class(tree,features->value[i])) * features->class[i] <= 0){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%f\n",features->class[i],predD); + }else{ + if((predI=predict_tree_multiclass(tree,features->value[i])) != features->class[i]){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%d\n",features->class[i],predI); + } + break; + } + } + } + + accuracy /= features->nexamples; + accuracy = 1.0-accuracy; + + fclose(fp); + + fprintf(stdout,"Accuracy: %f\n",accuracy); + fprintf(stdout,"Class\t%d",features->p_classes[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",features->p_classes[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Ndata\t%d",data_in_each_class[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",data_in_each_class[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Nerrors\t%d",(int)error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",(int)error[j]); + } + fprintf(stdout,"\n"); + + for(j=0;jnclasses;j++){ + error[j] /= data_in_each_class[j]; + } + + fprintf(stdout,"Perrors\t%f",error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%f",error[j]); + } + fprintf(stdout,"\n"); + free(data_in_each_class); + free(error); +} + +double predict_btree_2class(btree,x) + /* + for 2 classes problems: given a btree model, return the predicted + margin of a test point x + */ + BTree *btree; + double *x; +{ + int b; + double predict; + + predict = 0.0; + for(b=0;bntrees;b++){ + predict += predict_tree_multiclass(&(btree->tree[b]),x) * btree->weights[b]; + } + return predict; +} + +int predict_btree_multiclass(btree,x,nclasses,classes) + /* + for multiclasses problems: given a btree model, return the predicted + class of a test point x + */ + BTree *btree; + double *x; + int *classes; + int nclasses; +{ + int *predict; + int b,j; + int pred_class; + int max_class; + int max; + + predict=(int *)G_calloc(nclasses,sizeof(int)); + + for(b=0;bntrees;b++){ + pred_class=predict_tree_multiclass(&(btree->tree[b]),x); + for(j=0;jmax){ + max=predict[j]; + max_class=j; + } + } + + free(predict); + return classes[max_class]; +} + + +void test_btree(btree,features,file) + /* + test a btree model on a set of data + (features) and write the results into a file. To standard output + accuracy and error on each class + */ + BTree *btree; + Features *features; + char *file; +{ + int i,j; + int *data_in_each_class; + FILE *fp; + char tempbuf[500]; + int predI; + double predD; + double *error; + double accuracy; + + + fp = fopen(file, "w"); + if(fp == NULL){ + sprintf(tempbuf, "test_btree-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + data_in_each_class=(int *)G_calloc(features->nclasses,sizeof(int)); + error=(double *)G_calloc(features->nclasses,sizeof(double)); + + accuracy = 0.0; + for(i=0;inexamples;i++){ + for(j=0;jnclasses;j++){ + if(features->class[i] == features->p_classes[j]){ + data_in_each_class[j] += 1; + if(features->nclasses==2){ + if((predD=predict_btree_2class(btree,features->value[i])) *features->class[i] <= 0){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%f\n",features->class[i],predD); + }else{ + if((predI=predict_btree_multiclass(btree,features->value[i],features->nclasses, + features->p_classes)) != features->class[i]){ + error[j] += 1.0; + accuracy += 1.0; + } + fprintf(fp,"%d\t%d\n",features->class[i],predI); + } + break; + } + } + } + + accuracy /= features->nexamples; + accuracy = 1.0-accuracy; + + fclose(fp); + + fprintf(stdout,"Accuracy: %f\n",accuracy); + fprintf(stdout,"Class\t%d",features->p_classes[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",features->p_classes[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Ndata\t%d",data_in_each_class[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",data_in_each_class[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Nerrors\t%d",(int)error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",(int)error[j]); + } + fprintf(stdout,"\n"); + + for(j=0;jnclasses;j++){ + error[j] /= data_in_each_class[j]; + } + + fprintf(stdout,"Perrors\t%f",error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%f",error[j]); + } + fprintf(stdout,"\n"); + free(data_in_each_class); + free(error); +} + +void test_btree_progressive(btree,features,file) + /* + test a btree model on a set of data + (features) and write the results into a file. To standard output + accuracy and error on each class + */ + BTree *btree; + Features *features; + char *file; +{ + int i,j; + int *data_in_each_class; + FILE *fp; + char tempbuf[500]; + int predI; + double predD; + double *error; + double accuracy; + int b; + + fp = fopen(file, "w"); + if(fp == NULL){ + sprintf(tempbuf, "test_btree-> Can't open file %s for writing", file); + G_fatal_error(tempbuf); + } + + data_in_each_class=(int *)G_calloc(features->nclasses,sizeof(int)); + error=(double *)G_calloc(features->nclasses,sizeof(double)); + + for(b=1;b<=btree->ntrees;b++){ + if((b<100 &&b%2==1) || (b>=100) || (b==btree->ntrees)){ + /* + if((b<500 && b%10==0) || (b<5000 && b%100==0) || (b%1000==0)|| + (b==btree->ntrees)){ + */ + accuracy = 0.0; + for(j=0;jnclasses;j++){ + error[j]=.0; + data_in_each_class[j]=0; + } + for(i=0;inexamples;i++){ + for(j=0;jnclasses;j++){ + if(features->class[i] == features->p_classes[j]){ + data_in_each_class[j] += 1; + if(features->nclasses==2){ + if((predD= + predict_btree_2class_progressive(btree,features->value[i],b)) + *features->class[i] <= 0){ + error[j] += 1.0; + accuracy += 1.0; + } + if(b==btree->ntrees) + fprintf(fp,"%d\t%f\n",features->class[i],predD); + }else{ + if((predI= + predict_btree_multiclass_progressive(btree,features->value[i], + features->nclasses, + features->p_classes,b)) + != features->class[i]){ + error[j] += 1.0; + accuracy += 1.0; + } + if(b==btree->ntrees) + fprintf(fp,"%d\t%d\n",features->class[i],predI); + } + break; + } + } + } + accuracy /= features->nexamples; + accuracy = 1.0-accuracy; + + if(b==btree->ntrees) + fclose(fp); + + fprintf(stdout,"nmodels = %d\n",b); + fprintf(stdout,"Accuracy: %f\n",accuracy); + fprintf(stdout,"Class\t%d",features->p_classes[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",features->p_classes[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Ndata\t%d",data_in_each_class[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",data_in_each_class[j]); + } + fprintf(stdout,"\n"); + fprintf(stdout,"Nerrors\t%d",(int)error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%d",(int)error[j]); + } + fprintf(stdout,"\n"); + + for(j=0;jnclasses;j++){ + error[j] /= data_in_each_class[j]; + } + + fprintf(stdout,"Perrors\t%f",error[0]); + for(j=1;jnclasses;j++){ + fprintf(stdout,"\t%f",error[j]); + } + fprintf(stdout,"\n"); + fflush(stdout); + } + } + free(data_in_each_class); + free(error); +} + +double predict_btree_2class_progressive(btree,x,bmax) + /* + for 2 classes problems: given a btree model, return the predicted + margin of a test point x + */ + BTree *btree; + double *x; + int bmax; +{ + int b; + double predict; + + predict = 0.0; + for(b=0;btree[b]),x) * btree->weights[b]; + } + return predict; +} + +int predict_btree_multiclass_progressive(btree,x,nclasses,classes,bmax) + /* + for multiclasses problems: given a btree model, return the predicted + class of a test point x + */ + BTree *btree; + double *x; + int *classes; + int nclasses; + int bmax; +{ + int *predict; + int b,j; + int pred_class; + int max_class; + int max; + + predict=(int *)G_calloc(nclasses,sizeof(int)); + + for(b=0;btree[b]),x); + for(j=0;jmax){ + max=predict[j]; + max_class=j; + } + } + + free(predict); + return classes[max_class]; +} + + +void compute_tree_boosting_parallel(btree,boosting,parallel_boosting,w, + nsamples,nvar,data,data_class, + nclasses,classes, stamps,minsize, + weights_boosting, costs) + /* + receives in input training data of dimensions nsamples x nvar, + with class labels data_class, the possible classes (of length nclasses) + and computes a boosting tree model (number of models = boosting) using w + as parameter for the cost sensitive procedure; + optionally, the user can build stamps and decide the + minimal number of cases within a node as stopping criteria. + */ + BTree *btree; + int boosting; + int parallel_boosting; + double w; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; + int stamps; + int minsize; + int weights_boosting; + double *costs; +{ + int i,j,b; + int *bsamples; + double **xdata_training; + int *xclasses_training; + double *prob; + double e00,e01,e10,e11,prior0,prior1; + int *error; + double eps, totprob; + double totbeta; + double mean,variance,alpha,beta; + int idum=1; + + +#ifdef LEAVEOUTEASYPOINTS +#undef LEAVEOUTEASYPOINTS +#endif + + +#ifdef LEAVEOUTEASYPOINTS + int **correct; + + correct=(int **) G_calloc(nsamples,sizeof(int*)); + for(i=0;iw_evolution=(double**)G_calloc(nsamples,sizeof(double*)); + for(i=0;iw_evolution[i]=(double*)G_calloc(parallel_boosting+3,sizeof(double)); + + btree->tree=(Tree *)G_calloc(parallel_boosting,sizeof(Tree)); + btree->ntrees=parallel_boosting; + btree->weights=(double *)G_calloc(btree->ntrees,sizeof(double)); + btree->w = w; + + prob=(double *)calloc(nsamples,sizeof(double)); + bsamples=(int *) G_calloc(nsamples,sizeof(int)); + xdata_training=(double **) G_calloc(nsamples,sizeof(double *)); + xclasses_training=(int *) G_calloc(nsamples,sizeof(int)); + error=(int *) G_calloc(nsamples,sizeof(int)); + + for(i=0;iw_evolution[i][b]=prob[i]; + + Bootsamples(nsamples,prob,bsamples); + for(i=0;itree[b]),nsamples,nvar,xdata_training, + xclasses_training, nclasses,classes,stamps,minsize,costs); + + e00=e01=e10=e11=prior0=prior1=0.0; + for(i=0;itree[b]),data[i]) != + data_class[i]){ +#ifdef LEAVEOUTEASYPOINTS + correct[i][b] = FALSE; +#endif + error[i] = TRUE; + e01 += prob[i]; + }else{ +#ifdef LEAVEOUTEASYPOINTS + correct[i][b] = TRUE; +#endif + error[i] = FALSE; + e00 += prob[i]; + } + prior0 += prob[i]; + }else{ + if(predict_tree_multiclass(&(btree->tree[b]),data[i]) != + data_class[i]){ +#ifdef LEAVEOUTEASYPOINTS + correct[i][b] = FALSE; +#endif + error[i] = TRUE; + e10 += prob[i]; + }else{ +#ifdef LEAVEOUTEASYPOINTS + correct[i][b] = TRUE; +#endif + error[i] = FALSE; + e11 += prob[i]; + } + prior1 += prob[i]; + } + } + eps = (1.0 - e00 / (e00+e01)) * prior0 *btree->w + + (1.0 - e11 / (e10+e11)) * prior1 * (2.0 - btree->w); + if(eps > 0.0 && eps < 0.5){ + btree->weights[b] = 0.5 * log((1.0 - eps) / eps); + totprob=0.0; + for(i=0;iweights[b] * btree->w); + }else{ + prob[i] = prob[i]* exp(btree->weights[b] * (2.0-btree->w)); + } + }else{ + if(data_class[i] == classes[0]){ + prob[i] = prob[i] * exp(-btree->weights[b] * (2.0-btree->w)); + }else{ + prob[i] = prob[i] * exp(-btree->weights[b] * btree->w); + } + } + totprob += prob[i]; + } + for(i=0;iweights[b] = 0.0; + for(i=0;iw_evolution[i],boosting); + variance=var_of_double_array(btree->w_evolution[i],boosting); + alpha=mean*mean/variance; + beta=variance/mean; + + + for(j=boosting;jw_evolution[i][j]=gamdev(alpha,beta,&idum); + } + + for(b=boosting;bw_evolution[i][b]; + Bootsamples(nsamples,prob,bsamples); + for(i=0;itree[b]),nsamples,nvar,xdata_training, + xclasses_training, nclasses,classes,stamps,minsize,costs); + + e00=e01=e10=e11=prior0=prior1=0.0; + for(i=0;itree[b]),data[i]) != data_class[i]){ + error[i] = TRUE; + e01 += prob[i]; + }else{ + error[i] = FALSE; + e00 += prob[i]; + } + prior0 += prob[i]; + }else{ + if(predict_tree_multiclass(&(btree->tree[b]),data[i]) != data_class[i]){ + error[i] = TRUE; + e10 += prob[i]; + }else{ + error[i] = FALSE; + e11 += prob[i]; + } + prior1 += prob[i]; + } + } + eps = (1.0 - e00 / (e00+e01)) * prior0 *btree->w + + (1.0 - e11 / (e10+e11)) * prior1 * (2.0 - btree->w); + if(eps > 0.0 && eps < 0.5){ + btree->weights[b] = 0.5 * log((1.0 - eps) / eps); + totprob=0.0; + for(i=0;iweights[b] * btree->w); + }else{ + prob[i] = prob[i]* exp(btree->weights[b] * (2.0-btree->w)); + } + }else{ + if(data_class[i] == classes[0]){ + prob[i] = prob[i] * exp(-btree->weights[b] * (2.0-btree->w)); + }else{ + prob[i] = prob[i] * exp(-btree->weights[b] * btree->w); + } + } + totprob += prob[i]; + } + for(i=0;iweights[b] = 0.0; + for(i=0;intrees;b++){ + totbeta += btree->weights[b]; + } + for(b=0;bntrees;b++){ + btree->weights[b] /= totbeta; + } + + free(bsamples); + free(xclasses_training); + free(prob); + free(error); + free(xdata_training); + +} + + Property changes on: trunk/grassaddons/i.pr/PRLIB/tree.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/PRLIB/write_matrix.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/write_matrix.c (rev 0) +++ trunk/grassaddons/i.pr/PRLIB/write_matrix.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,26 @@ +#include "gis.h" +#include + +void write_matrix(outfile,matrix,r,c) + char *outfile; + double **matrix; + int r,c; +{ + FILE *fp; + int i,j; + char tempbuf[500]; + + fp=fopen(outfile,"w"); + if(fp == NULL){ + sprintf(tempbuf, "write_matrix-> Can't open file <%s> for writing", outfile); + G_fatal_error(tempbuf); + } + + for(i=0;i 32767 %%% do our best to avoid overflow + \then \divide \count 0 by 4 + \divide \count 4 by 4 + \else \ifnum \count 0 < -32767 + \then \divide \count 0 by 4 + \divide \count 4 by 4 + \else + \fi + \fi + \ifnum \count 2 > 32767 %%% while retaining reasonable accuracy + \then \divide \count 2 by 4 + \divide \count 4 by 4 + \else \ifnum \count 2 < -32767 + \then \divide \count 2 by 4 + \divide \count 4 by 4 + \else + \fi + \fi + \multiply \count 0 by \count 2 + \divide \count 0 by \count 4 + \xdef \product {#1 = \the \count 0 \internal@nits}% + \aftergroup \product + }} + +\def\r@duce{\ifdim\dimen0 > 90\r@dian \then % sin(x+90) = sin(180-x) + \multiply\dimen0 by -1 + \advance\dimen0 by 180\r@dian + \r@duce + \else \ifdim\dimen0 < -90\r@dian \then % sin(-x) = sin(360+x) + \advance\dimen0 by 360\r@dian + \r@duce + \fi + \fi} + +\def\Sine#1% + {{% + \dimen 0 = #1 \r@dian + \r@duce + \ifdim\dimen0 = -90\r@dian \then + \dimen4 = -1\r@dian + \c@mputefalse + \fi + \ifdim\dimen0 = 90\r@dian \then + \dimen4 = 1\r@dian + \c@mputefalse + \fi + \ifdim\dimen0 = 0\r@dian \then + \dimen4 = 0\r@dian + \c@mputefalse + \fi +% + \ifc@mpute \then + % convert degrees to radians + \divide\dimen0 by 180 + \dimen0=3.141592654\dimen0 +% + \dimen 2 = 3.1415926535897963\r@dian %%% a well-known constant + \divide\dimen 2 by 2 %%% we only deal with -pi/2 : pi/2 + \Mess@ge {Sin: calculating Sin of \nodimen 0}% + \count 0 = 1 %%% see power-series expansion for sine + \dimen 2 = 1 \r@dian %%% ditto + \dimen 4 = 0 \r@dian %%% ditto + \loop + \ifnum \dimen 2 = 0 %%% then we've done + \then \stillc@nvergingfalse + \else \stillc@nvergingtrue + \fi + \ifstillc@nverging %%% then calculate next term + \then \term {\count 0} {\dimen 0} {\dimen 2}% + \advance \count 0 by 2 + \count 2 = \count 0 + \divide \count 2 by 2 + \ifodd \count 2 %%% signs alternate + \then \advance \dimen 4 by \dimen 2 + \else \advance \dimen 4 by -\dimen 2 + \fi + \repeat + \fi + \xdef \sine {\nodimen 4}% + }} + +% Now the Cosine can be calculated easily by calling \Sine +\def\Cosine#1{\ifx\sine\UnDefined\edef\Savesine{\relax}\else + \edef\Savesine{\sine}\fi + {\dimen0=#1\r@dian\advance\dimen0 by 90\r@dian + \Sine{\nodimen 0} + \xdef\cosine{\sine} + \xdef\sine{\Savesine}}} +% end of trig stuff +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\psdraft{ + \def\@psdraft{0} + %\ps@typeout{draft level now is \@psdraft \space . } +} +\def\psfull{ + \def\@psdraft{100} + %\ps@typeout{draft level now is \@psdraft \space . } +} + +\psfull + +\newif\if@scalefirst +\def\psscalefirst{\@scalefirsttrue} +\def\psrotatefirst{\@scalefirstfalse} +\psrotatefirst + +\newif\if@draftbox +\def\psnodraftbox{ + \@draftboxfalse +} +\def\psdraftbox{ + \@draftboxtrue +} +\@draftboxtrue + +\newif\if@prologfile +\newif\if@postlogfile +\def\pssilent{ + \@noisyfalse +} +\def\psnoisy{ + \@noisytrue +} +\psnoisy +%%% These are for the option list. +%%% A specification of the form a = b maps to calling \@p@@sa{b} +\newif\if@bbllx +\newif\if@bblly +\newif\if@bburx +\newif\if@bbury +\newif\if@height +\newif\if@width +\newif\if@rheight +\newif\if@rwidth +\newif\if@angle +\newif\if@clip +\newif\if@verbose +\def\@p@@sclip#1{\@cliptrue} + + +\newif\if@decmpr + +%%% GDH 7/26/87 -- changed so that it first looks in the local directory, +%%% then in a specified global directory for the ps file. +%%% RPR 6/25/91 -- changed so that it defaults to user-supplied name if +%%% boundingbox info is specified, assuming graphic will be created by +%%% print time. +%%% TJD 10/19/91 -- added bbfile vs. file distinction, and @decmpr flag + +\def\@p@@sfigure#1{\def\@p@sfile{null}\def\@p@sbbfile{null} + \openin1=#1.bb + \ifeof1\closein1 + \openin1=\figurepath#1.bb + \ifeof1\closein1 + \openin1=#1 + \ifeof1\closein1% + \openin1=\figurepath#1 + \ifeof1 + \ps@typeout{Error, File #1 not found} + \if@bbllx\if@bblly + \if@bburx\if@bbury + \def\@p@sfile{#1}% + \def\@p@sbbfile{#1}% + \@decmprfalse + \fi\fi\fi\fi + \else\closein1 + \def\@p@sfile{\figurepath#1}% + \def\@p@sbbfile{\figurepath#1}% + \@decmprfalse + \fi% + \else\closein1% + \def\@p@sfile{#1} + \def\@p@sbbfile{#1} + \@decmprfalse + \fi + \else + \def\@p@sfile{\figurepath#1} + \def\@p@sbbfile{\figurepath#1.bb} + \@decmprtrue + \fi + \else + \def\@p@sfile{#1} + \def\@p@sbbfile{#1.bb} + \@decmprtrue + \fi} + +\def\@p@@sfile#1{\@p@@sfigure{#1}} + +\def\@p@@sbbllx#1{ + %\ps@typeout{bbllx is #1} + \@bbllxtrue + \dimen100=#1 + \edef\@p@sbbllx{\number\dimen100} +} +\def\@p@@sbblly#1{ + %\ps@typeout{bblly is #1} + \@bbllytrue + \dimen100=#1 + \edef\@p@sbblly{\number\dimen100} +} +\def\@p@@sbburx#1{ + %\ps@typeout{bburx is #1} + \@bburxtrue + \dimen100=#1 + \edef\@p@sbburx{\number\dimen100} +} +\def\@p@@sbbury#1{ + %\ps@typeout{bbury is #1} + \@bburytrue + \dimen100=#1 + \edef\@p@sbbury{\number\dimen100} +} +\def\@p@@sheight#1{ + \@heighttrue + \dimen100=#1 + \edef\@p@sheight{\number\dimen100} + %\ps@typeout{Height is \@p@sheight} +} +\def\@p@@swidth#1{ + %\ps@typeout{Width is #1} + \@widthtrue + \dimen100=#1 + \edef\@p@swidth{\number\dimen100} +} +\def\@p@@srheight#1{ + %\ps@typeout{Reserved height is #1} + \@rheighttrue + \dimen100=#1 + \edef\@p@srheight{\number\dimen100} +} +\def\@p@@srwidth#1{ + %\ps@typeout{Reserved width is #1} + \@rwidthtrue + \dimen100=#1 + \edef\@p@srwidth{\number\dimen100} +} +\def\@p@@sangle#1{ + %\ps@typeout{Rotation is #1} + \@angletrue +% \dimen100=#1 + \edef\@p@sangle{#1} %\number\dimen100} +} +\def\@p@@ssilent#1{ + \@verbosefalse +} +\def\@p@@sprolog#1{\@prologfiletrue\def\@prologfileval{#1}} +\def\@p@@spostlog#1{\@postlogfiletrue\def\@postlogfileval{#1}} +\def\@cs@name#1{\csname #1\endcsname} +\def\@setparms#1=#2,{\@cs@name{@p@@s#1}{#2}} +% +% initialize the defaults (size the size of the figure) +% +\def\ps@init@parms{ + \@bbllxfalse \@bbllyfalse + \@bburxfalse \@bburyfalse + \@heightfalse \@widthfalse + \@rheightfalse \@rwidthfalse + \def\@p@sbbllx{}\def\@p@sbblly{} + \def\@p@sbburx{}\def\@p@sbbury{} + \def\@p@sheight{}\def\@p@swidth{} + \def\@p@srheight{}\def\@p@srwidth{} + \def\@p@sangle{0} + \def\@p@sfile{} \def\@p@sbbfile{} + \def\@p@scost{10} + \def\@sc{} + \@prologfilefalse + \@postlogfilefalse + \@clipfalse + \if@noisy + \@verbosetrue + \else + \@verbosefalse + \fi +} +% +% Go through the options setting things up. +% +\def\parse@ps@parms#1{ + \@psdo\@psfiga:=#1\do + {\expandafter\@setparms\@psfiga,}} +% +% Compute bb height and width +% +\newif\ifno@bb +\def\bb@missing{ + \if@verbose{ + \ps@typeout{psfig: searching \@p@sbbfile \space for bounding box} + }\fi + \no@bbtrue + \epsf@getbb{\@p@sbbfile} + \ifno@bb \else \bb@cull\epsf@llx\epsf@lly\epsf@urx\epsf@ury\fi +} +\def\bb@cull#1#2#3#4{ + \dimen100=#1 bp\edef\@p@sbbllx{\number\dimen100} + \dimen100=#2 bp\edef\@p@sbblly{\number\dimen100} + \dimen100=#3 bp\edef\@p@sbburx{\number\dimen100} + \dimen100=#4 bp\edef\@p@sbbury{\number\dimen100} + \no@bbfalse +} +% rotate point (#1,#2) about (0,0). +% The sine and cosine of the angle are already stored in \sine and +% \cosine. The result is placed in (\p@intvaluex, \p@intvaluey). +\newdimen\p@intvaluex +\newdimen\p@intvaluey +\def\rotate@#1#2{{\dimen0=#1 sp\dimen1=#2 sp +% calculate x' = x \cos\theta - y \sin\theta + \global\p@intvaluex=\cosine\dimen0 + \dimen3=\sine\dimen1 + \global\advance\p@intvaluex by -\dimen3 +% calculate y' = x \sin\theta + y \cos\theta + \global\p@intvaluey=\sine\dimen0 + \dimen3=\cosine\dimen1 + \global\advance\p@intvaluey by \dimen3 + }} +\def\compute@bb{ + \no@bbfalse + \if@bbllx \else \no@bbtrue \fi + \if@bblly \else \no@bbtrue \fi + \if@bburx \else \no@bbtrue \fi + \if@bbury \else \no@bbtrue \fi + \ifno@bb \bb@missing \fi + \ifno@bb \ps@typeout{FATAL ERROR: no bb supplied or found} + \no-bb-error + \fi + % +%\ps@typeout{BB: \@p@sbbllx, \@p@sbblly, \@p@sbburx, \@p@sbbury} +% +% store height/width of original (unrotated) bounding box + \count203=\@p@sbburx + \count204=\@p@sbbury + \advance\count203 by -\@p@sbbllx + \advance\count204 by -\@p@sbblly + \edef\ps@bbw{\number\count203} + \edef\ps@bbh{\number\count204} + %\ps@typeout{ psbbh = \ps@bbh, psbbw = \ps@bbw } + \if@angle + \Sine{\@p@sangle}\Cosine{\@p@sangle} + {\dimen100=\maxdimen\xdef\r@p@sbbllx{\number\dimen100} + \xdef\r@p@sbblly{\number\dimen100} + \xdef\r@p@sbburx{-\number\dimen100} + \xdef\r@p@sbbury{-\number\dimen100}} +% +% Need to rotate all four points and take the X-Y extremes of the new +% points as the new bounding box. + \def\minmaxtest{ + \ifnum\number\p@intvaluex<\r@p@sbbllx + \xdef\r@p@sbbllx{\number\p@intvaluex}\fi + \ifnum\number\p@intvaluex>\r@p@sbburx + \xdef\r@p@sbburx{\number\p@intvaluex}\fi + \ifnum\number\p@intvaluey<\r@p@sbblly + \xdef\r@p@sbblly{\number\p@intvaluey}\fi + \ifnum\number\p@intvaluey>\r@p@sbbury + \xdef\r@p@sbbury{\number\p@intvaluey}\fi + } +% lower left + \rotate@{\@p@sbbllx}{\@p@sbblly} + \minmaxtest +% upper left + \rotate@{\@p@sbbllx}{\@p@sbbury} + \minmaxtest +% lower right + \rotate@{\@p@sbburx}{\@p@sbblly} + \minmaxtest +% upper right + \rotate@{\@p@sbburx}{\@p@sbbury} + \minmaxtest + \edef\@p@sbbllx{\r@p@sbbllx}\edef\@p@sbblly{\r@p@sbblly} + \edef\@p@sbburx{\r@p@sbburx}\edef\@p@sbbury{\r@p@sbbury} +%\ps@typeout{rotated BB: \r@p@sbbllx, \r@p@sbblly, \r@p@sbburx, \r@p@sbbury} + \fi + \count203=\@p@sbburx + \count204=\@p@sbbury + \advance\count203 by -\@p@sbbllx + \advance\count204 by -\@p@sbblly + \edef\@bbw{\number\count203} + \edef\@bbh{\number\count204} + %\ps@typeout{ bbh = \@bbh, bbw = \@bbw } +} +% +% \in@hundreds performs #1 * (#2 / #3) correct to the hundreds, +% then leaves the result in @result +% +\def\in@hundreds#1#2#3{\count240=#2 \count241=#3 + \count100=\count240 % 100 is first digit #2/#3 + \divide\count100 by \count241 + \count101=\count100 + \multiply\count101 by \count241 + \advance\count240 by -\count101 + \multiply\count240 by 10 + \count101=\count240 %101 is second digit of #2/#3 + \divide\count101 by \count241 + \count102=\count101 + \multiply\count102 by \count241 + \advance\count240 by -\count102 + \multiply\count240 by 10 + \count102=\count240 % 102 is the third digit + \divide\count102 by \count241 + \count200=#1\count205=0 + \count201=\count200 + \multiply\count201 by \count100 + \advance\count205 by \count201 + \count201=\count200 + \divide\count201 by 10 + \multiply\count201 by \count101 + \advance\count205 by \count201 + % + \count201=\count200 + \divide\count201 by 100 + \multiply\count201 by \count102 + \advance\count205 by \count201 + % + \edef\@result{\number\count205} +} +\def\compute@wfromh{ + % computing : width = height * (bbw / bbh) + \in@hundreds{\@p@sheight}{\@bbw}{\@bbh} + %\ps@typeout{ \@p@sheight * \@bbw / \@bbh, = \@result } + \edef\@p@swidth{\@result} + %\ps@typeout{w from h: width is \@p@swidth} +} +\def\compute@hfromw{ + % computing : height = width * (bbh / bbw) + \in@hundreds{\@p@swidth}{\@bbh}{\@bbw} + %\ps@typeout{ \@p@swidth * \@bbh / \@bbw = \@result } + \edef\@p@sheight{\@result} + %\ps@typeout{h from w : height is \@p@sheight} +} +\def\compute@handw{ + \if@height + \if@width + \else + \compute@wfromh + \fi + \else + \if@width + \compute@hfromw + \else + \edef\@p@sheight{\@bbh} + \edef\@p@swidth{\@bbw} + \fi + \fi +} +\def\compute@resv{ + \if@rheight \else \edef\@p@srheight{\@p@sheight} \fi + \if@rwidth \else \edef\@p@srwidth{\@p@swidth} \fi + %\ps@typeout{rheight = \@p@srheight, rwidth = \@p@srwidth} +} +% +% Compute any missing values +\def\compute@sizes{ + \compute@bb + \if@scalefirst\if@angle +% at this point the bounding box has been adjsuted correctly for +% rotation. PSFIG does all of its scaling using \@bbh and \@bbw. If +% a width= or height= was specified along with \psscalefirst, then the +% width=/height= value needs to be adjusted to match the new (rotated) +% bounding box size (specifed in \@bbw and \@bbh). +% \ps@bbw width= +% ------- = ---------- +% \@bbw new width= +% so `new width=' = (width= * \@bbw) / \ps@bbw; where \ps@bbw is the +% width of the original (unrotated) bounding box. + \if@width + \in@hundreds{\@p@swidth}{\@bbw}{\ps@bbw} + \edef\@p@swidth{\@result} + \fi + \if@height + \in@hundreds{\@p@sheight}{\@bbh}{\ps@bbh} + \edef\@p@sheight{\@result} + \fi + \fi\fi + \compute@handw + \compute@resv} + +% +% \psfig +% usage : \psfig{file=, height=, width=, bbllx=, bblly=, bburx=, bbury=, +% rheight=, rwidth=, clip=} +% +% "clip=" is a switch and takes no value, but the `=' must be present. +\def\psfig#1{\vbox { + % do a zero width hard space so that a single + % \psfig in a centering enviornment will behave nicely + %{\setbox0=\hbox{\ }\ \hskip-\wd0} + % + \ps@init@parms + \parse@ps@parms{#1} + \compute@sizes + % + \ifnum\@p@scost<\@psdraft{ + % + \special{ps::[begin] \@p@swidth \space \@p@sheight \space + \@p@sbbllx \space \@p@sbblly \space + \@p@sbburx \space \@p@sbbury \space + startTexFig \space } + \if@angle + \special {ps:: \@p@sangle \space rotate \space} + \fi + \if@clip{ + \if@verbose{ + \ps@typeout{(clip)} + }\fi + \special{ps:: doclip \space } + }\fi + \if@prologfile + \special{ps: plotfile \@prologfileval \space } \fi + \if@decmpr{ + \if@verbose{ + \ps@typeout{psfig: including \@p@sfile.Z \space } + }\fi + \special{ps: plotfile "`zcat \@p@sfile.Z" \space } + }\else{ + \if@verbose{ + \ps@typeout{psfig: including \@p@sfile \space } + }\fi + \special{ps: plotfile \@p@sfile \space } + }\fi + \if@postlogfile + \special{ps: plotfile \@postlogfileval \space } \fi + \special{ps::[end] endTexFig \space } + % Create the vbox to reserve the space for the figure. + \vbox to \@p@srheight sp{ + % 1/92 TJD Changed from "true sp" to "sp" for magnification. + \hbox to \@p@srwidth sp{ + \hss + } + \vss + } + }\else{ + % draft figure, just reserve the space and print the + % path name. + \if@draftbox{ + % Verbose draft: print file name in box + \hbox{\frame{\vbox to \@p@srheight sp{ + \vss + \hbox to \@p@srwidth sp{ \hss \@p@sfile \hss } + \vss + }}} + }\else{ + % Non-verbose draft + \vbox to \@p@srheight sp{ + \vss + \hbox to \@p@srwidth sp{\hss} + \vss + } + }\fi + + + + }\fi +}} +\psfigRestoreAt +\let\@=\LaTeXAtSign + + + Added: trunk/grassaddons/i.pr/doc/usage.tex =================================================================== --- trunk/grassaddons/i.pr/doc/usage.tex (rev 0) +++ trunk/grassaddons/i.pr/doc/usage.tex 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,608 @@ +\documentstyle[psfig,times]{article} + +\begin{document} +\begin{center} + {\Large\em L'ambiente PR (Pattern Recognition)} +\end{center} +\vspace{1truecm} +\noindent + +\section{i.pr\_training} +Interfaccia grafica per estrazione di dati di training da mappe raster +GRASS. Data una lista di mappe (parametro map), di cui la prima +verr\`{a} utilizzata per visualizzazione se non \`{e} settato il +parametro vis\_map, l'utente cliccando sulla mappa selezioner\`{a} +esempi di training che avranno dimensione rows $\times$ cols +(parametri rows e cols rispettivamente). Gli esempi selezionati +saranno assegnati alla classe scelta in input dall'utente (parametro +class) che dovr\`{a} essere un intero positivo progressivo. Una +procedura alternativa (e non grafica) \`{e} quella di dare in input al +programma un file di siti GRASS (parametro site\_file) e il programma +creer\`{a} gli esempi di training in corrispondenza dei siti stessi. +La classe assegnata agli esempi sar\`{a} quella definita nel file di +siti. L'output del programma \`{e} una serie di mappe raster di +dimensione rows $\times$ cols il cui nome sar\`{a} del tipo {\em x\_y.z} +dove {\em y} \`{e} il nome della mappe raster da cui \`{e} stata estratta, +{\em z} un contatore mentre {\em x} sar\`{a} il nome di un file che +verr\`{a} creato (parametro training) e che sar\`{a} come quello generato +dalle seguenti chiamate: + +ESEMPIO: i.pr\_training map=ammcom,genesi rows=11 cols=11 training=AAA class=1 + +ESEMPIO: i.pr\_training map=ammcom,genesi rows=11 cols=11 training=AAA class=2 + +FILE: AAA + +\noindent +\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# +\begin{verbatim} +Data type: +GrassTraining +Number of layers: +2 +Label: +AAA +Data: +Layer_1 Layer_2 Class East North Rows Cols EW-res NS-res +AAA_ammcom.1 AAA_genesi.1 1 1657029 5072830 11 11 1.5 1.5 +AAA_ammcom.2 AAA_genesi.2 1 1657072 5072864 11 11 1.5 1.5 +AAA_ammcom.3 AAA_genesi.3 2 1657123 5072871 11 11 1.5 1.5 +AAA_ammcom.4 AAA_genesi.4 2 1657153 5072910 11 11 1.5 1.5 +\end{verbatim} +\noindent +\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# + +\subsection*{Help} +\begin{verbatim} +Usage: + i.pr_training map=name[,name,...] [vis_map=name] training=name + [site_file=name] rows=value cols=value [class=value] + +Parameters: + map Input raster maps (max 25) for extracting the training + examples. + The first one will be used for graphical output + in case vis_map option not set + vis_map Raster map for visualization. + training Name of the output file containing the training raster + maps. + If this file already exists, the new data will + be appended to the end of the file. + site_file Name of the site file containing labelled location. + Substitutes the interactive procedure of site selection. + rows Number of rows (required odd) of the training samples. + cols Number of columns (required odd) of the training samples. + class Numerical label to be attached to the training examples. + Option not required with the site_file option. +\end{verbatim} + +\section{i.pr\_features} +Processa dati di training ed estrae features. Dato un file di training +in ingresso (paretro training) e che contiene il nome di mappe raster +relative a layers differenti permette eleborare di normalizzare le +mappa dei layers selezionati (parametro normalize) di calcolarne la +media (parametro mean), la varianza (parametro variance). Inoltre per +ogni layer selezionato permette di calcolare la componenti principali +(parametro prin\_comp); il modello di componenti principali pu\`{o} +essere calcolato su tutti i dati (default) oppure solo sui dati delle +classi selezionate (parametro class\_pc). Inoltre permette di +standardizzare le features estratte (parametro standardize); questo +parametro non \`{e} collegato al numero di layers contenuti nel file di +training ma \`{e} collegato al numero di features precedentemente +calcolate. L'output del programma \`{e} un file (parametro features) come quello generato dalla seguente chiamata: + +ESEMPIO: i.pr\_features training=AAA features=BBB normalize=1 mean=1,2 + +FILE BBB: + +\noindent +\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# +\begin{verbatim} +##################### +TRAINING: (AAA) +##################### +Type of data: +1 +Number of layers: +2 +Training dimensions: +11 11 +EW-res NS-res +1.5 1.5 +##################### +FEATURES: +##################### +normalize: +1 1 1 +standardize: +0 +mean: +1 2 1 2 +variance: +0 +pca: +0 +Number of classes: +2 +Classes: +1 2 +Standardization values: +NULL +NULL +Features dimensions: +4 2 +Features: +l1_mean l2_mean class +1.000000 5.000000 1 +1.000000 5.000000 1 +1.000000 5.000000 2 +1.000000 5.000000 2 +\end{verbatim} +\noindent +\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# + +\noindent +Se nessuna opearazione viene selezionata, le features estratte saranno i dati stessi. + +\noindent +Il programma i.pr\_features permette di eseguire le stesse operazione +su dati non GRASS, ovvero su una tabella di dati. Il formato dei dati +deve essere come il seguente: + +FILE AAA: + +\noindent +\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# +\begin{verbatim} +Data type: +TableTraining +Dimension: +2 +Data: +6.5 0. 1 +-6.5 -0. -1 +6.3 1.2 1 +-6.3 -1.2 -1 +5.8 2.4 1 +-5.8 -2.4 -1 +\end{verbatim} +\noindent +\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# + +\noindent +In questo caso i dati sono interpretati come singolo layer (quindi ad esempio se si setta mean=1, la feature estratta sar\`{a} la media dei dati). + +\noindent +L'output sar\`{a} come il seguente: + +ESEMPIO: i.pr\_features training=AAA features=BBB mean=1 + +FILE: BBB + +\noindent +\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# +\begin{verbatim} + +##################### +TRAINING: (AAA) +##################### +Type of data: +2 +Number of layers: +1 +Training dimensions: +1 2 +EW-res NS-res +0.000000 0.000000 +##################### +FEATURES: +##################### +normalize: +0 +standardize: +0 +mean: +1 1 1 +variance: +0 +pca: +0 +Number of classes: +2 +Classes: +1 -1 +Standardization values: +NULL +NULL +Features dimensions: +6 1 +Features: +l1_mean class +3.250000 1 +-3.250000 -1 +3.784850 1 +-3.784850 -1 +4.164670 1 +-4.164670 -1 +\end{verbatim} +\noindent +\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# + +\subsection*{Help} +\begin{verbatim} +Usage: + i.pr_features [-s] training=name[,name,...] features=name + [normalize=value[,value,...]] [mean=value[,value,...]] + [variance=value[,value,...]] [prin_comp=value[,value,...]] + [class_pc=value[,value,...]] [standardize=value[,value,...]] + +Flags: + -s Print site file containing coordinates of examples and class labels + (from training data) into features option and exit. + +Parameters: + training Input files (max 50) containing training data. + 2 formats are currently supported: + 1) GRASS_data (output of i.pr_training) + 2) TABLE_data. + features Name of the output file containing the features. + normalize Numbers of the layers to be normalized. + mean Numbers of the layers on which to compute the mean value. + variance Numbers of the layers on which to compute the variance. + prin_comp Numbers of the layers on which to compute the principal + components. + class_pc Classes of the data to be used for computing the + principal components. + If not set, all the examples will be used. + standardize Numbers of features to be standardize. + WARNING: not related to the number of layers. +\end{verbatim} + +\section{i.pr\_statistics} +Calcola statistiche sulle features. Dato un file di features in input +(parametro features), calcola kolgomorov-smirnov test e t\-test per +ogni classe di ogni features. Se nelle features sono presenti +componenti principali, calcola la varianza spiegata da esse. Se ci +sono pi\`{u} modelli di componenti principali (per pi\`{u} layers), +l'analisi viene eseguita solo su un layer (parametro layer). Il +parametro npc serve per limitare l'analissi alle prime npc componenti +princiapli. + +\begin{verbatim} +Usage: + i.pr_statistics features=name [layer=value] [npc=value] + +Parameters: + features Input file containing the features (output of i.pr_features). + layer Number of the layer to be analized (concerning with the + principal components). + Ignored if features does not contain principal + components model. + default: 1 + npc Number of principal components to be analized. + If this number is greater then the dimension of the data, + all the principal components will be considered. + Ignored if features does not contain principal + components model. +\end{verbatim} + +\section{i.pr\_model} +Crea modello di classificazione a partire da file di features. Il tipo +di modello creato viene scelto settando uno dei flag g (gaussian mixture) n (nearest +neighbor) t (classification trees) s (support vector machines). Ci +sono poi dei parametri generali come il file delle features (parametro +features), il nome del file prodotto e contenente il modello +(parametro model), il nome di un file di features addizioanle sul +quale calcolare dei valori di predizione durante la fase di training +(parametro validation), il nome di un file di features addizioanle sul +quale calcolare dei valori di predizione oltre al training set +(parametro test) e il numero di componenti principali da utilizzare +nel modello (parametro npc) se queste sono presenti nelle features. +Poi ci sono parametri modello specifici. Nessuno per la gaussian +mixture. Il numero di neighbors per nearest neighbor (parametro +nn\_k), anche se questo parametro serve solo per la valutazione del +modello in quando il modello di per s\`{e} sono i dati stessi. Per i +classification trees si pu\`{o} decidere se fare alberi ad un solo +nodo (stamps) o no (parametro tree\_stamps), oppure decidere quanti +dati deve contenere almeno un nodo per essere splittato (parametro +tree\_minsize). Inoltre il parametro tree\_costs permette di +sbilanciare le classi (stile rpart). Per le support vector machines +l'utente deve settare il tipo di kernel (parametro svm\_kernel, che +pu\'o assumere i valori linear gaussian e 2pbk), l'ampiezza del kernel +in caso sia gaussiano (parametro (svm\_kp), il parametro di +regolarizzazione (svm\_C), i parametri di convergenza svm\_eps, +svm\_tolerance e svm\_maxloops. Si suggereisce di non modificare i +primi due mentre il numero massimo di loop di ottimizazione pu\`{o} +essere modificato (sempre con cura). Per le support vector machines si +pu\`{o} decidere di calcolare una stima del leave-one-out model error +utilizzando il paramtro svm\_l1o. L'output della procedura \`{e} un +file che contiene il modello selezionato. A standard output verranno +descritte le prestazioni del modello sul training set e opzionalmente +su un test set. Per le support vector machines opzionalmente anche una +stima di cross-validation. Per i modelli classification trees e +support vecor machines sono disponibili anche combinazioni di modelli +(bagging e boosting). Il numero di modelli \`{e} scelto dall'utente +(parametri bagging e boosting rispettivamente). Per il boosting \`{e} +disponibile anche la versione cost-sensitive, il cui parametro \`{e} +cost\_boosting. Se si usa boosting, \'e possibile ottenere la dinamica +dei pesi boosting utilizzando il parametro weights\_boosting. Sempre +per boosting di trees \`e possibile sviluppare (il tutto \'e +sperimentale) la versione soft del modello con il parametro +soft\_margin\_boosting. Una versione cost-sensitive per la support +vector machine singola \`e ottenibile utilizzando il parametro +svm\_cost. +\`E possibile inoltre utilizzare una versione regolarizzata dell'algoritmo +AdaBoost specificando il numero di intervalli (parametro reg) in cui +suddividere il misclassification ratio (quindi il numero di +training set generati), in questo caso il validation set \`e indispnsabile, in +alternativa \`e possibile scegliere manualmente il valore di misclassification +ratio al disopra del quale i campioni vengono eliminati dal training set +(parametro misclass\_ratio). +Per alcuni modelli sono implementate solo classificazione +binarie in accordo al seguente prospetto: + +\noindent +gaussian mixture: multiclasse + +\noindent +nearest neighbor: multiclasse + +\noindent +classification trees: multiclasse + +\noindent +support vector machines: binaria + +\noindent +bagging classification trees: multiclasse + +\noindent +boosting classification trees: binaria + +\noindent +bagging support vector machines: binaria + +\noindent +boosting support vector machines: binaria + +\subsection*{Help} +\begin{verbatim} +Usage: + i.pr_model [-gtsn] features=name model=name [validation=name] + [test=name] [npc=value] [bagging=value] [boosting=value] [reg=value] + [misclass_ratio=value] [reg_verbose=value] [progressive_error=value] + [cost_boosting=value] [weights_boosting=value] [parallel_boosting=value] + [soft_margin_boosting=value] [tree_stamps=value] [tree_minsize=value] + [tree_costs=value[,value,...]] [svm_kernel=name] [svm_kp=value] + [svm_C=value] [svm_cost=value] [svm_tol=value] [svm_eps=value] + [svm_l1o=value] [svm_maxloops=value] [svm_verbose=value] [nn_k=value] + +Flags: + -g selected model: gaussian mixture. + -t selected model: classification trees. + -s selected model: support vector machines. + -n selected model: nearest neighbor. + +Parameters: + features Input file containing the features + (output of i.pr_features). + model Name of the output file containing the model. + validation Input file containing other features for the + training and for the evaluation of the performances + of the model on an independent test set + (for regularized AdaBoost). + test Input file containing other features for the + evaluation of the performances of the model + on an independent test set. + npc Number of the principal components to be used + for the model development. + If not set all the principal components + will be used. + Ignored if features does not contain + principal components model. + bagging Number of bagging models. + If bagging = 0 the classical model will + be implemented. + Implemented for trees and svm only. + default: 0 + boosting Number of boosting models. + If boosting = 0 the classical model will + be implemented. + Implemented for trees and svm only. + default: 0 + reg Number of misclassification ratio intervals. + default: 0 + misclass_ratio For regularized AdaBoost: misclassification ratio + for hard point shaving and compute the new model. + default: 1.00 + reg_verbose For regularized AdaBoost: + - if it is set = 1 the current value of + misclassification ratio and the current + error will be printed. + - if it is set to >1 the number of + loops, accuracy and the current value of + misclassification ratio will be printed. + For shaving and compute: + - if it is set >0 the numbers of samples + shaved will be printed. + default: 0 + progressive_error Progressive estimate of the model error + increasing the number of aggregated models + options: 0,1 + default: 0 + cost_boosting Cost parameter for the implementation of + cost-sensitive procedure(w in [0,2]). + w>1 results higher weight on examples of class 1. + w<1 results higher weight on examples of class -1. + w=1 corresponds to standard Adaboost. + default: 1.0 + weights_boosting For boosting: if weights_boosting = 1, a file + containing the evolution of the weights associated + to data points will be produced. + options: 0,1 + default: 0 + parallel_boosting For boosting: number of true boosting steps for + parallel boosting. + Implemented only for trees!! + default: 0 + soft_margin_boosting For boosting: if soft_margin_boosting = 1, + sof margin of Ababoost will bee used. + Implemented only with trees. (Sperimental!!!!!!!!) + options: 0,1 + default: 0 + tree_stamps For trees: if tree_stamps = 1, a single split + tree will be procuded, if tree_stamps = 0, + a classical tree will be procuded. + options: 0,1 + default: 0 + tree_minsize For trees: minimum number of examples containined + into a node for splitting the node itself + default: 0 + tree_costs For trees: misclassification costs for each class + svm_kernel For svm: type of employed kernel. + options: gaussian,linear,2pbk + default: linear + svm_kp For svm: kernel parameter (Required parameter if + you are using gaussian kernel). + svm_C For svm: optimization parameter (Required parameter). + svm_cost Cost parameter for the implementation of + cost-sensitive procedure(w in [-1,1]). + w>0 results higher weight on examples of class 1. + w<0 results higher weight on examples of class -1. + w=0 corresponds to standard SVM. + Not yet implemented (and may be it will be + never implemented) for bagging and boosting. + default: 0.0 + svm_tol For svm: tollerance parameter. + default: 0.001 + svm_eps For svm: epsilon. + default: 0.001 + svm_l1o For svm: leave 1 out error estimate. + options: 0,1 + default: 0 + svm_maxloops For svm: maximum number of optimization steps. + default: 1000 + svm_verbose For svm: if it is set to 1 the number of loops will + be printed. + options: 0,1 + default: 0 + nn_k For nn: Number of neighbor to be considered during + the test phase. + default: 1 +\end{verbatim} + + +\section*{i.pr\_classify} +Classifica mappe raster GRASS sulla base di un modello di +classificazione. Dato un numero di mappe raster GRASS in input +(parametr input\_map) in cui l'ordine deve essere lo stesso utilizzato +per l'estrazione di dati di training(!!!!), ed un modello di +classificazione (parametro model), viene prodotta una mappa raster +GRASS contenente il risultato della classifcazione. + +Valori della mappa per tipo di modello: + +\noindent +gaussian mixture binaria: probabilit\`{a} a posteriori della classe pi\`{u} probabile moltiplicata per la classe stessa $\{-1,1\}$ + +\noindent +gaussian mixture multiclasse: classe pi\`{u} probabile + +\noindent +nearest neighbor binaria: proporzione di dati della classe pi\`{u} probabile moltiplicata per la classe stessa $\{-1,1\}$ + +\noindent +nearest neighbor multiclasse: classe pi\`{u} probabile + +\noindent +classification trees binaria: proporzione di dati della classe pi\`{u} probabile nel nodo terminale moltiplicata per la classe stessa $\{-1,1\}$ + +\noindent +classification trees multiclasse: classe pi\`{u} probabile + +\noindent +support vector machines binaria: output della support vector machine stessa $(-\infty,\infty)$ + +\noindent +bagging classification trees multiclasse: classe pi\`{u} probabile + +\noindent +bagging classification trees binaria: somma pesata di modelli $(-1,1)$ + +\noindent +boosting classification trees (solo binaria): somma pesata di modelli $(-1,1)$ + +\noindent +bagging support vector machines (solo binaria): somma pesata di modelli $(-1,1)$ + +\noindent +boosting support vector machines(solo binaria) : somma pesata di modelli $(-1,1)$ + +\subsection*{Help} +\begin{verbatim} +Usage: + i.pr_classify input_map=name[,name,...] model=name output_map=name + +Parameters: + input_map Input raster maps to be classified. + It is required a number of maps at least equal to the number + of maps used for the training. If this number is greater + the last maps will be ignored. + WARNING: the order in which the maps are given should + be compared with that used for the training. + model Input file containing the model (output of i .pr_model). + If the data used for model development are not GRASS_data + the program will abort. + output_map Name of the output raster map conaining the resulting + classification. +\end{verbatim} + + +\section*{i.pr\_subsets} +Crea features file per esperimenti a partire da un file di features +(opzione features) implementando cross-validation (flag c) o bootstrap +resampling (flag b). L'opzione n\_sets setta il numero di bootstap +subsets o il numero di folder per cross-validation. L'opzione seed permette di creare insiemi differenti. + +\subsection*{Help} +\begin{verbatim} +Usage: + i.pr_subsets [-cb] features=name n_sets=value seed=value + +Flags: + -c selected method: cross-validation. + -b selected method: bootstrap. + +Parameters: + features Input file containing the features (output of i.pr_features). + n_sets Number of subsets (>=1). If you set n_sets=1 and select + cross-validation, leave one out cv will be implemented. + seed Seed for the initialization (>=0), which specifies a + starting point for the random number sequence. Replicate + same experiment. + default: 0 +\end{verbatim} + +\section*{i.pr\_features\_additional} +Dato un file di features (opzione features) applica le regole che +hanno creato quelle features a una lista di training files (opzione +training) e crea da questi un nuovo file di features (opzione +features\_out). + +\subsection*{Help} +\begin{verbatim} +Usage: + i.pr_features_additional training=name[,name,...] features=name + features_out=name + +Parameters: + training Input files (max 50) containing training data. + 2 formats are currently supported: + 1) GRASS_data (output of i.pr_training) + 2) TABLE_data. + features Name of the input file containing the features. + features_out Name of the output file containing the features. +\end{verbatim} +\end{document} + + Added: trunk/grassaddons/i.pr/i.pr_blob/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_blob/Makefile (rev 0) +++ trunk/grassaddons/i.pr/i.pr_blob/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,14 @@ +MODULE_TOPDIR = ../../.. + +PRINCLUDE = ../include/ +EXTRA_CFLAGS = -I$(PRINCLUDE) +PRLIB = -lgrass_pr + +PGM = i.pr_blob + +LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) +DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) + +include $(MODULE_TOPDIR)/include/Make/Module.make + +default: cmd Property changes on: trunk/grassaddons/i.pr/i.pr_blob/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_blob/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_blob/main.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_blob/main.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,132 @@ +#include "gis.h" +#include "global.h" +#include +#include +#include + + + +int main(argc,argv) +int argc; +char *argv[]; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + struct Option *opt4; + struct Option *opt5; + char tempbuf[500]; + char *mapset; + struct Cell_head cellhd; + double **matrix ; + DCELL *rowbuf; + DCELL *tf; + int fd; + double minv,maxv; + int minp,maxp; + int i,j; + Blob *blobs; + int nblobs,npoints; + BlobSites *sites; + + + + char gisrc[500]; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + "/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1); + if(getenv("GISRC")==NULL){ + sprintf(gisrc,"/ssi0/ssi/%s/.grassrc5",getenv("LOGNAME")); + setenv("GISRC",gisrc,1); + } + + /* Define the different options */ + + opt1 = G_define_option(); + opt1->key = "input_map"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->gisprompt = "old,cell,raster" ; + opt1->description = "Input raster map for searching for blobs."; + + opt2 = G_define_option() ; + opt2->key = "min_pixels"; + opt2->type = TYPE_INTEGER; + opt2->required = YES; + opt2->description= "minimum number of pixels defining a blob"; + + opt3 = G_define_option(); + opt3->key = "max_pixels"; + opt3->type = TYPE_INTEGER; + opt3->required = YES; + opt3->description = "maximum number of pixels defining a blob"; + + opt4 = G_define_option(); + opt4->key = "min_value"; + opt4->type = TYPE_DOUBLE; + opt4->required = YES; + opt4->description = "minimum value of the map for defining a blob"; + + opt5 = G_define_option(); + opt5->key = "max_value"; + opt5->type = TYPE_DOUBLE; + opt5->required = YES; + opt5->description = "maximum value of the map for defining a blob\n\n\tThe output is a site file, BUT it will be printed to standard output."; + + /***** Start of main *****/ + G_gisinit(argv[0]); + + if (G_parser(argc, argv) < 0) + exit(-1); + + sscanf(opt2->answer,"%d",&minp); + sscanf(opt3->answer,"%d",&maxp); + sscanf(opt4->answer,"%lf",&minv); + sscanf(opt5->answer,"%lf",&maxv); + + + if((mapset = G_find_cell2(opt1->answer, "")) == NULL){ + sprintf(tempbuf,"can't open raster map <%s> for reading",opt1->answer); + G_fatal_error(tempbuf); + } + + if((fd = G_open_cell_old(opt1->answer, mapset)) < 0){ + sprintf(tempbuf,"error opening raster map <%s>", opt1->answer); + G_fatal_error(tempbuf); + } + + G_get_window (&cellhd); + + rowbuf = (DCELL *)G_calloc(cellhd.cols * cellhd.rows,sizeof(DCELL)); + tf=rowbuf; + matrix = (double **) G_calloc(cellhd.rows,sizeof(double *)); + for(i=0;i=minp) && (sites[i].n<=maxp)) + fprintf(stdout,"%f|%f|#%d%s%f\n",sites[i].east,sites[i].north, + sites[i].n, "%",sites[i].min); + + + return 0; +} Property changes on: trunk/grassaddons/i.pr/i.pr_blob/main.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_classify/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_classify/Makefile (rev 0) +++ trunk/grassaddons/i.pr/i.pr_classify/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,14 @@ +MODULE_TOPDIR = ../../.. + +PRINCLUDE = ../include/ +EXTRA_CFLAGS = -I$(PRINCLUDE) +PRLIB = -lgrass_pr + +PGM = i.pr_classify + +LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) +DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) + +include $(MODULE_TOPDIR)/include/Make/Module.make + +default: cmd Property changes on: trunk/grassaddons/i.pr/i.pr_classify/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_classify/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_classify/main.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_classify/main.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,423 @@ +#include "gis.h" +#include "global.h" +#include +#include +#include + + +int extract_array_with_null(); + +int main(argc,argv) +int argc; +char *argv[]; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + int model_type; + NearestNeighbor nn; + GaussianMixture gm; + Tree tree; + SupportVectorMachine svm; + BTree btree; + BSupportVectorMachine bsvm; + char tmpbuf[500]; + char *mapset; + struct Cell_head cellhd; + double ***matrix ; + DCELL *rowbuf; + DCELL *tf; + int *fd; + int r,c,l; + Features features; + int i,j; + int fdout; + int *space_for_each_layer; + double *wind_vect; + double *X; + int borderC,borderR,borderC_upper,dim; + double mean,sd; + int corrent_feature; + double *projected; + int *compute_features; + DCELL *output_cell; + int set_null; + int n_input_map; + int R,C; + int last_row; + + char gisrc[500]; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + "/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1); + if(getenv("GISRC")==NULL){ + sprintf(gisrc,"/ssi0/ssi/%s/.grassrc5",getenv("LOGNAME")); + setenv("GISRC",gisrc,1); + } + + /* Define the different options */ + + opt1 = G_define_option(); + opt1->key = "input_map"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->multiple = YES; + opt1->gisprompt = "old,cell,raster" ; + opt1->description = "Input raster maps to be classified.\n\t\tIt is required a number of maps at least equal to the number of maps\n\t\tused for the training. If this number is greater the last maps will be ignored.\n\t\tWARNING: the order in which the maps are given should be compared \n\t\twith that used for the training."; + + opt2 = G_define_option() ; + opt2->key = "model"; + opt2->type = TYPE_STRING; + opt2->required = YES; + opt2->description= "Input file containing the model (output of i .pr_model).\n\t\tIf the data used for model development are not GRASS_data the program will abort."; + + opt3 = G_define_option(); + opt3->key = "output_map"; + opt3->type = TYPE_STRING; + opt3->required = YES; + opt3->gisprompt = "new,cell,raster" ; + opt3->description = "Name of the output raster map conaining the resulting classification."; + + /***** Start of main *****/ + G_gisinit(argv[0]); + + if (G_parser(argc, argv) < 0) + exit(-1); + + /*read the model*/ + model_type=read_model(opt2->answer,&features,&nn,&gm,&tree, + &svm,&btree,&bsvm); + + if(features.training.data_type != GRASS_data){ + sprintf(tmpbuf,"Model build using othe than GRASS data\n"); + G_fatal_error(tmpbuf); + } + if(model_type==0){ + sprintf(tmpbuf,"Model not recognized\n"); + G_fatal_error(tmpbuf); + } + + if(model_type == GM_model){ + compute_test_gm(&gm); + } + + /* load current region */ + G_get_window (&cellhd); + if(fabs((cellhd.ew_res - features.training.ew_res)/ + features.training.ew_res)>0.1){ + sprintf(tmpbuf,"EW resolution of training data and test map differs more than 10%%\n"); + G_warning(tmpbuf); + } + if(fabs((cellhd.ns_res - features.training.ns_res)/ + features.training.ns_res)>0.1){ + sprintf(tmpbuf,"NS resolution of training data and test map differs more than 10%%\n"); + G_warning(tmpbuf); + } + + /*compute features space*/ + dim=features.training.rows*features.training.cols; + + space_for_each_layer=(int *)G_calloc(features.training.nlayers, + sizeof(int)); + compute_features=(int *)G_calloc(features.training.nlayers,sizeof(int)); + for(j=0;janswers[l];l++){ + if((mapset = G_find_cell2(opt1->answers[l], "")) == NULL){ + sprintf(tmpbuf,"raster map [%s] not available",opt1->answers[l]); + G_fatal_error(tmpbuf); + } + + if((fd[l] = G_open_cell_old(opt1->answers[l], mapset)) < 0){ + sprintf(tmpbuf,"error opening raster map [%s]", opt1->answers[l]); + G_fatal_error(tmpbuf); + } + n_input_map += 1; + } + + if(n_input_map < features.training.nlayers){ + sprintf(tmpbuf,"Model requires %d input maps\n", + features.training.nlayers); + G_fatal_error(tmpbuf); + } + if(n_input_map > features.training.nlayers){ + sprintf(tmpbuf,"Only first %d maps considered\n", + features.training.nlayers); + G_warning(tmpbuf); + } + + /*open the output map*/ + fdout=open_new_DCELL(opt3->answer); + + /*useful vars*/ + borderC=(features.training.cols-1)/2; + borderC_upper=cellhd.cols-borderC; + borderR=(features.training.rows-1)/2; + last_row=features.training.rows-1; + + + /*read first rows*/ + for(r=0;r\n",opt1->answers[l]); + G_fatal_error(tmpbuf); + } + for(c = 0; c < cellhd.cols; c++){ + if (G_is_d_null_value (tf)) + *tf = 0.0; + matrix[l][r][c] = *tf; + tf++; + } + } + G_free(rowbuf); + } + + /*write the first rows of the output map*/ + for(c=1;c<=cellhd.cols;c++) + G_set_d_null_value(output_cell,c); + for(r=0;r\n",opt1->answers[l]); + G_fatal_error(tmpbuf); + } + for(c = 0; c < cellhd.cols; c++){ + if (G_is_d_null_value (tf)) + *tf = 0.0; + matrix[l][last_row][c] = *tf; + tf++; + } + G_free(rowbuf); + } + } + r += 1; + } + + /*write the last rows of the output map*/ + for(c=1;c<=cellhd.cols;c++) + G_set_d_null_value(output_cell,c); + for(r=0;r + +int main(argc, argv) + int argc ; + char **argv ; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + struct Option *opt4; + struct Option *opt5; + struct Option *opt6; + struct Option *opt7; + struct Option *opt8; + + struct Flag *flag_s; + char *training_file[TRAINING_MAX_INPUTFILES]; + int ntraining_file; + int i,j; + Features features; + char *tmpbuf; + int nclasses_for_pca; + char tempbuf[500]; + char opt1desc[500]; + FILE *fp; + + + char gisrc[500]; + +/* Initialize the GIS calls */ + G_gisinit(argv[0]) ; + + sprintf(opt1desc,"Input files (max %d) containing training data.\n\t\t2 formats are currently supported:\n\t\t1) GRASS_data (output of i.pr_training)\n\t\t2) TABLE_data.",TRAINING_MAX_INPUTFILES); + +/* set up command line */ + opt1 = G_define_option(); + opt1->key = "training"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->description = opt1desc; + opt1->multiple = YES; + + opt2 = G_define_option(); + opt2->key = "features"; + opt2->type = TYPE_STRING; + opt2->required = YES; + opt2->description = "Name of the output file containing the features."; + + opt4 = G_define_option(); + opt4->key = "normalize"; + opt4->type = TYPE_INTEGER; + opt4->required = NO; + opt4->description = "Numbers of the layers to be normalized."; + opt4->multiple = YES; + + opt6 = G_define_option(); + opt6->key = "mean"; + opt6->type = TYPE_INTEGER; + opt6->required = NO; + opt6->description = "Numbers of the layers on which to compute the mean value."; + opt6->multiple = YES; + + opt7 = G_define_option(); + opt7->key = "variance"; + opt7->type = TYPE_INTEGER; + opt7->required = NO; + opt7->description = "Numbers of the layers on which to compute the variance."; + opt7->multiple = YES; + + opt8 = G_define_option(); + opt8->key = "prin_comp"; + opt8->type = TYPE_INTEGER; + opt8->required = NO; + opt8->description = "Numbers of the layers on which to compute the principal components."; + opt8->multiple = YES; + + opt3 = G_define_option(); + opt3->key = "class_pc"; + opt3->type = TYPE_INTEGER; + opt3->required = NO; + opt3->description = "Classes of the data to be used for computing the principal components.\n\t\tIf not set, all the examples will be used."; + opt3->multiple = YES; + + opt5 = G_define_option(); + opt5->key = "standardize"; + opt5->type = TYPE_INTEGER; + opt5->required = NO; + opt5->description = "Numbers of features to be standardize.\n\t\tWARNING: not related to the number of layers."; + opt5->multiple = YES; + + + flag_s = G_define_flag(); + flag_s->key = 's'; + flag_s->description = "Print site file containing coordinates of examples and class labels\n\t(from training data) into features option and exit."; + + + if (G_parser(argc, argv)) + exit(1); + + /*read input training files*/ + ntraining_file=0; + for (i = 0; (training_file[ntraining_file] = opt1->answers[i]); i++){ + ntraining_file += 1; + if(ntraining_file > TRAINING_MAX_INPUTFILES){ + sprintf(tempbuf,"Maximum nomber of allowed training files is %d", + TRAINING_MAX_INPUTFILES); + G_fatal_error(tempbuf); + } + } + + + /*fill training structure*/ + inizialize_training(&(features.training)); + for(i=0;ianswer){ + if((fp=fopen(opt2->answer,"w"))==NULL){ + sprintf(tempbuf,"Can't open file %s for writing",opt2->answer); + G_fatal_error(tempbuf); + } + for(i=0;ianswers){ + j=0; + for (i = 0; (tmpbuf=opt4->answers[i]); i++){ + j += 1; + } + features.f_normalize=(int *)G_calloc(2+j,sizeof(int)); + features.f_normalize[0]=1; + features.f_normalize[1]=j; + for(i=2;i<2+j;i++){ + sscanf(opt4->answers[i-2],"%d",&(features.f_normalize[i])); + if((features.f_normalize[i]<=0) || + (features.f_normalize[i] > features.training.nlayers)){ + sprintf(tempbuf,"nlayers = %d\n", features.training.nlayers); + G_fatal_error(tempbuf); + } + features.f_normalize[i] -= 1; + } + }else{ + features.f_normalize=(int *)G_calloc(2,sizeof(int)); + } + + + + if(opt6->answers){ + j=0; + for (i = 0; (tmpbuf=opt6->answers[i]); i++){ + j += 1; + } + features.f_mean=(int *)G_calloc(2+j,sizeof(int)); + features.f_mean[0]=1; + features.f_mean[1]=j; + for(i=2;i<2+j;i++){ + sscanf(opt6->answers[i-2],"%d",&(features.f_mean[i])); + if((features.f_mean[i]<=0) || + (features.f_mean[i] > features.training.nlayers)){ + sprintf(tempbuf,"nlayers = %d\n", features.training.nlayers); + G_fatal_error(tempbuf); + } + features.f_mean[i] -= 1; + } + }else{ + features.f_mean=(int *)G_calloc(2,sizeof(int)); + } + + + + if(opt7->answers){ + j=0; + for (i = 0; (tmpbuf=opt7->answers[i]); i++){ + j += 1; + } + features.f_variance=(int *)G_calloc(2+j,sizeof(int)); + features.f_variance[0]=1; + features.f_variance[1]=j; + for(i=2;i<2+j;i++){ + sscanf(opt7->answers[i-2],"%d",&(features.f_variance[i])); + if((features.f_variance[i]<=0) || + (features.f_variance[i] > features.training.nlayers)){ + sprintf(tempbuf,"nlayers = %d\n", features.training.nlayers); + G_fatal_error(tempbuf); + } + features.f_variance[i] -= 1; + } + }else{ + features.f_variance=(int *)G_calloc(2,sizeof(int)); + } + + + + if(opt8->answers){ + j=0; + for (i = 0; (tmpbuf=opt8->answers[i]); i++){ + j += 1; + } + features.f_pca=(int *)G_calloc(2+j,sizeof(int)); + features.f_pca[0]=1; + features.f_pca[1]=j; + for(i=2;i<2+j;i++){ + sscanf(opt8->answers[i-2],"%d",&(features.f_pca[i])); + if((features.f_pca[i]<=0) || + (features.f_pca[i] > features.training.nlayers)){ + sprintf(tempbuf,"nlayers = %d\n", features.training.nlayers); + G_fatal_error(tempbuf); + } + features.f_pca[i] -= 1; + } + }else{ + features.f_pca=(int *)G_calloc(2,sizeof(int)); + } + + + + if(features.f_pca[0]){ + if(opt3->answers){ + nclasses_for_pca=0; + for (i = 0; (tmpbuf=opt3->answers[i]); i++){ + nclasses_for_pca += 1; + } + features.pca_class=(int *)G_calloc(2+nclasses_for_pca,sizeof(int)); + features.pca_class[0]=1; + features.pca_class[1]=nclasses_for_pca; + for(i=2;i<2+nclasses_for_pca;i++){ + sscanf(opt3->answers[i-2],"%d",&(features.pca_class[i])); + } + }else{ + features.pca_class=(int *)G_calloc(2,sizeof(int)); + } + } + + if(opt5->answers){ + j=0; + for (i = 0; (tmpbuf=opt5->answers[i]); i++){ + j += 1; + } + features.f_standardize=(int *)G_calloc(2+j,sizeof(int)); + features.f_standardize[0]=1; + features.f_standardize[1]=j; + for(i=2;i<2+j;i++){ + sscanf(opt5->answers[i-2],"%d",&(features.f_standardize[i])); + features.f_standardize[i] -= 1; + } + }else{ + features.f_standardize=(int *)G_calloc(2,sizeof(int)); + } + + + + /*fill features structure*/ + compute_features(&features); + + + /*standardize features*/ + if(features.f_standardize[0]){ + standardize_features(&features); + } + + /*write features*/ + write_features(opt2->answer,&features); + + return 0; +} + Property changes on: trunk/grassaddons/i.pr/i.pr_features/main.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_features_additional/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_additional/Makefile (rev 0) +++ trunk/grassaddons/i.pr/i.pr_features_additional/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,14 @@ +MODULE_TOPDIR = ../../.. + +PRINCLUDE = ../include/ +EXTRA_CFLAGS = -I$(PRINCLUDE) +PRLIB = -lgrass_pr + +PGM = i.pr_features_additional + +LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) +DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) + +include $(MODULE_TOPDIR)/include/Make/Module.make + +default: cmd Property changes on: trunk/grassaddons/i.pr/i.pr_features_additional/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_features_additional/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_additional/main.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_features_additional/main.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,337 @@ +#include "gis.h" +#include "global.h" +#include + +void generate_features(); + +int main(argc, argv) + int argc ; + char **argv ; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + + char *training_file[TRAINING_MAX_INPUTFILES]; + int ntraining_file; + int i; + Features features,features_out; + char tempbuf[500]; + char opt1desc[500]; + + + char gisrc[500]; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + "/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1); + if(getenv("GISRC")==NULL){ + sprintf(gisrc,"/ssi0/ssi/%s/.grassrc5",getenv("LOGNAME")); + setenv("GISRC",gisrc,1); + } + +/* Initialize the GIS calls */ + G_gisinit(argv[0]) ; + + sprintf(opt1desc,"Input files (max %d) containing training data.\n\t\t2 formats are currently supported:\n\t\t1) GRASS_data (output of i.pr_training)\n\t\t2) TABLE_data.",TRAINING_MAX_INPUTFILES); + +/* set up command line */ + opt1 = G_define_option(); + opt1->key = "training"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->description = opt1desc; + opt1->multiple = YES; + + opt2 = G_define_option(); + opt2->key = "features"; + opt2->type = TYPE_STRING; + opt2->required = YES; + opt2->description = "Name of the input file containing the features."; + + + opt3 = G_define_option(); + opt3->key = "features_out"; + opt3->type = TYPE_STRING; + opt3->required = YES; + opt3->description = "Name of the output file containing the resulting features."; + + + if (G_parser(argc, argv)) + exit(1); + + /*read input training files*/ + ntraining_file=0; + for (i = 0; (training_file[ntraining_file] = opt1->answers[i]); i++){ + ntraining_file += 1; + if(ntraining_file > TRAINING_MAX_INPUTFILES){ + sprintf(tempbuf,"Maximum nomber of allowed training files is %d", + TRAINING_MAX_INPUTFILES); + G_fatal_error(tempbuf); + } + } + + + /*fill training structure*/ + inizialize_training(&(features_out.training)); + for(i=0;ianswer,&features,-1); + + /*which action to do on the data*/ + features_out.f_normalize=features.f_normalize; + features_out.f_standardize=features.f_standardize; + features_out.f_mean=features.f_mean; + features_out.f_variance=features.f_variance; + features_out.f_pca=features.f_pca; + features_out.f_standardize=features.f_standardize; + + if(features_out.f_pca[0]){ + features_out.pca=features.pca; + features_out.pca_class=(int *)G_calloc(1,sizeof(int)); + } + + + /*fill features structure*/ + generate_features(&features,&features_out); + + /*standardize features*/ + if(features_out.f_standardize[0]){ + features_out.mean=features.mean; + features_out.sd=features.sd; + standardize_features(&features_out); + } + + /*write features*/ + write_features(opt3->answer,&features_out); + + return 0; +} + +void generate_features(features,features_out) + Features *features,*features_out; +{ + int i,j,k,l; + char *mapset; + int fp; + struct Cell_head cellhd; + DCELL *rowbuf; + DCELL *tf; + DCELL **matrix; + int r,c; + char tempbuf[500]; + int *compute_features; + int dim; + DCELL *mean = NULL,*sd = NULL; + int corrent_feature; + int *space_for_each_layer; + DCELL *projected = NULL; + int addclass; + + compute_features=(int *)G_calloc(features_out->training.nlayers,sizeof(int)); + + features_out->nexamples = features_out->training.nexamples; + dim=features_out->training.rows * features_out->training.cols; + + /*compute space*/ + space_for_each_layer=(int *)G_calloc(features_out->training.nlayers, + sizeof(int)); + features_out->examples_dim = 0; + for(j=0;jtraining.nlayers;j++){ + if(features_out->f_mean[0]){ + for(i=2;i<2+features_out->f_mean[1];i++){ + if(features_out->f_mean[i]==j){ + compute_features[j]=TRUE; + space_for_each_layer[j] += 1; + } + } + } + if(features_out->f_variance[0]){ + for(i=2;i<2+features_out->f_variance[1];i++){ + if(features_out->f_variance[i]==j){ + compute_features[j]=TRUE; + space_for_each_layer[j] += 1; + } + } + } + if(features_out->f_pca[0]){ + for(i=2;i<2+features_out->f_pca[1];i++){ + if(features_out->f_pca[i]==j){ + compute_features[j]=TRUE; + space_for_each_layer[j] += dim; + } + } + } + if(space_for_each_layer[j]==0){ + space_for_each_layer[j]=dim; + } + features_out->examples_dim += space_for_each_layer[j]; + } + + /*alloc memory*/ + features_out->value=(double **)G_calloc(features_out->nexamples,sizeof(double*)); + for(i=0;inexamples;i++){ + features_out->value[i]=(double *)G_calloc(features_out->examples_dim,sizeof(double)); + } + features_out->class=(int *)G_calloc(features_out->nexamples,sizeof(int)); + + matrix=(double **)G_calloc(features_out->nexamples,sizeof(double *)); + for(i=0;inexamples;i++){ + matrix[i]=(double *)G_calloc(dim,sizeof(double)); + } + + mean=(double*)G_calloc(features_out->nexamples,sizeof(double)); + sd=(double*)G_calloc(features_out->nexamples,sizeof(double)); + + + /*copy classes*/ + for(i=0;inexamples;i++){ + features_out->class[i]=features_out->training.class[i]; + } + + /*compute p_classes*/ + features_out->p_classes=(int *) G_calloc(1,sizeof(int)); + features_out->nclasses=1; + features_out->p_classes[0] = features_out->class[0]; + for(i=1;inexamples;i++){ + addclass=TRUE; + for(j=0;jnclasses;j++){ + if(features_out->class[i] == features_out->p_classes[j]){ + addclass=FALSE; + } + } + if(addclass){ + features_out->nclasses += 1; + features_out->p_classes=(int *)realloc(features_out->p_classes, + features_out->nclasses * sizeof(int)); + features_out->p_classes[features_out->nclasses-1] = features_out->class[i]; + } + } + + if(features_out->f_pca[0]){ + projected=(double*)G_calloc(dim,sizeof(double)); + } + + corrent_feature=0; + for(j=0;jtraining.nlayers;j++){ + for(i=0;inexamples;i++){ + switch(features_out->training.data_type){ + case GRASS_data: + if ((mapset=G_find_cell(features_out->training.mapnames[i][j], "")) == NULL) { + sprintf(tempbuf, "generate_features-> Can't find raster map <%s>", features_out->training.mapnames[i][j]); + G_fatal_error(tempbuf); + } + if ((fp =G_open_cell_old(features_out->training.mapnames[i][j], mapset))< 0){ + sprintf(tempbuf,"generate_features-> Can't open raster map <%s> for reading",features_out->training.mapnames[i][j]); + G_fatal_error(tempbuf); + } + + G_get_cellhd (features_out->training.mapnames[i][j], mapset, &cellhd); + G_set_window(&cellhd); + if((cellhd.rows != features_out->training.rows) || (cellhd.cols != features_out->training.cols)){ + /* fprintf(stderr,"map number = %d\n",i);*/ + sprintf(tempbuf, "generate_features-> Dimension Error"); + G_fatal_error(tempbuf); + } + rowbuf = (DCELL *)G_calloc(dim,sizeof(DCELL)); + tf = rowbuf; + + + for(r = 0; r < features_out->training.rows; r++){ + G_get_d_raster_row(fp, tf, r); + for(c = 0; c < features_out->training.cols; c++){ + if (G_is_d_null_value (tf)) + *tf = 0.0; + matrix[i][c + (r * features_out->training.cols)] = *tf; + tf++; + } + } + free(rowbuf); + + G_close_cell(fp); + break; + case TABLE_data: + matrix[i]=features_out->training.data[i]; + break; + default: + sprintf(tempbuf, "generate_features-> Format not recognized"); + G_fatal_error(tempbuf); + break; + } + } + + for(k=0;knexamples;k++){ + mean[k] = sd[k] = 0.0; + } + mean_and_sd_of_double_matrix_by_row(matrix,features_out->nexamples, + dim,mean,sd); + + if(features_out->f_normalize[0]){ + for(i=2;i<2+features_out->f_normalize[1];i++){ + if(features_out->f_normalize[i]==j){ + for(k=0;knexamples;k++){ + for(r = 0; r < dim; r++){ + matrix[k][r] = (matrix[k][r] - mean[k])/sd[k]; + } + } + } + } + } + + if(!compute_features[j]){ + for(i=0;inexamples;i++){ + for(r = 0; r < dim; r++){ + features_out->value[i][corrent_feature+r] = matrix[i][r]; + } + } + corrent_feature+=dim; + }else{ + if(features_out->f_mean[0]){ + for(i=2;i<2+features_out->f_mean[1];i++){ + if(features_out->f_mean[i]==j){ + for(k=0;knexamples;k++){ + features_out->value[k][corrent_feature]=mean[k]; + } + corrent_feature+=1; + } + } + } + + if(features_out->f_variance[0]){ + for(i=2;i<2+features_out->f_variance[1];i++){ + if(features_out->f_variance[i]==j){ + for(k=0;knexamples;k++){ + features_out->value[k][corrent_feature]=sd[k]*sd[k]; + } + corrent_feature+=1; + } + } + } + + + if(features_out->f_pca[0]){ + for(i=2;i<2+features_out->f_pca[1];i++){ + if(features_out->f_pca[i]==j){ + for(l=0;lnexamples;l++){ + product_double_vector_double_matrix(features_out->pca[j].eigmat, + matrix[l], + dim,dim,projected); + for(r=0;rvalue[l][corrent_feature+r]=projected[r]; + } + } + corrent_feature+=dim; + } + } + } + } + } + + + free(mean); + free(sd); + free(compute_features); +} Property changes on: trunk/grassaddons/i.pr/i.pr_features_additional/main.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_features_extract/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_extract/Makefile (rev 0) +++ trunk/grassaddons/i.pr/i.pr_features_extract/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,14 @@ +MODULE_TOPDIR = ../../.. + +PRINCLUDE = ../include/ +EXTRA_CFLAGS = -I$(PRINCLUDE) +PRLIB = -lgrass_pr + +PGM = i.pr_features_extract + +LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) +DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) + +include $(MODULE_TOPDIR)/include/Make/Module.make + +default: cmd Property changes on: trunk/grassaddons/i.pr/i.pr_features_extract/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_features_extract/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_extract/main.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_features_extract/main.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,156 @@ +#include "gis.h" +#include "global.h" +#include +#include + +#define MAXLIMITS 20 + +int read_selection(); + +int main(argc, argv) + int argc ; + char **argv ; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + struct Option *opt4; + + int i,j,k; + Features features; + + char features_out_name[500]; + int limits[MAXLIMITS]; + int *selection; + char *tmpbuf; + char gisrc[500]; + int nselection; + int nlimits; + double **copydata; + int col; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + ".",1); + // "/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1); + if(getenv("GISRC")==NULL){ + sprintf(gisrc,".grassrc5"); + //sprintf(gisrc,"/ssi0/ssi/%s/.grassrc5",getenv("LOGNAME")); + setenv("GISRC",gisrc,1); + } + +/* Initialize the GIS calls */ + G_gisinit(argv[0]) ; + +/* set up command line */ + opt1 = G_define_option(); + opt1->key = "features"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->description = "Input file containing the features (output of i.pr_features)."; + + opt2 = G_define_option(); + opt2->key = "selected"; + opt2->type = TYPE_STRING; + opt2->required = YES; + opt2->description = "File containing the results of the features selection procedure\n\t\t(output of i.pr_features_selection)."; + + + opt3 = G_define_option(); + opt3->key = "nvar"; + opt3->type = TYPE_INTEGER; + opt3->required = YES; + opt3->multiple = YES; + opt3->description = "Number of reordered variables to be extracted."; + + + opt4 = G_define_option(); + opt4->key = "output"; + opt4->type = TYPE_STRING; + opt4->required = NO; + opt4->description = "Optionally, creates output features files with output option as root\n\t\t(insteed of the features option)."; + + + if (G_parser(argc, argv)) + exit(1); + + nlimits=0; + /*get limits*/ + if(opt3->answers){ + j=0; + for (i = 0; (tmpbuf=opt3->answers[i]); i++,nlimits++){ + if(i==MAXLIMITS) + break; + sscanf(tmpbuf,"%d",&(limits[i])); + j += 1; + } + } + + /*read features*/ + read_features(opt1->answer,&features,-1); + + /*copy data*/ + copydata=(double**)G_calloc(features.nexamples,sizeof(double*)); + for(i=0;ianswer,&selection); + + if(nselection!=features.examples_dim){ + fprintf(stderr,"WARNING: number of features (=%d) different from length of relative importance file (=%d)\n",features.examples_dim,nselection); + } + + /*build files*/ + for(i=0;ianswer==NULL) + sprintf(features_out_name,"%s_fsExtr_%d",opt1->answer,limits[i]); + else + sprintf(features_out_name,"%s_fsExtr_%d",opt4->answer,limits[i]); + + write_features(features_out_name,&features); + } + + return 0; +} + +int read_selection(file,selection) + char *file; + int **selection; +{ + FILE *fp; + char tmpbuf[500]; + char *line = NULL; + int index=0; + + if((fp=fopen(file,"r"))==NULL){ + sprintf(tmpbuf,"Error opening file %s for reading",file); + G_fatal_error(tmpbuf); + } + + *selection=(int *)calloc(1,sizeof(int)); + while((line=GetLine(fp))!= NULL){ + line = (char *)strchr(line, '\t'); + sscanf(line,"%d",&((*selection)[index])); + index++; + *selection=realloc(*selection,(index+1)*sizeof(int)); + } + + return index; +} Property changes on: trunk/grassaddons/i.pr/i.pr_features_extract/main.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_features_selection/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_selection/Makefile (rev 0) +++ trunk/grassaddons/i.pr/i.pr_features_selection/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,14 @@ +MODULE_TOPDIR = ../../.. + +PRINCLUDE = ../include/ +EXTRA_CFLAGS = -I$(PRINCLUDE) +PRLIB = -lgrass_pr + +PGM = i.pr_features_selection + +LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) +DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) + +include $(MODULE_TOPDIR)/include/Make/Module.make + +default: cmd Property changes on: trunk/grassaddons/i.pr/i.pr_features_selection/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_features_selection/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_selection/main.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_features_selection/main.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,567 @@ +#include "gis.h" +#include "global.h" +#include +#include +#include +#include + +int main(argc, argv) + int argc ; + char **argv ; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + struct Option *opt6; + struct Option *opt7; + struct Option *opt8; + struct Option *opt9; + struct Option *opt10; + struct Option *opt12; + struct Option *opt18; + struct Option *opt23; + struct Option *opt24; + struct Option *opt22; + struct Flag *flag_w; + + Features features; + SupportVectorMachine *svm_models; + SupportVectorMachine svm; + + char tmpbuf[500]; + char svm_kernel_type[100]; + char fs_type_string[100]; + double svm_kp,svm_C,svm_tol,svm_eps; + int svm_maxloops; + int svm_kernel; + double svm_cost; + double *svm_W; + int i,j,k,t; + int fs_type,fs_rfe,neliminati; + FILE *fp_fs_out; + FILE *fp_fs_w,*fp_fs_stats; + char file_w[200],file_stats[200]; + int *selected,*names,*posizwsquare,*vareliminate; + int rimanenti; + int ncicli; + double **H_tot,**H_tmp,*valoriDJ,*wsquarenuovo,*vareliminatedouble; + int svm_verbose; + char gisrc[500]; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + ".",1); + /*"/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1);*/ + if(getenv("GISRC")==NULL){ + sprintf(gisrc,".grassrc5"); + /*sprintf(gisrc,"/ssi0/ssi/%s/.grassrc5",getenv("LOGNAME"));*/ + setenv("GISRC",gisrc,1); + } + + /* Initialize the GIS calls */ + G_gisinit(argv[0]) ; + + /* set up command line */ + opt1 = G_define_option(); + opt1->key = "features"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->description = "Input file containing the features (output of i.pr_features)."; + + opt2 = G_define_option(); + opt2->key = "output"; + opt2->type = TYPE_STRING; + opt2->required = YES; + opt2->description = "Name of the output file containing the selected features."; + + opt3 = G_define_option(); + opt3->key = "npc"; + opt3->type = TYPE_INTEGER; + opt3->required = NO; + opt3->description = "Number of the principal components to be used for the model development.\n\t\t\tIf not set all the principal components will be used.\n\t\t\tIgnored if features does not contain principal components model."; + + opt6 = G_define_option(); + opt6->key = "svm_kernel"; + opt6->type = TYPE_STRING; + opt6->required = NO; + opt6->description = "For svm: type of employed kernel."; + opt6->answer = "linear"; + opt6->options = "gaussian,linear"; + + opt7 = G_define_option(); + opt7->key = "svm_kp"; + opt7->type = TYPE_DOUBLE; + opt7->required = NO; + opt7->description = "For svm: kernel parameter (Required parameter if you are using gaussian kernel)."; + + opt8 = G_define_option(); + opt8->key = "svm_C"; + opt8->type = TYPE_DOUBLE; + opt8->required = NO; + opt8->description = "For svm: optimization parameter (Required parameter)."; + + opt18 = G_define_option(); + opt18->key = "svm_cost"; + opt18->type = TYPE_DOUBLE; + opt18->required = NO; + opt18->description = "Cost parameter for the implementation of cost-sensitive procedure(w in [-1,1]).\n\t\t\tw>0 results higher weight on examples of class 1.\n\t\t\tw<0 results higher weight on examples of class -1.\n\t\t\tw=0 corresponds to standard SVM."; + opt18->answer = "0.0"; + + + opt23 = G_define_option(); + opt23->key = "fs_type"; + opt23->type = TYPE_STRING; + opt23->required = YES; + opt23->description = "Feature selection method."; + opt23->options = "rfe,e_rfe,1_rfe,sqrt_rfe"; + + opt24 = G_define_option(); + opt24->key = "fs_rfe"; + opt24->type = TYPE_INTEGER; + opt24->required = NO; + opt24->description = "If you are using the e_rfe method, you have to choose the number of feartures\n\t\t\tfor the classical rfe method to start (fs_rfe>1)."; + + opt9 = G_define_option(); + opt9->key = "svm_tol"; + opt9->type = TYPE_DOUBLE; + opt9->required = NO; + opt9->description = "For svm: tollerance parameter."; + opt9->answer = "0.001"; + + opt10 = G_define_option(); + opt10->key = "svm_eps"; + opt10->type = TYPE_DOUBLE; + opt10->required = NO; + opt10->description = "For svm: epsilon."; + opt10->answer = "0.001"; + + opt12 = G_define_option(); + opt12->key = "svm_maxloops"; + opt12->type = TYPE_INTEGER; + opt12->required = NO; + opt12->description = "For svm: maximum number of optimization steps."; + opt12->answer = "1000"; + + opt22 = G_define_option(); + opt22->key = "svm_verbose"; + opt22->type = TYPE_INTEGER; + opt22->required = NO; + opt22->description = "For svm: if it is set to 1 the number of loops will be printed."; + opt22->options = "0,1"; + opt22->answer = "0"; + + + flag_w = G_define_flag(); + flag_w->key = 'w'; + flag_w->description = "Produce file containing weights at each step."; + + + if (G_parser(argc, argv)) + exit(1); + + /* + read number of pc + (May be we do not use this parameter in the next future) + */ + + if(opt3->answer){ + sscanf(opt3->answer,"%d",&(features.npc)); + }else{ + features.npc=-1; + } + + /*read SVM parameters*/ + + sscanf(opt6->answer,"%s",svm_kernel_type); + sscanf(opt18->answer,"%lf",&svm_cost); + + if(strcmp(svm_kernel_type,"linear") == 0){ + svm_kernel= SVM_KERNEL_LINEAR; + }else if(strcmp(svm_kernel_type,"gaussian") == 0){ + svm_kernel=SVM_KERNEL_GAUSSIAN; + }else{ + sprintf(tmpbuf,"kernel type not implemended!\n"); + G_fatal_error(tmpbuf); + } + if(svm_kernel==SVM_KERNEL_GAUSSIAN){ + if(!opt7->answer){ + sprintf(tmpbuf,"Please set kernel parameter\n"); + G_fatal_error(tmpbuf); + }else{ + sscanf(opt7->answer,"%lf",&svm_kp); + if(svm_kp <= 0){ + sprintf(tmpbuf,"kernel parameter must be > 0\n"); + G_fatal_error(tmpbuf); + } + } + }else + svm_kp=0.0; + + if(!opt8->answer){ + sprintf(tmpbuf,"Please set optimization parameter\n"); + G_fatal_error(tmpbuf); + }else{ + sscanf(opt8->answer,"%lf",&svm_C); + if(svm_C <= 0){ + sprintf(tmpbuf,"optimization parameter must be > 0\n"); + G_fatal_error(tmpbuf); + } + } + sscanf(opt9->answer,"%lf",&svm_tol); + if(svm_tol <= 0){ + sprintf(tmpbuf,"tol must be > 0\n"); + G_fatal_error(tmpbuf); + } + sscanf(opt10->answer,"%lf",&svm_eps); + if(svm_eps <= 0){ + sprintf(tmpbuf,"eps must be > 0\n"); + G_fatal_error(tmpbuf); + } + sscanf(opt12->answer,"%d",&svm_maxloops); + if(svm_maxloops <= 0){ + sprintf(tmpbuf,"maximum number of loops must be > 0\n"); + G_fatal_error(tmpbuf); + } + sscanf(opt22->answer,"%d",&svm_verbose); + /* read features selection parameters (PLease check consistence!!!!)*/ + + sscanf(opt23->answer,"%s",fs_type_string); + if(strcmp(fs_type_string,"rfe") == 0) + fs_type= FS_RFE; + else if(strcmp(fs_type_string,"e_rfe") == 0) + fs_type= FS_E_RFE; + else if(strcmp(fs_type_string,"1_rfe") == 0) + fs_type= FS_ONE_RFE; + else if(strcmp(fs_type_string,"sqrt_rfe") == 0) + fs_type= FS_SQRT_RFE; + else{ + sprintf(tmpbuf,"features selection method not recognized!\n"); + G_fatal_error(tmpbuf); + } + + if(fs_type == FS_E_RFE){ + if(!opt24->answer){ + sprintf(tmpbuf,"You selected e_rfe: please set fs_rfe parameter!\n"); + G_fatal_error(tmpbuf); + }else + sscanf(opt24->answer,"%d",&fs_rfe); + + if(fs_rfe <= 1){ + sprintf(tmpbuf,"fs_rfe must be > 1\n"); + G_fatal_error(tmpbuf); + } + } + + /*output files*/ + + fp_fs_out=fopen(opt2->answer,"w"); + + if(fp_fs_out==NULL){ + fprintf(stderr,"Error opening file %s for writing\n",opt2->answer); + exit(0); + } + + if(flag_w->answer){ + sprintf(file_w,"%s_w",opt2->answer); + fp_fs_w=fopen(file_w,"w"); + + if(fp_fs_w==NULL){ + fprintf(stderr,"Error opening file %s for writing\n",file_w); + exit(0); + } + }else + fp_fs_w=NULL; + + if(fs_type == FS_E_RFE){ + sprintf(file_stats,"%s_stats",opt2->answer); + fp_fs_stats=fopen(file_stats,"w"); + + if(fp_fs_stats==NULL){ + fprintf(stderr,"Error opening file %s for writing\n",file_stats); + exit(0); + } + }else + fp_fs_stats=NULL; + + + /*read features*/ + + read_features(opt1->answer,&features,features.npc); + if(features.nclasses==2){ + if((features.p_classes[0] * features.p_classes[1]) != -1){ + fprintf(stderr,"class %d interpreted as class -1\n", + features.p_classes[0]); + fprintf(stderr,"class %d interpreted as class 1\n", + features.p_classes[1]); + + for(i=0;i0){ + if(features.class[i]<0) + svm_W[i]=1.-svm_cost; + } else if(svm_cost<0){ + if(features.class[i]>0) + svm_W[i]=1.+svm_cost; + } + } + + /*set features selection variables*/ + svm_models=(SupportVectorMachine*) G_calloc(features.examples_dim-1, + sizeof(SupportVectorMachine)); + + names=(int*)calloc(features.examples_dim,sizeof(int)); + selected=(int*)calloc(features.examples_dim,sizeof(int)); + + for(j=0;jfs_rfe;i++){ + compute_svm(&(svm_models[i]),features.nexamples, + rimanenti,features.value, + features.class,svm_kernel,svm_kp, + svm_C,svm_tol,svm_eps,svm_maxloops,svm_verbose,svm_W); + + e_rfe_lin(&(svm_models[i]),&features,names, + selected,i,&rimanenti,fp_fs_w,fp_fs_stats); + free_svm(&(svm_models[i])); + ncicli++; + } + + for(i=ncicli;rimanenti>1;i++){ + compute_svm(&(svm_models[i]),features.nexamples, + rimanenti,features.value, + features.class,svm_kernel,svm_kp, + svm_C,svm_tol,svm_eps,svm_maxloops,svm_verbose,svm_W); + rfe_lin(&(svm_models[i]),&features,names,selected, + features.examples_dim-rimanenti,fp_fs_w); + free_svm(&(svm_models[i])); + rimanenti--; + } + selected[0]=names[0]; + break; + case FS_SQRT_RFE: + /* Eliminate sqrt(remaining features) features at a time*/ + rimanenti=features.examples_dim; + for(i=0;rimanenti>1;i++){ + + compute_svm(&(svm_models[i]),features.nexamples, + rimanenti,features.value, + features.class,svm_kernel,svm_kp, + svm_C,svm_tol,svm_eps,svm_maxloops,svm_verbose,svm_W); + + wsquarenuovo=(double *)calloc(rimanenti,sizeof(double)); + + for(j=0;jfs_rfe;i++){ + compute_svm(&(svm_models[i]),features.nexamples, + rimanenti,features.value, + features.class,svm_kernel,svm_kp, + svm_C,svm_tol,svm_eps,svm_maxloops,svm_verbose,svm_W); + + compute_valoriDJ(&(svm_models[i]),&features,H_tot,H_tmp,&valoriDJ); + e_rfe_gauss(valoriDJ,&features,names,selected,i,H_tot, + H_tmp,&rimanenti,svm_kp,fp_fs_w,fp_fs_stats); + + free(valoriDJ); + free_svm(&(svm_models[i])); + ncicli++; + } + + for(i=ncicli;rimanenti>1;i++){ + compute_svm(&(svm_models[i]),features.nexamples, + rimanenti,features.value, + features.class,svm_kernel,svm_kp, + svm_C,svm_tol,svm_eps,svm_maxloops,svm_verbose,svm_W); + compute_valoriDJ(&(svm_models[i]),&features,H_tot,H_tmp,&valoriDJ); + rfe_gauss(valoriDJ,&features,names,selected, + features.examples_dim-rimanenti,H_tot,H_tmp, + svm_kp,fp_fs_w); + free(valoriDJ); + free_svm(&(svm_models[i])); + rimanenti--; + } + selected[0]=names[0]; + break; + default: + break; + } + } + + + /*print output file containing the order of the relative importance*/ + for(i=0;ianswer) + fclose(fp_fs_w); + + return 0; +} + Property changes on: trunk/grassaddons/i.pr/i.pr_features_selection/main.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_model/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_model/Makefile (rev 0) +++ trunk/grassaddons/i.pr/i.pr_model/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,14 @@ +MODULE_TOPDIR = ../../.. + +PRINCLUDE = ../include/ +EXTRA_CFLAGS = -I$(PRINCLUDE) +PRLIB = -lgrass_pr + +PGM = i.pr_model + +LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) +DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) + +include $(MODULE_TOPDIR)/include/Make/Module.make + +default: cmd Property changes on: trunk/grassaddons/i.pr/i.pr_model/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_model/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_model/main.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_model/main.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,981 @@ +#include "gis.h" +#include "global.h" +#include +#include +#include + + +int main(argc, argv) + int argc ; + char **argv ; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + struct Option *opt4; + struct Option *opt5; + struct Option *opt6; + struct Option *opt7; + struct Option *opt8; + struct Option *opt9; + struct Option *opt10; + struct Option *opt11; + struct Option *opt12; + struct Option *opt13; + struct Option *opt14; + struct Option *opt15; + struct Option *opt16; + struct Option *opt17; + struct Option *opt18; + struct Option *opt19; + struct Option *opt20; + struct Option *opt21; + struct Option *opt22; + struct Option *opt23; + struct Option *opt24; + struct Option *opt25; + struct Option *opt26; + struct Option *opt27; + struct Option *opt28; + struct Flag *flag_g; + struct Flag *flag_t; + struct Flag *flag_s; + struct Flag *flag_n; + + Features features; + Features test_features; + Features validation_features; + Tree tree; + GaussianMixture gm; + NearestNeighbor nn; + SupportVectorMachine svm; + BTree btree; + BSupportVectorMachine bsvm; + + char tmpbuf[500]; + int tree_stamps, tree_minsize; + char svm_kernel_type[100]; + double svm_kp,svm_C,svm_tol,svm_eps; + int svm_maxloops; + int svm_kernel; + int svm_verbose; + double svm_cost; + double *svm_W; + int bagging,boosting,reg,reg_verbose; + double w; + int i,j; + char outfile[500]; + char outfile1[500]; + int svm_l1o; + int weights_boosting; + double *tree_costs; + char *tmp_costs; + int soft_margin_boosting; + int progressive_error; + int parallel_boosting; + double *misratio; + double misclass_ratio; + char gisrc[500]; + int testset; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + "/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1); + if(getenv("GISRC")==NULL){ + sprintf(gisrc,".grassrc5"); + setenv("GISRC",gisrc,1); + } + + + /* Initialize the GIS calls */ + G_gisinit(argv[0]) ; + + /* set up command line */ + opt1 = G_define_option(); + opt1->key = "features"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->description = "Input file containing the features (output of i.pr_features)."; + + opt2 = G_define_option(); + opt2->key = "model"; + opt2->type = TYPE_STRING; + opt2->required = YES; + opt2->description = "Name of the output file containing the model."; + + opt26 = G_define_option(); + opt26->key = "validation"; + opt26->type = TYPE_STRING; + opt26->required = NO; + opt26->description = "Input file containing other features for the training\n\t\t\tand for the evaluation of the performances of the model\n\t\t\ton an independent test set (for regularized AdaBoost)."; + + opt16 = G_define_option(); + opt16->key = "test"; + opt16->type = TYPE_STRING; + opt16->required = NO; + opt16->description = "Input file containing other features for the evaluation of the\n\t\t\tperformances of the model on an independent test set."; + + opt3 = G_define_option(); + opt3->key = "npc"; + opt3->type = TYPE_INTEGER; + opt3->required = NO; + opt3->description = "Number of the principal components to be used for the model development.\n\t\t\tIf not set all the principal components will be used.\n\t\t\tIgnored if features does not contain principal components model."; + + opt13 = G_define_option(); + opt13->key = "bagging"; + opt13->type = TYPE_INTEGER; + opt13->required = NO; + opt13->description = "Number of bagging models.\n\t\t\tIf bagging = 0 the classical model will be implemented.\n\t\t\tImplemented for trees and svm only."; + opt13->answer = "0"; + + opt14 = G_define_option(); + opt14->key = "boosting"; + opt14->type = TYPE_INTEGER; + opt14->required = NO; + opt14->description = "Number of boosting models.\n\t\t\tIf boosting = 0 the classical model will be implemented.\n\t\t\tImplemented for trees and svm only."; + opt14->answer = "0"; + + opt25 = G_define_option(); + opt25->key = "reg"; + opt25->type = TYPE_INTEGER; + opt25->required = NO; + opt25->description = "Number of misclassification ratio intervals."; + opt25->answer = "0"; + + opt28 = G_define_option(); + opt28->key = "misclass_ratio"; + opt28->type = TYPE_DOUBLE; + opt28->required = NO; + opt28->description = "For regularized AdaBoost: misclassification ratio for\n\t\t\thard point shaving and compute the new model."; + opt28->answer = "1.00"; + + opt27 = G_define_option(); + opt27->key = "reg_verbose"; + opt27->type = TYPE_INTEGER; + opt27->required = NO; + opt27->description = "For regularized AdaBoost:\n\t\t\t- if it is set = 1 the current value of misclassification\n\t\t\t ratio and the current error will be printed.\n\t\t\t- if it is set to >1 the number of\n\t\t\t loops, accuracy and the current value of misclassification ratio\n\t\t\twill be printed.\n\t\t\t For shaving and compute:\n\t\t\t - if it is set >0 the numbers of samples shaved will be printed."; + opt27->answer = "0"; + + opt23 = G_define_option(); + opt23->key = "progressive_error"; + opt23->type = TYPE_INTEGER; + opt23->required = NO; + opt23->description = "Progressive estimate of the model error\n\t\t\tincreasing the number of aggregated models"; + opt23->answer = "0"; + opt23->options = "0,1"; + + opt15 = G_define_option(); + opt15->key = "cost_boosting"; + opt15->type = TYPE_DOUBLE; + opt15->required = NO; + opt15->description = "Cost parameter for the implementation of cost-sensitive procedure(w in [0,2]).\n\t\t\tw>1 results higher weight on examples of class 1.\n\t\t\tw<1 results higher weight on examples of class -1.\n\t\t\tw=1 corresponds to standard Adaboost."; + opt15->answer = "1.0"; + + opt19 = G_define_option(); + opt19->key = "weights_boosting"; + opt19->type = TYPE_INTEGER; + opt19->required = NO; + opt19->description = "For boosting: if weights_boosting = 1, a file containing the evolution\n\t\t\tof the weights associated to data points will be produced."; + opt19->answer ="0"; + opt19->options = "0,1"; + + + + opt24 = G_define_option(); + opt24->key = "parallel_boosting"; + opt24->type = TYPE_INTEGER; + opt24->required = NO; + opt24->description = "For boosting: number of true boosting steps for parallel boosting.\n\t\t\tImplemented only for trees!!"; + opt24->answer ="0"; + + opt21 = G_define_option(); + opt21->key = "soft_margin_boosting"; + opt21->type = TYPE_INTEGER; + opt21->required = NO; + opt21->description = "For boosting: if soft_margin_boosting = 1, sof margin of Ababoost\n\t\t\t will bee used. Implemented only with trees. (Sperimental!!!!!!!!!!)"; + opt21->answer ="0"; + opt21->options = "0,1"; + + opt4 = G_define_option(); + opt4->key = "tree_stamps"; + opt4->type = TYPE_INTEGER; + opt4->required = NO; + opt4->description = "For trees: if tree_stamps = 1, a single split tree will be procuded,\n\t\t\tif tree_stamps = 0, a classical tree will be procuded."; + opt4->answer = "0"; + opt4->options = "0,1"; + + opt5 = G_define_option(); + opt5->key = "tree_minsize"; + opt5->type = TYPE_INTEGER; + opt5->required = NO; + opt5->description = "For trees: minimum number of examples containined\n\t\t\tinto a node for splitting the node itself"; + opt5->answer = "0"; + + opt20 = G_define_option(); + opt20->key = "tree_costs"; + opt20->type = TYPE_INTEGER; + opt20->required = NO; + opt20->description = "For trees: misclassification costs for each class"; + opt20->multiple = YES; + + opt6 = G_define_option(); + opt6->key = "svm_kernel"; + opt6->type = TYPE_STRING; + opt6->required = NO; + opt6->description = "For svm: type of employed kernel."; + opt6->answer = "linear"; + opt6->options = "gaussian,linear,2pbk"; + + opt7 = G_define_option(); + opt7->key = "svm_kp"; + opt7->type = TYPE_DOUBLE; + opt7->required = NO; + opt7->description = "For svm: kernel parameter (Required parameter if you are using gaussian kernel)."; + + opt8 = G_define_option(); + opt8->key = "svm_C"; + opt8->type = TYPE_DOUBLE; + opt8->required = NO; + opt8->description = "For svm: optimization parameter (Required parameter)."; + + opt18 = G_define_option(); + opt18->key = "svm_cost"; + opt18->type = TYPE_DOUBLE; + opt18->required = NO; + opt18->description = "Cost parameter for the implementation of cost-sensitive procedure(w in [-1,1]).\n\t\t\tw>0 results higher weight on examples of class 1.\n\t\t\tw<0 results higher weight on examples of class -1.\n\t\t\tw=0 corresponds to standard SVM.\n\t\t\tNot yet implemented (and may be it will be never implemented)\n\t\t\tfor bagging and boosting"; + opt18->answer = "0.0"; + + opt9 = G_define_option(); + opt9->key = "svm_tol"; + opt9->type = TYPE_DOUBLE; + opt9->required = NO; + opt9->description = "For svm: tollerance parameter."; + opt9->answer = "0.001"; + + opt10 = G_define_option(); + opt10->key = "svm_eps"; + opt10->type = TYPE_DOUBLE; + opt10->required = NO; + opt10->description = "For svm: epsilon."; + opt10->answer = "0.001"; + + opt11 = G_define_option(); + opt11->key = "svm_l1o"; + opt11->type = TYPE_INTEGER; + opt11->required = NO; + opt11->description = "For svm: leave 1 out error estimate."; + opt11->answer = "0"; + opt11->options = "0,1"; + + opt12 = G_define_option(); + opt12->key = "svm_maxloops"; + opt12->type = TYPE_INTEGER; + opt12->required = NO; + opt12->description = "For svm: maximum number of optimization steps."; + opt12->answer = "1000"; + + opt22 = G_define_option(); + opt22->key = "svm_verbose"; + opt22->type = TYPE_INTEGER; + opt22->required = NO; + opt22->description = "For svm: if it is set to 1 the number of loops will be printed."; + opt22->options = "0,1"; + opt22->answer = "0"; + + opt17 = G_define_option(); + opt17->key = "nn_k"; + opt17->type = TYPE_INTEGER; + opt17->required = NO; + opt17->description = "For nn: Number of neighbor to be considered during the test phase."; + opt17->answer = "1"; + + + flag_g = G_define_flag(); + flag_g->key = 'g'; + flag_g->description = "selected model: gaussian mixture."; + + flag_t = G_define_flag(); + flag_t->key = 't'; + flag_t->description = "selected model: classification trees."; + + flag_s = G_define_flag(); + flag_s->key = 's'; + flag_s->description = "selected model: support vector machines."; + + flag_n = G_define_flag(); + flag_n->key = 'n'; + flag_n->description = "selected model: nearest neighbor."; + + + if (G_parser(argc, argv)) + exit(1); + + /*read parameters*/ + if(opt3->answer){ + sscanf(opt3->answer,"%d",&(features.npc)); + }else{ + features.npc=-1; + } + + if(flag_n->answer){ + sscanf(opt17->answer,"%d",&(nn.k)); + if(nn.k <=0){ + sprintf(tmpbuf,"number of neighbor must be > 0\n"); + G_fatal_error(tmpbuf); + } + if(nn.k%2==0){ + sprintf(tmpbuf,"number of neighbor must be odd\n"); + G_fatal_error(tmpbuf); + } + } + + if(flag_t->answer){ + sscanf(opt4->answer,"%d",&tree_stamps); + if((tree_stamps != 0) && (tree_stamps != 1)){ + sprintf(tmpbuf,"stamps must be 0 or 1\n"); + G_fatal_error(tmpbuf); + } + sscanf(opt5->answer,"%d",&tree_minsize); + if(tree_minsize < 0){ + sprintf(tmpbuf,"minsize must be >= 0\n"); + G_fatal_error(tmpbuf); + } + } + + if(flag_s->answer){ + sscanf(opt6->answer,"%s",svm_kernel_type); + sscanf(opt18->answer,"%lf",&svm_cost); + + if(strcmp(svm_kernel_type,"linear") == 0){ + svm_kernel= SVM_KERNEL_LINEAR; + }else if(strcmp(svm_kernel_type,"gaussian") == 0){ + svm_kernel=SVM_KERNEL_GAUSSIAN; + }else if(strcmp(svm_kernel_type,"2pbk") == 0){ + svm_kernel=SVM_KERNEL_DIRECT; + }else{ + sprintf(tmpbuf,"kernel type not implemended!\n"); + G_fatal_error(tmpbuf); + } + if(svm_kernel==SVM_KERNEL_GAUSSIAN){ + if(!opt7->answer){ + sprintf(tmpbuf,"Please set kernel parameter\n"); + G_fatal_error(tmpbuf); + }else{ + sscanf(opt7->answer,"%lf",&svm_kp); + if(svm_kp <= 0){ + sprintf(tmpbuf,"kernel parameter must be > 0\n"); + G_fatal_error(tmpbuf); + } + } + }else + svm_kp=0.0; + + if(!opt8->answer){ + sprintf(tmpbuf,"Please set optimization parameter\n"); + G_fatal_error(tmpbuf); + }else{ + sscanf(opt8->answer,"%lf",&svm_C); + if(svm_C <= 0){ + sprintf(tmpbuf,"optimization parameter must be > 0\n"); + G_fatal_error(tmpbuf); + } + } + sscanf(opt9->answer,"%lf",&svm_tol); + if(svm_tol <= 0){ + sprintf(tmpbuf,"tol must be > 0\n"); + G_fatal_error(tmpbuf); + } + sscanf(opt10->answer,"%lf",&svm_eps); + if(svm_eps <= 0){ + sprintf(tmpbuf,"eps must be > 0\n"); + G_fatal_error(tmpbuf); + } + sscanf(opt12->answer,"%d",&svm_maxloops); + if(svm_maxloops <= 0){ + sprintf(tmpbuf,"maximum number of loops must be > 0\n"); + G_fatal_error(tmpbuf); + } + sscanf(opt11->answer,"%d",&svm_l1o); + sscanf(opt22->answer,"%d",&svm_verbose); + } + + sscanf(opt13->answer,"%d",&bagging); + sscanf(opt14->answer,"%d",&boosting); + sscanf(opt25->answer,"%d",®); + sscanf(opt27->answer,"%d",®_verbose); + sscanf(opt23->answer,"%d",&progressive_error); + + sscanf(opt28->answer,"%lf",&misclass_ratio); + if((misclass_ratio<0)||(misclass_ratio>1)){ + sprintf(tmpbuf,"misclassification ratio must be > 0 and < 1\n"); + G_fatal_error(tmpbuf); + } + if((misclass_ratio<1)&&(reg>0)){ + sprintf(tmpbuf,"Please select only one between shaving the training set and regularized AdaBoost\n"); + G_fatal_error(tmpbuf); + } + if(bagging < 0){ + bagging=0; + } + + if(reg<0){ + reg=0;} + + if(boosting < 0){ + boosting=0; + } + + if((bagging > 0) && (boosting > 0)){ + sprintf(tmpbuf,"Please select only one between bagging and boosting\n"); + G_fatal_error(tmpbuf); + } + + if(boosting>0){ + sscanf(opt15->answer,"%lf",&w); + if(w < 0.0 || w > 2.0){ + sprintf(tmpbuf,"boosting cost in [0,2]\n"); + G_fatal_error(tmpbuf); + } + sscanf(opt19->answer,"%d",&weights_boosting); + if((weights_boosting != 0) && (weights_boosting != 1)){ + sprintf(tmpbuf,"weights_boosting must be 0 or 1\n"); + G_fatal_error(tmpbuf); + } + sscanf(opt21->answer,"%d",&soft_margin_boosting); + if((soft_margin_boosting != 0) && (soft_margin_boosting != 1)){ + sprintf(tmpbuf,"soft_margin_boosting must be 0 or 1\n"); + G_fatal_error(tmpbuf); + } + if(opt24->answer) { + sscanf(opt24->answer,"%d",¶llel_boosting); + if((parallel_boosting <= boosting)&&(parallel_boosting>0)){ + sprintf(tmpbuf,"parallel_boosting must be > boosting\n"); + G_fatal_error(tmpbuf); + } + } + } + + /*read features*/ + read_features(opt1->answer,&features,features.npc); + if(features.nclasses==2){ + if((features.p_classes[0] * features.p_classes[1]) != -1){ + fprintf(stderr,"class %d interpreted as class -1\n", + features.p_classes[0]); + fprintf(stderr,"class %d interpreted as class 1\n", + features.p_classes[1]); + + for(i=0;ianswer){ + tree_costs=(double *)G_calloc(features.nclasses,sizeof(double)); + if(opt20->answers){ + j=0; + for (i = 0; (tmp_costs=opt20->answers[i]); i++){ + j += 1; + } + + if(j>features.nclasses) + j=features.nclasses; + + for(i=0;ianswers[i],"%lf",&(tree_costs[i])); + + for(i=j;ianswer){ + testset=1; + read_features(opt16->answer,&test_features,features.npc); + if(test_features.nclasses==2){ + if((test_features.p_classes[0] * test_features.p_classes[1]) != -1){ + fprintf(stderr,"class %d interpreted as class -1\n", + test_features.p_classes[0]); + fprintf(stderr,"class %d interpreted as class 1\n", + test_features.p_classes[1]); + + for(i=0;ianswer)&&(reg>0)){ + read_features(opt26->answer,&validation_features,features.npc); + if(validation_features.nclasses==2){ + if((validation_features.p_classes[0] * validation_features.p_classes[1]) != -1){ + fprintf(stderr,"class %d interpreted as class -1\n", + validation_features.p_classes[0]); + fprintf(stderr,"class %d interpreted as class 1\n", + validation_features.p_classes[1]); + + for(i=0;ianswer)&&(reg>0)){ + fprintf(stderr,"Regularized adaboost: validation data not foud\n"); + exit(-1);} + + /*single models*/ + if((bagging == 0) && (boosting == 0)){ + if(flag_t->answer){ + /*tree*/ + compute_tree(&tree,features.nexamples, features.examples_dim, + features.value, features.class,features.nclasses, + features.p_classes,tree_stamps,tree_minsize,tree_costs); + + /*model test and output*/ + write_tree(opt2->answer,&tree,&features); + + sprintf(outfile,"%s_tr_prediction",opt2->answer); + fprintf(stdout,"Prediction on training data: %s\n",opt1->answer); + test_tree(&tree,&features, outfile); + if(opt16->answer){ + sprintf(outfile,"%s_ts_prediction",opt2->answer); + fprintf(stdout,"Prediction on test data: %s\n",opt16->answer); + test_tree(&tree,&test_features, outfile); + } + return 0; + } + + if(flag_g->answer){ + /*gm*/ + compute_gm(&gm,features.nexamples,features.examples_dim, + features.value,features.class,features.nclasses, + features.p_classes); + + /*model test and output*/ + write_gm(opt2->answer,&gm,&features); + + compute_test_gm(&gm); + + sprintf(outfile,"%s_tr_prediction",opt2->answer); + fprintf(stdout,"Prediction on training data: %s\n",opt1->answer); + test_gm(&gm,&features, outfile); + if(opt16->answer){ + sprintf(outfile,"%s_ts_prediction",opt2->answer); + fprintf(stdout,"Prediction on test data: %s\n",opt16->answer); + test_gm(&gm,&test_features, outfile); + } + return 0; + } + + if(flag_n->answer){ + /*nearest neighbours*/ + compute_nn(&nn,features.nexamples,features.examples_dim, + features.value,features.class); + + /*model test and output*/ + write_nn(opt2->answer,&nn,&features); + + sprintf(outfile,"%s_tr_prediction",opt2->answer); + fprintf(stdout,"Prediction on training data: %s\n",opt1->answer); + test_nn(&nn,&features,nn.k,outfile); + if(opt16->answer){ + sprintf(outfile,"%s_ts_prediction",opt2->answer); + fprintf(stdout,"Prediction on test data: %s\n",opt16->answer); + test_nn(&nn,&test_features,nn.k,outfile); + } + return 0; + } + + if(flag_s->answer){ + /*svm*/ + + if(features.nclasses != 2){ + sprintf(tmpbuf,"svm works only with 2 class problems\n"); + G_fatal_error(tmpbuf); + } + + /*svm costs*/ + svm_W=(double*)calloc(features.nexamples,sizeof(double)); + for(i=0;i0){ + if(features.class[i]<0) + svm_W[i]=1.-svm_cost; + } else if(svm_cost<0){ + if(features.class[i]>0) + svm_W[i]=1.+svm_cost; + } + } + svm.cost=svm_cost; + + compute_svm(&svm,features.nexamples,features.examples_dim, + features.value,features.class,svm_kernel,svm_kp, + svm_C,svm_tol,svm_eps,svm_maxloops,svm_verbose,svm_W); + write_svm(opt2->answer,&svm,&features); + + /*model test and output*/ + sprintf(outfile,"%s_tr_prediction",opt2->answer); + fprintf(stdout,"Prediction on training data: %s\n",opt1->answer); + test_svm(&svm,&features, outfile); + + /*if requested, leave 1 out error estimate*/ + if(svm_l1o==1){ + fprintf(stdout,"Leave one out error estimate\n"); + estimate_cv_error(&svm); + } + if(opt16->answer){ + sprintf(outfile,"%s_ts_prediction",opt2->answer); + fprintf(stdout,"Prediction on test data: %s\n",opt16->answer); + test_svm(&svm,&test_features, outfile); + } + + return 0; + } + } + + /*bagging models*/ + if(bagging>0){ + if(flag_n->answer){ + sprintf(tmpbuf,"Sorry, bagging of nearest neighbor not yet implemented\n\n"); + G_fatal_error(tmpbuf); + } + if(flag_g->answer){ + sprintf(tmpbuf,"Sorry, bagging of gaussian mixture not yet implemented\n\n"); + G_fatal_error(tmpbuf); + } + if(flag_t->answer){ + /*trees*/ + compute_tree_bagging(&btree,bagging,features.nexamples, + features.examples_dim,features.value, + features.class,features.nclasses, + features.p_classes,tree_stamps,tree_minsize, + tree_costs); + + /*model test and output*/ + write_bagging_boosting_tree(opt2->answer,&btree,&features); + sprintf(outfile,"%s_tr_prediction",opt2->answer); + fprintf(stdout,"Prediction on training data: %s\n",opt1->answer); + if(!progressive_error) + test_btree(&btree,&features,outfile); + else + test_btree_progressive(&btree,&features,outfile); + if(opt16->answer){ + sprintf(outfile,"%s_ts_prediction",opt2->answer); + fprintf(stdout,"Prediction on test data: %s\n",opt16->answer); + if(!progressive_error) + test_btree(&btree,&test_features,outfile); + else + test_btree_progressive(&btree,&test_features,outfile); + } + return 0; + } + if(flag_s->answer){ + /*svm*/ + if(features.nclasses != 2){ + sprintf(tmpbuf,"svm works only with 2 class problems\n"); + G_fatal_error(tmpbuf); + } + + svm_W=(double*)calloc(features.nexamples,sizeof(double)); + for(i=0;ianswer,&bsvm,&features); + + sprintf(outfile,"%s_tr_prediction",opt2->answer); + fprintf(stdout,"Prediction on training data: %s\n",opt1->answer); + if(!progressive_error) + test_bsvm(&bsvm,&features,outfile); + else + test_bsvm_progressive(&bsvm,&features,outfile); + if(opt16->answer){ + sprintf(outfile,"%s_ts_prediction",opt2->answer); + fprintf(stdout,"Prediction on test data: %s\n",opt16->answer); + if(!progressive_error) + test_bsvm(&bsvm,&test_features,outfile); + else + test_bsvm_progressive(&bsvm,&test_features,outfile); + } + return 0; + } + } + + /*boosting models*/ + if(boosting>0){ + if(flag_n->answer){ + sprintf(tmpbuf,"Sorry, boosting of nearest neighbor not yet implemented\n\n"); + G_fatal_error(tmpbuf); + } + if(flag_g->answer){ + sprintf(tmpbuf,"Sorry, boosting of gaussian mixture not yet implemented\n\n"); + G_fatal_error(tmpbuf); + } + + if(features.nclasses != 2){ + sprintf(tmpbuf,"boosting works only with 2 class problems\n"); + G_fatal_error(tmpbuf); + } + if(flag_t->answer){ + /*trees*/ + /*regularized adboost*/ + if((parallel_boosting==0) &&((reg>0)||(misclass_ratio<1.00))){ + misratio= (double *)G_calloc(features.nexamples,sizeof(double)); + compute_tree_boosting_reg(&btree,boosting,w,features.nexamples, + features.examples_dim,features.value, + features.class,features.nclasses, + features.p_classes,tree_stamps,tree_minsize, + weights_boosting,tree_costs,misratio); + if(reg_verbose!=0) + for (i=0; i0){ + compute_tree_boosting_parallel(&btree,boosting,parallel_boosting,w, + features.nexamples, + features.examples_dim,features.value, + features.class,features.nclasses, + features.p_classes,tree_stamps, + tree_minsize, + weights_boosting,tree_costs); + + boosting=parallel_boosting; + } + + /*if requested, boosting weights to output*/ + if(weights_boosting==1){ + double *tmparray,*hist; + + hist=(double*)G_calloc(10000,sizeof(double)); + tmparray=(double*)G_calloc(boosting,sizeof(double)); + for(i=0;ianswer); + write_matrix(outfile,btree.w_evolution,features.nexamples, + boosting+3); + + } + + /*if requested, soft margin boosting (sperimental)*/ + if(soft_margin_boosting){ + double *alpha,*beta, **M; + + alpha=(double*)calloc(features.nexamples,sizeof(double)); + beta=(double*)calloc(boosting,sizeof(double)); + + M=(double**)calloc(features.nexamples,sizeof(double*)); + for(i=0;ianswer,&btree,&features);} + + sprintf(outfile,"%s_tr_prediction",opt2->answer); + if(!progressive_error){ + + if((reg>0)&&(misclass_ratio==1.00)){ + fprintf(stdout,"Prediction on training data: %s\n",opt1->answer); + test_btree_reg(&btree,&features,outfile,misratio);} + else if (misclass_ratio<1.00){ + /* if requested, it shave the hard point (point with misclassification ratio > misclass_ratio), + compute the new tree model and write output.*/ + sprintf(outfile1,"%s_ts_prediction",opt2->answer); + shaving_and_compute(boosting,w,features.nexamples, + features.examples_dim,features.value, + features.class,features.nclasses, + features.p_classes,tree_stamps,tree_minsize, + weights_boosting,tree_costs,misratio,reg_verbose, + misclass_ratio,outfile,opt2->answer,features,test_features,outfile1,testset); + } + else{ + fprintf(stdout,"Prediction on training data: %s\n",opt1->answer); + test_btree(&btree,&features,outfile);} + } + else{ + fprintf(stdout,"Prediction on training data: %s\n",opt1->answer); + test_btree_progressive(&btree,&features,outfile);} + + if(((opt16->answer) && (misclass_ratio==1.00))||((reg>0) && (opt26->answer))){ + sprintf(outfile,"%s_ts_prediction",opt2->answer); + + /*if requested, it computes the regularized adaboost, model test and write output*/ + {if((reg>0) && (opt26->answer)){ + regularized_boosting(boosting,w,features.nexamples, + features.examples_dim,features.value, + features.class,features.nclasses, + features.p_classes,tree_stamps,tree_minsize, + weights_boosting,tree_costs,misratio,reg,test_features, + outfile,validation_features,reg_verbose,opt16->answer, + opt26->answer,opt2->answer,features,testset); + } + + else if(!progressive_error) { + fprintf(stdout,"Prediction on test data: %s\n",opt16->answer); + test_btree(&btree,&test_features,outfile);} + else{ + fprintf(stdout,"Prediction on test data: %s\n",opt16->answer); + test_btree_progressive(&btree,&test_features,outfile); } + } + } + return 0; + } + + if(flag_s->answer){ + /*svm*/ + svm_W=(double*)calloc(features.nexamples,sizeof(double)); + for(i=0;ianswer); + write_matrix(outfile,bsvm.w_evolution,features.nexamples,boosting+3); + + } + + /*model test and output*/ + write_bagging_boosting_svm(opt2->answer,&bsvm,&features); + + sprintf(outfile,"%s_tr_prediction",opt2->answer); + fprintf(stdout,"Prediction on training data: %s\n",opt1->answer); + if(!progressive_error) + test_bsvm(&bsvm,&features,outfile); + else + test_bsvm_progressive(&bsvm,&features,outfile); + if(opt16->answer){ + sprintf(outfile,"%s_ts_prediction",opt2->answer); + fprintf(stdout,"Prediction on test data: %s\n",opt16->answer); + if(!progressive_error) + test_bsvm(&bsvm,&test_features,outfile); + else + test_bsvm_progressive(&bsvm,&test_features,outfile); + } + return 0; + } + } + + sprintf(tmpbuf,"please select a model\n"); + G_warning(tmpbuf); + return 0; +} + + + + + + + + + + + Property changes on: trunk/grassaddons/i.pr/i.pr_model/main.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_sites_aggregate/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_sites_aggregate/Makefile (rev 0) +++ trunk/grassaddons/i.pr/i.pr_sites_aggregate/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,14 @@ +MODULE_TOPDIR = ../../.. + +PRINCLUDE = ../include/ +EXTRA_CFLAGS = -I$(PRINCLUDE) +PRLIB = -lgrass_pr + +PGM = i.pr_sites_aggregate + +LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) +DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) + +include $(MODULE_TOPDIR)/include/Make/Module.make + +default: cmd Property changes on: trunk/grassaddons/i.pr/i.pr_sites_aggregate/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_sites_aggregate/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_sites_aggregate/main.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_sites_aggregate/main.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,211 @@ +#include "gis.h" +#include "global.h" +#include +#include +#include +#include "Vect.h" + + +#define MAXPNTS 1000 + +int main(argc,argv) + int argc; + char *argv[]; +{ + struct Option *opt1,*opt2,*opt3,*opt4; + char *line=NULL; + FILE *fp; + int i,j,k,npoints; + double **data; + int *mark; + double max_dist,min_dist; + double tmpx,tmpy; + int np,np2; + double tmpdist; + int *indice,*indice2; + double *dist; + int *indxx; + int count; + + struct Map_info Out; + struct Map_info Out2; + struct line_pnts *Points; + struct line_cats *Cats; + struct line_pnts *Points2; + struct line_cats *Cats2; + + + opt1 = G_define_option() ; + opt1->key = "sites"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->description= "site file"; + + opt2 = G_define_option() ; + opt2->key = "max_dist"; + opt2->type = TYPE_DOUBLE; + opt2->required = YES; + opt2->description= "count sites distant less than max_dist"; + + opt3 = G_define_option() ; + opt3->key = "min_dist"; + opt3->type = TYPE_DOUBLE; + opt3->required = YES; + opt3->description= "count sites distant less than min_dist"; + + + opt4 = G_define_standard_option(G_OPT_V_OUTPUT); + opt4->key = "link"; + opt4->description = "Output vector with lines"; + + /***** Start of main *****/ + G_gisinit(argv[0]); + + if (G_parser(argc, argv) < 0) + exit(-1); + + sscanf(opt2->answer,"%lf",&max_dist); + max_dist *= max_dist; + sscanf(opt3->answer,"%lf",&min_dist); + min_dist *= min_dist; + + Vect_open_new (&Out2, opt4->answer, 0); + sprintf(opt4->answer,"%s_graph",opt4->answer); + Vect_open_new (&Out, opt4->answer, 0); + + Points = Vect_new_line_struct (); + Cats = Vect_new_cats_struct (); + Points2 = Vect_new_line_struct (); + Cats2 = Vect_new_cats_struct (); + + data=(double**)calloc(1,sizeof(double*)); + data[0]=(double*)calloc(3,sizeof(double)); + + fp=fopen(opt1->answer,"r"); + + npoints=0; + while((line=GetLine(fp))!=NULL){ + sscanf(line,"%lf", &(data[npoints][0])); + line = (char *)strchr(line, '|'); + *line++; + sscanf(line,"%lf", &(data[npoints][1])); + line = (char *)strchr(line, '|'); + *line++; + sscanf(line,"%lf", &(data[npoints][2])); + npoints++; + data=(double**)realloc(data,(npoints+1)*sizeof(double*)); + data[npoints]=(double*)calloc(3,sizeof(double)); + } + + mark=(int *)calloc(npoints,sizeof(int)); + for(i=0;idata[i][2]) + count=data[i][2]; + else + count=np; + + tmpx=0; + tmpy=0; + for(j=0;j +#include + +#define TINY 1.0e-20 +#define MAXLIMITS 10000 + +void pearsn(); +double erfcc(); + +int main(argc,argv) + int argc; + char *argv[]; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + struct Option *opt4; + Features features; + char tempbuf[500]; + char *tmpbuf; + int corr[MAXLIMITS]; + int i,j,h,k; + double **mat; + double min, max, NEWmin, NEWmax, a; + CELL **intmat; + struct Cell_head cellhd; + struct Cell_head cellhd_orig; + char outputmap_name[500]; + int FD; + int npca; + double sqrt_npca; + int ROW, COL; + int index; + char *outputxgraph_name; + FILE *FP; + double sum; + double tmp; + double *vett1,*vett2; + int maxeig=0; + int layer; + int ncorr; + int *npoints_for_class; + double **DataMat; + double d,prob,coeffcorr,pvalue,zvalue; + double mean,sd; + int *indexA; + char gisrc[500]; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + "/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1); + if(getenv("GISRC")==NULL){ + sprintf(gisrc,"/ssi0/ssi/%s/.grassrc5",getenv("LOGNAME")); + setenv("GISRC",gisrc,1); + } + + G_gisinit(argv[0]); + + opt1 = G_define_option() ; + opt1->key = "features"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->description= "Input file containing the features (output of i.pr_features)." ; + + opt3 = G_define_option() ; + opt3->key = "layer"; + opt3->type = TYPE_INTEGER; + opt3->required = NO; + opt3->description= "Number of the layer to be analized (concerning with the principal components).\n\t\tIgnored if features does not contain principal components model."; + opt3->answer = "1"; + + opt2 = G_define_option() ; + opt2->key = "npc"; + opt2->type = TYPE_INTEGER; + opt2->required = NO; + opt2->description= "Number of principal components to be analized.\n\t\tIf this number is greater then the dimension of the data,\n\t\tall the principal components will be considered.\n\t\tIgnored if features does not contain principal components model."; + + opt4 = G_define_option(); + opt4->key = "corr"; + opt4->type = TYPE_INTEGER; + opt4->required = NO; + opt4->multiple = YES; + opt4->description = "Index of columns to compute correlation."; + + /***** Start of main *****/ + + if (G_parser(argc, argv) < 0) + exit(-1); + + sscanf(opt3->answer,"%d",&layer); + + read_features(opt1->answer, &features,-1); + if((layer <= 0) || (layer > features.training.nlayers)){ + sprintf(tempbuf,"Number of layers is %d\n",features.training.nlayers); + G_fatal_error(tempbuf); + } + + ncorr=0; + /*get index for correlation*/ + if(opt4->answers){ + for (i = 0; (tmpbuf=opt4->answers[i]); i++,ncorr++){ + if(i==MAXLIMITS) + break; + sscanf(tmpbuf,"%d",&(corr[i])); + if (corr[i]==0){ + ncorr=features.examples_dim; + for(j=0;jfeatures.examples_dim ){ + sprintf(tempbuf,"Negative index of columns or wrong index\n"); + G_fatal_error(tempbuf); + } + } + + if(ncorr==1){ + sprintf(tempbuf,"Can't do correlation with 1 column!!\n"); + G_fatal_error(tempbuf); + } + + /* calcolo la correlazione tra le varie variabili */ + + vett1=(double*)calloc(features.nexamples,sizeof(double)); + vett2=(double*)calloc(features.nexamples,sizeof(double)); + + for (i=0;i .0) + maxeig = i + 1; + + if(opt2->answer == NULL) + npca = maxeig; + else{ + sscanf(opt2->answer,"%d",&npca); + if(npca <= 0){ + sprintf(tempbuf,"npca must be > 0"); + G_fatal_error(tempbuf); + } + } + if(npca > maxeig) + npca = maxeig; + + + if(features.training.rows > 1 && features.training.cols > 1){ + /*make sure avalilability of monitir*/ + R_open_driver(); + R_close_driver(); + + /*number of rows and cols on the virtual screen*/ + + sqrt_npca=sqrt(npca); + if(((int)sqrt_npca * (int)sqrt_npca) >= npca){ + ROW = (int)sqrt_npca; + COL = ROW; + } + else{ + ROW = (int)sqrt_npca + 1; + COL = ROW; + } + if((ROW * (COL - 1)) >= npca) + COL = COL - 1; + + + /* set region*/ + G_get_window(&cellhd_orig); + cellhd=cellhd_orig; + cellhd.rows=features.training.rows * ROW; + cellhd.cols=features.training.cols * COL; + cellhd.ew_res=1.0; + cellhd.ns_res=1.0; + cellhd.north=(double)(cellhd.rows); + cellhd.south=.0; + cellhd.east=(double)(cellhd.cols); + cellhd.west=.0; + if(G_set_window(&cellhd) == -1){ + sprintf(tempbuf,"error setting working window"); + G_fatal_error(tempbuf); + } + + /*open output raster map*/ + + sprintf(outputmap_name,"%s_tmpimage",opt1->answer); + + if(outputmap_name != NULL) + FD=open_new_CELL(outputmap_name); + else{ + sprintf(tempbuf,"error setting the output name"); + G_fatal_error(tempbuf); + } + + /* alloc memory*/ + mat=(double **)G_calloc(cellhd.rows,sizeof(double *)); + for(i=0;i max) + max = mat[i][j]; + } + + /*converted the aoutovalue in 0-256*/ + NEWmin = 1.; + NEWmax = 255.; + + if(max != min) + a = (NEWmax - NEWmin) / (max - min); + else{ + sprintf(tempbuf,"min of eigenvect %d = max of eigenvect %d",index, + index); + G_fatal_error(tempbuf); + } + + for(i=0;i= 0.0 ? ans : 2.0-ans; +} Property changes on: trunk/grassaddons/i.pr/i.pr_statistics/main.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_subsets/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_subsets/Makefile (rev 0) +++ trunk/grassaddons/i.pr/i.pr_subsets/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,14 @@ +MODULE_TOPDIR = ../../.. + +PRINCLUDE = ../include/ +EXTRA_CFLAGS = -I$(PRINCLUDE) +PRLIB = -lgrass_pr + +PGM = i.pr_subsets + +LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) +DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) + +include $(MODULE_TOPDIR)/include/Make/Module.make + +default: cmd Property changes on: trunk/grassaddons/i.pr/i.pr_subsets/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_subsets/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_subsets/main.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_subsets/main.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,593 @@ +#include "gis.h" +#include "global.h" +#include +#include +#include + +void write_matrix(); + +int main(argc, argv) + int argc ; + char **argv ; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + struct Flag *flag_c; + struct Flag *flag_b; + struct Flag *flag_s; + + Features features; + Features *tr_features; + Features *ts_features; + + char tmpbuf[500]; + int n_sets; + int i,j,k; + char fileout[500],filelab[500]; + FILE *flab; + double *prob,*prob_pos,*prob_neg; + int *random_labels,*non_extracted,*random_labels_pos,*random_labels_neg; + int n_non_extracted; + int npos,nneg; + int n_extracted; + int extracted; + int indx; + int idum; + double probok; + int seed; + + char gisrc[500]; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + ".",1); + //"/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1); + if(getenv("GISRC")==NULL){ + sprintf(gisrc,".grassrc5"); + //sprintf(gisrc,"/ssi0/ssi/%s/.grassrc5",getenv("LOGNAME")); + setenv("GISRC",gisrc,1); + } + + /* Initialize the GIS calls */ + G_gisinit(argv[0]) ; + + /* set up command line */ + opt1 = G_define_option(); + opt1->key = "features"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->description = "Input file containing the features (output of i.pr_features)."; + + opt2 = G_define_option(); + opt2->key = "n_sets"; + opt2->type = TYPE_INTEGER; + opt2->required = YES; + opt2->description = "Number of subsets (>=1). If you set n_sets=1 and select cross-validation,\n\t\tleave one out cv will be implemented."; + + opt3 = G_define_option(); + opt3->key = "seed"; + opt3->type = TYPE_INTEGER; + opt3->required = YES; + opt3->description = "Seed for the initialization (>=0), which specifies a starting point\n\t\tfor the random number sequence. Replicate same experiment."; + opt3->answer="0"; + + flag_c = G_define_flag(); + flag_c->key = 'c'; + flag_c->description = "selected method: cross-validation."; + + flag_b = G_define_flag(); + flag_b->key = 'b'; + flag_b->description = "selected method: bootstrap."; + + flag_s = G_define_flag(); + flag_s->key = 's'; + flag_s->description = "selected method: stratified bootstrap (works only with two classes."; + + if (G_parser(argc, argv)) + exit(1); + + + /*read parameters*/ + sscanf(opt2->answer,"%d",&n_sets); + if(n_sets<=0){ + sprintf(tmpbuf,"n_sets must be >0"); + G_fatal_error(tmpbuf); + } + + sscanf(opt3->answer,"%d",&seed); + if(seed<0){ + sprintf(tmpbuf,"seed must be >=0"); + G_fatal_error(tmpbuf); + } + + if(!flag_b->answer && !flag_c->answer){ + sprintf(tmpbuf,"Neither -b nor -c flag set!\n"); + G_fatal_error(tmpbuf); + } + + /*read features*/ + read_features(opt1->answer,&features,-1); + + if(flag_b->answer && !flag_s->answer){ + sprintf(filelab,"%s__bootstrap__labels",opt1->answer); + flab=fopen(filelab,"w"); + + tr_features=(Features*)calloc(n_sets,sizeof(Features)); + ts_features=(Features*)calloc(n_sets,sizeof(Features)); + + prob=(double*)calloc(features.nexamples,sizeof(double)); + for(i=0;ianswer,i+1); + write_features(fileout,&tr_features[i]); + + fprintf (flab,"Training %d:\n",i+1); + + for (j=0;j<(tr_features[i].nexamples-1);j++){ + fprintf(flab,"%d\t",random_labels[j]+1); + } + fprintf(flab,"%d\n",random_labels[tr_features[i].nexamples-1]+1); + + /*test*/ + n_non_extracted=0; + for(k=0;kanswer,i+1); + write_features(fileout,&ts_features[i]); + + fprintf (flab,"Test %d:\n",i+1); + + for (j=0;j<(ts_features[i].nexamples-1);j++){ + fprintf(flab,"%d\t", non_extracted[j]+1); + } + fprintf(flab,"%d\n",non_extracted[ts_features[i].nexamples-1]+1); + + } + free(prob); + free(random_labels); + free(non_extracted); + + return 0; + } + + + /*stratified bootstrap*/ + if(flag_s->answer && flag_b->answer) + { + + sprintf(filelab,"%s__str_bootstrap__labels",opt1->answer); + flab=fopen(filelab,"w"); + + tr_features=(Features*)calloc(n_sets,sizeof(Features)); + ts_features=(Features*)calloc(n_sets,sizeof(Features)); + + random_labels=(int*)calloc(features.nexamples,sizeof(int)); + non_extracted=(int*)calloc(features.nexamples,sizeof(int)); + + npos=0; + nneg=0; + + for(i=0;ianswer,i+1); + write_features(fileout,&tr_features[i]); + + fprintf (flab,"Training %d:\n",i+1); + + for (j=0;j<(tr_features[i].nexamples-1);j++){ + fprintf(flab,"%d\t",random_labels[j]+1); + } + fprintf(flab,"%d\n",random_labels[tr_features[i].nexamples-1]+1); + + /*test*/ + n_non_extracted=0; + for(k=0;kanswer,i+1); + write_features(fileout,&ts_features[i]); + + fprintf (flab,"Test %d:\n",i+1); + + for (j=0;j<(ts_features[i].nexamples-1);j++){ + fprintf(flab,"%d\t", non_extracted[j]+1); + } + fprintf(flab,"%d\n",non_extracted[ts_features[i].nexamples-1]+1); + + } + free(prob_pos); + free(prob_neg); + free(random_labels); + free(random_labels_pos); + free(random_labels_neg); + free(non_extracted); + + return 0; + } + + if(flag_c->answer && !flag_s->answer){ + if(n_sets==1){ + tr_features=(Features*)calloc(features.nexamples,sizeof(Features)); + ts_features=(Features*)calloc(features.nexamples,sizeof(Features)); + + /*training*/ + for(i=0;ianswer,i+1); + write_features(fileout,&tr_features[i]); + + /*test*/ + ts_features[i].file=features.file; + ts_features[i].nexamples=1; + ts_features[i].examples_dim=features.examples_dim; + ts_features[i].value=(double**)calloc(1,sizeof(double*)); + ts_features[i].class=(int*)calloc(1,sizeof(int)); + ts_features[i].value[0]=features.value[i]; + ts_features[i].class[0]=features.class[i]; + + + ts_features[i].p_classes=features.p_classes; + ts_features[i].nclasses=features.nclasses; + ts_features[i].mean=features.mean; + ts_features[i].sd=features.sd; + ts_features[i].f_normalize=features.f_normalize; + ts_features[i].f_standardize=features.f_standardize; + ts_features[i].f_mean=features.f_mean; + ts_features[i].f_variance=features.f_variance; + ts_features[i].f_pca=features.f_pca; + ts_features[i].pca_class=features.pca_class; + ts_features[i].pca=features.pca; + ts_features[i].training=features.training; + ts_features[i].npc=features.npc; + ts_features[i].training.file="generated by i.pr_subsets"; + + sprintf(fileout,"%s__ts_l1ocv__%d",opt1->answer,i+1); + write_features(fileout,&ts_features[i]); + } + return 0; + }else{ + sprintf(filelab,"%s__cv__labels",opt1->answer); + flab=fopen(filelab,"w"); + + tr_features=(Features*)calloc(n_sets,sizeof(Features)); + ts_features=(Features*)calloc(n_sets,sizeof(Features)); + + if(n_sets>features.nexamples){ + sprintf(tmpbuf,"n_sets must be <= %d (=number of training data) if you want to use cross-validation",features.nexamples); + G_fatal_error(tmpbuf); + } + + probok=pow(1.-pow(1.-1./n_sets,(double)features.nexamples),(double)n_sets); + if(probok<0.95){ + sprintf(tmpbuf,"the probability of extracting %d non empty test sets is less than 0.95 (the probability is exactly %e). Sorry but I don't like to take this risk.",n_sets,probok); + G_fatal_error(tmpbuf); + } + + random_labels=(int*)calloc(features.nexamples,sizeof(int)); + for(i=0;ianswer,n_sets,i+1); + write_features(fileout,&tr_features[i]); + + + /*test*/ + n_non_extracted=0; + for(j=0;janswer,n_sets,i+1); + write_features(fileout,&tr_features[i]); + + } + free(random_labels); + return 0; + } + } + + if(flag_c->answer && flag_s->answer) + { + fprintf(stderr,"Stratified Cross validation not implemented (yet)!\n"); + exit (0); + } + return 0; +} Property changes on: trunk/grassaddons/i.pr/i.pr_subsets/main.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,376 @@ +#include "gis.h" +#include "global.h" +#include +#include +#include + +void write_matrix(); + +int main(argc, argv) + int argc ; + char **argv ; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + struct Flag *flag_c; + struct Flag *flag_b; + + Features features; + Features *tr_features; + Features *ts_features; + + char tmpbuf[500]; + int n_sets; + int i,j,k; + char fileout[500]; + double *prob; + int *random_labels,*non_extracted; + int n_non_extracted; + int n_extracted; + int extracted; + int indx; + int idum; + double probok; + int seed; + + char gisrc[500]; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + "/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1); + if(getenv("GISRC")==NULL){ + sprintf(gisrc,"/ssi0/ssi/%s/.grassrc5",getenv("LOGNAME")); + setenv("GISRC",gisrc,1); + } + + /* Initialize the GIS calls */ + G_gisinit(argv[0]) ; + + /* set up command line */ + opt1 = G_define_option(); + opt1->key = "features"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->description = "Input file containing the features (output of i.pr_features)."; + + opt2 = G_define_option(); + opt2->key = "n_sets"; + opt2->type = TYPE_INTEGER; + opt2->required = YES; + opt2->description = "Number of subsets (>=1). If you set n_sets=1 and select cross-validation,\n\t\tleave one out cv will be implemented."; + + opt3 = G_define_option(); + opt3->key = "seed"; + opt3->type = TYPE_INTEGER; + opt3->required = YES; + opt3->description = "Seed for the initialization (>=0), which specifies a starting point\n\t\tfor the random number sequence. Replicate same experiment."; + opt3->answer="0"; + + flag_c = G_define_flag(); + flag_c->key = 'c'; + flag_c->description = "selected method: cross-validation."; + + flag_b = G_define_flag(); + flag_b->key = 'b'; + flag_b->description = "selected method: bootstrap."; + + + if (G_parser(argc, argv)) + exit(1); + + + /*read parameters*/ + sscanf(opt2->answer,"%d",&n_sets); + if(n_sets<=0){ + sprintf(tmpbuf,"n_sets must be >0"); + G_fatal_error(tmpbuf); + } + + sscanf(opt3->answer,"%d",&seed); + if(seed<0){ + sprintf(tmpbuf,"seed must be >=0"); + G_fatal_error(tmpbuf); + } + + /*read features*/ + read_features(opt1->answer,&features,-1); + + + + if(flag_b->answer){ + tr_features=(Features*)calloc(n_sets,sizeof(Features)); + ts_features=(Features*)calloc(n_sets,sizeof(Features)); + + prob=(double*)calloc(features.nexamples,sizeof(double)); + for(i=0;ianswer,i+1); + write_features(fileout,&tr_features[i]); + + /*test*/ + n_non_extracted=0; + for(k=0;kanswer,i+1); + write_features(fileout,&ts_features[i]); + + } + free(prob); + free(random_labels); + free(non_extracted); + + return 0; + } + + + if(flag_c->answer){ + if(n_sets==1){ + tr_features=(Features*)calloc(features.nexamples,sizeof(Features)); + ts_features=(Features*)calloc(features.nexamples,sizeof(Features)); + + /*training*/ + for(i=0;ianswer,i+1); + write_features(fileout,&tr_features[i]); + + /*test*/ + ts_features[i].file=features.file; + ts_features[i].nexamples=1; + ts_features[i].examples_dim=features.examples_dim; + ts_features[i].value=(double**)calloc(1,sizeof(double*)); + ts_features[i].class=(int*)calloc(1,sizeof(int)); + ts_features[i].value[0]=features.value[i]; + ts_features[i].class[0]=features.class[i]; + + + ts_features[i].p_classes=features.p_classes; + ts_features[i].nclasses=features.nclasses; + ts_features[i].mean=features.mean; + ts_features[i].sd=features.sd; + ts_features[i].f_normalize=features.f_normalize; + ts_features[i].f_standardize=features.f_standardize; + ts_features[i].f_mean=features.f_mean; + ts_features[i].f_variance=features.f_variance; + ts_features[i].f_pca=features.f_pca; + ts_features[i].pca_class=features.pca_class; + ts_features[i].pca=features.pca; + ts_features[i].training=features.training; + ts_features[i].npc=features.npc; + ts_features[i].training.file="generated by i.pr_subsets"; + + sprintf(fileout,"%s__ts_l1ocv__%d",opt1->answer,i+1); + write_features(fileout,&ts_features[i]); + } + return 0; + }else{ + tr_features=(Features*)calloc(n_sets,sizeof(Features)); + ts_features=(Features*)calloc(n_sets,sizeof(Features)); + + if(n_sets>features.nexamples){ + sprintf(tmpbuf,"n_sets must be <= %d (=number of training data) if you want to use cross-validation",features.nexamples); + G_fatal_error(tmpbuf); + } + + probok=pow(1.-pow(1.-1./n_sets,(double)features.nexamples),(double)n_sets); + if(probok<0.95){ + sprintf(tmpbuf,"the probability of extracting %d non empty test sets is less than 0.95 (the probability is exactly %e). Sorry but I don't like to take this risk.",n_sets,probok); + G_fatal_error(tmpbuf); + } + + random_labels=(int*)calloc(features.nexamples,sizeof(int)); + for(i=0;ianswer,n_sets,i+1); + write_features(fileout,&tr_features[i]); + + + /*test*/ + n_non_extracted=0; + for(j=0;janswer,n_sets,i+1); + write_features(fileout,&tr_features[i]); + + } + free(random_labels); + return 0; + } + } + + return 0; +} Property changes on: trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig_2.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig_2.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig_2.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,423 @@ +#include "gis.h" +#include "global.h" +#include +#include +#include + +void write_matrix(); + +int main(argc, argv) + int argc ; + char **argv ; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + struct Flag *flag_c; + struct Flag *flag_b; + + Features features; + Features *tr_features; + Features *ts_features; + + char tmpbuf[500]; + int n_sets; + int i,j,k; + char fileout[500],filelab[500]; + FILE *flab; + double *prob; + int *random_labels,*non_extracted; + int n_non_extracted; + int n_extracted; + int extracted; + int indx; + int idum; + double probok; + int seed; + + char gisrc[500]; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + "/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1); + if(getenv("GISRC")==NULL){ + sprintf(gisrc,"/ssi0/ssi/%s/.grassrc5",getenv("LOGNAME")); + setenv("GISRC",gisrc,1); + } + + /* Initialize the GIS calls */ + G_gisinit(argv[0]) ; + + /* set up command line */ + opt1 = G_define_option(); + opt1->key = "features"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->description = "Input file containing the features (output of i.pr_features)."; + + opt2 = G_define_option(); + opt2->key = "n_sets"; + opt2->type = TYPE_INTEGER; + opt2->required = YES; + opt2->description = "Number of subsets (>=1). If you set n_sets=1 and select cross-validation,\n\t\tleave one out cv will be implemented."; + + opt3 = G_define_option(); + opt3->key = "seed"; + opt3->type = TYPE_INTEGER; + opt3->required = YES; + opt3->description = "Seed for the initialization (>=0), which specifies a starting point\n\t\tfor the random number sequence. Replicate same experiment."; + opt3->answer="0"; + + flag_c = G_define_flag(); + flag_c->key = 'c'; + flag_c->description = "selected method: cross-validation."; + + flag_b = G_define_flag(); + flag_b->key = 'b'; + flag_b->description = "selected method: bootstrap."; + + + if (G_parser(argc, argv)) + exit(1); + + + /*read parameters*/ + sscanf(opt2->answer,"%d",&n_sets); + if(n_sets<=0){ + sprintf(tmpbuf,"n_sets must be >0"); + G_fatal_error(tmpbuf); + } + + sscanf(opt3->answer,"%d",&seed); + if(seed<0){ + sprintf(tmpbuf,"seed must be >=0"); + G_fatal_error(tmpbuf); + } + + /*read features*/ + read_features(opt1->answer,&features,-1); + + + + if(flag_b->answer){ + sprintf(filelab,"%s__bootstrap__labels",opt1->answer); + flab=fopen(filelab,"w"); + + tr_features=(Features*)calloc(n_sets,sizeof(Features)); + ts_features=(Features*)calloc(n_sets,sizeof(Features)); + + prob=(double*)calloc(features.nexamples,sizeof(double)); + for(i=0;ianswer,i+1); + write_features(fileout,&tr_features[i]); + + fprintf (flab,"Training %d:\n",i+1); + + for (j=0;j<(tr_features[i].nexamples-1);j++){ + fprintf(flab,"%d\t",random_labels[j]+1); + } + fprintf(flab,"%d\n",random_labels[tr_features[i].nexamples-1]+1); + + /*test*/ + n_non_extracted=0; + for(k=0;kanswer,i+1); + write_features(fileout,&ts_features[i]); + + fprintf (flab,"Test %d:\n",i+1); + + for (j=0;j<(ts_features[i].nexamples-1);j++){ + fprintf(flab,"%d\t", non_extracted[j]+1); + } + fprintf(flab,"%d\n",non_extracted[ts_features[i].nexamples-1]+1); + + } + free(prob); + free(random_labels); + free(non_extracted); + + return 0; + } + + + if(flag_c->answer){ + if(n_sets==1){ + tr_features=(Features*)calloc(features.nexamples,sizeof(Features)); + ts_features=(Features*)calloc(features.nexamples,sizeof(Features)); + + /*training*/ + for(i=0;ianswer,i+1); + write_features(fileout,&tr_features[i]); + + /*test*/ + ts_features[i].file=features.file; + ts_features[i].nexamples=1; + ts_features[i].examples_dim=features.examples_dim; + ts_features[i].value=(double**)calloc(1,sizeof(double*)); + ts_features[i].class=(int*)calloc(1,sizeof(int)); + ts_features[i].value[0]=features.value[i]; + ts_features[i].class[0]=features.class[i]; + + + ts_features[i].p_classes=features.p_classes; + ts_features[i].nclasses=features.nclasses; + ts_features[i].mean=features.mean; + ts_features[i].sd=features.sd; + ts_features[i].f_normalize=features.f_normalize; + ts_features[i].f_standardize=features.f_standardize; + ts_features[i].f_mean=features.f_mean; + ts_features[i].f_variance=features.f_variance; + ts_features[i].f_pca=features.f_pca; + ts_features[i].pca_class=features.pca_class; + ts_features[i].pca=features.pca; + ts_features[i].training=features.training; + ts_features[i].npc=features.npc; + ts_features[i].training.file="generated by i.pr_subsets"; + + sprintf(fileout,"%s__ts_l1ocv__%d",opt1->answer,i+1); + write_features(fileout,&ts_features[i]); + } + return 0; + }else{ + sprintf(filelab,"%s__cv__labels",opt1->answer); + flab=fopen(filelab,"w"); + + tr_features=(Features*)calloc(n_sets,sizeof(Features)); + ts_features=(Features*)calloc(n_sets,sizeof(Features)); + + if(n_sets>features.nexamples){ + sprintf(tmpbuf,"n_sets must be <= %d (=number of training data) if you want to use cross-validation",features.nexamples); + G_fatal_error(tmpbuf); + } + + probok=pow(1.-pow(1.-1./n_sets,(double)features.nexamples),(double)n_sets); + if(probok<0.95){ + sprintf(tmpbuf,"the probability of extracting %d non empty test sets is less than 0.95 (the probability is exactly %e). Sorry but I don't like to take this risk.",n_sets,probok); + G_fatal_error(tmpbuf); + } + + random_labels=(int*)calloc(features.nexamples,sizeof(int)); + for(i=0;ianswer,n_sets,i+1); + write_features(fileout,&tr_features[i]); + + + /*test*/ + n_non_extracted=0; + for(j=0;janswer,n_sets,i+1); + write_features(fileout,&tr_features[i]); + + } + free(random_labels); + return 0; + } + } + + return 0; +} Property changes on: trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig_2.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/Makefile (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,14 @@ +MODULE_TOPDIR = ../../.. + +PRINCLUDE = ../include/ +EXTRA_CFLAGS = -I$(PRINCLUDE) +PRLIB = -lgrass_pr + +PGM = i.pr_training + +LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) +DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) + +include $(MODULE_TOPDIR)/include/Make/Module.make + +default: cmd Property changes on: trunk/grassaddons/i.pr/i.pr_training/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/conv.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/conv.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/conv.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,73 @@ +#include "globals.h" +int view_to_col(view,x) + View *view; + int x; +{ + return x - view->cell.left; +} + +int view_to_row(view,y) + View *view; + int y; +{ + return y - view->cell.top; +} + +int col_to_view(view,col) + View *view; +{ + return view->cell.left + col; +} + +int row_to_view(view,row) + View *view; +{ + return view->cell.top + row; +} + +void row_to_northing(cellhd,row,location, north) + struct Cell_head *cellhd; + double location; + double *north; +{ + *north = cellhd->north - (row + location) * cellhd->ns_res; +} + +void col_to_easting(cellhd,col,location, east) + struct Cell_head *cellhd; + double location; + double *east; + +{ + *east = cellhd->west + (col + location) * cellhd->ew_res; +} + + +void northing_to_row(cellhd,north,row) + struct Cell_head *cellhd; + double north; + int *row; +{ + *row = (cellhd->north - north) / cellhd->ns_res; +} + +void easting_to_col(cellhd,east,col) + struct Cell_head *cellhd; + double east; + int *col; +{ + *col = (east - cellhd->west) / cellhd->ew_res; +} + +void from_screen_to_geo(view, x, y, east, north) + View *view; + int x, y; + double *east, *north; +{ + int row, col; + + col = view_to_col (view, x); + col_to_easting (&view->cell.head, col, 0.5, east); + row = view_to_row (view, y); + row_to_northing (&view->cell.head, row, 0.5, north); +} Property changes on: trunk/grassaddons/i.pr/i.pr_training/conv.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/defs.h =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/defs.h (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/defs.h 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,19 @@ +#include "imagery.h" + +/* 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; + Property changes on: trunk/grassaddons/i.pr/i.pr_training/defs.h ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/globals.h =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/globals.h (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/globals.h 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,44 @@ +#include "defs.h" + +#ifndef GLOBAL +# define GLOBAL extern +# define INIT(x) +#else +# define INIT(x) = x +#endif + + +GLOBAL int G_get_color(); + +GLOBAL int SCREEN_TOP; +GLOBAL int SCREEN_BOTTOM; +GLOBAL int SCREEN_LEFT; +GLOBAL int SCREEN_RIGHT; + +GLOBAL View *VIEW_MAP1; +GLOBAL View *VIEW_TITLE1; +GLOBAL View *VIEW_MAP1_ZOOM; +GLOBAL View *VIEW_TITLE1_ZOOM; +GLOBAL View *VIEW_IMAGE; +GLOBAL View *VIEW_TITLE_IMAGE; +GLOBAL View *VIEW_INFO; +GLOBAL View *VIEW_EXIT; +GLOBAL View *VIEW_EMPTY; +GLOBAL View *VIEW_MENU; + +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] + + +#undef INIT Property changes on: trunk/grassaddons/i.pr/i.pr_training/globals.h ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/graphics.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/graphics.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/graphics.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,317 @@ +#include "globals.h" +#include "raster.h" +#include "D.h" +#include "display.h" +#include "loc_func.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; +} + + +void Init_graphics2() +{ + /* + R_color_table_fixed(); + */ + R_color_offset (0); + + Dscreen(); + + + 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, 100.0); + VIEW_TITLE_IMAGE = makeview (97.5, 100.0, 50.0, 100.0); + VIEW_MAP1 = makeview (0.0, 97.5, 0.0, 100.0); + VIEW_IMAGE = makeview (51.0, 97.5, 50.0, 100.0); + VIEW_TITLE1_ZOOM = makeview (47.5, 51.0, 0.0, 50.0); + VIEW_EMPTY = makeview (47.5, 51.0, 50.0, 100.0); + VIEW_MAP1_ZOOM = makeview (2.5, 47.5, 0.0, 50.0); + VIEW_EXIT = makeview (2.5, 5.0, 90.0, 100.0); + VIEW_INFO = makeview (7.5, 45.0, 52.5, 97.5); + VIEW_MENU = makeview (0.0, 2.5, 0.0, 100.0); + + G_init_colors (&VIEW_MAP1->cell.colors); + G_init_colors (&VIEW_IMAGE->cell.colors); +} + + +void Init_graphics() +{ + /* + R_color_table_fixed(); + */ + R_color_offset (0); + + Dscreen(); + + + 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_TITLE_IMAGE = makeview (97.5, 100.0, 50.0, 100.0); + VIEW_MAP1 = makeview (51.0, 97.5, 0.0, 50.0); + VIEW_IMAGE = makeview (51.0, 97.5, 50.0, 100.0); + VIEW_TITLE1_ZOOM = makeview (47.5, 51.0, 0.0, 50.0); + VIEW_EMPTY = makeview (47.5, 51.0, 50.0, 100.0); + VIEW_MAP1_ZOOM = makeview (2.5, 47.5, 0.0, 50.0); + VIEW_EXIT = makeview (2.5, 5.0, 90.0, 100.0); + VIEW_INFO = makeview (7.5, 45.0, 52.5, 97.5); + VIEW_MENU = makeview (0.0, 2.5, 0.0, 100.0); + + G_init_colors (&VIEW_MAP1->cell.colors); + G_init_colors (&VIEW_IMAGE->cell.colors); +} + +void Outline_box (top, bottom, left, 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); +} + + +int Text_width (text) + 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; +} + +void Text (text, top, bottom, left, right, edge) + char *text; +{ + 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); +} + +void Uparrow (top, bottom, left, 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); +} + +void Downarrow (top, bottom, left, 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); +} + +void display_map(cellhd, view, name, mapset) + struct Cell_head *cellhd; + View *view; + char *name; + char *mapset; +{ + + G_adjust_window_to_box (cellhd, &view->cell.head, view->nrows, + view->ncols); + Configure_view (view, name, mapset, cellhd->ns_res, cellhd->ew_res); + drawcell(view); +} + + +void drawcell(view) + View *view; +{ + int fd; + int left, top; + int ncols, nrows; + int row; + CELL *cell; + int repeat; + struct Colors *colors; + int read_colors; + char msg[100]; + + + 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_IMAGE->cell.colors; + read_colors = view == VIEW_IMAGE; + } + if (read_colors) + { + G_free_colors (colors); + if(G_read_colors (view->cell.name, view->cell.mapset, colors) < 0) + return 0; + } + + display_title (view); + + D_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; + + Outline_box (top, top+nrows-1, left, left+ncols-1); + + {char *getenv(); + if (getenv("NO_DRAW")) return 1; + } + + fd = G_open_cell_old (view->cell.name, view->cell.mapset); + if (fd < 0) + return 0; + cell = G_allocate_cell_buf(); + + /* + sprintf (msg, "Plotting %s ...", view->cell.name); + Menu_msg(msg); + */ + + for (row = 0; row < nrows; row += repeat) + { + R_move_abs (left, top+row); + if(G_get_map_row_nomask(fd, cell, row) < 0) + break; + repeat = G_row_repeat_nomask (fd, row); + D_raster (cell, ncols, repeat, colors); + } + G_close_cell (fd); + G_free (cell); + if(colors != &VIEW_MAP1->cell.colors) + D_set_colors(&VIEW_MAP1->cell.colors); + + return row==nrows; +} + +void exit_button() +{ + int size; + Erase_view (VIEW_EXIT); + R_standard_color (RED); + size = VIEW_EXIT->nrows - 4; + R_text_size (size, size); + Text ("exit", VIEW_EXIT->top, VIEW_EXIT->bottom, + VIEW_EXIT->left, VIEW_EXIT->right, 2); + R_standard_color (WHITE); +} + +void info_button() +{ + int size; + Erase_view (VIEW_INFO); + R_standard_color (GREEN); + size = VIEW_INFO->nrows/13; + R_text_size (size, size); + Text ("UPPER LEFT PANEL:", VIEW_INFO->top, VIEW_INFO->top+size, + VIEW_INFO->left, VIEW_INFO->right, 1); + R_standard_color (YELLOW); + Text ("left: mark 1", VIEW_INFO->top+size, VIEW_INFO->top+2*size, + VIEW_INFO->left, VIEW_INFO->right, 1); + Text ("left: mark 2", VIEW_INFO->top+2*size, + VIEW_INFO->top+3*size, VIEW_INFO->left, VIEW_INFO->right, 1); + Text ("", VIEW_INFO->top+4*size, + VIEW_INFO->top+5*size, VIEW_INFO->left, VIEW_INFO->right, 1); + R_standard_color (GREEN); + Text ("LOWER LEFT PANEL:", VIEW_INFO->top+5*size, + VIEW_INFO->top+6*size, VIEW_INFO->left, VIEW_INFO->right, 1); + R_standard_color (YELLOW); + Text ("left(double): select", VIEW_INFO->top+6*size, + VIEW_INFO->top+7*size, + VIEW_INFO->left, VIEW_INFO->right, 1); + Text ("", VIEW_INFO->top+8*size, + VIEW_INFO->top+9*size, VIEW_INFO->left, VIEW_INFO->right, 1); + R_standard_color (GREEN); + Text ("UPPER RIGHT PANEL:", VIEW_INFO->top+9*size, + VIEW_INFO->top+10*size, VIEW_INFO->left, VIEW_INFO->right, 1); + R_standard_color (YELLOW); + Text ("right(double): save", VIEW_INFO->top+10*size, + VIEW_INFO->top+11*size, VIEW_INFO->left, VIEW_INFO->right, 1); + R_standard_color (WHITE); +} Property changes on: trunk/grassaddons/i.pr/i.pr_training/graphics.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/loc_func.h =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/loc_func.h (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/loc_func.h 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,37 @@ +void Mouse_pointer(); +void display_one_point (); +int point_in_view(); +void rectangle(); +void point(); +int read_points_from_file(); +void display_title (); +void Configure_view (); +int In_view (); +void Erase_view (); +double magnification (); +void write_map(); +void compute_temp_region2(); +void compute_temp_region(); +void Outline_box (); +void Init_graphics2(); +void Init_graphics(); + +int Text_width(); +void Text (); +void Uparrow (); +void Downarrow (); +void display_map(); +void drawcell(); +void exit_button(); +void info_button(); + +void row_to_northing(); +void col_to_easting(); +void northing_to_row(); +void easting_to_col(); +void from_screen_to_geo(); +int view_to_col(); +int view_to_row(); +int col_to_view(); +int row_to_view(); +void dot(); Property changes on: trunk/grassaddons/i.pr/i.pr_training/loc_func.h ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/main.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/main.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,347 @@ +#define GLOBAL + +#include +#include "gis.h" +#include "raster.h" +#include "global.h" +#include "globals.h" +#include "func.h" +#include "loc_func.h" + +int main(argc, argv) + int argc ; + char **argv ; +{ + struct Option *opt1; + struct Option *opt2; + struct Option *opt3; + struct Option *opt4; + struct Option *opt5; + struct Option *opt6; + struct Option *opt7; + struct Cell_head cellhd, zoomed_cellhd, map_cellhd; + char *mapset[TRAINING_MAX_LAYERS]; + char *name[TRAINING_MAX_LAYERS]; + int nmaps; + char buf[256]; + int window_rows, window_cols; + FILE *fp; + int num_class; + int i,j; + Training training; + int X1,X2,Y1,Y2; + int x_screen1, y_screen1, button1; + int x_screen2, y_screen2, button2; + int other = TRUE; + double east, north, west, south; + double tempeast1, tempnorth1; + double tempeast2, tempnorth2; + char out_map[100]; + int orig_nexamples; + char opt1desc[500]; + char *vis_map; + char *vis_mapset; + + char gisrc[500]; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + "/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1); + if(getenv("GISRC")==NULL){ + sprintf(gisrc,"/ssi0/ssi/%s/.grassrc5",getenv("LOGNAME")); + setenv("GISRC",gisrc,1); + } + + /* Initialize the GIS calls */ + G_gisinit(argv[0]) ; + + sprintf(opt1desc,"Input raster maps (max %d) for extracting the training examples.\n\t\tThe first one will be used for graphical output in case vis_map option not set",TRAINING_MAX_LAYERS); + /* set up command line */ + opt1 = G_define_option(); + opt1->key = "map"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->gisprompt = "old,cell,raster" ; + opt1->description = opt1desc; + opt1->multiple = YES; + + opt7 = G_define_option(); + opt7->key = "vis_map"; + opt7->type = TYPE_STRING; + opt7->required = NO; + opt7->gisprompt = "old,cell,raster" ; + opt7->description = "Raster map for visualization."; + + opt4 = G_define_option() ; + opt4->key = "training"; + opt4->type = TYPE_STRING; + opt4->required = YES; + opt4->description= "Name of the output file containing the training raster maps.\n\t\tIf this file already exists, the new data will be appended\n\t\tto the end of the file."; + + opt6 = G_define_option() ; + opt6->key = "site_file"; + opt6->type = TYPE_STRING; + opt6->required = NO; + opt6->description= "Name of the site file containing labelled location.\n\t\tSubstitutes the interactive procedure of site selection."; + + opt2 = G_define_option(); + opt2->key = "rows"; + opt2->type = TYPE_INTEGER; + opt2->required = YES; + opt2->description = "Number of rows (required odd) of the training samples."; + + opt3 = G_define_option(); + opt3->key = "cols"; + opt3->type = TYPE_INTEGER; + opt3->required = YES; + opt3->description = "Number of columns (required odd) of the training samples."; + + opt5 = G_define_option() ; + opt5->key = "class"; + opt5->type = TYPE_INTEGER; + opt5->required = NO; + opt5->description= "Numerical label to be attached to the training examples.\n\t\tOption not required with the site_file option."; + + if (G_parser(argc, argv)) + exit(1); + + /* informations from command line */ + nmaps=0; + for (i = 0; name[nmaps] = opt1->answers[i]; i++){ + mapset[i] = G_find_cell2 (name[i], "") ; + if (mapset[i] == NULL){ + sprintf(buf,"Can't find raster map <%s>", name[i]); + G_fatal_error(buf) ; + } + nmaps += 1; + if(nmaps > TRAINING_MAX_LAYERS){ + sprintf(buf,"Too many raster maps\nMaximum number allowed = %d", + TRAINING_MAX_LAYERS); + G_fatal_error(buf) ; + } + } + + if(opt7->answer){ + vis_map=opt7->answer; + vis_mapset = G_find_cell2 (vis_map, "") ; + if (vis_mapset == NULL){ + sprintf(buf,"Can't find raster map <%s>", vis_map); + G_fatal_error(buf) ; + } + }else{ + vis_map=name[0]; + vis_mapset=mapset[0]; + } + + if(!opt6->answer && !opt5->answer){ + sprintf(buf,"Please select a class for the examples\n"); + G_fatal_error(buf); + } + if(!opt6->answer){ + sscanf (opt5->answer, "%d", &num_class); + } + if(opt6->answer && opt5->answer){ + sprintf(buf,"Option class ignored\nLabels will be directlly read from site file\n"); + G_warning(buf); + } + sscanf (opt2->answer, "%d", &window_rows); + sscanf (opt3->answer, "%d", &window_cols); + if(window_rows%2==0 || window_cols%2==0){ + sprintf(buf,"Number of rows and columns must be odd\n"); + G_fatal_error(buf); + } + + /*open output file and read/initialize training*/ + inizialize_training(&training); + if(fopen(opt4->answer,"r")==NULL){ + if((fp = fopen(opt4->answer,"w"))==NULL){ + sprintf(buf,"Can't open file %s for writing\n",opt4->answer); + G_fatal_error(buf); + } + fprintf(fp,"Data type:\n"); + fprintf(fp,"GrassTraining\n"); + fprintf(fp,"Number of layers:\n"); + fprintf(fp,"%d\n",nmaps); + fprintf(fp,"Label:\n"); + fprintf(fp,"%s\n",opt4->answer); + fprintf(fp,"Data:\n"); + for(i=0;ianswer,"a"))==NULL){ + sprintf(buf,"Can't open file %s for appending\n",opt4->answer); + G_fatal_error(buf); + } + read_training(opt4->answer,&training); + } + + if(!opt6->answer){ + R_open_driver(); + + /*inizialize monitor*/ + Init_graphics(); + exit_button(); + info_button(); + + /*get current region*/ + G_get_window (&cellhd); + + /*plot map*/ + display_map(&cellhd, VIEW_MAP1, vis_map, vis_mapset); + R_standard_color (RED); + for(i=0;itempeast2){ + east=tempeast1; + west=tempeast2; + }else{ + east=tempeast2; + west=tempeast1; + } + if(tempnorth1>tempnorth2){ + north=tempnorth1; + south=tempnorth2; + }else{ + north=tempnorth2; + south=tempnorth1; + } + compute_temp_region(&zoomed_cellhd,&cellhd,east,west,north,south); + Erase_view(VIEW_MAP1_ZOOM); + display_map(&zoomed_cellhd, VIEW_MAP1_ZOOM, vis_map, vis_mapset); + R_standard_color(RED); + for(i=0;icell.configured ){ + from_screen_to_geo(VIEW_MAP1_ZOOM, x_screen2, y_screen2, &east, + &north); + compute_temp_region2(&map_cellhd,&zoomed_cellhd,east,north, + window_rows, window_cols); + R_standard_color(BLUE); + display_one_point (VIEW_MAP1, east, north); + display_one_point (VIEW_MAP1_ZOOM, east, north); + display_map(&map_cellhd, VIEW_IMAGE, vis_map, vis_mapset); + R_flush(); + } + } + + if(In_view (VIEW_IMAGE, x_screen1, y_screen1) && + In_view (VIEW_IMAGE, x_screen2, y_screen2)){ + if(button1 == 3 && button2 == 3){ + if(VIEW_IMAGE->cell.configured ){ + training.nexamples += 1; + training.east[training.nexamples]=east; + training.north[training.nexamples]=north; + + R_standard_color (RED); + + display_one_point (VIEW_MAP1, training.east[training.nexamples], + training.north[training.nexamples]); + display_one_point (VIEW_MAP1_ZOOM, + training.east[training.nexamples], + training.north[training.nexamples]); + R_flush(); + for(i=0;ianswer, name[i],training.nexamples); + write_map(&map_cellhd, name[i], mapset[i], out_map); + fprintf(fp,"%s\t",out_map); + } + fprintf(fp,"%d\t%f\t%f\t%d\t%d\t%f\t%f\n",num_class, + training.east[training.nexamples], + training.north[training.nexamples], + window_rows, window_cols,cellhd.ew_res, + cellhd.ns_res); + } + } + } + } + }else{ + G_get_window (&cellhd); + R_open_driver(); + Init_graphics2(); + display_map(&cellhd, VIEW_MAP1, vis_map, vis_mapset); + + R_flush(); + orig_nexamples=training.nexamples; + if(read_points_from_file(&training,opt6->answer)==0){ + sprintf (buf, "Error readining site file <%s>", opt6->answer); + G_fatal_error(buf); + } + R_standard_color(BLUE); + for(i=0;ianswer, name[j],i+1); + write_map(&map_cellhd, name[j], mapset[j], out_map); + fprintf(fp,"%s\t",out_map); + } + fprintf(fp,"%d\t%f\t%f\t%d\t%d\t%f\t%f\n",training.class[i], + training.east[i], + training.north[i], + window_rows, window_cols,cellhd.ew_res, + cellhd.ns_res); + } + fclose(fp); + R_close_driver(); + return 0; + } + return 0; +} + Property changes on: trunk/grassaddons/i.pr/i.pr_training/main.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/mouse.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/mouse.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/mouse.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,13 @@ +#include "raster.h" +#include "globals.h" + + +void Mouse_pointer (x, y, button) + int *x, *y, *button; +{ + static int curx, cury; + + R_get_location_with_pointer (&curx, &cury, button); + *x = curx; + *y = cury; +} Property changes on: trunk/grassaddons/i.pr/i.pr_training/mouse.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/points.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/points.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/points.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,66 @@ +#include "raster.h" +#include "globals.h" +#include "loc_func.h" + +void display_one_point (view, east, north) + View *view; + double east, north; +{ + int row, col, x, y; + + /*TODO*/ + northing_to_row (&view->cell.head, north,&row);// + .5; + easting_to_col (&view->cell.head, east,&col);// + .5; + y = row_to_view (view, row); + x = col_to_view (view, col); + dot (x,y); +} + +void dot(x,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 point_in_view(view, east, north) + View *view; + double north, east; +{ + if((north <= view->cell.head.north) && + (north >= view->cell.head.south) && + (east <= view->cell.head.east) && + (east >= view->cell.head.west)) + return 1; + else + return 0; +} + +void rectangle(x_screen1,y_screen1,x_screen2,y_screen2) +{ + R_move_abs(x_screen1,y_screen1); + R_cont_abs(x_screen1,y_screen2); + R_cont_abs(x_screen2,y_screen2); + R_cont_abs(x_screen2,y_screen1); + R_cont_abs(x_screen1,y_screen1); +} + +void point(x,y) +{ + int vx[5], vy[5]; + + vx[0] = x; vy[0] = y - 2; + vx[1] = x - 2; vy[1] = y; + vx[2] = x; vy[2] = y + 2; + vx[3] = x + 2; vy[3] = y; + vx[4] = x; vy[4] = y - 2; + + R_polygon_abs (vx, vy, 5); +} + Property changes on: trunk/grassaddons/i.pr/i.pr_training/points.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/sites.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/sites.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/sites.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,47 @@ +#include "gis.h" +#include "global.h" +#include "globals.h" + + +int read_points_from_file(training,site_file) + Training *training; + char *site_file; +{ + char msg[256]; + char *mapset; + FILE *out; + Site *site; + int dims=0,cat=0,strs=0,dbls=0; + int code; + + mapset = G_find_file ("site_lists", site_file, ""); + if (mapset == NULL){ + sprintf (msg, "read_points_from_file-> Can't find sites file <%s>", site_file); + G_fatal_error (msg); + } + out = G_fopen_sites_old (site_file, mapset); + if (out == NULL){ + sprintf (msg, "read_points_from_file-> Can't open sites file <%s>", site_file); + G_fatal_error (msg); + } + if (G_site_describe (out, &dims, &cat, &strs, &dbls)!=0){ + sprintf (msg, "read_points_from_file-> Error in G_site_describe"); + G_warning(msg); + return 0; + } + site = (Site *) G_calloc(1,sizeof(Site)); + site = G_site_new_struct(0,dims, strs, dbls); + while((code=G_site_get(out, site )) > -1){ + training->east[training->nexamples] = site->east; + training->north[training->nexamples] = site->north; + training->class[training->nexamples] = site->ccat; + training->nexamples += 1; + } + fclose(out); + if(code != -1){ + sprintf (msg, "read_points_from_file-> Error in G_site_get"); + G_warning(msg); + return 0; + } + return 1; +} Property changes on: trunk/grassaddons/i.pr/i.pr_training/sites.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/title.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/title.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/title.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,46 @@ +#include "raster.h" +#include "globals.h" +#include "loc_func.h" + +void display_title (view) + View *view; +{ + View *title; + char center[100]; + int size; + double magnification(); + + *center = 0; + + if (view->cell.configured) + { + sprintf (center, "(mag %.1lf)", magnification (view)); + } + + if (view == VIEW_MAP1) + { + title = VIEW_TITLE1; + } + else if (view == VIEW_MAP1_ZOOM) + { + title = VIEW_TITLE1_ZOOM; + } + + if (view == VIEW_IMAGE) + { + title = VIEW_TITLE_IMAGE; + } + + Erase_view (title); + size = title->nrows - 4; + R_text_size (size, size); + if (*center) + { + R_standard_color (YELLOW); + Text (center, title->top, title->bottom, + (title->left + title->right - Text_width (center)) / 2, + title->right, 2); + } + R_standard_color (WHITE); + +} Property changes on: trunk/grassaddons/i.pr/i.pr_training/title.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/view.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/view.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/view.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,51 @@ +#include +#include "raster.h" +#include "globals.h" +#include "loc_func.h" + +void Configure_view (view, name, mapset, ns_res, ew_res) + View *view; + char *name, *mapset; + double ns_res, 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; +} + +int In_view (view, x, y) + View *view; +{ + return (x >= view->left && x <= view->right && y >= view->top && y <= view->bottom); +} + +void Erase_view (view) + View *view; +{ + R_standard_color (BLACK); + R_box_abs (view->left, view->top, view->right, view->bottom); +} + +double +magnification (view) + View *view; +{ + if (!view->cell.configured) + return ((double) 0.0); + return (view->cell.ew_res / view->cell.head.ew_res); +} Property changes on: trunk/grassaddons/i.pr/i.pr_training/view.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/write_map.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/write_map.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/write_map.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,72 @@ +#include +#include +#include +#include "globals.h" +#include "glocale.h" + +void write_map(cellhd, name, mapset, dest) + struct Cell_head *cellhd; + char *name; + char *mapset; + char *dest; +{ + int fd_to, fd_from, row, nrows, ncols; + CELL *buf; + char command[500]; + char *lp, *lm; + char *coldir; + struct stat statdir; + + G_set_window(cellhd); + + fd_from = G_open_cell_old(name, mapset); + if(fd_from < 0) + G_fatal_error(_("Error reading raster map <%s> in mapset <%s>"), + name, mapset); + + + fd_to = G_open_cell_new(dest); + if(fd_to < 0) + G_fatal_error(_("Error writing raster map <%s> in mapset <%s>"), + dest, G_mapset()); + + buf = G_allocate_raster_buf(CELL_TYPE); + + ncols = G_window_cols(); + nrows = G_window_rows(); + + for(row=0; rownorth = north; + temp_region->south = south; + temp_region->east = east; + temp_region->west = west; + temp_region->cols= (int)(temp_region->east - temp_region->west) / + region->ew_res; + temp_region->rows= (int)(temp_region->north - temp_region->south) / + region->ns_res; + temp_region->ns_res=region->ns_res; + temp_region->ew_res=region->ew_res; + + +} Property changes on: trunk/grassaddons/i.pr/i.pr_training/zoom.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_training/zoom2.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/zoom2.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_training/zoom2.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,17 @@ +#include "globals.h" + +void compute_temp_region2(struct Cell_head *temp_region, + struct Cell_head *region, + double east, + double north, + int window_rows, + int window_cols) +{ + *temp_region = *region; + temp_region->north = north + (double)window_rows / 2 * temp_region->ns_res ; + temp_region->south = north - (double)window_rows / 2 * temp_region->ns_res ; + temp_region->east = east + (double)window_cols / 2 * temp_region->ew_res ; + temp_region->west = east - (double)window_cols / 2 * temp_region->ew_res ; + temp_region->rows = window_rows; + temp_region->cols = window_cols; +} Property changes on: trunk/grassaddons/i.pr/i.pr_training/zoom2.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_uxb/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_uxb/Makefile (rev 0) +++ trunk/grassaddons/i.pr/i.pr_uxb/Makefile 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,14 @@ +MODULE_TOPDIR = ../../.. + +PRINCLUDE = ../include/ +EXTRA_CFLAGS = -I$(PRINCLUDE) +PRLIB = -lgrass_pr + +PGM = i.pr_uxb + +LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) +DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) + +include $(MODULE_TOPDIR)/include/Make/Module.make + +default: cmd Property changes on: trunk/grassaddons/i.pr/i.pr_uxb/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_uxb/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_uxb/main.c (rev 0) +++ trunk/grassaddons/i.pr/i.pr_uxb/main.c 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,467 @@ +#include "gis.h" +#include "global.h" +#include +#include +#include + + +int extract_array_with_null(); + +int main(argc,argv) +int argc; +char *argv[]; +{ + struct Option *opt1; + struct Option *opt2; + int model_type; + NearestNeighbor nn; + GaussianMixture gm; + Tree tree; + SupportVectorMachine svm; + BTree btree; + BSupportVectorMachine bsvm; + char tmpbuf[500]; + char *mapset; + struct Cell_head cellhd; + double ***matrix ; + DCELL *rowbuf; + DCELL *tf; + int *fd; + int r,c,l; + Features features; + int i,j; + int *space_for_each_layer; + double *wind_vect; + double *X; + int borderC,borderR,borderC_upper,dim; + double mean,sd; + int corrent_feature; + double *projected; + int *compute_features; + double **output_cell; + int set_null; + int n_input_map; + int R,C; + int last_row; + + char gisrc[500]; + + if(getenv("GISBASE")==NULL) + setenv("GISBASE", + "/mpa_sw/ssi/BIO/software/GRASS5.0.0/grass5bin_cvs/grass5",1); + if(getenv("GISRC")==NULL){ + sprintf(gisrc,"/ssi0/ssi/%s/.grassrc5",getenv("LOGNAME")); + setenv("GISRC",gisrc,1); + } + + /* Define the different options */ + + opt1 = G_define_option(); + opt1->key = "input_map"; + opt1->type = TYPE_STRING; + opt1->required = YES; + opt1->multiple = YES; + opt1->gisprompt = "old,cell,raster" ; + opt1->description = "Input raster maps to be classified.\n\t\tIt is required a number of maps at least equal to the number of maps\n\t\tused for the training. If this number is greater the last maps will be ignored.\n\t\tWARNING: the order in which the maps are given should be compared \n\t\twith that used for the training."; + + opt2 = G_define_option() ; + opt2->key = "model"; + opt2->type = TYPE_STRING; + opt2->required = YES; + opt2->description= "Input file containing the model (output of i .pr_model).\n\t\tIf the data used for model development are not GRASS_data the program will abort."; + + /***** Start of main *****/ + G_gisinit(argv[0]); + + if (G_parser(argc, argv) < 0) + exit(-1); + + /*read the model*/ + model_type=read_model(opt2->answer,&features,&nn,&gm,&tree, + &svm,&btree,&bsvm); + + if(features.training.data_type != GRASS_data){ + sprintf(tmpbuf,"Model build using othe than GRASS data\n"); + G_fatal_error(tmpbuf); + } + if(model_type==0){ + sprintf(tmpbuf,"Model not recognized\n"); + G_fatal_error(tmpbuf); + } + + if(model_type == GM_model){ + compute_test_gm(&gm); + } + + /* load current region */ + G_get_window (&cellhd); + if(fabs((cellhd.ew_res - features.training.ew_res)/ + features.training.ew_res)>0.1){ + sprintf(tmpbuf,"EW resolution of training data and test map differs more than 10%%\n"); + G_warning(tmpbuf); + } + if(fabs((cellhd.ns_res - features.training.ns_res)/ + features.training.ns_res)>0.1){ + sprintf(tmpbuf,"NS resolution of training data and test map differs more than 10%%\n"); + G_warning(tmpbuf); + } + + /*compute features space*/ + dim=features.training.rows*features.training.cols; + + space_for_each_layer=(int *)G_calloc(features.training.nlayers, + sizeof(int)); + compute_features=(int *)G_calloc(features.training.nlayers,sizeof(int)); + for(j=0;janswers[l];l++){ + if((mapset = G_find_cell2(opt1->answers[l], "")) == NULL){ + sprintf(tmpbuf,"raster map [%s] not available",opt1->answers[l]); + G_fatal_error(tmpbuf); + } + + if((fd[l] = G_open_cell_old(opt1->answers[l], mapset)) < 0){ + sprintf(tmpbuf,"error opening raster map [%s]", opt1->answers[l]); + G_fatal_error(tmpbuf); + } + n_input_map += 1; + } + + if(n_input_map < features.training.nlayers){ + sprintf(tmpbuf,"Model requires %d input maps\n", + features.training.nlayers); + G_fatal_error(tmpbuf); + } + if(n_input_map > features.training.nlayers){ + sprintf(tmpbuf,"Only first %d maps considered\n", + features.training.nlayers); + G_warning(tmpbuf); + } + + /*useful vars*/ + borderC=(features.training.cols-1)/2; + borderC_upper=cellhd.cols-borderC; + borderR=(features.training.rows-1)/2; + last_row=features.training.rows-1; + + + /*read first rows*/ + for(r=0;r\n",opt1->answers[l]); + G_fatal_error(tmpbuf); + } + for(c = 0; c < cellhd.cols; c++){ + if (G_is_d_null_value (tf)) + *tf = 0.0; + matrix[l][r][c] = *tf; + tf++; + } + } + G_free(rowbuf); + } + + /*computing...*/ + r=features.training.rows; + + while(r\n",opt1->answers[l]); + G_fatal_error(tmpbuf); + } + for(c = 0; c < cellhd.cols; c++){ + if (G_is_d_null_value (tf)) + *tf = 0.0; + matrix[l][last_row][c] = *tf; + tf++; + } + G_free(rowbuf); + } + } + r += 1; + } + /* + for(r=0;r 0){ + if(sites2[i].max>A*np+B) + fprintf(stdout,"%f|%f|#%d%s%f%s%f\n",sites2[i].east,sites2[i].north, + sites2[i].n, "%",sites2[i].min,"%",sites2[i].max); + } + + } + /* + for(j=0;j=1) + fprintf(stdout,"%f|%f|#%d%s%f\n",sites2[j].east,sites2[j].north, + sites2[j].n, "%",sites2[j].min); + */ + } + return 0; +} + +int extract_array_with_null(R,C,c,bc,mat,wind_vect) + int R,C,c,bc; + double **mat; + double *wind_vect; +{ + int i,j; + double sum; + int index; + + sum = 0.0; + index=0; + for(i = 0; i < R;i++){ + for(j = 0; j < C;j++){ + wind_vect[index]=mat[i][c - bc +j]; + sum += wind_vect[index++]; + } + } + if(sum == 0.0){ + return 1; + }else{ + return 0; + } +} Property changes on: trunk/grassaddons/i.pr/i.pr_uxb/main.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/include/func.h =================================================================== --- trunk/grassaddons/i.pr/include/func.h (rev 0) +++ trunk/grassaddons/i.pr/include/func.h 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,291 @@ +/* +tree.c +*/ + +void compute_tree(); +void write_tree(); +void compute_tree_boosting(); +void compute_tree_boosting_reg(); +void regularized_boosting(); +double test_regularized_boosting(); +void test_btree_reg(); +void shaving_and_compute(); +void compute_tree_bagging(); +void write_bagging_boosting_tree(); +int predict_tree_multiclass(); +double predict_tree_2class(); +void test_tree(); +double predict_btree_2class(); +int predict_btree_multiclass(); +void test_btree(); +void test_btree_progressive(); +double predict_btree_2class_progressive(); +int predict_btree_multiclass_progressive(); +void compute_tree_boosting_parallel(); + +/* +features_selection.c +*/ + +void compute_valoriDJ(); +void free_svm(); +void e_rfe_lin(); +void e_rfe_gauss(); +void one_rfe_lin(); +void one_rfe_gauss(); +void rfe_lin(); +void rfe_gauss(); +void write_matrix(); +void compute_H(); +void compute_H_perdiff(); +void traslo(); + +/* +soft_margin_boosting.c +*/ + +void maximize(); + +/* +write_matrix.c +*/ + +void write_matrix(); + +/* +entropy.c +*/ + +double Entropy(); +double clog(); +void histo(); +void histo1(); + +/* +min_quadratic.c +*/ + +void mqc(); + +/* +blob.c +*/ + +void extract_sites_from_blob(); +void find_blob(); + +/* +test.c +*/ + +void ksone_normal(); +void kstwo(); + double probks(); + double probks2(); +double normal_distribution(); +double cumulative_normal_distribution(); + double gammln(); + double betacf(); + double betai(); +void tutest(); + +/* +read_models.c +*/ + +int read_model(); + +/* +nn.c +*/ + +void compute_nn(); +void write_nn(); +int predict_nn_multiclass(); +double predict_nn_2class(); +void test_nn(); + +/* +svm.c +*/ + +void compute_svm(); +void estimate_cv_error(); +void write_svm(); +void test_svm(); +double predict_svm(); +void compute_svm_bagging(); +void write_bagging_boosting_svm(); +void compute_svm_boosting(); +double predict_bsvm(); +void test_bsvm(); +void test_bsvm_progressive(); +double predict_bsvm_progressive(); +double dot_product(); + +/* +features.c +*/ + +void compute_features(); +void write_features(); +void standardize_features(); +void write_header_features(); +void read_features(); +void read_header_features(); + +/* +gm.c +*/ + +void compute_gm(); +void write_gm(); +void test_gm(); +void compute_test_gm(); +int predict_gm_multiclass(); +double predict_gm_2class(); + +/* +training.c +*/ + +void inizialize_training(); +void read_training(); + +/* +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(); + +/* +pca.c +*/ + +void inizialize_pca(); +void write_pca(); +void read_pca(); + +/* +random.c +*/ + +double ran1(); +double gasdev(); +double gamdev(); +double expdev(); + +/* +bootstrap.c +*/ + +void Bootsamples(); +void Bootsamples_rseed(); + +/* +dist.c +*/ + +double squared_distance(); +double euclidean_distance(); +double scalar_product(); +double euclidean_norm(); + +/* +open.c +*/ + +int open_new_CELL(); +int open_new_DCELL(); + +/* +percent.c +*/ + +void percent (); + +/* +getline.c +*/ + +char *GetLine(); + +/* +sort.c +*/ + +void shell(); +void indexx_1(); + +/* +integration.c +*/ + +double trapzd(); +double trapzd1(); +double trapzd2(); +double qtrap(); +double qtrap1(); +double qtrap2(); + +/* +eigen.c +*/ + +void tred2(); +int tqli(); +void eigen_of_double_matrix(); +void eigsrt(); + +/* +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(); +double entropy(); +double gaussian_kernel(); +double squared_gaussian_kernel(); +double min(); +double max(); + +/* +lu.c +*/ + +void ludcmp(); +void lubksb(); +void inverse_of_double_matrix(); +double determinant_of_double_matrix(); + + + + + + + + + + + + + + + + + Property changes on: trunk/grassaddons/i.pr/include/func.h ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/include/func_help =================================================================== --- trunk/grassaddons/i.pr/include/func_help (rev 0) +++ trunk/grassaddons/i.pr/include/func_help 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,1624 @@ +######################### +features_selection.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + and Maria Serafini + + for + + Features Selction with SVM +*/ + +void compute_valoriDJ(svm,features,H_tot,H_tmp,valoriDJ) + SupportVectorMachine *svm; + Features *features; + double **H_tot,**H_tmp,**valoriDJ; +void free_svm(svm) + SupportVectorMachine *svm; +void e_rfe_lin(svm,features,names,selected,i,rimanenti,fp_fs_w,fp_fs_stats) + SupportVectorMachine *svm; + Features *features; + int *names, *selected; + int i; + int *rimanenti; + FILE *fp_fs_w,*fp_fs_stats; +void e_rfe_gauss(valoriDJ,features,names,selected,i,H_tot,H_tmp, + rimanenti,svm_kp,fp_fs_w,fp_fs_stats) + double *valoriDJ; + Features *features; + double **H_tot,**H_tmp; + int *names, *selected; + int i; + int *rimanenti; + double svm_kp; + FILE *fp_fs_w,*fp_fs_stats; +void one_rfe_lin(svm,names,selected,fp_fs_w) + SupportVectorMachine *svm; + int *names, *selected; + FILE *fp_fs_w; +void one_rfe_gauss(valoriDJ,names,selected,n,fp_fs_w) + double *valoriDJ; + int *names, *selected; + int n; + FILE *fp_fs_w; +void rfe_lin(svm,features,names,selected,i,fp_fs_w) + SupportVectorMachine *svm; + Features *features; + int *names, *selected; + int i; + FILE *fp_fs_w; +void rfe_gauss(valoriDJ,features,names,selected,i,H_tot,H_tmp,svm_kp,fp_fs_w) + Features *features; + double *valoriDJ; + int *names, *selected; + double **H_tot,**H_tmp; + int i; + double svm_kp; + FILE *fp_fs_w; +void write_matrix(outfile,matrix,r,c) + char *outfile; + double **matrix; + int r,c; +void compute_H(matrix,XX,y,ndati,nfeat,sigma) + double **matrix,**XX; + int *y; + double sigma; + int ndati,nfeat; +void compute_H_perdiff(Hvecchia,Hnuova,XX,ndati,sigma,featdaelim) + double **Hvecchia,**Hnuova,**XX; + double sigma; + int ndati,featdaelim; + + // featdaelim e' la variabile numerata come numera C (0...nfeat-1) +void traslo(x,n) + double *x; + int n; + +######################### +soft_margin_boosting.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + Soft Boosting implementation (quadratic programming) +*/ + +void maximize(alpha,N,beta,T,M) + double *alpha,*beta,**M; + int N,T; + +######################### +write_matrix.c +######################### + +void write_matrix(outfile,matrix,r,c) + char *outfile; + double **matrix; + int r,c; + +######################### +entropy.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + Entropy management +*/ + +double Entropy(data,n,zero) + double *data; + int n; + double zero; +double clog(x,zero) + double x; + double zero; +void histo(data,n,h,nbin) + double *data, *h; + int n,nbin; +void histo1(data,n,h,nbin) + double *data; + int n,nbin; + int *h; + + +######################### +min_quadratic.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + quadratic programming +*/ + +void mqc(M,m,n,H,h,mH,K,k,mK,eps,x,minvalue) + double **M,*m; + double **H,*h; + double **K,*k; + int n,mH,mK; + double eps; + double *x; + double *minvalue; +{ + int i,j,l; + + double **invM; + double **HM,**HMH,*tnH,**HMK,**KM,**KMK,*tnK,**tH,**tK; + double mMm; + double gap; + double *alpha,*beta; + double L,f; + double tmpalpha,tmpbeta,tmpL,tmpf; + + /*alloc memory*/ + invM=(double**)calloc(n,sizeof(double*)); + for(i=0;i0){ + HM=(double**)calloc(mH,sizeof(double*)); + for(i=0;i0 && mK>0){ + HMK=(double**)calloc(mH,sizeof(double*)); + for(i=0;i0){ + KM=(double**)calloc(mK,sizeof(double*)); + for(i=0;i0){ + product_double_matrix_double_matrix(H,invM,mH,n,n,HM); + product_double_matrix_double_matrix(HM,tH,mH,n,mH,HMH); + product_double_matrix_double_vector(HM,m,mH,n,tnH); + for(i=0;i0 && mK>0) + product_double_matrix_double_matrix(HM,tK,mH,n,mK,HMK); + + if(mK>0){ + product_double_matrix_double_matrix(K,invM,mK,n,n,KM); + product_double_matrix_double_matrix(KM,tK,mK,n,mK,KMK); + product_double_matrix_double_vector(KM,m,mK,n,tnK); + for(i=0;i0) + alpha=(double*)calloc(mH,sizeof(double)); + if(mK>0) + beta=(double*)calloc(mK,sizeof(double)); + + gap=eps+1; + /*gradient ascendent on the dual Lagrangian*/ + while(gap>eps){ + if(mH>0 && mK>0){ + for(l=0;l0) + tmpalpha += HMH[i][l]*alpha[i]; + + tmpalpha += tnH[l]; + + + for(i=0;i0) + tmpbeta += HMK[i][l]*alpha[i]; + + beta[l] -= tmpbeta/KMK[l][l]; + + } + }else if(mH>0 && mK==0){ + for(l=0;l0) + tmpalpha += HMH[i][l]*alpha[i]; + + tmpalpha += tnH[l]; + + alpha[l] -= tmpalpha/HMH[l][l]; + if(alpha[l] < .0) + alpha[l] = .0; + } + }else if(mH==0 && mK>0){ + for(l=0;l0) + for(j=0;j0) + tmpL += alpha[i]*alpha[j]*HMH[i][j]; + L -= .5*tmpL; + + tmpL=.0; + for(i=0;i0) + tmpL += alpha[i]*tnH[i]; + L -= tmpL; + + tmpL=.0; + for(i=0;i0) + for(j=0;j0) + tmpf += alpha[i]*tnH[i]; + f -= .5*tmpf; + + tmpf=.0; + for(i=0;i0) + x[l] +=HM[i][l]*alpha[i]; + + for(i=0;i0){ + free(alpha); + free(tnH); + for(i=0;i0){ + free(beta); + free(tnK); + for(i=0;i0 && mH>0){ + for(i=0;i= tm. npoints is just a counter of cells belonging to the blob. + nblobs is the total number of blobs.*/ + double **matrix; + int r,c; + Blob **blobs; + double tm,tM; + int *nblobs; + int *npoints; + +######################### +test.c +######################### + +/* + The following routines are borrowed from "Numerical Recipes in C" + and rearranged by Stefano Merler + + for + + statistical test computation + + Supported functions for: + - KS test the normal distribution of data + - KS test for equality of 2 distribution + - t-test for mean +*/ + +void ksone_normal(data,n,p1,p2,d,prob) + /* + KS test for normal distribution. data is the array of data + of length n. p1 and p2 mean and sd of the normal distribution + tested. On output d is the value of the test and prob + the p-value + */ + double *data,*d,*prob; + int n; + double p1,p2; + +void kstwo(data1,n1,data2,n2,d,prob) + /* + KS test for testing 2 distribution. data1 is the first + array of data of length n1. data2 is the second array + of data of length n2. On output d is the value of the + test and prob the p-value + */ + double *data1, *data2, *d, *prob; + int n1,n2; +double normal_distribution(x,mu,sigma) + /* + normal distribution with mean mu and + standard deviation sigma computed at point x + + 1/(sigma*sqrt(PIG) exp(-(x-mu)^2/2sigma^2) + */ + double x,mu,sigma; +double cumulative_normal_distribution(mu,sigma,x) + /* + cumulative probability of the normal + distribution with mean mu and + standard deviation sigma, i.e. + integral from -Inf to x + + */ + double mu,sigma,x; +void tutest(data1,n1,data2,n2,t,prob) + /* + */ + double *data1, *data2, *t, *prob; + int n1,n2; + +######################### +read_models.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + loading different model types +*/ + +int read_model(file,features,nn,gm,tree,svm,btree,bsvm) + /*read a model from file and fill the structure according to the + model type. Moreover load the features*/ + char *file; + NearestNeighbor *nn; + GaussianMixture *gm; + Tree *tree; + SupportVectorMachine *svm; + BTree *btree; + BSupportVectorMachine *bsvm; + Features *features; + +######################### +nn.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + structure NearestNeighbor management +*/ + +void compute_nn(nn,nsamples,nvar,data,data_class) + /* + Compute nn model, given a matrix of examples data of dimension + nsamples x nvar. Classes of each example are contained in data_class. + */ + NearestNeighbor *nn; + int nsamples,nvar; + double **data; + int *data_class; +void write_nn(file,nn,features) + /* + write nn structure to a file + */ + char *file; + NearestNeighbor *nn; + Features *features; +int predict_nn_multiclass(nn,x,k,nclasses,classes) + /* + multiclass problems: given a nn model, return the predicted class of a test point x + using k-nearest neighbor for the prediction. the array classes (of length nclasses) + shall contain all the possible classes to be predicted + */ + NearestNeighbor *nn; + double *x; + int k; + int *classes; + int nclasses; +double predict_nn_2class(nn,x,k,nclasses,classes) + /* + 2 class problems: given a nn model, return the majority of the class (with sign) + of a test point x using k-nearest neighbor for the prediction. + the array classes (of length nclasses) shall contain all the possible + classes to be predicted + */ + NearestNeighbor *nn; + double *x; + int k; + int *classes; + int nclasses; +void test_nn(nn,features,k,file) + /* + test nn model on a set of data (features) using k-nearest neighbor + and write the results into a file. To standard output accuracy + and error on each class + */ + NearestNeighbor *nn; + Features *features; + char *file; + int k; + +######################### +svm.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + structures SupportVectorMachine adn BSupportVectorMachine management +*/ + + +void compute_svm(svm,n,d,x,y,svm_kernel,svm_kp,svm_C,svm_tol,svm_eps, + svm_maxloops,svm_W) + SupportVectorMachine *svm; + int n,d; + double **x; + int *y; + int svm_kernel; + double svm_kp,svm_C,svm_tol,svm_eps; + int svm_maxloops; + double *svm_W; +void estimate_cv_error(SVM) + SupportVectorMachine *SVM; +void write_svm(file,svm,features) + /* + write svm structure to a file + */ + SupportVectorMachine *svm; + char *file; + Features *features; +void test_svm(svm,features,file) + /* + test svm model on a set of data (features) and write the results + into a file. To standard output accuracy and error on each class + */ + SupportVectorMachine *svm; + Features *features; + char *file; +double predict_svm(svm,x) + /* + given a svm model, return the predicted margin of a test point x + */ + SupportVectorMachine *svm; + double *x; +void compute_svm_bagging(bsvm,bagging,nsamples,nvar,data,data_class, + svm_kernel,kp,C,tol,eps,maxloops,svm_W) + BSupportVectorMachine *bsvm; + int bagging; + int nsamples,nvar; + double **data; + int *data_class; + int svm_kernel; + double kp; + double C; + double tol; + double eps; + int maxloops; + double *svm_W; +void write_bagging_boosting_svm(file,bsvm,features) + /* + write a bagging or boosting svm to a file + */ + char *file; + BSupportVectorMachine *bsvm; + Features *features; +void compute_svm_boosting(bsvm,boosting,w,nsamples,nvar,data,data_class, + nclasses,classes, svm_kernel,kp,C,tol,svm_eps, + maxloops,svm_W,weights_boosting) + + BSupportVectorMachine *bsvm; + int boosting; + double w; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; + int svm_kernel; + double kp; + double C; + double svm_eps; + double tol; + int maxloops; + double *svm_W; + int weights_boosting; + +double predict_bsvm(bsvm,x) + /* + given a bsvm model, return the predicted margin of a test point x + */ + BSupportVectorMachine *bsvm; + double *x; +void test_bsvm(bsvm,features,file) + /* + test bagging or boosting svm model on a set of data (features) + and write the results into a file. To standard output accuracy + and error on each class + */ + BSupportVectorMachine *bsvm; + Features *features; + char *file; +double dot_product(x,y,n) + double *x,*y; + int n; + + +######################### +features.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + structure Feature management +*/ +void compute_features(features) + /* + given a training structure in input, fill the features structure + according to specification lyke + features->f_mean + features->f_variance + features->f_pca + features->f_texture (not yet implemented) + */ + Features *features; + space_for_each_layer=(int *)G_calloc(features->training.nlayers, + sizeof(int)); + features->examples_dim = 0; + features->p_classes=(int *)realloc(features->p_classes, + features->nclasses * sizeof(int)); + features->p_classes[features->nclasses-1] = features->class[i]; + } + } + + /*space for pca*/ +void write_features(file,features) + /* + write the features into a file + */ + char *file; + Features *features; +void standardize_features(features) + /* + standardize fetures accordining to the fetures.f_standardize array + */ + Features *features; +void write_header_features(fp,features) + /* + write the header features into the pointed file + */ + FILE *fp; + Features *features; +void read_features(file,features,npc) + /* + read the features from a file. If pc structure is contained + within features, only load the first npc component. If npc < 0 + all the pc will be loaded. + */ + char *file; + Features *features; + int npc; + features->value[i]=(double *)G_calloc(features->examples_dim, + sizeof(double)); + } + features->class=(int *)G_calloc(features->nexamples,sizeof(int)); + + line=GetLine(fp); + line=GetLine(fp); +void read_header_features(fp,features) + /* + read the hearder features from the file pointed + */ + FILE *fp; + Features *features; + +######################### +gm.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + structure GaussianMixture management +*/ + +void compute_gm(gm,nsamples,nvar,data,data_class,nclasses,classes) + /* + Compute gm model, given a matrix of examples data of dimension + nsamples x nvar. Classes of each example are contained in data_class. + the array classes (of length nclasses) shall contain all the possible + classes of the array data_class + */ + GaussianMixture *gm; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; +void write_gm(file,gm,features) + /* + write gm structure to a file + */ + char *file; + GaussianMixture *gm; + Features *features; +void test_gm(gm,features,file) + /* + test gm model on a set of data (features) and write the results + into a file. To standard output accuracy and error on each class + */ + GaussianMixture *gm; + Features *features; + char *file; +void compute_test_gm(gm) + /* + compute inverse and determinant of each covariance matrix of a gm model + */ + GaussianMixture *gm; +int predict_gm_multiclass(gm,x) + /* + multiclass problems: given a gm model, return the predicted class + of a test point x + */ + GaussianMixture *gm; + double *x; +double predict_gm_2class(gm,x) + /* + 2 class problems: given a gm model , return the posterior of class (with sign) for + a test point x + */ + GaussianMixture *gm; + double *x; + +######################### +training.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + structure Training management +*/ + +void inizialize_training(training) + /* + alloc memory for training (see global.h for details) + */ + Training *training; +void read_training(file,training) + /* + read training structure from a file. Supported formats + GRASS_data:list of labelled raster maps + TABLE_data:list of labelled vecors + */ + char *file; + Training *training; + training->data[training->nexamples]=(double *)G_calloc(training->cols, + sizeof(double)); + +######################### +tree.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + structure Tree and BTree management +*/ + +void compute_tree(tree,nsamples,nvar,data,data_class,nclasses, + classes,stamps,minsize,costs) + /* + receives in input training data of dimensions nsamples x nvar, + with class labels data_class, the possible classes (of length nclasses) + and computes a tree model; optionally, the user can build stamps + and decide the minimal number of cases within a node as + stopping criteria. + */ + Tree *tree; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; + int stamps; + int minsize; + double *costs; +void write_tree(file,tree,features) + /* + write a tree model to a file + */ + char *file; + Tree *tree; + Features *features; +void compute_tree_boosting(btree,boosting,w,nsamples,nvar,data,data_class, + nclasses,classes, stamps,minsize,weights_boosting, + costs) + /* + receives in input training data of dimensions nsamples x nvar, + with class labels data_class, the possible classes (of length nclasses) + and computes a boosting tree model (number of models = boosting) using w + as parameter for the cost sensitive procedure; + optionally, the user can build stamps and decide the + minimal number of cases within a node as stopping criteria. + */ + BTree *btree; + int boosting; + double w; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; + int stamps; + int minsize; + int weights_boosting; + double *costs; +void compute_tree_bagging(btree,bagging,nsamples,nvar,data,data_class, + nclasses,classes,stamps,minsize,costs) + /* + receives in input training data of dimensions nsamples x nvar, + with class labels data_class, the possible classes (of length nclasses) + and computes a bagging tree model (number of models = bagging); + optionally, the user can build stamps and decide the + minimal number of cases within a node as stopping criteria. + */ + BTree *btree; + int bagging; + int nsamples,nvar; + double **data; + int *data_class; + int *classes; + int nclasses; + int stamps; + int minsize; + double *costs; +void write_bagging_boosting_tree(file,btree,features) + /* + write a bagging or boosting tree model to a file + */ + char *file; + BTree *btree; + Features *features; +int predict_tree_multiclass(tree,x) + /* + multiclass problems: given a tree model, return the predicted class + of a test point x + */ + Tree *tree; + double *x; +double predict_tree_2class(tree,x) + /* + 2 class problems: given a tree model, return the proportion of data + in the terminal node (with sign) of a test point x + */ + Tree *tree; + double *x; +void test_tree(tree,features,file) + /* + test a tree model on a set of data (features) and write the results + into a file. To standard output accuracy and error on each class + */ + Tree *tree; + Features *features; + char *file; +double predict_btree_2class(btree,x) + /* + for 2 classes problems: given a btree model, return the predicted + margin of a test point x + */ + BTree *btree; + double *x; +int predict_btree_multiclass(btree,x,nclasses,classes) + /* + for multiclasses problems: given a btree model, return the predicted + class of a test point x + */ + BTree *btree; + double *x; + int *classes; + int nclasses; +void test_btree(btree,features,file) + /* + test a btree model on a set of data + (features) and write the results into a file. To standard output + accuracy and error on each class + */ + BTree *btree; + Features *features; + char *file; + +######################### +matrix.c +######################### + +/* + 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 +*/ + +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; +void product_double_matrix_double_vector(x,y,r,cr,out) + /* + vector x matrix y * x, + 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; +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; +void transpose_double_matrix(x,n) + /* + transpose, and overwrite, the input matrix x + of dimension n x n + */ + double **x; + int n; +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; +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; +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; + +######################### +pca.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + structure Pca management +*/ + + +void inizialize_pca(pca,dim) + /* + alloc memory for Pca structure pca of dimension dim + */ + Pca *pca; + int dim; +void write_pca(fp,pca) + /* write a pca structure into the file pointed*/ + FILE *fp; + Pca *pca; +void read_pca(fp,pca) + /* raed a pca structure from the file pointed*/ + FILE *fp; + Pca *pca; + +######################### +random.c +######################### + +/* + The following routines are borrowed from "Numerical Recipes in C" + + for + + extraction of samples from normal and uniform distributions +*/ + +double ran1(idum) + /* + return a double from a uniform distributio over [0,1]. + Idum inizialize the procedure + */ + int *idum; +double gasdev(idum) + /* + return a double from a normal distribution (m=0, v=1). + Idum inizialize the procedure + */ + int *idum; + +######################### +bootstrap.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + bootstrap, probabily based, samples estraction +*/ + +void Bootsamples(n,prob,random_labels) + /* + given an array of probabilities of length n, extract a bootstrap sample + of n elements according to the vector of probabilities + */ + int n; + double *prob; + int *random_labels; + +void Bootsamples_rseed(n,prob,random_labels,idum) + /* + given an array of probabilities of length n, extract a bootstrap sample + of n elements according to the vector of probabilities + */ + int n; + double *prob; + int *random_labels; + int *idum; + + +######################### +dist.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + Distance between arrays computation +*/ + +double squared_distance(x,y,n) + /* + squared euclidean distance between vectors x and y of length n + */ + double *x; + double *y; + int n; +double euclidean_distance(x,y,n) + /* + euclidean distance between vectors x and y of length n + */ + double *x, *y; + int n; +double scalar_product(x,y,n) + /* + scalar product between vector x and y of length n + */ + double *x,*y; + int n; +double euclidean_norm(x,n) + /* + euclidean norm of a vector x of length n + */ + double *x; + int n; + +######################### +open.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + open new raster maps +*/ + +int open_new_CELL(name) + /* + open a new raster map of name name in CELL format + */ + char *name; +int open_new_DCELL(name) + /* + open a new raster map of name name in DELL format + */ + char *name; + +######################### +percent.c +######################### + +/* + The following routines are written and tested by Stefano Merler + + for + + status of a loop computation +*/ + +void percent (n,d,s) + /* + compute percentage (and print to stderr) + of work done within a loop. + n actual number, d total number, s step + */ + int n,d,s; + + +######################### +getline.c +######################### + +/* + The following routine is written and tested by Stefano Merler + + for + + getting a line from a buffered stream +*/ + +char *GetLine(fp) + /* + get a line from a buffered stream (pointed from fp) + */ + FILE *fp; + +######################### +sort.c +######################### + +/* + The following routines is borrowed from "Numerical Recipes in C" + + for + + sortinf of an array +*/ + +void shell(n,arr) + /* + sort and rearranges an array arr of length n + into ascending order + */ + double *arr; + int n; +void indexx_1(n,arrin,indx) + /* + sort array arrin of length n into ascending order, + without modify it. The order of the sording will be + contained into the indx array + */ + int n, indx[]; + double arrin[]; + +######################### +integration.c +######################### + +/* + Same of the following routines are borrowed from "Numerical Recipes in C" + other are written and tested by Stefano Merler + + for + + integration of function using the trapezoidal rule + + Supported function for + - non-parametric functions + - functions depending from 1 parameter + - functions depending from 2 parameters +*/ + + +double trapzd(func,a,b,n) + /* + trapezoidal rule for func=func(x) on interval [a,b] + n = steps number + */ + double a,b; + double (*func)(); + int n; +double trapzd1(func,p1,a,b,n) + /* + trapezoidal rule for func=func(x; p1) on interval [a,b] + p1 free parameter + n = steps number + */ + double a,b; + double p1; + double (*func)(); + int n; +double trapzd2(func,p1,p2,a,b,n) + /* + trapezoidal rule for func=func(x; p1,p2) on interval [a,b] + p1 and p2 free parameters + n = steps number + */ + double a,b; + double p1,p2; + double (*func)(); + int n; +double qtrap(func,a,b) + /* + trapezoidal rule for func=func(x) with stopping rule + */ + double a,b; + double (*func)(); +double qtrap1(func,p1,a,b) + /* + trapezoidal rule for func=func(x) on interval [a,b] + with internal stopping rule + p1 free parameter + */ + double a,b; + double p1; + double (*func)(); +double qtrap2(func,p1,p2,a,b) + /* + trapezoidal rule for func=func(x) on interval [a,b] + with internal stopping rule + p1 and p2 free parameters + */ + double a,b; + double p1,p2; + double (*func)(); + +######################### +eigen.c +######################### + +/* + Same of the following routines are borrowed from "Numerical Recipes in C" + other are written and tested by Stefano Merler + + for + + Eigenvalues and eigenvectors of simmetric matrices compution + and management +*/ + +void tred2(a,n,d,e) + /* + Houserholder method for reduction of simmetric n x n matrix a to + tridiagonal form: on output a contains the ortogonal transformation + matrix, d contains the diagonal elements, and e the off-diagonal. + */ + double **a,d[],e[]; + int n; +int tqli(d,e,n,z) + /* + QL algorithm: compute eigenvalues and eigenvectors + of simmetric tridiagonal matrix. On input, d diagonal + and e off-diagonal elements of the matrix (usually the + output of tred2), z the matrix output of tred2. + On output d eigenvalues, z eigenvectors. + */ + double d[],e[],**z; + int n; +void eigen_of_double_matrix(M, Vectors, lambda, n) + /* + Computes eigenvalues (and eigen vectors if desired) for + symmetric matrix M of dimension n x n. + Vectors and lambda contain the (obvious) output. + */ + double **M; + double **Vectors; + double *lambda; + int n; +void eigsrt(d,z,bands) + /* sort eigenvalues d in descending order, and rearranges + eigenvectors z correspondingly. bands contains the number + of eigenvalues = rows of z = cols of z + */ + double *d,**z; + long bands; + +######################### +stats.c +######################### + +/* + The following routing are written and tested by Stefano Merler + + for + + statistical description of data + + Supported function for: + - mean computation + - standard deviation and variance computation + - autocovariance computation + - covariance matrix computation + -min-max of an array +*/ + +double mean_of_double_array(x,n) + /* + compute the mean of an array x of lenth n + */ + double *x; + int n; +double var_of_double_array(x,n) + /* + compute the var of an array x of length n + */ + double *x; + int n; +double sd_of_double_array(x,n) + /* + compute the sd of an array x of length n + */ + double *x; + int n; +double var_of_double_array_given_mean(x,n,mean) + /* + compute the var of an array x of length n + without computation of the mean mean, + given in input + */ + double *x; + double mean; + int n; +double sd_of_double_array_given_mean(x,n,mean) + /* + compute the sd of an array x of length n + without computation of the mean, + given in input + */ + double *x; + double mean; + int n; +void mean_and_var_of_double_matrix_by_row(x,n,m,mean,var) + /* + each row of the input matrix x (dimension n x m) + is considered an independent array of data. + The function compute mean and var of each row, + stored within the array mean and var. + */ + double **x; + int n; + int m; + double *mean; + double *var; +void mean_and_sd_of_double_matrix_by_row(x,n,m,mean,sd) + /* + each row of the input matrix x (dimension n x m) + is considered an independent array of data. + The function compute mean and sd of each row, + stored within the array mean and sd. + */ + double **x; + int n; + int m; + double *mean; + double *sd; +void mean_and_var_of_double_matrix_by_col(x,n,m,mean,var) + /* + each col of the input matrix x (dimension n x m) + is considered an independent array of data. + The function compute mean and var of each col, + stored within the array mean and sd. + */ + double **x; + int n; + int m; + double *mean; + double *var; +void mean_and_sd_of_double_matrix_by_col(x,n,m,mean,sd) + /* + each col of the input matrix x (dimension n x m) + is considered an independent array of data. + The function compute mean and sd of each col, + stored within the array mean and sd. + */ + double **x; + int n; + int m; + double *mean; + double *sd; +double auto_covariance_of_2_double_array(x,y,n) + /* + compute the auto covariance of 2 array x and y of length n + */ + double *x; + double *y; + int n; +void covariance_of_double_matrix(x,n,m,cov) + /* + compute covariance matrix of a matrix x of dimension n x m. + Output to matrix cov. + */ + double **x; + double **cov; + int n,m; +double entropy(p,n) + /* + compute and return entropy of an array p (his components to be intended + as proportions) of length n + */ + double *p; + int n; +double gaussian_kernel(x,y,n,kp) + /* + compute e return gaussian kernel exp(-sqrt(||x-y||)/kp), + x and y array of length n + */ + double *x,*y; + int n; + double kp; +double squared_gaussian_kernel(x,y,n,kp) + /* + compute e return gaussian kernel exp(-||x-y||/kp), + x and y array of length n + */ + double *x,*y; + int n; + double kp; +double min(x,n) + double *x; + int n; +double max(x,n) + double *x; + int n; + +######################### +lu.c +######################### + +/* + Same 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 +*/ + +void ludcmp(a,n,indx,d) + /* + LU decomposition of n x n matrix a. + */ + int n,*indx; + double **a,*d; +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; +void inverse_of_double_matrix(A,inv_A,n) + /* + Inverse of a matrix A of dimension n x n. + Output stored in inv_A + */ + double **A,**inv_A; + int n; +double determinant_of_double_matrix(A,n) + /* + determinant of a double matrix A of dimension n x n + */ + double **A; + int n; Added: trunk/grassaddons/i.pr/include/global.h =================================================================== --- trunk/grassaddons/i.pr/include/global.h (rev 0) +++ trunk/grassaddons/i.pr/include/global.h 2007-05-31 23:49:13 UTC (rev 763) @@ -0,0 +1,233 @@ +#include +#include +#include "func.h" + +#define PIG 3.141593 + +#define TRUE 1 +#define FALSE 0 + +#define TRAINING_MAX_INPUTFILES 50 +#define TRAINING_MAX_LAYERS 25 +#define TRAINING_MAX_EXAMPLES 100000 +#define BUFFSIZE 500000 /* MAX NUMBER OF BITES FOR EACH ROW*/ + +#define NN_model 1 +#define GM_model 2 +#define CT_model 3 +#define SVM_model 4 +#define BCT_model 5 +#define BSVM_model 6 + +#define GRASS_data 1 +#define TABLE_data 2 + +#define SVM_KERNEL_LINEAR 1 +#define SVM_KERNEL_GAUSSIAN 2 +#define SVM_KERNEL_DIRECT 3 + + +#define FS_RFE 1 +#define FS_E_RFE 2 +#define FS_ONE_RFE 3 +#define FS_SQRT_RFE 4 + +typedef struct +{ + char *file; /*source data*/ + int data_type; /*GRASS_data or TABLE_data*/ + int nlayers; /*number of layers (for GRASS_data)*/ + int nexamples; /*number of examples*/ + char ***mapnames; /*name of the raster maps (for GRASS_data) + nlayers maps in each row*/ + int *class; /*class label of the examples*/ + double *east; /*east coordinate of centers of the maps (for GRASS_data)*/ + double *north; /*north coordinate of centers of the maps (for GRASS_data)*/ + double **data; /*matrix of data (for TABLE_data)*/ + double ew_res; /*resolution e-w (for GRASS_data)*/ + double ns_res; /*resolution n-s (for GRASS_data)*/ + int rows; /*rows of the examples (1 for for GRASS_data)*/ + int cols; /*number of colums of the examples*/ +} Training; + +typedef struct +{ + int n; /*number of elements*/ + 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*/ +} Pca; + + +typedef struct +{ + char *file; /*source data*/ + int nexamples; /*number of examples*/ + int examples_dim; /*dimension of the examples*/ + double **value; /*matrix of the data*/ + int *class; /*class labels*/ + int *p_classes; /*all the class present in the class array*/ + int nclasses; /*number of classes*/ + double *mean; /*mean of the vars (in case of standardization)*/ + double *sd;/*sd of the vars (in case of standardization)*/ + int *f_normalize; /*for normalising a datum: TRUE or FALSE*/ + int *f_standardize; /*for standardize variables: TRUE or FALSE*/ + int *f_mean; /*for computing the mean of a datum: TRUE or FALSE*/ + int *f_variance; /*for computing the variance of a datum: TRUE or FALSE*/ + int *f_pca; /*for computing pc on the data: TRUE or FALSE*/ + int *pca_class; /*use only this classes for computing the pc*/ + Pca *pca; /*the pc structure (if f_pca)*/ + Training training; /*some information regarding training data*/ + int npc; /* number of pc to be (eventually) used for the model development*/ +} Features; + + +typedef struct +{ + double **data; /*data contained into the node*/ + int *classes; /*classes of the data*/ + int npoints; /*number of data into the data*/ + int nvar; /*dimension of the data*/ + int nclasses; /*number of classes*/ + int *npoints_for_class; /*number of elements for each class*/ + double *priors; /*prior probabilities for each class*/ + int class; /*class associated to the ciurrent node*/ + int terminal; /*is the node terminal? TRUE or FALSE*/ + int left; /*his left child*/ + int right; /*his right child*/ + int var; /*variable used to split this node (if not terminal)*/ + double value; /*value of the variable for splitting the data*/ +} Node; + +typedef struct +{ + Node *node; /*the nodes*/ + int nnodes; /*number of nodes*/ + int stamps; /*if it is stamps: TRUE or FALSE*/ + int minsize; /*minsize for splitting a node*/ + Features features; /*the features used for the model development*/ +} Tree; + +typedef struct +{ + Tree *tree; /*the trees*/ + int ntrees; /*number of trees*/ + double *weights; /*their wieghts*/ + double w; /*cost-sensitive parameter use (for boosting)*/ + double **w_evolution; + Features features; /*the features used for the model development*/ +} BTree; + +typedef struct +{ + int nclasses; /*number of classes*/ + int *classes; /*array of the class names*/ + int *npoints_for_class; /*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*/ + Features features; /*the features used for the model development*/ +} GaussianMixture; + +typedef struct +{ + int nsamples; /*number of examples*/ + int nvars; /*number of variables*/ + double **data; /*the data*/ + int *class; /*their classes*/ + int k; + Features features; /*the features used for the model development*/ +} NearestNeighbor; + +typedef struct +{ + int d; + int i1; + double *x1; + int y1; + int i2; + double *x2; + int y2; + double w_coeff; + double b; +} SVM_direct_kernel; + +typedef struct +{ + int N;/*number of examples*/ + int d;/*number of features*/ + int orig_d; + double C;/*bias/variance parameter*/ + double tolerance;/*tolerance for testing KKT conditions*/ + double eps;/*convergence parameters:used in both takeStep and mqc functions*/ + double two_sigma_squared;/*kernel parameter*/ + double *alph;/*lagrangian coefficients*/ + double b;/*offset*/ + double *w;/*hyperplane parameters (linearly separable case)*/ + double *error_cache;/*error for each training point*/ + double **dense_points;/*training data*/ + int *target;/*class labels*/ + int kernel_type;/*kernel type:1 linear, 2 gaussian, 3 squared gaussian*/ + int end_support_i;/*set to N, never changed*/ + double (*learned_func)();/*the SVM*/ + double (*kernel_func)();/*the kernel*/ + double delta_b;/*gap between old and updated offset*/ + double *precomputed_self_dot_product;/*squared norm of the training data*/ + double *Cw;/*weighted bias/variance parameter (sen/spe tuning)*/ + SVM_direct_kernel *models; + double **dot_prod; + double **H; + int n_direct_kernel; + int non_bound_support;/*number of non bound SV*/ + int bound_support;/*number of bound SV*/ + int maxloops; + int convergence; + int verbose; + double cost; /*sen/spe cost (only for single svm)*/ + Features features; /*the features used for the model development*/ +} SupportVectorMachine; + + +typedef struct +{ + SupportVectorMachine *svm; /*the svm*/ + int nsvm; /*number of svm*/ + double *weights; /*their weights*/ + double w; /*cost-sensitive parameter use (for boosting)*/ + double **w_evolution; + Features features; /*the features used for the model development*/ +} BSupportVectorMachine; + +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*/ + double max; /*minimum value of the blob*/ + int n; /*number of points whitin the blob*/ +} BlobSites; + Property changes on: trunk/grassaddons/i.pr/include/global.h ___________________________________________________________________ Name: svn:eol-style + native From neteler at grass.itc.it Fri Jun 1 01:52:28 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Fri Jun 1 01:52:30 2007 Subject: [grass-addons] r764 - trunk/grassaddons/i.pr Message-ID: <200705312352.l4VNqS5u004260@grass.itc.it> Author: neteler Date: 2007-06-01 01:52:26 +0200 (Fri, 01 Jun 2007) New Revision: 764 Modified: trunk/grassaddons/i.pr/Makefile Log: restored orig path (best compiled under grass63/imagery/. i.pr still needs lots of updates to GRASS 6) Modified: trunk/grassaddons/i.pr/Makefile =================================================================== --- trunk/grassaddons/i.pr/Makefile 2007-05-31 23:49:13 UTC (rev 763) +++ trunk/grassaddons/i.pr/Makefile 2007-05-31 23:52:26 UTC (rev 764) @@ -1,5 +1,4 @@ -#MODULE_TOPDIR = ../.. -MODULE_TOPDIR = /home/neteler/grass63 +MODULE_TOPDIR = ../.. include $(MODULE_TOPDIR)/include/Make/Dir.make From landa at grass.itc.it Fri Jun 1 12:37:24 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Fri Jun 1 12:37:27 2007 Subject: [grass-addons] r765 - trunk/grassaddons/gui/gui_modules Message-ID: <200706011037.l51AbOA4011137@grass.itc.it> Author: landa Date: 2007-06-01 12:37:21 +0200 (Fri, 01 Jun 2007) New Revision: 765 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/menuform.py trunk/grassaddons/gui/gui_modules/toolbars.py trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Various minor fixes (concerning with AddBarscale, etc) Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-05-31 23:52:26 UTC (rev 764) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-01 10:37:21 UTC (rev 765) @@ -310,7 +310,7 @@ w,h = self.GetFullTextExtent(img[0])[0:2] pdc.SetFont(img[1]) pdc.SetTextForeground(img[2]) - coords,w,h = self.textBounds(img,coords) + coords,w,h = self.TextBounds(img,coords) if rotation == 0: pdc.DrawText(img[0], coords[0], coords[1]) else: @@ -321,21 +321,28 @@ pdc.EndDrawing() self.Refresh() - def textBounds(self, textinfo, coords): + def TextBounds(self, textinfo, coords): + """ + Return text boundary data + """ rotation = float(textinfo[3]) + + Debug.msg (4, "BufferedWindow.TextBounds(): text=%s, rotation=%f" % \ + (textinfo[0], rotation)) + self.Update() self.Refresh() self.SetFont(textinfo[1]) w,h = self.GetTextExtent(textinfo[0]) if rotation == 0: coords[2], coords[3] = coords[0] + w, coords[1] + h - return coords,w,h + return coords, w, h else: boxh = math.fabs(math.sin(math.radians(rotation)) * w) + h boxw = math.fabs(math.cos(math.radians(rotation)) * w) + h coords[2] = coords[0] + boxw coords[3] = coords[1] + boxh - return coords,boxw,boxh + return coords, boxw, boxh def OnPaint(self, event): """ @@ -636,8 +643,12 @@ """ Left mouse button pressed """ - Debug.msg (5, "BufferedWindow.OnLeftDown():") - if self.mouse["use"] == "measure" or self.mouse["use"] == "profile": + Debug.msg (5, "BufferedWindow.OnLeftDown(): use=%s" % \ + self.mouse["use"]) + + if self.mouse["use"] == "measure" or self.mouse["use"] == "profile" or \ + (self.mouse["use"] == "pointer" and self.parent.digittoolbar): + # measure || profile || digit tool if len(self.polycoords) == 0: self.mouse['begin'] = event.GetPositionTuple()[:] self.mouse['end'] = self.mouse['begin'] @@ -645,11 +656,9 @@ self.ClearLines() else: self.mouse['begin'] = self.mouse['end'] - else: - # get decoration id + else: # get decoration id self.lastpos = self.mouse['begin'] = event.GetPositionTuple()[:] - # idlist = self.pdc.FindObjectsByBBox(self.lastpos[0],self.lastpos[1]) - idlist = self.pdc.FindObjects(self.lastpos[0],self.lastpos[1], self.hitradius) + idlist = self.pdc.FindObjects(x=self.lastpos[0], y=self.lastpos[1], radius=self.hitradius) if idlist != []: self.dragid = idlist[0] @@ -657,75 +666,79 @@ """ Left mouse button released """ - Debug.msg (5, "BufferedWindow.OnLeftUp():") - # end point of zoom box or drag + Debug.msg (5, "BufferedWindow.OnLeftUp(): use=%s" % \ + self.mouse["use"]) + if self.mouse['use'] == "zoom" or self.mouse['use'] == "pan": - + # end point of zoom box or drag self.mouse['end'] = event.GetPositionTuple()[:] # set region in zoom or pan self.Zoom(self.mouse['begin'], self.mouse['end'], self.zoomtype) + # redraw map self.render=True self.UpdateMap() - - # querying elif self.mouse["use"] == "query": - self.Parent.QueryMap(self.mouse['begin'][0],self.mouse['begin'][1]) - - # creating measurement line - elif self.mouse["use"] == "measure" or self.mouse["use"] == "profile": + # querying + self.parent.QueryMap(self.mouse['begin'][0],self.mouse['begin'][1]) + elif self.mouse["use"] == "measure" or self.mouse["use"] == "profile" or \ + (self.mouse["use"] == "pointer" and self.parent.digittoolbar): + # measure || profile || digit tool self.mouse['end'] = event.GetPositionTuple()[:] if self.mouse["use"] == "measure": - self.Parent.MeasureDist(self.mouse['begin'],self.mouse['end']) + self.parent.MeasureDist(self.mouse['begin'],self.mouse['end']) try: self.polycoords.append(self.mouse['end']) self.pdc.ClearId(self.lineid) self.DrawLines() except: pass - - # end drag of overlay decoration elif self.dragid != None: + # end drag of overlay decoration self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid) self.dragid = None self.currtxtid = None id = None self.Update() - # digitizing - elif self.parent.digittoolbar: - if self.parent.digittoolbar.action == "add": - try: - map = self.parent.digittoolbar.layers[self.parent.digittoolbar.layerID].name - except: - map = None - dlg = wx.MessageDialog(self, _("No vector map layer selected for editing"), - _("Error"), wx.OK | wx.ICON_ERROR) - dlg.ShowModal() - dlg.Destroy() - if map: - east, north = self.Pixel2Cell(self.mouse['begin'][0],self.mouse['begin'][1]) - if self.parent.digittoolbar.type in ["point", "centroid"]: - # add new point - Digit.AddPoint(map=map, - type=self.parent.digittoolbar.type, - x=east, y=north) - elif self.parent.digittoolbar.type in ["line", "boundary"]: - # add new point to the line - Debug.msg (3, "BufferedWindow.MouseAction(): new saved pos=%f,%f" % (east, north)) - self.savedpos.append ((east, north)) +# # digitizing +# elif self.parent.digittoolbar: +# if self.parent.digittoolbar.action == "add": +# try: +# map = self.parent.digittoolbar.layers[self.parent.digittoolbar.layerID].name +# except: +# map = None +# dlg = wx.MessageDialog(self, _("No vector map layer selected for editing"), +# _("Error"), wx.OK | wx.ICON_ERROR) +# dlg.ShowModal() +# dlg.Destroy() - # redraw map - self.render=True - self.UpdateMap() +# if map: +# east, north = self.Pixel2Cell(self.mouse['begin'][0],self.mouse['begin'][1]) +# if self.parent.digittoolbar.type in ["point", "centroid"]: +# # add new point +# Digit.AddPoint(map=map, +# type=self.parent.digittoolbar.type, +# x=east, y=north) +# elif self.parent.digittoolbar.type in ["line", "boundary"]: +# # add new point to the line +# Debug.msg (3, "BufferedWindow.MouseAction(): new saved pos=%f,%f" % (east, north)) +# self.savedpos.append ((east, north)) +# # redraw map +# self.render=True +# self.UpdateMap() + def OnButtonDClick(self, event): """ Mouse button double click """ - Debug.msg (5, "BufferedWindow.OnButtonDClick():") + Debug.msg (5, "BufferedWindow.OnButtonDClick(): use=%s" % \ + self.mouse["use"]) + if self.mouse["use"] == "measure": + # measure self.ClearLines() self.polycoords = [] self.mouse['use'] = 'pointer' @@ -734,6 +747,7 @@ self.Refresh() self.SetCursor(self.parent.cursors["default"]) elif self.mouse["use"] == "profile": + # profile pass # self.pdc.ClearId(self.lineid) # self.pdc.ClearId(self.plineid) @@ -752,7 +766,7 @@ self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid) if self.dragid > 100: self.currtxtid = self.dragid - self.parent.addText(None) + self.parent.AddText(None) elif self.dragid == 0: self.parent.AddBarscale(None) elif self.dragid == 1: @@ -762,13 +776,16 @@ """ Right mouse button pressed """ - Debug.msg (5, "BufferedWindow.OnRightDown():") + Debug.msg (5, "BufferedWindow.OnRightDown(): use=%s" % \ + self.mouse["use"]) + x,y = event.GetPositionTuple()[:] - #l = self.pdc.FindObjectsByBBox(x, y) - l = self.pdc.FindObjects(x, y, self.hitradius) + l = self.pdc.FindObjects(x=x, y=y, radius=self.hitradius) if not l: return + id = l[0] + if id != 99: if self.pdc.GetIdGreyedOut(id) == True: self.pdc.SetIdGreyedOut(id, False) @@ -783,7 +800,9 @@ """ Right mouse button released """ - Debug.msg (5, "BufferedWindow.OnRightUp():") + Debug.msg (5, "BufferedWindow.OnRightUp(): use=%s" % \ + self.mouse["use"]) + if self.parent.digittoolbar and self.parent.digittoolbar.action == "add": if self.parent.digittoolbar.type in ["line", "boundary"]: try: @@ -813,8 +832,9 @@ self.pdc.ClearId(self.lineid) self.pdc.ClearId(self.plineid) self.Refresh() + return True except: - pass + return False def Pixel2Cell(self, x, y): @@ -826,6 +846,7 @@ """ newx = self.Map.region['w'] + x * self.Map.region["ewres"] newy = self.Map.region['n'] - y * self.Map.region["nsres"] + return newx, newy def Zoom(self, begin, end, zoomtype): @@ -850,16 +871,14 @@ # zoom out elif zoomtype < 0: - newreg['w'], newreg['n'] = self.Pixel2Cell(-x1*2,-y1*2) - newreg['e'], newreg['s'] = self.Pixel2Cell( - self.Map.width+2*(self.Map.width-x2), - self.Map.height+2*(self.Map.height-y2)) + newreg['w'], newreg['n'] = self.Pixel2Cell(-x1 * 2, -y1 * 2) + newreg['e'], newreg['s'] = self.Pixel2Cell(self.Map.width + 2 * (self.Map.width - x2), + self.Map.height + 2 * (self.Map.height - y2)) # pan elif zoomtype == 0: - newreg['w'], newreg['n'] = self.Pixel2Cell(x1-x2, y1-y2) - newreg['e'], newreg['s'] = self.Pixel2Cell( - self.Map.width+x1-x2, - self.Map.height+y1-y2) + newreg['w'], newreg['n'] = self.Pixel2Cell(x1 - x2, y1 - y2) + newreg['e'], newreg['s'] = self.Pixel2Cell(self.Map.width + x1 - x2, + self.Map.height + y1 - y2) # if new region has been calculated, set the values if newreg : @@ -868,7 +887,7 @@ self.Map.region['e'] = newreg['e'] self.Map.region['w'] = newreg['w'] - self.ZoomHistory(newreg['n'],newreg['s'],newreg['e'],newreg['w']) + self.ZoomHistory(newreg['n'], newreg['s'], newreg['e'], newreg['w']) def ZoomBack(self): """ @@ -1675,34 +1694,35 @@ if id not in self.ovlcoords: self.ovlcoords[id] = [10,10] - # Decoration overlay control dialog - dlg = DecDialog(self, wx.ID_ANY, 'Scale and North arrow', size=(350, 200), + # decoration overlay control dialog + dlg = DecDialog(self, wx.ID_ANY, _('Scale and North arrow'), size=(350, 200), style=wx.DEFAULT_DIALOG_STYLE, ovltype=ovltype, cmd='d.barscale', drawid=id, - checktxt = "Show/hide scale and arrow", - ctrltxt = "scale object", + checktxt = _("Show/hide scale and arrow"), + ctrltxt = _("scale object"), params = params) dlg.CenterOnScreen() - # If OK button pressed in decoration control dialog - val = dlg.ShowModal() - if val == wx.ID_OK: + # if OK button pressed in decoration control dialog + if dlg.ShowModal() == wx.ID_OK: if self.ovlchk[id] == True: self.MapWindow.Draw(self.MapWindow.pdc, drawid=id, img=img, pdctype='image', coords=self.ovlcoords[id]) + # update the map canvas self.MapWindow.UpdateMap() + dlg.Destroy() # close properties dialog if open -# try: -# self.propwin[ovltype].Close(True) -# except: -# pass + # try: + # self.propwin[ovltype].Close(True) + # except: + # pass def AddLegend(self, event): """ @@ -1766,17 +1786,19 @@ Handler for text decoration menu selection. """ ovltype = 2 # index for overlay layer in render + + # default values maptext = '' textfont = self.GetFont() textcolor = wx.BLACK - textcoords = [10,10,10,10] - rotation = 0 + textcoords = [10, 10, 10, 10] + rotation = 0.0 if self.MapWindow.currtxtid == None: # text doesn't already exist - id = wx.NewId()+100 + id = wx.NewId() + 100 else: # text already exists id = self.MapWindow.currtxtid - textcoords=self.ovlcoords[id] + textcoords = self.ovlcoords[id] dlg = TextDialog(self, wx.ID_ANY, 'Text', size=(400, 200), style=wx.DEFAULT_DIALOG_STYLE, @@ -1788,11 +1810,11 @@ # If OK button pressed in decoration control dialog val = dlg.ShowModal() if val == wx.ID_OK: - maptext = dlg.currText - textfont = dlg.currFont - textcolor = dlg.currClr - rotation = dlg.currRot - coords,w,h = self.MapWindow.textBounds((maptext,textfont,textcolor,rotation),textcoords) + maptext = dlg.currText + textfont = dlg.currFont + textcolor = dlg.currClr + rotation = dlg.currRot + coords,w,h = self.MapWindow.TextBounds((maptext, textfont, textcolor, rotation),textcoords) # delete object if if it has no text if maptext == '': @@ -1857,20 +1879,23 @@ # end of class MapFrame class DecDialog(wx.Dialog): + """ + Controls setting options and displaying/hiding map overlay decorations + """ def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize, - style=wx.DEFAULT_DIALOG_STYLE, ovltype=0, cmd='d.barscale', - drawid=None, checktxt='', ctrltxt='', params=''): + style=wx.DEFAULT_DIALOG_STYLE, ovltype=0, cmd='d.barscale', + drawid=None, checktxt='', ctrltxt='', params=''): wx.Dialog.__init__(self, parent, id, title, pos, size, style) - """ - Controls setting options and displaying/hiding map overlay decorations - """ self.ovltype = ovltype - self.drawid = drawid - self.ovlcmd = cmd - self.ovlchk = self.Parent.MapWindow.ovlchk - self.params = params #previously set decoration options to pass back to options dialog + self.drawid = drawid + self.ovlcmd = cmd + self.parent = parent + self.ovlchk = self.parent.MapWindow.ovlchk + self.params = params #previously set decoration options to pass back to options dialog + #self.MakeModal(True) + sizer = wx.BoxSizer(wx.VERTICAL) box = wx.BoxSizer(wx.HORIZONTAL) @@ -1909,51 +1934,55 @@ self.SetSizer(sizer) sizer.Fit(self) - self.Bind(wx.EVT_CHECKBOX, self.onCheck, self.chkbox) - self.Bind(wx.EVT_BUTTON, self.onOptions, optnbtn) + self.Bind(wx.EVT_CHECKBOX, self.OnCheck, self.chkbox) + self.Bind(wx.EVT_BUTTON, self.OnOptions, optnbtn) - def onCheck(self, event): + def OnCheck(self, event): """ Handler for checkbox for displaying/hiding decoration """ check = event.IsChecked() self.ovlchk[self.drawid] = check - def onOptions(self, event): + def OnOptions(self, event): """ Sets option for decoration map overlays """ + # display properties dialog (modal mode) + menuform.GUI().ParseCommand(self.ovlcmd, gmpath, + completed=(self.parent.GetOptData, self.ovltype, self.params), + parentframe=self, modal=True) - menuform.GUI().parseCommand(self.ovlcmd, gmpath, - completed=(self.Parent.GetOptData,self.ovltype,self.params), - parentframe=None) +class TextDialog(wx.Dialog): + """ + Controls setting options and displaying/hiding map overlay decorations + """ -class TextDialog(wx.Dialog): def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize, - style=wx.DEFAULT_DIALOG_STYLE, - ovltype=2,drawid=None): + style=wx.DEFAULT_DIALOG_STYLE, + ovltype=2,drawid=None): + wx.Dialog.__init__(self, parent, id, title, pos, size, style) - """ - Controls setting options and displaying/hiding map overlay decorations - """ self.ovltype = ovltype - self.drawid = drawid - - if drawid in self.Parent.MapWindow.textdict: - self.currText,self.currFont,self.currClr,self.currRot = self.Parent.MapWindow.textdict[drawid] + self.drawid = drawid + self.parent = parent + + if drawid in self.parent.MapWindow.textdict: + self.currText, self.currFont, self.currClr, self.currRot = self.parent.MapWindow.textdict[drawid] else: self.currClr = wx.BLACK self.currText = '' self.currFont = self.GetFont() - self.currRot = 0 + self.currRot = 0.0 sizer = wx.BoxSizer(wx.VERTICAL) box = wx.BoxSizer(wx.HORIZONTAL) - label = wx.StaticText(self, -1, "Enter text:") + label = wx.StaticText(self, wx.ID_ANY, _("Enter text:")) box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - self.textentry = wx.TextCtrl(self, -1, "", size=(200,-1)) + + self.textentry = wx.TextCtrl(self, wx.ID_ANY, "", size=(200,-1)) self.textentry.SetFont(self.currFont) self.textentry.SetForegroundColour(self.currClr) self.textentry.SetValue(self.currText) @@ -1961,11 +1990,11 @@ sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) - label = wx.StaticText(self, -1, "Rotation:") + label = wx.StaticText(self, wx.ID_ANY, "Rotation:") box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) self.rotation = wx.SpinCtrl(self, id=wx.ID_ANY, value="", pos=(30, 50), size=(75,-1), style=wx.SP_ARROW_KEYS) - self.rotation.SetRange(-360,360) + self.rotation.SetRange(-360, 360) self.rotation.SetValue(int(self.currRot)) box.Add(self.rotation, 0, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) @@ -1976,11 +2005,11 @@ sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) - label = wx.StaticText(self, -1, ("Drag text with mouse in pointer mode\nto position. Double-click to change options")) + label = wx.StaticText(self, wx.ID_ANY, ("Drag text with mouse in pointer mode\nto position. Double-click to change options")) box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) - line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) + line = wx.StaticLine(self, wx.ID_ANY, size=(20,-1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) btnsizer = wx.StdDialogButtonSizer() @@ -1998,17 +2027,25 @@ self.SetSizer(sizer) sizer.Fit(self) - self.Bind(wx.EVT_BUTTON, self.onSelectFont, fontbtn) - self.textentry.Bind(wx.EVT_TEXT, self.onText) - self.rotation.Bind(wx.EVT_TEXT, self.onRotation) - - def onText(self, event): + # bindings + self.Bind(wx.EVT_BUTTON, self.OnSelectFont, fontbtn) + self.Bind(wx.EVT_TEXT, self.OnText, self.textentry) + self.Bind(wx.EVT_SPINCTRL, self.OnRotation, self.rotation) + + def OnText(self, event): + """Change text string""" self.currText = event.GetString() - def onRotation(self, event): - self.currRot = event.GetString() + def OnRotation(self, event): + """Change rotation""" + self.currRot = event.GetInt() + Debug.msg (5, "TextDialog.OnRotation(): rotation=%f" % \ + self.currRot) - def onSelectFont(self, event): + event.Skip() + + def OnSelectFont(self, event): + """Change font""" data = wx.FontData() data.EnableEffects(True) data.SetColour(self.currClr) # set colour @@ -2045,7 +2082,7 @@ box = wx.BoxSizer(wx.HORIZONTAL) if loadsave == 'load': - label = wx.StaticText(self, -1, "Load region:") + label = wx.StaticText(self, wx.ID_ANY, "Load region:") box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) self.selection = select.Select(self, id=wx.ID_ANY, size=(300,-1), type='windows') @@ -2053,16 +2090,16 @@ self.selection.Bind(wx.EVT_TEXT, self.onSelection) elif loadsave == 'save': - label = wx.StaticText(self, -1, "Save region:") + label = wx.StaticText(self, wx.ID_ANY, "Save region:") box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - self.textentry = wx.TextCtrl(self, -1, "", size=(200,-1)) + self.textentry = wx.TextCtrl(self, wx.ID_ANY, "", size=(200,-1)) box.Add(self.textentry, 0, wx.ALIGN_CENTRE|wx.ALL, 5) self.textentry.Bind(wx.EVT_TEXT, self.onText) sizer.Add(item=box, proportion=0, flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5) - line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) + line = wx.StaticLine(self, wx.ID_ANY, size=(20,-1), style=wx.LI_HORIZONTAL) sizer.Add(item=line, proportion=0, flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, border=5) Modified: trunk/grassaddons/gui/gui_modules/menuform.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menuform.py 2007-05-31 23:52:26 UTC (rev 764) +++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-06-01 10:37:21 UTC (rev 765) @@ -110,21 +110,21 @@ # From lib/gis/col_str.c, except purple which is mentioned # there but not given RGB values str2rgb = {'aqua': (100, 128, 255), - 'black': (0, 0, 0), - 'blue': (0, 0, 255), - 'brown': (180, 77, 25), - 'cyan': (0, 255, 255), - 'gray': (128, 128, 128), - 'green': (0, 255, 0), + 'black': (0, 0, 0), + 'blue': (0, 0, 255), + 'brown': (180, 77, 25), + 'cyan': (0, 255, 255), + 'gray': (128, 128, 128), + 'green': (0, 255, 0), 'grey': (128, 128, 128), - 'indigo': (0, 128, 255), - 'magenta': (255, 0, 255), - 'orange': (255, 128, 0), - 'purple': (128, 0, 128), - 'red': (255, 0, 0), - 'violet': (128, 0, 255), - 'white': (255, 255, 255), - 'yellow': (255, 255, 0)} + 'indigo': (0, 128, 255), + 'magenta': (255, 0, 255), + 'orange': (255, 128, 0), + 'purple': (128, 0, 128), + 'red': (255, 0, 0), + 'violet': (128, 0, 255), + 'white': (255, 255, 255), + 'yellow': (255, 255, 0)} rgb2str = {} for (s,r) in str2rgb.items(): rgb2str[ r ] = s @@ -1073,7 +1073,7 @@ def __init__(self, parent=-1): self.parent = parent - def ParseCommand(self, cmd, gmpath, completed=None, parentframe=-1 ): + def ParseCommand(self, cmd, gmpath, completed=None, parentframe=-1, modal=False): """ Parse command @@ -1107,7 +1107,7 @@ self.mf = mainFrame(parent=self.parent, ID=wx.ID_ANY, task_description=self.grass_task, get_dcmd=get_dcmd, layer=layer) self.mf.Show(True) - self.mf.MakeModal(False) + self.mf.MakeModal(modal) if __name__ == "__main__": Modified: trunk/grassaddons/gui/gui_modules/toolbars.py =================================================================== --- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-05-31 23:52:26 UTC (rev 764) +++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-01 10:37:21 UTC (rev 765) @@ -278,8 +278,12 @@ """ Unmark currently enabled map layer. """ - Debug.msg (4, "DigitToolbar.StopEditing(): layer=%s" % \ - self.layers[self.layerSelectedID].name) + if self.layerSelectedID: + Debug.msg (4, "DigitToolbar.StopEditing(): layer=%s" % \ + self.layers[self.layerSelectedID].name) + else: + Debug.msg (4, "DigitToolbar.StopEditing(): layer=None") + self.layerSelectedID = None self.combo.SetValue ('Select vector map') # TODO Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-05-31 23:52:26 UTC (rev 764) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-01 10:37:21 UTC (rev 765) @@ -197,6 +197,9 @@ event.Skip() return + pos = event.GetPosition() + pos = self.ScreenToClient(pos) + ltype = self.layers[self.layer_selected].type if not hasattr (self, "popupID1"): @@ -248,7 +251,7 @@ self.popupMenu.Append(self.popupID4, _("Histogram")) self.Bind (wx.EVT_MENU, self.OnHistogram, id=self.popupID4) - self.PopupMenu(self.popupMenu) + self.PopupMenu(self.popupMenu, pos) self.popupMenu.Destroy() def OnHistogram(self, event): From neteler at grass.itc.it Fri Jun 1 16:48:32 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Fri Jun 1 16:48:33 2007 Subject: [grass-addons] r766 - in trunk/grassaddons/i.pr: 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_sites_aggregate i.pr_statistics i.pr_subsets i.pr_subsets/old i.pr_training i.pr_uxb Message-ID: <200706011448.l51EmWd4014534@grass.itc.it> Author: neteler Date: 2007-06-01 16:48:31 +0200 (Fri, 01 Jun 2007) New Revision: 766 Modified: trunk/grassaddons/i.pr/PRLIB/features.c trunk/grassaddons/i.pr/PRLIB/features_selection.c trunk/grassaddons/i.pr/PRLIB/gm.c trunk/grassaddons/i.pr/PRLIB/nn.c trunk/grassaddons/i.pr/PRLIB/open.c trunk/grassaddons/i.pr/PRLIB/pca.c trunk/grassaddons/i.pr/PRLIB/read_models.c trunk/grassaddons/i.pr/PRLIB/soft_margin_boosting.c trunk/grassaddons/i.pr/PRLIB/svm.c trunk/grassaddons/i.pr/PRLIB/test.c trunk/grassaddons/i.pr/PRLIB/training.c trunk/grassaddons/i.pr/PRLIB/tree.c trunk/grassaddons/i.pr/PRLIB/write_matrix.c trunk/grassaddons/i.pr/i.pr_blob/main.c trunk/grassaddons/i.pr/i.pr_classify/main.c trunk/grassaddons/i.pr/i.pr_features/main.c trunk/grassaddons/i.pr/i.pr_features_additional/main.c trunk/grassaddons/i.pr/i.pr_features_extract/main.c trunk/grassaddons/i.pr/i.pr_features_selection/main.c trunk/grassaddons/i.pr/i.pr_model/main.c trunk/grassaddons/i.pr/i.pr_sites_aggregate/main.c trunk/grassaddons/i.pr/i.pr_statistics/main.c trunk/grassaddons/i.pr/i.pr_subsets/main.c trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig.c trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig_2.c trunk/grassaddons/i.pr/i.pr_training/defs.h trunk/grassaddons/i.pr/i.pr_training/graphics.c trunk/grassaddons/i.pr/i.pr_training/main.c trunk/grassaddons/i.pr/i.pr_training/mouse.c trunk/grassaddons/i.pr/i.pr_training/points.c trunk/grassaddons/i.pr/i.pr_training/sites.c trunk/grassaddons/i.pr/i.pr_training/title.c trunk/grassaddons/i.pr/i.pr_training/view.c trunk/grassaddons/i.pr/i.pr_training/write_map.c trunk/grassaddons/i.pr/i.pr_uxb/main.c Log: include headers fixed for GRASS 6 Modified: trunk/grassaddons/i.pr/PRLIB/features.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/features.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/features.c 2007-06-01 14:48:31 UTC (rev 766) @@ -5,7 +5,7 @@ structure Feature management */ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/PRLIB/features_selection.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/features_selection.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/features_selection.c 2007-06-01 14:48:31 UTC (rev 766) @@ -8,7 +8,7 @@ Features Selction with SVM */ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/PRLIB/gm.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/gm.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/gm.c 2007-06-01 14:48:31 UTC (rev 766) @@ -6,7 +6,7 @@ structure GaussianMixture management */ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/PRLIB/nn.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/nn.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/nn.c 2007-06-01 14:48:31 UTC (rev 766) @@ -6,7 +6,7 @@ structure NearestNeighbor management */ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/PRLIB/open.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/open.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/open.c 2007-06-01 14:48:31 UTC (rev 766) @@ -6,7 +6,7 @@ open new raster maps */ -#include "gis.h" +#include #include int open_new_CELL(name) Modified: trunk/grassaddons/i.pr/PRLIB/pca.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/pca.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/pca.c 2007-06-01 14:48:31 UTC (rev 766) @@ -7,7 +7,7 @@ */ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/PRLIB/read_models.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/read_models.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/read_models.c 2007-06-01 14:48:31 UTC (rev 766) @@ -6,7 +6,7 @@ loading different model types */ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/PRLIB/soft_margin_boosting.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/soft_margin_boosting.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/soft_margin_boosting.c 2007-06-01 14:48:31 UTC (rev 766) @@ -6,7 +6,7 @@ Soft Boosting implementation (quadratic programming) */ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/PRLIB/svm.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/svm.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/svm.c 2007-06-01 14:48:31 UTC (rev 766) @@ -7,7 +7,7 @@ */ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/PRLIB/test.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/test.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/test.c 2007-06-01 14:48:31 UTC (rev 766) @@ -13,7 +13,7 @@ */ #include -#include "gis.h" +#include #include "global.h" #define EPS1 0.001 Modified: trunk/grassaddons/i.pr/PRLIB/training.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/training.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/training.c 2007-06-01 14:48:31 UTC (rev 766) @@ -6,7 +6,7 @@ structure Training management */ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/PRLIB/tree.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/tree.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/tree.c 2007-06-01 14:48:31 UTC (rev 766) @@ -6,7 +6,7 @@ structure Tree and BTree management */ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/PRLIB/write_matrix.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/write_matrix.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/PRLIB/write_matrix.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include void write_matrix(outfile,matrix,r,c) Modified: trunk/grassaddons/i.pr/i.pr_blob/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_blob/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_blob/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/i.pr_classify/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_classify/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_classify/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/i.pr_features/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_features/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_features/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include Modified: trunk/grassaddons/i.pr/i.pr_features_additional/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_additional/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_features_additional/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include Modified: trunk/grassaddons/i.pr/i.pr_features_extract/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_extract/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_features_extract/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/i.pr_features_selection/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_selection/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_features_selection/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/i.pr_model/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_model/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_model/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/i.pr_sites_aggregate/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_sites_aggregate/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_sites_aggregate/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,9 +1,9 @@ -#include "gis.h" +#include #include "global.h" #include #include #include -#include "Vect.h" +#include #define MAXPNTS 1000 Modified: trunk/grassaddons/i.pr/i.pr_statistics/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_statistics/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_statistics/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,6 +1,6 @@ -#include "gis.h" +#include #include "global.h" -#include "raster.h" +#include #include #include Modified: trunk/grassaddons/i.pr/i.pr_subsets/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_subsets/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_subsets/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig_2.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig_2.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_subsets/old/main_orig_2.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include #include Modified: trunk/grassaddons/i.pr/i.pr_training/defs.h =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/defs.h 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_training/defs.h 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "imagery.h" +#include /* this is a graphics structure */ typedef struct Modified: trunk/grassaddons/i.pr/i.pr_training/graphics.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/graphics.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_training/graphics.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,7 +1,7 @@ #include "globals.h" -#include "raster.h" -#include "D.h" -#include "display.h" +#include +#include +#include #include "loc_func.h" static View * makeview(double bottom, double top, double left, double right) Modified: trunk/grassaddons/i.pr/i.pr_training/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_training/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,8 +1,8 @@ #define GLOBAL #include -#include "gis.h" -#include "raster.h" +#include +#include #include "global.h" #include "globals.h" #include "func.h" Modified: trunk/grassaddons/i.pr/i.pr_training/mouse.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/mouse.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_training/mouse.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "raster.h" +#include #include "globals.h" Modified: trunk/grassaddons/i.pr/i.pr_training/points.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/points.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_training/points.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "raster.h" +#include #include "globals.h" #include "loc_func.h" Modified: trunk/grassaddons/i.pr/i.pr_training/sites.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/sites.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_training/sites.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include "globals.h" Modified: trunk/grassaddons/i.pr/i.pr_training/title.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/title.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_training/title.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "raster.h" +#include #include "globals.h" #include "loc_func.h" Modified: trunk/grassaddons/i.pr/i.pr_training/view.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/view.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_training/view.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,5 +1,5 @@ #include -#include "raster.h" +#include #include "globals.h" #include "loc_func.h" Modified: trunk/grassaddons/i.pr/i.pr_training/write_map.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/write_map.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_training/write_map.c 2007-06-01 14:48:31 UTC (rev 766) @@ -2,7 +2,7 @@ #include #include #include "globals.h" -#include "glocale.h" +#include void write_map(cellhd, name, mapset, dest) struct Cell_head *cellhd; Modified: trunk/grassaddons/i.pr/i.pr_uxb/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_uxb/main.c 2007-06-01 10:37:21 UTC (rev 765) +++ trunk/grassaddons/i.pr/i.pr_uxb/main.c 2007-06-01 14:48:31 UTC (rev 766) @@ -1,4 +1,4 @@ -#include "gis.h" +#include #include "global.h" #include #include From neteler at grass.itc.it Fri Jun 1 17:33:07 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Fri Jun 1 17:33:08 2007 Subject: [grass-addons] r767 - trunk/grassaddons/i.pr/include Message-ID: <200706011533.l51FX7uf015499@grass.itc.it> Author: neteler Date: 2007-06-01 17:33:07 +0200 (Fri, 01 Jun 2007) New Revision: 767 Modified: trunk/grassaddons/i.pr/include/global.h Log: fixed include order Modified: trunk/grassaddons/i.pr/include/global.h =================================================================== --- trunk/grassaddons/i.pr/include/global.h 2007-06-01 14:48:31 UTC (rev 766) +++ trunk/grassaddons/i.pr/include/global.h 2007-06-01 15:33:07 UTC (rev 767) @@ -1,8 +1,8 @@ +#include #include -#include #include "func.h" -#define PIG 3.141593 +#define PIG M_PI #define TRUE 1 #define FALSE 0 From neteler at grass.itc.it Fri Jun 1 17:36:53 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Fri Jun 1 17:36:54 2007 Subject: [grass-addons] r768 - in trunk/grassaddons/i.pr: . 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_sites_aggregate i.pr_statistics i.pr_subsets i.pr_training i.pr_uxb Message-ID: <200706011536.l51FarRv015520@grass.itc.it> Author: neteler Date: 2007-06-01 17:36:52 +0200 (Fri, 01 Jun 2007) New Revision: 768 Modified: trunk/grassaddons/i.pr/PRLIB/dist.c trunk/grassaddons/i.pr/README trunk/grassaddons/i.pr/i.pr_blob/Makefile trunk/grassaddons/i.pr/i.pr_classify/Makefile trunk/grassaddons/i.pr/i.pr_features/Makefile trunk/grassaddons/i.pr/i.pr_features_additional/Makefile trunk/grassaddons/i.pr/i.pr_features_extract/Makefile trunk/grassaddons/i.pr/i.pr_features_selection/Makefile trunk/grassaddons/i.pr/i.pr_model/Makefile trunk/grassaddons/i.pr/i.pr_sites_aggregate/Makefile trunk/grassaddons/i.pr/i.pr_statistics/Makefile trunk/grassaddons/i.pr/i.pr_subsets/Makefile trunk/grassaddons/i.pr/i.pr_training/Makefile trunk/grassaddons/i.pr/i.pr_uxb/Makefile Log: renamed modules to get closer to GRASS convention. Now it compiles Modified: trunk/grassaddons/i.pr/PRLIB/dist.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/dist.c 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/PRLIB/dist.c 2007-06-01 15:36:52 UTC (rev 768) @@ -6,8 +6,8 @@ Distance between arrays computation */ +#include #include "global.h" -#include double squared_distance(x,y,n) Modified: trunk/grassaddons/i.pr/README =================================================================== --- trunk/grassaddons/i.pr/README 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/README 2007-06-01 15:36:52 UTC (rev 768) @@ -9,4 +9,13 @@ * 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=/bartok0/ssi/neteler/software/cvsgrass63/ + +(adapt to your /path/to/grass6/ ) + Modified: trunk/grassaddons/i.pr/i.pr_blob/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_blob/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_blob/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_blob +PGM = i.pr.blob LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) Modified: trunk/grassaddons/i.pr/i.pr_classify/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_classify/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_classify/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_classify +PGM = i.pr.classify LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) Modified: trunk/grassaddons/i.pr/i.pr_features/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_features/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_features/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_features +PGM = i.pr.features LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) Modified: trunk/grassaddons/i.pr/i.pr_features_additional/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_additional/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_features_additional/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_features_additional +PGM = i.pr.features_additional LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) Modified: trunk/grassaddons/i.pr/i.pr_features_extract/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_extract/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_features_extract/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_features_extract +PGM = i.pr.features_extract LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) Modified: trunk/grassaddons/i.pr/i.pr_features_selection/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_features_selection/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_features_selection/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_features_selection +PGM = i.pr.features_selection LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) Modified: trunk/grassaddons/i.pr/i.pr_model/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_model/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_model/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_model +PGM = i.pr.model LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) Modified: trunk/grassaddons/i.pr/i.pr_sites_aggregate/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_sites_aggregate/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_sites_aggregate/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_sites_aggregate +PGM = i.pr.sites_aggregate LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) Modified: trunk/grassaddons/i.pr/i.pr_statistics/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_statistics/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_statistics/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_statistics +PGM = i.pr.statistics LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) Modified: trunk/grassaddons/i.pr/i.pr_subsets/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_subsets/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_subsets/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_subsets +PGM = i.pr.subsets LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) Modified: trunk/grassaddons/i.pr/i.pr_training/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_training/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_training +PGM = i.pr.training LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) Modified: trunk/grassaddons/i.pr/i.pr_uxb/Makefile =================================================================== --- trunk/grassaddons/i.pr/i.pr_uxb/Makefile 2007-06-01 15:33:07 UTC (rev 767) +++ trunk/grassaddons/i.pr/i.pr_uxb/Makefile 2007-06-01 15:36:52 UTC (rev 768) @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -I$(PRINCLUDE) PRLIB = -lgrass_pr -PGM = i.pr_uxb +PGM = i.pr.uxb LIBES = $(SITESLIB) $(PRLIB) $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(DATETIMELIB) DEPENDENCIES= $(SITESDEP) $(PRDEP) $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(DATETIMEDEP) From neteler at grass.itc.it Fri Jun 1 18:02:20 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Fri Jun 1 18:02:22 2007 Subject: [grass-addons] r769 - trunk/grassaddons/i.pr Message-ID: <200706011602.l51G2Kkr015594@grass.itc.it> Author: neteler Date: 2007-06-01 18:02:18 +0200 (Fri, 01 Jun 2007) New Revision: 769 Added: trunk/grassaddons/i.pr/TODO Log: TODO added Added: trunk/grassaddons/i.pr/TODO =================================================================== --- trunk/grassaddons/i.pr/TODO (rev 0) +++ trunk/grassaddons/i.pr/TODO 2007-06-01 16:02:18 UTC (rev 769) @@ -0,0 +1,6 @@ +This module set was developed for GRASS 5. + +TODO: +- change to ANSI prototypes +- follow SUBMITTING rules +- change sites to vector From landa at grass.itc.it Fri Jun 1 18:06:56 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Fri Jun 1 18:06:58 2007 Subject: [grass-addons] r770 - trunk/grassaddons/gui/gui_modules Message-ID: <200706011606.l51G6uPU015614@grass.itc.it> Author: landa Date: 2007-06-01 18:06:55 +0200 (Fri, 01 Jun 2007) New Revision: 770 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/menuform.py Log: minor bugfix (close mapdisplay window) Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-01 16:02:18 UTC (rev 769) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-01 16:06:55 UTC (rev 770) @@ -1460,7 +1460,7 @@ if pgnum > -1: self.layerbook.DeletePage(pgnum) - self.Destroy() + #self.Destroy() def getRender(self): """ @@ -1832,7 +1832,7 @@ self.MapWindow.Update() - def GetOptData(self, dcmd, type, params,propwin): + def GetOptData(self, dcmd, type, params, propwin): """ Callback method for decoration overlay command generated by dialog created in menuform.py Modified: trunk/grassaddons/gui/gui_modules/menuform.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menuform.py 2007-06-01 16:02:18 UTC (rev 769) +++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-06-01 16:06:55 UTC (rev 770) @@ -543,8 +543,14 @@ # We have to wait for the notebookpanel to be filled in order # to know if there actually is a Main tab status_text += _(" (those of Main in bold typeface are required)") - self.SetStatusText( status_text ) + try: + self.task.getCmd() + self.updateValuesHook() + except ValueError: + self.SetStatusText( status_text ) + + # buttons btnsizer = wx.BoxSizer(orient=wx.HORIZONTAL) # cancel @@ -1087,7 +1093,8 @@ else: get_dcmd = completed[0] layer = completed[1] - if completed[2]: dcmd_params.update(completed[2]) + if completed[2]: + dcmd_params.update(completed[2]) if parentframe != -1: self.parent = parentframe @@ -1102,9 +1109,11 @@ # if layer parameters previously set, re-insert them into dialog if completed is not None: - if 'params' in dcmd_params: self.grass_task.params = dcmd_params['params'] - if 'flags' in dcmd_params: self.grass_task.flags = dcmd_params['flags'] - + if 'params' in dcmd_params: + self.grass_task.params = dcmd_params['params'] + if 'flags' in dcmd_params: + self.grass_task.flags = dcmd_params['flags'] + self.mf = mainFrame(parent=self.parent, ID=wx.ID_ANY, task_description=self.grass_task, get_dcmd=get_dcmd, layer=layer) self.mf.Show(True) self.mf.MakeModal(modal) From neteler at grass.itc.it Fri Jun 1 20:41:53 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Fri Jun 1 20:41:56 2007 Subject: [grass-addons] r771 - in trunk/grassaddons/i.pr: . PRLIB i.pr_statistics i.pr_training include Message-ID: <200706011841.l51IfrNL016810@grass.itc.it> Author: neteler Date: 2007-06-01 20:41:41 +0200 (Fri, 01 Jun 2007) New Revision: 771 Added: trunk/grassaddons/i.pr/i.pr_statistics/cell.c trunk/grassaddons/i.pr/i.pr_statistics/localproto.h Modified: trunk/grassaddons/i.pr/PRLIB/entropy.c trunk/grassaddons/i.pr/README trunk/grassaddons/i.pr/i.pr_statistics/main.c trunk/grassaddons/i.pr/i.pr_training/graphics.c trunk/grassaddons/i.pr/include/func.h trunk/grassaddons/i.pr/include/func_help Log: now really compiles Modified: trunk/grassaddons/i.pr/PRLIB/entropy.c =================================================================== --- trunk/grassaddons/i.pr/PRLIB/entropy.c 2007-06-01 16:06:55 UTC (rev 770) +++ trunk/grassaddons/i.pr/PRLIB/entropy.c 2007-06-01 18:41:41 UTC (rev 771) @@ -26,12 +26,12 @@ else{ e=0.0; for(i=0;i +#include +#include +#include +#include +/*#include "edit.h"*/ +#include "localproto.h" + +static int cell_draw( char *, char *, struct Colors *, int); + + +/*! + * \brief + * + * If the map is a floating-point map, read the map using + * G_get_d_raster_row() and plot using D_draw_d_cell(). If the + * map is an integer map, read the map using G_get_c_raster_row() and + * plot using D_draw_cell(). + * + * \param name + * \param mapset + * \param overlay + * \return int + */ + +int Dcell(char *name, char *mapset, int overlay) +{ + struct Cell_head wind ; + struct Colors colors ; + char buff[128] ; + + G_get_set_window (&wind) ; + + if (D_check_map_window(&wind)) + G_fatal_error(_("Setting map window")) ; + + if (G_set_window(&wind) == -1) + G_fatal_error(_("Current window not settable")) ; + + /* Get existing map window for this graphics window, or save window */ + /* cell maps wipe out a picture, so we clear info on the window too */ + if (!overlay && D_clear_window()) + G_fatal_error(_("Can't clear current graphics window")) ; + + /* Save the current map window with the graphics window */ + D_check_map_window(&wind) ; + G_set_window (&wind); + + /* Set the colors for the display */ + if (G_read_colors(name, mapset, &colors) == -1) + G_fatal_error(_("Color file for [%s] not available"), name) ; + + /* Go draw the cell file */ + cell_draw(name, mapset, &colors, overlay) ; + + /* release the colors now */ + G_free_colors (&colors); + + /* record the cell file */ + /* If overlay add it to the list instead of setting the cell name */ + /* added 6/91 DBS @ CWU */ + if (overlay) { + sprintf(buff,"d.rast -o map=%s", G_fully_qualified_name(name,mapset)); + D_add_to_list(buff) ; + } + else { + D_set_cell_name(G_fully_qualified_name(name, mapset)); + } + + return 0; +} + +/* I modified this function to read and draw raster cell as doubles */ +static int cell_draw(char *name, char *mapset, struct Colors *colors, int overlay) +{ + int cellfile ; + DCELL *xarray ; + int cur_A_row ; + int t, b, l, r ; + + /* Set up the screen, conversions, and graphics */ + D_get_screen_window(&t, &b, &l, &r) ; + if (D_cell_draw_setup(t, b, l, r)) + G_fatal_error(_("Cannot use current window")) ; + + D_set_overlay_mode(overlay); + + /* Make sure map is available */ + if ((cellfile = G_open_cell_old(name, mapset)) == -1) + G_fatal_error(_("Not able to open cellfile for [%s]"), name); + + /* Allocate space for cell buffer */ + xarray = G_allocate_d_raster_buf() ; + + /* loop for array rows */ + for (cur_A_row = 0; cur_A_row != -1; ) + { + /* Get window (array) row currently required */ + G_get_d_raster_row(cellfile, xarray, cur_A_row) ; + + /* Draw the cell row, and get the next row number */ + cur_A_row = D_draw_d_raster(cur_A_row, xarray, colors) ; + } + R_flush() ; + + /* Wrap up and return */ + G_close_cell(cellfile) ; + G_free (xarray); + + return(0) ; +} Property changes on: trunk/grassaddons/i.pr/i.pr_statistics/cell.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/i.pr/i.pr_statistics/localproto.h =================================================================== --- trunk/grassaddons/i.pr/i.pr_statistics/localproto.h (rev 0) +++ trunk/grassaddons/i.pr/i.pr_statistics/localproto.h 2007-06-01 18:41:41 UTC (rev 771) @@ -0,0 +1,2 @@ +/* cell.c */ +int Dcell(char *, char *, int); Property changes on: trunk/grassaddons/i.pr/i.pr_statistics/localproto.h ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/grassaddons/i.pr/i.pr_statistics/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_statistics/main.c 2007-06-01 16:06:55 UTC (rev 770) +++ trunk/grassaddons/i.pr/i.pr_statistics/main.c 2007-06-01 18:41:41 UTC (rev 771) @@ -1,8 +1,10 @@ +#include +#include #include +#include #include "global.h" -#include -#include -#include +/*#include "edit.h"*/ +#include "localproto.h" #define TINY 1.0e-20 #define MAXLIMITS 10000 Modified: trunk/grassaddons/i.pr/i.pr_training/graphics.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/graphics.c 2007-06-01 16:06:55 UTC (rev 770) +++ trunk/grassaddons/i.pr/i.pr_training/graphics.c 2007-06-01 18:41:41 UTC (rev 771) @@ -1,6 +1,5 @@ #include "globals.h" #include -#include #include #include "loc_func.h" @@ -47,11 +46,11 @@ /* R_color_table_fixed(); */ - R_color_offset (0); +/* R_color_offset (0); Dscreen(); +*/ - SCREEN_TOP = R_screen_top(); SCREEN_BOTTOM = R_screen_bot(); SCREEN_LEFT = R_screen_left(); @@ -92,11 +91,11 @@ /* R_color_table_fixed(); */ - R_color_offset (0); +/* R_color_offset (0); Dscreen(); +*/ - SCREEN_TOP = R_screen_top(); SCREEN_BOTTOM = R_screen_bot(); SCREEN_LEFT = R_screen_left(); @@ -229,7 +228,7 @@ display_title (view); - D_set_colors (colors); +/* D_set_colors (colors);*/ G_set_window (&view->cell.head); nrows = G_window_rows(); @@ -260,13 +259,13 @@ if(G_get_map_row_nomask(fd, cell, row) < 0) break; repeat = G_row_repeat_nomask (fd, row); - D_raster (cell, ncols, repeat, colors); +/* D_raster (cell, ncols, repeat, colors); */ } G_close_cell (fd); G_free (cell); - if(colors != &VIEW_MAP1->cell.colors) +/* if(colors != &VIEW_MAP1->cell.colors) D_set_colors(&VIEW_MAP1->cell.colors); - +*/ return row==nrows; } Modified: trunk/grassaddons/i.pr/include/func.h =================================================================== --- trunk/grassaddons/i.pr/include/func.h 2007-06-01 16:06:55 UTC (rev 770) +++ trunk/grassaddons/i.pr/include/func.h 2007-06-01 18:41:41 UTC (rev 771) @@ -57,7 +57,7 @@ */ double Entropy(); -double clog(); +double Clog(); void histo(); void histo1(); Modified: trunk/grassaddons/i.pr/include/func_help =================================================================== --- trunk/grassaddons/i.pr/include/func_help 2007-06-01 16:06:55 UTC (rev 770) +++ trunk/grassaddons/i.pr/include/func_help 2007-06-01 18:41:41 UTC (rev 771) @@ -118,7 +118,7 @@ double *data; int n; double zero; -double clog(x,zero) +double Clog(x,zero) double x; double zero; void histo(data,n,h,nbin) From neteler at grass.itc.it Fri Jun 1 20:54:44 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Fri Jun 1 20:54:44 2007 Subject: [grass-addons] r772 - trunk/grassaddons Message-ID: <200706011854.l51IsiSQ016913@grass.itc.it> Author: neteler Date: 2007-06-01 20:54:43 +0200 (Fri, 01 Jun 2007) New Revision: 772 Modified: trunk/grassaddons/contributors.csv Log: +Maximilian Maldacker for GSoC Modified: trunk/grassaddons/contributors.csv =================================================================== --- trunk/grassaddons/contributors.csv 2007-06-01 18:41:41 UTC (rev 771) +++ trunk/grassaddons/contributors.csv 2007-06-01 18:54:43 UTC (rev 772) @@ -1,11 +1,12 @@ -barton,Michael Barton -bergenheim,Wolf Bergenheim -bundala,Daniel Bundala -calvelo,Daniel Calvelo Aros -cannata,Massimiliano Cannata -cepicky,Jachym Cepicky -chemin,Yann Chemin -clements,Glynn Clements -kindl,Florian Kindl -landa,Martin Landa -neteler,Markus Neteler +barton,Michael Barton +bergenheim,Wolf Bergenheim +bundala,Daniel Bundala +calvelo,Daniel Calvelo Aros +cannata,Massimiliano Cannata +cepicky,Jachym Cepicky +chemin,Yann Chemin +clements,Glynn Clements +kindl,Florian Kindl +landa,Martin Landa +maldacker,Maximilian Maldacker +neteler,Markus Neteler From barton at grass.itc.it Tue Jun 5 06:12:29 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 5 06:12:31 2007 Subject: [grass-addons] r773 - trunk/grassaddons/gui/gui_modules Message-ID: <200706050412.l554CTQH013808@grass.itc.it> Author: barton Date: 2007-06-05 06:12:20 +0200 (Tue, 05 Jun 2007) New Revision: 773 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py Log: Nicer formatting of measurement output, using algorithm developed by Hamish Bowman. Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-01 18:54:43 UTC (rev 772) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-05 04:12:20 UTC (rev 773) @@ -1572,6 +1572,12 @@ toolsmenu.Destroy() def OnMeasure(self, event): + """ + Init measurement routine that calculates + map distance along transect drawn on + map display + """ + # switch GIS Manager to output console to show measure results self.gismanager.notebook.SetSelection(1) @@ -1593,26 +1599,32 @@ self.gismanager.goutput.cmd_output.write('\nMeasuring distance:\n') def MeasureDist(self, beginpt, endpt): + """ + Calculate map distance from screen distance + and print to output window + """ x1,y1 = beginpt x2,y2 = endpt east = (x2-x1) * self.Map.region["ewres"] north = (y2-y1) * self.Map.region["nsres"] self.dist = round(math.sqrt(math.pow((east),2) + math.pow((north),2)),3) self.totaldist += self.dist + self.dist,dunits = self.FormatDist(self.dist) + self.totaldist,tdunits = self.FormatDist(self.totaldist) + strdist = str(self.dist) + strtotdist = str(self.totaldist) if self.projinfo['proj'] == 'xy' or 'degree' not in self.projinfo['unit']: angle = int(math.degrees(math.atan2(north,east)) + 0.5) angle = angle+90 if angle < 0: angle = 360+angle - self.gismanager.goutput.cmd_output.write('segment = '+ - str(self.dist)+ - '\ttotal distance = '+ - str(self.totaldist)+'\tbearing = '+str(angle)+'\n') + + mstring = 'segment = %s %s\ttotal distance = %s %s\tbearing = %d deg\n' \ + % (strdist,dunits,strtotdist,tdunits,angle) else: - self.gismanager.goutput.cmd_output.write('segment = '+ - str(self.dist)+ - '\ttotal distance = '+ - str(self.totaldist)+'\n') + mstring = 'segment = %s %s\ttotal distance = %s %s\n' \ + % (strdist,dunits,strtotdist,tdunits) + self.gismanager.goutput.cmd_output.write(mstring) def Profile(self, event): """ @@ -1623,6 +1635,54 @@ style=wx.DEFAULT_FRAME_STYLE) self.profile.Show() + def FormatDist(self, dist): + """Format length numbers and units in a nice way, + as a function of length. From code by Hamish Bowman + Grass Development Team 2006""" + + mapunits = self.projinfo['units'] + if mapunits == 'metres': mapunits = 'meters' + outunits = mapunits + dist = float(dist) + divisor = 1.0 + + # figure out which units to use + if mapunits == 'meters': + if dist > 2500.0: + outunits = 'km' + divisor = 1000.0 + else: outunits = 'm' + elif mapunits == 'feet': + # nano-bug: we match any "feet", but US Survey feet is really + # 5279.9894 per statute mile, or 10.6' per 1000 miles. As >1000 + # miles the tick markers are rounded to the nearest 10th of a + # mile (528'), the difference in foot flavours is ignored. + if dist > 5280.0: + outunits = 'miles' + divisor = 5280.0 + else: + outunits = 'ft' + elif 'degree' in mapunits: + if dist < 1: + outunits = 'min' + divisor = (1/60.0) + else: + outunits = 'deg' + + # format numbers in a nice way + + if (dist/divisor) >= 2500.0: + outdist = round(dist/divisor) + elif (dist/divisor) >= 1000.0: + outdist = round(dist/divisor,1) + elif (dist/divisor) > 0.0: + outdist = round(dist/divisor,int(math.ceil(3-math.log10(dist/divisor)))) + else: + outdist = float('%g' % dist/divisor) + + return (outdist,outunits) + + def Histogram(self, event): """ Init histogram display canvas and tools From barton at grass.itc.it Tue Jun 5 06:19:41 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 5 06:19:43 2007 Subject: [grass-addons] r774 - trunk/grassaddons/gui/gui_modules Message-ID: <200706050419.l554JfAu013833@grass.itc.it> Author: barton Date: 2007-06-05 06:19:33 +0200 (Tue, 05 Jun 2007) New Revision: 774 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py Log: Fix calculation error for cumulative distance. Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-05 04:12:20 UTC (rev 773) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-05 04:19:33 UTC (rev 774) @@ -326,7 +326,7 @@ Return text boundary data """ rotation = float(textinfo[3]) - + Debug.msg (4, "BufferedWindow.TextBounds(): text=%s, rotation=%f" % \ (textinfo[0], rotation)) @@ -645,7 +645,7 @@ """ Debug.msg (5, "BufferedWindow.OnLeftDown(): use=%s" % \ self.mouse["use"]) - + if self.mouse["use"] == "measure" or self.mouse["use"] == "profile" or \ (self.mouse["use"] == "pointer" and self.parent.digittoolbar): # measure || profile || digit tool @@ -668,7 +668,7 @@ """ Debug.msg (5, "BufferedWindow.OnLeftUp(): use=%s" % \ self.mouse["use"]) - + if self.mouse['use'] == "zoom" or self.mouse['use'] == "pan": # end point of zoom box or drag self.mouse['end'] = event.GetPositionTuple()[:] @@ -736,7 +736,7 @@ """ Debug.msg (5, "BufferedWindow.OnButtonDClick(): use=%s" % \ self.mouse["use"]) - + if self.mouse["use"] == "measure": # measure self.ClearLines() @@ -778,14 +778,14 @@ """ Debug.msg (5, "BufferedWindow.OnRightDown(): use=%s" % \ self.mouse["use"]) - + x,y = event.GetPositionTuple()[:] l = self.pdc.FindObjects(x=x, y=y, radius=self.hitradius) if not l: return - + id = l[0] - + if id != 99: if self.pdc.GetIdGreyedOut(id) == True: self.pdc.SetIdGreyedOut(id, False) @@ -802,7 +802,7 @@ """ Debug.msg (5, "BufferedWindow.OnRightUp(): use=%s" % \ self.mouse["use"]) - + if self.parent.digittoolbar and self.parent.digittoolbar.action == "add": if self.parent.digittoolbar.type in ["line", "boundary"]: try: @@ -846,7 +846,7 @@ """ newx = self.Map.region['w'] + x * self.Map.region["ewres"] newy = self.Map.region['n'] - y * self.Map.region["nsres"] - + return newx, newy def Zoom(self, begin, end, zoomtype): @@ -1609,10 +1609,10 @@ north = (y2-y1) * self.Map.region["nsres"] self.dist = round(math.sqrt(math.pow((east),2) + math.pow((north),2)),3) self.totaldist += self.dist - self.dist,dunits = self.FormatDist(self.dist) - self.totaldist,tdunits = self.FormatDist(self.totaldist) - strdist = str(self.dist) - strtotdist = str(self.totaldist) + d,dunits = self.FormatDist(self.dist) + td,tdunits = self.FormatDist(self.totaldist) + strdist = str(d) + strtotdist = str(td) if self.projinfo['proj'] == 'xy' or 'degree' not in self.projinfo['unit']: angle = int(math.degrees(math.atan2(north,east)) + 0.5) @@ -1775,7 +1775,7 @@ # update the map canvas self.MapWindow.UpdateMap() - + dlg.Destroy() # close properties dialog if open @@ -1955,7 +1955,7 @@ self.params = params #previously set decoration options to pass back to options dialog #self.MakeModal(True) - + sizer = wx.BoxSizer(wx.VERTICAL) box = wx.BoxSizer(wx.HORIZONTAL) @@ -2021,13 +2021,13 @@ def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE, ovltype=2,drawid=None): - + wx.Dialog.__init__(self, parent, id, title, pos, size, style) self.ovltype = ovltype self.drawid = drawid self.parent = parent - + if drawid in self.parent.MapWindow.textdict: self.currText, self.currFont, self.currClr, self.currRot = self.parent.MapWindow.textdict[drawid] else: @@ -2041,7 +2041,7 @@ box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, wx.ID_ANY, _("Enter text:")) box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - + self.textentry = wx.TextCtrl(self, wx.ID_ANY, "", size=(200,-1)) self.textentry.SetFont(self.currFont) self.textentry.SetForegroundColour(self.currClr) @@ -2091,7 +2091,7 @@ self.Bind(wx.EVT_BUTTON, self.OnSelectFont, fontbtn) self.Bind(wx.EVT_TEXT, self.OnText, self.textentry) self.Bind(wx.EVT_SPINCTRL, self.OnRotation, self.rotation) - + def OnText(self, event): """Change text string""" self.currText = event.GetString() @@ -2103,7 +2103,7 @@ self.currRot) event.Skip() - + def OnSelectFont(self, event): """Change font""" data = wx.FontData() From barton at grass.itc.it Tue Jun 5 06:30:02 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 5 06:30:04 2007 Subject: [grass-addons] r775 - trunk/grassaddons/gui/gui_modules Message-ID: <200706050430.l554U2Zg013937@grass.itc.it> Author: barton Date: 2007-06-05 06:29:53 +0200 (Tue, 05 Jun 2007) New Revision: 775 Modified: trunk/grassaddons/gui/gui_modules/profile.py Log: Automatically shows distance units in x-axis label by default. Modified: trunk/grassaddons/gui/gui_modules/profile.py =================================================================== --- trunk/grassaddons/gui/gui_modules/profile.py 2007-06-05 04:19:33 UTC (rev 774) +++ trunk/grassaddons/gui/gui_modules/profile.py 2007-06-05 04:29:53 UTC (rev 775) @@ -18,8 +18,7 @@ """ import wx -import wx.aui -import os, sys, time, glob, math +import os, sys, math import wx.lib.colourselect as csel try: @@ -80,6 +79,8 @@ toolbar = self.__createToolBar() + self.parent = parent + self.Map = render.Map() # instance of render.Map to be associated with display # @@ -124,7 +125,10 @@ self.profile = None # plot draw object self.ptitle = 'Profile of %s %s %s' % (self.rast1, self.rast2, self.rast3) - self.xlabel = "Distance" + if self.parent.projinfo['units'] != '': + self.xlabel = 'Distance (%s)' % self.parent.projinfo['units'] + else: + self.xlabel = "Distance along transect" self.ylabel = "Cell values" self.datalist1 = [] #list of distance,value pairs for plotting profile @@ -181,6 +185,8 @@ self.client.SetYSpec(self.ytype) + + def __createToolBar(self): """Creates toolbar""" @@ -356,19 +362,6 @@ self.seglist.append((cumdist,val)) lasteast = east lastnorth = north -# output = os.popen('r.what input=%s east_north=%d,%d' % (self.rast1,east,north), "r").read().strip().split('|') -# val = output[3] -# -# # calculate distance between coordinate points -# if lasteast and lastnorth: -# dist = math.sqrt(math.pow((lasteast-east),2) + math.pow((lastnorth-north),2)) -# cumdist += dist -# -# # build a list of distance,value pairs for each segment of transect -# self.seglist.append((cumdist,val)) -# lasteast = east -# lastnorth = north - except: pass @@ -665,7 +658,6 @@ dlg.ShowModal() dlg.Destroy() - def PText(self, event): """ Set custom text values for profile From barton at grass.itc.it Tue Jun 5 06:33:45 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 5 06:33:46 2007 Subject: [grass-addons] r776 - trunk/grassaddons/gui/gui_modules Message-ID: <200706050433.l554Xjor013972@grass.itc.it> Author: barton Date: 2007-06-05 06:33:37 +0200 (Tue, 05 Jun 2007) New Revision: 776 Modified: trunk/grassaddons/gui/gui_modules/render.py Log: Add docstring to ProjInfo method Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-06-05 04:29:53 UTC (rev 775) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-06-05 04:33:37 UTC (rev 776) @@ -57,7 +57,7 @@ def __del__(self): Debug.msg (3, "MapLayer.__del__(): layer=%s, cmd=%s" % (self.name, self.GetCmd(string=True))) - + def __renderLayer(self): """ Stores generic command with all parameters in the self.cmdlist variable @@ -139,7 +139,7 @@ """Return mapset name of the layer or None""" if not self.name: return None - + idxAt = self.name.find('@') if idxAt > -1: return self.name[idxAt+1:] @@ -446,7 +446,9 @@ return None def ProjInfo(self): - # get map units from PROJ_UNITS + """ + Return region projection and map units information + """ projinfo = {} cmdlist = ['g.proj', '-p'] @@ -713,7 +715,7 @@ layerNameList += layer.name + ',' Debug.msg (4, "Map.ReoderLayers(): layers=%s" % \ (layerNameList)) - + def ChangeLayer(self, layer, type, command, name=None, l_active=True, l_hidden=False, l_opacity=1, l_render=False): """ From barton at grass.itc.it Tue Jun 5 07:12:17 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 5 07:12:19 2007 Subject: [grass-addons] r777 - trunk/grassaddons/gui/gui_modules Message-ID: <200706050512.l555CHls014014@grass.itc.it> Author: barton Date: 2007-06-05 07:12:07 +0200 (Tue, 05 Jun 2007) New Revision: 777 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py Log: Toolbar should be top dockable and not left dockable. Otherwise it creates a panel that occupies most of the displa window. Probably the same should be the case for Digitize toolbar. Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-05 04:33:37 UTC (rev 776) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-05 05:12:07 UTC (rev 777) @@ -1233,8 +1233,8 @@ self._mgr.AddPane(self.maptoolbar.toolbar, wx.aui.AuiPaneInfo(). Name("maptoolbar").Caption("Map Toolbar"). - ToolbarPane().Top().LeftDockable(True).RightDockable(False). - BottomDockable(False).TopDockable(False).CloseButton(False)) + ToolbarPane().Top().LeftDockable(False).RightDockable(False). + BottomDockable(False).TopDockable(True).CloseButton(False)) elif name == "digit": self.digittoolbar = toolbars.DigitToolbar(self, self.Map) From barton at grass.itc.it Tue Jun 5 09:35:34 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 5 09:35:36 2007 Subject: [grass-addons] r778 - trunk/grassaddons/gui/gui_modules Message-ID: <200706050735.l557ZYlS015106@grass.itc.it> Author: barton Date: 2007-06-05 09:35:22 +0200 (Tue, 05 Jun 2007) New Revision: 778 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/render.py Log: Capitalized method name to match other formatting. Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-05 05:12:07 UTC (rev 777) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-05 07:35:22 UTC (rev 778) @@ -424,6 +424,7 @@ self.imagedict[img] = pdc_id # set image PeudoDC ID Debug.msg (3, "BufferedWindow.GetOverlay(): numberof=%d" % len(self.ovldict)) + return self.ovldict @@ -1169,9 +1170,9 @@ # d.barscale overlay added to rendering overlay list - self.Map.addOverlay(0, type='overlay', command=['d.barscale'], l_active=False, l_render=False) + self.Map.AddOverlay(0, type='overlay', command=['d.barscale'], l_active=False, l_render=False) # d.barscale overlay added to rendering overlay list as placeholder for d.legend - self.Map.addOverlay(1, type='overlay', command=['d.barscale'], l_active=False, l_render=False) + self.Map.AddOverlay(1, type='overlay', command=['d.barscale'], l_active=False, l_render=False) # # Init map display @@ -1732,7 +1733,7 @@ ovltype = id = 0 # index for overlay layer in render if ovltype not in self.Map.ovlookup: - self.Map.addOverlay(ovltype, type='overlay', command='d.barscale', l_active=False, l_render=False) + self.Map.AddOverlay(ovltype, type='overlay', command='d.barscale', l_active=False, l_render=False) if ovltype in self.params: params = self.params[ovltype] @@ -1791,7 +1792,7 @@ ovltype = id = 1 # index for overlay layer in render if ovltype not in self.Map.ovlookup: - self.Map.addOverlay(ovltype, type='overlay', command='d.barscale', l_active=False, l_render=False) + self.Map.AddOverlay(ovltype, type='overlay', command='d.barscale', l_active=False, l_render=False) if ovltype in self.params: params = self.params[ovltype] @@ -1889,7 +1890,7 @@ self.MapWindow.textdict[id] = (maptext,textfont,textcolor,rotation) self.MapWindow.Draw(self.MapWindow.pdc, img=self.MapWindow.textdict[id], drawid=id, pdctype='text', coords=textcoords) - self.MapWindow.Update() + self.MapWindow.UpdateMap() def GetOptData(self, dcmd, type, params, propwin): Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-06-05 05:12:07 UTC (rev 777) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-06-05 07:35:22 UTC (rev 778) @@ -818,7 +818,7 @@ else: return None - def addOverlay(self, ovltype=None, type='overlay', command=None, + def AddOverlay(self, ovltype=None, type='overlay', command=None, l_active=True, l_hidden=False, l_opacity=1, l_render=False): """ Adds overlay (grid, barscale, others?) to list of overlays @@ -832,7 +832,7 @@ Added layer on success or None """ - Debug.msg (2, "Map.addOverlay(): cmd=%s, render=%d" % (command, l_render)) + Debug.msg (2, "Map.AddOverlay(): cmd=%s, render=%d" % (command, l_render)) overlay = MapLayer(type='overlay', name=None, cmd=command, active=l_active, hidden=l_hidden, opacity=l_opacity) From landa at grass.itc.it Tue Jun 5 16:08:25 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Tue Jun 5 16:08:27 2007 Subject: [grass-addons] r779 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200706051408.l55E8PTO019707@grass.itc.it> Author: landa Date: 2007-06-05 16:06:57 +0200 (Tue, 05 Jun 2007) New Revision: 779 Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py trunk/grassaddons/gui/wxgui.py Log: minor changes in layer popup menu Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-05 07:35:22 UTC (rev 778) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-05 14:06:57 UTC (rev 779) @@ -188,7 +188,8 @@ """Change layer name""" Debug.msg (3, "LayerTree.OnChangeLayerName: name=%s" % event.GetLabel()) - self.Map.ChangeLayerName (self.layer_selected, event.GetLabel()) + if self.layers[self.layer_selected].type != 'group': + self.Map.ChangeLayerName (self.layer_selected, event.GetLabel()) def OnContextMenu (self, event): """Context Layer Menu""" @@ -197,10 +198,13 @@ event.Skip() return + ltype = self.layers[self.layer_selected].type + + Debug.msg (4, "LayerTree.OnContextMenu: layertype=%s" % \ + ltype) + pos = event.GetPosition() pos = self.ScreenToClient(pos) - - ltype = self.layers[self.layer_selected].type if not hasattr (self, "popupID1"): self.popupID1 = wx.NewId() @@ -210,43 +214,46 @@ self.popupID5 = wx.NewId() self.popupID6 = wx.NewId() - self.Bind (wx.EVT_MENU, self.gismgr.DeleteLayer, id=self.popupID1) - self.Bind (wx.EVT_MENU, self.RenameLayer, id=self.popupID2) - self.Bind (wx.EVT_MENU, self.OnPopupProperties, id=self.popupID3) - self.popupMenu = wx.Menu() # general item - self.popupMenu.Append (self.popupID1, _("Delete")) - self.popupMenu.Append (self.popupID2, _("Rename")) + self.popupMenu.Append(self.popupID1, text=_("Delete")) + self.Bind(wx.EVT_MENU, self.gismgr.DeleteLayer, id=self.popupID1) + + if ltype != "command": # rename + self.popupMenu.Append(self.popupID2, text=_("Rename")) + self.Bind(wx.EVT_MENU, self.RenameLayer, id=self.popupID2) # map layer items - if ltype != "group": # properties + if ltype != "group" and \ + ltype != "command": # properties self.popupMenu.AppendSeparator() self.popupMenu.Append(self.popupID3, text=_("Properties")) + self.Bind(wx.EVT_MENU, self.OnPopupProperties, id=self.popupID3) # specific items try: mltype = self.layers[self.layer_selected].maplayer.type except: - return + mltype = None # vector specific items - if mltype == "vector": + if mltype and mltype == "vector": self.popupMenu.AppendSeparator() - self.popupMenu.Append(self.popupID4, _("Show attribute table")) - self.popupMenu.Append(self.popupID5, _("Start editing")) + self.popupMenu.Append(self.popupID4, text=_("Show attribute table")) + self.Bind (wx.EVT_MENU, self.gismgr.ShowAttributeTable, id=self.popupID4) + + self.popupMenu.Append(self.popupID5, text=_("Start editing")) + self.popupMenu.Append(self.popupID6, text=_("Stop editing")) + self.Bind (wx.EVT_MENU, self.OnStartEditing, id=self.popupID5) + self.Bind (wx.EVT_MENU, self.OnStopEditing, id=self.popupID6) + layer = self.layers[self.layer_selected].maplayer # enable editing only for vector map layers available in the current mapset if layer.GetMapset() != grassenv.env["MAPSET"]: self.popupMenu.Enable (self.popupID5, False) - self.popupMenu.Append(self.popupID6, _("Stop editing")) - self.popupMenu.Enable(self.popupID6, False) + self.popupMenu.Enable(self.popupID6, False) - self.Bind (wx.EVT_MENU, self.gismgr.ShowAttributeTable, id=self.popupID4) - self.Bind (wx.EVT_MENU, self.OnStartEditing, id=self.popupID5) - self.Bind (wx.EVT_MENU, self.OnStopEditing, id=self.popupID6) - # raster - elif mltype == "raster": + elif mltype and mltype == "raster": self.popupMenu.AppendSeparator() self.popupMenu.Append(self.popupID4, _("Histogram")) self.Bind (wx.EVT_MENU, self.OnHistogram, id=self.popupID4) Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-05 07:35:22 UTC (rev 778) +++ trunk/grassaddons/gui/wxgui.py 2007-06-05 14:06:57 UTC (rev 779) @@ -589,8 +589,13 @@ self.MsgNoLayerSelected() return - dlg = wx.MessageDialog (parent=self, message=_("Are you sure you want delete layer <" + \ - str(self.curr_page.maptree.GetItemText(self.curr_page.maptree.layer_selected)) + ">?"), + layerName = str(self.curr_page.maptree.GetItemText(self.curr_page.maptree.layer_selected)) + if layerName: + message = _("Are you sure you want delete layer <" + layerName + ">?") + else: + message = _("Are you sure you want delete this layer?") + + dlg = wx.MessageDialog (parent=self, message=message, caption=_("Delete layer"), style=wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_QUESTION) From landa at grass.itc.it Tue Jun 5 18:35:52 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Tue Jun 5 18:35:53 2007 Subject: [grass-addons] r780 - trunk/grassaddons/gui/gui_modules Message-ID: <200706051635.l55GZqKM021509@grass.itc.it> Author: landa Date: 2007-06-05 18:35:39 +0200 (Tue, 05 Jun 2007) New Revision: 780 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py Log: remove redundant code Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-05 14:06:57 UTC (rev 779) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-05 16:35:39 UTC (rev 780) @@ -53,13 +53,6 @@ imagepath = images.__path__[0] sys.path.append(imagepath) -icons = "" - -if not os.getenv("GRASS_ICONPATH"): - icons = os.getenv("GISBASE") + "/etc/gui/icons/" -else: - icons = os.environ["GRASS_ICONPATH"] - # for cmdlinef cmdfilename = None @@ -2241,10 +2234,6 @@ import gettext gettext.install("gm_map") # replace with the appropriate catalog name - - if not os.getenv("GRASS_ICONPATH"): - os.environ["GRASS_ICONPATH"]=os.getenv("GISBASE")+"/etc/gui/icons/" - print "Starting monitor <%s>" % (title) gm_map = MapApp(0) From barton at grass.itc.it Wed Jun 6 08:13:49 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Jun 6 08:14:07 2007 Subject: [grass-addons] r781 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200706060613.l566DnJA000811@grass.itc.it> Author: barton Date: 2007-06-06 08:13:21 +0200 (Wed, 06 Jun 2007) New Revision: 781 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/wxgui_utils.py trunk/grassaddons/gui/wxgui.py Log: Layer manager window (GIS Manager) now a AUI managed window so that map display can be docked to it by user if desired. Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-05 16:35:39 UTC (rev 780) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-06 06:13:21 UTC (rev 781) @@ -1088,7 +1088,8 @@ def __init__(self, parent=None, id = wx.ID_ANY, title="GRASS GIS Map display", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"], - tree=None, notebook=None, gismgr=None, page=None, Map=None): + tree=None, notebook=None, gismgr=None, page=None, + Map=None, auimgr=None): """ Main map display window with toolbars, statusbar and DrawWindow @@ -1137,6 +1138,7 @@ # # Fancy gui # +# self._mgr = auimgr self._mgr = wx.aui.AuiManager(self) self.SetIcon(wx.Icon(os.path.join(imagepath,'grass.map.gif'), wx.BITMAP_TYPE_ANY)) @@ -1200,7 +1202,10 @@ # # Update fancy gui style # - self._mgr.AddPane(self.MapWindow, wx.CENTER) + self._mgr.AddPane(self.MapWindow, wx.aui.AuiPaneInfo().CentrePane(). + Dockable(False).BestSize((-1,-1)). + CloseButton(False).DestroyOnClose(True). + Layer(0)) self._mgr.Update() # @@ -1227,16 +1232,20 @@ self._mgr.AddPane(self.maptoolbar.toolbar, wx.aui.AuiPaneInfo(). Name("maptoolbar").Caption("Map Toolbar"). - ToolbarPane().Top().LeftDockable(False).RightDockable(False). - BottomDockable(False).TopDockable(True).CloseButton(False)) + ToolbarPane().Top(). + LeftDockable(False).RightDockable(False). + BottomDockable(False).TopDockable(True). + CloseButton(False).Layer(2)) elif name == "digit": self.digittoolbar = toolbars.DigitToolbar(self, self.Map) self._mgr.AddPane(self.digittoolbar.toolbar, wx.aui.AuiPaneInfo(). Name("digittoolbar").Caption("Digit Toolbar"). - ToolbarPane().Top().Row(1).LeftDockable(False).RightDockable(True). - BottomDockable(False).TopDockable(False).CloseButton(False)) + ToolbarPane().Top().Row(1). + LeftDockable(False).RightDockable(True). + BottomDockable(False).TopDockable(False). + CloseButton(False).Layer(2)) self._mgr.Update() Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-05 16:35:39 UTC (rev 780) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-06 06:13:21 UTC (rev 781) @@ -26,14 +26,14 @@ class AbstractLayer: """ Abstract layer in LayerTree - + Attributes: - * type - layer type ('cmdlayer', 'group', etc) -- see LayerTree.AddLayer() + * type - layer type ('cmdlayer', 'group', etc) -- see LayerTree.AddLayer() """ def __init__(self, type): self.type = type - + class Layer(AbstractLayer): """ This class represents general item in LayerTree @@ -59,7 +59,7 @@ def __del__(self): Debug.msg (3, "Layer.__del__(): type=%s" % \ self.type) - + def AddMapLayer (self, maplayer): """Add reference to MapLayer instance""" self.maplayer = maplayer @@ -78,7 +78,8 @@ size=wx.DefaultSize, style=wx.SUNKEN_BORDER, ctstyle=CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT | CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT| - CT.TR_EDIT_LABELS|CT.TR_MULTIPLE, idx=None, gismgr=None, notebook=None): + CT.TR_EDIT_LABELS|CT.TR_MULTIPLE, + idx=None, gismgr=None, notebook=None, auimgr=None): CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style,ctstyle) self.SetAutoLayout(True) @@ -99,18 +100,17 @@ self.gismgr = gismgr self.notebook = notebook # GIS Manager notebook for layer tree self.treepg = parent # notebook page holding layer tree + self.auimgr = auimgr # aui manager - # init associated map display self.mapdisplay = mapdisp.MapFrame(self, id=wx.ID_ANY, pos=wx.DefaultPosition, size=(640,480), style=wx.DEFAULT_FRAME_STYLE, tree=self, notebook=self.notebook, gismgr=self.gismgr, page=self.treepg, - Map=self.Map) + Map=self.Map, auimgr=self.auimgr) # title self.mapdisplay.SetTitle(_("GRASS GIS - Map Display: " + str(self.disp_idx) + " - Location: " + grassenv.env["LOCATION_NAME"])) - #self.maptree[self.disp_idx] = self.mapdisplays[self.disp_idx].getTree() #show new display self.mapdisplay.Show() @@ -272,19 +272,19 @@ if hasattr (self.mapdisplay, "histogram") and self.mapdisplay.histogram: self.histogramFrame = self.mapdisplay.histogram - + if not self.histogramFrame: self.histogramFrame = histogram.HistFrame(self, id=wx.ID_ANY, pos=wx.DefaultPosition, size=(400,300), style=wx.DEFAULT_FRAME_STYLE) # show new display self.histogramFrame.Show() - + self.histogramFrame.SetHistLayer(['d.histogram', 'map=%s' % rastName]) self.histogramFrame.HistWindow.UpdateHist() self.histogramFrame.Refresh() self.histogramFrame.Update() - + def OnStartEditing (self, event): """ Start editing vector map layer requested by the user @@ -324,7 +324,7 @@ self.first = True checked = False params = {} # no initial options parameters - + if self.layer_selected: self.SelectItem(self.layer_selected, select=False) @@ -352,18 +352,18 @@ # add layer to the layer tree if (self.layer_selected and self.layer_selected != self.GetRootItem() and \ - self.layers[self.layer_selected].type != 'group'): + self.layers[self.layer_selected].type != 'group'): parent = self.GetItemParent(self.layer_selected) layer = self.InsertItem(parent, self.GetPrevSibling(self.layer_selected), text='', ct_type=1, wnd=ctrl) # add layer to the group elif (self.layer_selected and self.layer_selected != self.GetRootItem() and \ - self.layers[self.layer_selected].type == 'group'): + self.layers[self.layer_selected].type == 'group'): layer = self.PrependItem(parent=self.layer_selected, text='', ct_type=1, wnd=ctrl) self.Expand(self.layer_selected) # add first layer to the layer tree - else: + else: layer = self.PrependItem(parent=self.root, text='', ct_type=1, wnd=ctrl) # create Layer instance & add to self.layers dictionary @@ -431,7 +431,7 @@ Debug.msg (3, "LayerTree.PropertiesDialog(): ltype=%s" % \ ltype) - + if ltype == 'raster': menuform.GUI().ParseCommand('d.rast', gmpath, completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'rgb': @@ -473,12 +473,12 @@ """Remove selected layer for the layer tree""" item = event.GetItem() - + try: item.properties.Close(True) except: pass - + Debug.msg (3, "LayerTree.OnDeleteLayer(): name=%s" % \ (self.GetItemText(item))) @@ -496,7 +496,7 @@ item = event.GetItem() checked = item.IsChecked() layer = self.layers[item] - + if self.drag == False and self.first == False: # change active parameter for item in layers list in render.Map if layer.type == 'group': @@ -519,11 +519,11 @@ cmd = event.GetString() layer = item = None - + for item, layer in self.layers.iteritems(): if layer.wxCtrl == ctrl: break - + # change parameters for item in layers list in render.Map if item and self.drag == False: self.ChangeLayer(item) @@ -531,7 +531,7 @@ if 'map=' in option: mapname = option.split('=')[1] self.Map.ChangeLayerName(layer.maplayer, mapname) - + event.Skip() def OnOpacity(self, event): @@ -580,7 +580,7 @@ """ Drag and drop of tree nodes """ - + item = event.GetItem() Debug.msg (3, "LayerTree.OnBeginDrag(): layer=%s" % \ (self.GetItemText(item))) @@ -588,7 +588,7 @@ event.Allow() self.drag = True self.DoSelectItem(item, unselect_others=True) - + # save everthing associated with item to drag self.dragItem = item @@ -597,7 +597,7 @@ Recreate item (needed for OnEndDrag()) """ oldLayer = self.layers[oldItem] - + Debug.msg (4, "LayerTree.RecreateItem(): layer=%s" % \ self.GetItemText(oldItem)) @@ -623,7 +623,7 @@ except: newctrl.SetValue(100) self.Bind(wx.EVT_SPINCTRL, self.OnOpacity, newctrl) - + # decide where to put new layer and put it there if not parent: flag = self.HitTest(event.GetPoint())[1] @@ -634,7 +634,7 @@ text = self.GetItemText(oldItem) image = self.GetItemImage(oldItem, 0) wind = self.GetItemWindow(oldItem) - checked = self.IsItemChecked(oldItem) + checked = self.IsItemChecked(oldItem) if oldLayer.type == 'group': windval = None data = None @@ -675,9 +675,9 @@ self.layers[new].wxCtrl = newctrl self.CheckItem(new, checked=checked) - + event.Skip() - + return new def OnEndDrag(self, event): @@ -691,7 +691,7 @@ old = self.dragItem # make sure this member exists except: return - + Debug.msg (4, "LayerTree.OnEndDrag(): layer=%s" % \ (self.GetItemText(self.dragItem))) @@ -775,7 +775,7 @@ Debug.msg (4, "LayerTree.ReoderLayers(): items=%s" % \ (itemList)) - + # reorder map layers treelayers.reverse() self.Map.ReorderLayers(treelayers) @@ -783,7 +783,7 @@ def ChangeLayer(self, item): """Change layer""" layer = self.layers[item] - + if layer.type == 'command': if self.GetItemWindow(item).GetValue() != None: cmdlist = self.GetItemWindow(item).GetValue().split(' ') @@ -796,7 +796,7 @@ opac = float(self.GetItemWindow(item).GetValue())/100 chk = self.IsItemChecked(item) hidden = not self.IsVisible(item) - + layer.maplayer = self.Map.ChangeLayer(layer=layer.maplayer, type=layer.maplayer.type, command=cmdlist, name=self.GetItemText(item), l_active=chk, l_hidden=hidden, l_opacity=opac, l_render=False) @@ -1012,7 +1012,7 @@ gisbase = os.environ['GISBASE'] self.gcmdlst = os.listdir(gisbase+r'/bin') self.gcmdlst = self.gcmdlst + os.listdir(gisbase+r'/scripts') - + return self.gcmdlst def RunCmd(self, command): Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-05 16:35:39 UTC (rev 780) +++ trunk/grassaddons/gui/wxgui.py 2007-06-06 06:13:21 UTC (rev 781) @@ -6,7 +6,7 @@ PURPOSE: Main Python app to set up GIS Manager window and trap commands Only command console is working currently, but windows for panels and layer tree done and demo tree items appear - + AUTHORS: The GRASS Development Team Michael Barton (Arizona State University) & Jachym Cepicky (Mendel University of Agriculture) @@ -26,6 +26,7 @@ import types import wx +import wx.aui import wx.combo import wx.html import wx.stc @@ -44,7 +45,6 @@ gmpath = icons.__path__[0] sys.path.append(gmpath) -import gui_modules.track as track import gui_modules.wxgui_utils as wxgui_utils import gui_modules.mapdisp as mapdisp import gui_modules.render as render @@ -111,19 +111,21 @@ self.iconsize = (16, 16) wx.Frame.__init__(self, parent=parent, id=-1, title=title, style=wx.DEFAULT_FRAME_STYLE) + self._auimgr = wx.aui.AuiManager(self) + # creating widgets self.notebook = self.__createNoteBook() + self.cmdinput = self.__createCommandInput() self.menubar = self.__createMenuBar() toolbar = self.__createToolBar() #self.panel = wx.Panel(self,-1, style= wx.EXPAND) self.sizer= wx.BoxSizer(wx.VERTICAL) - self.cmdsizer = wx.BoxSizer(wx.HORIZONTAL) - self.track = track +# self.cmdsizer = wx.BoxSizer(wx.HORIZONTAL) # do layout self.SetTitle(_("GRASS GIS Manager - wxPython Prototype")) - self.SetMinSize((450, 450)) + self.SetMinSize((400, 450)) self.SetIcon(wx.Icon(os.path.join(imagepath,'grass.smlogo.gif'), wx.BITMAP_TYPE_ANY)) # set environmental variables @@ -141,10 +143,23 @@ self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self.Bind(wx.EVT_LEFT_DOWN, self.AddRaster) + self._auimgr.AddPane(toolbar, wx.aui.AuiPaneInfo().ToolbarPane(). + Top().Dockable(False).CloseButton(False). + DestroyOnClose(True).Row(0).Layer(0)) + self._auimgr.AddPane(self.notebook, wx.aui.AuiPaneInfo(). + Left().CentrePane().BestSize((-1,-1)).Dockable(False). + CloseButton(False).DestroyOnClose(True).Row(1).Layer(0)) + self._auimgr.AddPane(self.cmdinput, wx.aui.AuiPaneInfo(). + Bottom().BestSize((-1,25)).Dockable(False). + CloseButton(False).DestroyOnClose(True). + PaneBorder(False).Row(2).Layer(0). + CaptionVisible(False)) + self._auimgr.Update() + # item, proportion, flag, border, userData - self.sizer.Add(self.notebook, proportion=1, flag=wx.EXPAND, border=1) - self.sizer.Add(self.cmdinput, proportion=0, flag=wx.EXPAND, border=1) - self.SetSizer(self.sizer) +# self.sizer.Add(self.notebook, proportion=1, flag=wx.EXPAND, border=1) +# self.sizer.Add(self.cmdinput, proportion=0, flag=wx.EXPAND, border=1) +# self.SetSizer(self.sizer) self.sizer.Fit(self) self.Layout() wx.CallAfter(self.notebook.SetSelection, 0) @@ -235,6 +250,8 @@ #self.out_sizer.Fit(self.outpage) #self.outpage.Layout() + + self.Centre() return self.notebook @@ -316,9 +333,6 @@ id=wx.ID_ANY, pos=wx.DefaultPosition, size=(400,300), style=wx.DEFAULT_FRAME_STYLE) - # title -# self.histogram.SetTitle(_("GRASS GIS - Map Display: " + str(self.disp_idx) + " - Location: " + grassenv.env["LOCATION_NAME"])) - #show new display self.histogram.Show() self.histogram.Refresh() @@ -396,7 +410,7 @@ return mapname = map = mapset = size = icon = None - + for option in dcmd: if option.find('map') > -1: mapname = option.split('=')[1] @@ -425,7 +439,8 @@ size=wx.DefaultSize, style=wx.TR_HAS_BUTTONS |wx.TR_LINES_AT_ROOT|wx.TR_EDIT_LABELS|wx.TR_HIDE_ROOT |wx.TR_DEFAULT_STYLE|wx.NO_BORDER|wx.FULL_REPAINT_ON_RESIZE, - idx=self.disp_idx, gismgr=self, notebook=self.gm_cb) + idx=self.disp_idx, gismgr=self, notebook=self.gm_cb, + auimgr=self._auimgr) # layout for controls cb_boxsizer = wx.BoxSizer(wx.VERTICAL) @@ -437,6 +452,13 @@ self.disp_idx += 1 +# self._auimgr.AddPane(self.curr_page.maptree.mapdisplay, wx.aui.AuiPaneInfo().Right(). +# Dockable(False).BestSize((-1,-1)). +# CloseButton(True).MinimizeButton(True). +# DestroyOnClose(True).Layer(1)) +# +# self._auimgr.Update() + # toolBar button handlers def OnRaster(self, event): """Add raster menu""" @@ -649,13 +671,13 @@ wx.SplashScreen (bitmap=introBmp, splashStyle=wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, milliseconds=1500, parent=None, id=wx.ID_ANY) wx.Yield() - + # create and show main frame mainframe = GMFrame(parent=None, id=wx.ID_ANY, title="") mainframe.Show() self.SetTopWindow(mainframe) - + return True def reexec_with_pythonw(): From barton at grass.itc.it Wed Jun 6 08:35:04 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Jun 6 08:35:06 2007 Subject: [grass-addons] r782 - trunk/grassaddons/gui Message-ID: <200706060635.l566Z4dX001335@grass.itc.it> Author: barton Date: 2007-06-06 08:34:39 +0200 (Wed, 06 Jun 2007) New Revision: 782 Modified: trunk/grassaddons/gui/wxgui.py Log: Added command prompt at bottom Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-06 06:13:21 UTC (rev 781) +++ trunk/grassaddons/gui/wxgui.py 2007-06-06 06:34:39 UTC (rev 782) @@ -117,6 +117,7 @@ self.notebook = self.__createNoteBook() self.cmdinput = self.__createCommandInput() + self.cmdprompt = self.__createCommandPrompt() self.menubar = self.__createMenuBar() toolbar = self.__createToolBar() #self.panel = wx.Panel(self,-1, style= wx.EXPAND) @@ -149,10 +150,15 @@ self._auimgr.AddPane(self.notebook, wx.aui.AuiPaneInfo(). Left().CentrePane().BestSize((-1,-1)).Dockable(False). CloseButton(False).DestroyOnClose(True).Row(1).Layer(0)) + self._auimgr.AddPane(self.cmdprompt, wx.aui.AuiPaneInfo(). + Bottom().BestSize((-1,25)).Dockable(False). + CloseButton(False).DestroyOnClose(True). + PaneBorder(False).Row(2).Layer(0).Position(0). + Fixed().CaptionVisible(False).PinButton(False)) self._auimgr.AddPane(self.cmdinput, wx.aui.AuiPaneInfo(). Bottom().BestSize((-1,25)).Dockable(False). CloseButton(False).DestroyOnClose(True). - PaneBorder(False).Row(2).Layer(0). + PaneBorder(False).Row(2).Layer(0).Position(1). CaptionVisible(False)) self._auimgr.Update() @@ -167,6 +173,11 @@ # start default initial display self.NewDisplay() + def __createCommandPrompt(self): + """Creates command prompt""" + self.cmdprompt = wx.StaticText(self, -1, " command: ") + return self.cmdprompt + def __createCommandInput(self): """Creates command input area""" #l = wx.StaticText(self, -1, "GRASS> ") From barton at grass.itc.it Wed Jun 6 08:51:47 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Jun 6 08:51:50 2007 Subject: [grass-addons] r783 - trunk/grassaddons/gui Message-ID: <200706060651.l566plVq001436@grass.itc.it> Author: barton Date: 2007-06-06 08:51:34 +0200 (Wed, 06 Jun 2007) New Revision: 783 Modified: trunk/grassaddons/gui/wxgui.py Log: Some code cleanup and tightening minimum window size. Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-06 06:34:39 UTC (rev 782) +++ trunk/grassaddons/gui/wxgui.py 2007-06-06 06:51:34 UTC (rev 783) @@ -126,7 +126,7 @@ # do layout self.SetTitle(_("GRASS GIS Manager - wxPython Prototype")) - self.SetMinSize((400, 450)) + self.SetMinSize((400, 350)) self.SetIcon(wx.Icon(os.path.join(imagepath,'grass.smlogo.gif'), wx.BITMAP_TYPE_ANY)) # set environmental variables @@ -235,20 +235,16 @@ """Creates notebook widgets""" # create main notebook widget - #bookStyle=FN.FNB_DEFAULT_STYLE #| FN.FNB_FANCY_TABS - #bookStyle=FN.FNB_DEFAULT_STYLE|FN.FNB_BOTTOM|FN.FNB_NO_X_BUTTON|FN.FNB_NO_NAV_BUTTONS nbStyle=FN.FNB_FANCY_TABS|FN.FNB_BOTTOM|FN.FNB_NO_X_BUTTON|FN.FNB_NO_NAV_BUTTONS self.notebook = FN.FlatNotebook(self, id=wx.ID_ANY, style=nbStyle) # create displays notebook widget and add it to main notebook page cbStyle=FN.FNB_VC8|FN.FNB_BACKGROUND_GRADIENT|FN.FNB_X_ON_TAB|FN.FNB_TABS_BORDER_SIMPLE - #self.cb_panel = wx.Panel(self,-1, style = wx.EXPAND) self.gm_cb = FN.FlatNotebook(self, id=wx.ID_ANY, style=cbStyle) self.gm_cb.SetTabAreaColour(wx.Colour(125,200,175)) self.notebook.AddPage(self.gm_cb, text="Map layers for each display") # create command output text area and add it to main notebook page - #self.outpanel = wx.Panel(self,-1, style = wx.EXPAND) self.goutput = wxgui_utils.GMConsole(self) self.outpage = self.notebook.AddPage(self.goutput, text="Command output") @@ -651,7 +647,8 @@ self.gm_cb.GetPage(page).maptree.Map.Clean() self.DeleteAllPages() except: - self.DestroyChildren() + pass +# self.DestroyChildren() self.Destroy() def Nomethod(self, event): From barton at grass.itc.it Wed Jun 6 09:37:04 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Jun 6 09:37:10 2007 Subject: [grass-addons] r784 - trunk/grassaddons/gui/gui_modules Message-ID: <200706060737.l567b4I1001683@grass.itc.it> Author: barton Date: 2007-06-06 09:36:52 +0200 (Wed, 06 Jun 2007) New Revision: 784 Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Fix for command line entry. d.* commands not working yet, but getting closer. Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-06 06:51:34 UTC (rev 783) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-06 07:36:52 UTC (rev 784) @@ -218,7 +218,7 @@ # general item self.popupMenu.Append(self.popupID1, text=_("Delete")) self.Bind(wx.EVT_MENU, self.gismgr.DeleteLayer, id=self.popupID1) - + if ltype != "command": # rename self.popupMenu.Append(self.popupID2, text=_("Rename")) self.Bind(wx.EVT_MENU, self.RenameLayer, id=self.popupID2) @@ -236,7 +236,7 @@ except: mltype = None # vector specific items - if mltype and mltype == "vector": + if mltype and mltype == "vector": self.popupMenu.AppendSeparator() self.popupMenu.Append(self.popupID4, text=_("Show attribute table")) self.Bind (wx.EVT_MENU, self.gismgr.ShowAttributeTable, id=self.popupID4) @@ -250,7 +250,7 @@ # enable editing only for vector map layers available in the current mapset if layer.GetMapset() != grassenv.env["MAPSET"]: self.popupMenu.Enable (self.popupID5, False) - self.popupMenu.Enable(self.popupID6, False) + self.popupMenu.Enable(self.popupID6, False) # raster elif mltype and mltype == "raster": @@ -958,7 +958,7 @@ style=wx.TAB_TRAVERSAL|wx.FULL_REPAINT_ON_RESIZE): wx.Panel.__init__(self, parent, id, pos, size, style) #initialize variables - + self.Map = render.Map() self.parent = parent self.cmd_output = "" self.console_command = "" @@ -1077,10 +1077,14 @@ #self.cmd_output.write(command + "\n----------\n") self.cmd_output.write("$" + ' '.join(command)) # TODO This needs to be fixed to use current rendering procedures - # dcmds = command.split(',') - # curr_disp.addMapsToList(type='command', map=dcmds, mset=None) - # curr_disp.ReDrawCommand() + # + dcmds = command.split(',') + for command in dcmds: + self.Map.AddLayer(type='command', command=[command], + l_active=checked, l_hidden=False, l_opacity=1, l_render=False) + + else: # Send any other command to the shell. Send output to # console output window. @@ -1092,7 +1096,15 @@ tmpreg = os.getenv("GRASS_REGION") os.unsetenv("GRASS_REGION") - p = cmd.Command(command + ["--verbose"]) + if command in gcmdlst: + cmdlist = command.split(' ') + cmdlist = cmdlist.append('--verbose') + p = cmd.Command(cmdlist) + else: + output = os.popen(command, "r").read().strip().split('\n') + for outline in output: + self.cmd_output.write(outline+'\n') + return # deactivate computational region and return to display settings if tmpreg: From barton at grass.itc.it Wed Jun 6 09:56:30 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Jun 6 09:56:32 2007 Subject: [grass-addons] r785 - trunk/grassaddons/gui/gui_modules Message-ID: <200706060756.l567uU2F001783@grass.itc.it> Author: barton Date: 2007-06-06 09:56:21 +0200 (Wed, 06 Jun 2007) New Revision: 785 Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Further fixes for command line processing. d.* commands without arguments work now to add layer to layer tree. Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-06 07:36:52 UTC (rev 784) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-06 07:56:21 UTC (rev 785) @@ -958,7 +958,7 @@ style=wx.TAB_TRAVERSAL|wx.FULL_REPAINT_ON_RESIZE): wx.Panel.__init__(self, parent, id, pos, size, style) #initialize variables - self.Map = render.Map() + self.Map = '' self.parent = parent self.cmd_output = "" self.console_command = "" @@ -1022,7 +1022,7 @@ output text widget, and send stdout output to output text widget. - Note: 'command' is given as list + Command is transformed into a list for processing TODO: Display commands (*.d) are captured and processed separately by mapdisp.py. Display commands are @@ -1035,15 +1035,16 @@ # cmd = self.console_command.GetLineText(0) try: curr_disp = self.Parent.Parent.curr_page.maptree.mapdisplay + self.Map = self.mapdisplay.getRender() except: # disp_idx = None curr_disp = None - if len(command) == 1 and command[0] in gcmdlst: + if len(command.split(' ')) == 1 and command in gcmdlst: # send GRASS command without arguments to GUI command interface # except display commands (they are handled differently) global gmpath - if command[0][0:2] == "d.": + if command[0:2] == "d.": try: layertype = {'d.rast' : 'raster', 'd.rgb' : 'rgb', @@ -1055,7 +1056,7 @@ 'd.vect.thematic': 'thememap', 'd.vect.chart' : 'themechart', 'd.grid' : 'grid', - 'd.labels' : 'labels'}[command[0]] + 'd.labels' : 'labels'}[command] except KeyError: print _('Command type not yet implemented') return @@ -1064,10 +1065,10 @@ self.Parent.Parent.curr_page.maptree.AddLayer(layertype) else: - menuform.GUI().ParseCommand(command[0], gmpath, parentframe=None) - self.command_output.write(command[0] + "\n----------\n") + menuform.GUI().ParseCommand(command, gmpath, parentframe=None) + self.cmd_output.write(command + "\n----------\n") - elif command[0][0:2] == "d." and len(command) > 1 and command[0] in gcmdlst: + elif command[0:2] == "d." and len(command.split(' ')) > 1 and command in gcmdlst: """ Send GRASS display command(s)with arguments to the display processor and echo to command output console. @@ -1081,8 +1082,10 @@ dcmds = command.split(',') for command in dcmds: - self.Map.AddLayer(type='command', command=[command], + cmdlist = command.split(' ') + self.Map.AddLayer(type='command', command=cmdlist, l_active=checked, l_hidden=False, l_opacity=1, l_render=False) + curr_disp.UpdateMap() else: From barton at grass.itc.it Wed Jun 6 22:05:30 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Jun 6 22:05:32 2007 Subject: [grass-addons] r786 - trunk/grassaddons/gui/gui_modules Message-ID: <200706062005.l56K5Umj012863@grass.itc.it> Author: barton Date: 2007-06-06 22:05:23 +0200 (Wed, 06 Jun 2007) New Revision: 786 Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Fixed CLI so that d.* commands with arguments now display to current map display. Multiple d.* commands, separated by commas will display. Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-06 07:56:21 UTC (rev 785) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-06 20:05:23 UTC (rev 786) @@ -1035,7 +1035,7 @@ # cmd = self.console_command.GetLineText(0) try: curr_disp = self.Parent.Parent.curr_page.maptree.mapdisplay - self.Map = self.mapdisplay.getRender() + self.Map = curr_disp.getRender() except: # disp_idx = None curr_disp = None @@ -1068,7 +1068,7 @@ menuform.GUI().ParseCommand(command, gmpath, parentframe=None) self.cmd_output.write(command + "\n----------\n") - elif command[0:2] == "d." and len(command.split(' ')) > 1 and command in gcmdlst: + elif command[0:2] == "d." and len(command.split(' ')) > 1 and command.split(' ')[0] in gcmdlst: """ Send GRASS display command(s)with arguments to the display processor and echo to command output console. @@ -1084,10 +1084,12 @@ for command in dcmds: cmdlist = command.split(' ') self.Map.AddLayer(type='command', command=cmdlist, - l_active=checked, l_hidden=False, l_opacity=1, l_render=False) - curr_disp.UpdateMap() + l_active=True, l_hidden=False, l_opacity=1, l_render=False) + curr_disp.MapWindow.UpdateMap() + + else: # Send any other command to the shell. Send output to # console output window. @@ -1137,7 +1139,6 @@ self.cmd_output.write('North: '+rastqlist[1]+"\n") self.cmd_output.write(rastqlist[2]+"\n") data = rastqlist[3:] - print 'data=',data for x in range(0,len(data),2): self.cmd_output.write('Category: '+data[x]+"\n") self.cmd_output.write('Label: '+data[x+1]+"\n") From barton at grass.itc.it Thu Jun 7 02:16:40 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Jun 7 02:16:42 2007 Subject: [grass-addons] r787 - trunk/grassaddons/gui/gui_modules Message-ID: <200706070016.l570Geht015630@grass.itc.it> Author: barton Date: 2007-06-07 02:16:34 +0200 (Thu, 07 Jun 2007) New Revision: 787 Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Changed delimiter between display commands in the CLI from , to ; Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-06 20:05:23 UTC (rev 786) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-07 00:16:34 UTC (rev 787) @@ -1080,7 +1080,7 @@ # TODO This needs to be fixed to use current rendering procedures # - dcmds = command.split(',') + dcmds = command.split(';') for command in dcmds: cmdlist = command.split(' ') self.Map.AddLayer(type='command', command=cmdlist, From barton at grass.itc.it Fri Jun 8 04:44:48 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 8 04:44:49 2007 Subject: [grass-addons] r788 - trunk/grassaddons/gui Message-ID: <200706080244.l582imZb000859@grass.itc.it> Author: barton Date: 2007-06-08 04:44:39 +0200 (Fri, 08 Jun 2007) New Revision: 788 Modified: trunk/grassaddons/gui/wxgui.py Log: Add status bar with auto display of help for menu items. Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-07 00:16:34 UTC (rev 787) +++ trunk/grassaddons/gui/wxgui.py 2007-06-08 02:44:39 UTC (rev 788) @@ -111,6 +111,8 @@ self.iconsize = (16, 16) wx.Frame.__init__(self, parent=parent, id=-1, title=title, style=wx.DEFAULT_FRAME_STYLE) + self.CreateStatusBar() + self._auimgr = wx.aui.AuiManager(self) # creating widgets @@ -217,6 +219,7 @@ menu.AppendMenu(wx.NewId(), label, subMenu) else: self.__createMenuItem(menu, *eachItem) + self.Bind(wx.EVT_MENU_HIGHLIGHT_ALL, self.OnMenuHighlight) return menu def __createMenuItem(self, menu, label, help, handler, gcmd, kind=wx.ITEM_NORMAL): @@ -262,7 +265,20 @@ self.Centre() return self.notebook + def OnMenuHighlight(self, event): + """ + Default menu help handler + """ + # Show how to get menu item info from this event handler + id = event.GetMenuId() + item = self.GetMenuBar().FindItemById(id) + if item: + text = item.GetText() + help = item.GetHelp() + # but in this case just call Skip so the default is done + event.Skip() + # choicebook methods def onCBPageChanged(self, event): """Page in notebook changed""" @@ -295,7 +311,7 @@ #global gmpath cmd = self.cmdinput.GetValue() - self.goutput.runCmd(cmd) + self.goutput.RunCmd(cmd) #menuform.GUI().ParseCommand(cmd, gmpath) def runMenuCmd(self, event): @@ -459,11 +475,14 @@ self.disp_idx += 1 -# self._auimgr.AddPane(self.curr_page.maptree.mapdisplay, wx.aui.AuiPaneInfo().Right(). -# Dockable(False).BestSize((-1,-1)). -# CloseButton(True).MinimizeButton(True). -# DestroyOnClose(True).Layer(1)) +# self._auimgr.SetManagedWindow(self.curr_page.maptree.testframe) # +# self._auimgr.AddPane(self.curr_page.maptree.testframe, +# wx.aui.AuiPaneInfo().Right(). +# BestSize((-1,-1)). +# CloseButton(True).MinimizeButton(True). +# DestroyOnClose(True).Layer(2)) +# # self._auimgr.Update() # toolBar button handlers @@ -649,6 +668,7 @@ except: pass # self.DestroyChildren() + self._auimgr.UnInit() self.Destroy() def Nomethod(self, event): From barton at grass.itc.it Fri Jun 8 04:45:43 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 8 04:45:44 2007 Subject: [grass-addons] r789 - trunk/grassaddons/gui/gui_modules Message-ID: <200706080245.l582jhU4000879@grass.itc.it> Author: barton Date: 2007-06-08 04:45:34 +0200 (Fri, 08 Jun 2007) New Revision: 789 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Updated file menu to include all items in TclTk menus Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-08 02:44:39 UTC (rev 788) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-08 02:45:34 UTC (rev 789) @@ -4,10 +4,112 @@ def GetMenu(self): return [( ("Files", ( - ("Import", "Import files", "self.runMenuCmd", "r.in.gdal"), - ("Export", "Export files", "self.runMenuCmd", "r.out.gdal"), + ("Import", ( + ("Raster map", ( + ("Multiple formats using GDAL", "Import multiple formats using GDAL", "self.runMenuCmd", "r.in.gdal"), + ("","","", ""), + ("Aggregate ASCII xyz", "Import aggregate ASCII xyz data", "self.runMenuCmd", "r.in.xyz"), + ("ASCII grid", "Import ASCII GRID (includes GRASS ASCII)", "self.runMenuCmd", "r.in.ascii"), + ("ASCII polygons and lines", "Import Polygons and lines from ASCII file", "self.runMenuCmd", "r.in.poly"), + ("","","", ""), + ("Binary", "Import binary file (includes GTOPO30 format)", "self.runMenuCmd", "r.in.bin"), + ("ESRI Arc/Info ASCII grid", "Import ESRI Arc/Info ASCII grid", "self.runMenuCmd", "r.in.arc"), + ("GRIDATB.FOR", "Import GRIDATB.FOR map file (TOPMODEL)", "self.runMenuCmd", "r.in.gridatb"), + ("MAT-File (v.4)", "Import MAT-File (v.4) array (Matlab or Octave)", "self.runMenuCmd", "r.in.mat"), + ("SPOT NDVI", "Import SPOT vegetation NDVI data sets", "self.runMenuCmd", "r.in.spotvgt"), + ("SRTM HGT", "Import SRTM hgt files", "self.runMenuCmd", "r.in.srtm"), + ("Terra ASTER HDF", "Import Terra ASTER HDF files", "self.runMenuCmd", "r.in.aster"), + ("","","", ""), + ("WMS", "Import Web Mapping Server", "self.runMenuCmd", "r.in.wms"), + )), + ("Vector map", ( + ("Multiple formats using OGR", "Import multiple formats using OGR", "self.runMenuCmd", "v.in.ogr"), + ("","","", ""), + ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.runMenuCmd", "v.in.ascii"), + ("Old GRASS vector", "Import old GRASS vector format", "self.runMenuCmd", "v.convert"), + ("","","", ""), + ("DXF", "Import DXF file", "self.runMenuCmd", "v.in.dxf"), + ("ESRI e00", "Import ESRI e00 file", "self.runMenuCmd", "v.in.e00"), + ("Garmin GPS", "Import Garmin GPS Waypoints/Routes/Tracks", "self.runMenuCmd", "v.in.garmin"), + ("GPSBabel GPS", "Import GPS Waypoints/Routes/Tracks using GPSBabel", "self.runMenuCmd", "v.in.gpsbabel"), + ("GEOnet", "Import GEOnet Name server country files (US-NGA GNS)", "self.runMenuCmd", "v.in.gns"), + ("Matlab and MapGen", "Import Matlab and MapGen files", "self.runMenuCmd", "v.in.mapgen"), + )), + + ("Grid 3D", ( + ("ASCII 3D", "Import ASCII 3D file", "self.runMenuCmd", "r3.in.ascii"), + ("Vis5D", "Import Vis5D file", "self.runMenuCmd", "r3.in.v5d"), + )), + )), + ("Export", ( + ("Raster map", ( + ("Multiple formats using GDAL", "Export multiple formats using GDAL", "self.runMenuCmd", "r.out.gdal"), + ("","","", ""), + ("ASCII grid", "Export ASCII grid (for GRASS, Surfer, Modflow, etc)", "self.runMenuCmd", "r.out.ascii"), + ("ASCII x,y,z", "Export ASCII x,y,z values of cell centers", "self.runMenuCmd", "r.out.xyz"), + ("","","", ""), + ("ESRI ASCII grid", "Export ESRI Arc/Info ASCII grid", "self.runMenuCmd", "r.out.arc"), + ("GRIDATB.FOR", "Export GRIDATB.FOR map file (TOPMODEL)", "self.runMenuCmd", "r.out.gridatb"), + ("MAT-File (v.4)", "Export MAT-File (v.4) array (Matlab or Octave)", "self.runMenuCmd", "r.out.mat"), + ("","","", ""), + ("Binary", "Export binary file", "self.runMenuCmd", "r.out.bin"), + ("","","", ""), + ("MPEG-1", "Export MPEG-1 animations", "self.runMenuCmd", "r.out.mpeg"), + ("PNG", "Export PNG image (not georeferenced)", "self.runMenuCmd", "r.out.png"), + ("PPM", "Export PPM image (24bit)", "self.runMenuCmd", "r.out.ppm"), + ("POV-Ray", "Export POVray height-field", "self.runMenuCmd", "r.out.pov"), + ("TIFF", "Export TIFF image (8/24bit)", "self.runMenuCmd", "r.out.tiff"), + ("VRML", "Export VRML file", "self.runMenuCmd", "r.out.vrml"), + ("VTK", "Export VTK ASCII file", "self.runMenuCmd", "r.out.vtk"), + )), + ("Vector map", ( + ("Multiple formats using OGR", "Export multiple formats using OGR", "self.runMenuCmd", "v.out.ogr"), + ("","","", ""), + ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.runMenuCmd", "v.out.ascii"), + + ("DXF", "Export DXF file", "self.runMenuCmd", "v.out.dxf"), + ("POV-Ray", "Export POV-Ray format file", "self.runMenuCmd", "v.out.pov"), + ("SVG", "Export SVG file", "self.runMenuCmd", "v.out.svg"), + ("VTK", "Export VTK ASCII file", "self.runMenuCmd", "v.out.vtk"), + )), + + ("Grid 3D", ( + ("ASCII 3D", "Export ASCII 3D file", "self.runMenuCmd", "r3.out.ascii"), + ("Vis5D", "Export Vis5D file", "self.runMenuCmd", "r3.out.v5d"), + ("VTK", "Export VTK ASCII file", "self.runMenuCmd", "r3.out.vtk"), + )), + )), ("","","", ""), - ("E&xit", "Exit from wxgui.py", "self.OnCloseWindow", "") + ("Manage maps and volumes", ( + ("Copy", "Copy maps within mapsets or between mapsets", "self.runMenuCmd", "g.copy"), + ("","","", ""), + ("List", "List maps by type", "self.runMenuCmd", "list"), + ("List filtered", "List maps filtered by expressions and wildcards", "self.runMenuCmd", "g.mlist"), + ("","","", ""), + ("Rename", "Rename maps", "self.runMenuCmd", "g.rename"), + ("","","", ""), + ("Delete", "Delete maps", "self.runMenuCmd", "g.remove"), + ("Delete filtered", "Delete maps using expressions and wildcards", "self.runMenuCmd", "g.mremove"), + )), + ("Map type conversions", ( + ("Raster to vector", "Convert raster to vector map", "self.runMenuCmd", "r.to.vect"), + ("Raster series to volume", "Convert raster map series to volume", "self.runMenuCmd", "r.to.rast3"), + ("Raster 2.5D to volume", "Convert raster 2.5D map to volume", "self.runMenuCmd", "r.to.rast3elev"), + ("","","", ""), + ("Vector to raster", "Convert vector to raster map", "self.runMenuCmd", "v.to.rast"), + ("Vector to volume", "Convert vector 3D points to volume voxels", "self.runMenuCmd", "v.to.rast3"), + ("Sites to vector", "Convert sites (GRASS 5) to vector map", "self.runMenuCmd", "v.in.sites"), + ("","","", ""), + ("Volumes to raster series", "Convert raster to vector map", "self.runMenuCmd", "r3.to.rast"), + )), + ("","","", ""), + ("Georectify (not functional)", "Georectify raster and vector maps", "self.runMenuCmd", ""), + ("","","", ""), + ("Bearing/distance to coordinates", "Convert between bearing/distance and coordinates", "self.runMenuCmd", "m.cogo"), + ("","","", ""), + ("Postscript plot", "Create cartographic PostScript plot", "self.runMenuCmd", "ps.map"), + ("","","", ""), + ("E&xit", "Exit from wxgui.py", "self.OnCloseWindow", ""), )), ("Config", ( ("Region", "Set region", "self.runMenuCmd", "g.region"), From barton at grass.itc.it Fri Jun 8 04:48:57 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 8 04:48:58 2007 Subject: [grass-addons] r790 - trunk/grassaddons/gui/gui_modules Message-ID: <200706080248.l582mvn0000907@grass.itc.it> Author: barton Date: 2007-06-08 04:48:40 +0200 (Fri, 08 Jun 2007) New Revision: 790 Modified: trunk/grassaddons/gui/gui_modules/menudata.py trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Minor fix so that accidentally selecting (nonfunctional) georectify menu item does not cause an error. Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-08 02:45:34 UTC (rev 789) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-08 02:48:40 UTC (rev 790) @@ -103,7 +103,7 @@ ("Volumes to raster series", "Convert raster to vector map", "self.runMenuCmd", "r3.to.rast"), )), ("","","", ""), - ("Georectify (not functional)", "Georectify raster and vector maps", "self.runMenuCmd", ""), + ("Georectify (not functional)", "Georectify raster and vector maps", "self.OnGeorectify", ""), ("","","", ""), ("Bearing/distance to coordinates", "Convert between bearing/distance and coordinates", "self.runMenuCmd", "m.cogo"), ("","","", ""), Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-08 02:45:34 UTC (rev 789) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-08 02:48:40 UTC (rev 790) @@ -102,6 +102,9 @@ self.treepg = parent # notebook page holding layer tree self.auimgr = auimgr # aui manager + + self.testframe = wx.Frame(self, -1, title='Test Frame') + # init associated map display self.mapdisplay = mapdisp.MapFrame(self, id=wx.ID_ANY, pos=wx.DefaultPosition, size=(640,480), @@ -117,8 +120,6 @@ self.mapdisplay.Refresh() self.mapdisplay.Update() - self.Map = self.mapdisplay.getRender() - self.root = self.AddRoot("Map Layers") self.SetPyData(self.root, (None,None)) From barton at grass.itc.it Fri Jun 8 07:22:58 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 8 07:23:00 2007 Subject: [grass-addons] r791 - trunk/grassaddons/gui/gui_modules Message-ID: <200706080522.l585MwWF002879@grass.itc.it> Author: barton Date: 2007-06-08 07:22:50 +0200 (Fri, 08 Jun 2007) New Revision: 791 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py Log: Clean up debugging code Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-08 02:48:40 UTC (rev 790) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-08 05:22:50 UTC (rev 791) @@ -983,7 +983,6 @@ "rows=%f" % new['rows'], "cols=%f" % new['cols']] - print cmdRegion p = cmd.Command(cmdRegion) if tmpreg: From barton at grass.itc.it Fri Jun 8 08:43:01 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 8 08:43:02 2007 Subject: [grass-addons] r792 - trunk/grassaddons/gui/gui_modules Message-ID: <200706080643.l586h1qQ003801@grass.itc.it> Author: barton Date: 2007-06-08 08:42:53 +0200 (Fri, 08 Jun 2007) New Revision: 792 Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Fixing bugs in CLI parsing. Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-08 05:22:50 UTC (rev 791) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-08 06:42:53 UTC (rev 792) @@ -1041,7 +1041,13 @@ # disp_idx = None curr_disp = None - if len(command.split(' ')) == 1 and command in gcmdlst: + try: + # if command is not already a list, make it one + cmdlist = command.split(' ') + except: + cmdlist = command + + if len(cmdlist) == 1 and cmdlist[0] in gcmdlst: # send GRASS command without arguments to GUI command interface # except display commands (they are handled differently) global gmpath @@ -1066,28 +1072,31 @@ self.Parent.Parent.curr_page.maptree.AddLayer(layertype) else: - menuform.GUI().ParseCommand(command, gmpath, parentframe=None) - self.cmd_output.write(command + "\n----------\n") + menuform.GUI().ParseCommand(string.join(cmdlist), gmpath, parentframe=None) + self.cmd_output.write(string.join(cmdlist) + "\n----------\n") - elif command[0:2] == "d." and len(command.split(' ')) > 1 and command.split(' ')[0] in gcmdlst: + elif command[0:2] == "d." and len(cmdlist) > 1: """ Send GRASS display command(s)with arguments to the display processor and echo to command output console. - Accepts a list of d.* commands separated by commas. + Accepts a list of d.* commands separated by semi-colons. Display with focus receives display command(s). """ - #self.cmd_output.write(command + "\n----------\n") - self.cmd_output.write("$" + ' '.join(command)) - # TODO This needs to be fixed to use current rendering procedures - # + print 'cmdlist 0=',cmdlist[0] + self.cmd_output.write("$" + ' '.join(cmdlist)) + dcmds = command.split(';') for command in dcmds: - cmdlist = command.split(' ') - self.Map.AddLayer(type='command', command=cmdlist, - l_active=True, l_hidden=False, l_opacity=1, l_render=False) + try: + # only add the display command to the rendering list if it has arguments + cmdlist = command.strip().split(' ') + if cmdlist[0] in gcmdlst and len(cmdlist) > 1: + self.Map.AddLayer(type='command', command=cmdlist, + l_active=True, l_hidden=False, l_opacity=1, l_render=False) + except: + pass - curr_disp.MapWindow.UpdateMap() @@ -1097,21 +1106,26 @@ try: os.environ["GRASS_MESSAGE_FORMAT"] = "gui" #self.cmd_output.write(command+"\n----------\n") - self.cmd_output.write("$ " + ' '.join(command) + "\n") + self.cmd_output.write("$ " + ' '.join(cmdlist) + "\n") # activate compuational region (set with g.region) for all non-display commands. tmpreg = os.getenv("GRASS_REGION") os.unsetenv("GRASS_REGION") - if command in gcmdlst: - cmdlist = command.split(' ') - cmdlist = cmdlist.append('--verbose') - p = cmd.Command(cmdlist) - else: + + if cmdlist[0] not in gcmdlst: + # if command is not a GRASS command, treat it like a shell command output = os.popen(command, "r").read().strip().split('\n') for outline in output: self.cmd_output.write(outline+'\n') return + else: + # process GRASS command with argument + print 'cmdlist 2.5=',cmdlist + cmdlist.append('--verbose') + print 'cmdlist3=', cmdlist + p = cmd.Command(cmdlist) + # deactivate computational region and return to display settings if tmpreg: os.environ["GRASS_REGION"] = tmpreg From barton at grass.itc.it Fri Jun 8 08:50:05 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 8 08:50:07 2007 Subject: [grass-addons] r793 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200706080650.l586o5cI003838@grass.itc.it> Author: barton Date: 2007-06-08 08:49:53 +0200 (Fri, 08 Jun 2007) New Revision: 793 Modified: trunk/grassaddons/gui/gui_modules/menudata.py trunk/grassaddons/gui/wxgui.py Log: Further updates to menu Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-08 06:42:53 UTC (rev 792) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-08 06:49:53 UTC (rev 793) @@ -6,411 +6,425 @@ ("Files", ( ("Import", ( ("Raster map", ( - ("Multiple formats using GDAL", "Import multiple formats using GDAL", "self.runMenuCmd", "r.in.gdal"), + ("Multiple formats using GDAL", "Import multiple formats using GDAL", "self.OnMenuCmd", "r.in.gdal"), ("","","", ""), - ("Aggregate ASCII xyz", "Import aggregate ASCII xyz data", "self.runMenuCmd", "r.in.xyz"), - ("ASCII grid", "Import ASCII GRID (includes GRASS ASCII)", "self.runMenuCmd", "r.in.ascii"), - ("ASCII polygons and lines", "Import Polygons and lines from ASCII file", "self.runMenuCmd", "r.in.poly"), + ("Aggregate ASCII xyz", "Import aggregate ASCII xyz data", "self.OnMenuCmd", "r.in.xyz"), + ("ASCII grid", "Import ASCII GRID (includes GRASS ASCII)", "self.OnMenuCmd", "r.in.ascii"), + ("ASCII polygons and lines", "Import Polygons and lines from ASCII file", "self.OnMenuCmd", "r.in.poly"), ("","","", ""), - ("Binary", "Import binary file (includes GTOPO30 format)", "self.runMenuCmd", "r.in.bin"), - ("ESRI Arc/Info ASCII grid", "Import ESRI Arc/Info ASCII grid", "self.runMenuCmd", "r.in.arc"), - ("GRIDATB.FOR", "Import GRIDATB.FOR map file (TOPMODEL)", "self.runMenuCmd", "r.in.gridatb"), - ("MAT-File (v.4)", "Import MAT-File (v.4) array (Matlab or Octave)", "self.runMenuCmd", "r.in.mat"), - ("SPOT NDVI", "Import SPOT vegetation NDVI data sets", "self.runMenuCmd", "r.in.spotvgt"), - ("SRTM HGT", "Import SRTM hgt files", "self.runMenuCmd", "r.in.srtm"), - ("Terra ASTER HDF", "Import Terra ASTER HDF files", "self.runMenuCmd", "r.in.aster"), + ("Binary", "Import binary file (includes GTOPO30 format)", "self.OnMenuCmd", "r.in.bin"), + ("ESRI Arc/Info ASCII grid", "Import ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.in.arc"), + ("GRIDATB.FOR", "Import GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.in.gridatb"), + ("MAT-File (v.4)", "Import MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.in.mat"), + ("SPOT NDVI", "Import SPOT vegetation NDVI data sets", "self.OnMenuCmd", "r.in.spotvgt"), + ("SRTM HGT", "Import SRTM hgt files", "self.OnMenuCmd", "r.in.srtm"), + ("Terra ASTER HDF", "Import Terra ASTER HDF files", "self.OnMenuCmd", "r.in.aster"), ("","","", ""), - ("WMS", "Import Web Mapping Server", "self.runMenuCmd", "r.in.wms"), + ("WMS", "Import Web Mapping Server", "self.OnMenuCmd", "r.in.wms"), )), ("Vector map", ( - ("Multiple formats using OGR", "Import multiple formats using OGR", "self.runMenuCmd", "v.in.ogr"), + ("Multiple formats using OGR", "Import multiple formats using OGR", "self.OnMenuCmd", "v.in.ogr"), ("","","", ""), - ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.runMenuCmd", "v.in.ascii"), - ("Old GRASS vector", "Import old GRASS vector format", "self.runMenuCmd", "v.convert"), + ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.in.ascii"), + ("Old GRASS vector", "Import old GRASS vector format", "self.OnMenuCmd", "v.convert"), ("","","", ""), - ("DXF", "Import DXF file", "self.runMenuCmd", "v.in.dxf"), - ("ESRI e00", "Import ESRI e00 file", "self.runMenuCmd", "v.in.e00"), - ("Garmin GPS", "Import Garmin GPS Waypoints/Routes/Tracks", "self.runMenuCmd", "v.in.garmin"), - ("GPSBabel GPS", "Import GPS Waypoints/Routes/Tracks using GPSBabel", "self.runMenuCmd", "v.in.gpsbabel"), - ("GEOnet", "Import GEOnet Name server country files (US-NGA GNS)", "self.runMenuCmd", "v.in.gns"), - ("Matlab and MapGen", "Import Matlab and MapGen files", "self.runMenuCmd", "v.in.mapgen"), + ("DXF", "Import DXF file", "self.OnMenuCmd", "v.in.dxf"), + ("ESRI e00", "Import ESRI e00 file", "self.OnMenuCmd", "v.in.e00"), + ("Garmin GPS", "Import Garmin GPS Waypoints/Routes/Tracks", "self.OnMenuCmd", "v.in.garmin"), + ("GPSBabel GPS", "Import GPS Waypoints/Routes/Tracks using GPSBabel", "self.OnMenuCmd", "v.in.gpsbabel"), + ("GEOnet", "Import GEOnet Name server country files (US-NGA GNS)", "self.OnMenuCmd", "v.in.gns"), + ("Matlab and MapGen", "Import Matlab and MapGen files", "self.OnMenuCmd", "v.in.mapgen"), )), ("Grid 3D", ( - ("ASCII 3D", "Import ASCII 3D file", "self.runMenuCmd", "r3.in.ascii"), - ("Vis5D", "Import Vis5D file", "self.runMenuCmd", "r3.in.v5d"), + ("ASCII 3D", "Import ASCII 3D file", "self.OnMenuCmd", "r3.in.ascii"), + ("Vis5D", "Import Vis5D file", "self.OnMenuCmd", "r3.in.v5d"), )), )), ("Export", ( ("Raster map", ( - ("Multiple formats using GDAL", "Export multiple formats using GDAL", "self.runMenuCmd", "r.out.gdal"), + ("Multiple formats using GDAL", "Export multiple formats using GDAL", "self.OnMenuCmd", "r.out.gdal"), ("","","", ""), - ("ASCII grid", "Export ASCII grid (for GRASS, Surfer, Modflow, etc)", "self.runMenuCmd", "r.out.ascii"), - ("ASCII x,y,z", "Export ASCII x,y,z values of cell centers", "self.runMenuCmd", "r.out.xyz"), + ("ASCII grid", "Export ASCII grid (for GRASS, Surfer, Modflow, etc)", "self.OnMenuCmd", "r.out.ascii"), + ("ASCII x,y,z", "Export ASCII x,y,z values of cell centers", "self.OnMenuCmd", "r.out.xyz"), ("","","", ""), - ("ESRI ASCII grid", "Export ESRI Arc/Info ASCII grid", "self.runMenuCmd", "r.out.arc"), - ("GRIDATB.FOR", "Export GRIDATB.FOR map file (TOPMODEL)", "self.runMenuCmd", "r.out.gridatb"), - ("MAT-File (v.4)", "Export MAT-File (v.4) array (Matlab or Octave)", "self.runMenuCmd", "r.out.mat"), + ("ESRI ASCII grid", "Export ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.out.arc"), + ("GRIDATB.FOR", "Export GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.out.gridatb"), + ("MAT-File (v.4)", "Export MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.out.mat"), ("","","", ""), - ("Binary", "Export binary file", "self.runMenuCmd", "r.out.bin"), + ("Binary", "Export binary file", "self.OnMenuCmd", "r.out.bin"), ("","","", ""), - ("MPEG-1", "Export MPEG-1 animations", "self.runMenuCmd", "r.out.mpeg"), - ("PNG", "Export PNG image (not georeferenced)", "self.runMenuCmd", "r.out.png"), - ("PPM", "Export PPM image (24bit)", "self.runMenuCmd", "r.out.ppm"), - ("POV-Ray", "Export POVray height-field", "self.runMenuCmd", "r.out.pov"), - ("TIFF", "Export TIFF image (8/24bit)", "self.runMenuCmd", "r.out.tiff"), - ("VRML", "Export VRML file", "self.runMenuCmd", "r.out.vrml"), - ("VTK", "Export VTK ASCII file", "self.runMenuCmd", "r.out.vtk"), + ("MPEG-1", "Export MPEG-1 animations", "self.OnMenuCmd", "r.out.mpeg"), + ("PNG", "Export PNG image (not georeferenced)", "self.OnMenuCmd", "r.out.png"), + ("PPM", "Export PPM image (24bit)", "self.OnMenuCmd", "r.out.ppm"), + ("POV-Ray", "Export POVray height-field", "self.OnMenuCmd", "r.out.pov"), + ("TIFF", "Export TIFF image (8/24bit)", "self.OnMenuCmd", "r.out.tiff"), + ("VRML", "Export VRML file", "self.OnMenuCmd", "r.out.vrml"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r.out.vtk"), )), ("Vector map", ( - ("Multiple formats using OGR", "Export multiple formats using OGR", "self.runMenuCmd", "v.out.ogr"), + ("Multiple formats using OGR", "Export multiple formats using OGR", "self.OnMenuCmd", "v.out.ogr"), ("","","", ""), - ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.runMenuCmd", "v.out.ascii"), + ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.out.ascii"), - ("DXF", "Export DXF file", "self.runMenuCmd", "v.out.dxf"), - ("POV-Ray", "Export POV-Ray format file", "self.runMenuCmd", "v.out.pov"), - ("SVG", "Export SVG file", "self.runMenuCmd", "v.out.svg"), - ("VTK", "Export VTK ASCII file", "self.runMenuCmd", "v.out.vtk"), + ("DXF", "Export DXF file", "self.OnMenuCmd", "v.out.dxf"), + ("POV-Ray", "Export POV-Ray format file", "self.OnMenuCmd", "v.out.pov"), + ("SVG", "Export SVG file", "self.OnMenuCmd", "v.out.svg"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "v.out.vtk"), )), ("Grid 3D", ( - ("ASCII 3D", "Export ASCII 3D file", "self.runMenuCmd", "r3.out.ascii"), - ("Vis5D", "Export Vis5D file", "self.runMenuCmd", "r3.out.v5d"), - ("VTK", "Export VTK ASCII file", "self.runMenuCmd", "r3.out.vtk"), + ("ASCII 3D", "Export ASCII 3D file", "self.OnMenuCmd", "r3.out.ascii"), + ("Vis5D", "Export Vis5D file", "self.OnMenuCmd", "r3.out.v5d"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r3.out.vtk"), )), )), ("","","", ""), ("Manage maps and volumes", ( - ("Copy", "Copy maps within mapsets or between mapsets", "self.runMenuCmd", "g.copy"), + ("Copy", "Copy maps within mapsets or between mapsets", "self.OnMenuCmd", "g.copy"), ("","","", ""), - ("List", "List maps by type", "self.runMenuCmd", "list"), - ("List filtered", "List maps filtered by expressions and wildcards", "self.runMenuCmd", "g.mlist"), + ("List", "List maps by type", "self.OnMenuCmd", "list"), + ("List filtered", "List maps filtered by expressions and wildcards", "self.OnMenuCmd", "g.mlist"), ("","","", ""), - ("Rename", "Rename maps", "self.runMenuCmd", "g.rename"), + ("Rename", "Rename maps", "self.OnMenuCmd", "g.rename"), ("","","", ""), - ("Delete", "Delete maps", "self.runMenuCmd", "g.remove"), - ("Delete filtered", "Delete maps using expressions and wildcards", "self.runMenuCmd", "g.mremove"), + ("Delete", "Delete maps", "self.OnMenuCmd", "g.remove"), + ("Delete filtered", "Delete maps using expressions and wildcards", "self.OnMenuCmd", "g.mremove"), )), ("Map type conversions", ( - ("Raster to vector", "Convert raster to vector map", "self.runMenuCmd", "r.to.vect"), - ("Raster series to volume", "Convert raster map series to volume", "self.runMenuCmd", "r.to.rast3"), - ("Raster 2.5D to volume", "Convert raster 2.5D map to volume", "self.runMenuCmd", "r.to.rast3elev"), + ("Raster to vector", "Convert raster to vector map", "self.OnMenuCmd", "r.to.vect"), + ("Raster series to volume", "Convert raster map series to volume", "self.OnMenuCmd", "r.to.rast3"), + ("Raster 2.5D to volume", "Convert raster 2.5D map to volume", "self.OnMenuCmd", "r.to.rast3elev"), ("","","", ""), - ("Vector to raster", "Convert vector to raster map", "self.runMenuCmd", "v.to.rast"), - ("Vector to volume", "Convert vector 3D points to volume voxels", "self.runMenuCmd", "v.to.rast3"), - ("Sites to vector", "Convert sites (GRASS 5) to vector map", "self.runMenuCmd", "v.in.sites"), + ("Vector to raster", "Convert vector to raster map", "self.OnMenuCmd", "v.to.rast"), + ("Vector to volume", "Convert vector 3D points to volume voxels", "self.OnMenuCmd", "v.to.rast3"), + ("Sites to vector", "Convert sites (GRASS 5) to vector map", "self.OnMenuCmd", "v.in.sites"), ("","","", ""), - ("Volumes to raster series", "Convert raster to vector map", "self.runMenuCmd", "r3.to.rast"), + ("Volumes to raster series", "Convert raster to vector map", "self.OnMenuCmd", "r3.to.rast"), )), ("","","", ""), ("Georectify (not functional)", "Georectify raster and vector maps", "self.OnGeorectify", ""), ("","","", ""), - ("Bearing/distance to coordinates", "Convert between bearing/distance and coordinates", "self.runMenuCmd", "m.cogo"), + ("Bearing/distance to coordinates", "Convert between bearing/distance and coordinates", "self.OnMenuCmd", "m.cogo"), ("","","", ""), - ("Postscript plot", "Create cartographic PostScript plot", "self.runMenuCmd", "ps.map"), + ("Postscript plot", "Create cartographic PostScript plot", "self.OnMenuCmd", "ps.map"), ("","","", ""), ("E&xit", "Exit from wxgui.py", "self.OnCloseWindow", ""), )), ("Config", ( - ("Region", "Set region", "self.runMenuCmd", "g.region"), - ("","","", ""), - ("Set display font", "Set default font for GRASS displays", "self.DefaultFont", ""), + ("Region", ( + ("Display region", "Display region settings", "self.RunMenuCmd", "g.region -p"), + ("Set region", "Change region settings", "self.OnMenuCmd", "g.region"), )), + ("GRASS working environment", ( + ("Mapset access (not functional)", "Set access to other mapsets in current location", "self.OnMapsets", ""), + ("Change working environment", "Change current working session to new mapset, location, or data directory", "self.OnMenuCmd", "g.mapset"), + ("User access", "Change access by other users to current mapset", "self.OnMenuCmd", "g.access"), + ("Show settings", "Show current GRASS environment settings", "self.RunMenuCmd", "g.gisenv "), + ("Change settings", "Change GRASS environment settings", "self.OnMenuCmd", "g.gisenv"), + ("Version", "Show current GRASS version", "self.RunMenuCmd", "g.version -c"), + )), + ("Manage projections", ( + ("Projections", "Show projection information and create projection files", "self.OnMenuCmd", "g.proj"), + ("Convert coordinates", "Convert coordinates from one projection to another", "self.OnMenuCmd", "m.proj"), + )), + ("Display font", "Set default font for GRASS displays", "self.DefaultFont", ""), + )), ("Raster", ( ("Develop map", ( - ("Digitize raster", "Digitize raster", "self.runMenuCmd", "r.digit"), + ("Digitize raster (not functional)", "Digitize raster", "self.OnRDigit", ""), ("","","", ""), - ("Compress/decompress raster file", "Compress/decompress raster file", "self.runMenuCmd", "r.compress"), - ("Manage boundary definition (WHICH COMMAND?)", "Manage boundary definition", "self.runMenuCmd", "r.region"), - ("Manage null values", "Manage null values", "self.runMenuCmd", "r.null"), - ("Manage timestamp for files", "Manage timestamp for files", "self.runMenuCmd", "r.timestamp"), - ("Quantization for floating-point maps", "Quantization for floating-point maps", "self.runMenuCmd", "r.quant"), - ("Resample (change resolution) using nearest neighbor method", "Resample (change resolution) using nearest neighbor method", "self.runMenuCmd", "r.resample"), - ("Resample (change resolution) using regularized spline tension", "Resample (change resolution) using regularized spline tension", "self.runMenuCmd", "r.resamp.rst"), - ("Support file creation and maintenance", "Support file creation and maintenance", "self.runMenuCmd", "r.support.sh"), + ("Compress/decompress raster file", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), + ("Manage boundary definition (WHICH COMMAND?)", "Manage boundary definition", "self.OnMenuCmd", "r.region"), + ("Manage null values", "Manage null values", "self.OnMenuCmd", "r.null"), + ("Manage timestamp for files", "Manage timestamp for files", "self.OnMenuCmd", "r.timestamp"), + ("Quantization for floating-point maps", "Quantization for floating-point maps", "self.OnMenuCmd", "r.quant"), + ("Resample (change resolution) using nearest neighbor method", "Resample (change resolution) using nearest neighbor method", "self.OnMenuCmd", "r.resample"), + ("Resample (change resolution) using regularized spline tension", "Resample (change resolution) using regularized spline tension", "self.OnMenuCmd", "r.resamp.rst"), + ("Support file creation and maintenance", "Support file creation and maintenance", "self.OnMenuCmd", "r.support.sh"), ("","","", ""), - ("Reproject raster from other location", "Reproject raster from other location", "self.runMenuCmd", "r.proj"), - ("Generate tiling for other projection", "Generate tiling for other projection", "self.runMenuCmd", "r.tileset"), + ("Reproject raster from other location", "Reproject raster from other location", "self.OnMenuCmd", "r.proj"), + ("Generate tiling for other projection", "Generate tiling for other projection", "self.OnMenuCmd", "r.tileset"), )), ("Manage map colors", ( - ("Set colors to predefined color tables", "Set colors to predefined color tables", "self.runMenuCmd", "r.colors"), - ("Set colors using color rules", "Set colors using color rules", "self.runMenuCmd", "r.colors.rules"), + ("Set colors to predefined color tables", "Set colors to predefined color tables", "self.OnMenuCmd", "r.colors"), + ("Set colors using color rules", "Set colors using color rules", "self.OnMenuCmd", "r.colors.rules"), ("","","", ""), - ("Blend 2 color maps to produce 3 RGB files", "Blend 2 color maps to produce 3 RGB files", "self.runMenuCmd", "r.blend"), - ("Create color image from RGB files", "Create color image from RGB files", "self.runMenuCmd", "r.composite"), - ("Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.runMenuCmd", "r.his"), + ("Blend 2 color maps to produce 3 RGB files", "Blend 2 color maps to produce 3 RGB files", "self.OnMenuCmd", "r.blend"), + ("Create color image from RGB files", "Create color image from RGB files", "self.OnMenuCmd", "r.composite"), + ("Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.OnMenuCmd", "r.his"), )), - ("Query by coordinates", "Query by coordinates", "self.runMenuCmd", "r.what"), + ("Query by coordinates", "Query by coordinates", "self.OnMenuCmd", "r.what"), ("","","", ""), - ("Create raster buffers", "Develop raster buffer", "self.runMenuCmd", "r.buffer"), - ("Create raster MASK", "Develop raster mask", "self.runMenuCmd", "r.mask"), - ("Locate closest points between areas in 2 raster maps", "r.distance", "self.runMenuCmd", "r.distance"), - ("Map calculator", "Map calculator", "self.runMenuCmd", "scripts/mapcalc_gparser.sh"), + ("Create raster buffers", "Develop raster buffer", "self.OnMenuCmd", "r.buffer"), + ("Create raster MASK", "Develop raster mask", "self.OnMenuCmd", "r.mask"), + ("Locate closest points between areas in 2 raster maps", "r.distance", "self.OnMenuCmd", "r.distance"), + ("Map calculator", "Map calculator", "self.OnMenuCmd", "scripts/mapcalc_gparser.sh"), ("Neighborhood analysis", ( - ("Moving window analysis of raster cells", "Moving window analysis of raster cells", "self.runMenuCmd", "r.neighbors"), - ("Analyze vector points in neighborhood of raster cells", "Analyze vector points in neighborhood of raster cells", "self.runMenuCmd", "v.neighbors"), + ("Moving window analysis of raster cells", "Moving window analysis of raster cells", "self.OnMenuCmd", "r.neighbors"), + ("Analyze vector points in neighborhood of raster cells", "Analyze vector points in neighborhood of raster cells", "self.OnMenuCmd", "v.neighbors"), )), ("Overlay maps", ( - ("Cross product", "Cross product", "self.runMenuCmd", "r.cross"), - ("Function of map series (time series)", "Function of map series (time series)", "self.runMenuCmd", "r.series"), - ("Patch maps", "Patch maps", "self.runMenuCmd", "r.patch"), + ("Cross product", "Cross product", "self.OnMenuCmd", "r.cross"), + ("Function of map series (time series)", "Function of map series (time series)", "self.OnMenuCmd", "r.series"), + ("Patch maps", "Patch maps", "self.OnMenuCmd", "r.patch"), ("","","", ""), - ("Statistical calculations for cover map over base map", "Statistical calculations for cover map over base map", "self.runMenuCmd", "r.statistics"), + ("Statistical calculations for cover map over base map", "Statistical calculations for cover map over base map", "self.OnMenuCmd", "r.statistics"), )), ("Solar radiance and shadows", ( - ("Solar irradiance and daily irradiation", "Solar irradiance and daily irradiation", "self.runMenuCmd", "r.sun"), - ("Shadow map for sun position or date/time", "Shadow map for sun position or date/time", "self.runMenuCmd", "r.sunmask"), + ("Solar irradiance and daily irradiation", "Solar irradiance and daily irradiation", "self.OnMenuCmd", "r.sun"), + ("Shadow map for sun position or date/time", "Shadow map for sun position or date/time", "self.OnMenuCmd", "r.sunmask"), )), ("Terrain analysis", ( - ("Calculate cumulative movement costs between locales", "Calculate cumulative movement costs between locales", "self.runMenuCmd", "r.walk"), - ("cost surface", "cost surface", "self.runMenuCmd", "r.cost"), - ("Least cost route or flow", "Least cost route or flow", "self.runMenuCmd", "r.drain"), - ("Shaded relief map", "Shaded relief map", "self.runMenuCmd", "r.shaded.relief"), - ("Slope and aspect", "Slope and aspect", "self.runMenuCmd", "r.slope.aspect"), - ("Terrain parameters", "Terrain parameters", "self.runMenuCmd", "r.param.scale"), - ("Textural features", "Textural features", "self.runMenuCmd", "r.texture"), - ("Visibility/Line of sight", "Visibility/Line of sight", "self.runMenuCmd", "r.los"), + ("Calculate cumulative movement costs between locales", "Calculate cumulative movement costs between locales", "self.OnMenuCmd", "r.walk"), + ("cost surface", "cost surface", "self.OnMenuCmd", "r.cost"), + ("Least cost route or flow", "Least cost route or flow", "self.OnMenuCmd", "r.drain"), + ("Shaded relief map", "Shaded relief map", "self.OnMenuCmd", "r.shaded.relief"), + ("Slope and aspect", "Slope and aspect", "self.OnMenuCmd", "r.slope.aspect"), + ("Terrain parameters", "Terrain parameters", "self.OnMenuCmd", "r.param.scale"), + ("Textural features", "Textural features", "self.OnMenuCmd", "r.texture"), + ("Visibility/Line of sight", "Visibility/Line of sight", "self.OnMenuCmd", "r.los"), )), ("Transform features", ( - ("Clump small areas (statistics calculated by r.volume)", "Clump small areas (statistics calculated by r.volume)", "self.runMenuCmd", "r.clump"), - ("Grow areas", "Grow areas", "self.runMenuCmd", "r.grow"), - ("Thin linear features", "Thin linear features", "self.runMenuCmd", "r.thin"), + ("Clump small areas (statistics calculated by r.volume)", "Clump small areas (statistics calculated by r.volume)", "self.OnMenuCmd", "r.clump"), + ("Grow areas", "Grow areas", "self.OnMenuCmd", "r.grow"), + ("Thin linear features", "Thin linear features", "self.OnMenuCmd", "r.thin"), )), ("","","", ""), ("Hydrologic modeling", ( - ("Carve stream channels into elevation map using vector streams map", "Carve stream channels into elevation map using vector streams map", "self.runMenuCmd", "r.carve"), - ("Depressionless elevation map and flowline map", "Depressionless elevation map and flowline map", "self.runMenuCmd", "r.fill.dir"), - ("Fill lake from seed point to specified level", "Fill lake from seed point to specified level", "self.runMenuCmd", "r.lake"), - ("Flow accumulation for massive grids (WHICH COMMAND?)", "Flow accumulation for massive grids", "self.runMenuCmd", "r.flow"), - ("Generate flow lines for raster map (WHICH COMMAND?)", "Generate flow lines for raster map", "self.runMenuCmd", "r.flow"), - ("SIMWE overland flow modeling (WHICH COMMAND?)", "SIMWE overland flow modeling", "self.runMenuCmd", "r.simwe"), - ("SIMWE sediment erosion, transport, deposition modeling (WHICH COMMAND?)", "SIMWE sediment erosion, transport, deposition modeling", "self.runMenuCmd", "r.simwe"), - ("Topographic index map", "Topographic index map", "self.runMenuCmd", "r.topidx"), - ("TOPMODEL simulation", "TOPMODEL simulation", "self.runMenuCmd", "r.topmodel"), - ("Watershed subbasins", "Watershed subbasins", "self.runMenuCmd", "r.basins.fill"), - ("Watershed analysis", "Watershed analysis", "self.runMenuCmd", "r.watershed"), - ("Watershed basin creation", "Watershed basin creation", "self.runMenuCmd", "r.water.outlet"), + ("Carve stream channels into elevation map using vector streams map", "Carve stream channels into elevation map using vector streams map", "self.OnMenuCmd", "r.carve"), + ("Depressionless elevation map and flowline map", "Depressionless elevation map and flowline map", "self.OnMenuCmd", "r.fill.dir"), + ("Fill lake from seed point to specified level", "Fill lake from seed point to specified level", "self.OnMenuCmd", "r.lake"), + ("Flow accumulation for massive grids (WHICH COMMAND?)", "Flow accumulation for massive grids", "self.OnMenuCmd", "r.flow"), + ("Generate flow lines for raster map (WHICH COMMAND?)", "Generate flow lines for raster map", "self.OnMenuCmd", "r.flow"), + ("SIMWE overland flow modeling (WHICH COMMAND?)", "SIMWE overland flow modeling", "self.OnMenuCmd", "r.simwe"), + ("SIMWE sediment erosion, transport, deposition modeling (WHICH COMMAND?)", "SIMWE sediment erosion, transport, deposition modeling", "self.OnMenuCmd", "r.simwe"), + ("Topographic index map", "Topographic index map", "self.OnMenuCmd", "r.topidx"), + ("TOPMODEL simulation", "TOPMODEL simulation", "self.OnMenuCmd", "r.topmodel"), + ("Watershed subbasins", "Watershed subbasins", "self.OnMenuCmd", "r.basins.fill"), + ("Watershed analysis", "Watershed analysis", "self.OnMenuCmd", "r.watershed"), + ("Watershed basin creation", "Watershed basin creation", "self.OnMenuCmd", "r.water.outlet"), )), ("Landscape structure modeling", ( - ("Set up sampling and analysis framework", "Set up sampling and analysis framework", "self.runMenuCmd", "r.le.setup"), + ("Set up sampling and analysis framework", "Set up sampling and analysis framework", "self.OnMenuCmd", "r.le.setup"), ("","","", ""), - ("Analyze landscape characteristics", "Analyze landscape characteristics", "self.runMenuCmd", "r.le.pixel"), - ("Analyze landscape patch characteristics", "Analyze landscape patch characteristics", "self.runMenuCmd", "r.le.patch"), - ("Output landscape patch information", "Output landscape patch information", "self.runMenuCmd", "r.le.trace"), + ("Analyze landscape characteristics", "Analyze landscape characteristics", "self.OnMenuCmd", "r.le.pixel"), + ("Analyze landscape patch characteristics", "Analyze landscape patch characteristics", "self.OnMenuCmd", "r.le.patch"), + ("Output landscape patch information", "Output landscape patch information", "self.OnMenuCmd", "r.le.trace"), )), ("Wildfire modeling", ( - ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.runMenuCmd", "r.ros"), - ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.runMenuCmd", "r.spreadpath"), - ("Simulate anisotropic spread phenomena", "Simulate anisotropic spread phenomena", "self.runMenuCmd", "r.spread"), + ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.OnMenuCmd", "r.ros"), + ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.OnMenuCmd", "r.spreadpath"), + ("Simulate anisotropic spread phenomena", "Simulate anisotropic spread phenomena", "self.OnMenuCmd", "r.spread"), )), ("","","", ""), ("Change category values and labels", ( - ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.runMenuCmd", "d.rast.edit"), + ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.OnMenuCmd", "d.rast.edit"), ("","","", ""), - ("Reclassify categories for areas of specified sizes", "Reclassify categories for areas of specified sizes", "self.runMenuCmd", "r.reclass.area"), - ("Reclassify categories using rules", "Reclassify categories using rules", "self.runMenuCmd", "r.reclass.rules"), - ("Reclassify categories using rules file", "Reclassify categories using rules file", "self.runMenuCmd", "r.reclass.file"), + ("Reclassify categories for areas of specified sizes", "Reclassify categories for areas of specified sizes", "self.OnMenuCmd", "r.reclass.area"), + ("Reclassify categories using rules", "Reclassify categories using rules", "self.OnMenuCmd", "r.reclass.rules"), + ("Reclassify categories using rules file", "Reclassify categories using rules file", "self.OnMenuCmd", "r.reclass.file"), ("","","", ""), - ("Recode categories using rules (create new map)", "Recode categories using rules (create new map)", "self.runMenuCmd", "r.recode.rules"), - ("Recode categories using rules file (create new map)", "Recode categories using rules file (create new map)", "self.runMenuCmd", "r.recode.file"), + ("Recode categories using rules (create new map)", "Recode categories using rules (create new map)", "self.OnMenuCmd", "r.recode.rules"), + ("Recode categories using rules file (create new map)", "Recode categories using rules file (create new map)", "self.OnMenuCmd", "r.recode.file"), ("","","", ""), - ("Rescale categories (create new map)", "Rescale categories (create new map)", "self.runMenuCmd", "r.rescale"), - ("Rescale categories with equalized histogram (create new map)", "Rescale categories with equalized histogram (create new map)", "self.runMenuCmd", "r.rescale.eq"), + ("Rescale categories (create new map)", "Rescale categories (create new map)", "self.OnMenuCmd", "r.rescale"), + ("Rescale categories with equalized histogram (create new map)", "Rescale categories with equalized histogram (create new map)", "self.OnMenuCmd", "r.rescale.eq"), )), ("","","", ""), - ("Generate concentric circles around points", "Generate concentric circles around points", "self.runMenuCmd", "r.circle"), + ("Generate concentric circles around points", "Generate concentric circles around points", "self.OnMenuCmd", "r.circle"), ("Generate random raster cells", ( - ("Generate random cells", "Generate random cells", "self.runMenuCmd", "r.random.cells"), - ("Generate random cells and vector points from raster map", "Generate random cells and vector points from raster map", "self.runMenuCmd", "r.random"), + ("Generate random cells", "Generate random cells", "self.OnMenuCmd", "r.random.cells"), + ("Generate random cells and vector points from raster map", "Generate random cells and vector points from raster map", "self.OnMenuCmd", "r.random"), )), ("Generate surfaces", ( - ("Generate density surface using moving Gaussian kernel", "Generate density surface using moving Gaussian kernel", "self.runMenuCmd", "v.kernel"), - ("Generate fractal surface", "Generate fractal surface", "self.runMenuCmd", "r.surf.fractal"), - ("Generate gaussian deviates surface", "Generate gaussian deviates surface", "self.runMenuCmd", "r.surf.gauss"), - ("Generate plane", "Generate plane", "self.runMenuCmd", "r.plane"), - ("Generate random deviates surface", "Generate random deviates surface", "self.runMenuCmd", "r.surf.random"), - ("Generate random surface with spatial dependence", "Generate random surface with spatial dependence", "self.runMenuCmd", "r.random.surface"), + ("Generate density surface using moving Gaussian kernel", "Generate density surface using moving Gaussian kernel", "self.OnMenuCmd", "v.kernel"), + ("Generate fractal surface", "Generate fractal surface", "self.OnMenuCmd", "r.surf.fractal"), + ("Generate gaussian deviates surface", "Generate gaussian deviates surface", "self.OnMenuCmd", "r.surf.gauss"), + ("Generate plane", "Generate plane", "self.OnMenuCmd", "r.plane"), + ("Generate random deviates surface", "Generate random deviates surface", "self.OnMenuCmd", "r.surf.random"), + ("Generate random surface with spatial dependence", "Generate random surface with spatial dependence", "self.OnMenuCmd", "r.random.surface"), )), - ("Generate vector contour lines", "Generate vector contour lines", "self.runMenuCmd", "r.contour"), + ("Generate vector contour lines", "Generate vector contour lines", "self.OnMenuCmd", "r.contour"), ("Interpolate surfaces", ( - ("Bilinear interpolation from raster points", "Bilinear interpolation from raster points", "self.runMenuCmd", "r.bilinear"), - ("Inverse distance weighted interpolation from raster points", "Inverse distance weighted interpolation from raster points", "self.runMenuCmd", "r.surf.idw"), - ("Interpolation from raster contour", "Interpolation from raster contour", "self.runMenuCmd", "r.surf.contour"), + ("Bilinear interpolation from raster points", "Bilinear interpolation from raster points", "self.OnMenuCmd", "r.bilinear"), + ("Inverse distance weighted interpolation from raster points", "Inverse distance weighted interpolation from raster points", "self.OnMenuCmd", "r.surf.idw"), + ("Interpolation from raster contour", "Interpolation from raster contour", "self.OnMenuCmd", "r.surf.contour"), ("","","", ""), - ("Inverse distance weighted interpolation from vector points", "Inverse distance weighted interpolation from vector points", "self.runMenuCmd", "v.surf.idw"), - ("Regularized spline tension interpolation from vector points or contours (WHICH COMMAND ?)", "Regularized spline tension interpolation from vector points or contours", "self.runMenuCmd", "v.surf.rst"), + ("Inverse distance weighted interpolation from vector points", "Inverse distance weighted interpolation from vector points", "self.OnMenuCmd", "v.surf.idw"), + ("Regularized spline tension interpolation from vector points or contours (WHICH COMMAND ?)", "Regularized spline tension interpolation from vector points or contours", "self.OnMenuCmd", "v.surf.rst"), ("","","", ""), - ("Fill NULL cells by interpolation using regularized spline tension", "Fill NULL cells by interpolation using regularized spline tension", "self.runMenuCmd", "r.fillnulls"), + ("Fill NULL cells by interpolation using regularized spline tension", "Fill NULL cells by interpolation using regularized spline tension", "self.OnMenuCmd", "r.fillnulls"), )), ("","","", ""), ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.runMenuCmd", "r.info"), - ("Report category labels and values", "Report category labels and values", "self.runMenuCmd", "r.cats"), + ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), + ("Report category labels and values", "Report category labels and values", "self.OnMenuCmd", "r.cats"), ("","","", ""), - ("General statistics", "General statistics", "self.runMenuCmd", "r.stats"), - ("Range of all category values", "Range of all category values", "self.runMenuCmd", "r.describe"), - ("Sum all cell category values", "Sum all cell category values", "self.runMenuCmd", "r.sum"), - ("Sum area by map and category", "Sum area by map and category", "self.runMenuCmd", "r.report"), - ("Summary statistics for clumped cells (work with r.clump)", "Summary statistics for clumped cells (work with r.clump)", "self.runMenuCmd", "r.volume"), - ("Total surface area corrected for topography", "Total surface area corrected for topography", "self.runMenuCmd", "r.surf.area"), - ("Univariate statistics", "Univariate statistics", "self.runMenuCmd", "r.univar"), - ("Univariate statistics (script version)", "Univariate statistics (script version)", "self.runMenuCmd", "r.univar.sh"), + ("General statistics", "General statistics", "self.OnMenuCmd", "r.stats"), + ("Range of all category values", "Range of all category values", "self.OnMenuCmd", "r.describe"), + ("Sum all cell category values", "Sum all cell category values", "self.OnMenuCmd", "r.sum"), + ("Sum area by map and category", "Sum area by map and category", "self.OnMenuCmd", "r.report"), + ("Summary statistics for clumped cells (work with r.clump)", "Summary statistics for clumped cells (work with r.clump)", "self.OnMenuCmd", "r.volume"), + ("Total surface area corrected for topography", "Total surface area corrected for topography", "self.OnMenuCmd", "r.surf.area"), + ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "r.univar"), + ("Univariate statistics (script version)", "Univariate statistics (script version)", "self.OnMenuCmd", "r.univar.sh"), ("","","", ""), - ("Sample values along transects", "Sample values along transects", "self.runMenuCmd", "r.profile"), - ("Sample values along transects (use azimuth, distance)", "Sample values along transects (use azimuth, distance)", "self.runMenuCmd", "r.transect"), + ("Sample values along transects", "Sample values along transects", "self.OnMenuCmd", "r.profile"), + ("Sample values along transects (use azimuth, distance)", "Sample values along transects (use azimuth, distance)", "self.OnMenuCmd", "r.transect"), ("","","", ""), - ("Covariance/correlation", "Covariance/correlation", "self.runMenuCmd", "r.covar"), - ("Linear regression between 2 maps", "Linear regression between 2 maps", "self.runMenuCmd", "r.regression.line"), - ("Mutual category occurrences (coincidence)", "Mutual category occurrences (coincidence)", "self.runMenuCmd", "r.coin"), + ("Covariance/correlation", "Covariance/correlation", "self.OnMenuCmd", "r.covar"), + ("Linear regression between 2 maps", "Linear regression between 2 maps", "self.OnMenuCmd", "r.regression.line"), + ("Mutual category occurrences (coincidence)", "Mutual category occurrences (coincidence)", "self.OnMenuCmd", "r.coin"), )), ("","","", "") )), ("Vector", ( ("Develop map", ( - ("Digitize", "Digitize vector", "self.runMenuCmd", "v.digit"), + ("Digitize", "Digitize vector", "self.OnMenuCmd", "v.digit"), ("","","", ""), - ("Create/Rebuild topology", "Create/Rebuild topology", "self.runMenuCmd", "v.build"), - ("Clean vector files", "clean vector files", "self.runMenuCmd", "v.clean"), + ("Create/Rebuild topology", "Create/Rebuild topology", "self.OnMenuCmd", "v.build"), + ("Clean vector files", "clean vector files", "self.OnMenuCmd", "v.clean"), ("","","", ""), - ("Break lines at intersections", "Break lines at intersections", "self.runMenuCmd", "v.topo.check"), - ("Build polylines from adjacent segments", "Build polylines from adjacent segments", "self.runMenuCmd", "v.build.polylines"), - ("Split polylines into segments", "Split polylines into segments", "self.runMenuCmd", "v.segment"), - ("Create lines parallel to existing lines", "Create lines parallel to existing lines", "self.runMenuCmd", "v.parallel"), + ("Break lines at intersections", "Break lines at intersections", "self.OnMenuCmd", "v.topo.check"), + ("Build polylines from adjacent segments", "Build polylines from adjacent segments", "self.OnMenuCmd", "v.build.polylines"), + ("Split polylines into segments", "Split polylines into segments", "self.OnMenuCmd", "v.segment"), + ("Create lines parallel to existing lines", "Create lines parallel to existing lines", "self.OnMenuCmd", "v.parallel"), ("","","", ""), - ("Convert vector feature types", "Convert vector feature types", "self.runMenuCmd", "v.type"), - ("Convert 2D vector to 3D by sampling raster", "Convert 2D vector to 3D by sampling raster", "self.runMenuCmd", "v.drape"), - ("Extrude 2D vector into 3D vector", "Extrude 2D vector into 3D vector", "self.runMenuCmd", "v.extrude"), + ("Convert vector feature types", "Convert vector feature types", "self.OnMenuCmd", "v.type"), + ("Convert 2D vector to 3D by sampling raster", "Convert 2D vector to 3D by sampling raster", "self.OnMenuCmd", "v.drape"), + ("Extrude 2D vector into 3D vector", "Extrude 2D vector into 3D vector", "self.OnMenuCmd", "v.extrude"), ("","","", ""), - ("Create text label file for vector features", "Create text label file for vector features", "self.runMenuCmd", "v.label"), + ("Create text label file for vector features", "Create text label file for vector features", "self.OnMenuCmd", "v.label"), ("","","", ""), - ("Reproject vector from other location", "Reproject vector from other location", "self.runMenuCmd", "v.proj"), + ("Reproject vector from other location", "Reproject vector from other location", "self.OnMenuCmd", "v.proj"), ("","","", "") )), ("","","", ""), ("vector<->database connections", ( - ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.runMenuCmd", "v.external"), - ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.runMenuCmd", "v.db.connect"), + ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), + ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), )), - ("Query by attributes", "Query by attributes", "self.runMenuCmd", "v.extract"), - ("Query by coordinate(s)", "Query by coordinate(s)", "self.runMenuCmd", "v.what"), - ("Query by map features", "Query by map features", "self.runMenuCmd", "v.select"), + ("Query by attributes", "Query by attributes", "self.OnMenuCmd", "v.extract"), + ("Query by coordinate(s)", "Query by coordinate(s)", "self.OnMenuCmd", "v.what"), + ("Query by map features", "Query by map features", "self.OnMenuCmd", "v.select"), ("","","", ""), - ("Create vector buffers", "Create vector buffers", "self.runMenuCmd", "v.buffer"), + ("Create vector buffers", "Create vector buffers", "self.OnMenuCmd", "v.buffer"), ("Linear referencing for vectors", ( - ("Create linear reference system", "Create linear reference system", "self.runMenuCmd", "v.lrs.create"), - ("Create stationing from input lines, and linear reference system", "Create stationing from input lines, and linear reference system", "self.runMenuCmd", "v.lrs.label"), - ("Create points/segments from input lines, linear reference system and positions read from stdin", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.runMenuCmd", "v.lrs.segment"), - ("Find line id and real km+offset for given points in vector map using linear reference system", "Find line id and real km+offset for given points in vector map using linear reference system", "self.runMenuCmd", "v.lrs.where"), + ("Create linear reference system", "Create linear reference system", "self.OnMenuCmd", "v.lrs.create"), + ("Create stationing from input lines, and linear reference system", "Create stationing from input lines, and linear reference system", "self.OnMenuCmd", "v.lrs.label"), + ("Create points/segments from input lines, linear reference system and positions read from stdin", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.OnMenuCmd", "v.lrs.segment"), + ("Find line id and real km+offset for given points in vector map using linear reference system", "Find line id and real km+offset for given points in vector map using linear reference system", "self.OnMenuCmd", "v.lrs.where"), )), ("Neighborhood analysis", ( - ("Locate nearest feature to points or centroids", "Locate nearest feature to points or centroids", "self.runMenuCmd", "v.distance"), - ("Generate Thiessen polygons around points (Voronoi diagram)", "Generate Thiessen polygons around points (Voronoi diagram)", "self.runMenuCmd", "v.voronoi"), - ("Connect points to create Delaunay triangles", "Connect points to create Delaunay triangles", "self.runMenuCmd", "v.delaunay"), + ("Locate nearest feature to points or centroids", "Locate nearest feature to points or centroids", "self.OnMenuCmd", "v.distance"), + ("Generate Thiessen polygons around points (Voronoi diagram)", "Generate Thiessen polygons around points (Voronoi diagram)", "self.OnMenuCmd", "v.voronoi"), + ("Connect points to create Delaunay triangles", "Connect points to create Delaunay triangles", "self.OnMenuCmd", "v.delaunay"), )), ("Network analysis", ( - ("Allocate subnets", "Allocate subnets", "self.runMenuCmd", "v.net.alloc"), - ("Network maintenance", "Network maintenance", "self.runMenuCmd", "v.net"), - ("Shortest route", "Shortest route", "self.runMenuCmd", "v.net.path"), - ("Shortest route (visualization only)", "Shortest route (visualization only)", "self.runMenuCmd", "d.path"), - ("Split net to bands between cost isolines", "Split net to bands between cost isolines", "self.runMenuCmd", "v.net.iso"), - ("Steiner tree", "Steiner tree", "self.runMenuCmd", "v.net.steiner"), - ("Traveling salesman analysis", "Traveling salesman analysis", "self.runMenuCmd", "v.net.salesman"), + ("Allocate subnets", "Allocate subnets", "self.OnMenuCmd", "v.net.alloc"), + ("Network maintenance", "Network maintenance", "self.OnMenuCmd", "v.net"), + ("Shortest route", "Shortest route", "self.OnMenuCmd", "v.net.path"), + ("Shortest route (visualization only)", "Shortest route (visualization only)", "self.OnMenuCmd", "d.path"), + ("Split net to bands between cost isolines", "Split net to bands between cost isolines", "self.OnMenuCmd", "v.net.iso"), + ("Steiner tree", "Steiner tree", "self.OnMenuCmd", "v.net.steiner"), + ("Traveling salesman analysis", "Traveling salesman analysis", "self.OnMenuCmd", "v.net.salesman"), )), ("Overlay maps", ( - ("Overlay/combine 2 vector maps", "Overlay/combine 2 vector maps", "self.runMenuCmd", "v.overlay"), - ("Patch multiple maps (combine)", "Patch multiple maps (combine)", "self.runMenuCmd", "v.patch"), + ("Overlay/combine 2 vector maps", "Overlay/combine 2 vector maps", "self.OnMenuCmd", "v.overlay"), + ("Patch multiple maps (combine)", "Patch multiple maps (combine)", "self.OnMenuCmd", "v.patch"), )), - ("Generate area feature for extent of current region", "Generate area feature for extent of current region", "self.runMenuCmd", "v.in.region"), - ("Generate rectangular vector grid", "Generate rectangular vector grid", "self.runMenuCmd", "v.mkgrid"), + ("Generate area feature for extent of current region", "Generate area feature for extent of current region", "self.OnMenuCmd", "v.in.region"), + ("Generate rectangular vector grid", "Generate rectangular vector grid", "self.OnMenuCmd", "v.mkgrid"), ("","","", ""), ("Change attributes", ( - ("Attach/delete, or report categories", "Attach/delete, or report categories", "self.runMenuCmd", "v.category"), - ("Reclassify features using rules file", "Reclassify features using rules file", "self.runMenuCmd", "v.reclass"), + ("Attach/delete, or report categories", "Attach/delete, or report categories", "self.OnMenuCmd", "v.category"), + ("Reclassify features using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), )), ("","","", ""), ("Work with vector points", ( ("Generate points", ( - ("Generate points from database", "Generate points from database", "self.runMenuCmd", "v.in.db"), - ("Generate random points", "Generate random points", "self.runMenuCmd", "v.random"), - ("Random location perturbations of points", "Random location perturbations of points", "self.runMenuCmd", "v.perturb"), + ("Generate points from database", "Generate points from database", "self.OnMenuCmd", "v.in.db"), + ("Generate random points", "Generate random points", "self.OnMenuCmd", "v.random"), + ("Random location perturbations of points", "Random location perturbations of points", "self.OnMenuCmd", "v.perturb"), )), ("Generate areas from points", ( - ("Generate convex hull for point set", "Generate convex hull for point set", "self.runMenuCmd", "v.hull"), - ("Generate Delaunay triangles for point set", "Generate Delaunay triangles for point set", "self.runMenuCmd", "v.delaunay"), - ("Generate Voronoi diagram/Thiessen polygons for point set", "Generate Voronoi diagram/Thiessen polygons for point set", "self.runMenuCmd", "v.voronoi"), + ("Generate convex hull for point set", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), + ("Generate Delaunay triangles for point set", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), + ("Generate Voronoi diagram/Thiessen polygons for point set", "Generate Voronoi diagram/Thiessen polygons for point set", "self.OnMenuCmd", "v.voronoi"), )), ("Sample raster maps", ( - ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.runMenuCmd", "v.rast.stats"), - ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.runMenuCmd", "v.what.rast"), - ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.runMenuCmd", "v.sample"), + ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.OnMenuCmd", "v.rast.stats"), + ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.OnMenuCmd", "v.what.rast"), + ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.OnMenuCmd", "v.sample"), )), - ("Partition points into test/training sets for k-fold cross validation", "Partition points into test/training sets for k-fold cross validation", "self.runMenuCmd", "v.kcv"), - ("Transfer attribute data from queried vector map to points", "Transfer attribute data from queried vector map to points", "self.runMenuCmd", "v.what.vect"), + ("Partition points into test/training sets for k-fold cross validation", "Partition points into test/training sets for k-fold cross validation", "self.OnMenuCmd", "v.kcv"), + ("Transfer attribute data from queried vector map to points", "Transfer attribute data from queried vector map to points", "self.OnMenuCmd", "v.what.vect"), )), ("","","", ""), ("Reports and statistics", ( - ("Basic information", "Basic information", "self.runMenuCmd", "v.info"), - ("Load vector attributes to database or create reports", "Load vector attributes to database or create reports", "self.runMenuCmd", "v.to.db"), - ("Report areas for vector attribute categories", "Report areas for vector attribute categories", "self.runMenuCmd", "v.report"), - ("Univariate statistics", "Univariate statistics", "self.runMenuCmd", "v.univar"), + ("Basic information", "Basic information", "self.OnMenuCmd", "v.info"), + ("Load vector attributes to database or create reports", "Load vector attributes to database or create reports", "self.OnMenuCmd", "v.to.db"), + ("Report areas for vector attribute categories", "Report areas for vector attribute categories", "self.OnMenuCmd", "v.report"), + ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "v.univar"), ("","","", ""), - ("Test normality of point distribution", "Test normality of point distribution", "self.runMenuCmd", "v.normal"), - ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.runMenuCmd", "v.rast.stats"), - ("Indices of point counts in quadrats", "Indices of point counts in quadrats", "self.runMenuCmd", "v.qcount"), + ("Test normality of point distribution", "Test normality of point distribution", "self.OnMenuCmd", "v.normal"), + ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.OnMenuCmd", "v.rast.stats"), + ("Indices of point counts in quadrats", "Indices of point counts in quadrats", "self.OnMenuCmd", "v.qcount"), )), ("","","", "") )), ("Image", ( ("Develop images and groups", ( - ("Create/edit imagery group", "Create/edit imagery group", "self.runMenuCmd", "i.group"), - ("Target imagery group", "Target imagery group", "self.runMenuCmd", "i.target"), + ("Create/edit imagery group", "Create/edit imagery group", "self.OnMenuCmd", "i.group"), + ("Target imagery group", "Target imagery group", "self.OnMenuCmd", "i.target"), ("","","", ""), - ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.runMenuCmd", "i.image.mosaic"), + ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.OnMenuCmd", "i.image.mosaic"), )), ("Manage image colors", ( - ("Color balance and enhance color tables of multiband imagery for rgb display", "Color balance and enhance color tables of multiband imagery for rgb display", "self.runMenuCmd", "i.landsat.rgb"), - ("Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "self.runMenuCmd", "i.his.rgb"), - ("Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "self.runMenuCmd", "i.rgb.his"), + ("Color balance and enhance color tables of multiband imagery for rgb display", "Color balance and enhance color tables of multiband imagery for rgb display", "self.OnMenuCmd", "i.landsat.rgb"), + ("Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "self.OnMenuCmd", "i.his.rgb"), + ("Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "self.OnMenuCmd", "i.rgb.his"), )), ("Rectify and georeference image group", ( - ("Set ground control points (GCP's) from raster map or keyboard entry", "Set ground control points (GCP's) from raster map or keyboard entry", "self.runMenuCmd", "i.points"), - ("Set ground control points (GCP's) from vector map or keyboard entry", "Set ground control points (GCP's) from vector map or keyboard entry", "self.runMenuCmd", "i.vpoints"), - ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.runMenuCmd", "i.rectify"), - ("Ortho Photo rectification", "Ortho Photo rectification", "self.runMenuCmd", "i.ortho.photo"), + ("Set ground control points (GCP's) from raster map or keyboard entry", "Set ground control points (GCP's) from raster map or keyboard entry", "self.OnMenuCmd", "i.points"), + ("Set ground control points (GCP's) from vector map or keyboard entry", "Set ground control points (GCP's) from vector map or keyboard entry", "self.OnMenuCmd", "i.vpoints"), + ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.OnMenuCmd", "i.rectify"), + ("Ortho Photo rectification", "Ortho Photo rectification", "self.OnMenuCmd", "i.ortho.photo"), )), ("","","", ""), - ("Brovey transformation and pan sharpening", "Brovey transformation and pan sharpening", "self.runMenuCmd", "i.fusion.brovey"), + ("Brovey transformation and pan sharpening", "Brovey transformation and pan sharpening", "self.OnMenuCmd", "i.fusion.brovey"), ("Classify image", ( - ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.runMenuCmd", "i.cluster"), + ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.OnMenuCmd", "i.cluster"), ("","","", ""), - ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.runMenuCmd", "i.maxlik"), - ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.runMenuCmd", "i.smap"), + ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.OnMenuCmd", "i.maxlik"), + ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.OnMenuCmd", "i.smap"), ("","","", ""), - ("Interactive input for supervised classification", "Interactive input for supervised classification", "self.runMenuCmd", "i.class"), - ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.runMenuCmd", "i.gensig"), - ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.runMenuCmd", "i.gensigset"), + ("Interactive input for supervised classification", "Interactive input for supervised classification", "self.OnMenuCmd", "i.class"), + ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.OnMenuCmd", "i.gensig"), + ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.OnMenuCmd", "i.gensigset"), )), ("Filter image", ( - ("Zero edge crossing detection", "Zero edge crossing detection", "self.runMenuCmd", "i.zc"), - ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.runMenuCmd", "r.mfilter"), + ("Zero edge crossing detection", "Zero edge crossing detection", "self.OnMenuCmd", "i.zc"), + ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.OnMenuCmd", "r.mfilter"), )), ("Histogram image", "Histogram image", "self.DispHistogram", ""), - ("Spectral response", "Spectral response", "self.runMenuCmd", "i.spectral"), - ("Tasseled cap vegetation index", "Tasseled cap vegetation index", "self.runMenuCmd", "i.tasscap"), + ("Spectral response", "Spectral response", "self.OnMenuCmd", "i.spectral"), + ("Tasseled cap vegetation index", "Tasseled cap vegetation index", "self.OnMenuCmd", "i.tasscap"), ("Transform image", ( - ("Canonical component", "Canonical component", "self.runMenuCmd", "i.cca"), - ("Principal component", "Principal component", "self.runMenuCmd", "i.pca"), - ("Fast Fourier Transform", "Fast Fourier Transform", "self.runMenuCmd", "i.fft"), - ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.runMenuCmd", "i.ifft"), + ("Canonical component", "Canonical component", "self.OnMenuCmd", "i.cca"), + ("Principal component", "Principal component", "self.OnMenuCmd", "i.pca"), + ("Fast Fourier Transform", "Fast Fourier Transform", "self.OnMenuCmd", "i.fft"), + ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.OnMenuCmd", "i.ifft"), )), ("","","", ""), ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.runMenuCmd", "r.info"), - ("Range of image values", "Range of image values", "self.runMenuCmd", "r.describe"), + ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), + ("Range of image values", "Range of image values", "self.OnMenuCmd", "r.describe"), ("","","", ""), - ("Bit pattern comparison for ID of low quality pixels", "Bit pattern comparison for ID of low quality pixels", "self.runMenuCmd", "r.bitpattern"), - ("Kappa classification accuracy assessment", "Kappa classification accuracy assessment", "self.runMenuCmd", "r.kappa"), - ("Optimum index factor for LandSat TM", "Optimum index factor for LandSat TM", "self.runMenuCmd", "i.oif"), + ("Bit pattern comparison for ID of low quality pixels", "Bit pattern comparison for ID of low quality pixels", "self.OnMenuCmd", "r.bitpattern"), + ("Kappa classification accuracy assessment", "Kappa classification accuracy assessment", "self.OnMenuCmd", "r.kappa"), + ("Optimum index factor for LandSat TM", "Optimum index factor for LandSat TM", "self.OnMenuCmd", "i.oif"), )), ("","","", "") )), Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-08 06:42:53 UTC (rev 792) +++ trunk/grassaddons/gui/wxgui.py 2007-06-08 06:49:53 UTC (rev 793) @@ -190,7 +190,7 @@ self.cmdinput.SetFont(wx.Font(10, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL, 0, '')) wx.CallAfter(self.cmdinput.SetInsertionPoint, 0) - self.Bind(wx.EVT_TEXT_ENTER, self.runCmd, self.cmdinput) + self.Bind(wx.EVT_TEXT_ENTER, self.OnRunCmd, self.cmdinput) return self.cmdinput @@ -279,6 +279,24 @@ # but in this case just call Skip so the default is done event.Skip() + def OnGeorectify(self, event): + """ + Launch georectifier module + """ + pass + + def OnMapsets(self, event): + """ + Launch mapset access module + """ + pass + + def OnRDigit(self, event): + """ + Launch raster digitizing module + """ + pass + # choicebook methods def onCBPageChanged(self, event): """Page in notebook changed""" @@ -305,7 +323,7 @@ self.gm_cb.GetPage(event.GetSelection()).maptree.Close(True) event.Skip() - def runCmd(self,event): + def OnRunCmd(self,event): """Run command""" #global gmpath @@ -314,7 +332,13 @@ self.goutput.RunCmd(cmd) #menuform.GUI().ParseCommand(cmd, gmpath) - def runMenuCmd(self, event): + def RunMenuCmd(self, event): + menuitem = self.menubar.FindItemById(event.GetId()) + itemtext = menuitem.GetText() + cmd = menucmd[itemtext] + self.goutput.RunCmd(cmd) + + def OnMenuCmd(self, event): """Run menu command""" menuitem = self.menubar.FindItemById(event.GetId()) From barton at grass.itc.it Fri Jun 8 08:50:43 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 8 08:50:45 2007 Subject: [grass-addons] r794 - trunk/grassaddons/gui/gui_modules Message-ID: <200706080650.l586ohtL003866@grass.itc.it> Author: barton Date: 2007-06-08 08:50:35 +0200 (Fri, 08 Jun 2007) New Revision: 794 Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Clean up debugging code Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-08 06:49:53 UTC (rev 793) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-08 06:50:35 UTC (rev 794) @@ -1120,9 +1120,7 @@ return else: # process GRASS command with argument - print 'cmdlist 2.5=',cmdlist cmdlist.append('--verbose') - print 'cmdlist3=', cmdlist p = cmd.Command(cmdlist) From chemin at grass.itc.it Fri Jun 8 10:53:07 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 10:53:09 2007 Subject: [grass-addons] r795 - trunk/grassaddons/gipe Message-ID: <200706080853.l588r7Lu005445@grass.itc.it> Author: chemin Date: 2007-06-08 10:53:00 +0200 (Fri, 08 Jun 2007) New Revision: 795 Modified: trunk/grassaddons/gipe/Makefile trunk/grassaddons/gipe/gmmenu.tcl trunk/grassaddons/gipe/imagery_Makefile trunk/grassaddons/gipe/menudata.py Log: Added Flag for Hargreaves-Samani (1985) method, renamed i.evapo.MH to r.evapo.MH to match r.evapo.PM from HydroFOSS Modified: trunk/grassaddons/gipe/Makefile =================================================================== --- trunk/grassaddons/gipe/Makefile 2007-06-08 06:50:35 UTC (rev 794) +++ trunk/grassaddons/gipe/Makefile 2007-06-08 08:53:00 UTC (rev 795) @@ -24,6 +24,7 @@ r.digit \ r.distance \ r.drain \ + r.evapo.MH \ r.fill.dir \ r.flow \ r.gaswap.serial \ Modified: trunk/grassaddons/gipe/gmmenu.tcl =================================================================== --- trunk/grassaddons/gipe/gmmenu.tcl 2007-06-08 06:50:35 UTC (rev 794) +++ trunk/grassaddons/gipe/gmmenu.tcl 2007-06-08 08:53:00 UTC (rev 795) @@ -540,7 +540,7 @@ }} {separator} {cascad {[G_msg "ETo, ETP, ETa"]} {} "" $tmenu { - {command {[G_msg "Reference ET (Hargreaves)"]} {} "i.evapo.MH" {} -command {execute i.evapo.MH }} + {command {[G_msg "Reference ET (Hargreaves)"]} {} "r.evapo.MH" {} -command {execute i.evapo.MH }} {separator} {command {[G_msg "Potential ET (Penman-Monteith)"]} {} "r.evapo.PM" {} -command {execute r.evapo.PM }} {command {[G_msg "Potential ET (Prestley and Taylor)"]} {} "i.evapo.PT" {} -command {execute i.evapo.PT }} Modified: trunk/grassaddons/gipe/imagery_Makefile =================================================================== --- trunk/grassaddons/gipe/imagery_Makefile 2007-06-08 06:50:35 UTC (rev 794) +++ trunk/grassaddons/gipe/imagery_Makefile 2007-06-08 08:53:00 UTC (rev 795) @@ -28,7 +28,6 @@ i.eb.ustar \ i.eb.z0m \ i.emissivity \ - i.evapo.MH \ i.evapo.potrad \ i.evapo.PT \ i.evapo.TSA \ Modified: trunk/grassaddons/gipe/menudata.py =================================================================== --- trunk/grassaddons/gipe/menudata.py 2007-06-08 06:50:35 UTC (rev 794) +++ trunk/grassaddons/gipe/menudata.py 2007-06-08 08:53:00 UTC (rev 795) @@ -316,9 +316,9 @@ )), ("","","", ""), ("ETo, ETP, ETa", ( - ("Reference ET (Hargreaves)", "Reference ET (Hargreaves)", "self.runMenuCmd", "i.evapo.MH"), + ("Reference ET (Hargreaves)", "Reference ET (Hargreaves)", "self.runMenuCmd", "r.evapo.MH"), ("","","", ""), - ("Potential ET (Penman-Monteith)", "Potential ET (Penman-Monteith)", "self.runMenuCmd", "i.evapo.PM"), + ("Potential ET (Penman-Monteith)", "Potential ET (Penman-Monteith)", "self.runMenuCmd", "r.evapo.PM"), ("Potential ET (Prestley and Taylor)", "Potential ET (Prestley and Taylor)", "self.runMenuCmd", "i.evapo.PT"), ("Potential ET (Radiative)", "Potential ET (Radiative)", "self.runMenuCmd", "i.evapo.potrad"), ("Potential ET (Radiative) from L7DN (.met)", "Potential ET (Radiative) from L7DN (.met)", "self.runMenuCmd", "i.dn2potrad.l7"), From chemin at grass.itc.it Fri Jun 8 10:57:14 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 10:57:16 2007 Subject: [grass-addons] r796 - trunk/grassaddons/gipe Message-ID: <200706080857.l588vEd9005465@grass.itc.it> Author: chemin Date: 2007-06-08 10:57:10 +0200 (Fri, 08 Jun 2007) New Revision: 796 Removed: trunk/grassaddons/gipe/i.evapo.MH/ Log: updating the directories From chemin at grass.itc.it Fri Jun 8 11:18:52 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 11:18:54 2007 Subject: [grass-addons] r797 - trunk/grassaddons/gipe/i.atcorr Message-ID: <200706080918.l589IqW4005494@grass.itc.it> Author: chemin Date: 2007-06-08 11:18:45 +0200 (Fri, 08 Jun 2007) New Revision: 797 Modified: trunk/grassaddons/gipe/i.atcorr/6s.cpp trunk/grassaddons/gipe/i.atcorr/6s.h trunk/grassaddons/gipe/i.atcorr/Abstra.cpp trunk/grassaddons/gipe/i.atcorr/Abstra.h Log: Update C compatible comment format in i.atcorr Modified: trunk/grassaddons/gipe/i.atcorr/6s.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/6s.cpp 2007-06-08 08:57:10 UTC (rev 796) +++ trunk/grassaddons/gipe/i.atcorr/6s.cpp 2007-06-08 09:18:45 UTC (rev 797) @@ -37,7 +37,7 @@ static AtmosModel original_atms; int init_6S(char* icnd_name) { - // (atmospheric conditions input text file) + /* (atmospheric conditions input text file) */ ifstream inText; inText.open(icnd_name); if(!inText.is_open()) { @@ -45,27 +45,27 @@ return -1; } - // redirect cin to the input text file + /* redirect cin to the input text file */ cin.rdbuf(inText.rdbuf()); - // read the input geometrical conditions + /* read the input geometrical conditions */ geom = GeomCond::Parse(); - // read atmospheric model + /* read atmospheric model */ original_atms = AtmosModel::Parse(); - atms = original_atms; // making a copy + atms = original_atms; /* making a copy */ - // read aerosol model + /* read aerosol model */ aero = AerosolModel::Parse(geom.xmud); - // read aerosol concentration + /* read aerosol concentration */ aerocon = AerosolConcentration::Parse(aero.iaer, atms); - // read altitude + /* read altitude */ alt = Altitude::Parse(); alt.init(atms, aerocon); - // read iwave stuff + /* read iwave stuff */ iwave = IWave::Parse(); /**********************************************************************c @@ -155,29 +155,29 @@ cout << endl << endl << endl; Output::Begin(); Output::Repeat(30,'*'); Output::Print(head); Output::Repeat(30,'*'); Output::End(); - // ---- geometrical conditions ---- + /* ---- geometrical conditions ---- */ geom.print(); - // --- atmospheric model ---- + /* --- atmospheric model ---- */ atms.print(); - // --- aerosols model (type) ---- + /* --- aerosols model (type) ---- */ aero.print(); - // --- aerosols model (concentration) ---- + /* --- aerosols model (concentration) ---- */ aerocon.print(); - // --- spectral condition ---- + /* --- spectral condition ---- */ iwave.print(); - // --- ground reflectance (type and spectral variation) ---- + /* --- ground reflectance (type and spectral variation) ---- */ Output::Ln(); Output::WriteLn(22," target type "); Output::WriteLn(22," ----------- "); Output::WriteLn(10," homogeneous ground "); - //12x a39 f6.3 + /* 12x a39 f6.3 */ static const string reflec[8] = { string(" user defined spectral reflectance "), string(" monochromatic reflectance "), @@ -189,7 +189,7 @@ string(" spectral volcanic debris reflectance ") }; - float rocave = 0; // block of code in Fortran will always compute 0 + float rocave = 0; /* block of code in Fortran will always compute 0 */ ostringstream s; s.setf(ios::fixed, ios::floatfield); s << setprecision(3); @@ -197,7 +197,7 @@ Output::WriteLn(12, s.str()); - // --- pressure at ground level (174) and altitude (175) ---- + /* --- pressure at ground level (174) and altitude (175) ---- */ Output::Ln(); Output::WriteLn(22," target elevation description "); Output::WriteLn(22," ---------------------------- "); @@ -228,7 +228,7 @@ alt.print(); - // ---- atmospheric correction ---- + /* ---- atmospheric correction ---- */ Output::Ln(); Output::WriteLn(23," atmospheric correction activated "); Output::WriteLn(23," -------------------------------- "); @@ -237,7 +237,7 @@ TransformInput compute() { const float accu3 = 1e-07; -// ---- initilialization // very liberal :) +/* ---- initilialization very liberal :) */ int i, j; float fr = 0; @@ -311,7 +311,7 @@ ainr[i][j] = 0; } - // ---- spectral loop ---- + /* ---- spectral loop ---- */ if (iwave.iwave == -2) { Output::WriteLn(1,"wave total total total total atm. swl step sbor dsol toar "); @@ -327,12 +327,12 @@ if(l == iwave.iinf || l == iwave.isup) sbor *= 0.5f; if(iwave.iwave == -1) sbor = 1.0f / step; - float roc = 0; // rocl[l]; - float roe = 0; // roel[l]; + float roc = 0; /* rocl[l]; */ + float roe = 0; /* roel[l]; */ float wl = 0.25f + l * step; AbstraStruct as; - float uwus, uo3us; // initialized in abstra + float uwus, uo3us; /* initialized in abstra */ abstra(atms, alt, wl, (float)geom.xmus, (float)geom.xmuv, atms.uw / 2.0f, atms.uo3, uwus, uo3us, alt.puw / 2.0f, alt.puo3, alt.puwus, alt.puo3us, as); @@ -392,7 +392,7 @@ float romeas2 = ratm2 + rsurf * tgtot; float romeas3 = ratm3 + rsurf * tgtot; - // computing integrated values over the spectral band + /* computing integrated values over the spectral band */ if (iwave.iwave == -2) { Output::Begin(); @@ -468,7 +468,7 @@ sb = sb + sbor * step; seb = seb + coef; - // output at the ground level. + /* output at the ground level. */ float tdir = (float)exp(-(is.tray + is.taer) / geom.xmus); float tdif = is.dtott - tdir; float etn = is.dtott * dgtot / (1 - avr * is.astot); @@ -503,7 +503,7 @@ aini[1][j] = aini[1][j] + ani[1][j] * sbor * step; } - // output at satellite level + /* output at satellite level */ float tmdir = (float)exp(-(is.tray + is.taer) / geom.xmuv); float tmdif = is.utott - tmdir; float xla0n = ratm2; @@ -527,8 +527,8 @@ } - // ---- integrated values of apparent reflectance, radiance ---- - // ---- and gaseous transmittances (total,downward,separately gases) ---- + /* ---- integrated values of apparent reflectance, radiance ----*/ + /* ---- and gaseous transmittances (total,downward,separately gases) ----*/ refet = refet / seb; refet1 = refet1 / seb; refet2 = refet2 / seb; Modified: trunk/grassaddons/gipe/i.atcorr/6s.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/6s.h 2007-06-08 08:57:10 UTC (rev 796) +++ trunk/grassaddons/gipe/i.atcorr/6s.h 2007-06-08 09:18:45 UTC (rev 797) @@ -39,4 +39,4 @@ */ extern TransformInput compute(); -#endif // _6S_H +#endif /* _6S_H */ Modified: trunk/grassaddons/gipe/i.atcorr/Abstra.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Abstra.cpp 2007-06-08 08:57:10 UTC (rev 796) +++ trunk/grassaddons/gipe/i.atcorr/Abstra.cpp 2007-06-08 09:18:45 UTC (rev 797) @@ -1,6 +1,6 @@ #ifdef WIN32 #pragma warning (disable : 4305) -#endif // WIN32 +#endif /* WIN32 */ #include "common.h" #include "Abstra.h" #include "AtmosModel.h" @@ -10235,13 +10235,13 @@ return; } - // constants determination + /* constants determination */ const float p0 = 1013.25f; const float g = 98.1f; const float t0 = 250.f; - // volumic mass in kilogrammes per m3 + /* volumic mass in kilogrammes per m3 */ ds = 0; te = 0; roair = 0; @@ -10353,7 +10353,7 @@ if(to270) for(int i = 0; i < 8; i++) a[i] = 0; - // mixing ratio calculation for each gaseous constituents + /* mixing ratio calculation for each gaseous constituents */ int k; for(k = 0; k < 33; k++) { @@ -10389,7 +10389,7 @@ udtp = 0; updtp = 0; - // pressure scale integration sigma = atms.p / p0 + /* pressure scale integration sigma = atms.p / p0 */ for(k = 1; k < 33; k++) { ds = (atms.p[k-1] - atms.p[k]) / atms.p[0]; @@ -10409,7 +10409,7 @@ if(idgaz == 6) uu = 1000 * uu / rmch4; if(idgaz == 7) uu = 1000 * uu / rmco; - // mixing ratio for plane calculation for each gaseous constituents + /* mixing ratio for plane calculation for each gaseous constituents */ if ((alt.idatmp == 0) || (alt.idatmp == 4)) { uupl = uu; @@ -10442,7 +10442,7 @@ upl = 0; uppl = 0; - // update ratio plane + /* update ratio plane */ for(int i = 0; i < 10; i++) ratpl[i] = 1; if (alt.idatmp == 8) @@ -10459,8 +10459,8 @@ ratpl[9] = uwpl / uwusp; } - // pressure scale integration sigma = atms.p / p0 - // * all gases + /* pressure scale integration sigma = atms.p / p0 */ + /* * all gases*/ for(k = 1; k < 33; k++) { @@ -10483,13 +10483,13 @@ if(idgaz == 6) uupl = 1000 * uupl / rmch4; if(idgaz == 7) uupl = 1000 * uupl / rmco; - } // endif test atms.idatm = 0,4 + } /* endif test atms.idatm = 0,4 */ - // downward path + /* downward path */ uud = uu / xmus; - // upward path + /* upward path */ uuu = uupl / xmuv; - // total(down + up) path + /* total(down + up) path */ uut = uu / xmus + uupl / xmuv; if((idgaz == 2 && iv > 9620) || (idgaz == 3 && iv > 15920)) @@ -10536,7 +10536,7 @@ test2 = ako3 * uuu; test3 = ako3 * uut; - // exponential overflow test + /* exponential overflow test */ if(test1 > 86.0) test1 = 86.0; if(test2 > 86.0) test2 = 86.0; @@ -10557,7 +10557,7 @@ continue; } - // downward path + /* downward path */ ud = u / xmus; upd = up / xmus; udt = ud; @@ -10573,7 +10573,7 @@ tnu[idgaz-1][0] = (float)exp(y); - // upward path modified to take account for plane content + /* upward path modified to take account for plane content */ udp = upl / xmuv; updp = uppl / xmuv; udtp = udp; @@ -10588,7 +10588,7 @@ if(idgaz == 1) y = (float)(-a[0] * udp / sqrt(1 + (a[0] / atest) * (udp * udp / updtp))); tnu[idgaz-1][1] = (float)exp(y); - // total(down + up) path modified on the way up + /* total(down + up) path modified on the way up */ ut = u / xmus + upl / xmuv; upt = up / xmus + uppl / xmuv; utt = ut; Modified: trunk/grassaddons/gipe/i.atcorr/Abstra.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Abstra.h 2007-06-08 08:57:10 UTC (rev 796) +++ trunk/grassaddons/gipe/i.atcorr/Abstra.h 2007-06-08 09:18:45 UTC (rev 797) @@ -3,27 +3,27 @@ struct AbstraStruct { - float dtwava; // downward absorption water vapor dtwava - float dtozon; // downward absorption ozone dtozon - float dtdica; // downward absorption carbon diox dtdica - float dtoxyg; // downward absorption oxygen dtoxyg - float dtniox; // downward absorption nitrous oxi dtniox - float dtmeth; // downward absorption methane dtmeth - float dtmoca; // downward absorption carbon mono dtmoca - float utwava; // upward absorption water vapor utwava - float utozon; // upward absorption ozone utozon - float utdica; // upward absorption carbon diox utdica - float utoxyg; // upward absorption oxygen utoxyg - float utniox; // upward absorption nitrous oxi utniox - float utmeth; // upward absorption methane utmeth - float utmoca; // upward absorption carbon mono utmoca - float ttwava; // total(on the two paths ) absorption water vapor ttwava - float ttozon; // total(on the two paths ) absorption ozone ttozon - float ttdica; // total(on the two paths ) absorption carbon diox ttdica - float ttoxyg; // total(on the two paths ) absorption oxygen ttoxyg - float ttniox; // total absorption nitrous oxi ttniox - float ttmeth; // total absorption methane ttmeth - float ttmoca; // total absorption carbon mono ttmoca + float dtwava; /* downward absorption water vapor dtwava */ + float dtozon; /* downward absorption ozone dtozon */ + float dtdica; /* downward absorption carbon diox dtdica */ + float dtoxyg; /* downward absorption oxygen dtoxyg */ + float dtniox; /* downward absorption nitrous oxi dtniox */ + float dtmeth; /* downward absorption methane dtmeth */ + float dtmoca; /* downward absorption carbon mono dtmoca */ + float utwava; /* upward absorption water vapor utwava */ + float utozon; /* upward absorption ozone utozon */ + float utdica; /* upward absorption carbon diox utdica */ + float utoxyg; /* upward absorption oxygen utoxyg */ + float utniox; /* upward absorption nitrous oxi utniox */ + float utmeth; /* upward absorption methane utmeth */ + float utmoca; /* upward absorption carbon mono utmoca */ + float ttwava; /* total(on the two paths ) absorption water vapor ttwava */ + float ttozon; /* total(on the two paths ) absorption ozone ttozon */ + float ttdica; /* total(on the two paths ) absorption carbon diox ttdica */ + float ttoxyg; /* total(on the two paths ) absorption oxygen ttoxyg */ + float ttniox; /* total absorption nitrous oxi ttniox */ + float ttmeth; /* total absorption methane ttmeth */ + float ttmoca; /* total absorption carbon mono ttmoca */ }; struct AtmosModel; @@ -41,4 +41,4 @@ const float uwpl, const float uo3pl, const float uwusp, const float uo3usp, AbstraStruct& as ); -#endif // ABSTRA_H +#endif /* ABSTRA_H */ From chemin at grass.itc.it Fri Jun 8 11:31:00 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 11:31:02 2007 Subject: [grass-addons] r798 - trunk/grassaddons/gipe/i.atcorr Message-ID: <200706080931.l589V0NR005518@grass.itc.it> Author: chemin Date: 2007-06-08 11:30:53 +0200 (Fri, 08 Jun 2007) New Revision: 798 Modified: trunk/grassaddons/gipe/i.atcorr/AerosolConcentration.cpp trunk/grassaddons/gipe/i.atcorr/AerosolConcentration.h trunk/grassaddons/gipe/i.atcorr/AerosolModel.cpp trunk/grassaddons/gipe/i.atcorr/AerosolModel.h Log: Update C compatible comment format in i.atcorr (more) Modified: trunk/grassaddons/gipe/i.atcorr/AerosolConcentration.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/AerosolConcentration.cpp 2007-06-08 09:18:45 UTC (rev 797) +++ trunk/grassaddons/gipe/i.atcorr/AerosolConcentration.cpp 2007-06-08 09:30:53 UTC (rev 798) @@ -26,12 +26,12 @@ taer55 = 0.f; cin >> v; - cin.ignore(numeric_limits::max(),'\n'); // ignore comments + cin.ignore(numeric_limits::max(),'\n'); /* ignore comments */ if(v == 0) { cin >> taer55; - cin.ignore(numeric_limits::max(),'\n'); // ignore comments + cin.ignore(numeric_limits::max(),'\n'); /* ignore comments */ v = (float)(exp(-log(taer55/2.7628f)/0.79902f)); } else if(v > 0) oda550(v, atms); @@ -39,9 +39,9 @@ void AerosolConcentration::oda550(const float v, const AtmosModel& atms) { - // aerosol optical depth at wl=550nm - // vertical repartition of aerosol density for v=23km - // ( in nbr of part/cm3 ) + /* aerosol optical depth at wl=550nm */ + /* vertical repartition of aerosol density for v=23km */ + /* ( in nbr of part/cm3 ) */ static const float an23[34] = { 2.828e+03,1.244e+03,5.371e+02,2.256e+02,1.192e+02, 8.987e+01,6.337e+01,5.890e+01,6.069e+01,5.818e+01, @@ -53,8 +53,8 @@ }; - // vertical repartition of aerosol density for v=5km - // ( in nbr of part/cm3 ) + /* vertical repartition of aerosol density for v=5km */ + /* ( in nbr of part/cm3 ) */ static const float an5[34] = { 1.378e+04,5.030e+03,1.844e+03,6.731e+02,2.453e+02, 8.987e+01,6.337e+01,5.890e+01,6.069e+01,5.818e+01, @@ -88,7 +88,7 @@ void AerosolConcentration::print() { - // --- aerosol model (concentration) ---- + /* --- aerosol model (concentration) ---- */ Output::Begin(); Output::End(); if(iaer == 0) return; Modified: trunk/grassaddons/gipe/i.atcorr/AerosolConcentration.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/AerosolConcentration.h 2007-06-08 09:18:45 UTC (rev 797) +++ trunk/grassaddons/gipe/i.atcorr/AerosolConcentration.h 2007-06-08 09:30:53 UTC (rev 798) @@ -31,7 +31,7 @@ struct AerosolConcentration { - // aerosol concentration parameters + /* aerosol concentration parameters */ float taer55; private: @@ -47,5 +47,5 @@ static AerosolConcentration Parse(const long int iaer, const AtmosModel &atms); }; -#endif // AEROSOLCONCENTRATION_H +#endif /* AEROSOLCONCENTRATION_H */ Modified: trunk/grassaddons/gipe/i.atcorr/AerosolModel.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/AerosolModel.cpp 2007-06-08 09:18:45 UTC (rev 797) +++ trunk/grassaddons/gipe/i.atcorr/AerosolModel.cpp 2007-06-08 09:30:53 UTC (rev 798) @@ -2,8 +2,8 @@ #include "AerosolModel.h" #include "AtmosModel.h" #ifdef WIN32 -#pragma warning(disable:4305) // disable warning about initialization of a float by a double -#endif // WIN32 +#pragma warning(disable:4305) /* disable warning about initialization of a float by a double */ +#endif /* WIN32 */ /* (background desert model...) */ void AerosolModel::bdm() @@ -59,7 +59,7 @@ double sca[10][4]; double p1[10][4][83]; - const double rmul = 0.99526231496887960135245539673954; //rlogpas = 0.030; // (10**rlogpas-1.D+00) + const double rmul = 0.99526231496887960135245539673954; /*rlogpas = 0.030; (10**rlogpas-1.D+00)*/ int i; for(i = 0; i < mie_in.icp; i++) @@ -81,23 +81,23 @@ double r; double dr; double nr = 0; - // LOOPS ON THE NUMBER OF PARTICLE TYPE (4 max) + /* LOOPS ON THE NUMBER OF PARTICLE TYPE (4 max) */ for(i = 0; i < mie_in.icp; i++) { r = mie_in.rmin; dr = r*rmul; - // LOOPS ON THE RADIUS OF THE PARTICLE + /* LOOPS ON THE RADIUS OF THE PARTICLE */ do { - // call of the size distribution nr. For our computation, we need dn/dr for - // all functions except for sun-photometer inputs for which we need dV/dlog(r) + /* call of the size distribution nr. For our computation, we need dn/dr for */ + /* all functions except for sun-photometer inputs for which we need dV/dlog(r) */ switch(iaer-7) { case 1: { - // --- Mixture of particles (Log-Normal distribution functions, up to 5) + /* --- Mixture of particles (Log-Normal distribution functions, up to 5)*/ const double sqrt2PI = 2.506628274631000502415765284811; const double ln10 = 2.3025850929940456840179914546844; double log10_x2 = log10(mie_in.x2[i]); @@ -108,7 +108,7 @@ } case 2: { - // --- Modified Gamma distribution function + /* --- Modified Gamma distribution function */ const double ldexp = -300.; double arg=-mie_in.x2[i]*pow(r,(double)mie_in.x3[i]); if(arg > ldexp) nr = pow(r,(double)mie_in.x1[i])*exp(arg); @@ -117,14 +117,14 @@ } case 3: { - // --- Junge power-law function + /* --- Junge power-law function */ nr = pow(0.1,-(double)mie_in.x1[i]); if(r > 0.1) nr = pow(r,-(double)mie_in.x1[i]); break; } case 4: { - // --- from sun photometer + /* --- from sun photometer */ nr = 0; for(int j = 1; j < mie_in.irsunph; j++) if((r-mie_in.rsunph[j]) < 0.000001) @@ -136,13 +136,13 @@ } } - // The Mie's calculations have to be called several times (min=2, max=10 for - // each type of particle): at wavelengths bounding the range of the selected - // wavelengths,and at 0.550 microns to normalized the extinction coefficient - // (if it's not in the selected range of wavelengths). + /* The Mie's calculations have to be called several times (min=2, max=10 for + each type of particle): at wavelengths bounding the range of the selected + wavelengths,and at 0.550 microns to normalized the extinction coefficient + (if it's not in the selected range of wavelengths). */ double xndpr2 = nr * dr * M_PI * (r * r); - // relatif number of particle for each type of particle (has to be equal to 1) + /* relatif number of particle for each type of particle (has to be equal to 1) */ np[i]+= nr * dr; for(int j = 0; j < 10; j++) @@ -156,7 +156,7 @@ ext[j][i] += xndpr2 * Qext; sca[j][i] += xndpr2 * Qsca; - // phase function for each type of particle + /* phase function for each type of particle */ for(int k = 0; k < 83; k++) p1[j][i][k] += p11[k]*xndpr2; } @@ -166,9 +166,9 @@ } - // NOW WE MIXTE THE DIFFERENT TYPES OF PARTICLE - // computation of the scattering and extinction coefficients. We first start - // at 0.550 micron (the extinction coefficient is normalized at 0.550 micron) + /* NOW WE MIXTE THE DIFFERENT TYPES OF PARTICLE + computation of the scattering and extinction coefficients. We first start + at 0.550 micron (the extinction coefficient is normalized at 0.550 micron) */ int j; for(j = 0; j < 10; j++) for(int i = 0; i < mie_in.icp; i++) @@ -179,8 +179,8 @@ sc[0][j] += (float)(mie_in.cij[i] * sca[j][i]); } - // computation of the phase function and the asymetry coefficient - // of the mixture of particles + /* computation of the phase function and the asymetry coefficient + of the mixture of particles */ for(j = 0; j < 10; j++) { @@ -216,9 +216,9 @@ double Ren=nr/(nr*nr+ni*ni); double Imn=ni/(nr*nr+ni*ni); - // ---Identification of the greater order of computation (=mu) - // as defined by F.J. Corbato, J. Assoc. Computing Machinery, 1959, - // 6, 366-375 + /* ---Identification of the greater order of computation (=mu) + as defined by F.J. Corbato, J. Assoc. Computing Machinery, 1959, + 6, 366-375 */ int N=int(0.5*(-1+sqrt(1+4*X*X)))+1; if (N == 1) N = 2; @@ -233,12 +233,12 @@ mu2 = int(Np + 30. * (0.1 + 0.35 * Up * (2 - Up * Up)/ 2 / (1 - Up))); } - int mu = (mu1 < mu2) ? mu1 : mu2; // min(mu1, mu2) + int mu = (mu1 < mu2) ? mu1 : mu2; /* min(mu1, mu2) */ - // --- Identification of the transition line. Below this line the Bessel - // function j behaves as oscillating functions. Above the behavior - // becomes monotonic. We start at a order greater than this transition - // line (order max=mu) because a downward recursion is called for. + /* --- Identification of the transition line. Below this line the Bessel + function j behaves as oscillating functions. Above the behavior + becomes monotonic. We start at a order greater than this transition + line (order max=mu) because a downward recursion is called for. */ double Rn[10001], xj[10001]; int k = mu + 1; @@ -271,8 +271,8 @@ for(k = mub; k >= 1; k--) xj[k-1] = (2 * k + 1) * xj[k] / X - xj[k+1]; double coxj = xj[0] - X * xj[1] * cos(X) + X * xj[0] * sin(X); - // --- Computation Dn(alpha) and Dn(alpha*m) (cf MIE's theory) - // downward recursion - real and imaginary parts + /* --- Computation Dn(alpha) and Dn(alpha*m) (cf MIE's theory) + downward recursion - real and imaginary parts */ double RDnY[10001]; double IDnY[10001]; @@ -292,8 +292,8 @@ IDnY[k-1] = k * Imn / X + XnumIDnY / XdenDnY; } - // --- Initialization of the upward recursions - // macro to help keep indexing correct, can't be to safe + /* --- Initialization of the upward recursions + macro to help keep indexing correct, can't be to safe */ #define INDEX(X) ((X)+1) double xy[10002]; xy[INDEX(-1)] = sin(X) / X; @@ -316,16 +316,16 @@ if (k <= mub) xj[k] /= coxj; else xj[k] = Rn[k-1] * xj[k-1]; - // --- Computation of bessel's function y(alpha) + /* --- Computation of bessel's function y(alpha) */ xy[INDEX(k)] = (2 * k - 1) * xy[INDEX(k-1)] / X - xy[INDEX(k-2)]; double xJonH = xj[k] / ( xj[k] * xj[k] + xy[INDEX(k)] * xy[INDEX(k)] ); - // --- Computation of Gn(alpha), Real and Imaginary part + /* --- Computation of Gn(alpha), Real and Imaginary part */ double XdenGNX = (RGnX[k-1] - k/X)*(RGnX[k-1] - k/X) + IGnX[k-1] * IGnX[k-1]; RGnX[k] = (k / X - RGnX[k-1])/XdenGNX - k / X; IGnX[k] = IGnX[k-1] / XdenGNX; - // --- Computation of An(alpha) and Bn(alpha), Real and Imaginary part + /* --- Computation of An(alpha) and Bn(alpha), Real and Imaginary part */ double Xnum1An = RDnY[k] - nr * RDnX[k]; double Xnum2An = IDnY[k] + ni * RDnX[k]; double Xden1An = RDnY[k] - nr * RGnX[k] - ni * IGnX[k]; @@ -346,8 +346,8 @@ RBn[k] = xJonH * (xj[k] * RBnb - xy[INDEX(k)] * IBnb); IBn[k] = xJonH * (xy[INDEX(k)] * RBnb + xj[k] * IBnb); - // ---Criterion on the recursion formulas as defined by D. Deirmendjian - // et al., J. Opt. Soc. Am., 1961, 51, 6, 620-633 + /* ---Criterion on the recursion formulas as defined by D. Deirmendjian + et al., J. Opt. Soc. Am., 1961, 51, 6, 620-633 */ double temp = RAn[k] * RAn[k] + IAn[k] * IAn[k] + RBn[k] * RBn[k] + IBn[k] * IBn[k]; if((temp/k) < 1e-14) { @@ -355,16 +355,16 @@ break; } - // --- Computation of the scattering and extinction efficiency factor + /* --- Computation of the scattering and extinction efficiency factor */ double xpond = 2 / X / X * (2 * k + 1); Qsca = Qsca + xpond * temp; Qext = Qext + xpond * (RAn[k] + RBn[k]); } - // --- Computation of the amplitude functions S1 and S2 (cf MIE's theory) - // defined by PIn, TAUn, An and Bn with PIn and TAUn related to the - // Legendre polynomials. + /* --- Computation of the amplitude functions S1 and S2 (cf MIE's theory) + defined by PIn, TAUn, An and Bn with PIn and TAUn related to the + Legendre polynomials. */ for(int j = 0; j < 83; j++) { double RS1 = 0; @@ -390,18 +390,18 @@ TAUn[k+1] = (k + 1) * sixs_sos.cgaus[j] * PIn[k + 1] - (k + 2) * PIn[k]; } - // --- Computation of the scattering intensity efficiency + /* --- Computation of the scattering intensity efficiency */ p11[j] = 2 * (RS1 *RS1 + IS1 * IS1 + RS2 * RS2 + IS2 * IS2)/X/X; } } -// load parameters from .mie file +/* load parameters from .mie file */ void AerosolModel::load() { int i; ifstream in(filename.c_str()); - cin.ignore(numeric_limits::max(),'\n'); // ignore this line + cin.ignore(numeric_limits::max(),'\n'); /* ignore this line */ in.ignore(8); for(i = 0; i < 10; i++) @@ -415,13 +415,13 @@ in.ignore(6); in >> sixs_aer.gasym[i]; in.ignore(3); - cin.ignore(numeric_limits::max(),'\n'); // ignore the rest + cin.ignore(numeric_limits::max(),'\n'); /* ignore the rest */ } - // ignore 3 lines - cin.ignore(numeric_limits::max(),'\n'); // ignore this line - cin.ignore(numeric_limits::max(),'\n'); // ignore this line - cin.ignore(numeric_limits::max(),'\n'); // ignore this line + /* ignore 3 lines */ + cin.ignore(numeric_limits::max(),'\n'); /* ignore this line */ + cin.ignore(numeric_limits::max(),'\n'); /* ignore this line */ + cin.ignore(numeric_limits::max(),'\n'); /* ignore this line */ for(i = 0; i < 83; i++) { @@ -431,21 +431,21 @@ in.ignore(1); in >> sixs_sos.phasel[j][i]; } - cin.ignore(numeric_limits::max(),'\n'); // ignore the rest + cin.ignore(numeric_limits::max(),'\n'); /* ignore the rest */ } } -// do we wish to save this? +/* do we wish to save this? */ void AerosolModel::save() { ofstream out(filename.c_str()); - // output header + /* output header */ out << " Wlgth Nor_Ext_Co Nor_Sca_Co Sg_Sca_Alb Asymm_Para Extinct_Co Scatter_Co" << endl; int i; for(i = 0; i < 10; i++) { - out << setprecision(4); // set the required precision + out << setprecision(4); /* set the required precision */ out << " " << setw(10) << sixs_disc.wldis[0] << " " << setw(10) << sixs_aer.ext[i] << " " << setw(10) << sca[i] @@ -580,7 +580,7 @@ static const float asy3[10] = { .704f, .69f, .686f, .68f, .667f, .659f, .637f, .541f, .437f, .241f }; static const float asy4[10] = { .705f, .744f, .751f, .757f, .762f, .759f, .737f, .586f, .372f, .139f }; - // local + /* local */ double coef; float sigm; double sumni; @@ -591,8 +591,8 @@ float sc[4][10]; float asy[4][10]; - int i; // crappy VS6 - // initialize ex, sc & asy + int i; /* crappy VS6 */ + /* initialize ex, sc & asy */ for(i = 0; i < 4; i++) { int j; @@ -614,20 +614,20 @@ for (int k = 1; k <= 83; ++k) sixs_sos.phasel[i][k] = 0.f; } - // return if iear = 0 + /* return if iear = 0 */ if(iaer == 0) return; - // look for an interval in cgaus + /* look for an interval in cgaus */ long int j1 = -1; for (i = 0; i < 82; ++i) if (xmud >= sixs_sos.cgaus[i] && xmud < sixs_sos.cgaus[i+1]) { j1 = i; break; } - if(j1 == -1) return; // unable to find interval + if(j1 == -1) return; /* unable to find interval */ coef = -(xmud - sixs_sos.cgaus[j1]) / (sixs_sos.cgaus[j1+1] - sixs_sos.cgaus[j1]); switch(iaer) { - case 12: // read from file + case 12: /* read from file */ { load(); for(i = 0; i < 10; i++) @@ -784,7 +784,7 @@ cin >> iaer; cin.ignore(numeric_limits::max(),'\n'); - // initialize vars; + /* initialize vars; */ mie_in.rmin = 0.f; mie_in.rmax = 0.f; mie_in.icp = 1; @@ -817,7 +817,7 @@ case 0: case 5: case 6: - case 7: break; // do nothing + case 7: break; /* do nothing */ case 1: { @@ -948,7 +948,7 @@ break; } case 12: - { // read file name + { /* read file name */ getline(cin,filename); filename = filename.substr(0, filename.find(" ")); break; @@ -959,7 +959,7 @@ if(iaer >= 8 && iaer <= 11) { cin >> iaerp; - if( iaerp == 1 ) // read file name + if( iaerp == 1 ) /* read file name */ { getline(cin,filename); filename = filename.substr(0, filename.find(" ")); @@ -970,7 +970,7 @@ aeroso(xmud); } -// format 132 +/* format 132 */ void AerosolModel::print132(string s) { Output::Begin(); @@ -980,10 +980,10 @@ Output::End(); } -// --- aerosols model ---- +/* --- aerosols model ---- */ void AerosolModel::print() { - // --- aerosols model (type) ---- + /* --- aerosols model (type) ---- */ Output::Begin(); Output::Repeat(10, ' '); Output::Print(" aerosols type identity :"); Modified: trunk/grassaddons/gipe/i.atcorr/AerosolModel.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/AerosolModel.h 2007-06-08 09:18:45 UTC (rev 797) +++ trunk/grassaddons/gipe/i.atcorr/AerosolModel.h 2007-06-08 09:30:53 UTC (rev 798) @@ -84,7 +84,7 @@ struct AerosolModel { - long int iaer; // aerosol model + long int iaer; /* aerosol model */ float c[4]; private: @@ -92,14 +92,14 @@ float sca[10]; long int iaerp; - // methods + /* methods */ void aeroso(const float xmud); string filename; void load(); - void save(); // .mie file + void save(); /* .mie file */ - // defined models' initilizations + /* defined models' initilizations */ void bdm(); void bbm(); void stm(); @@ -133,7 +133,7 @@ void parse(const float xmud); - // format 132 + /* format 132 */ void print132(string s); public: void print(); @@ -142,4 +142,4 @@ -#endif // AEROSOL_MODEL_H +#endif /* AEROSOL_MODEL_H */ From chemin at grass.itc.it Fri Jun 8 11:37:47 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 11:37:48 2007 Subject: [grass-addons] r799 - trunk/grassaddons/gipe/i.atcorr Message-ID: <200706080937.l589blb7005547@grass.itc.it> Author: chemin Date: 2007-06-08 11:37:40 +0200 (Fri, 08 Jun 2007) New Revision: 799 Modified: trunk/grassaddons/gipe/i.atcorr/Altitude.cpp trunk/grassaddons/gipe/i.atcorr/Altitude.h trunk/grassaddons/gipe/i.atcorr/AtmosModel.cpp trunk/grassaddons/gipe/i.atcorr/AtmosModel.h Log: Update C compatible comment format in i.atcorr (more 1) Modified: trunk/grassaddons/gipe/i.atcorr/Altitude.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Altitude.cpp 2007-06-08 09:30:53 UTC (rev 798) +++ trunk/grassaddons/gipe/i.atcorr/Altitude.cpp 2007-06-08 09:37:40 UTC (rev 799) @@ -16,7 +16,7 @@ */ void Altitude::pressure(AtmosModel& atms, float& uw, float& uo3) { - // log linear interpolation + /* log linear interpolation */ if(xps >= 100) xps = 99.99f; int i; @@ -29,7 +29,7 @@ float xb = (float)(atms.z[isup] - xa * log(atms.p[isup])); float ps = (float)exp((xps - xb) / xa); - // interpolating temperature wator vapor and ozone profile versus altitude + /* interpolating temperature wator vapor and ozone profile versus altitude */ float xalt = xps; float xtemp = (atms.t[isup] - atms.t[iinf]) / (atms.z[isup] - atms.z[iinf]); xtemp = xtemp * (xalt - atms.z[iinf]) + atms.t[iinf]; @@ -38,9 +38,9 @@ float xwh = (atms.wh[isup] - atms.wh[iinf]) / (atms.z[isup] - atms.z[iinf]); xwh = xwh * (xalt - atms.z[iinf]) + atms.wh[iinf]; - // updating atmospheric profile - // 1rst level: target , complete to 34 - // with interpolated layers + /* updating atmospheric profile + 1rst level: target , complete to 34 + with interpolated layers */ atms.z[0] = xalt; atms.p[0] = ps; atms.t[0] = xtemp; @@ -65,7 +65,7 @@ atms.wo[i] = (atms.wo[33] - atms.wo[l]) * (i - l) / (33 - l) + atms.wo[l]; } - // compute modified h2o and o3 integrated content + /* compute modified h2o and o3 integrated content */ uw = 0; uo3 = 0; const float g = 98.1f; @@ -108,7 +108,7 @@ */ void Altitude::presplane(AtmosModel& atms) { - // log linear interpolation + /* log linear interpolation */ xpp += atms.z[0]; if(xpp >= 100) xpp = 1000; @@ -122,7 +122,7 @@ float xb = (float)(atms.z[isup] - xa * log(atms.p[isup])); float ps = (float)(exp((xpp - xb) / xa)); - // interpolating temperature wator vapor and ozone profile versus altitud + /* interpolating temperature wator vapor and ozone profile versus altitud */ float xalt = xpp; float xtemp = (atms.t[isup] - atms.t[iinf])/ (atms.z[isup] - atms.z[iinf]); xtemp = xtemp * (xalt - atms.z[iinf]) + atms.t[iinf]; @@ -131,9 +131,9 @@ float xwh = (atms.wh[isup] - atms.wh[iinf]) / (atms.z[isup] - atms.z[iinf]); xwh = xwh * (xalt - atms.z[iinf]) + atms.wh[iinf]; - // updating atmospheric profile - // last level: plane , complete to 34 - // with interpolated layers + /* updating atmospheric profile + last level: plane , complete to 34 + with interpolated layers */ for(i = 0; i <= iinf; i++) { plane_sim.zpl[i] = atms.z[i]; @@ -152,9 +152,9 @@ plane_sim.wopl[i] = xwo; } - // compute modified h2o and o3 integrated content - // compute conversion factor for rayleigh optical thickness computation - // ftray=rp/rt + /* compute modified h2o and o3 integrated content + compute conversion factor for rayleigh optical thickness computation + ftray=rp/rt */ atms.uw = 0; atms.uo3 = 0; const float g = 98.1f; @@ -207,7 +207,7 @@ if(xpp <= 0) { - // ground measurement option + /* ground measurement option */ palt = 0; pps = atms.p[0]; idatmp = 0; @@ -216,7 +216,7 @@ } else if(xpp >= 100) { - // satellite case of equivalent + /* satellite case of equivalent */ palt = 1000; pps = 0; taer55p = aerocon.taer55; @@ -226,10 +226,10 @@ } else { - // "real" plane case + /* "real" plane case */ cin >> puw; cin >> puo3; - cin.ignore(numeric_limits::max(),'\n'); // ignore comments + cin.ignore(numeric_limits::max(),'\n'); /* ignore comments */ if ( puw < 0 ) { presplane(atms); @@ -256,12 +256,12 @@ if ((taer55p > 0) || ((aerocon.taer55 - taer55p) < 1e-03)) { - // a scale heigh of 2km is assumed in case no value is given for taer55p + /* a scale heigh of 2km is assumed in case no value is given for taer55p */ taer55p = (float)(aerocon.taer55 * (1 - exp(-palt / 2))); } else { - // compute effective scale heigh + /* compute effective scale heigh */ double sham = exp(-palt / 4); double sha = 1 - (taer55p / aerocon.taer55); @@ -277,15 +277,15 @@ void Altitude::parse() { cin >> original_xps; - cin.ignore(numeric_limits::max(),'\n'); // ignore comments + cin.ignore(numeric_limits::max(),'\n'); /* ignore comments */ original_xps = -original_xps; cin >> original_xpp; - cin.ignore(numeric_limits::max(),'\n'); // ignore comments + cin.ignore(numeric_limits::max(),'\n'); /* ignore comments */ original_xpp = -original_xpp; } -// --- plane simulation output if selected ---- +/* --- plane simulation output if selected ---- */ void Altitude::print() { if(palt < 1000) Modified: trunk/grassaddons/gipe/i.atcorr/Altitude.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Altitude.h 2007-06-08 09:30:53 UTC (rev 798) +++ trunk/grassaddons/gipe/i.atcorr/Altitude.h 2007-06-08 09:37:40 UTC (rev 799) @@ -27,9 +27,9 @@ C this altitude is relative to the target altitude c c c c for aircraft simulations only, you have to give c -c puw,po3 (water vapor content,ozone content between the c +c puw,po3 (water vapor content,ozone content between the c c aircraft and the surface) c -c taerp (the aerosol optical thickness at 550nm between the c +c taerp (the aerosol optical thickness at 550nm between the c c aircraft and the surface) c c if these data are not available, enter negative values for all c c of them, puw,po3 will then be interpolated from the us62 standard c @@ -44,7 +44,7 @@ float xps; float xpp; - // some vars + /* some vars */ mutable float palt; float pps; int idatmp; @@ -66,9 +66,9 @@ } plane_sim; private: - // remember the original input values - // these values are set the first time when parse is called - // and used in subsequent calls to init to set xps and xpp + /* remember the original input values + these values are set the first time when parse is called + and used in subsequent calls to init to set xps and xpp */ float original_xps; float original_xpp; @@ -91,4 +91,4 @@ }; -#endif // ALTITUDE_H +#endif /* ALTITUDE_H */ Modified: trunk/grassaddons/gipe/i.atcorr/AtmosModel.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/AtmosModel.cpp 2007-06-08 09:30:53 UTC (rev 798) +++ trunk/grassaddons/gipe/i.atcorr/AtmosModel.cpp 2007-06-08 09:37:40 UTC (rev 799) @@ -325,7 +325,7 @@ void AtmosModel::parse() { cin >> idatm; - cin.ignore(numeric_limits::max(),'\n'); // read the rest of the scraps, like comments + cin.ignore(numeric_limits::max(),'\n'); /* read the rest of the scraps, like comments */ uw = 0.; uo3 = 0.; @@ -341,7 +341,7 @@ case 6: us62(); break; case 7: { - // read input + /* read input */ for(int i = 0; i < 34; i++) { cin >> z[i]; @@ -349,7 +349,7 @@ cin >> t[i]; cin >> wh[i]; cin >> wo[i]; - cin.ignore(numeric_limits::max(),'\n'); // read the rest of the scraps, like comments + cin.ignore(numeric_limits::max(),'\n'); /* read the rest of the scraps, like comments */ } break; } @@ -357,7 +357,7 @@ { cin >> uw; cin >> uo3; - cin.ignore(numeric_limits::max(),'\n'); // read the rest of the scraps, like comments + cin.ignore(numeric_limits::max(),'\n'); /* read the rest of the scraps, like comments */ us62(); break; } @@ -365,7 +365,7 @@ } } -// --- atmospheric model ---- +/* --- atmospheric model ---- */ void AtmosModel::print() { static const string head(" atmospheric model description "); Modified: trunk/grassaddons/gipe/i.atcorr/AtmosModel.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/AtmosModel.h 2007-06-08 09:30:53 UTC (rev 798) +++ trunk/grassaddons/gipe/i.atcorr/AtmosModel.h 2007-06-08 09:37:40 UTC (rev 799) @@ -36,13 +36,13 @@ struct AtmosModel { - long int idatm; // atmospheric model + long int idatm; /* atmospheric model*/ - // secondary + /* secondary */ float uw; float uo3; - // primary + /* primary */ float z[34]; float p[34]; float t[34]; @@ -50,7 +50,7 @@ float wo[34]; private: - // methods to initialize each model + /* methods to initialize each model */ void us62(); void tropic(); void midsum(); @@ -65,4 +65,4 @@ static AtmosModel Parse(); }; -#endif // ATMOSPHERIC_MODEL_H +#endif /* ATMOSPHERIC_MODEL_H */ From chemin at grass.itc.it Fri Jun 8 11:57:13 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 11:57:15 2007 Subject: [grass-addons] r800 - trunk/grassaddons/gipe/i.atcorr Message-ID: <200706080957.l589vDnA005605@grass.itc.it> Author: chemin Date: 2007-06-08 11:57:07 +0200 (Fri, 08 Jun 2007) New Revision: 800 Modified: trunk/grassaddons/gipe/i.atcorr/common.cpp trunk/grassaddons/gipe/i.atcorr/common.h trunk/grassaddons/gipe/i.atcorr/computations.cpp Log: Update C compatible comment format in i.atcorr (more 2) Modified: trunk/grassaddons/gipe/i.atcorr/common.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/common.cpp 2007-06-08 09:37:40 UTC (rev 799) +++ trunk/grassaddons/gipe/i.atcorr/common.cpp 2007-06-08 09:57:07 UTC (rev 800) @@ -1,15 +1,15 @@ #include "common.h" #ifdef WIN32 -#pragma warning(disable:4305) // disable warning about initialization of a float by a double +#pragma warning(disable:4305) /* disable warning about initialization of a float by a double */ #endif -Sixs_aer sixs_aer; // will be initialized in AerosolModel -Sixs_trunc sixs_trunc; // initialized in discom global routine +Sixs_aer sixs_aer; /* will be initialized in AerosolModel */ +Sixs_trunc sixs_trunc; /* initialized in discom global routine */ Sixs_disc sixs_disc = { {0}, {0}, {0}, {0}, {0}, {0}, - { .4f, .488f, .515f, .55f, .633f, .694f, .86f, 1.536f, 2.25f, 3.75f },// wldis + { .4f, .488f, .515f, .55f, .633f, .694f, .86f, 1.536f, 2.25f, 3.75f },/* wldis */ {0}, {0} }; @@ -45,10 +45,10 @@ }; -// only used in aerosol model +/* only used in aerosol model */ Sixs_aerbas sixs_aerbas = { - // background desert model... + /* background desert model... */ {{ 0.8352,0.8057,0.7377,0.6569,0.5760,0.5032,0.4427,0.3969, @@ -183,7 +183,7 @@ 13.032,13.853,14.061 }}, - // biomass burning model... + /* biomass burning model... */ {{ 0.2150,0.2122,0.2027,0.1928,0.1884,0.1905,0.1952,0.1983, 0.1980,0.1954,0.1918,0.1874,0.1819,0.1752,0.1680,0.1612, @@ -318,9 +318,9 @@ 2.5283,2.5355,2.5372 }}, - // stratospherique aerosol model... - // model: Stratospheric aerosol as follow king's model - // Journal of Climate and Applied Meteorology, Vol23, No7, pp=1121-1137, 1984 + /* stratospherique aerosol model... + model: Stratospheric aerosol as follow king's model + Journal of Climate and Applied Meteorology, Vol23, No7, pp=1121-1137, 1984 */ {{ .4482, .4378, .3984, .3460, .3030, .2864, .3011, .3393, .3852, .4224, .4395, .4332, .4068, .3674, .3232, .2806, @@ -452,7 +452,7 @@ 2.0370, 2.0419, 2.0431 }}, - // dust model + /* dust model */ {{ 0.2021E+00,0.2079E+00,0.2462E+00,0.2310E+00,0.2069E+00,0.1883E+00, 0.1750E+00,0.1624E+00,0.1458E+00,0.1241E+00,0.1013E+00,0.8379E-01, @@ -614,7 +614,7 @@ 0.2699E+02,0.4205E+02,0.7598E+02,0.1847E+03,0.5926E+03 }}, - // water model + /* water model */ {{ 0.4115E+00,0.4045E+00,0.3805E+00,0.3495E+00,0.3192E+00,0.2943E+00, 0.2768E+00,0.2659E+00,0.2592E+00,0.2538E+00,0.2479E+00,0.2411E+00, @@ -776,7 +776,7 @@ 0.6262E+01,0.6528E+01,0.6740E+01,0.6876E+01,0.6911E+01 }}, - // ocean model + /* ocean model */ {{ 0.7855E+00,0.6283E+00,0.5465E+00,0.4693E+00,0.4153E+00,0.3917E+00, 0.3657E+00,0.3378E+00,0.3161E+00,0.3025E+00,0.2972E+00,0.2990E+00, @@ -938,7 +938,7 @@ 0.1816E+02,0.2237E+02,0.2799E+02,0.3517E+02,0.3934E+02 }}, - // soot model + /* soot model */ {{ 0.4897E+00,0.4896E+00,0.4890E+00,0.4881E+00,0.4867E+00,0.4849E+00, 0.4827E+00,0.4802E+00,0.4773E+00,0.4743E+00,0.4709E+00,0.4675E+00, @@ -1101,10 +1101,10 @@ 0.1685E+01,0.1694E+01,0.1701E+01,0.1704E+01,0.1705E+01 }}, - // user defined model + /* user defined model */ {{0},{0},{0},{0},{0},{0},{0},{0}}, - // pointer to current active model + /* pointer to current active model */ 0 }; Modified: trunk/grassaddons/gipe/i.atcorr/common.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/common.h 2007-06-08 09:37:40 UTC (rev 799) +++ trunk/grassaddons/gipe/i.atcorr/common.h 2007-06-08 09:57:07 UTC (rev 800) @@ -13,7 +13,7 @@ #ifndef M_PI #define M_PI 3.1415926535897932384626433832795 -#endif // M_PI +#endif /* M_PI */ #define M_PI2 6.283185307179586476925286766559 #define MIN(X,Y) ((X) <= (Y) ? (X) : (Y)) #define ROUND(X) ((X) - (int)(X) < 0.5 ? (int)(X) : (int)((X)+1)) @@ -28,7 +28,7 @@ /* Globals */ -// not sure what the name stands for +/* not sure what the name stands for */ struct Sixs_sos { float phasel[10][83]; @@ -46,16 +46,16 @@ struct Sixs_aerbas { - float bdm_ph[10][83]; // background desert model... - float bbm_ph[10][83]; // biomass burning model... - float stm_ph[10][83]; // stratospherique aerosol model... - float dust_ph[10][83]; // dust model - float wate_ph[10][83]; // water model - float ocea_ph[10][83]; // ocean model - float soot_ph[10][83]; // soot model + float bdm_ph[10][83]; /* background desert model... */ + float bbm_ph[10][83]; /* biomass burning model... */ + float stm_ph[10][83]; /* stratospherique aerosol model... */ + float dust_ph[10][83]; /* dust model */ + float wate_ph[10][83]; /* water model */ + float ocea_ph[10][83]; /* ocean model */ + float soot_ph[10][83]; /* soot model */ - float usr_ph[10][83]; // user defined model from size distribution - float (*ph)[10][83]; // pointer to current active model + float usr_ph[10][83]; /* user defined model from size distribution */ + float (*ph)[10][83]; /* pointer to current active model */ }; struct Sixs_trunc @@ -83,4 +83,4 @@ extern Sixs_trunc sixs_trunc; extern Sixs_disc sixs_disc; -#endif // MY_COMMON_H +#endif /* MY_COMMON_H */ Modified: trunk/grassaddons/gipe/i.atcorr/computations.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/computations.cpp 2007-06-08 09:37:40 UTC (rev 799) +++ trunk/grassaddons/gipe/i.atcorr/computations.cpp 2007-06-08 09:57:07 UTC (rev 800) @@ -23,11 +23,11 @@ float sphalbr, sphalbt, sphalba; }; -// To compute the molecular optical depth as a function of wavelength for any -// atmosphere defined by the pressure and temperature profiles. +/* To compute the molecular optical depth as a function of wavelength for any + atmosphere defined by the pressure and temperature profiles. */ float odrayl(const AtmosModel &atms, const float wl) { - // air refraction index edlen 1966 / metrologia,2,71-80 putting pw=0 + /* air refraction index edlen 1966 / metrologia,2,71-80 putting pw=0 */ float ak=1/wl; double awl= wl*wl*wl*wl; double a1 = 130 - ak * ak; @@ -175,7 +175,7 @@ if( it == 0 ) dt = 1e-17; else dt = 2 * (ta + tr - yy) / (nt - it + 1); - float zx; // return value + float zx; /* return value */ float ecart = 0; do { dt = dt / 2; @@ -208,7 +208,7 @@ } -// indexing macro for the psl variable +/* indexing macro for the psl variable */ #define PSI(X) ((X)+1) /* Compute the values of Legendre polynomials used in the successive order of @@ -255,7 +255,7 @@ { double a = 1; for(int i = 1; i <= is; i++) a *= sqrt((double)(i + is) / (double)i) * 0.5; -// double b = a * sqrt((double)is / (is + 1.)) * sqrt((is - 1.) / (is + 2.)); +/* double b = a * sqrt((double)is / (is + 1.)) * sqrt((is - 1.) / (is + 2.));*/ for(int j = 0; j <= mu; j++) { @@ -327,17 +327,17 @@ float tap = tamoy - tamoyp; int iplane = 0; - // if plane observations recompute scale height for aerosol knowing: - // the aerosol optical depth as measure from the plane = tamoyp - // the rayleigh scale height = = hr (8km) - // the rayleigh optical depth at plane level = trmoyp - // the altitude of the plane = palt - // the rayleigh optical depth for total atmos = trmoy - // the aerosol optical depth for total atmos = tamoy - // if not plane observations then ha is equal to 2.0km - // ntp local variable: if ntp=nt no plane observation selected - // ntp=nt-1 plane observation selected - // it's a mixing rayleigh+aerosol + /* if plane observations recompute scale height for aerosol knowing: + the aerosol optical depth as measure from the plane = tamoyp + the rayleigh scale height = = hr (8km) + the rayleigh optical depth at plane level = trmoyp + the altitude of the plane = palt + the rayleigh optical depth for total atmos = trmoy + the aerosol optical depth for total atmos = tamoy + if not plane observations then ha is equal to 2.0km + ntp local variable: if ntp=nt no plane observation selected + ntp=nt-1 plane observation selected + it's a mixing rayleigh+aerosol */ float ha = 2; int snt = nt; @@ -350,10 +350,10 @@ float xmus = -gauss.rm[STDI(0)]; - // compute mixing rayleigh, aerosol - // case 1: pure rayleigh - // case 2: pure aerosol - // case 3: mixing rayleigh-aerosol + /* compute mixing rayleigh, aerosol + case 1: pure rayleigh + case 2: pure aerosol + case 3: mixing rayleigh-aerosol */ float h[31]; memset(h, 0, sizeof(h)); @@ -426,15 +426,15 @@ } } - // update plane layer if necessary + /* update plane layer if necessary */ if (ntp == (snt - 1)) { - // compute position of the plane layer + /* compute position of the plane layer */ float taup = tap + trp; iplane = -1; for(int i = 0; i <= ntp; i++) if (taup >= h[i]) iplane = i; - // update the layer from the end to the position to update if necessary + /* update the layer from the end to the position to update if necessary */ float xt1 = (float)fabs(h[iplane] - taup); float xt2 = (float)fabs(h[iplane+1] - taup); @@ -492,17 +492,17 @@ int i; for(i = 0; i < np; i++) for(int m = -mu; m <= mu; m++) xl[STDI(m)][i] = 0; - // ************ incident angle mus ******* + /* ************ incident angle mus ******* */ float aaaa = delta / (2 - delta); float ron = (1 - aaaa) / (1 + 2 * aaaa); - // rayleigh phase function + /* rayleigh phase function */ float beta0 = 1; float beta2 = 0.5f * ron; - // fourier decomposition + /* fourier decomposition */ float i1[31][2*mu + 1]; float i2[31][2*mu + 1]; float i3[2*mu + 1]; @@ -517,7 +517,7 @@ for(int is = 0; is <= iborm; is++) { - // primary scattering + /* primary scattering */ int ig = 1; float roavion0 = 0; float roavion1 = 0; @@ -527,7 +527,7 @@ int j; for(j = -mu; j <= mu; j++) i3[STDI(j)] = 0; - // kernel computations + /* kernel computations */ float xpl[2*mu + 1]; float bp[26][2*mu + 1]; memset(xpl, 0, sizeof(float)*(2*mu+1)); @@ -553,7 +553,7 @@ sa2 = bp[0][STDI(j)]; sa1 = 0; } - // primary scattering source function at every level within the layer + /* primary scattering source function at every level within the layer */ for(int k = 0; k <= snt; k++) { @@ -565,7 +565,7 @@ } int k; - // vertical integration, primary upward radiation + /* vertical integration, primary upward radiation */ for(k = 1; k <= mu; k++) { i1[snt][STDI(k)] = 0; @@ -584,7 +584,7 @@ } } - // vertical integration, primary downward radiation + /* vertical integration, primary downward radiation */ for(k = -mu; k <= -1; k++) { i1[0][STDI(k)] = 0; @@ -602,8 +602,8 @@ } } - // inm2 is inialized with scattering computed at n-2 - // i3 is inialized with primary scattering + /* inm2 is inialized with scattering computed at n-2 + i3 is inialized with primary scattering */ for(k = -mu; k <= mu; k++) { if(k < 0) @@ -624,13 +624,13 @@ do { - // loop on successive order + /* loop on successive order */ ig++; - // successive orders - // multiple scattering source function at every level within the laye - // if is < ou = 2 kernels are a mixing of aerosols and molecules kern - // if is >2 aerosols kernels only + /* successive orders + multiple scattering source function at every level within the laye + if is < ou = 2 kernels are a mixing of aerosols and molecules kern + if is >2 aerosols kernels only */ if(is - 2 <= 0) { @@ -689,7 +689,7 @@ } - // vertical integration, upward radiation + /* vertical integration, upward radiation */ int k; for(k = 1; k <= mu; k++) { @@ -709,7 +709,7 @@ } } - // vertical integration, downward radiation + /* vertical integration, downward radiation */ for(k = -mu; k <= -1; k++) { i1[0][STDI(k)] = 0; @@ -729,7 +729,7 @@ } } - // in is the nieme scattering order + /* in is the nieme scattering order */ for(k = -mu; k <= mu; k++) { if(k < 0) in[STDI(k)] = i1[snt][STDI(k)]; @@ -737,7 +737,7 @@ } roavion0 = i1[iplane][STDI(mu)]; - // convergence test (geometrical serie) + /* convergence test (geometrical serie) */ if(ig > 2) { float a1 = roavion2; @@ -771,7 +771,7 @@ if(z < 0.0001) { - // successful test (geometrical serie) + /* successful test (geometrical serie) */ float y1; for(int l = -mu; l <= mu; l++) @@ -801,23 +801,23 @@ roavion += g1; } - break; // break out of the while loop + break; /* break out of the while loop */ } - // inm2 is the (n-2)ieme scattering order + /* inm2 is the (n-2)ieme scattering order */ for(int k = -mu; k <= mu; k++) inm2[STDI(k)] = inm1[STDI(k)]; roavion2 = roavion1; } - // inm1 is the (n-1)ieme scattering order + /* inm1 is the (n-1)ieme scattering order */ for(k = -mu; k <= mu; k++) inm1[STDI(k)] = in[STDI(k)]; roavion1 = roavion0; - // sum of the n-1 orders + /* sum of the n-1 orders */ for(k = -mu; k <= mu; k++) i3[STDI(k)] += in[STDI(k)]; roavion += roavion0; - // stop if order n is less than 1% of the sum + /* stop if order n is less than 1% of the sum */ double z = 0; for(k = -mu; k <= mu; k++) { @@ -829,14 +829,14 @@ } if(z < 0.00001) break; - } while( ig <= 20 ); // stop if order n is greater than 20 in any case + } while( ig <= 20 ); /* stop if order n is greater than 20 in any case */ - // sum of the fourier component s + /* sum of the fourier component s */ float delta0s = 1; if(is != 0) delta0s = 2; for(k = -mu; k <= mu; k++) i4[STDI(k)] += delta0s * i3[STDI(k)]; - // stop of the fourier decomposition + /* stop of the fourier decomposition */ int l; for(l = 0; l < np; l++) { @@ -877,26 +877,26 @@ const float tamoyp, const float trmoyp, float (&xf)[3], Gauss &gauss, const Altitude &alt) { - // molecular ratio within the layer - // computations are performed assuming a scale of 8km for - // molecules and 2km for aerosols + /* molecular ratio within the layer + computations are performed assuming a scale of 8km for + molecules and 2km for aerosols */ - // the optical thickness above plane are recomputed to give o.t above pla + /* the optical thickness above plane are recomputed to give o.t above pla */ float trp = trmoy - trmoyp; float tap = tamoy - tamoyp; - // if plane observations recompute scale height for aerosol knowing: - // the aerosol optical depth as measure from the plane = tamoyp - // the rayleigh scale height = = hr (8km) - // the rayleigh optical depth at plane level = trmoyp - // the altitude of the plane = palt - // the rayleigh optical depth for total atmos = trmoy - // the aerosol optical depth for total atmos = tamoy - // if not plane observations then ha is equal to 2.0km - // sntp local variable: if sntp=snt no plane observation selected - // sntp=snt-1 plane observation selected + /* if plane observations recompute scale height for aerosol knowing: + the aerosol optical depth as measure from the plane = tamoyp + the rayleigh scale height = = hr (8km) + the rayleigh optical depth at plane level = trmoyp + the altitude of the plane = palt + the rayleigh optical depth for total atmos = trmoy + the aerosol optical depth for total atmos = tamoy + if not plane observations then ha is equal to 2.0km + sntp local variable: if sntp=snt no plane observation selected + sntp=snt-1 plane observation selected */ - // it's a mixing rayleigh+aerosol + /* it's a mixing rayleigh+aerosol */ int snt = nt; int iplane = 0; int ntp = snt; @@ -908,10 +908,10 @@ ntp = snt - 1; } - // compute mixing rayleigh, aerosol - // case 1: pure rayleigh - // case 2: pure aerosol - // case 3: mixing rayleigh-aerosol + /* compute mixing rayleigh, aerosol + case 1: pure rayleigh + case 2: pure aerosol + case 3: mixing rayleigh-aerosol */ float h[31]; float ydel[31]; @@ -970,15 +970,15 @@ } } - // update plane layer if necessary + /* update plane layer if necessary */ if (ntp == (snt-1)) { - // compute position of the plane layer + /* compute position of the plane layer */ float taup = tap + trp; iplane = -1; for(int i = 0; i <= ntp; i++) if (taup >= h[i]) iplane = i; - // update the layer from the end to the position to update if necessary + /* update the layer from the end to the position to update if necessary */ float xt1 = (float)fabs(h[iplane] - taup); float xt2 = (float)fabs(h[iplane + 1] - taup); if ((xt1 > 0.005) && (xt2 > 0.005)) @@ -1031,11 +1031,11 @@ float aaaa = delta / (2-delta); float ron = (1 - aaaa) / (1 + 2 * aaaa); - // rayleigh phase function + /* rayleigh phase function */ float beta0 = 1; float beta2 = 0.5f * ron; - // primary scattering + /* primary scattering */ int ig = 1; float tavion0 = 0; float tavion1 = 0; @@ -1051,7 +1051,7 @@ int j; for(j = -mu; j <= mu; j++) i3[STDI(j)] = 0; - // kernel computations + /* kernel computations */ float xpl[2*mu + 1]; float bp[26][2*mu + 1]; kernel(0, xpl, bp, gauss); @@ -1059,7 +1059,7 @@ for(j = -mu; j <= mu; j++) for(int k = 0; k <= snt; k++) i2[k][STDI(j)] = 0; - // vertical integration, primary upward radiation + /* vertical integration, primary upward radiation */ int k; for(k = 1; k <= mu; k++) { @@ -1069,12 +1069,12 @@ } - // vertical integration, primary downward radiation + /* vertical integration, primary downward radiation */ for(k = -mu; k <= -1; k++) for(int i = 0; i <= snt; i++) i1[i][STDI(k)] = 0.0; - // inm2 is inialized with scattering computed at n-2 - // i3 is inialized with primary scattering + /* inm2 is inialized with scattering computed at n-2 + i3 is inialized with primary scattering */ for(k = -mu; k <= mu; k++) { if(k == 0) continue; @@ -1095,11 +1095,11 @@ tavion2 = i1[iplane][STDI(mu)]; do { - // loop on successive order + /* loop on successive order */ ig = ig++; - // successive orders - // multiple scattering source function at every level within the laye + /* successive orders + multiple scattering source function at every level within the laye */ for(k = 1; k <= mu; k++) { for(int i = 0; i <= snt; i++) @@ -1122,7 +1122,7 @@ } } - // vertical integration, upward radiation + /* vertical integration, upward radiation */ for(k = 1; k <= mu; k++) { i1[snt][STDI(k)] = 0.0; @@ -1141,7 +1141,7 @@ } } - // vertical integration, downward radiation + /* vertical integration, downward radiation */ for(k = -mu; k <= -1; k++) { i1[0][STDI(k)] = 0; @@ -1159,7 +1159,7 @@ } } - // in is the nieme scattering order + /* in is the nieme scattering order */ for(k = -mu; k <= mu; k++) { if(k == 0) continue; @@ -1168,7 +1168,7 @@ } tavion0 = i1[iplane][STDI(mu)]; - // convergence test (geometrical serie) + /* convergence test (geometrical serie) */ if(ig > 2) { float z = 0; @@ -1199,7 +1199,7 @@ if(z < 0.0001) { - // successful test (geometrical serie) + /* successful test (geometrical serie) */ for(int l = -mu; l <= mu; l++) { @@ -1226,23 +1226,23 @@ } - break; // go to 505 + break; /* go to 505 */ } - // inm2 is the (n-2)ieme scattering order + /* inm2 is the (n-2)ieme scattering order */ for(k = -mu; k <= mu; k++) inm2[STDI(k)] = inm1[STDI(k)]; tavion2 = tavion1; } - // inm1 is the (n-1)ieme scattering order + /* inm1 is the (n-1)ieme scattering order */ for(k = -mu; k <= mu; k++) inm1[STDI(k)] = in[STDI(k)]; tavion1 = tavion0; - // sum of the n-1 orders + /* sum of the n-1 orders */ for(k = -mu; k <= mu; k++) i3[STDI(k)] += in[STDI(k)]; tavion = tavion + tavion0; - // stop if order n is less than 1% of the sum + /* stop if order n is less than 1% of the sum */ float z = 0; for(k = -mu; k <= mu; k++) { @@ -1254,10 +1254,10 @@ } if(z < 0.00001) break; - // stop if order n is greater than 20 in any case + /* stop if order n is greater than 20 in any case */ } while(ig <= 20); - // dimension for os computation + /* dimension for os computation */ xf[0] = tavion; xf[1] = 0; xf[2] = 0; @@ -1273,16 +1273,15 @@ */ float chand(const float xtau, const GeomCond &geom) { - // input parameters: xphi,xmus,xmuv,xtau - // xphi: azimuthal difference between sun and observation (xphi=0, - // in backscattering) and expressed in degree (0.:360.) - // xmus: cosine of the sun zenith angle - // xmuv: cosine of the observation zenith angle - // xtau: molecular optical depth - // output parameter: xrray : molecular reflectance (0.:1.) + /* input parameters: xphi,xmus,xmuv,xtau + xphi: azimuthal difference between sun and observation (xphi=0, + in backscattering) and expressed in degree (0.:360.) + xmus: cosine of the sun zenith angle + xmuv: cosine of the observation zenith angle + xtau: molecular optical depth + output parameter: xrray : molecular reflectance (0.:1.) + constant : xdep: depolarization factor (0.0279) */ - // constant : xdep: depolarization factor (0.0279) - const float xdep = 0.0279; static const float as0[10] = { @@ -1366,11 +1365,11 @@ float xlm1[2 * mu + 1][np]; float xlm2[2 * mu + 1][np]; - // atmospheric reflectances + /* atmospheric reflectances */ oap.rorayl = 0; oap.roaero = 0; - // rayleigh reflectance 3 cases (satellite,plane,ground) + /* rayleigh reflectance 3 cases (satellite,plane,ground) */ if(alt.palt < 900 && alt.palt > 0) { gauss.rm[STDI(-mu)] = -(float)geom.xmuv; @@ -1390,9 +1389,9 @@ return; } - // rayleigh+aerosol=romix,aerosol=roaero reflectance computed - // using sucessive order of scattering method - // 3 cases: satellite,plane,ground + /* rayleigh+aerosol=romix,aerosol=roaero reflectance computed + using sucessive order of scattering method + 3 cases: satellite,plane,ground */ if (alt.palt > 0) { gauss.rm[STDI(-mu)] = -(float)geom.xmuv; @@ -1415,7 +1414,7 @@ float fintexp1(const float xtau) { - // accuracy 2e-07... for 0 900) @@ -1596,12 +1595,12 @@ memset(&oap, 0, sizeof(oap)); Gauss gauss; - gauss.init(); // discom is the only function that uses the gauss data - memset(&sixs_trunc, 0, sizeof(sixs_trunc)); // clear this to keep preconditions the same and output consistent + gauss.init(); /* discom is the only function that uses the gauss data */ + memset(&sixs_trunc, 0, sizeof(sixs_trunc)); /* clear this to keep preconditions the same and output consistent */ -// computation of all scattering parameters at wavelength -// discrete values,so we -// can interpolate at any wavelength +/* computation of all scattering parameters at wavelength + discrete values,so we + can interpolate at any wavelength */ int i; for(i = 0; i < 10; i++) { @@ -1610,11 +1609,11 @@ ((i > 0) && (sixs_disc.wldis[i] > iwave.ffu.wlsup) && (sixs_disc.wldis[i-1] > iwave.ffu.wlsup))) continue; float wl = sixs_disc.wldis[i]; - // computation of rayleigh optical depth at wl + /* computation of rayleigh optical depth at wl */ float tray = odrayl(atms, wl); float trayp; - // plane case discussed here above + /* plane case discussed here above */ if (alt.idatmp == 0) trayp = 0; else if (alt.idatmp == 4) trayp = tray; else trayp = tray * alt.ftray; @@ -1622,17 +1621,17 @@ sixs_disc.trayl[i] = tray; sixs_disc.traypl[i] = trayp; - // computation of aerosol optical properties at wl + /* computation of aerosol optical properties at wl */ float taer = aerocon.taer55 * sixs_aer.ext[i] / sixs_aer.ext[3]; float taerp = alt.taer55p * sixs_aer.ext[i] / sixs_aer.ext[3]; float piza = sixs_aer.ome[i]; - // computation of atmospheric reflectances + /* computation of atmospheric reflectances - // rorayl is rayleigh ref - // roaero is aerosol ref - // call plegen to decompose aerosol phase function in Betal + rorayl is rayleigh ref + roaero is aerosol ref + call plegen to decompose aerosol phase function in Betal */ float coeff = 0; if(aero.iaer != 0) @@ -1647,8 +1646,8 @@ atmref(tamoy, tray, pizmoy, tamoyp, trayp, oap, gauss, geom, aero, alt); - // computation of scattering transmitances (direct and diffuse) - // first time for rayleigh ,next total (rayleigh+aerosols) + /* computation of scattering transmitances (direct and diffuse) + first time for rayleigh ,next total (rayleigh+aerosols) */ scatra(tamoy, tamoyp, tray, trayp, pizmoy, oap, gauss, geom, alt); @@ -1762,12 +1761,12 @@ }; -// calculation of the environmental function for -// rayleigh and aerosols contribution. -// -// this calculation have been done for nadir observation -// and are corrected of the effect of the view zenith angle. +/* calculation of the environmental function for + rayleigh and aerosols contribution. + this calculation have been done for nadir observation + and are corrected of the effect of the view zenith angle. */ + const float a0 = 1.3347; const float b0 = 0.57757; const float a1 = -1.479; @@ -1808,7 +1807,7 @@ fae0 = (float)(1. - xcfa1 * exp(-r * xcfa2) - (1. - xcfa1) * exp(-r * xcfa3)); } - // correction of the effect of the view zenith angle + /* correction of the effect of the view zenith angle */ xlnv = (float)log(xmuv); fra = (float)(fra0 * (xlnv * (1 - fra0) + 1)); fae = (float)(fae0 * ((1 + a0 * xlnv + b0 * xlnv * xlnv) + fae0 * (a1 * xlnv + b1 * xlnv * xlnv) + From chemin at grass.itc.it Fri Jun 8 12:08:31 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 12:08:32 2007 Subject: [grass-addons] r801 - trunk/grassaddons/gipe/i.atcorr Message-ID: <200706081008.l58A8V92005658@grass.itc.it> Author: chemin Date: 2007-06-08 12:08:23 +0200 (Fri, 08 Jun 2007) New Revision: 801 Modified: trunk/grassaddons/gipe/i.atcorr/Date.h trunk/grassaddons/gipe/i.atcorr/Gauss.h trunk/grassaddons/gipe/i.atcorr/GeomCond.cpp trunk/grassaddons/gipe/i.atcorr/GeomCond.h trunk/grassaddons/gipe/i.atcorr/gauss.cpp Log: Update C compatible comment format in i.atcorr (more 3) Modified: trunk/grassaddons/gipe/i.atcorr/Date.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Date.h 2007-06-08 09:57:07 UTC (rev 800) +++ trunk/grassaddons/gipe/i.atcorr/Date.h 2007-06-08 10:08:23 UTC (rev 801) @@ -52,4 +52,4 @@ } }; -#endif // MY_DATE_H +#endif /* MY_DATE_H */ Modified: trunk/grassaddons/gipe/i.atcorr/Gauss.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Gauss.h 2007-06-08 09:57:07 UTC (rev 800) +++ trunk/grassaddons/gipe/i.atcorr/Gauss.h 2007-06-08 10:08:23 UTC (rev 801) @@ -4,7 +4,7 @@ const long int mu = 25; const long int np = 49; -// index standard interval [-1,1] +/* index standard interval [-1,1] */ #define STDI(X) ((X)+mu) struct Gauss @@ -14,15 +14,15 @@ static float angphi[13]; public: - // [a,b] = [0,2*Pi] - float rp[np]; // gaussian angles - float gp[np]; // gaussian weights + /* [a,b] = [0,2*Pi] */ + float rp[np]; /* gaussian angles */ + float gp[np]; /* gaussian weights */ // [a,b] = [-1,1] - float rm[2*mu+1]; // shifted gaussian angles - float gb[2*mu+1]; // shifted gaussian weights - // with the ends zeroed as well as the center - // [0 ? ? ? ? 0 ? ? ? ? 0] + float rm[2*mu+1]; /* shifted gaussian angles */ + float gb[2*mu+1]; /* shifted gaussian weights */ + /* with the ends zeroed as well as the center */ + /* [0 ? ? ? ? 0 ? ? ? ? 0] */ /* preliminary computations for gauss integration */ void init(); @@ -33,4 +33,4 @@ static void gauss (float a, float b, float *x, float *w, long int n); }; -#endif // MY_GAUSS_H +#endif /* MY_GAUSS_H */ Modified: trunk/grassaddons/gipe/i.atcorr/GeomCond.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/GeomCond.cpp 2007-06-08 09:57:07 UTC (rev 800) +++ trunk/grassaddons/gipe/i.atcorr/GeomCond.cpp 2007-06-08 10:08:23 UTC (rev 801) @@ -98,7 +98,7 @@ if (ia != 0 && ia % 4 == 0) ++j; } -// returns the sign of the element +/* returns the sign of the element */ #define SIGN(X) (((X) >= 0) ? 1. : -1.) void GeomCond::pos_fft (long int j, float tu) @@ -166,19 +166,19 @@ { double yr, xr, alti; - if(igeom == 1) // meteosat observation + if(igeom == 1) /* meteosat observation */ { yr = nl - 1250.5; xr = nc - 2500.5; alti = 42164.0 - 6378.155; } - else if(igeom == 2) // goes east observation + else if(igeom == 2) /* goes east observation */ { yr = nl - 8665.5; xr = nc - 6498.5; alti = 42107.0 - 6378.155; } - else // goes west observation + else /* goes west observation */ { yr = nl - 8665.5; xr = nc - 6498.5; @@ -253,11 +253,11 @@ void GeomCond::posnoa(float tu, int nc, float xlonan, float campm, float hna) { -// noaa 6 definition -// orbite inclination ai in radians -// hor mouv in rad/s an -// h/r=860/6378 -// campm allows the user to switch to pm platforms +/* noaa 6 definition + orbite inclination ai in radians + hor mouv in rad/s an + h/r=860/6378 + campm allows the user to switch to pm platforms */ const double r = 860. / 6378.155; const double ai = 98.96 * M_PI / 180.; @@ -308,15 +308,15 @@ void GeomCond::parse() { cin >> igeom; - cin.ignore(numeric_limits::max(),'\n'); // read the rest of the scraps, like comments + cin.ignore(numeric_limits::max(),'\n'); /* read the rest of the scraps, like comments */ - float campm = -1.0f; // initialize in case igeom == 5 + float campm = -1.0f; /* initialize in case igeom == 5 */ float tu, xlonan, hna; int nc, nl; switch(igeom) { - case 0: // internal format + case 0: /* internal format */ { cin >> asol; cin >> phi0; @@ -324,12 +324,12 @@ cin >> phiv; cin >> month; cin >> jday; - cin.ignore(numeric_limits::max(),'\n'); // read the rest of the scraps, like comments + cin.ignore(numeric_limits::max(),'\n'); /* read the rest of the scraps, like comments */ break; } - case 1: // meteosat observation - case 2: // goes east observation - case 3: // goes west observation + case 1: /* meteosat observation */ + case 2: /* goes east observation */ + case 3: /* goes west observation */ { cin >> month; cin >> jday; @@ -353,16 +353,16 @@ posnoa(tu, nc, xlonan, campm, hna); break; } - case 6: // hrv ( spot ) * enter month,day,hh.ddd,long.,lat. - case 7: // tm ( landsat ) * enter month,day,hh.ddd,long.,lat. - case 8: // etm+ ( landsat7) * enter month,day,hh.ddd,long.,lat. + case 6: /* hrv ( spot ) * enter month,day,hh.ddd,long.,lat. */ + case 7: /* tm ( landsat ) * enter month,day,hh.ddd,long.,lat. */ + case 8: /* etm+ ( landsat7) * enter month,day,hh.ddd,long.,lat. */ { cin >> month; cin >> jday; cin >> tu; cin >> xlon; cin >> xlat; - cin.ignore(numeric_limits::max(),'\n'); // read the rest of the scraps, like comments + cin.ignore(numeric_limits::max(),'\n'); /* read the rest of the scraps, like comments */ landsat(tu); break; } @@ -398,7 +398,7 @@ dsol = varsol(); } -// ---- print geometrical conditions ---- +/* ---- print geometrical conditions ---- */ void GeomCond::print() { static const string etiq1[9] = { Modified: trunk/grassaddons/gipe/i.atcorr/GeomCond.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/GeomCond.h 2007-06-08 09:57:07 UTC (rev 800) +++ trunk/grassaddons/gipe/i.atcorr/GeomCond.h 2007-06-08 10:08:23 UTC (rev 801) @@ -57,9 +57,9 @@ struct GeomCond { - long int igeom; // geometrical conditions + long int igeom; /* geometrical conditions */ - // primary + /* primary */ float asol; float phi0; float avis; @@ -69,7 +69,7 @@ float xlon; float xlat; - // some vars + /* some vars */ float phi; float phirad; float xmus; @@ -83,7 +83,7 @@ void print(); private: - // conversion routines + /* conversion routines */ void possol(float tu); void landsat(float tu); void posobs(float tu, int nc, int nl); @@ -92,10 +92,10 @@ void day_number(long int ia, long int& j); void pos_fft (long int j, float tu); - float varsol(); // returns dsol as in fortran proggie + float varsol(); /* returns dsol as in fortran proggie */ void parse(); public: static GeomCond Parse(); }; -#endif // GEOMETRICAL_CONTITIONS_H +#endif /* GEOMETRICAL_CONTITIONS_H */ Modified: trunk/grassaddons/gipe/i.atcorr/gauss.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/gauss.cpp 2007-06-08 09:57:07 UTC (rev 800) +++ trunk/grassaddons/gipe/i.atcorr/gauss.cpp 2007-06-08 10:08:23 UTC (rev 801) @@ -12,11 +12,11 @@ { int j; - // convert angphi and angmu to radians + /* convert angphi and angmu to radians */ for (j = 0; j < 13; ++j) angphi[j] = (float)(angphi[j] * M_PI / 180.f); for (j = 0; j < 10; ++j) angmu[j] = (float)cos(angmu[j] * M_PI / 180.f); - // calculate rm & gb + /* calculate rm & gb */ float anglem[mu2]; float weightm[mu2]; @@ -28,7 +28,7 @@ rm[STDI(-mu)] = 0; rm[STDI(0)] = 0; rm[STDI(mu)] = 0; - // do shift into rm & gb + /* do shift into rm & gb */ for (j = -mu+1; j <= -1; ++j) { rm[-j] = anglem[mu + j - 1]; @@ -41,7 +41,7 @@ gb[2*mu - j] = weightm[mu + j - 2]; } - // calculate rp & gp + /* calculate rp & gp */ gauss (0.f, (float)2 * M_PI, rp, gp, np); } From chemin at grass.itc.it Fri Jun 8 12:23:29 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 12:23:31 2007 Subject: [grass-addons] r802 - trunk/grassaddons/gipe/i.atcorr Message-ID: <200706081023.l58ANTZG005692@grass.itc.it> Author: chemin Date: 2007-06-08 12:23:20 +0200 (Fri, 08 Jun 2007) New Revision: 802 Modified: trunk/grassaddons/gipe/i.atcorr/Interp.cpp trunk/grassaddons/gipe/i.atcorr/Interp.h trunk/grassaddons/gipe/i.atcorr/Iwave.cpp trunk/grassaddons/gipe/i.atcorr/Iwave.h Log: Update C compatible comment format in i.atcorr (more 4) Modified: trunk/grassaddons/gipe/i.atcorr/Interp.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Interp.cpp 2007-06-08 10:08:23 UTC (rev 801) +++ trunk/grassaddons/gipe/i.atcorr/Interp.cpp 2007-06-08 10:23:20 UTC (rev 802) @@ -6,31 +6,31 @@ const float taer55p, const float xmud, InterpStruct& is) { -// that for the atmosphere : -// the reflectances -// rayleigh = rorayl -// aerosols = roaero -// mixing = romix -// the downward transmittances -// rayleigh = dtotr -// aerosols = dtota -// total = dtott -// the upward transmittances -// rayleigh = utotr -// aerosols = utota -// total = utott -// the spherical albedos -// rayleigh = asray -// aerosols = asaer -// total = astot -// the optical thickness of total atmosphere -// rayleigh = tray -// aerosols = taer -// the optical thickness of the atmosphere above the plane -// rayleigh = is.trayp -// aerosols = taerp -// the tsca of the aerosols (god dammed it) -// total atmosphere = tsca +/* that for the atmosphere : + the reflectances + rayleigh = rorayl + aerosols = roaero + mixing = romix + the downward transmittances + rayleigh = dtotr + aerosols = dtota + total = dtott + the upward transmittances + rayleigh = utotr + aerosols = utota + total = utott + the spherical albedos + rayleigh = asray + aerosols = asaer + total = astot + the optical thickness of total atmosphere + rayleigh = tray + aerosols = taer + the optical thickness of the atmosphere above the plane + rayleigh = is.trayp + aerosols = taerp + the tsca of the aerosols (god dammed it) + total atmosphere = tsca */ int linf = 0; for(int i = 0; i < 9; i++) if(wl > sixs_disc.wldis[i] && wl <= sixs_disc.wldis[i+1]) linf = i; @@ -39,8 +39,8 @@ int lsup = linf + 1; - // interpolation in function of wavelength for scattering - // atmospheric functions from discrete values at sixs_disc.wldis + /* interpolation in function of wavelength for scattering + atmospheric functions from discrete values at sixs_disc.wldis */ float alphaa = 0; float betaa = 0; Modified: trunk/grassaddons/gipe/i.atcorr/Interp.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Interp.h 2007-06-08 10:08:23 UTC (rev 801) +++ trunk/grassaddons/gipe/i.atcorr/Interp.h 2007-06-08 10:23:20 UTC (rev 802) @@ -33,4 +33,4 @@ const float taer55p, const float xmud, InterpStruct& is); -#endif // INTERP_H +#endif /* INTERP_H */ Modified: trunk/grassaddons/gipe/i.atcorr/Iwave.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Iwave.cpp 2007-06-08 10:08:23 UTC (rev 801) +++ trunk/grassaddons/gipe/i.atcorr/Iwave.cpp 2007-06-08 10:23:20 UTC (rev 802) @@ -2,11 +2,11 @@ #include "Iwave.h" #ifdef WIN32 -#pragma warning(disable:4305) // disable warning about initialization of a float by a double +#pragma warning(disable:4305) /* disable warning about initialization of a float by a double */ #endif -// -// spectral band of meteosat -// +/* + spectral band of meteosat +*/ void IWave::meteo() { static const float sr[305] = { @@ -68,7 +68,7 @@ void IWave::goes_east() { - // spectral band of goes east + /* spectral band of goes east */ static const float sr[165] = { .00, .00, .00, .01, .01, .03, .05, .09, .13, .22, .30, .38, .46, .52, @@ -105,7 +105,7 @@ void IWave::goes_west() { - // spectral band of goes west + /* spectral band of goes west */ static const float sr[165] = { .00, .00, .00, .00, .00, .01, .02, @@ -143,7 +143,7 @@ void IWave::avhrr(int iwa) { - // 1st spectral band of avhrr (noaa 6) + /* 1st spectral band of avhrr (noaa 6) */ static const float sr1[80] = { .0000, .0178, .0355, .0533, .0710, .1655, .2600, .3545, .4490, .5215, .5940, .6665, .7390, .7575, .7760, .7945, @@ -157,7 +157,7 @@ .0130, .0115, .0100, .0085, .0070, .0052, .0035, .0017 }; - // 2nd spectral band of avhrr (noaa 6) + /* 2nd spectral band of avhrr (noaa 6) */ static const float sr2[173] = { .0000, .0020, .0040, .0060, .0080, .0710, .1340, .1970, @@ -185,7 +185,7 @@ }; - // 1st spectral band of avhrr (noaa 7) + /* 1st spectral band of avhrr (noaa 7) */ static const float sr3[121] = { .0000, .0008, .0016, .0024, .0032, .0032, .0031, .0030, .0030, .0029, .0029, .0028, .0028, .0027, .0027, .0026, @@ -205,7 +205,7 @@ .0000 }; - // 2nd spectral band of avhrr (noaa 7) + /* 2nd spectral band of avhrr (noaa 7) */ static const float sr4[213] = { .0000, .0018, .0035, .0053, .0070, .0068, .0065, .0063, .0060, .0058, .0055, .0052, .0050, .0050, .0050, .0050, @@ -236,7 +236,7 @@ .0018, .0013, .0009, .0004, .0000 }; - // 1st spectral band of avhrr (noaa 8) + /* 1st spectral band of avhrr (noaa 8) */ static const float sr5[189] = { .0000, .0012, .0024, .0036, .0048, .0223, .0399, .0574, .0749, .1633, .2517, .3400, .4284, .4937, .5590, .6243, @@ -265,7 +265,7 @@ }; - // 2nd spectral band of avhrr (noaa 8) + /* 2nd spectral band of avhrr (noaa 8) */ static const float sr6[177] = { .0000, .0095, .0190, .0285, .0381, .0476, .0571, .0666, .0761, .1559, .2358, .3156, .3954, .4855, .5756, .6658, @@ -292,7 +292,7 @@ .0000 }; - // 1st spectral band of avhrr (noaa 9) + /* 1st spectral band of avhrr (noaa 9) */ static const float sr7[113] = { .0000, .0001, .0003, .0004, .0006, .0040, .0074, .0108, .0142, .0622, .1101, .1581, .2060, .2810, .3561, .4311, @@ -311,7 +311,7 @@ .0000 }; - // 2nd spectral band of avhrr (noaa 9) + /* 2nd spectral band of avhrr (noaa 9) */ static const float sr8[197] = { .0000, .0011, .0022, .0033, .0044, .0207, .0369, .0532, .0694, .1410, .2127, .2843, .3559, .4388, .5217, .6047, @@ -340,7 +340,7 @@ .0014, .0010, .0007, .0003, .0000 }; - // 1st spectral band of avhrr (noaa 10) + /* 1st spectral band of avhrr (noaa 10) */ static const float sr9[101] = { .0000, .0005, .0010, .0015, .0020, .0023, .0025, .0028, .0030, .0239, .0448, .0657, .0866, .1852, .2838, .3824, @@ -357,7 +357,7 @@ .0010, .0007, .0005, .0002, .0000 }; - // 2nd spectral band of avhrr (noaa 10) + /* 2nd spectral band of avhrr (noaa 10) */ static const float sr10[237] = { .0000, .0006, .0012, .0018, .0024, .0030, .0036, .0042, .0048, .0049, .0049, .0050, .0051, .0051, .0052, .0052, @@ -391,7 +391,7 @@ .0015, .0011, .0008, .0004, .0000 }; - // 1st spectral band of avhrr (noaa 11) + /* 1st spectral band of avhrr (noaa 11) */ static const float sr11[113] = { .0000, .0033, .0065, .0098, .0130, .0500, .0870, .1240, .1610, .2385, .3160, .3935, .4710, .5150, .5590, .6030, @@ -410,7 +410,7 @@ .0000 }; - // 2nd spectral band of avhrr (noaa 11) + /* 2nd spectral band of avhrr (noaa 11) */ static const float sr12[209] = { .0000, .0005, .0010, .0015, .0020, .0025, .0030, .0035, .0040, .0039, .0037, .0036, .0035, .0034, .0032, .0031, @@ -441,7 +441,7 @@ .0000 }; - // 1st spectral band of avhrr (noaa 12) + /* 1st spectral band of avhrr (noaa 12) */ static const float sr13[201] = { .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, @@ -472,7 +472,7 @@ .0000 }; - // 2nd spectral band of avhrr (noaa 12) + /* 2nd spectral band of avhrr (noaa 12) */ static const float sr14[189] = { .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0050, .0111, .0162, .0180, .0153, .0097, .0038, @@ -500,7 +500,7 @@ .0000, .0000, .0000, .0000, .0000 }; - // 1st spectral band of avhrr (noaa 14) -from NOAA/POD Guide + /* 1st spectral band of avhrr (noaa 14) -from NOAA/POD Guide */ static const float sr15[241] = { .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, @@ -535,7 +535,7 @@ .0010 }; - // 2nd spectral band of avhrr (noaa 14) + /* 2nd spectral band of avhrr (noaa 14) */ static const float sr16[176] = { .0000,.0000,.0000,.0000,.0000,.0000,.0022,.0045, .0067,.0090,.0107,.0125,.0143,.0160,.0543,.0925, @@ -609,7 +609,7 @@ void IWave::hrv(int iwa) { - // 1st spectral band of hrv1 + /* 1st spectral band of hrv1 */ static const float sr1[73] = { .0010, .0023, .0035, .0048, .0060, .0492, .0925, .1357, .1790, .2598, .3405, .4213, .5020, .5575, .6130, .6685, @@ -623,7 +623,7 @@ .0000 }; - // 2nd spectral band of hrv1 + /* 2nd spectral band of hrv1 */ static const float sr2[49] = { .0190, .0845, .1500, .2155, .2810, .3870, .4930, .5990, .7050, .7663, .8275, .8888, .9500, .9557, .9615, .9672, @@ -634,7 +634,7 @@ .0030 }; - // 3rd spectral band of hrv1 + /* 3rd spectral band of hrv1 */ static const float sr3[81] = { .0010, .0033, .0055, .0078, .0100, .0238, .0375, .0513, .0650, .0953, .1255, .1558, .1860, .2470, .3080, .3690, @@ -649,7 +649,7 @@ .0010 }; - // panchromatic band of hrv1 + /* panchromatic band of hrv1 */ static const float sr4[129] = { .0000, .0013, .0025, .0038, .0050, .0322, .0595, .0867, .1140, .1723, .2305, .2888, .3470, .3748, .4025, .4303, @@ -670,7 +670,7 @@ .0020 }; - // 1st spectral band of hrv2 + /* 1st spectral band of hrv2 */ static const float sr5[73] = { .0010, .0015, .0020, .0025, .0030, .0040, .0050, .0060, .0070, .0850, .1630, .2410, .3190, .3918, .4645, .5373, @@ -684,7 +684,7 @@ .0000 }; - // 2nd spectral band of hrv2 + /* 2nd spectral band of hrv2 */ static const float sr6[57] = { .0040, .0045, .0050, .0055, .0060, .0115, .0170, .0225, .0280, .0893, .1505, .2118, .2730, .3593, .4455, .5318, @@ -696,7 +696,7 @@ .0100 }; - // 3rd spectral band of hrv2 + /* 3rd spectral band of hrv2 */ static const float sr7[81] = { .0020, .0030, .0040, .0050, .0060, .0105, .0150, .0195, .0240, .0380, .0520, .0660, .0800, .1140, .1480, .1820, @@ -711,7 +711,7 @@ .0010 }; - // panchromatic spectral band of hrv2 + /* panchromatic spectral band of hrv2 */ static const float sr8[129] = { .0010, .0013, .0015, .0018, .0020, .0137, .0255, .0372, .0490, .0898, .1305, .1713, .2120, .2468, .2815, .3163, @@ -765,7 +765,7 @@ void IWave::tm(int iwa) { - // 1st spectral band of thematic mapper + /* 1st spectral band of thematic mapper */ static const float sr1[53] = { .0030, .0085, .0140, .0255, .0370, .0500, .0630, .2010, .3390, .5030, .6670, .6935, .7200, .7525, .7850, .8030, @@ -776,7 +776,7 @@ .0050, .0045, .0040, .0035, .0030 }; - // 2nd spectral band of thematic mapper + /* 2nd spectral band of thematic mapper */ static const float sr2[61] = { .0010, .0055, .0100, .0165, .0230, .0305, .0380, .1010, .1640, .2710, .3780, .4750, .5720, .6150, .6580, .6945, @@ -788,7 +788,7 @@ .0120, .0090, .0060, .0030, .0000 }; - // 3rd spectral band of thematic mapper + /* 3rd spectral band of thematic mapper */ static const float sr3[65] = { .0020, .0020, .0020, .0020, .0020, .0030, .0040, .0060, .0080, .0140, .0200, .0290, .0380, .0730, .1080, .2020, @@ -801,7 +801,7 @@ .0030 }; - // 4th spectral band of thematic mapper + /* 4th spectral band of thematic mapper */ static const float sr4[89] = { .0020, .0035, .0050, .0060, .0070, .0080, .0090, .0140, .0190, .0260, .0330, .0520, .0710, .1035, .1360, .2055, @@ -817,7 +817,7 @@ .0000 }; - // 5th spectral band of thematic mapper + /* 5th spectral band of thematic mapper */ static const float sr5[156] = { .0000, .0003, .0007, .0010, .0013, .0015, .0018, .0020, .0038, .0055, .0073, .0090, .0123, .0155, .0188, .0220, @@ -841,7 +841,7 @@ .0015, .0010, .0005, .0000 }; - // 7th spectral band of thematic mapper + /* 7th spectral band of thematic mapper */ static const float sr6[185] = { .0000, .0005, .0010, .0015, .0020, .0025, .0030, .0035, .0040, .0043, .0045, .0048, .0050, .0055, .0060, .0065, @@ -897,7 +897,7 @@ void IWave::mss(int iwa) { - // 1st spectral band of multi spectral scanner + /* 1st spectral band of multi spectral scanner */ static const float sr1[67] = { .00, .01, .01, .01, .02, .04, .05, .09, .13, .21, .29, .45, .61, .72, @@ -911,7 +911,7 @@ .02, .02, .02, .01 }; - // 2nd spectral band of multi spectral scanner + /* 2nd spectral band of multi spectral scanner */ static const float sr2[69] = { .01, .01, .01, .01, .01, .01, .02, .03, .04, .08, .13, .21, .29, .43, @@ -925,7 +925,7 @@ .05, .05, .04, .04, .03, .03 }; - // 3rd spectral band of multi spectral scanner + /* 3rd spectral band of multi spectral scanner */ static const float sr3[81] = { .01, .01, .01, .02, .02, .02, .02, .03, .03, .05, .07, .10, .14, .17, @@ -941,7 +941,7 @@ .01, .01, .01, .01 }; - // 4th spectral band of multi spectral scanner + /* 4th spectral band of multi spectral scanner */ static const float sr4[127] = { .01, .02, .02, .04, .06, .14, .21, .45, .68, .76, .83, .89, .94, .94, @@ -988,7 +988,7 @@ void IWave::mas(int iwa) { - //first spectral band of Modis airborne simulator + /* first spectral band of Modis airborne simulator */ static const float sr1[35] = { .0244, .0338, .0536, .1052, .1941, .3166, .4797, .6893, .9417,1.2218,1.4890,1.7202,1.9194,2.0812,2.1934,2.2580, @@ -997,7 +997,7 @@ .0473, .0308, .0248 }; - //second spectral band of Modis airborne simulator + /* second spectral band of Modis airborne simulator */ static const float sr2[38] = { .0197, .0223, .0298, .0481, .0877, .1645, .2829, .4699, .7101, .9752,1.2209,1.4459,1.6307,1.7482,1.8092,1.8370, @@ -1006,7 +1006,7 @@ .4250, .2204, .0947, .0447, .0253, .0209 }; - //third spectral band of Modis airborne simulator + /* third spectral band of Modis airborne simulator */ static const float sr3[34] = { .0273, .0357, .0560, .1265, .3269, .6239, .9777,1.3481, 1.7037,2.0081,2.1885,2.2765,2.3178,2.3474,2.3777,2.4053, @@ -1015,7 +1015,7 @@ .0333, .0270 }; - //fourth spectral band of Modis airborne simulator + /* fourth spectral band of Modis airborne simulator */ static const float sr4[40] = { .0242, .0276, .0364, .0505, .0717, .1058, .1841, .3889, .7570,1.1872,1.6245,1.9511,2.0986,2.1652,2.2058,2.2430, @@ -1024,7 +1024,7 @@ .0926, .0830, .0720, .0590, .0476, .0377, .0300, .0245 }; - //fifth spectral band of Modis airborne simulator + /* fifth spectral band of Modis airborne simulator */ static const float sr5[56] = { .0232, .0234, .0254, .0259, .0300, .0313, .0325, .0368, @@ -1037,7 +1037,7 @@ }; - //sixth spectral band of Modis airborne simulator + /* sixth spectral band of Modis airborne simulator */ static const float sr6[40] = { .0229, .0271, .0404, .0690, .1237, .2051, .3206, .4619, .6269, .8073,1.0025,1.2045,1.4075,1.5980,1.7690,1.9111, @@ -1046,7 +1046,7 @@ .5164, .3475, .2148, .1205, .0665, .0376, .0254, .0211 }; - //seventh spectral band of Modis airborne simulator + /* seventh spectral band of Modis airborne simulator */ static const float sr7[117] = { .0075, .0087, .0108, .0133, .0168, .0208, .0257, .0312, .0379, .0456, .0540, .0629, .0728, .0828, .0937, .1054, @@ -1065,13 +1065,13 @@ .0151, .0117, .0093, .0076, .0070 }; - // third band of MODIS (469nm) soil and vegetation differences + /* third band of MODIS (469nm) soil and vegetation differences */ static const float sr8[13] = { .0732, .8372,3.6403,4.9195,5.0091,5.0102,5.0102,5.0099, 4.9670,4.0931,1.2880, .1186, .0237 }; - // fifth band of MODIS ( 1.24micron) leaf and canopy properties + /* fifth band of MODIS ( 1.24micron) leaf and canopy properties */ static const float sr9[25] = { .0094, .0143, .0248, .0457, .0902, .1928, .4494,1.1087, 2.4282,3.6387,4.5556,4.9434,4.9975,4.9434,4.5556,3.6387, @@ -1079,7 +1079,7 @@ .0094 }; - // sixth band of MODIS ( 1.64microns) snow and cloud differences + /* sixth band of MODIS ( 1.64microns) snow and cloud differences */ static const float sr10[27] = { .0215, .0307, .0493, .0827, .1454, .2693, .5240,1.0412, 1.9431,2.6724,3.3494,3.8269,4.0296,4.0624,4.0296,3.8269, @@ -1123,7 +1123,7 @@ void IWave::modis(int iwa) { - //band 1 of MODIS (vegetation monitoring at 250m) + /* band 1 of MODIS (vegetation monitoring at 250m) */ static const float sr1[31] = { .0000, .0000, .0101, .0984, .2914, .5020, .6564, .6881, .7064, .7114, .7292, .7523, .7721, .7852, .8112, .8664, @@ -1131,7 +1131,7 @@ .3996, .2327, .1024, .0369, .0157, .0092, .0000 }; - //band 2 of MODIS (vegetation monitoring at 250m) + /* band 2 of MODIS (vegetation monitoring at 250m) */ static const float sr2[34] = { .0000, .0216, .0502, .0923, .1431, .1938, .2713, .4292, .6543, .8606, .9672, .9609, .9418, .9273, .9311, .9550, @@ -1140,26 +1140,26 @@ .0076, .0000 }; - //band 3 of MODIS (vegetation monitoring at 500m / MVI) + /* band 3 of MODIS (vegetation monitoring at 500m / MVI) */ static const float sr3[14] = { .0000, .0222, .2021, .7451,1.0141, .9036, .8745, .9242, 1.0009, .9305, .5877, .1496, .0170, .0000 }; - //band 4 of MODIS (green channel at 500m ) + /* band 4 of MODIS (green channel at 500m ) */ static const float sr4[13] = { .0286, .2645, .7583, .9889,1.0002, .9750, .9726, .9878, .9622, .7041, .2147, .0163, .0000 }; - //band 5 of MODIS (cloud channel at 500m ) + /* band 5 of MODIS (cloud channel at 500m ) */ static const float sr5[23] = { .0000, .0188, .0381, .0984, .1872, .3188, .4933, .6582, .8046, .8877, .9564, .9973,1.0000, .9451, .8172, .6366, .3949, .2260, .1218, .0623, .0253, .0173, .0000 }; - //band 6 of MODIS (snow/ice channel at 500m ) + /* band 6 of MODIS (snow/ice channel at 500m ) */ static const float sr6[27] = { .0000, .0580, .0910, .1611, .2705, .4289, .6049, .7688, .8948, .9729,1.0000, .9969, .9875, .9648, .9278, .8629, @@ -1167,7 +1167,7 @@ .0162, .0108, .0000 }; - //band 7 of MODIS (liquid water absorption channel at 500m ) + /* band 7 of MODIS (liquid water absorption channel at 500m ) */ static const float sr7[51] = { .0000, .0124, .0165, .0229, .0317, .0444, .0630, .0918, .1358, .2006, .2904, .4032, .5329, .6632, .7775, .8680, @@ -1208,7 +1208,7 @@ void IWave::polder(int iwa) { - //band 1 of POLDER (443 mic, polarized channel) + /* band 1 of POLDER (443 mic, polarized channel) */ static const float sr1[27] = { .0003, .0042, .0028, .0036, .0060, .0134, .0430, .1284, .3394, .6162, .8056, .9060, .9656, .9968, .9880, .8944, @@ -1217,7 +1217,7 @@ .0040, .0000, .0000 }; - // band 2 of POLDER (490 mic) + /* band 2 of POLDER (490 mic) */ static const float sr2[46] = { .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, .0000, @@ -1227,7 +1227,7 @@ .0304, .0170, .0102, .0070, .0000, .0000 }; - // band 3 of POLDER (565 mic) + /* band 3 of POLDER (565 mic) */ static const float sr3[26] = { .0000, .0016, .0048, .0074, .0130, .0258, .0566, .1368, .3294, .6592, .9270, .9946, .9798, .9544, .9262, .8814, @@ -1235,7 +1235,7 @@ .0038, .0000 }; - // band 4 of POLDER (670 P1, polarized channel) + /* band 4 of POLDER (670 P1, polarized channel) */ static const float sr4[30] = { .0000, .0000, .0000, .0000, .0010, .0044, .0022, .0140, .0176, .0394, .1004, .2476, .5462, .8672, .9902, .9874, @@ -1243,13 +1243,13 @@ .0224, .0186, .0160, .0072, .0000, .0000 }; - // band 5 of POLDER (763 mic, oxygen absorption channel) + /* band 5 of POLDER (763 mic, oxygen absorption channel) */ static const float sr5[15] = { .0000, .0004, .0046, .0134, .0834, .4148, .8056, .9274, .9880, .7488, .2416, .0416, .0094, .0008, .0000 }; - // band 6 of POLDER (765 mic, oxygen absorption channel) + /* band 6 of POLDER (765 mic, oxygen absorption channel) */ static const float sr6[53] = { .0000, .0000, .0010, .0018, .0010, .0030, .0046, .0080, .0096, .0140, .0202, .0300, .0410, .0622, .0958, .1516, @@ -1260,7 +1260,7 @@ .0028, .0022, .0000, .0000, .0000 }; - // band 7 of POLDER (865 P1, polarized channel) + /* band 7 of POLDER (865 P1, polarized channel) */ static const float sr7[45] = { .0000, .0004, .0008, .0024, .0030, .0056, .0102, .0186, .0338, .0622, .1110, .1974, .3410, .5432, .7610, .9218, @@ -1270,7 +1270,7 @@ .0014, .0006, .0000, .0000, .0000 }; - // band 8 of POLDER (910 mic, water vapor absorption channel) + /* band 8 of POLDER (910 mic, water vapor absorption channel) */ static const float sr8[31] = { .0000, .0000, .0000, .0012, .0016, .0018, .0032, .0046, .0082, .0158, .0354, .0876, .2242, .5142, .8436, .9848, @@ -1310,10 +1310,10 @@ void IWave::etmplus(int iwa) { - // Spectral filter data found on the following page: - // http://ltpwww.gsfc.nasa.gov/IAS/handbook/handbook_toc.html - - // 1st spectral band of enhanced thematic mapper plus + /* Spectral filter data found on the following page: + http://ltpwww.gsfc.nasa.gov/IAS/handbook/handbook_toc.html + */ + /* 1st spectral band of enhanced thematic mapper plus */ static const float sr1[35] = { .0160, .0710, .2870, .6665, .7920, .8570, .8390, .8060, .7790, .8460, .9010, .8995, .8900, .8510, .8750, .8930, @@ -1322,7 +1322,7 @@ .2930, .0545, .0090 }; - // 2nd spectral band of enhanced thematic mapper plus + /* 2nd spectral band of enhanced thematic mapper plus */ static const float sr2[50] = { .0006, .0015, .0030, .0117, .0260, .0740, .1740, .3480, .5520, .6960, .7590, .7845, .8220, .8695, .9050, .9285, @@ -1333,7 +1333,7 @@ .0048, .0021 }; - // 3rd spectral band of enhanced thematic mapper plus + /* 3rd spectral band of enhanced thematic mapper plus */ static const float sr3[36] = { .0001, .0006, .0020, .0095, .0470, .1740, .4190, .7310, .9210, .9425, .9370, .9365, .9490, .9645, .9730, .9705, @@ -1342,7 +1342,7 @@ .1830, .0660, .0250, .0121 }; - // 4th spectral band of enhanced thematic mapper plus + /* 4th spectral band of enhanced thematic mapper plus */ static const float sr4[70] = { .0004, .0021, .0037, .0024, .0010, .0199, .0315, .0518, .0690, .1100, .1750, .2710, .4020, .5555, .7050, .8120, @@ -1356,7 +1356,7 @@ }; - // 5th spectral band of enhanced thematic mapper plus + /* 5th spectral band of enhanced thematic mapper plus */ static const float sr5[116] = { .0015, .0000, .0010, .0112, .0120, .0060, .0135, .0210, .0400, .0530, .0760, .1028, .1480, .2052, .2740, .3660, @@ -1375,7 +1375,7 @@ .0110, .0100, .0060, .0020 }; - // 7th spectral band of enhanced thematic mapper plus + /* 7th spectral band of enhanced thematic mapper plus */ static const float sr6[147] = { .0020, .0020, .0120, .0085, .0090, .0177, .0170, .0313, .0370, .0458, .0580, .0762, .0880, .1097, .1490, .1960, @@ -1398,7 +1398,7 @@ .0130, .0065, .0150 }; - // 8th spectral band of enhanced thematic mapper plus (Pan) + /* 8th spectral band of enhanced thematic mapper plus (Pan) */ static const float sr7[164] = { .0028, .0175, .0563, .1500, .3285, .5015, .5845, .5990, .6018, .6095, .6143, .6100, .6035, .6035, .6118, .6270, @@ -1452,10 +1452,10 @@ float IWave::solirr(const float wl) const { -// si (in w/m2/micron) contains the values of the solar -// irradiance between 0.25 and 4.0 microns, by step of 0.0025 m. -// the value of the total irradiance is 1372 w/m2 on the whole -// spectrum (1358 w/m2 between 0.25 and 4.0 microns) +/* si (in w/m2/micron) contains the values of the solar + irradiance between 0.25 and 4.0 microns, by step of 0.0025 m. + the value of the total irradiance is 1372 w/m2 on the whole + spectrum (1358 w/m2 between 0.25 and 4.0 microns) */ static const float si[1501] = { 69.30, 77.65, 86.00, 100.06, 114.12, 137.06, 160.00, @@ -1720,7 +1720,7 @@ cin >> ffu.wlsup; cin.ignore(numeric_limits::max(),'\n'); } - else if(iwave < 0) // excludes -2 + else if(iwave < 0) /* excludes -2 */ { cin >> wl; cin.ignore(numeric_limits::max(),'\n'); @@ -1729,13 +1729,13 @@ } else { - // da big switch + /* da big switch */ if(iwave == 1) { cin >> ffu.wlinf; cin >> ffu.wlsup; cin.ignore(numeric_limits::max(),'\n'); - // moved rest further on + /* moved rest further on */ } else if(iwave == 2) meteo(); else if(iwave == 3) goes_east(); @@ -1752,17 +1752,17 @@ else fprintf(stderr, "Unsupported iwave value: %d\n", iwave); } - iinf = (int)((ffu.wlinf - 0.25f) / 0.0025f + 1.5f) - 1; // remember indexing - isup = (int)((ffu.wlsup - 0.25f) / 0.0025f + 1.5f) - 1; // " + iinf = (int)((ffu.wlinf - 0.25f) / 0.0025f + 1.5f) - 1; /* remember indexing*/ + isup = (int)((ffu.wlsup - 0.25f) / 0.0025f + 1.5f) - 1; /* "*/ - if(iwave == 1) // moved here to avoid unnecessery gotos + if(iwave == 1) /* moved here to avoid unnecessery gotos */ { for(int i = iinf; i <= isup; i++) cin >> ffu.s[i]; cin.ignore(numeric_limits::max(),'\n'); } } -// --- spectral condition ---- +/* --- spectral condition ---- */ void IWave::print() { static const string nsat[68] = { Modified: trunk/grassaddons/gipe/i.atcorr/Iwave.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Iwave.h 2007-06-08 10:08:23 UTC (rev 801) +++ trunk/grassaddons/gipe/i.atcorr/Iwave.h 2007-06-08 10:23:20 UTC (rev 802) @@ -140,4 +140,4 @@ static IWave Parse(); }; -#endif // IWAVE_H +#endif /* IWAVE_H */ From chemin at grass.itc.it Fri Jun 8 12:35:01 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 12:35:03 2007 Subject: [grass-addons] r803 - trunk/grassaddons/gipe/i.atcorr Message-ID: <200706081035.l58AZ1fJ005734@grass.itc.it> Author: chemin Date: 2007-06-08 12:34:55 +0200 (Fri, 08 Jun 2007) New Revision: 803 Modified: trunk/grassaddons/gipe/i.atcorr/Output.h trunk/grassaddons/gipe/i.atcorr/main.cpp Log: Update C compatible comment format in i.atcorr (more 5) Modified: trunk/grassaddons/gipe/i.atcorr/Output.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Output.h 2007-06-08 10:23:20 UTC (rev 802) +++ trunk/grassaddons/gipe/i.atcorr/Output.h 2007-06-08 10:34:55 UTC (rev 803) @@ -10,28 +10,28 @@ static unsigned int pos; public: - // begin a line + /* begin a line */ static void Begin() { pos += 2; fprintf(stderr, "* "); } - // print a string + /* print a string */ static void Print(std::string x) { pos += x.length(); fprintf(stderr, "%s", x.c_str()); } - // print c, cnt times + /* print c, cnt times */ static void Repeat(int cnt, char c) { pos += cnt; for(int i = 0; i < cnt; i++) fprintf(stderr, "%c", c); } - // end the line + /* end the line */ static void End() @@ -41,7 +41,7 @@ pos = 0; } - // position the stream upto, but excluding p + /* position the stream upto, but excluding p */ static void Position(unsigned int p) { if(p < pos) return; @@ -49,7 +49,7 @@ pos = p - 1; } - // write a s after cnt spaces + /* write a s after cnt spaces */ static void WriteLn(int cnt, std::string s) { Begin(); @@ -58,7 +58,7 @@ End(); } - // write a blank line + /* write a blank line */ static void Ln() { Begin(); @@ -66,4 +66,4 @@ } }; -#endif // MY_OUTPUT +#endif /* MY_OUTPUT */ Modified: trunk/grassaddons/gipe/i.atcorr/main.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/main.cpp 2007-06-08 10:23:20 UTC (rev 802) +++ trunk/grassaddons/gipe/i.atcorr/main.cpp 2007-06-08 10:34:55 UTC (rev 803) @@ -38,22 +38,22 @@ /* Input options and flags */ struct Options { - // options - struct Option *iimg; // input satelite image - struct Option *iscl; // input data is scaled to this range - struct Option *ialt; // an input elevation map in km used to increase - // atmospheric correction accuracy, including this - // will make computations take much, much longer - struct Option *ivis; // an input visibility map in km (same purpose and effect as ialt) - struct Option *icnd; // the input conditions file - struct Option *oimg; // output image name - struct Option *oscl; // scale the output data (reflectance values) to this range + /* options */ + struct Option *iimg; /* input satelite image */ + struct Option *iscl; /* input data is scaled to this range */ + struct Option *ialt; /* an input elevation map in km used to increase */ + /* atmospheric correction accuracy, including this */ + /* will make computations take much, much longer */ + struct Option *ivis; /* an input visibility map in km (same purpose and effect as ialt) */ + struct Option *icnd; /* the input conditions file */ + struct Option *oimg; /* output image name */ + struct Option *oscl; /* scale the output data (reflectance values) to this range */ - // flags - struct Flag *oflt; // output data as floating point and do not round - struct Flag *irad; // treat input values as reflectance instead of radiance values - struct Flag *etmafter; // treat input data as a satelite image of type etm+ taken after July 1, 2000 - struct Flag *etmbefore; // treat input data as a satelite image of type etm+ taken before July 1, 2000 + /* flags */ + struct Flag *oflt; /* output data as floating point and do not round */ + struct Flag *irad; /* treat input values as reflectance instead of radiance values */ + struct Flag *etmafter; /* treat input data as a satelite image of type etm+ taken after July 1, 2000 */ + struct Flag *etmbefore; /* treat input data as a satelite image of type etm+ taken before July 1, 2000 */ struct Flag *optimize; }; @@ -70,7 +70,7 @@ */ void adjust_region(char *name) { - struct Cell_head iimg_head; // the input image header file + struct Cell_head iimg_head; /* the input image header file */ if(G_get_cellhd(name, G_mapset(), &iimg_head) < 0) G_fatal_error("Unable to retreive header dat for input image"); @@ -102,7 +102,7 @@ { enum TICacheSize { - MAX_TIs = 128 // this value is a guess, increase it if in general more categories are used + MAX_TIs = 128 /* this value is a guess, increase it if in general more categories are used */ }; TransformInput tis[MAX_TIs]; float alts[MAX_TIs]; @@ -129,17 +129,17 @@ } }; -// the transform input map, is a array of ticaches. -// The first key is the visibility which matches to a TICache for the altitudes. -// This code is horrible, i just spent 20min writing and 5min debugging it. +/* the transform input map, is a array of ticaches. + The first key is the visibility which matches to a TICache for the altitudes. + This code is horrible, i just spent 20min writing and 5min debugging it. */ class TIMap { enum TIMapSize { - MAX_TICs = 128 // this value is a guess. It means that 1024 TI's will be the max combinations of vis/alt pairs + MAX_TICs = 128 /* this value is a guess. It means that 1024 TI's will be the max combinations of vis/alt pairs */ }; - TICache tic[MAX_TICs]; // array of TICaches + TICache tic[MAX_TICs]; /* array of TICaches */ float visi[MAX_TICs]; int p; @@ -198,7 +198,7 @@ IntPair key(vis, alt); CacheMap::iterator it = timap.find(key); - if(it != timap.end()) // search found key + if(it != timap.end()) /* search found key */ { ti = (*it).second; } @@ -229,20 +229,20 @@ void process_raster(int ifd, InputMask imask, ScaleRange iscale, int ialt_fd, int ivis_fd, int ofd, bool oflt, ScaleRange oscale, bool optimize) { - FCELL* buf; // buffer for the input values - FCELL* alt = NULL; // buffer for the elevation values - FCELL* vis = NULL; // buffer for the visibility values + FCELL* buf; /* buffer for the input values */ + FCELL* alt = NULL; /* buffer for the elevation values */ + FCELL* vis = NULL; /* buffer for the visibility values */ FCELL prev_alt = -1.f; FCELL prev_vis = -1.f; int row, col; - // do initial computation with global elevation and visibility values + /* do initial computation with global elevation and visibility values */ TransformInput ti; ti = compute(); - TICache ticache; // use this to increase computation speed when an elevation map with categories are given + TICache ticache; /* use this to increase computation speed when an elevation map with categories are given */ - // allocate memory for buffers + /* allocate memory for buffers */ buf = (FCELL*)G_allocate_raster_buf(FCELL_TYPE); if(ialt_fd >= 0) alt = (FCELL*)G_allocate_raster_buf(FCELL_TYPE); if(ivis_fd >= 0) vis = (FCELL*)G_allocate_raster_buf(FCELL_TYPE); @@ -250,45 +250,45 @@ for(row = 0; row < G_window_rows(); row++) { - G_percent(row, G_window_rows(), 1); // keep the user informed of our progress + G_percent(row, G_window_rows(), 1); /* keep the user informed of our progress */ - // read the next row + /* read the next row */ if(G_get_raster_row(ifd, buf, row, FCELL_TYPE) < 0) G_fatal_error("Unable to read from input file"); - // read the next row of elevation values + /* read the next row of elevation values */ if(ialt_fd >= 0) if(G_get_raster_row(ialt_fd, alt, row, FCELL_TYPE) < 0) G_fatal_error("Unable to read from elevation raster"); - // read the next row of elevation values + /* read the next row of elevation values */ if(ivis_fd >= 0) if(G_get_raster_row(ivis_fd, vis, row, FCELL_TYPE) < 0) G_fatal_error("Unable to read from visibility raster"); - // loop over all the values in the row + /* loop over all the values in the row */ for(col = 0; col < G_window_cols(); col++) { if(isnan(vis[col]) || isnan(alt[col]) || isnan(buf[col])) {buf[col] = FP_NAN; continue;} - alt[col] /= 1000.0f; // converting to km from input which should be in meter + alt[col] /= 1000.0f; /* converting to km from input which should be in meter */ - // check if both maps are active and if whether any value has changed + /* check if both maps are active and if whether any value has changed */ if((ialt_fd >= 0) && (ivis_fd >= 0) && ((prev_vis != vis[col]) || (prev_alt != alt[col]))) { - prev_alt = alt[col]; // update new values + prev_alt = alt[col]; /* update new values */ prev_vis = vis[col]; - if(optimize) ti = optimize_va(vis[col], alt[col]); // try to optimize? - else { // no optimizations + if(optimize) ti = optimize_va(vis[col], alt[col]); /* try to optimize? */ + else { /* no optimizations */ pre_compute_hv(alt[col], vis[col]); ti = compute(); } } - else // only one of the maps is being used + else /* only one of the maps is being used */ { if((ivis_fd >= 0) && (prev_vis != vis[col])) { - prev_vis = vis[col]; // keep track of previous visibility + prev_vis = vis[col]; /* keep track of previous visibility */ if(optimize) { @@ -296,22 +296,22 @@ if(p >= 0) ti = ticache.get(p); else { - pre_compute_v(vis[col]); // re-compute transformation inputs - ti = compute(); // ... + pre_compute_v(vis[col]); /* re-compute transformation inputs */ + ti = compute(); /* ... */ ticache.add(ti, vis[col]); } } else { - pre_compute_v(vis[col]); // re-compute transformation inputs - ti = compute(); // ... + pre_compute_v(vis[col]); /* re-compute transformation inputs */ + ti = compute(); /* ... */ } } if((ialt_fd >= 0) && (prev_alt != alt[col])) { - prev_alt = alt[col]; // keep track of previous altitude + prev_alt = alt[col]; /* keep track of previous altitude */ if(optimize) { @@ -319,35 +319,35 @@ if(p >= 0) ti = ticache.get(p); else { - pre_compute_h(alt[col]); // re-compute transformation inputs - ti = compute(); // ... + pre_compute_h(alt[col]); /* re-compute transformation inputs */ + ti = compute(); /* ... */ ticache.add(ti, alt[col]); } } else { - pre_compute_h(alt[col]); // re-compute transformation inputs - ti = compute(); // ... + pre_compute_h(alt[col]); /* re-compute transformation inputs */ + ti = compute(); /* ... */ } } } - // transform from iscale.[min,max] to [0,1] + /* transform from iscale.[min,max] to [0,1] */ buf[col] = (buf[col] - iscale.min) / ((float)iscale.max - (float)iscale.min); buf[col] = transform(ti, imask, buf[col]); - // transform from [0,1] to oscale.[min,max] + /* transform from [0,1] to oscale.[min,max] */ buf[col] = buf[col] * ((float)oscale.max - (float)oscale.min) + oscale.min; if(~oflt && (buf[col] > (float)oscale.max)) fprintf(stderr,"The output data will overflow. Reflectance > 100%\n"); } - // write output + /* write output */ if(oflt) G_put_raster_row(ofd, buf, FCELL_TYPE); else write_fp_to_cell(ofd, buf); } - // free allocated memory + /* free allocated memory */ G_free(buf); if(ialt_fd >= 0) G_free(alt); if(ivis_fd >= 0) G_free(vis); @@ -406,7 +406,7 @@ opts.iscl->type = TYPE_INTEGER; opts.iscl->key_desc = "input scale range"; opts.iscl->required = NO; -// opts.iscl->answer = "0,255"; +/* opts.iscl->answer = "0,255"; */ opts.iscl->description = "Input raster's range [0,255]"; opts.ialt = G_define_option(); @@ -446,7 +446,7 @@ opts.oscl->type = TYPE_INTEGER; opts.oscl->key_desc = "Output scale range"; opts.oscl->required = NO; -// opts.oscl->answer = "0,255"; +/* opts.oscl->answer = "0,255"; */ opts.oscl->description = "Rescale output raster map [0,255]"; opts.oflt = G_define_flag(); @@ -475,7 +475,7 @@ /* Read the min and max values from the iscl and oscl options */ void read_scale(Option *scl, ScaleRange &range) { - //set default values + /* set default values */ range.min = 0; range.max = 255; @@ -492,7 +492,7 @@ } } - // swap values if max is smaller than min + /* swap values if max is smaller than min */ if(range.max < range.min) { int temp; @@ -505,12 +505,12 @@ int main(int argc, char* argv[]) { struct Options opts; - struct ScaleRange iscale; // input file's data is scaled to this interval - struct ScaleRange oscale; // output file's scale - int iimg_fd; // input image's file descriptor - int oimg_fd; // output image's file descriptor - int ialt_fd; // input elevation map's file descriptor - int ivis_fd; // input visibility map's file descriptor + struct ScaleRange iscale; /* input file's data is scaled to this interval */ + struct ScaleRange oscale; /* output file's scale */ + int iimg_fd; /* input image's file descriptor */ + int oimg_fd; /* output image's file descriptor */ + int ialt_fd; /* input elevation map's file descriptor */ + int ivis_fd; /* input visibility map's file descriptor */ /* Define module */ @@ -525,21 +525,21 @@ adjust_region(opts.iimg->answer); - // open input raster + /* open input raster */ if((iimg_fd = G_open_cell_old(opts.iimg->answer, G_mapset())) < 0) G_fatal_error("Can not open input raster."); - ialt_fd = -1; // initialize and assume there is no elevation map + ialt_fd = -1; /* initialize and assume there is no elevation map */ if(opts.ialt->answer) if((ialt_fd = G_open_cell_old(opts.ialt->answer, G_mapset())) < 0) G_fatal_error("Can not open elavation raster."); - ivis_fd = -1; // initialize and assume there is no visiblility map + ivis_fd = -1; /* initialize and assume there is no visiblility map */ if(opts.ivis->answer) if((ivis_fd = G_open_cell_old(opts.ivis->answer, G_mapset())) < 0) G_fatal_error("Can not open visibility raster."); - // open a floating point raster or not? + /* open a floating point raster or not? */ if(opts.oflt->answer) { if((oimg_fd = G_open_fp_cell_new(opts.oimg->answer)) < 0) @@ -551,20 +551,20 @@ G_fatal_error("Can not create output raster."); } - // read the scale parameters + /* read the scale parameters */ read_scale(opts.iscl, iscale); read_scale(opts.oscl, oscale); - // initialize this 6s computation and parse the input conditions file + /* initialize this 6s computation and parse the input conditions file */ init_6S(opts.icnd->answer); - InputMask imask = RADIANCE; // the input mask tells us what transformations if any - // needs to be done to make our input values, reflectance - // values scaled between 0 and 1 + InputMask imask = RADIANCE; /* the input mask tells us what transformations if any + needs to be done to make our input values, reflectance + values scaled between 0 and 1 */ if(opts.irad->answer) imask = REFLECTANCE; if(opts.etmbefore->answer) imask = (InputMask)(imask | ETM_BEFORE); if(opts.etmafter->answer) imask = (InputMask)(imask | ETM_AFTER); - // process the input raster and produce our atmospheric corrected output raster. + /* process the input raster and produce our atmospheric corrected output raster. */ process_raster(iimg_fd, imask, iscale, ialt_fd, ivis_fd, oimg_fd, opts.oflt->answer, oscale, opts.optimize->answer); @@ -579,7 +579,7 @@ Scaling is ignored and color ranges might not be correct. */ copy_colors(opts.iimg->answer, opts.oimg->answer); - // we are now done, so notify the user + /* we are now done, so notify the user */ fprintf(stderr, "Done!\n"); fflush(stderr); exit(0); } From chemin at grass.itc.it Fri Jun 8 12:37:09 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 12:37:10 2007 Subject: [grass-addons] r804 - trunk/grassaddons/gipe/i.atcorr Message-ID: <200706081037.l58Ab9hQ005754@grass.itc.it> Author: chemin Date: 2007-06-08 12:37:04 +0200 (Fri, 08 Jun 2007) New Revision: 804 Modified: trunk/grassaddons/gipe/i.atcorr/Transform.cpp trunk/grassaddons/gipe/i.atcorr/Transform.h Log: Update C compatible comment format in i.atcorr (last one) Modified: trunk/grassaddons/gipe/i.atcorr/Transform.cpp =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Transform.cpp 2007-06-08 10:34:55 UTC (rev 803) +++ trunk/grassaddons/gipe/i.atcorr/Transform.cpp 2007-06-08 10:37:04 UTC (rev 804) @@ -3,7 +3,7 @@ void EtmDN(int iwave, float asol, bool before, float &lmin, float &lmax) { - if (before) // ETM+ digital numbers taken before July 1, 2000 + if (before) /* ETM+ digital numbers taken before July 1, 2000 */ { switch(iwave) { @@ -65,7 +65,7 @@ } } } - else // ETM+ digital numbers taken after July 1, 2000 + else /* ETM+ digital numbers taken after July 1, 2000 */ { switch(iwave) { @@ -134,14 +134,14 @@ returns adjusted value also between 0 and 1 */ float transform(const TransformInput ti, InputMask imask, float idn) { - // convert from radiance to reflectance + /* convert from radiance to reflectance */ if((imask & ETM_BEFORE) || (imask & ETM_AFTER)) { /* http://ltpwww.gsfc.nas */ float lmin, lmax; EtmDN(ti.iwave, ti.asol, imask & ETM_BEFORE, lmin, lmax); - // multiply idn by 255.f to correct precondition that idn lies in [0, 255] + /* multiply idn by 255.f to correct precondition that idn lies in [0, 255] */ idn = (lmax - lmin) / 254.f * (idn * 255.f - 1.f) + lmin; if (idn < 0.f) idn = 0.f; idn /= 255.f; @@ -154,14 +154,14 @@ float xb = 0.0f; float xc = 0.0f; float rog = rapp / ti.tgasm; - // The if below was added to avoid ground reflectances lower than - // zero when ainr(1,1) greater than rapp/tgasm - // In such case either the choice of atmospheric model was not - // adequate for that image or the calculated apparent reflectance - // was too low. Run the model again for other conditions. - // The lines below just decrease ainr(1,1)/tgasm to avoid too - // bright pixels in the image. Check the output file to see if that - // has happened. + /* The if below was added to avoid ground reflectances lower than + zero when ainr(1,1) greater than rapp/tgasm + In such case either the choice of atmospheric model was not + adequate for that image or the calculated apparent reflectance + was too low. Run the model again for other conditions. + The lines below just decrease ainr(1,1)/tgasm to avoid too + bright pixels in the image. Check the output file to see if that + has happened. */ float decrfact = 1.0f; if (rog < (ainrpix / ti.tgasm)) Modified: trunk/grassaddons/gipe/i.atcorr/Transform.h =================================================================== --- trunk/grassaddons/gipe/i.atcorr/Transform.h 2007-06-08 10:34:55 UTC (rev 803) +++ trunk/grassaddons/gipe/i.atcorr/Transform.h 2007-06-08 10:37:04 UTC (rev 804) @@ -30,11 +30,11 @@ enum InputMask { REFLECTANCE = 0, - RADIANCE = 1, // the default - ETM_BEFORE = 2, // etm+ taken before July 1, 2000 + RADIANCE = 1, /* the default */ + ETM_BEFORE = 2, /* etm+ taken before July 1, 2000 */ REF_ETM_BEFORE = 2, RAD_ETM_BEFORE = 3, - ETM_AFTER = 4, // etm+ taken after July 1, 2000 + ETM_AFTER = 4, /* etm+ taken after July 1, 2000 */ REF_ETM_AFTER = 4, RAD_ETM_AFTER = 5 }; @@ -44,4 +44,4 @@ returns adjusted value also between 0 and 1 */ extern float transform(const TransformInput ti, InputMask imask, float idn); -#endif // TRANSFORM_H +#endif /* TRANSFORM_H */ From chemin at grass.itc.it Fri Jun 8 16:57:23 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 16:57:27 2007 Subject: [grass-addons] r805 - in trunk/grassaddons: gipe gui/gui_modules Message-ID: <200706081457.l58EvNrW008510@grass.itc.it> Author: chemin Date: 2007-06-08 16:56:12 +0200 (Fri, 08 Jun 2007) New Revision: 805 Modified: trunk/grassaddons/gipe/gmmenu.tcl trunk/grassaddons/gipe/install_yanns_grass.sh trunk/grassaddons/gipe/menudata.py trunk/grassaddons/gui/gui_modules/menudata.py Log: Updated GIPE to include install of HydroFOSS, i.pr and i.landsat.dehaze, not fully working yet Modified: trunk/grassaddons/gipe/gmmenu.tcl =================================================================== --- trunk/grassaddons/gipe/gmmenu.tcl 2007-06-08 10:37:04 UTC (rev 804) +++ trunk/grassaddons/gipe/gmmenu.tcl 2007-06-08 14:56:12 UTC (rev 805) @@ -506,9 +506,9 @@ {command {[G_msg "Mosaic up to 4 adjacent images"]} {} "i.image.mosaic" {} -command {execute i.image.mosaic }} }} {cascad {[G_msg "Manage image colors"]} {} "" $tmenu { - {command {[G_msg "Color balance and enhance color tables of multiband imagery for rgb display"]} {} "i.landsat.rgb" {} -command {execute i.landsat.rgb }} - {command {[G_msg "Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)"]} {} "i.his.rgb" {} -command {execute i.his.rgb }} - {command {[G_msg "Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)"]} {} "i.rgb.his" {} -command {execute i.rgb.his }} + {command {[G_msg "Color balance/enhance color tables for rgb display"]} {} "i.landsat.rgb" {} -command {execute i.landsat.rgb }} + {command {[G_msg "Transform HIS to RGB"]} {} "i.his.rgb" {} -command {execute i.his.rgb }} + {command {[G_msg "Transform RGB to HIS"]} {} "i.rgb.his" {} -command {execute i.rgb.his }} }} {cascad {[G_msg "Rectify and georeference image group"]} {} "" $tmenu { {command {[G_msg "Set ground control points (GCP's) from raster map or keyboard entry"]} {} "i.points" {} \ @@ -526,8 +526,10 @@ {command {[G_msg "Terra-Aster"]} {} "i.dn2ref.ast" {} -command {execute i.dn2ref.ast }} {separator} {command {[G_msg "Atmospheric correction"]} {} "i.atcorr" {} -command {execute i.atcorr }} + {command {[G_msg "Dehaze Landsat"]} {} "i.landsat.dehaze" {} -command {execute i.landsat.dehaze }} }} {cascad {[G_msg "Basic RS processing"]} {} "" $tmenu { + {command {[G_msg "Tassled cap vegetation index"]} {} "i.tasscap" {} -command {execute i.tasscap }} {command {[G_msg "Vegetation Indices (13 types)"]} {} "i.vi" {} -command {execute i.vi }} {command {[G_msg "Vegetation Indices (13 types) cluster"]} {} "i.vi.mpi" {} -command {execute i.vi.mpi }} {separator} @@ -540,7 +542,7 @@ }} {separator} {cascad {[G_msg "ETo, ETP, ETa"]} {} "" $tmenu { - {command {[G_msg "Reference ET (Hargreaves)"]} {} "r.evapo.MH" {} -command {execute i.evapo.MH }} + {command {[G_msg "Reference ET (Hargreaves)"]} {} "r.evapo.MH" {} -command {execute r.evapo.MH }} {separator} {command {[G_msg "Potential ET (Penman-Monteith)"]} {} "r.evapo.PM" {} -command {execute r.evapo.PM }} {command {[G_msg "Potential ET (Prestley and Taylor)"]} {} "i.evapo.PT" {} -command {execute i.evapo.PT }} @@ -573,8 +575,21 @@ {command {[G_msg "Biomass growth"]} {} "i.biomass" {} -command {execute r.biomass }} }} }} - {command {[G_msg "Brovey transformation and pan sharpening"]} {} "i.fusion.brovey" {} -command {execute i.fusion.brovey }} {cascad {[G_msg "Classify image"]} {} "" $tmenu { + {cascad {[G_msg "Classify image using pr library"]} {} "" $tmenu { + {command {[G_msg "pr_blob"]} {} "i.pr_blob" {} -command {execute i.pr_blob }} + {command {[G_msg "pr_classify"]} {} "pr_classify" {} -command {execute i.pr_classify}} + {command {[G_msg "pr_features"]} {} "pr_features" {} -command {execute i.pr_features}} + {command {[G_msg "pr_features_additional"]} {} "pr_features_additional" {} -command {execute i.pr_features_additional}} + {command {[G_msg "pr_features_extract"]} {} "pr_features_extract" {} -command {execute i.pr_features_extract}} + {command {[G_msg "pr_features_selection"]} {} "pr_features_selection" {} -command {execute i.pr_features_selection}} + {command {[G_msg "pr_model"]} {} "pr_model" {} -command {execute i.pr_model}} + {command {[G_msg "pr_sites_aggregate"]} {} "pr_sites_aggregate" {} -command {execute i.pr_sites_aggregate}} + {command {[G_msg "pr_statistics"]} {} "pr_statistics" {} -command {execute i.pr_statistics}} + {command {[G_msg "pr_subsets"]} {} "pr_subsets" {} -command {execute i.pr_subsets}} + {command {[G_msg "pr_training"]} {} "pr_training" {} -command {execute i.pr_training}} + {command {[G_msg "pr_uxb"]} {} "pr_uxb" {} -command {execute i.pr_uxb}} + }} {command {[G_msg "Clustering input for unsupervised classification"]} {} "i.cluster" {} -command {execute i.cluster }} {separator} {command {[G_msg "Maximum likelyhood classification (MLC)"]} {} "i.maxlik" {} -command {execute i.maxlik }} @@ -583,14 +598,17 @@ {command {[G_msg "Interactive input for supervised classification"]} {} "i.class" {} -command {term i.class }} {command {[G_msg "Non-interactive input for supervised classification (MLC)"]} {} "i.gensig" {} -command {execute i.gensig }} {command {[G_msg "Non-interactive input for supervised classification (SMAP)"]} {} "i.gensigset" {} -command {execute i.gensigset }} + {separator} + {command {[G_msg "Kappa classification accuracy assessment"]} {} "r.kappa" {} -command {execute r.kappa }} }} {cascad {[G_msg "Filter image"]} {} "" $tmenu { {command {[G_msg "Zero edge crossing detection"]} {} "i.zc" {} -command {execute i.zc }} {command {[G_msg "User defined matrix/convolving filter"]} {} "r.mfilter" {} -command {execute r.mfilter }} }} {command {[G_msg "Spectral response"]} {} "i.spectral" {} -command {execute i.spectral }} - {command {[G_msg "Tassled cap vegetation index"]} {} "i.tasscap" {} -command {execute i.tasscap }} {cascad {[G_msg "Transform image"]} {} "" $tmenu { + {command {[G_msg "Brovey pan sharpening"]} {} "i.fusion.brovey" {} -command {execute i.fusion.brovey }} + {separator} {command {[G_msg "Canonical component"]} {} "i.cca" {} -command {execute i.cca }} {command {[G_msg "Principal component"]} {} "i.pca" {} -command {execute i.pca }} {command {[G_msg "Fast Fourier Transform"]} {} "i.fft" {} -command {execute i.fft }} @@ -600,9 +618,9 @@ {cascad {[G_msg "Reports and statistics"]} {} "" $tmenu { {command {[G_msg "Report basic file information"]} {} "r.info" {} -command {execute r.info }} {command {[G_msg "Range of image values"]} {} "r.describe" {} -command {execute r.describe }} - {separator} + }} + {cascad {[G_msg "Quality Assessment"]} {} "" $tmenu { {command {[G_msg "Bit pattern comparison for ID of low quality pixels"]} {} "r.bitpattern" {} -command {execute r.bitpattern }} - {command {[G_msg "Kappa classification accuracy assessment"]} {} "r.kappa" {} -command {execute r.kappa }} {command {[G_msg "Optimum index factor for LandSat TM"]} {} "i.oif" {} -command {execute i.oif }} }} } Modified: trunk/grassaddons/gipe/install_yanns_grass.sh =================================================================== --- trunk/grassaddons/gipe/install_yanns_grass.sh 2007-06-08 10:37:04 UTC (rev 804) +++ trunk/grassaddons/gipe/install_yanns_grass.sh 2007-06-08 14:56:12 UTC (rev 805) @@ -7,31 +7,66 @@ #CHANGE THIS TO YOUR CVS TREE DIRECTORY GRASSCVSDIR=/home/yann/tmp/grass +# This Assumes you start in GIPE directory GIPEDIR=$('pwd') +cd .. +SVNDIR=$('pwd') +cd HydroFOSS +HFDIR=$('pwd') +cd ../GUI +WXDIR=$('pwd') #INSTALL GUI MODIFICATIONS cp -f $GIPEDIR/gui_Makefile $GRASSCVSDIR/gui/Makefile +#THIS ONE IS TCLTK cp -f $GIPEDIR/gmmenu.tcl $GRASSCVSDIR/gui/tcltk/gis.m/gmmenu.tcl cd $GRASSCVSDIR/gui/ make +#THIS ONE IS WXGRASS +cp -f $GIPEDIR/menudata.py $WXDIR/gui_modules/menudata.py #INSTALL MODULES +#START RASTER STUFF cd $GIPEDIR/ for directory in r.* do cp -rf $GIPEDIR/$directory $GRASSCVSDIR/raster/ done + +cd $HFDIR/ +for directory in r.* +do + cp -rf $HFDIR/$directory $GRASSCVSDIR/raster/ +done + cp -f $GIPEDIR/Makefile $GRASSCVSDIR/raster/ cd $GRASSCVSDIR/raster/ make +#END RASTER STUFF +#START IMAGERY STUFF +cd $GIPEDIR/ for directory in i.* do cp -rf $GIPEDIR/$directory $GRASSCVSDIR/imagery/ done + +cd $SVNDIR/ +for directory in i.* +do + cp -rf $GIPEDIR/$directory $GRASSCVSDIR/imagery/ +done + +cd $SVNDIR/ +for directory in i.pr/i.* +do + cp -rf $SVNDIR/i.pr/$directory $GRASSCVSDIR/imagery/ +done + cp -f $GIPEDIR/imagery_Makefile $GRASSCVSDIR/imagery/Makefile cd $GRASSCVSDIR/imagery/ make +#END IMAGERY STUFF #Install m.gem in /scripts cp -rf $GIPEDIR/m.gem $GRASSCVSDIR/scripts/ Modified: trunk/grassaddons/gipe/menudata.py =================================================================== --- trunk/grassaddons/gipe/menudata.py 2007-06-08 10:37:04 UTC (rev 804) +++ trunk/grassaddons/gipe/menudata.py 2007-06-08 14:56:12 UTC (rev 805) @@ -301,10 +301,11 @@ ("Terra-Aster", "Terra-Aster", "self.runMenuCmd", "i.dn2ref.ast"), ("","","", ""), ("Atmospheric correction", "Atmospheric correction", "self.runMenuCmd", "i.atcorr"), + ("Dehaze Landsat", "Dehaze Landsat", "self.runMenuCmd", "i.landsat.dehaze"), )), ("Basic RS processing", ( ("Vegetation Indices (13 types)", "Vegetation Indices (13 types)", "self.runMenuCmd", "i.vi"), - ("Vegetation Indices (13 types) cluster", "Vegetation Indices (13 types) cluster", "self.runMenuCmd", "r.vi.mpi"), + ("Vegetation Indices (13 types) cluster", "Vegetation Indices (13 types) cluster", "self.runMenuCmd", "i.vi.mpi"), ("Vegetation Index (Landsat TM Tasseled cap)", "Vegetation Index (Landsat TM Tasseled cap)", "self.runMenuCmd", "i.tasscap"), ("","","", ""), ("Albedo", "Albedo", "self.runMenuCmd", "i.albedo"), @@ -351,6 +352,20 @@ ("","","", ""), )), ("Classify image", ( + ("Classify using pr library", ( + ("pr_blob", "pr_blob", "self.runMenuCmd", "i.pr_blob"), + ("pr_classify", "pr_classify", "self.runMenuCmd", "i.pr_classify"), + ("pr_features", "pr_features", "self.runMenuCmd", "i.pr_features"), + ("pr_features_additional", "pr_features_additional", "self.runMenuCmd", "i.pr_features_additional"), + ("pr_features_extract", "pr_features_extract", "self.runMenuCmd", "i.pr_features_extract"), + ("pr_features_selection", "pr_features_selection", "self.runMenuCmd", "i.pr_features_selection"), + ("pr_model", "pr_model", "self.runMenuCmd", "i.pr_model"), + ("pr_sites_aggregate", "pr_sites_aggregate", "self.runMenuCmd", "i.pr_sites_aggregate"), + ("pr_statistics", "pr_statistics", "self.runMenuCmd", "i.pr_statistics"), + ("pr_subsets", "pr_subsets", "self.runMenuCmd", "i.pr_subsets"), + ("pr_training", "pr_training", "self.runMenuCmd", "i.pr_training"), + ("pr_uxb", "pr_uxb", "self.runMenuCmd", "i.pr_uxb"), + )), ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.runMenuCmd", "i.cluster"), ("","","", ""), ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.runMenuCmd", "i.maxlik"), Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-08 10:37:04 UTC (rev 804) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-08 14:56:12 UTC (rev 805) @@ -4,441 +4,458 @@ def GetMenu(self): return [( ("Files", ( - ("Import", ( - ("Raster map", ( - ("Multiple formats using GDAL", "Import multiple formats using GDAL", "self.OnMenuCmd", "r.in.gdal"), - ("","","", ""), - ("Aggregate ASCII xyz", "Import aggregate ASCII xyz data", "self.OnMenuCmd", "r.in.xyz"), - ("ASCII grid", "Import ASCII GRID (includes GRASS ASCII)", "self.OnMenuCmd", "r.in.ascii"), - ("ASCII polygons and lines", "Import Polygons and lines from ASCII file", "self.OnMenuCmd", "r.in.poly"), - ("","","", ""), - ("Binary", "Import binary file (includes GTOPO30 format)", "self.OnMenuCmd", "r.in.bin"), - ("ESRI Arc/Info ASCII grid", "Import ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.in.arc"), - ("GRIDATB.FOR", "Import GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.in.gridatb"), - ("MAT-File (v.4)", "Import MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.in.mat"), - ("SPOT NDVI", "Import SPOT vegetation NDVI data sets", "self.OnMenuCmd", "r.in.spotvgt"), - ("SRTM HGT", "Import SRTM hgt files", "self.OnMenuCmd", "r.in.srtm"), - ("Terra ASTER HDF", "Import Terra ASTER HDF files", "self.OnMenuCmd", "r.in.aster"), - ("","","", ""), - ("WMS", "Import Web Mapping Server", "self.OnMenuCmd", "r.in.wms"), - )), - ("Vector map", ( - ("Multiple formats using OGR", "Import multiple formats using OGR", "self.OnMenuCmd", "v.in.ogr"), - ("","","", ""), - ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.in.ascii"), - ("Old GRASS vector", "Import old GRASS vector format", "self.OnMenuCmd", "v.convert"), - ("","","", ""), - ("DXF", "Import DXF file", "self.OnMenuCmd", "v.in.dxf"), - ("ESRI e00", "Import ESRI e00 file", "self.OnMenuCmd", "v.in.e00"), - ("Garmin GPS", "Import Garmin GPS Waypoints/Routes/Tracks", "self.OnMenuCmd", "v.in.garmin"), - ("GPSBabel GPS", "Import GPS Waypoints/Routes/Tracks using GPSBabel", "self.OnMenuCmd", "v.in.gpsbabel"), - ("GEOnet", "Import GEOnet Name server country files (US-NGA GNS)", "self.OnMenuCmd", "v.in.gns"), - ("Matlab and MapGen", "Import Matlab and MapGen files", "self.OnMenuCmd", "v.in.mapgen"), - )), - - ("Grid 3D", ( - ("ASCII 3D", "Import ASCII 3D file", "self.OnMenuCmd", "r3.in.ascii"), - ("Vis5D", "Import Vis5D file", "self.OnMenuCmd", "r3.in.v5d"), - )), - )), - ("Export", ( - ("Raster map", ( - ("Multiple formats using GDAL", "Export multiple formats using GDAL", "self.OnMenuCmd", "r.out.gdal"), - ("","","", ""), - ("ASCII grid", "Export ASCII grid (for GRASS, Surfer, Modflow, etc)", "self.OnMenuCmd", "r.out.ascii"), - ("ASCII x,y,z", "Export ASCII x,y,z values of cell centers", "self.OnMenuCmd", "r.out.xyz"), - ("","","", ""), - ("ESRI ASCII grid", "Export ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.out.arc"), - ("GRIDATB.FOR", "Export GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.out.gridatb"), - ("MAT-File (v.4)", "Export MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.out.mat"), - ("","","", ""), - ("Binary", "Export binary file", "self.OnMenuCmd", "r.out.bin"), - ("","","", ""), - ("MPEG-1", "Export MPEG-1 animations", "self.OnMenuCmd", "r.out.mpeg"), - ("PNG", "Export PNG image (not georeferenced)", "self.OnMenuCmd", "r.out.png"), - ("PPM", "Export PPM image (24bit)", "self.OnMenuCmd", "r.out.ppm"), - ("POV-Ray", "Export POVray height-field", "self.OnMenuCmd", "r.out.pov"), - ("TIFF", "Export TIFF image (8/24bit)", "self.OnMenuCmd", "r.out.tiff"), - ("VRML", "Export VRML file", "self.OnMenuCmd", "r.out.vrml"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r.out.vtk"), - )), - ("Vector map", ( - ("Multiple formats using OGR", "Export multiple formats using OGR", "self.OnMenuCmd", "v.out.ogr"), - ("","","", ""), - ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.out.ascii"), - - ("DXF", "Export DXF file", "self.OnMenuCmd", "v.out.dxf"), - ("POV-Ray", "Export POV-Ray format file", "self.OnMenuCmd", "v.out.pov"), - ("SVG", "Export SVG file", "self.OnMenuCmd", "v.out.svg"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "v.out.vtk"), - )), - - ("Grid 3D", ( - ("ASCII 3D", "Export ASCII 3D file", "self.OnMenuCmd", "r3.out.ascii"), - ("Vis5D", "Export Vis5D file", "self.OnMenuCmd", "r3.out.v5d"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r3.out.vtk"), - )), - )), + ("Import", "Import files", "self.runMenuCmd", "r.in.gdal"), + ("Export", "Export files", "self.runMenuCmd", "r.out.gdal"), ("","","", ""), - ("Manage maps and volumes", ( - ("Copy", "Copy maps within mapsets or between mapsets", "self.OnMenuCmd", "g.copy"), - ("","","", ""), - ("List", "List maps by type", "self.OnMenuCmd", "list"), - ("List filtered", "List maps filtered by expressions and wildcards", "self.OnMenuCmd", "g.mlist"), - ("","","", ""), - ("Rename", "Rename maps", "self.OnMenuCmd", "g.rename"), - ("","","", ""), - ("Delete", "Delete maps", "self.OnMenuCmd", "g.remove"), - ("Delete filtered", "Delete maps using expressions and wildcards", "self.OnMenuCmd", "g.mremove"), - )), - ("Map type conversions", ( - ("Raster to vector", "Convert raster to vector map", "self.OnMenuCmd", "r.to.vect"), - ("Raster series to volume", "Convert raster map series to volume", "self.OnMenuCmd", "r.to.rast3"), - ("Raster 2.5D to volume", "Convert raster 2.5D map to volume", "self.OnMenuCmd", "r.to.rast3elev"), - ("","","", ""), - ("Vector to raster", "Convert vector to raster map", "self.OnMenuCmd", "v.to.rast"), - ("Vector to volume", "Convert vector 3D points to volume voxels", "self.OnMenuCmd", "v.to.rast3"), - ("Sites to vector", "Convert sites (GRASS 5) to vector map", "self.OnMenuCmd", "v.in.sites"), - ("","","", ""), - ("Volumes to raster series", "Convert raster to vector map", "self.OnMenuCmd", "r3.to.rast"), - )), - ("","","", ""), - ("Georectify (not functional)", "Georectify raster and vector maps", "self.OnGeorectify", ""), - ("","","", ""), - ("Bearing/distance to coordinates", "Convert between bearing/distance and coordinates", "self.OnMenuCmd", "m.cogo"), - ("","","", ""), - ("Postscript plot", "Create cartographic PostScript plot", "self.OnMenuCmd", "ps.map"), - ("","","", ""), - ("E&xit", "Exit from wxgui.py", "self.OnCloseWindow", ""), + ("E&xit", "Exit from wxgui.py", "self.onCloseWindow", "") )), ("Config", ( - ("Region", ( - ("Display region", "Display region settings", "self.RunMenuCmd", "g.region -p"), - ("Set region", "Change region settings", "self.OnMenuCmd", "g.region"), + ("Region", "Set region", "self.runMenuCmd", "g.region"), + ("","","", ""), + ("Set display font", "Set default font for GRASS displays", "self.DefaultFont", ""), + ("Add a GRASS Extension", "Add a GRASS Extension", "self.runMenuCmd", "scripts/m.gem") )), - ("GRASS working environment", ( - ("Mapset access (not functional)", "Set access to other mapsets in current location", "self.OnMapsets", ""), - ("Change working environment", "Change current working session to new mapset, location, or data directory", "self.OnMenuCmd", "g.mapset"), - ("User access", "Change access by other users to current mapset", "self.OnMenuCmd", "g.access"), - ("Show settings", "Show current GRASS environment settings", "self.RunMenuCmd", "g.gisenv "), - ("Change settings", "Change GRASS environment settings", "self.OnMenuCmd", "g.gisenv"), - ("Version", "Show current GRASS version", "self.RunMenuCmd", "g.version -c"), - )), - ("Manage projections", ( - ("Projections", "Show projection information and create projection files", "self.OnMenuCmd", "g.proj"), - ("Convert coordinates", "Convert coordinates from one projection to another", "self.OnMenuCmd", "m.proj"), - )), - ("Display font", "Set default font for GRASS displays", "self.DefaultFont", ""), - )), ("Raster", ( ("Develop map", ( - ("Digitize raster (not functional)", "Digitize raster", "self.OnRDigit", ""), + ("Digitize raster", "Digitize raster", "self.runMenuCmd", "r.digit"), ("","","", ""), - ("Compress/decompress raster file", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), - ("Manage boundary definition (WHICH COMMAND?)", "Manage boundary definition", "self.OnMenuCmd", "r.region"), - ("Manage null values", "Manage null values", "self.OnMenuCmd", "r.null"), - ("Manage timestamp for files", "Manage timestamp for files", "self.OnMenuCmd", "r.timestamp"), - ("Quantization for floating-point maps", "Quantization for floating-point maps", "self.OnMenuCmd", "r.quant"), - ("Resample (change resolution) using nearest neighbor method", "Resample (change resolution) using nearest neighbor method", "self.OnMenuCmd", "r.resample"), - ("Resample (change resolution) using regularized spline tension", "Resample (change resolution) using regularized spline tension", "self.OnMenuCmd", "r.resamp.rst"), - ("Support file creation and maintenance", "Support file creation and maintenance", "self.OnMenuCmd", "r.support.sh"), + ("Compress/decompress raster file", "Compress/decompress raster file", "self.runMenuCmd", "r.compress"), + ("Manage boundary definition (WHICH COMMAND?)", "Manage boundary definition", "self.runMenuCmd", "r.region"), + ("Manage null values", "Manage null values", "self.runMenuCmd", "r.null"), + ("Manage timestamp for files", "Manage timestamp for files", "self.runMenuCmd", "r.timestamp"), + ("Quantization for floating-point maps", "Quantization for floating-point maps", "self.runMenuCmd", "r.quant"), + ("Resample (change resolution) using nearest neighbor method", "Resample (change resolution) using nearest neighbor method", "self.runMenuCmd", "r.resample"), + ("Resample (change resolution) using regularized spline tension", "Resample (change resolution) using regularized spline tension", "self.runMenuCmd", "r.resamp.rst"), + ("Support file creation and maintenance", "Support file creation and maintenance", "self.runMenuCmd", "r.support.sh"), ("","","", ""), - ("Reproject raster from other location", "Reproject raster from other location", "self.OnMenuCmd", "r.proj"), - ("Generate tiling for other projection", "Generate tiling for other projection", "self.OnMenuCmd", "r.tileset"), + ("Reproject raster from other location", "Reproject raster from other location", "self.runMenuCmd", "r.proj"), + ("Generate tiling for other projection", "Generate tiling for other projection", "self.runMenuCmd", "r.tileset"), )), ("Manage map colors", ( - ("Set colors to predefined color tables", "Set colors to predefined color tables", "self.OnMenuCmd", "r.colors"), - ("Set colors using color rules", "Set colors using color rules", "self.OnMenuCmd", "r.colors.rules"), + ("Set colors to predefined color tables", "Set colors to predefined color tables", "self.runMenuCmd", "r.colors"), + ("Set colors using color rules", "Set colors using color rules", "self.runMenuCmd", "r.colors.rules"), ("","","", ""), - ("Blend 2 color maps to produce 3 RGB files", "Blend 2 color maps to produce 3 RGB files", "self.OnMenuCmd", "r.blend"), - ("Create color image from RGB files", "Create color image from RGB files", "self.OnMenuCmd", "r.composite"), - ("Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.OnMenuCmd", "r.his"), + ("Blend 2 color maps to produce 3 RGB files", "Blend 2 color maps to produce 3 RGB files", "self.runMenuCmd", "r.blend"), + ("Create color image from RGB files", "Create color image from RGB files", "self.runMenuCmd", "r.composite"), + ("Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.runMenuCmd", "r.his"), )), - ("Query by coordinates", "Query by coordinates", "self.OnMenuCmd", "r.what"), + ("Query/Profile", ( + ("Query by coordinates", "Query by coordinates", "self.runMenuCmd", "r.what"), + ("Profile", "Profile of transect", "self.DispProfile", ""), + )), ("","","", ""), - ("Create raster buffers", "Develop raster buffer", "self.OnMenuCmd", "r.buffer"), - ("Create raster MASK", "Develop raster mask", "self.OnMenuCmd", "r.mask"), - ("Locate closest points between areas in 2 raster maps", "r.distance", "self.OnMenuCmd", "r.distance"), - ("Map calculator", "Map calculator", "self.OnMenuCmd", "scripts/mapcalc_gparser.sh"), - ("Neighborhood analysis", ( - ("Moving window analysis of raster cells", "Moving window analysis of raster cells", "self.OnMenuCmd", "r.neighbors"), - ("Analyze vector points in neighborhood of raster cells", "Analyze vector points in neighborhood of raster cells", "self.OnMenuCmd", "v.neighbors"), - )), + ("Create raster MASK", "Develop raster mask", "self.runMenuCmd", "r.mask"), + ("Create raster buffers", "Develop raster buffer", "self.runMenuCmd", "r.buffer"), + ("Map calculator", "Map calculator", "self.runMenuCmd", "scripts/mapcalc_gparser.sh"), + ("","","", ""), ("Overlay maps", ( - ("Cross product", "Cross product", "self.OnMenuCmd", "r.cross"), - ("Function of map series (time series)", "Function of map series (time series)", "self.OnMenuCmd", "r.series"), - ("Patch maps", "Patch maps", "self.OnMenuCmd", "r.patch"), + ("Cross product", "Cross product", "self.runMenuCmd", "r.cross"), + ("Function of map series (time series)", "Function of map series (time series)", "self.runMenuCmd", "r.series"), + ("Patch maps", "Patch maps", "self.runMenuCmd", "r.patch"), ("","","", ""), - ("Statistical calculations for cover map over base map", "Statistical calculations for cover map over base map", "self.OnMenuCmd", "r.statistics"), + ("Statistical calculations for cover map over base map", "Statistical calculations for cover map over base map", "self.runMenuCmd", "r.statistics"), )), - ("Solar radiance and shadows", ( - ("Solar irradiance and daily irradiation", "Solar irradiance and daily irradiation", "self.OnMenuCmd", "r.sun"), - ("Shadow map for sun position or date/time", "Shadow map for sun position or date/time", "self.OnMenuCmd", "r.sunmask"), + ("Transform features", ( + ("Clump small areas (statistics calculated by r.volume)", "Clump small areas (statistics calculated by r.volume)", "self.runMenuCmd", "r.clump"), + ("Grow areas", "Grow areas", "self.runMenuCmd", "r.grow"), + ("Thin linear features", "Thin linear features", "self.runMenuCmd", "r.thin"), )), - ("Terrain analysis", ( - ("Calculate cumulative movement costs between locales", "Calculate cumulative movement costs between locales", "self.OnMenuCmd", "r.walk"), - ("cost surface", "cost surface", "self.OnMenuCmd", "r.cost"), - ("Least cost route or flow", "Least cost route or flow", "self.OnMenuCmd", "r.drain"), - ("Shaded relief map", "Shaded relief map", "self.OnMenuCmd", "r.shaded.relief"), - ("Slope and aspect", "Slope and aspect", "self.OnMenuCmd", "r.slope.aspect"), - ("Terrain parameters", "Terrain parameters", "self.OnMenuCmd", "r.param.scale"), - ("Textural features", "Textural features", "self.OnMenuCmd", "r.texture"), - ("Visibility/Line of sight", "Visibility/Line of sight", "self.OnMenuCmd", "r.los"), + ("Proximity/Neighborhood analysis", ( + ("Moving window analysis of raster cells", "Moving window analysis of raster cells", "self.runMenuCmd", "r.neighbors"), + ("Analyze vector points in neighborhood of raster cells", "Analyze vector points in neighborhood of raster cells", "self.runMenuCmd", "v.neighbors"), + ("","","", ""), + ("Locate closest points between areas in 2 raster maps", "r.distance", "self.runMenuCmd", "r.distance"), )), - ("Transform features", ( - ("Clump small areas (statistics calculated by r.volume)", "Clump small areas (statistics calculated by r.volume)", "self.OnMenuCmd", "r.clump"), - ("Grow areas", "Grow areas", "self.OnMenuCmd", "r.grow"), - ("Thin linear features", "Thin linear features", "self.OnMenuCmd", "r.thin"), - )), ("","","", ""), - ("Hydrologic modeling", ( - ("Carve stream channels into elevation map using vector streams map", "Carve stream channels into elevation map using vector streams map", "self.OnMenuCmd", "r.carve"), - ("Depressionless elevation map and flowline map", "Depressionless elevation map and flowline map", "self.OnMenuCmd", "r.fill.dir"), - ("Fill lake from seed point to specified level", "Fill lake from seed point to specified level", "self.OnMenuCmd", "r.lake"), - ("Flow accumulation for massive grids (WHICH COMMAND?)", "Flow accumulation for massive grids", "self.OnMenuCmd", "r.flow"), - ("Generate flow lines for raster map (WHICH COMMAND?)", "Generate flow lines for raster map", "self.OnMenuCmd", "r.flow"), - ("SIMWE overland flow modeling (WHICH COMMAND?)", "SIMWE overland flow modeling", "self.OnMenuCmd", "r.simwe"), - ("SIMWE sediment erosion, transport, deposition modeling (WHICH COMMAND?)", "SIMWE sediment erosion, transport, deposition modeling", "self.OnMenuCmd", "r.simwe"), - ("Topographic index map", "Topographic index map", "self.OnMenuCmd", "r.topidx"), - ("TOPMODEL simulation", "TOPMODEL simulation", "self.OnMenuCmd", "r.topmodel"), - ("Watershed subbasins", "Watershed subbasins", "self.OnMenuCmd", "r.basins.fill"), - ("Watershed analysis", "Watershed analysis", "self.OnMenuCmd", "r.watershed"), - ("Watershed basin creation", "Watershed basin creation", "self.OnMenuCmd", "r.water.outlet"), + ("Modeling: Hydrologic", ( + ("Carve stream channels into elevation map using vector streams map", "Carve stream channels into elevation map using vector streams map", "self.runMenuCmd", "r.carve"), + ("Depressionless elevation map and flowline map", "Depressionless elevation map and flowline map", "self.runMenuCmd", "r.fill.dir"), + ("Fill lake from seed point to specified level", "Fill lake from seed point to specified level", "self.runMenuCmd", "r.lake"), + ("Flow accumulation for massive grids (WHICH COMMAND?)", "Flow accumulation for massive grids", "self.runMenuCmd", "r.flow"), + ("Generate flow lines for raster map (WHICH COMMAND?)", "Generate flow lines for raster map", "self.runMenuCmd", "r.flow"), + ("","","", ""), + ("SIMWE overland flow modeling (WHICH COMMAND?)", "SIMWE overland flow modeling", "self.runMenuCmd", "r.simwe"), + ("SIMWE sediment erosion, transport, deposition modeling (WHICH COMMAND?)", "SIMWE sediment erosion, transport, deposition modeling", "self.runMenuCmd", "r.simwe"), + ("Topographic index map", "Topographic index map", "self.runMenuCmd", "r.topidx"), + ("TOPMODEL simulation", "TOPMODEL simulation", "self.runMenuCmd", "r.topmodel"), + ("","","", ""), + ("Watershed subbasins", "Watershed subbasins", "self.runMenuCmd", "r.basins.fill"), + ("Watershed analysis", "Watershed analysis", "self.runMenuCmd", "r.watershed"), + ("Watershed basin creation", "Watershed basin creation", "self.runMenuCmd", "r.water.outlet"), )), - ("Landscape structure modeling", ( - ("Set up sampling and analysis framework", "Set up sampling and analysis framework", "self.OnMenuCmd", "r.le.setup"), + ("Modeling: Landscape structure", ( + ("Set up sampling and analysis framework", "Set up sampling and analysis framework", "self.runMenuCmd", "r.le.setup"), ("","","", ""), - ("Analyze landscape characteristics", "Analyze landscape characteristics", "self.OnMenuCmd", "r.le.pixel"), - ("Analyze landscape patch characteristics", "Analyze landscape patch characteristics", "self.OnMenuCmd", "r.le.patch"), - ("Output landscape patch information", "Output landscape patch information", "self.OnMenuCmd", "r.le.trace"), + ("Analyze landscape characteristics", "Analyze landscape characteristics", "self.runMenuCmd", "r.le.pixel"), + ("Analyze landscape patch characteristics", "Analyze landscape patch characteristics", "self.runMenuCmd", "r.le.patch"), + ("Output landscape patch information", "Output landscape patch information", "self.runMenuCmd", "r.le.trace"), )), - ("Wildfire modeling", ( - ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.OnMenuCmd", "r.ros"), - ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.OnMenuCmd", "r.spreadpath"), - ("Simulate anisotropic spread phenomena", "Simulate anisotropic spread phenomena", "self.OnMenuCmd", "r.spread"), + ("Modeling: Terrain and solar", ( + ("Calculate cumulative movement costs between locales", "Calculate cumulative movement costs between locales", "self.runMenuCmd", "r.walk"), + ("Cost surface", "cost surface", "self.runMenuCmd", "r.cost"), + ("Least cost route or flow", "Least cost route or flow", "self.runMenuCmd", "r.drain"), + ("","","", ""), + ("Shaded relief map", "Shaded relief map", "self.runMenuCmd", "r.shaded.relief"), + ("Slope and aspect", "Slope and aspect", "self.runMenuCmd", "r.slope.aspect"), + ("Terrain parameters", "Terrain parameters", "self.runMenuCmd", "r.param.scale"), + ("","","", ""), + ("Textural features", "Textural features", "self.runMenuCmd", "r.texture"), + ("Visibility/Line of sight", "Visibility/Line of sight", "self.runMenuCmd", "r.los"), + ("","","", ""), + ("Solar irradiance and daily irradiation", "Solar irradiance and daily irradiation", "self.runMenuCmd", "r.sun"), + ("Shadow map for sun position or date/time", "Shadow map for sun position or date/time", "self.runMenuCmd", "r.sunmask"), )), + ("Modeling: Universal Soil Loss Equation (USLE)", ( + ("Rainfall Erosivity (R)", "Rainfall Erosivity (R)", "self.runMenuCmd", "r.usler"), + ("Soil Erodibility (K)", "Soil Erodibility (K)", "self.runMenuCmd", "r.uslek"), + ("Length Slope and Slope (LS)", "Length Slope and Slope (LS)", "self.runMenuCmd", "r.watershed"), + ("","","", ""), + )), + ("Modeling: Wildfire", ( + ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.runMenuCmd", "r.ros"), + ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.runMenuCmd", "r.spreadpath"), + ("Simulate anisotropic spread phenomena", "Simulate anisotropic spread phenomena", "self.runMenuCmd", "r.spread"), + )), ("","","", ""), ("Change category values and labels", ( - ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.OnMenuCmd", "d.rast.edit"), + ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.runMenuCmd", "d.rast.edit"), ("","","", ""), - ("Reclassify categories for areas of specified sizes", "Reclassify categories for areas of specified sizes", "self.OnMenuCmd", "r.reclass.area"), - ("Reclassify categories using rules", "Reclassify categories using rules", "self.OnMenuCmd", "r.reclass.rules"), - ("Reclassify categories using rules file", "Reclassify categories using rules file", "self.OnMenuCmd", "r.reclass.file"), + ("Reclassify categories for areas of specified sizes", "Reclassify categories for areas of specified sizes", "self.runMenuCmd", "r.reclass.area"), + ("Reclassify categories using rules", "Reclassify categories using rules", "self.runMenuCmd", "r.reclass.rules"), + ("Reclassify categories using rules file", "Reclassify categories using rules file", "self.runMenuCmd", "r.reclass.file"), ("","","", ""), - ("Recode categories using rules (create new map)", "Recode categories using rules (create new map)", "self.OnMenuCmd", "r.recode.rules"), - ("Recode categories using rules file (create new map)", "Recode categories using rules file (create new map)", "self.OnMenuCmd", "r.recode.file"), + ("Recode categories using rules (create new map)", "Recode categories using rules (create new map)", "self.runMenuCmd", "r.recode.rules"), + ("Recode categories using rules file (create new map)", "Recode categories using rules file (create new map)", "self.runMenuCmd", "r.recode.file"), ("","","", ""), - ("Rescale categories (create new map)", "Rescale categories (create new map)", "self.OnMenuCmd", "r.rescale"), - ("Rescale categories with equalized histogram (create new map)", "Rescale categories with equalized histogram (create new map)", "self.OnMenuCmd", "r.rescale.eq"), + ("Rescale categories (create new map)", "Rescale categories (create new map)", "self.runMenuCmd", "r.rescale"), + ("Rescale categories with equalized histogram (create new map)", "Rescale categories with equalized histogram (create new map)", "self.runMenuCmd", "r.rescale.eq"), )), ("","","", ""), - ("Generate concentric circles around points", "Generate concentric circles around points", "self.OnMenuCmd", "r.circle"), - ("Generate random raster cells", ( - ("Generate random cells", "Generate random cells", "self.OnMenuCmd", "r.random.cells"), - ("Generate random cells and vector points from raster map", "Generate random cells and vector points from raster map", "self.OnMenuCmd", "r.random"), - )), - ("Generate surfaces", ( - ("Generate density surface using moving Gaussian kernel", "Generate density surface using moving Gaussian kernel", "self.OnMenuCmd", "v.kernel"), - ("Generate fractal surface", "Generate fractal surface", "self.OnMenuCmd", "r.surf.fractal"), - ("Generate gaussian deviates surface", "Generate gaussian deviates surface", "self.OnMenuCmd", "r.surf.gauss"), - ("Generate plane", "Generate plane", "self.OnMenuCmd", "r.plane"), - ("Generate random deviates surface", "Generate random deviates surface", "self.OnMenuCmd", "r.surf.random"), - ("Generate random surface with spatial dependence", "Generate random surface with spatial dependence", "self.OnMenuCmd", "r.random.surface"), - )), - ("Generate vector contour lines", "Generate vector contour lines", "self.OnMenuCmd", "r.contour"), + ("Generate", ( + ("Concentric circles around points", "Concentric circles around points", "self.runMenuCmd", "r.circle"), + ("Density surface using moving Gaussian kernel", "Density surface using moving Gaussian kernel", "self.runMenuCmd", "v.kernel"), + ("Fractal surface", "Fractal surface", "self.runMenuCmd", "r.surf.fractal"), + ("Gaussian deviates surface", "Gaussian deviates surface", "self.runMenuCmd", "r.surf.gauss"), + ("Plane", "Plane", "self.runMenuCmd", "r.plane"), + ("","","", ""), + ("Random cells", "Random cells", "self.runMenuCmd", "r.random.cells"), + ("Random cells and vector points from raster map", "Random cells and vector points from raster map", "self.runMenuCmd", "r.random"), + ("Random deviates surface", "Random deviates surface", "self.runMenuCmd", "r.surf.random"), + ("Random surface with spatial dependence", "Random surface with spatial dependence", "self.runMenuCmd", "r.random.surface"), + ("","","", ""), + ("Vector contour lines", "Vector contour lines", "self.runMenuCmd", "r.contour"), + )), ("Interpolate surfaces", ( - ("Bilinear interpolation from raster points", "Bilinear interpolation from raster points", "self.OnMenuCmd", "r.bilinear"), - ("Inverse distance weighted interpolation from raster points", "Inverse distance weighted interpolation from raster points", "self.OnMenuCmd", "r.surf.idw"), - ("Interpolation from raster contour", "Interpolation from raster contour", "self.OnMenuCmd", "r.surf.contour"), + ("Bilinear (from raster points)", "Bilinear (from raster points)", "self.runMenuCmd", "r.bilinear"), + ("Inverse distance weighted (from raster points)", "Inverse distance weighted (from raster points)", "self.runMenuCmd", "r.surf.idw"), + ("From raster contour", "From raster contour", "self.runMenuCmd", "r.surf.contour"), ("","","", ""), - ("Inverse distance weighted interpolation from vector points", "Inverse distance weighted interpolation from vector points", "self.OnMenuCmd", "v.surf.idw"), - ("Regularized spline tension interpolation from vector points or contours (WHICH COMMAND ?)", "Regularized spline tension interpolation from vector points or contours", "self.OnMenuCmd", "v.surf.rst"), + ("Inverse distance weighted (from vector points)", "Inverse distance weighted (from vector points)", "self.runMenuCmd", "v.surf.idw"), + ("Regularized spline tension (from vector points/contours) (WHICH COMMAND ?)", "Regularized spline tension (from vector points/contours)", "self.runMenuCmd", "v.surf.rst"), ("","","", ""), - ("Fill NULL cells by interpolation using regularized spline tension", "Fill NULL cells by interpolation using regularized spline tension", "self.OnMenuCmd", "r.fillnulls"), + ("Fill NULL cells using regularized spline tension", "Fill NULL cells using regularized spline tension", "self.runMenuCmd", "r.fillnulls"), )), ("","","", ""), ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), - ("Report category labels and values", "Report category labels and values", "self.OnMenuCmd", "r.cats"), + ("Report basic file information", "Report basic file information", "self.runMenuCmd", "r.info"), + ("Report category labels and values", "Report category labels and values", "self.runMenuCmd", "r.cats"), ("","","", ""), - ("General statistics", "General statistics", "self.OnMenuCmd", "r.stats"), - ("Range of all category values", "Range of all category values", "self.OnMenuCmd", "r.describe"), - ("Sum all cell category values", "Sum all cell category values", "self.OnMenuCmd", "r.sum"), - ("Sum area by map and category", "Sum area by map and category", "self.OnMenuCmd", "r.report"), - ("Summary statistics for clumped cells (work with r.clump)", "Summary statistics for clumped cells (work with r.clump)", "self.OnMenuCmd", "r.volume"), - ("Total surface area corrected for topography", "Total surface area corrected for topography", "self.OnMenuCmd", "r.surf.area"), - ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "r.univar"), - ("Univariate statistics (script version)", "Univariate statistics (script version)", "self.OnMenuCmd", "r.univar.sh"), + ("General statistics", "General statistics", "self.runMenuCmd", "r.stats"), + ("Range of all category values", "Range of all category values", "self.runMenuCmd", "r.describe"), ("","","", ""), - ("Sample values along transects", "Sample values along transects", "self.OnMenuCmd", "r.profile"), - ("Sample values along transects (use azimuth, distance)", "Sample values along transects (use azimuth, distance)", "self.OnMenuCmd", "r.transect"), + ("Sum all cell category values", "Sum all cell category values", "self.runMenuCmd", "r.sum"), + ("Sum area by map and category", "Sum area by map and category", "self.runMenuCmd", "r.report"), + ("Summary statistics for clumped cells (work with r.clump)", "Summary statistics for clumped cells (work with r.clump)", "self.runMenuCmd", "r.volume"), ("","","", ""), - ("Covariance/correlation", "Covariance/correlation", "self.OnMenuCmd", "r.covar"), - ("Linear regression between 2 maps", "Linear regression between 2 maps", "self.OnMenuCmd", "r.regression.line"), - ("Mutual category occurrences (coincidence)", "Mutual category occurrences (coincidence)", "self.OnMenuCmd", "r.coin"), + ("Total surface area corrected for topography", "Total surface area corrected for topography", "self.runMenuCmd", "r.surf.area"), + ("Univariate statistics", "Univariate statistics", "self.runMenuCmd", "r.univar"), + ("Univariate statistics (script version)", "Univariate statistics (script version)", "self.runMenuCmd", "r.univar.sh"), + ("","","", ""), + ("Sample values along transects", "Sample values along transects", "self.runMenuCmd", "r.profile"), + ("Sample values along transects (use azimuth, distance)", "Sample values along transects (use azimuth, distance)", "self.runMenuCmd", "r.transect"), + ("","","", ""), + ("Covariance/correlation", "Covariance/correlation", "self.runMenuCmd", "r.covar"), + ("Linear regression between 2 maps", "Linear regression between 2 maps", "self.runMenuCmd", "r.regression.line"), + ("Mutual category occurrences (coincidence)", "Mutual category occurrences (coincidence)", "self.runMenuCmd", "r.coin"), )), ("","","", "") )), ("Vector", ( ("Develop map", ( - ("Digitize", "Digitize vector", "self.OnMenuCmd", "v.digit"), + ("Digitize", "Digitize vector", "self.runMenuCmd", "v.digit"), ("","","", ""), - ("Create/Rebuild topology", "Create/Rebuild topology", "self.OnMenuCmd", "v.build"), - ("Clean vector files", "clean vector files", "self.OnMenuCmd", "v.clean"), + ("Create/Rebuild topology", "Create/Rebuild topology", "self.runMenuCmd", "v.build"), + ("Clean vector files", "clean vector files", "self.runMenuCmd", "v.clean"), ("","","", ""), - ("Break lines at intersections", "Break lines at intersections", "self.OnMenuCmd", "v.topo.check"), - ("Build polylines from adjacent segments", "Build polylines from adjacent segments", "self.OnMenuCmd", "v.build.polylines"), - ("Split polylines into segments", "Split polylines into segments", "self.OnMenuCmd", "v.segment"), - ("Create lines parallel to existing lines", "Create lines parallel to existing lines", "self.OnMenuCmd", "v.parallel"), + ("Break lines at intersections", "Break lines at intersections", "self.runMenuCmd", "v.topo.check"), + ("Build polylines from adjacent segments", "Build polylines from adjacent segments", "self.runMenuCmd", "v.build.polylines"), + ("Split polylines into segments", "Split polylines into segments", "self.runMenuCmd", "v.segment"), + ("Create lines parallel to existing lines", "Create lines parallel to existing lines", "self.runMenuCmd", "v.parallel"), ("","","", ""), - ("Convert vector feature types", "Convert vector feature types", "self.OnMenuCmd", "v.type"), - ("Convert 2D vector to 3D by sampling raster", "Convert 2D vector to 3D by sampling raster", "self.OnMenuCmd", "v.drape"), - ("Extrude 2D vector into 3D vector", "Extrude 2D vector into 3D vector", "self.OnMenuCmd", "v.extrude"), + ("Convert vector feature types", "Convert vector feature types", "self.runMenuCmd", "v.type"), + ("Convert 2D vector to 3D by sampling raster", "Convert 2D vector to 3D by sampling raster", "self.runMenuCmd", "v.drape"), + ("Extrude 2D vector into 3D vector", "Extrude 2D vector into 3D vector", "self.runMenuCmd", "v.extrude"), ("","","", ""), - ("Create text label file for vector features", "Create text label file for vector features", "self.OnMenuCmd", "v.label"), + ("Create text label file for vector features", "Create text label file for vector features", "self.runMenuCmd", "v.label"), ("","","", ""), - ("Reproject vector from other location", "Reproject vector from other location", "self.OnMenuCmd", "v.proj"), + ("Reproject vector from other location", "Reproject vector from other location", "self.runMenuCmd", "v.proj"), ("","","", "") )), ("","","", ""), ("vector<->database connections", ( - ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), - ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), + ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.runMenuCmd", "v.external"), + ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.runMenuCmd", "v.db.connect"), )), - ("Query by attributes", "Query by attributes", "self.OnMenuCmd", "v.extract"), - ("Query by coordinate(s)", "Query by coordinate(s)", "self.OnMenuCmd", "v.what"), - ("Query by map features", "Query by map features", "self.OnMenuCmd", "v.select"), + ("Query by attributes", "Query by attributes", "self.runMenuCmd", "v.extract"), + ("Query by coordinate(s)", "Query by coordinate(s)", "self.runMenuCmd", "v.what"), + ("Query by map features", "Query by map features", "self.runMenuCmd", "v.select"), ("","","", ""), - ("Create vector buffers", "Create vector buffers", "self.OnMenuCmd", "v.buffer"), + ("Create vector buffers", "Create vector buffers", "self.runMenuCmd", "v.buffer"), ("Linear referencing for vectors", ( - ("Create linear reference system", "Create linear reference system", "self.OnMenuCmd", "v.lrs.create"), - ("Create stationing from input lines, and linear reference system", "Create stationing from input lines, and linear reference system", "self.OnMenuCmd", "v.lrs.label"), - ("Create points/segments from input lines, linear reference system and positions read from stdin", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.OnMenuCmd", "v.lrs.segment"), - ("Find line id and real km+offset for given points in vector map using linear reference system", "Find line id and real km+offset for given points in vector map using linear reference system", "self.OnMenuCmd", "v.lrs.where"), + ("Create linear reference system", "Create linear reference system", "self.runMenuCmd", "v.lrs.create"), + ("Create stationing from input lines, and linear reference system", "Create stationing from input lines, and linear reference system", "self.runMenuCmd", "v.lrs.label"), + ("Create points/segments from input lines, linear reference system and positions read from stdin", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.runMenuCmd", "v.lrs.segment"), + ("Find line id and real km+offset for given points in vector map using linear reference system", "Find line id and real km+offset for given points in vector map using linear reference system", "self.runMenuCmd", "v.lrs.where"), )), ("Neighborhood analysis", ( - ("Locate nearest feature to points or centroids", "Locate nearest feature to points or centroids", "self.OnMenuCmd", "v.distance"), - ("Generate Thiessen polygons around points (Voronoi diagram)", "Generate Thiessen polygons around points (Voronoi diagram)", "self.OnMenuCmd", "v.voronoi"), - ("Connect points to create Delaunay triangles", "Connect points to create Delaunay triangles", "self.OnMenuCmd", "v.delaunay"), + ("Locate nearest feature to points or centroids", "Locate nearest feature to points or centroids", "self.runMenuCmd", "v.distance"), + ("Generate Thiessen polygons around points (Voronoi diagram)", "Generate Thiessen polygons around points (Voronoi diagram)", "self.runMenuCmd", "v.voronoi"), + ("Connect points to create Delaunay triangles", "Connect points to create Delaunay triangles", "self.runMenuCmd", "v.delaunay"), )), ("Network analysis", ( - ("Allocate subnets", "Allocate subnets", "self.OnMenuCmd", "v.net.alloc"), - ("Network maintenance", "Network maintenance", "self.OnMenuCmd", "v.net"), - ("Shortest route", "Shortest route", "self.OnMenuCmd", "v.net.path"), - ("Shortest route (visualization only)", "Shortest route (visualization only)", "self.OnMenuCmd", "d.path"), - ("Split net to bands between cost isolines", "Split net to bands between cost isolines", "self.OnMenuCmd", "v.net.iso"), - ("Steiner tree", "Steiner tree", "self.OnMenuCmd", "v.net.steiner"), - ("Traveling salesman analysis", "Traveling salesman analysis", "self.OnMenuCmd", "v.net.salesman"), + ("Allocate subnets", "Allocate subnets", "self.runMenuCmd", "v.net.alloc"), + ("Network maintenance", "Network maintenance", "self.runMenuCmd", "v.net"), + ("Shortest route", "Shortest route", "self.runMenuCmd", "v.net.path"), + ("Shortest route (visualization only)", "Shortest route (visualization only)", "self.runMenuCmd", "d.path"), + ("Split net to bands between cost isolines", "Split net to bands between cost isolines", "self.runMenuCmd", "v.net.iso"), + ("Steiner tree", "Steiner tree", "self.runMenuCmd", "v.net.steiner"), + ("Traveling salesman analysis", "Traveling salesman analysis", "self.runMenuCmd", "v.net.salesman"), )), ("Overlay maps", ( - ("Overlay/combine 2 vector maps", "Overlay/combine 2 vector maps", "self.OnMenuCmd", "v.overlay"), - ("Patch multiple maps (combine)", "Patch multiple maps (combine)", "self.OnMenuCmd", "v.patch"), + ("Overlay/combine 2 vector maps", "Overlay/combine 2 vector maps", "self.runMenuCmd", "v.overlay"), + ("Patch multiple maps (combine)", "Patch multiple maps (combine)", "self.runMenuCmd", "v.patch"), )), - ("Generate area feature for extent of current region", "Generate area feature for extent of current region", "self.OnMenuCmd", "v.in.region"), - ("Generate rectangular vector grid", "Generate rectangular vector grid", "self.OnMenuCmd", "v.mkgrid"), + ("Generate area feature for extent of current region", "Generate area feature for extent of current region", "self.runMenuCmd", "v.in.region"), + ("Generate rectangular vector grid", "Generate rectangular vector grid", "self.runMenuCmd", "v.mkgrid"), ("","","", ""), ("Change attributes", ( - ("Attach/delete, or report categories", "Attach/delete, or report categories", "self.OnMenuCmd", "v.category"), - ("Reclassify features using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), + ("Attach/delete, or report categories", "Attach/delete, or report categories", "self.runMenuCmd", "v.category"), + ("Reclassify features using rules file", "Reclassify features using rules file", "self.runMenuCmd", "v.reclass"), )), ("","","", ""), ("Work with vector points", ( ("Generate points", ( - ("Generate points from database", "Generate points from database", "self.OnMenuCmd", "v.in.db"), - ("Generate random points", "Generate random points", "self.OnMenuCmd", "v.random"), - ("Random location perturbations of points", "Random location perturbations of points", "self.OnMenuCmd", "v.perturb"), + ("Generate points from database", "Generate points from database", "self.runMenuCmd", "v.in.db"), + ("Generate random points", "Generate random points", "self.runMenuCmd", "v.random"), + ("Random location perturbations of points", "Random location perturbations of points", "self.runMenuCmd", "v.perturb"), )), ("Generate areas from points", ( - ("Generate convex hull for point set", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), - ("Generate Delaunay triangles for point set", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), - ("Generate Voronoi diagram/Thiessen polygons for point set", "Generate Voronoi diagram/Thiessen polygons for point set", "self.OnMenuCmd", "v.voronoi"), + ("Generate convex hull for point set", "Generate convex hull for point set", "self.runMenuCmd", "v.hull"), + ("Generate Delaunay triangles for point set", "Generate Delaunay triangles for point set", "self.runMenuCmd", "v.delaunay"), + ("Generate Voronoi diagram/Thiessen polygons for point set", "Generate Voronoi diagram/Thiessen polygons for point set", "self.runMenuCmd", "v.voronoi"), )), ("Sample raster maps", ( - ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.OnMenuCmd", "v.rast.stats"), - ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.OnMenuCmd", "v.what.rast"), - ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.OnMenuCmd", "v.sample"), + ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.runMenuCmd", "v.rast.stats"), + ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.runMenuCmd", "v.what.rast"), + ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.runMenuCmd", "v.sample"), )), - ("Partition points into test/training sets for k-fold cross validation", "Partition points into test/training sets for k-fold cross validation", "self.OnMenuCmd", "v.kcv"), - ("Transfer attribute data from queried vector map to points", "Transfer attribute data from queried vector map to points", "self.OnMenuCmd", "v.what.vect"), + ("Partition points into test/training sets for k-fold cross validation", "Partition points into test/training sets for k-fold cross validation", "self.runMenuCmd", "v.kcv"), + ("Transfer attribute data from queried vector map to points", "Transfer attribute data from queried vector map to points", "self.runMenuCmd", "v.what.vect"), )), ("","","", ""), ("Reports and statistics", ( - ("Basic information", "Basic information", "self.OnMenuCmd", "v.info"), - ("Load vector attributes to database or create reports", "Load vector attributes to database or create reports", "self.OnMenuCmd", "v.to.db"), - ("Report areas for vector attribute categories", "Report areas for vector attribute categories", "self.OnMenuCmd", "v.report"), - ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "v.univar"), + ("Basic information", "Basic information", "self.runMenuCmd", "v.info"), + ("Load vector attributes to database or create reports", "Load vector attributes to database or create reports", "self.runMenuCmd", "v.to.db"), + ("Report areas for vector attribute categories", "Report areas for vector attribute categories", "self.runMenuCmd", "v.report"), + ("Univariate statistics", "Univariate statistics", "self.runMenuCmd", "v.univar"), ("","","", ""), - ("Test normality of point distribution", "Test normality of point distribution", "self.OnMenuCmd", "v.normal"), - ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.OnMenuCmd", "v.rast.stats"), - ("Indices of point counts in quadrats", "Indices of point counts in quadrats", "self.OnMenuCmd", "v.qcount"), + ("Test normality of point distribution", "Test normality of point distribution", "self.runMenuCmd", "v.normal"), + ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.runMenuCmd", "v.rast.stats"), + ("Indices of point counts in quadrats", "Indices of point counts in quadrats", "self.runMenuCmd", "v.qcount"), )), ("","","", "") )), ("Image", ( ("Develop images and groups", ( - ("Create/edit imagery group", "Create/edit imagery group", "self.OnMenuCmd", "i.group"), - ("Target imagery group", "Target imagery group", "self.OnMenuCmd", "i.target"), + ("Create/edit imagery group", "Create/edit imagery group", "self.runMenuCmd", "i.group"), + ("Target imagery group", "Target imagery group", "self.runMenuCmd", "i.target"), ("","","", ""), - ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.OnMenuCmd", "i.image.mosaic"), + ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.runMenuCmd", "i.image.mosaic"), )), ("Manage image colors", ( - ("Color balance and enhance color tables of multiband imagery for rgb display", "Color balance and enhance color tables of multiband imagery for rgb display", "self.OnMenuCmd", "i.landsat.rgb"), - ("Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "self.OnMenuCmd", "i.his.rgb"), - ("Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "self.OnMenuCmd", "i.rgb.his"), + ("Color auto-balance for rgb", "Color auto-balance for rgb", "self.runMenuCmd", "i.landsat.rgb"), + ("Transform HIS to RGB", "Transform HIS to RGB", "self.runMenuCmd", "i.his.rgb"), + ("Transform RGB to HIS", "Transform RGB to HIS", "self.runMenuCmd", "i.rgb.his"), )), ("Rectify and georeference image group", ( - ("Set ground control points (GCP's) from raster map or keyboard entry", "Set ground control points (GCP's) from raster map or keyboard entry", "self.OnMenuCmd", "i.points"), - ("Set ground control points (GCP's) from vector map or keyboard entry", "Set ground control points (GCP's) from vector map or keyboard entry", "self.OnMenuCmd", "i.vpoints"), - ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.OnMenuCmd", "i.rectify"), - ("Ortho Photo rectification", "Ortho Photo rectification", "self.OnMenuCmd", "i.ortho.photo"), + ("Set GCPs from raster map or keyboard entry", "Set GCPs from raster map or keyboard entry", "self.runMenuCmd", "i.points"), + ("Set GCPs from vector map or keyboard entry", "Set GCPs from vector map or keyboard entry", "self.runMenuCmd", "i.vpoints"), + ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.runMenuCmd", "i.rectify"), + ("Ortho Photo rectification", "Ortho Photo rectification", "self.runMenuCmd", "i.ortho.photo"), )), ("","","", ""), - ("Brovey transformation and pan sharpening", "Brovey transformation and pan sharpening", "self.OnMenuCmd", "i.fusion.brovey"), + ("GIPE", ( + ("DN2Rad2Ref", ( + ("Landsat 7 ETM+", "Landsat 7 ETM+", "self.runMenuCmd", "i.dn2ref.l7"), + ("Landsat 7 ETM+ (from .met)", "Landsat 7 ETM+ (from .met)", "self.runMenuCmd", "i.dn2full.l7"), + ("Terra-Aster", "Terra-Aster", "self.runMenuCmd", "i.dn2ref.ast"), + ("","","", ""), + ("Atmospheric correction", "Atmospheric correction", "self.runMenuCmd", "i.atcorr"), + ("Dehaze Landsat", "Dehaze Landsat", "self.runMenuCmd", "i.landsat.dehaze"), + )), + ("Basic RS processing", ( + ("Vegetation Indices (13 types)", "Vegetation Indices (13 types)", "self.runMenuCmd", "i.vi"), + ("Vegetation Indices (13 types) cluster", "Vegetation Indices (13 types) cluster", "self.runMenuCmd", "i.vi.mpi"), + ("Vegetation Index (Landsat TM Tasseled cap)", "Vegetation Index (Landsat TM Tasseled cap)", "self.runMenuCmd", "i.tasscap"), + ("","","", ""), + ("Albedo", "Albedo", "self.runMenuCmd", "i.albedo"), + ("Emissivity (generic from NDVI)", "Emissivity (generic from NDVI)", "self.runMenuCmd", "i.emissivity"), + ("","","", ""), + ("Latitude map", "Latitude map", "self.runMenuCmd", "i.latitude"), + ("Sunshine hours (potential)", "Sunshine hours (potential)", "self.runMenuCmd", "i.sunhours"), + ("Satellite overpass time", "Satellite overpass time", "self.runMenuCmd", "i.sattime"), + )), + ("","","", ""), + ("ETo, ETP, ETa", ( + ("Reference ET (Hargreaves)", "Reference ET (Hargreaves)", "self.runMenuCmd", "r.evapo.MH"), + ("","","", ""), + ("Potential ET (Penman-Monteith)", "Potential ET (Penman-Monteith)", "self.runMenuCmd", "r.evapo.PM"), + ("Potential ET (Prestley and Taylor)", "Potential ET (Prestley and Taylor)", "self.runMenuCmd", "i.evapo.PT"), + ("Potential ET (Radiative)", "Potential ET (Radiative)", "self.runMenuCmd", "i.evapo.potrad"), + ("Potential ET (Radiative) from L7DN (.met)", "Potential ET (Radiative) from L7DN (.met)", "self.runMenuCmd", "i.dn2potrad.l7"), + ("","","", ""), + ("Actual ET (SEBAL)", "Actual ET (SEBAL)", "self.runMenuCmd", "i.eb.eta"), + ("Actual ET (TSA)", "Actual ET (TSA)", "self.runMenuCmd", "i.evapo.TSA"), + )), + ("Energy Balance", ( + ("Surface roughness", "surface roughness", "self.runMenuCmd", "i.eb.z0m"), + ("Delta T", "delta T", "self.runMenuCmd", "i.eb.deltat"), + ("Net radiation", "net radiation", "self.runMenuCmd", "i.eb.netrad"), + ("","","", ""), + ("Displacement height", "Displacement height", "self.runMenuCmd", "i.eb.disp"), + ("Monin-Obukov Length", "Monin-Obukov Length", "self.runMenuCmd", "i.eb.molength"), + ("Psichrometric param. for heat", "psichrometric param. for heat", "self.runMenuCmd", "i.eb.psi"), + ("Blending height wind speed", "blending height wind speed", "self.runMenuCmd", "i.eb.ublend"), + ("Nominal wind speed", "nominal wind speed", "self.runMenuCmd", "i.eb.ustar"), + ("Aerod. resis. to heat transp.", "aerod. resis. to heat transp.", "self.runMenuCmd", "i.eb.rah"), + ("","","", ""), + ("Soil heat flux", "soil heat flux", "self.runMenuCmd", "i.eb.g0"), + ("Sensible heat flux", "sensible heat flux", "self.runMenuCmd", "i.eb.h0"), + ("Sensible heat flux iteration (fixed delta T)", "sensible heat flux iteration (fixed delta T)", "self.runMenuCmd", "i.eb.h_iter"), + ("","","", ""), + ("Evaporative fraction", "evaporative fraction", "self.runMenuCmd", "i.eb.evapfr"), + )), + ("","","", ""), + ("Biomass", ( + ("Biomass growth", "Biomass growth", "self.runMenuCmd", "i.biomass"), + )), + ("","","", ""), + )), ("Classify image", ( - ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.OnMenuCmd", "i.cluster"), + ("Classify using pr library", ( + ("pr_blob", "pr_blob", "self.runMenuCmd", "i.pr_blob"), + ("pr_classify", "pr_classify", "self.runMenuCmd", "i.pr_classify"), + ("pr_features", "pr_features", "self.runMenuCmd", "i.pr_features"), + ("pr_features_additional", "pr_features_additional", "self.runMenuCmd", "i.pr_features_additional"), + ("pr_features_extract", "pr_features_extract", "self.runMenuCmd", "i.pr_features_extract"), + ("pr_features_selection", "pr_features_selection", "self.runMenuCmd", "i.pr_features_selection"), + ("pr_model", "pr_model", "self.runMenuCmd", "i.pr_model"), + ("pr_sites_aggregate", "pr_sites_aggregate", "self.runMenuCmd", "i.pr_sites_aggregate"), + ("pr_statistics", "pr_statistics", "self.runMenuCmd", "i.pr_statistics"), + ("pr_subsets", "pr_subsets", "self.runMenuCmd", "i.pr_subsets"), + ("pr_training", "pr_training", "self.runMenuCmd", "i.pr_training"), + ("pr_uxb", "pr_uxb", "self.runMenuCmd", "i.pr_uxb"), + )), + ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.runMenuCmd", "i.cluster"), ("","","", ""), - ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.OnMenuCmd", "i.maxlik"), - ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.OnMenuCmd", "i.smap"), + ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.runMenuCmd", "i.maxlik"), + ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.runMenuCmd", "i.smap"), ("","","", ""), - ("Interactive input for supervised classification", "Interactive input for supervised classification", "self.OnMenuCmd", "i.class"), - ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.OnMenuCmd", "i.gensig"), - ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.OnMenuCmd", "i.gensigset"), + ("Interactive input for supervised classification", "Interactive input for supervised classification", "self.runMenuCmd", "i.class"), + ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.runMenuCmd", "i.gensig"), + ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.runMenuCmd", "i.gensigset"), + ("","","", ""), + ("Kappa classification accuracy assessment", "Kappa classification accuracy assessment", "self.runMenuCmd", "r.kappa"), )), + ("Transform image", ( + ("Brovey transformation and pan sharpening", "Brovey transformation and pan sharpening", "self.runMenuCmd", "i.fusion.brovey"), + ("","","", ""), + ("Canonical component", "Canonical component", "self.runMenuCmd", "i.cca"), + ("Principal component", "Principal component", "self.runMenuCmd", "i.pca"), + ("Fast Fourier Transform", "Fast Fourier Transform", "self.runMenuCmd", "i.fft"), + ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.runMenuCmd", "i.ifft"), + )), ("Filter image", ( - ("Zero edge crossing detection", "Zero edge crossing detection", "self.OnMenuCmd", "i.zc"), - ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.OnMenuCmd", "r.mfilter"), + ("Zero edge crossing detection", "Zero edge crossing detection", "self.runMenuCmd", "i.zc"), + ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.runMenuCmd", "r.mfilter"), )), - ("Histogram image", "Histogram image", "self.DispHistogram", ""), - ("Spectral response", "Spectral response", "self.OnMenuCmd", "i.spectral"), - ("Tasseled cap vegetation index", "Tasseled cap vegetation index", "self.OnMenuCmd", "i.tasscap"), - ("Transform image", ( - ("Canonical component", "Canonical component", "self.OnMenuCmd", "i.cca"), - ("Principal component", "Principal component", "self.OnMenuCmd", "i.pca"), - ("Fast Fourier Transform", "Fast Fourier Transform", "self.OnMenuCmd", "i.fft"), - ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.OnMenuCmd", "i.ifft"), + ("","","", ""), + ("Quality Analysis", ( + ("Bit pattern comparison for ID of low quality pixels", "Bit pattern comparison for ID of low quality pixels", "self.runMenuCmd", "r.bitpattern"), + ("Optimum index factor for LandSat TM", "Optimum index factor for LandSat TM", "self.runMenuCmd", "i.oif"), )), + ("Report and statistics", ( + ("Report basic file information", "Report basic file information", "self.runMenuCmd", "r.info"), + ("Range of image values", "Range of image values", "self.runMenuCmd", "r.describe"), + ("Histogram of image values", "Histogram of image values", "self.DispHistogram", ""), + ("Spectral response", "Spectral response", "self.runMenuCmd", "i.spectral"), + )), ("","","", ""), - ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), - ("Range of image values", "Range of image values", "self.OnMenuCmd", "r.describe"), - ("","","", ""), - ("Bit pattern comparison for ID of low quality pixels", "Bit pattern comparison for ID of low quality pixels", "self.OnMenuCmd", "r.bitpattern"), - ("Kappa classification accuracy assessment", "Kappa classification accuracy assessment", "self.OnMenuCmd", "r.kappa"), - ("Optimum index factor for LandSat TM", "Optimum index factor for LandSat TM", "self.OnMenuCmd", "i.oif"), + )), + ("Grid3D", ( + ("Develop grid3D volumes", ( + ("Manage nulls for grid3D volume", "Manage nulls for grid3D volume", "self.runMenuCmd", "r3.null"), + ("Manage timestamp for grid3D volume", "Manage timestamp for grid3D volume", "self.runMenuCmd", "r3.timestamp"), )), - ("","","", "") + ("Create 3D mask for grid3D operations", "Create 3D mask for grid3D operations", "self.runMenuCmd", "r3.mask"), + ("Create 2D raster cross section from grid3d volume", "Create 2D raster cross section from grid3d volume", "self.runMenuCmd", "r3.cross.rast"), + ("Map calculator for grid3D operations", "Map calculator for grid3D operations", "self.runMenuCmd", "r3.mapcalculator"), + ("Interpolate volume from vector points using splines", "Interpolate volume from vector points using splines", "self.runMenuCmd", "v.vol.rst"), + ("","","", ""), + ("Report and Statistics", ( + ("Display information about grid3D volume", "Display information about grid3D volume", "self.runMenuCmd", "r3.info"), + )), + ("","","", ""), )), - ("Database", ( - ("Query", "Query database", "self.Nomethod", ""), - ("","","", "") - )))] + ("Databases", ( + ("Manage database", ( + ("Connect to database", "Connect to database", "self.runMenuCmd", "db.connect"), + ("Login to database", "Login to database", "self.runMenuCmd", "db.login"), + ("","","", ""), + ("Create and add new attribute table to vector map", "Create and add new attribute table to vector map", "self.runMenuCmd", "v.db.addtable"), + ("Copy attribute table", "Copy attribute table", "self.runMenuCmd", "db.copy"), + ("Remove existing attribute table for vector map", "Remove existing attribute table for vector map", "self.runMenuCmd", "v.db.droptable"), + ("","","", ""), + ("Add columns to table", "Add columns to table", "self.runMenuCmd", "v.db.addcol"), + ("Change values in a column", "Change values in a column", "self.runMenuCmd", "v.db.update"), + ("Rename a column", "Rename a column", "self.runMenuCmd", "v.db.renamecol"), + ("","","", ""), + ("Test database", "Test database", "self.runMenuCmd", "db.test"), + )), + ("Database information", ( + ("Describe table", "Describe table", "self.runMenuCmd", "db.describe"), + ("List columns", "List columns", "self.runMenuCmd", "db.columns"), + ("List drivers", "List drivers", "self.runMenuCmd", "db.drivers"), + ("List tables", "List tables", "self.runMenuCmd", "db.tables"), + )), + ("","","", ""), + ("Query", ( + ("Query data in any table", "Query data in any table", "self.runMenuCmd", "db.select"), + ("Query vector attribute data", "Query vector attribute data", "self.runMenuCmd", "db.select"), + ("Execute SQL statement", "Execute SQL statement", "self.runMenuCmd", "db.execute"), + )), + ("Vector<->database connections", ( + ("Reconnect vector map to attribute database", "Reconnect vector map to attribute database", "self.runMenuCmd", "v.db.reconnect.all"), + ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.runMenuCmd", "v.db.connect"), + )), + ("","","", ""), + )), + ("Help", ( + ("GRASS help", "GRASS help", "self.runMenuCmd", "g.manual"), + ("GIS Manager help", "GIS Manager help", "self.runMenuCmd", "GIS Manager help"), + ("About GRASS", "About GRASS", "self.runMenuCmd", "About GRASS"), + ("About System", "About System", "self.runMenuCmd", "About System"), + ("","","", ""), + )), + )] - - - - - - - - - From chemin at grass.itc.it Fri Jun 8 17:20:35 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 17:20:36 2007 Subject: [grass-addons] r806 - trunk/grassaddons/gipe Message-ID: <200706081520.l58FKZgp008646@grass.itc.it> Author: chemin Date: 2007-06-08 17:20:30 +0200 (Fri, 08 Jun 2007) New Revision: 806 Modified: trunk/grassaddons/gipe/gmmenu.tcl Log: restoring menudata.py Modified: trunk/grassaddons/gipe/gmmenu.tcl =================================================================== --- trunk/grassaddons/gipe/gmmenu.tcl 2007-06-08 14:56:12 UTC (rev 805) +++ trunk/grassaddons/gipe/gmmenu.tcl 2007-06-08 15:20:30 UTC (rev 806) @@ -249,17 +249,15 @@ {command {[G_msg "Create color image from RGB files"]} {} "r.composite" {} -command {execute r.composite }} {command {[G_msg "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps"]} {} "r.his" {} -command {execute r.his }} }} + {cascad {[G_msg "Query/Profile"]} {} "" $tmenu { + {command {[G_msg "Query by coordinate(s)"]} {} "r.what" {} -command { execute r.what }} + {command {[G_msg "Profile analysis"]} {} "d.profile" {} -command {guarantee_xmon; execute d.profile }} + }} {separator} - {command {[G_msg "Query by coordinate(s)"]} {} "r.what" {} -command { execute r.what }} - {separator} + {command {[G_msg "Create raster MASK"]} {} "r.mask" {} -command { execute r.mask }} {command {[G_msg "Create raster buffers"]} {} "r.buffer" {} -command { execute r.buffer }} - {command {[G_msg "Create raster MASK"]} {} "r.mask" {} -command { execute r.mask }} - {command {[G_msg "Locate closest points between areas in 2 raster maps"]} {} "r.distance" {} -command { execute r.distance }} {command {[G_msg "Map calculator"]} {} "r.mapcalculator" {} -command { execute r.mapcalculator }} - {cascad {[G_msg "Neighborhood analysis"]} {} "" $tmenu { - {command {[G_msg "Moving window analysis of raster cells"]} {} "r.neighbors" {} -command { execute r.neighbors }} - {command {[G_msg "Analyze vector points in neighborhood of raster cells"]} {} "v.neighbors" {} -command { execute v.neighbors }} - }} + {separator} {cascad {[G_msg "Overlay maps"]} {} "" $tmenu { {command {[G_msg "Cross product"]} {} "r.cross" {} -command {execute r.cross }} {command {[G_msg "Function of map series (time series)"]} {} "r.series" {} -command {execute r.series }} @@ -267,33 +265,19 @@ {separator} {command {[G_msg "Statistical calculations for cover map over base map"]} {} "r.statistics" {} -command {execute r.statistics }} }} - {cascad {[G_msg "Solar radiance and shadows"]} {} "" $tmenu { - {command {[G_msg "Solar irradiance and daily irradiation"]} {} "r.sun" {} -command {execute r.sun }} - {command {[G_msg "Shadows map for sun position or date/time"]} {} "r.sunmask" {} -command {execute r.sunmask }} - }} - {cascad {[G_msg "Terrain analysis"]} {} "" $tmenu { - {command {[G_msg "Calculate cumulative movement costs between locales"]} {} "r.walk" {} -command {execute r.walk }} - {command {[G_msg "Cost surface"]} {} "r.cost" {} -command {execute r.cost }} - {command {[G_msg "Least cost route or flow"]} {} "r.drain" {} -command {execute r.drain }} - {command {[G_msg "Profile analysis"]} {} "d.profile" {} -command {guarantee_xmon; execute d.profile }} - {command {[G_msg "Shaded relief map"]} {} "r.shaded.relief" {} -command {execute r.shaded.relief }} - {command {[G_msg "Slope and aspect"]} {} "r.slope.aspect" {} -command {execute r.slope.aspect }} - {command {[G_msg "Terrain parameters"]} {} "r.param.scale" {} -command {execute r.param.scale }} - {command {[G_msg "Textural features"]} {} "r.texture" {} -command {execute r.texture }} - {command {[G_msg "Visibility/line of sight"]} {} "r.los" {} -command {execute r.los }} - }} {cascad {[G_msg "Transform features"]} {} "" $tmenu { {command {[G_msg "Clump small areas (statistics calculated by r.volume)"]} {} "r.clump" {} -command {execute r.clump }} {command {[G_msg "Grow areas"]} {} "r.grow" {} -command {execute r.grow }} {command {[G_msg "Thin linear features"]} {} "r.thin" {} -command {execute r.thin }} }} + {cascad {[G_msg "Proximity/Neighborhood analysis"]} {} "" $tmenu { + {command {[G_msg "Moving window analysis of raster cells"]} {} "r.neighbors" {} -command { execute r.neighbors }} + {command {[G_msg "Analyze vector points in neighborhood of raster cells"]} {} "v.neighbors" {} -command { execute v.neighbors }} + {separator} + {command {[G_msg "Locate closest points between areas in 2 raster maps"]} {} "r.distance" {} -command { execute r.distance }} + }} {separator} - {cascad {[G_msg "Universal Soil Loss Equation (USLE)"]} {} "" $tmenu { - {command {[G_msg "Rainfall Erosivity (R)"]} {} "r.usler" {} -command {execute r.usler }} - {command {[G_msg "Soil Erodibility (K)"]} {} "r.uslek" {} -command {execute r.uslek }} - {command {[G_msg "Length Slope and Slope (LS)"]} {} "r.watershed" {} -command {execute r.watershed }} - }} - {cascad {[G_msg "Hydrologic modeling"]} {} "" $tmenu { + {cascad {[G_msg " Modeling: Hydrologic"]} {} "" $tmenu { {command {[G_msg "Carve stream channels into elevation map using vector streams map"]} {} "r.carve" {} -command {execute r.carve }} {command {[G_msg "Depressionless elevation map and flowline map"]} {} "r.fill.dir" {} -command {execute r.fill.dir }} {command {[G_msg "Fill lake from seed point to specified level"]} {} "r.lake" {} -command {execute r.lake }} @@ -307,13 +291,34 @@ {command {[G_msg "Watershed analysis"]} {} "r.watershed" {} -command {execute r.watershed }} {command {[G_msg "Watershed basin creation"]} {} "r.water.outlet" {} -command {execute r.water.outlet }} }} - {cascad {[G_msg "Landscape structure modeling"]} {} "" $tmenu { + {cascad {[G_msg "Modeling: Landscape structure"]} {} "" $tmenu { {command {[G_msg "Set up sampling and analysis framework"]} {} "r.le.setup" {} -command {guarantee_xmon; term r.le.setup }} {separator} {command {[G_msg "Analyze landscape characteristics"]} {} "r.le.pixel" {} -command {execute r.le.pixel }} {command {[G_msg "Analyze landscape patch characteristics"]} {} " r.le.patch" {} -command {execute r.le.patch }} {command {[G_msg "Output landscape patch information"]} {} "r.le.trace" {} -command {execute r.le.trace }} }} + {cascad {[G_msg "Modeling: Solar radiance and shadows"]} {} "" $tmenu { + {command {[G_msg "Solar irradiance and daily irradiation"]} {} "r.sun" {} -command {execute r.sun }} + {command {[G_msg "Shadows map for sun position or date/time"]} {} "r.sunmask" {} -command {execute r.sunmask }} + }} + {cascad {[G_msg "Modeling: Terrain and solar"]} {} "" $tmenu { + {command {[G_msg "Calculate cumulative movement costs between locales"]} {} "r.walk" {} -command {execute r.walk }} + {command {[G_msg "Cost surface"]} {} "r.cost" {} -command {execute r.cost }} + {command {[G_msg "Least cost route or flow"]} {} "r.drain" {} -command {execute r.drain }} + {separator} + {command {[G_msg "Shaded relief map"]} {} "r.shaded.relief" {} -command {execute r.shaded.relief }} + {command {[G_msg "Slope and aspect"]} {} "r.slope.aspect" {} -command {execute r.slope.aspect }} + {command {[G_msg "Terrain parameters"]} {} "r.param.scale" {} -command {execute r.param.scale }} + {command {[G_msg "Textural features"]} {} "r.texture" {} -command {execute r.texture }} + {command {[G_msg "Visibility/line of sight"]} {} "r.los" {} -command {execute r.los }} + }} + {separator} + {cascad {[G_msg "Universal Soil Loss Equation (USLE)"]} {} "" $tmenu { + {command {[G_msg "Rainfall Erosivity (R)"]} {} "r.usler" {} -command {execute r.usler }} + {command {[G_msg "Soil Erodibility (K)"]} {} "r.uslek" {} -command {execute r.uslek }} + {command {[G_msg "Length Slope and Slope (LS)"]} {} "r.watershed" {} -command {execute r.watershed }} + }} {cascad {[G_msg "Landscape patch analysis"]} {} "" $tmenu { {command {[G_msg "Configure and create patch map for analysis"]} {} "r.li.setup" {} -command {execute r.li.setup }} {separator} From chemin at grass.itc.it Fri Jun 8 17:22:24 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 17:22:27 2007 Subject: [grass-addons] r807 - trunk/grassaddons/gui/gui_modules Message-ID: <200706081522.l58FMOhq008666@grass.itc.it> Author: chemin Date: 2007-06-08 17:22:15 +0200 (Fri, 08 Jun 2007) New Revision: 807 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: restoring menudata.py? Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-08 15:20:30 UTC (rev 806) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-08 15:22:15 UTC (rev 807) @@ -4,458 +4,441 @@ def GetMenu(self): return [( ("Files", ( - ("Import", "Import files", "self.runMenuCmd", "r.in.gdal"), - ("Export", "Export files", "self.runMenuCmd", "r.out.gdal"), + ("Import", ( + ("Raster map", ( + ("Multiple formats using GDAL", "Import multiple formats using GDAL", "self.OnMenuCmd", "r.in.gdal"), + ("","","", ""), + ("Aggregate ASCII xyz", "Import aggregate ASCII xyz data", "self.OnMenuCmd", "r.in.xyz"), + ("ASCII grid", "Import ASCII GRID (includes GRASS ASCII)", "self.OnMenuCmd", "r.in.ascii"), + ("ASCII polygons and lines", "Import Polygons and lines from ASCII file", "self.OnMenuCmd", "r.in.poly"), + ("","","", ""), + ("Binary", "Import binary file (includes GTOPO30 format)", "self.OnMenuCmd", "r.in.bin"), + ("ESRI Arc/Info ASCII grid", "Import ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.in.arc"), + ("GRIDATB.FOR", "Import GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.in.gridatb"), + ("MAT-File (v.4)", "Import MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.in.mat"), + ("SPOT NDVI", "Import SPOT vegetation NDVI data sets", "self.OnMenuCmd", "r.in.spotvgt"), + ("SRTM HGT", "Import SRTM hgt files", "self.OnMenuCmd", "r.in.srtm"), + ("Terra ASTER HDF", "Import Terra ASTER HDF files", "self.OnMenuCmd", "r.in.aster"), + ("","","", ""), + ("WMS", "Import Web Mapping Server", "self.OnMenuCmd", "r.in.wms"), + )), + ("Vector map", ( + ("Multiple formats using OGR", "Import multiple formats using OGR", "self.OnMenuCmd", "v.in.ogr"), + ("","","", ""), + ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.in.ascii"), + ("Old GRASS vector", "Import old GRASS vector format", "self.OnMenuCmd", "v.convert"), + ("","","", ""), + ("DXF", "Import DXF file", "self.OnMenuCmd", "v.in.dxf"), + ("ESRI e00", "Import ESRI e00 file", "self.OnMenuCmd", "v.in.e00"), + ("Garmin GPS", "Import Garmin GPS Waypoints/Routes/Tracks", "self.OnMenuCmd", "v.in.garmin"), + ("GPSBabel GPS", "Import GPS Waypoints/Routes/Tracks using GPSBabel", "self.OnMenuCmd", "v.in.gpsbabel"), + ("GEOnet", "Import GEOnet Name server country files (US-NGA GNS)", "self.OnMenuCmd", "v.in.gns"), + ("Matlab and MapGen", "Import Matlab and MapGen files", "self.OnMenuCmd", "v.in.mapgen"), + )), + + ("Grid 3D", ( + ("ASCII 3D", "Import ASCII 3D file", "self.OnMenuCmd", "r3.in.ascii"), + ("Vis5D", "Import Vis5D file", "self.OnMenuCmd", "r3.in.v5d"), + )), + )), + ("Export", ( + ("Raster map", ( + ("Multiple formats using GDAL", "Export multiple formats using GDAL", "self.OnMenuCmd", "r.out.gdal"), + ("","","", ""), + ("ASCII grid", "Export ASCII grid (for GRASS, Surfer, Modflow, etc)", "self.OnMenuCmd", "r.out.ascii"), + ("ASCII x,y,z", "Export ASCII x,y,z values of cell centers", "self.OnMenuCmd", "r.out.xyz"), + ("","","", ""), + ("ESRI ASCII grid", "Export ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.out.arc"), + ("GRIDATB.FOR", "Export GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.out.gridatb"), + ("MAT-File (v.4)", "Export MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.out.mat"), + ("","","", ""), + ("Binary", "Export binary file", "self.OnMenuCmd", "r.out.bin"), + ("","","", ""), + ("MPEG-1", "Export MPEG-1 animations", "self.OnMenuCmd", "r.out.mpeg"), + ("PNG", "Export PNG image (not georeferenced)", "self.OnMenuCmd", "r.out.png"), + ("PPM", "Export PPM image (24bit)", "self.OnMenuCmd", "r.out.ppm"), + ("POV-Ray", "Export POVray height-field", "self.OnMenuCmd", "r.out.pov"), + ("TIFF", "Export TIFF image (8/24bit)", "self.OnMenuCmd", "r.out.tiff"), + ("VRML", "Export VRML file", "self.OnMenuCmd", "r.out.vrml"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r.out.vtk"), + )), + ("Vector map", ( + ("Multiple formats using OGR", "Export multiple formats using OGR", "self.OnMenuCmd", "v.out.ogr"), + ("","","", ""), + ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.out.ascii"), + + ("DXF", "Export DXF file", "self.OnMenuCmd", "v.out.dxf"), + ("POV-Ray", "Export POV-Ray format file", "self.OnMenuCmd", "v.out.pov"), + ("SVG", "Export SVG file", "self.OnMenuCmd", "v.out.svg"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "v.out.vtk"), + )), + + ("Grid 3D", ( + ("ASCII 3D", "Export ASCII 3D file", "self.OnMenuCmd", "r3.out.ascii"), + ("Vis5D", "Export Vis5D file", "self.OnMenuCmd", "r3.out.v5d"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r3.out.vtk"), + )), + )), ("","","", ""), - ("E&xit", "Exit from wxgui.py", "self.onCloseWindow", "") + ("Manage maps and volumes", ( + ("Copy", "Copy maps within mapsets or between mapsets", "self.OnMenuCmd", "g.copy"), + ("","","", ""), + ("List", "List maps by type", "self.OnMenuCmd", "list"), + ("List filtered", "List maps filtered by expressions and wildcards", "self.OnMenuCmd", "g.mlist"), + ("","","", ""), + ("Rename", "Rename maps", "self.OnMenuCmd", "g.rename"), + ("","","", ""), + ("Delete", "Delete maps", "self.OnMenuCmd", "g.remove"), + ("Delete filtered", "Delete maps using expressions and wildcards", "self.OnMenuCmd", "g.mremove"), + )), + ("Map type conversions", ( + ("Raster to vector", "Convert raster to vector map", "self.OnMenuCmd", "r.to.vect"), + ("Raster series to volume", "Convert raster map series to volume", "self.OnMenuCmd", "r.to.rast3"), + ("Raster 2.5D to volume", "Convert raster 2.5D map to volume", "self.OnMenuCmd", "r.to.rast3elev"), + ("","","", ""), + ("Vector to raster", "Convert vector to raster map", "self.OnMenuCmd", "v.to.rast"), + ("Vector to volume", "Convert vector 3D points to volume voxels", "self.OnMenuCmd", "v.to.rast3"), + ("Sites to vector", "Convert sites (GRASS 5) to vector map", "self.OnMenuCmd", "v.in.sites"), + ("","","", ""), + ("Volumes to raster series", "Convert raster to vector map", "self.OnMenuCmd", "r3.to.rast"), + )), + ("","","", ""), + ("Georectify (not functional)", "Georectify raster and vector maps", "self.OnGeorectify", ""), + ("","","", ""), + ("Bearing/distance to coordinates", "Convert between bearing/distance and coordinates", "self.OnMenuCmd", "m.cogo"), + ("","","", ""), + ("Postscript plot", "Create cartographic PostScript plot", "self.OnMenuCmd", "ps.map"), + ("","","", ""), + ("E&xit", "Exit from wxgui.py", "self.OnCloseWindow", ""), )), ("Config", ( - ("Region", "Set region", "self.runMenuCmd", "g.region"), - ("","","", ""), - ("Set display font", "Set default font for GRASS displays", "self.DefaultFont", ""), - ("Add a GRASS Extension", "Add a GRASS Extension", "self.runMenuCmd", "scripts/m.gem") + ("Region", ( + ("Display region", "Display region settings", "self.RunMenuCmd", "g.region -p"), + ("Set region", "Change region settings", "self.OnMenuCmd", "g.region"), )), + ("GRASS working environment", ( + ("Mapset access (not functional)", "Set access to other mapsets in current location", "self.OnMapsets", ""), + ("Change working environment", "Change current working session to new mapset, location, or data directory", "self.OnMenuCmd", "g.mapset"), + ("User access", "Change access by other users to current mapset", "self.OnMenuCmd", "g.access"), + ("Show settings", "Show current GRASS environment settings", "self.RunMenuCmd", "g.gisenv "), + ("Change settings", "Change GRASS environment settings", "self.OnMenuCmd", "g.gisenv"), + ("Version", "Show current GRASS version", "self.RunMenuCmd", "g.version -c"), + )), + ("Manage projections", ( + ("Projections", "Show projection information and create projection files", "self.OnMenuCmd", "g.proj"), + ("Convert coordinates", "Convert coordinates from one projection to another", "self.OnMenuCmd", "m.proj"), + )), + ("Display font", "Set default font for GRASS displays", "self.DefaultFont", ""), + )), ("Raster", ( ("Develop map", ( - ("Digitize raster", "Digitize raster", "self.runMenuCmd", "r.digit"), + ("Digitize raster (not functional)", "Digitize raster", "self.OnRDigit", ""), ("","","", ""), - ("Compress/decompress raster file", "Compress/decompress raster file", "self.runMenuCmd", "r.compress"), - ("Manage boundary definition (WHICH COMMAND?)", "Manage boundary definition", "self.runMenuCmd", "r.region"), - ("Manage null values", "Manage null values", "self.runMenuCmd", "r.null"), - ("Manage timestamp for files", "Manage timestamp for files", "self.runMenuCmd", "r.timestamp"), - ("Quantization for floating-point maps", "Quantization for floating-point maps", "self.runMenuCmd", "r.quant"), - ("Resample (change resolution) using nearest neighbor method", "Resample (change resolution) using nearest neighbor method", "self.runMenuCmd", "r.resample"), - ("Resample (change resolution) using regularized spline tension", "Resample (change resolution) using regularized spline tension", "self.runMenuCmd", "r.resamp.rst"), - ("Support file creation and maintenance", "Support file creation and maintenance", "self.runMenuCmd", "r.support.sh"), + ("Compress/decompress raster file", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), + ("Manage boundary definition (WHICH COMMAND?)", "Manage boundary definition", "self.OnMenuCmd", "r.region"), + ("Manage null values", "Manage null values", "self.OnMenuCmd", "r.null"), + ("Manage timestamp for files", "Manage timestamp for files", "self.OnMenuCmd", "r.timestamp"), + ("Quantization for floating-point maps", "Quantization for floating-point maps", "self.OnMenuCmd", "r.quant"), + ("Resample (change resolution) using nearest neighbor method", "Resample (change resolution) using nearest neighbor method", "self.OnMenuCmd", "r.resample"), + ("Resample (change resolution) using regularized spline tension", "Resample (change resolution) using regularized spline tension", "self.OnMenuCmd", "r.resamp.rst"), + ("Support file creation and maintenance", "Support file creation and maintenance", "self.OnMenuCmd", "r.support.sh"), ("","","", ""), - ("Reproject raster from other location", "Reproject raster from other location", "self.runMenuCmd", "r.proj"), - ("Generate tiling for other projection", "Generate tiling for other projection", "self.runMenuCmd", "r.tileset"), + ("Reproject raster from other location", "Reproject raster from other location", "self.OnMenuCmd", "r.proj"), + ("Generate tiling for other projection", "Generate tiling for other projection", "self.OnMenuCmd", "r.tileset"), )), ("Manage map colors", ( - ("Set colors to predefined color tables", "Set colors to predefined color tables", "self.runMenuCmd", "r.colors"), - ("Set colors using color rules", "Set colors using color rules", "self.runMenuCmd", "r.colors.rules"), + ("Set colors to predefined color tables", "Set colors to predefined color tables", "self.OnMenuCmd", "r.colors"), + ("Set colors using color rules", "Set colors using color rules", "self.OnMenuCmd", "r.colors.rules"), ("","","", ""), - ("Blend 2 color maps to produce 3 RGB files", "Blend 2 color maps to produce 3 RGB files", "self.runMenuCmd", "r.blend"), - ("Create color image from RGB files", "Create color image from RGB files", "self.runMenuCmd", "r.composite"), - ("Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.runMenuCmd", "r.his"), + ("Blend 2 color maps to produce 3 RGB files", "Blend 2 color maps to produce 3 RGB files", "self.OnMenuCmd", "r.blend"), + ("Create color image from RGB files", "Create color image from RGB files", "self.OnMenuCmd", "r.composite"), + ("Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.OnMenuCmd", "r.his"), )), - ("Query/Profile", ( - ("Query by coordinates", "Query by coordinates", "self.runMenuCmd", "r.what"), - ("Profile", "Profile of transect", "self.DispProfile", ""), - )), + ("Query by coordinates", "Query by coordinates", "self.OnMenuCmd", "r.what"), ("","","", ""), - ("Create raster MASK", "Develop raster mask", "self.runMenuCmd", "r.mask"), - ("Create raster buffers", "Develop raster buffer", "self.runMenuCmd", "r.buffer"), - ("Map calculator", "Map calculator", "self.runMenuCmd", "scripts/mapcalc_gparser.sh"), - ("","","", ""), + ("Create raster buffers", "Develop raster buffer", "self.OnMenuCmd", "r.buffer"), + ("Create raster MASK", "Develop raster mask", "self.OnMenuCmd", "r.mask"), + ("Locate closest points between areas in 2 raster maps", "r.distance", "self.OnMenuCmd", "r.distance"), + ("Map calculator", "Map calculator", "self.OnMenuCmd", "scripts/mapcalc_gparser.sh"), + ("Neighborhood analysis", ( + ("Moving window analysis of raster cells", "Moving window analysis of raster cells", "self.OnMenuCmd", "r.neighbors"), + ("Analyze vector points in neighborhood of raster cells", "Analyze vector points in neighborhood of raster cells", "self.OnMenuCmd", "v.neighbors"), + )), ("Overlay maps", ( - ("Cross product", "Cross product", "self.runMenuCmd", "r.cross"), - ("Function of map series (time series)", "Function of map series (time series)", "self.runMenuCmd", "r.series"), - ("Patch maps", "Patch maps", "self.runMenuCmd", "r.patch"), + ("Cross product", "Cross product", "self.OnMenuCmd", "r.cross"), + ("Function of map series (time series)", "Function of map series (time series)", "self.OnMenuCmd", "r.series"), + ("Patch maps", "Patch maps", "self.OnMenuCmd", "r.patch"), ("","","", ""), - ("Statistical calculations for cover map over base map", "Statistical calculations for cover map over base map", "self.runMenuCmd", "r.statistics"), + ("Statistical calculations for cover map over base map", "Statistical calculations for cover map over base map", "self.OnMenuCmd", "r.statistics"), )), - ("Transform features", ( - ("Clump small areas (statistics calculated by r.volume)", "Clump small areas (statistics calculated by r.volume)", "self.runMenuCmd", "r.clump"), - ("Grow areas", "Grow areas", "self.runMenuCmd", "r.grow"), - ("Thin linear features", "Thin linear features", "self.runMenuCmd", "r.thin"), + ("Solar radiance and shadows", ( + ("Solar irradiance and daily irradiation", "Solar irradiance and daily irradiation", "self.OnMenuCmd", "r.sun"), + ("Shadow map for sun position or date/time", "Shadow map for sun position or date/time", "self.OnMenuCmd", "r.sunmask"), )), - ("Proximity/Neighborhood analysis", ( - ("Moving window analysis of raster cells", "Moving window analysis of raster cells", "self.runMenuCmd", "r.neighbors"), - ("Analyze vector points in neighborhood of raster cells", "Analyze vector points in neighborhood of raster cells", "self.runMenuCmd", "v.neighbors"), - ("","","", ""), - ("Locate closest points between areas in 2 raster maps", "r.distance", "self.runMenuCmd", "r.distance"), + ("Terrain analysis", ( + ("Calculate cumulative movement costs between locales", "Calculate cumulative movement costs between locales", "self.OnMenuCmd", "r.walk"), + ("cost surface", "cost surface", "self.OnMenuCmd", "r.cost"), + ("Least cost route or flow", "Least cost route or flow", "self.OnMenuCmd", "r.drain"), + ("Shaded relief map", "Shaded relief map", "self.OnMenuCmd", "r.shaded.relief"), + ("Slope and aspect", "Slope and aspect", "self.OnMenuCmd", "r.slope.aspect"), + ("Terrain parameters", "Terrain parameters", "self.OnMenuCmd", "r.param.scale"), + ("Textural features", "Textural features", "self.OnMenuCmd", "r.texture"), + ("Visibility/Line of sight", "Visibility/Line of sight", "self.OnMenuCmd", "r.los"), )), + ("Transform features", ( + ("Clump small areas (statistics calculated by r.volume)", "Clump small areas (statistics calculated by r.volume)", "self.OnMenuCmd", "r.clump"), + ("Grow areas", "Grow areas", "self.OnMenuCmd", "r.grow"), + ("Thin linear features", "Thin linear features", "self.OnMenuCmd", "r.thin"), + )), ("","","", ""), - ("Modeling: Hydrologic", ( - ("Carve stream channels into elevation map using vector streams map", "Carve stream channels into elevation map using vector streams map", "self.runMenuCmd", "r.carve"), - ("Depressionless elevation map and flowline map", "Depressionless elevation map and flowline map", "self.runMenuCmd", "r.fill.dir"), - ("Fill lake from seed point to specified level", "Fill lake from seed point to specified level", "self.runMenuCmd", "r.lake"), - ("Flow accumulation for massive grids (WHICH COMMAND?)", "Flow accumulation for massive grids", "self.runMenuCmd", "r.flow"), - ("Generate flow lines for raster map (WHICH COMMAND?)", "Generate flow lines for raster map", "self.runMenuCmd", "r.flow"), - ("","","", ""), - ("SIMWE overland flow modeling (WHICH COMMAND?)", "SIMWE overland flow modeling", "self.runMenuCmd", "r.simwe"), - ("SIMWE sediment erosion, transport, deposition modeling (WHICH COMMAND?)", "SIMWE sediment erosion, transport, deposition modeling", "self.runMenuCmd", "r.simwe"), - ("Topographic index map", "Topographic index map", "self.runMenuCmd", "r.topidx"), - ("TOPMODEL simulation", "TOPMODEL simulation", "self.runMenuCmd", "r.topmodel"), - ("","","", ""), - ("Watershed subbasins", "Watershed subbasins", "self.runMenuCmd", "r.basins.fill"), - ("Watershed analysis", "Watershed analysis", "self.runMenuCmd", "r.watershed"), - ("Watershed basin creation", "Watershed basin creation", "self.runMenuCmd", "r.water.outlet"), + ("Hydrologic modeling", ( + ("Carve stream channels into elevation map using vector streams map", "Carve stream channels into elevation map using vector streams map", "self.OnMenuCmd", "r.carve"), + ("Depressionless elevation map and flowline map", "Depressionless elevation map and flowline map", "self.OnMenuCmd", "r.fill.dir"), + ("Fill lake from seed point to specified level", "Fill lake from seed point to specified level", "self.OnMenuCmd", "r.lake"), + ("Flow accumulation for massive grids (WHICH COMMAND?)", "Flow accumulation for massive grids", "self.OnMenuCmd", "r.flow"), + ("Generate flow lines for raster map (WHICH COMMAND?)", "Generate flow lines for raster map", "self.OnMenuCmd", "r.flow"), + ("SIMWE overland flow modeling (WHICH COMMAND?)", "SIMWE overland flow modeling", "self.OnMenuCmd", "r.simwe"), + ("SIMWE sediment erosion, transport, deposition modeling (WHICH COMMAND?)", "SIMWE sediment erosion, transport, deposition modeling", "self.OnMenuCmd", "r.simwe"), + ("Topographic index map", "Topographic index map", "self.OnMenuCmd", "r.topidx"), + ("TOPMODEL simulation", "TOPMODEL simulation", "self.OnMenuCmd", "r.topmodel"), + ("Watershed subbasins", "Watershed subbasins", "self.OnMenuCmd", "r.basins.fill"), + ("Watershed analysis", "Watershed analysis", "self.OnMenuCmd", "r.watershed"), + ("Watershed basin creation", "Watershed basin creation", "self.OnMenuCmd", "r.water.outlet"), )), - ("Modeling: Landscape structure", ( - ("Set up sampling and analysis framework", "Set up sampling and analysis framework", "self.runMenuCmd", "r.le.setup"), + ("Landscape structure modeling", ( + ("Set up sampling and analysis framework", "Set up sampling and analysis framework", "self.OnMenuCmd", "r.le.setup"), ("","","", ""), - ("Analyze landscape characteristics", "Analyze landscape characteristics", "self.runMenuCmd", "r.le.pixel"), - ("Analyze landscape patch characteristics", "Analyze landscape patch characteristics", "self.runMenuCmd", "r.le.patch"), - ("Output landscape patch information", "Output landscape patch information", "self.runMenuCmd", "r.le.trace"), + ("Analyze landscape characteristics", "Analyze landscape characteristics", "self.OnMenuCmd", "r.le.pixel"), + ("Analyze landscape patch characteristics", "Analyze landscape patch characteristics", "self.OnMenuCmd", "r.le.patch"), + ("Output landscape patch information", "Output landscape patch information", "self.OnMenuCmd", "r.le.trace"), )), - ("Modeling: Terrain and solar", ( - ("Calculate cumulative movement costs between locales", "Calculate cumulative movement costs between locales", "self.runMenuCmd", "r.walk"), - ("Cost surface", "cost surface", "self.runMenuCmd", "r.cost"), - ("Least cost route or flow", "Least cost route or flow", "self.runMenuCmd", "r.drain"), - ("","","", ""), - ("Shaded relief map", "Shaded relief map", "self.runMenuCmd", "r.shaded.relief"), - ("Slope and aspect", "Slope and aspect", "self.runMenuCmd", "r.slope.aspect"), - ("Terrain parameters", "Terrain parameters", "self.runMenuCmd", "r.param.scale"), - ("","","", ""), - ("Textural features", "Textural features", "self.runMenuCmd", "r.texture"), - ("Visibility/Line of sight", "Visibility/Line of sight", "self.runMenuCmd", "r.los"), - ("","","", ""), - ("Solar irradiance and daily irradiation", "Solar irradiance and daily irradiation", "self.runMenuCmd", "r.sun"), - ("Shadow map for sun position or date/time", "Shadow map for sun position or date/time", "self.runMenuCmd", "r.sunmask"), + ("Wildfire modeling", ( + ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.OnMenuCmd", "r.ros"), + ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.OnMenuCmd", "r.spreadpath"), + ("Simulate anisotropic spread phenomena", "Simulate anisotropic spread phenomena", "self.OnMenuCmd", "r.spread"), )), - ("Modeling: Universal Soil Loss Equation (USLE)", ( - ("Rainfall Erosivity (R)", "Rainfall Erosivity (R)", "self.runMenuCmd", "r.usler"), - ("Soil Erodibility (K)", "Soil Erodibility (K)", "self.runMenuCmd", "r.uslek"), - ("Length Slope and Slope (LS)", "Length Slope and Slope (LS)", "self.runMenuCmd", "r.watershed"), - ("","","", ""), - )), - ("Modeling: Wildfire", ( - ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.runMenuCmd", "r.ros"), - ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.runMenuCmd", "r.spreadpath"), - ("Simulate anisotropic spread phenomena", "Simulate anisotropic spread phenomena", "self.runMenuCmd", "r.spread"), - )), ("","","", ""), ("Change category values and labels", ( - ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.runMenuCmd", "d.rast.edit"), + ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.OnMenuCmd", "d.rast.edit"), ("","","", ""), - ("Reclassify categories for areas of specified sizes", "Reclassify categories for areas of specified sizes", "self.runMenuCmd", "r.reclass.area"), - ("Reclassify categories using rules", "Reclassify categories using rules", "self.runMenuCmd", "r.reclass.rules"), - ("Reclassify categories using rules file", "Reclassify categories using rules file", "self.runMenuCmd", "r.reclass.file"), + ("Reclassify categories for areas of specified sizes", "Reclassify categories for areas of specified sizes", "self.OnMenuCmd", "r.reclass.area"), + ("Reclassify categories using rules", "Reclassify categories using rules", "self.OnMenuCmd", "r.reclass.rules"), + ("Reclassify categories using rules file", "Reclassify categories using rules file", "self.OnMenuCmd", "r.reclass.file"), ("","","", ""), - ("Recode categories using rules (create new map)", "Recode categories using rules (create new map)", "self.runMenuCmd", "r.recode.rules"), - ("Recode categories using rules file (create new map)", "Recode categories using rules file (create new map)", "self.runMenuCmd", "r.recode.file"), + ("Recode categories using rules (create new map)", "Recode categories using rules (create new map)", "self.OnMenuCmd", "r.recode.rules"), + ("Recode categories using rules file (create new map)", "Recode categories using rules file (create new map)", "self.OnMenuCmd", "r.recode.file"), ("","","", ""), - ("Rescale categories (create new map)", "Rescale categories (create new map)", "self.runMenuCmd", "r.rescale"), - ("Rescale categories with equalized histogram (create new map)", "Rescale categories with equalized histogram (create new map)", "self.runMenuCmd", "r.rescale.eq"), + ("Rescale categories (create new map)", "Rescale categories (create new map)", "self.OnMenuCmd", "r.rescale"), + ("Rescale categories with equalized histogram (create new map)", "Rescale categories with equalized histogram (create new map)", "self.OnMenuCmd", "r.rescale.eq"), )), ("","","", ""), - ("Generate", ( - ("Concentric circles around points", "Concentric circles around points", "self.runMenuCmd", "r.circle"), - ("Density surface using moving Gaussian kernel", "Density surface using moving Gaussian kernel", "self.runMenuCmd", "v.kernel"), - ("Fractal surface", "Fractal surface", "self.runMenuCmd", "r.surf.fractal"), - ("Gaussian deviates surface", "Gaussian deviates surface", "self.runMenuCmd", "r.surf.gauss"), - ("Plane", "Plane", "self.runMenuCmd", "r.plane"), - ("","","", ""), - ("Random cells", "Random cells", "self.runMenuCmd", "r.random.cells"), - ("Random cells and vector points from raster map", "Random cells and vector points from raster map", "self.runMenuCmd", "r.random"), - ("Random deviates surface", "Random deviates surface", "self.runMenuCmd", "r.surf.random"), - ("Random surface with spatial dependence", "Random surface with spatial dependence", "self.runMenuCmd", "r.random.surface"), - ("","","", ""), - ("Vector contour lines", "Vector contour lines", "self.runMenuCmd", "r.contour"), - )), + ("Generate concentric circles around points", "Generate concentric circles around points", "self.OnMenuCmd", "r.circle"), + ("Generate random raster cells", ( + ("Generate random cells", "Generate random cells", "self.OnMenuCmd", "r.random.cells"), + ("Generate random cells and vector points from raster map", "Generate random cells and vector points from raster map", "self.OnMenuCmd", "r.random"), + )), + ("Generate surfaces", ( + ("Generate density surface using moving Gaussian kernel", "Generate density surface using moving Gaussian kernel", "self.OnMenuCmd", "v.kernel"), + ("Generate fractal surface", "Generate fractal surface", "self.OnMenuCmd", "r.surf.fractal"), + ("Generate gaussian deviates surface", "Generate gaussian deviates surface", "self.OnMenuCmd", "r.surf.gauss"), + ("Generate plane", "Generate plane", "self.OnMenuCmd", "r.plane"), + ("Generate random deviates surface", "Generate random deviates surface", "self.OnMenuCmd", "r.surf.random"), + ("Generate random surface with spatial dependence", "Generate random surface with spatial dependence", "self.OnMenuCmd", "r.random.surface"), + )), + ("Generate vector contour lines", "Generate vector contour lines", "self.OnMenuCmd", "r.contour"), ("Interpolate surfaces", ( - ("Bilinear (from raster points)", "Bilinear (from raster points)", "self.runMenuCmd", "r.bilinear"), - ("Inverse distance weighted (from raster points)", "Inverse distance weighted (from raster points)", "self.runMenuCmd", "r.surf.idw"), - ("From raster contour", "From raster contour", "self.runMenuCmd", "r.surf.contour"), + ("Bilinear interpolation from raster points", "Bilinear interpolation from raster points", "self.OnMenuCmd", "r.bilinear"), + ("Inverse distance weighted interpolation from raster points", "Inverse distance weighted interpolation from raster points", "self.OnMenuCmd", "r.surf.idw"), + ("Interpolation from raster contour", "Interpolation from raster contour", "self.OnMenuCmd", "r.surf.contour"), ("","","", ""), - ("Inverse distance weighted (from vector points)", "Inverse distance weighted (from vector points)", "self.runMenuCmd", "v.surf.idw"), - ("Regularized spline tension (from vector points/contours) (WHICH COMMAND ?)", "Regularized spline tension (from vector points/contours)", "self.runMenuCmd", "v.surf.rst"), + ("Inverse distance weighted interpolation from vector points", "Inverse distance weighted interpolation from vector points", "self.OnMenuCmd", "v.surf.idw"), + ("Regularized spline tension interpolation from vector points or contours (WHICH COMMAND ?)", "Regularized spline tension interpolation from vector points or contours", "self.OnMenuCmd", "v.surf.rst"), ("","","", ""), - ("Fill NULL cells using regularized spline tension", "Fill NULL cells using regularized spline tension", "self.runMenuCmd", "r.fillnulls"), + ("Fill NULL cells by interpolation using regularized spline tension", "Fill NULL cells by interpolation using regularized spline tension", "self.OnMenuCmd", "r.fillnulls"), )), ("","","", ""), ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.runMenuCmd", "r.info"), - ("Report category labels and values", "Report category labels and values", "self.runMenuCmd", "r.cats"), + ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), + ("Report category labels and values", "Report category labels and values", "self.OnMenuCmd", "r.cats"), ("","","", ""), - ("General statistics", "General statistics", "self.runMenuCmd", "r.stats"), - ("Range of all category values", "Range of all category values", "self.runMenuCmd", "r.describe"), + ("General statistics", "General statistics", "self.OnMenuCmd", "r.stats"), + ("Range of all category values", "Range of all category values", "self.OnMenuCmd", "r.describe"), + ("Sum all cell category values", "Sum all cell category values", "self.OnMenuCmd", "r.sum"), + ("Sum area by map and category", "Sum area by map and category", "self.OnMenuCmd", "r.report"), + ("Summary statistics for clumped cells (work with r.clump)", "Summary statistics for clumped cells (work with r.clump)", "self.OnMenuCmd", "r.volume"), + ("Total surface area corrected for topography", "Total surface area corrected for topography", "self.OnMenuCmd", "r.surf.area"), + ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "r.univar"), + ("Univariate statistics (script version)", "Univariate statistics (script version)", "self.OnMenuCmd", "r.univar.sh"), ("","","", ""), - ("Sum all cell category values", "Sum all cell category values", "self.runMenuCmd", "r.sum"), - ("Sum area by map and category", "Sum area by map and category", "self.runMenuCmd", "r.report"), - ("Summary statistics for clumped cells (work with r.clump)", "Summary statistics for clumped cells (work with r.clump)", "self.runMenuCmd", "r.volume"), + ("Sample values along transects", "Sample values along transects", "self.OnMenuCmd", "r.profile"), + ("Sample values along transects (use azimuth, distance)", "Sample values along transects (use azimuth, distance)", "self.OnMenuCmd", "r.transect"), ("","","", ""), - ("Total surface area corrected for topography", "Total surface area corrected for topography", "self.runMenuCmd", "r.surf.area"), - ("Univariate statistics", "Univariate statistics", "self.runMenuCmd", "r.univar"), - ("Univariate statistics (script version)", "Univariate statistics (script version)", "self.runMenuCmd", "r.univar.sh"), - ("","","", ""), - ("Sample values along transects", "Sample values along transects", "self.runMenuCmd", "r.profile"), - ("Sample values along transects (use azimuth, distance)", "Sample values along transects (use azimuth, distance)", "self.runMenuCmd", "r.transect"), - ("","","", ""), - ("Covariance/correlation", "Covariance/correlation", "self.runMenuCmd", "r.covar"), - ("Linear regression between 2 maps", "Linear regression between 2 maps", "self.runMenuCmd", "r.regression.line"), - ("Mutual category occurrences (coincidence)", "Mutual category occurrences (coincidence)", "self.runMenuCmd", "r.coin"), + ("Covariance/correlation", "Covariance/correlation", "self.OnMenuCmd", "r.covar"), + ("Linear regression between 2 maps", "Linear regression between 2 maps", "self.OnMenuCmd", "r.regression.line"), + ("Mutual category occurrences (coincidence)", "Mutual category occurrences (coincidence)", "self.OnMenuCmd", "r.coin"), )), ("","","", "") )), ("Vector", ( ("Develop map", ( - ("Digitize", "Digitize vector", "self.runMenuCmd", "v.digit"), + ("Digitize", "Digitize vector", "self.OnMenuCmd", "v.digit"), ("","","", ""), - ("Create/Rebuild topology", "Create/Rebuild topology", "self.runMenuCmd", "v.build"), - ("Clean vector files", "clean vector files", "self.runMenuCmd", "v.clean"), + ("Create/Rebuild topology", "Create/Rebuild topology", "self.OnMenuCmd", "v.build"), + ("Clean vector files", "clean vector files", "self.OnMenuCmd", "v.clean"), ("","","", ""), - ("Break lines at intersections", "Break lines at intersections", "self.runMenuCmd", "v.topo.check"), - ("Build polylines from adjacent segments", "Build polylines from adjacent segments", "self.runMenuCmd", "v.build.polylines"), - ("Split polylines into segments", "Split polylines into segments", "self.runMenuCmd", "v.segment"), - ("Create lines parallel to existing lines", "Create lines parallel to existing lines", "self.runMenuCmd", "v.parallel"), + ("Break lines at intersections", "Break lines at intersections", "self.OnMenuCmd", "v.topo.check"), + ("Build polylines from adjacent segments", "Build polylines from adjacent segments", "self.OnMenuCmd", "v.build.polylines"), + ("Split polylines into segments", "Split polylines into segments", "self.OnMenuCmd", "v.segment"), + ("Create lines parallel to existing lines", "Create lines parallel to existing lines", "self.OnMenuCmd", "v.parallel"), ("","","", ""), - ("Convert vector feature types", "Convert vector feature types", "self.runMenuCmd", "v.type"), - ("Convert 2D vector to 3D by sampling raster", "Convert 2D vector to 3D by sampling raster", "self.runMenuCmd", "v.drape"), - ("Extrude 2D vector into 3D vector", "Extrude 2D vector into 3D vector", "self.runMenuCmd", "v.extrude"), + ("Convert vector feature types", "Convert vector feature types", "self.OnMenuCmd", "v.type"), + ("Convert 2D vector to 3D by sampling raster", "Convert 2D vector to 3D by sampling raster", "self.OnMenuCmd", "v.drape"), + ("Extrude 2D vector into 3D vector", "Extrude 2D vector into 3D vector", "self.OnMenuCmd", "v.extrude"), ("","","", ""), - ("Create text label file for vector features", "Create text label file for vector features", "self.runMenuCmd", "v.label"), + ("Create text label file for vector features", "Create text label file for vector features", "self.OnMenuCmd", "v.label"), ("","","", ""), - ("Reproject vector from other location", "Reproject vector from other location", "self.runMenuCmd", "v.proj"), + ("Reproject vector from other location", "Reproject vector from other location", "self.OnMenuCmd", "v.proj"), ("","","", "") )), ("","","", ""), ("vector<->database connections", ( - ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.runMenuCmd", "v.external"), - ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.runMenuCmd", "v.db.connect"), + ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), + ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), )), - ("Query by attributes", "Query by attributes", "self.runMenuCmd", "v.extract"), - ("Query by coordinate(s)", "Query by coordinate(s)", "self.runMenuCmd", "v.what"), - ("Query by map features", "Query by map features", "self.runMenuCmd", "v.select"), + ("Query by attributes", "Query by attributes", "self.OnMenuCmd", "v.extract"), + ("Query by coordinate(s)", "Query by coordinate(s)", "self.OnMenuCmd", "v.what"), + ("Query by map features", "Query by map features", "self.OnMenuCmd", "v.select"), ("","","", ""), - ("Create vector buffers", "Create vector buffers", "self.runMenuCmd", "v.buffer"), + ("Create vector buffers", "Create vector buffers", "self.OnMenuCmd", "v.buffer"), ("Linear referencing for vectors", ( - ("Create linear reference system", "Create linear reference system", "self.runMenuCmd", "v.lrs.create"), - ("Create stationing from input lines, and linear reference system", "Create stationing from input lines, and linear reference system", "self.runMenuCmd", "v.lrs.label"), - ("Create points/segments from input lines, linear reference system and positions read from stdin", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.runMenuCmd", "v.lrs.segment"), - ("Find line id and real km+offset for given points in vector map using linear reference system", "Find line id and real km+offset for given points in vector map using linear reference system", "self.runMenuCmd", "v.lrs.where"), + ("Create linear reference system", "Create linear reference system", "self.OnMenuCmd", "v.lrs.create"), + ("Create stationing from input lines, and linear reference system", "Create stationing from input lines, and linear reference system", "self.OnMenuCmd", "v.lrs.label"), + ("Create points/segments from input lines, linear reference system and positions read from stdin", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.OnMenuCmd", "v.lrs.segment"), + ("Find line id and real km+offset for given points in vector map using linear reference system", "Find line id and real km+offset for given points in vector map using linear reference system", "self.OnMenuCmd", "v.lrs.where"), )), ("Neighborhood analysis", ( - ("Locate nearest feature to points or centroids", "Locate nearest feature to points or centroids", "self.runMenuCmd", "v.distance"), - ("Generate Thiessen polygons around points (Voronoi diagram)", "Generate Thiessen polygons around points (Voronoi diagram)", "self.runMenuCmd", "v.voronoi"), - ("Connect points to create Delaunay triangles", "Connect points to create Delaunay triangles", "self.runMenuCmd", "v.delaunay"), + ("Locate nearest feature to points or centroids", "Locate nearest feature to points or centroids", "self.OnMenuCmd", "v.distance"), + ("Generate Thiessen polygons around points (Voronoi diagram)", "Generate Thiessen polygons around points (Voronoi diagram)", "self.OnMenuCmd", "v.voronoi"), + ("Connect points to create Delaunay triangles", "Connect points to create Delaunay triangles", "self.OnMenuCmd", "v.delaunay"), )), ("Network analysis", ( - ("Allocate subnets", "Allocate subnets", "self.runMenuCmd", "v.net.alloc"), - ("Network maintenance", "Network maintenance", "self.runMenuCmd", "v.net"), - ("Shortest route", "Shortest route", "self.runMenuCmd", "v.net.path"), - ("Shortest route (visualization only)", "Shortest route (visualization only)", "self.runMenuCmd", "d.path"), - ("Split net to bands between cost isolines", "Split net to bands between cost isolines", "self.runMenuCmd", "v.net.iso"), - ("Steiner tree", "Steiner tree", "self.runMenuCmd", "v.net.steiner"), - ("Traveling salesman analysis", "Traveling salesman analysis", "self.runMenuCmd", "v.net.salesman"), + ("Allocate subnets", "Allocate subnets", "self.OnMenuCmd", "v.net.alloc"), + ("Network maintenance", "Network maintenance", "self.OnMenuCmd", "v.net"), + ("Shortest route", "Shortest route", "self.OnMenuCmd", "v.net.path"), + ("Shortest route (visualization only)", "Shortest route (visualization only)", "self.OnMenuCmd", "d.path"), + ("Split net to bands between cost isolines", "Split net to bands between cost isolines", "self.OnMenuCmd", "v.net.iso"), + ("Steiner tree", "Steiner tree", "self.OnMenuCmd", "v.net.steiner"), + ("Traveling salesman analysis", "Traveling salesman analysis", "self.OnMenuCmd", "v.net.salesman"), )), ("Overlay maps", ( - ("Overlay/combine 2 vector maps", "Overlay/combine 2 vector maps", "self.runMenuCmd", "v.overlay"), - ("Patch multiple maps (combine)", "Patch multiple maps (combine)", "self.runMenuCmd", "v.patch"), + ("Overlay/combine 2 vector maps", "Overlay/combine 2 vector maps", "self.OnMenuCmd", "v.overlay"), + ("Patch multiple maps (combine)", "Patch multiple maps (combine)", "self.OnMenuCmd", "v.patch"), )), - ("Generate area feature for extent of current region", "Generate area feature for extent of current region", "self.runMenuCmd", "v.in.region"), - ("Generate rectangular vector grid", "Generate rectangular vector grid", "self.runMenuCmd", "v.mkgrid"), + ("Generate area feature for extent of current region", "Generate area feature for extent of current region", "self.OnMenuCmd", "v.in.region"), + ("Generate rectangular vector grid", "Generate rectangular vector grid", "self.OnMenuCmd", "v.mkgrid"), ("","","", ""), ("Change attributes", ( - ("Attach/delete, or report categories", "Attach/delete, or report categories", "self.runMenuCmd", "v.category"), - ("Reclassify features using rules file", "Reclassify features using rules file", "self.runMenuCmd", "v.reclass"), + ("Attach/delete, or report categories", "Attach/delete, or report categories", "self.OnMenuCmd", "v.category"), + ("Reclassify features using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), )), ("","","", ""), ("Work with vector points", ( ("Generate points", ( - ("Generate points from database", "Generate points from database", "self.runMenuCmd", "v.in.db"), - ("Generate random points", "Generate random points", "self.runMenuCmd", "v.random"), - ("Random location perturbations of points", "Random location perturbations of points", "self.runMenuCmd", "v.perturb"), + ("Generate points from database", "Generate points from database", "self.OnMenuCmd", "v.in.db"), + ("Generate random points", "Generate random points", "self.OnMenuCmd", "v.random"), + ("Random location perturbations of points", "Random location perturbations of points", "self.OnMenuCmd", "v.perturb"), )), ("Generate areas from points", ( - ("Generate convex hull for point set", "Generate convex hull for point set", "self.runMenuCmd", "v.hull"), - ("Generate Delaunay triangles for point set", "Generate Delaunay triangles for point set", "self.runMenuCmd", "v.delaunay"), - ("Generate Voronoi diagram/Thiessen polygons for point set", "Generate Voronoi diagram/Thiessen polygons for point set", "self.runMenuCmd", "v.voronoi"), + ("Generate convex hull for point set", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), + ("Generate Delaunay triangles for point set", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), + ("Generate Voronoi diagram/Thiessen polygons for point set", "Generate Voronoi diagram/Thiessen polygons for point set", "self.OnMenuCmd", "v.voronoi"), )), ("Sample raster maps", ( - ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.runMenuCmd", "v.rast.stats"), - ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.runMenuCmd", "v.what.rast"), - ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.runMenuCmd", "v.sample"), + ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.OnMenuCmd", "v.rast.stats"), + ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.OnMenuCmd", "v.what.rast"), + ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.OnMenuCmd", "v.sample"), )), - ("Partition points into test/training sets for k-fold cross validation", "Partition points into test/training sets for k-fold cross validation", "self.runMenuCmd", "v.kcv"), - ("Transfer attribute data from queried vector map to points", "Transfer attribute data from queried vector map to points", "self.runMenuCmd", "v.what.vect"), + ("Partition points into test/training sets for k-fold cross validation", "Partition points into test/training sets for k-fold cross validation", "self.OnMenuCmd", "v.kcv"), + ("Transfer attribute data from queried vector map to points", "Transfer attribute data from queried vector map to points", "self.OnMenuCmd", "v.what.vect"), )), ("","","", ""), ("Reports and statistics", ( - ("Basic information", "Basic information", "self.runMenuCmd", "v.info"), - ("Load vector attributes to database or create reports", "Load vector attributes to database or create reports", "self.runMenuCmd", "v.to.db"), - ("Report areas for vector attribute categories", "Report areas for vector attribute categories", "self.runMenuCmd", "v.report"), - ("Univariate statistics", "Univariate statistics", "self.runMenuCmd", "v.univar"), + ("Basic information", "Basic information", "self.OnMenuCmd", "v.info"), + ("Load vector attributes to database or create reports", "Load vector attributes to database or create reports", "self.OnMenuCmd", "v.to.db"), + ("Report areas for vector attribute categories", "Report areas for vector attribute categories", "self.OnMenuCmd", "v.report"), + ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "v.univar"), ("","","", ""), - ("Test normality of point distribution", "Test normality of point distribution", "self.runMenuCmd", "v.normal"), - ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.runMenuCmd", "v.rast.stats"), - ("Indices of point counts in quadrats", "Indices of point counts in quadrats", "self.runMenuCmd", "v.qcount"), + ("Test normality of point distribution", "Test normality of point distribution", "self.OnMenuCmd", "v.normal"), + ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.OnMenuCmd", "v.rast.stats"), + ("Indices of point counts in quadrats", "Indices of point counts in quadrats", "self.OnMenuCmd", "v.qcount"), )), ("","","", "") )), ("Image", ( ("Develop images and groups", ( - ("Create/edit imagery group", "Create/edit imagery group", "self.runMenuCmd", "i.group"), - ("Target imagery group", "Target imagery group", "self.runMenuCmd", "i.target"), + ("Create/edit imagery group", "Create/edit imagery group", "self.OnMenuCmd", "i.group"), + ("Target imagery group", "Target imagery group", "self.OnMenuCmd", "i.target"), ("","","", ""), - ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.runMenuCmd", "i.image.mosaic"), + ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.OnMenuCmd", "i.image.mosaic"), )), ("Manage image colors", ( - ("Color auto-balance for rgb", "Color auto-balance for rgb", "self.runMenuCmd", "i.landsat.rgb"), - ("Transform HIS to RGB", "Transform HIS to RGB", "self.runMenuCmd", "i.his.rgb"), - ("Transform RGB to HIS", "Transform RGB to HIS", "self.runMenuCmd", "i.rgb.his"), + ("Color balance and enhance color tables of multiband imagery for rgb display", "Color balance and enhance color tables of multiband imagery for rgb display", "self.OnMenuCmd", "i.landsat.rgb"), + ("Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "self.OnMenuCmd", "i.his.rgb"), + ("Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "self.OnMenuCmd", "i.rgb.his"), )), ("Rectify and georeference image group", ( - ("Set GCPs from raster map or keyboard entry", "Set GCPs from raster map or keyboard entry", "self.runMenuCmd", "i.points"), - ("Set GCPs from vector map or keyboard entry", "Set GCPs from vector map or keyboard entry", "self.runMenuCmd", "i.vpoints"), - ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.runMenuCmd", "i.rectify"), - ("Ortho Photo rectification", "Ortho Photo rectification", "self.runMenuCmd", "i.ortho.photo"), + ("Set ground control points (GCP's) from raster map or keyboard entry", "Set ground control points (GCP's) from raster map or keyboard entry", "self.OnMenuCmd", "i.points"), + ("Set ground control points (GCP's) from vector map or keyboard entry", "Set ground control points (GCP's) from vector map or keyboard entry", "self.OnMenuCmd", "i.vpoints"), + ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.OnMenuCmd", "i.rectify"), + ("Ortho Photo rectification", "Ortho Photo rectification", "self.OnMenuCmd", "i.ortho.photo"), )), ("","","", ""), - ("GIPE", ( - ("DN2Rad2Ref", ( - ("Landsat 7 ETM+", "Landsat 7 ETM+", "self.runMenuCmd", "i.dn2ref.l7"), - ("Landsat 7 ETM+ (from .met)", "Landsat 7 ETM+ (from .met)", "self.runMenuCmd", "i.dn2full.l7"), - ("Terra-Aster", "Terra-Aster", "self.runMenuCmd", "i.dn2ref.ast"), - ("","","", ""), - ("Atmospheric correction", "Atmospheric correction", "self.runMenuCmd", "i.atcorr"), - ("Dehaze Landsat", "Dehaze Landsat", "self.runMenuCmd", "i.landsat.dehaze"), - )), - ("Basic RS processing", ( - ("Vegetation Indices (13 types)", "Vegetation Indices (13 types)", "self.runMenuCmd", "i.vi"), - ("Vegetation Indices (13 types) cluster", "Vegetation Indices (13 types) cluster", "self.runMenuCmd", "i.vi.mpi"), - ("Vegetation Index (Landsat TM Tasseled cap)", "Vegetation Index (Landsat TM Tasseled cap)", "self.runMenuCmd", "i.tasscap"), - ("","","", ""), - ("Albedo", "Albedo", "self.runMenuCmd", "i.albedo"), - ("Emissivity (generic from NDVI)", "Emissivity (generic from NDVI)", "self.runMenuCmd", "i.emissivity"), - ("","","", ""), - ("Latitude map", "Latitude map", "self.runMenuCmd", "i.latitude"), - ("Sunshine hours (potential)", "Sunshine hours (potential)", "self.runMenuCmd", "i.sunhours"), - ("Satellite overpass time", "Satellite overpass time", "self.runMenuCmd", "i.sattime"), - )), - ("","","", ""), - ("ETo, ETP, ETa", ( - ("Reference ET (Hargreaves)", "Reference ET (Hargreaves)", "self.runMenuCmd", "r.evapo.MH"), - ("","","", ""), - ("Potential ET (Penman-Monteith)", "Potential ET (Penman-Monteith)", "self.runMenuCmd", "r.evapo.PM"), - ("Potential ET (Prestley and Taylor)", "Potential ET (Prestley and Taylor)", "self.runMenuCmd", "i.evapo.PT"), - ("Potential ET (Radiative)", "Potential ET (Radiative)", "self.runMenuCmd", "i.evapo.potrad"), - ("Potential ET (Radiative) from L7DN (.met)", "Potential ET (Radiative) from L7DN (.met)", "self.runMenuCmd", "i.dn2potrad.l7"), - ("","","", ""), - ("Actual ET (SEBAL)", "Actual ET (SEBAL)", "self.runMenuCmd", "i.eb.eta"), - ("Actual ET (TSA)", "Actual ET (TSA)", "self.runMenuCmd", "i.evapo.TSA"), - )), - ("Energy Balance", ( - ("Surface roughness", "surface roughness", "self.runMenuCmd", "i.eb.z0m"), - ("Delta T", "delta T", "self.runMenuCmd", "i.eb.deltat"), - ("Net radiation", "net radiation", "self.runMenuCmd", "i.eb.netrad"), - ("","","", ""), - ("Displacement height", "Displacement height", "self.runMenuCmd", "i.eb.disp"), - ("Monin-Obukov Length", "Monin-Obukov Length", "self.runMenuCmd", "i.eb.molength"), - ("Psichrometric param. for heat", "psichrometric param. for heat", "self.runMenuCmd", "i.eb.psi"), - ("Blending height wind speed", "blending height wind speed", "self.runMenuCmd", "i.eb.ublend"), - ("Nominal wind speed", "nominal wind speed", "self.runMenuCmd", "i.eb.ustar"), - ("Aerod. resis. to heat transp.", "aerod. resis. to heat transp.", "self.runMenuCmd", "i.eb.rah"), - ("","","", ""), - ("Soil heat flux", "soil heat flux", "self.runMenuCmd", "i.eb.g0"), - ("Sensible heat flux", "sensible heat flux", "self.runMenuCmd", "i.eb.h0"), - ("Sensible heat flux iteration (fixed delta T)", "sensible heat flux iteration (fixed delta T)", "self.runMenuCmd", "i.eb.h_iter"), - ("","","", ""), - ("Evaporative fraction", "evaporative fraction", "self.runMenuCmd", "i.eb.evapfr"), - )), - ("","","", ""), - ("Biomass", ( - ("Biomass growth", "Biomass growth", "self.runMenuCmd", "i.biomass"), - )), - ("","","", ""), - )), + ("Brovey transformation and pan sharpening", "Brovey transformation and pan sharpening", "self.OnMenuCmd", "i.fusion.brovey"), ("Classify image", ( - ("Classify using pr library", ( - ("pr_blob", "pr_blob", "self.runMenuCmd", "i.pr_blob"), - ("pr_classify", "pr_classify", "self.runMenuCmd", "i.pr_classify"), - ("pr_features", "pr_features", "self.runMenuCmd", "i.pr_features"), - ("pr_features_additional", "pr_features_additional", "self.runMenuCmd", "i.pr_features_additional"), - ("pr_features_extract", "pr_features_extract", "self.runMenuCmd", "i.pr_features_extract"), - ("pr_features_selection", "pr_features_selection", "self.runMenuCmd", "i.pr_features_selection"), - ("pr_model", "pr_model", "self.runMenuCmd", "i.pr_model"), - ("pr_sites_aggregate", "pr_sites_aggregate", "self.runMenuCmd", "i.pr_sites_aggregate"), - ("pr_statistics", "pr_statistics", "self.runMenuCmd", "i.pr_statistics"), - ("pr_subsets", "pr_subsets", "self.runMenuCmd", "i.pr_subsets"), - ("pr_training", "pr_training", "self.runMenuCmd", "i.pr_training"), - ("pr_uxb", "pr_uxb", "self.runMenuCmd", "i.pr_uxb"), - )), - ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.runMenuCmd", "i.cluster"), + ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.OnMenuCmd", "i.cluster"), ("","","", ""), - ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.runMenuCmd", "i.maxlik"), - ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.runMenuCmd", "i.smap"), + ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.OnMenuCmd", "i.maxlik"), + ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.OnMenuCmd", "i.smap"), ("","","", ""), - ("Interactive input for supervised classification", "Interactive input for supervised classification", "self.runMenuCmd", "i.class"), - ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.runMenuCmd", "i.gensig"), - ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.runMenuCmd", "i.gensigset"), - ("","","", ""), - ("Kappa classification accuracy assessment", "Kappa classification accuracy assessment", "self.runMenuCmd", "r.kappa"), + ("Interactive input for supervised classification", "Interactive input for supervised classification", "self.OnMenuCmd", "i.class"), + ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.OnMenuCmd", "i.gensig"), + ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.OnMenuCmd", "i.gensigset"), )), - ("Transform image", ( - ("Brovey transformation and pan sharpening", "Brovey transformation and pan sharpening", "self.runMenuCmd", "i.fusion.brovey"), - ("","","", ""), - ("Canonical component", "Canonical component", "self.runMenuCmd", "i.cca"), - ("Principal component", "Principal component", "self.runMenuCmd", "i.pca"), - ("Fast Fourier Transform", "Fast Fourier Transform", "self.runMenuCmd", "i.fft"), - ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.runMenuCmd", "i.ifft"), - )), ("Filter image", ( - ("Zero edge crossing detection", "Zero edge crossing detection", "self.runMenuCmd", "i.zc"), - ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.runMenuCmd", "r.mfilter"), + ("Zero edge crossing detection", "Zero edge crossing detection", "self.OnMenuCmd", "i.zc"), + ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.OnMenuCmd", "r.mfilter"), )), - ("","","", ""), - ("Quality Analysis", ( - ("Bit pattern comparison for ID of low quality pixels", "Bit pattern comparison for ID of low quality pixels", "self.runMenuCmd", "r.bitpattern"), - ("Optimum index factor for LandSat TM", "Optimum index factor for LandSat TM", "self.runMenuCmd", "i.oif"), + ("Histogram image", "Histogram image", "self.DispHistogram", ""), + ("Spectral response", "Spectral response", "self.OnMenuCmd", "i.spectral"), + ("Tasseled cap vegetation index", "Tasseled cap vegetation index", "self.OnMenuCmd", "i.tasscap"), + ("Transform image", ( + ("Canonical component", "Canonical component", "self.OnMenuCmd", "i.cca"), + ("Principal component", "Principal component", "self.OnMenuCmd", "i.pca"), + ("Fast Fourier Transform", "Fast Fourier Transform", "self.OnMenuCmd", "i.fft"), + ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.OnMenuCmd", "i.ifft"), )), - ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.runMenuCmd", "r.info"), - ("Range of image values", "Range of image values", "self.runMenuCmd", "r.describe"), - ("Histogram of image values", "Histogram of image values", "self.DispHistogram", ""), - ("Spectral response", "Spectral response", "self.runMenuCmd", "i.spectral"), - )), ("","","", ""), - )), - ("Grid3D", ( - ("Develop grid3D volumes", ( - ("Manage nulls for grid3D volume", "Manage nulls for grid3D volume", "self.runMenuCmd", "r3.null"), - ("Manage timestamp for grid3D volume", "Manage timestamp for grid3D volume", "self.runMenuCmd", "r3.timestamp"), + ("Report and statistics", ( + ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), + ("Range of image values", "Range of image values", "self.OnMenuCmd", "r.describe"), + ("","","", ""), + ("Bit pattern comparison for ID of low quality pixels", "Bit pattern comparison for ID of low quality pixels", "self.OnMenuCmd", "r.bitpattern"), + ("Kappa classification accuracy assessment", "Kappa classification accuracy assessment", "self.OnMenuCmd", "r.kappa"), + ("Optimum index factor for LandSat TM", "Optimum index factor for LandSat TM", "self.OnMenuCmd", "i.oif"), )), - ("Create 3D mask for grid3D operations", "Create 3D mask for grid3D operations", "self.runMenuCmd", "r3.mask"), - ("Create 2D raster cross section from grid3d volume", "Create 2D raster cross section from grid3d volume", "self.runMenuCmd", "r3.cross.rast"), - ("Map calculator for grid3D operations", "Map calculator for grid3D operations", "self.runMenuCmd", "r3.mapcalculator"), - ("Interpolate volume from vector points using splines", "Interpolate volume from vector points using splines", "self.runMenuCmd", "v.vol.rst"), - ("","","", ""), - ("Report and Statistics", ( - ("Display information about grid3D volume", "Display information about grid3D volume", "self.runMenuCmd", "r3.info"), - )), - ("","","", ""), + ("","","", "") )), - ("Databases", ( - ("Manage database", ( - ("Connect to database", "Connect to database", "self.runMenuCmd", "db.connect"), - ("Login to database", "Login to database", "self.runMenuCmd", "db.login"), - ("","","", ""), - ("Create and add new attribute table to vector map", "Create and add new attribute table to vector map", "self.runMenuCmd", "v.db.addtable"), - ("Copy attribute table", "Copy attribute table", "self.runMenuCmd", "db.copy"), - ("Remove existing attribute table for vector map", "Remove existing attribute table for vector map", "self.runMenuCmd", "v.db.droptable"), - ("","","", ""), - ("Add columns to table", "Add columns to table", "self.runMenuCmd", "v.db.addcol"), - ("Change values in a column", "Change values in a column", "self.runMenuCmd", "v.db.update"), - ("Rename a column", "Rename a column", "self.runMenuCmd", "v.db.renamecol"), - ("","","", ""), - ("Test database", "Test database", "self.runMenuCmd", "db.test"), - )), - ("Database information", ( - ("Describe table", "Describe table", "self.runMenuCmd", "db.describe"), - ("List columns", "List columns", "self.runMenuCmd", "db.columns"), - ("List drivers", "List drivers", "self.runMenuCmd", "db.drivers"), - ("List tables", "List tables", "self.runMenuCmd", "db.tables"), - )), - ("","","", ""), - ("Query", ( - ("Query data in any table", "Query data in any table", "self.runMenuCmd", "db.select"), - ("Query vector attribute data", "Query vector attribute data", "self.runMenuCmd", "db.select"), - ("Execute SQL statement", "Execute SQL statement", "self.runMenuCmd", "db.execute"), - )), - ("Vector<->database connections", ( - ("Reconnect vector map to attribute database", "Reconnect vector map to attribute database", "self.runMenuCmd", "v.db.reconnect.all"), - ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.runMenuCmd", "v.db.connect"), - )), - ("","","", ""), - )), - ("Help", ( - ("GRASS help", "GRASS help", "self.runMenuCmd", "g.manual"), - ("GIS Manager help", "GIS Manager help", "self.runMenuCmd", "GIS Manager help"), - ("About GRASS", "About GRASS", "self.runMenuCmd", "About GRASS"), - ("About System", "About System", "self.runMenuCmd", "About System"), - ("","","", ""), - )), - )] + ("Database", ( + ("Query", "Query database", "self.Nomethod", ""), + ("","","", "") + )))] + + + + + + + + + From chemin at grass.itc.it Fri Jun 8 20:38:22 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 8 20:38:24 2007 Subject: [grass-addons] r808 - trunk/grassaddons/gipe Message-ID: <200706081838.l58IcMWE011308@grass.itc.it> Author: chemin Date: 2007-06-08 20:38:15 +0200 (Fri, 08 Jun 2007) New Revision: 808 Modified: trunk/grassaddons/gipe/gmmenu.tcl trunk/grassaddons/gipe/menudata.py Log: Updated gmmenu.tcl/menudata.py with i.pr menus and made raster/imagery menus as they are in gipe/menudata.py Modified: trunk/grassaddons/gipe/gmmenu.tcl =================================================================== --- trunk/grassaddons/gipe/gmmenu.tcl 2007-06-08 15:22:15 UTC (rev 807) +++ trunk/grassaddons/gipe/gmmenu.tcl 2007-06-08 18:38:15 UTC (rev 808) @@ -277,7 +277,7 @@ {command {[G_msg "Locate closest points between areas in 2 raster maps"]} {} "r.distance" {} -command { execute r.distance }} }} {separator} - {cascad {[G_msg " Modeling: Hydrologic"]} {} "" $tmenu { + {cascad {[G_msg "Modeling: Hydrologic"]} {} "" $tmenu { {command {[G_msg "Carve stream channels into elevation map using vector streams map"]} {} "r.carve" {} -command {execute r.carve }} {command {[G_msg "Depressionless elevation map and flowline map"]} {} "r.fill.dir" {} -command {execute r.fill.dir }} {command {[G_msg "Fill lake from seed point to specified level"]} {} "r.lake" {} -command {execute r.lake }} @@ -298,9 +298,22 @@ {command {[G_msg "Analyze landscape patch characteristics"]} {} " r.le.patch" {} -command {execute r.le.patch }} {command {[G_msg "Output landscape patch information"]} {} "r.le.trace" {} -command {execute r.le.trace }} }} - {cascad {[G_msg "Modeling: Solar radiance and shadows"]} {} "" $tmenu { - {command {[G_msg "Solar irradiance and daily irradiation"]} {} "r.sun" {} -command {execute r.sun }} - {command {[G_msg "Shadows map for sun position or date/time"]} {} "r.sunmask" {} -command {execute r.sunmask }} + {cascad {[G_msg "Modeling: Landscape patch analysis"]} {} "" $tmenu { + {command {[G_msg "Configure and create patch map for analysis"]} {} "r.li.setup" {} -command {execute r.li.setup }} + {separator} + {command {[G_msg "Calculate contrast weighted edge density index"]} {} "r.li.cwed" {} -command {execute r.li.cwed }} + {command {[G_msg "Calculate dominance's diversity index"]} {} "r.li.dominance" {} -command {execute r.li.dominance }} + {command {[G_msg "Calculate edge density index using a 4 neighbour algorithm"]} {} "r.li.edgedensity" {} -command {execute r.li.edgedensity }} + {command {[G_msg "Calculate mean patch size index using a 4 neighbour algorithm"]} {} " r.li.mps" {} -command {execute r.li.mps }} + {command {[G_msg "Calculate coefficient of variation of patch area"]} {} " r.li.padcv" {} -command {execute r.li.padcv }} + {command {[G_msg "Calculate range of patch area size"]} {} "r.li.padrange" {} -command {execute r.li.padrange }} + {command {[G_msg "Calculate standard deviation of patch area"]} {} "r.li.padsd" {} -command {execute r.li.padsd }} + {command {[G_msg "Calculate patch density index using a 4 neighbour algorithm"]} {} "r.li.patchdensity" {} -command {execute r.li.patchdensity }} + {command {[G_msg "Calculate patch number index using a 4 neighbour algorithm"]} {} "r.li.patchnum" {} -command {execute r.li.patchnum }} + {command {[G_msg "Calculate dominance's diversity index"]} {} "r.li.shannon" {} -command {execute r.li.shannon }} + {command {[G_msg "Calculate Shannon's diversity index"]} {} "r.li.richness" {} -command {execute r.li.richness }} + {command {[G_msg "Calculate shape index"]} {} "r.li.shape" {} -command {execute r.li.shape }} + {command {[G_msg "Calculate Simpson's diversity index"]} {} "r.li.simpson" {} -command {execute r.li.simpson }} }} {cascad {[G_msg "Modeling: Terrain and solar"]} {} "" $tmenu { {command {[G_msg "Calculate cumulative movement costs between locales"]} {} "r.walk" {} -command {execute r.walk }} @@ -310,33 +323,20 @@ {command {[G_msg "Shaded relief map"]} {} "r.shaded.relief" {} -command {execute r.shaded.relief }} {command {[G_msg "Slope and aspect"]} {} "r.slope.aspect" {} -command {execute r.slope.aspect }} {command {[G_msg "Terrain parameters"]} {} "r.param.scale" {} -command {execute r.param.scale }} + {separator} {command {[G_msg "Textural features"]} {} "r.texture" {} -command {execute r.texture }} {command {[G_msg "Visibility/line of sight"]} {} "r.los" {} -command {execute r.los }} + {separator} + {command {[G_msg "Solar irradiance and daily irradiation"]} {} "r.sun" {} -command {execute r.sun }} + {command {[G_msg "Shadows map for sun position or date/time"]} {} "r.sunmask" {} -command {execute r.sunmask }} }} {separator} - {cascad {[G_msg "Universal Soil Loss Equation (USLE)"]} {} "" $tmenu { + {cascad {[G_msg "Modeling: Universal Soil Loss Equation (USLE)"]} {} "" $tmenu { {command {[G_msg "Rainfall Erosivity (R)"]} {} "r.usler" {} -command {execute r.usler }} {command {[G_msg "Soil Erodibility (K)"]} {} "r.uslek" {} -command {execute r.uslek }} {command {[G_msg "Length Slope and Slope (LS)"]} {} "r.watershed" {} -command {execute r.watershed }} }} - {cascad {[G_msg "Landscape patch analysis"]} {} "" $tmenu { - {command {[G_msg "Configure and create patch map for analysis"]} {} "r.li.setup" {} -command {execute r.li.setup }} - {separator} - {command {[G_msg "Calculate contrast weighted edge density index"]} {} "r.li.cwed" {} -command {execute r.li.cwed }} - {command {[G_msg "Calculate dominance's diversity index"]} {} "r.li.dominance" {} -command {execute r.li.dominance }} - {command {[G_msg "Calculate edge density index using a 4 neighbour algorithm"]} {} "r.li.edgedensity" {} -command {execute r.li.edgedensity }} - {command {[G_msg "Calculate mean patch size index using a 4 neighbour algorithm"]} {} " r.li.mps" {} -command {execute r.li.mps }} - {command {[G_msg "Calculate coefficient of variation of patch area"]} {} " r.li.padcv" {} -command {execute r.li.padcv }} - {command {[G_msg "Calculate range of patch area size"]} {} "r.li.padrange" {} -command {execute r.li.padrange }} - {command {[G_msg "Calculate standard deviation of patch area"]} {} "r.li.padsd" {} -command {execute r.li.padsd }} - {command {[G_msg "Calculate patch density index using a 4 neighbour algorithm"]} {} "r.li.patchdensity" {} -command {execute r.li.patchdensity }} - {command {[G_msg "Calculate patch number index using a 4 neighbour algorithm"]} {} "r.li.patchnum" {} -command {execute r.li.patchnum }} - {command {[G_msg "Calculate dominance's diversity index"]} {} "r.li.shannon" {} -command {execute r.li.shannon }} - {command {[G_msg "Calculate Shannon's diversity index"]} {} "r.li.richness" {} -command {execute r.li.richness }} - {command {[G_msg "Calculate shape index"]} {} "r.li.shape" {} -command {execute r.li.shape }} - {command {[G_msg "Calculate Simpson's diversity index"]} {} "r.li.simpson" {} -command {execute r.li.simpson }} - }} - {cascad {[G_msg "Wildfire modeling"]} {} "" $tmenu { + {cascad {[G_msg "Modeling: Wildfire modeling"]} {} "" $tmenu { {command {[G_msg "Generate rate of spread (ROS) maps"]} {} "r.ros" {} -command {execute r.ros }} {command {[G_msg "Generate least-cost spread paths"]} {} "r.spreadpath" {} -command {execute r.spreadpath }} {command {[G_msg "Simulate anisotropic spread phenomena"]} {} "r.spread" {} -command {execute r.spread }} @@ -357,20 +357,20 @@ {command {[G_msg "Rescale categories with equalized histogram (create new map)"]} {} "r.rescale.eq" {} -command {execute r.rescale.eq }} }} {separator} - {command {[G_msg "Generate concentric circles around points"]} {} "r.circle" {} -command { execute r.circle }} - {cascad {[G_msg "Generate random raster cells"]} {} "" $tmenu { - {command {[G_msg "Generate random cells"]} {} "r.random.cells" {} -command {execute r.random.cells }} - {command {[G_msg "Generate random cells and vector points from raster map"]} {} "r.random" {} -command {execute r.random }} + {cascad {[G_msg "Generate"]} {} "" $tmenu { + {command {[G_msg "Concentric circles around points"]} {} "r.circle" {} -command { execute r.circle }} + {command {[G_msg "Density surface using moving Gausian kernal"]} {} "v.kernel" {} -command {execute v.kernel }} + {command {[G_msg "Fractal surface"]} {} "r.surf.fractal" {} -command {execute r.surf.fractal }} + {command {[G_msg "Gaussian deviates surface"]} {} "r.surf.gauss" {} -command {execute r.surf.gauss }} + {command {[G_msg "Plane"]} {} "r.plane" {} -command {execute r.plane }} + {separator} + {command {[G_msg "Random cells"]} {} "r.random.cells" {} -command {execute r.random.cells }} + {command {[G_msg "Random cells and vector points from raster map"]} {} "r.random" {} -command {execute r.random }} + {command {[G_msg "Random deviates surface"]} {} "r.surf.random" {} -command {execute r.surf.random }} + {command {[G_msg "Random surface with spatial dependence"]} {} "r.random.surface" {} -command {execute r.random.surface }} + {separator} + {command {[G_msg "Vector contour lines"]} {} "r.contour" {} -command { execute r.contour }} }} - {cascad {[G_msg "Generate surfaces"]} {} "" $tmenu { - {command {[G_msg "Generate density surface using moving Gausian kernal"]} {} "v.kernel" {} -command {execute v.kernel }} - {command {[G_msg "Generate fractal surface"]} {} "r.surf.fractal" {} -command {execute r.surf.fractal }} - {command {[G_msg "Generate gaussian deviates surface"]} {} "r.surf.gauss" {} -command {execute r.surf.gauss }} - {command {[G_msg "Generate plane"]} {} "r.plane" {} -command {execute r.plane }} - {command {[G_msg "Generate random deviates surface"]} {} "r.surf.random" {} -command {execute r.surf.random }} - {command {[G_msg "Generate random surface with spatial dependence"]} {} "r.random.surface" {} -command {execute r.random.surface }} - }} - {command {[G_msg "Generate vector contour lines"]} {} "r.contour" {} -command { execute r.contour }} {cascad {[G_msg "Interpolate surfaces"]} {} "" $tmenu { {command {[G_msg "Bicubic and bilinear interpolation with Tykhonov regularization from vector points"]} {} "v.surf.bspline" {} -command { execute v.surf.bspline }} {command {[G_msg "Bilinear interpolation from raster points"]} {} "r.bilinear" {} -command { execute r.bilinear }} @@ -392,6 +392,7 @@ {command {[G_msg "Sum all cell category values"]} {} "r.sum" {} -command {execute r.sum }} {command {[G_msg "Sum area by map and category"]} {} "r.report" {} -command {execute r.report }} {command {[G_msg "Summary statistics for clumped cells (works with r.clump)"]} {} "r.volume" {} -command {execute r.volume }} + {separator} {command {[G_msg "Total surface area corrected for topography"]} {} "r.surf.area" {} -command {execute r.surf.area }} {command {[G_msg "Univariate statistics"]} {} "r.univar" {} -command {execute r.univar }} {command {[G_msg "Univariate statistics (script version)"]} {} " r.univar" {} -command {execute r.univar }} Modified: trunk/grassaddons/gipe/menudata.py =================================================================== --- trunk/grassaddons/gipe/menudata.py 2007-06-08 15:22:15 UTC (rev 807) +++ trunk/grassaddons/gipe/menudata.py 2007-06-08 18:38:15 UTC (rev 808) @@ -4,458 +4,586 @@ def GetMenu(self): return [( ("Files", ( - ("Import", "Import files", "self.runMenuCmd", "r.in.gdal"), - ("Export", "Export files", "self.runMenuCmd", "r.out.gdal"), + ("Import", ( + ("Raster map", ( + ("Multiple formats using GDAL", "Import multiple formats using GDAL", "self.OnMenuCmd", "r.in.gdal"), + ("","","", ""), + ("Aggregate ASCII xyz", "Import aggregate ASCII xyz data", "self.OnMenuCmd", "r.in.xyz"), + ("ASCII grid", "Import ASCII GRID (includes GRASS ASCII)", "self.OnMenuCmd", "r.in.ascii"), + ("ASCII polygons and lines", "Import Polygons and lines from ASCII file", "self.OnMenuCmd", "r.in.poly"), + ("","","", ""), + ("Binary", "Import binary file (includes GTOPO30 format)", "self.OnMenuCmd", "r.in.bin"), + ("ESRI Arc/Info ASCII grid", "Import ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.in.arc"), + ("GRIDATB.FOR", "Import GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.in.gridatb"), + ("MAT-File (v.4)", "Import MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.in.mat"), + ("SPOT NDVI", "Import SPOT vegetation NDVI data sets", "self.OnMenuCmd", "r.in.spotvgt"), + ("SRTM HGT", "Import SRTM hgt files", "self.OnMenuCmd", "r.in.srtm"), + ("Terra ASTER HDF", "Import Terra ASTER HDF files", "self.OnMenuCmd", "r.in.aster"), + ("","","", ""), + ("WMS", "Import Web Mapping Server", "self.OnMenuCmd", "r.in.wms"), + )), + ("Vector map", ( + ("Multiple formats using OGR", "Import multiple formats using OGR", "self.OnMenuCmd", "v.in.ogr"), + ("","","", ""), + ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.in.ascii"), + ("Old GRASS vector", "Import old GRASS vector format", "self.OnMenuCmd", "v.convert"), + ("","","", ""), + ("DXF", "Import DXF file", "self.OnMenuCmd", "v.in.dxf"), + ("ESRI e00", "Import ESRI e00 file", "self.OnMenuCmd", "v.in.e00"), + ("Garmin GPS", "Import Garmin GPS Waypoints/Routes/Tracks", "self.OnMenuCmd", "v.in.garmin"), + ("GPSBabel GPS", "Import GPS Waypoints/Routes/Tracks using GPSBabel", "self.OnMenuCmd", "v.in.gpsbabel"), + ("GEOnet", "Import GEOnet Name server country files (US-NGA GNS)", "self.OnMenuCmd", "v.in.gns"), + ("Matlab and MapGen", "Import Matlab and MapGen files", "self.OnMenuCmd", "v.in.mapgen"), + )), + + ("Grid 3D", ( + ("ASCII 3D", "Import ASCII 3D file", "self.OnMenuCmd", "r3.in.ascii"), + ("Vis5D", "Import Vis5D file", "self.OnMenuCmd", "r3.in.v5d"), + )), + )), + ("Export", ( + ("Raster map", ( + ("Multiple formats using GDAL", "Export multiple formats using GDAL", "self.OnMenuCmd", "r.out.gdal"), + ("","","", ""), + ("ASCII grid", "Export ASCII grid (for GRASS, Surfer, Modflow, etc)", "self.OnMenuCmd", "r.out.ascii"), + ("ASCII x,y,z", "Export ASCII x,y,z values of cell centers", "self.OnMenuCmd", "r.out.xyz"), + ("","","", ""), + ("ESRI ASCII grid", "Export ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.out.arc"), + ("GRIDATB.FOR", "Export GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.out.gridatb"), + ("MAT-File (v.4)", "Export MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.out.mat"), + ("","","", ""), + ("Binary", "Export binary file", "self.OnMenuCmd", "r.out.bin"), + ("","","", ""), + ("MPEG-1", "Export MPEG-1 animations", "self.OnMenuCmd", "r.out.mpeg"), + ("PNG", "Export PNG image (not georeferenced)", "self.OnMenuCmd", "r.out.png"), + ("PPM", "Export PPM image (24bit)", "self.OnMenuCmd", "r.out.ppm"), + ("POV-Ray", "Export POVray height-field", "self.OnMenuCmd", "r.out.pov"), + ("TIFF", "Export TIFF image (8/24bit)", "self.OnMenuCmd", "r.out.tiff"), + ("VRML", "Export VRML file", "self.OnMenuCmd", "r.out.vrml"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r.out.vtk"), + )), + ("Vector map", ( + ("Multiple formats using OGR", "Export multiple formats using OGR", "self.OnMenuCmd", "v.out.ogr"), + ("","","", ""), + ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.out.ascii"), + + ("DXF", "Export DXF file", "self.OnMenuCmd", "v.out.dxf"), + ("POV-Ray", "Export POV-Ray format file", "self.OnMenuCmd", "v.out.pov"), + ("SVG", "Export SVG file", "self.OnMenuCmd", "v.out.svg"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "v.out.vtk"), + )), + + ("Grid 3D", ( + ("ASCII 3D", "Export ASCII 3D file", "self.OnMenuCmd", "r3.out.ascii"), + ("Vis5D", "Export Vis5D file", "self.OnMenuCmd", "r3.out.v5d"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r3.out.vtk"), + )), + )), ("","","", ""), - ("E&xit", "Exit from wxgui.py", "self.onCloseWindow", "") + ("Manage maps and volumes", ( + ("Copy", "Copy maps within mapsets or between mapsets", "self.OnMenuCmd", "g.copy"), + ("","","", ""), + ("List", "List maps by type", "self.OnMenuCmd", "list"), + ("List filtered", "List maps filtered by expressions and wildcards", "self.OnMenuCmd", "g.mlist"), + ("","","", ""), + ("Rename", "Rename maps", "self.OnMenuCmd", "g.rename"), + ("","","", ""), + ("Delete", "Delete maps", "self.OnMenuCmd", "g.remove"), + ("Delete filtered", "Delete maps using expressions and wildcards", "self.OnMenuCmd", "g.mremove"), + )), + ("Map type conversions", ( + ("Raster to vector", "Convert raster to vector map", "self.OnMenuCmd", "r.to.vect"), + ("Raster series to volume", "Convert raster map series to volume", "self.OnMenuCmd", "r.to.rast3"), + ("Raster 2.5D to volume", "Convert raster 2.5D map to volume", "self.OnMenuCmd", "r.to.rast3elev"), + ("","","", ""), + ("Vector to raster", "Convert vector to raster map", "self.OnMenuCmd", "v.to.rast"), + ("Vector to volume", "Convert vector 3D points to volume voxels", "self.OnMenuCmd", "v.to.rast3"), + ("Sites to vector", "Convert sites (GRASS 5) to vector map", "self.OnMenuCmd", "v.in.sites"), + ("","","", ""), + ("Volumes to raster series", "Convert raster to vector map", "self.OnMenuCmd", "r3.to.rast"), + )), + ("","","", ""), + ("Georectify (not functional)", "Georectify raster and vector maps", "self.OnGeorectify", ""), + ("","","", ""), + ("Bearing/distance to coordinates", "Convert between bearing/distance and coordinates", "self.OnMenuCmd", "m.cogo"), + ("","","", ""), + ("Postscript plot", "Create cartographic PostScript plot", "self.OnMenuCmd", "ps.map"), + ("","","", ""), + ("E&xit", "Exit from wxgui.py", "self.OnCloseWindow", ""), )), ("Config", ( - ("Region", "Set region", "self.runMenuCmd", "g.region"), - ("","","", ""), - ("Set display font", "Set default font for GRASS displays", "self.DefaultFont", ""), - ("Add a GRASS Extension", "Add a GRASS Extension", "self.runMenuCmd", "scripts/m.gem") + ("Region", ( + ("Display region", "Display region settings", "self.RunMenuCmd", "g.region -p"), + ("Set region", "Change region settings", "self.OnMenuCmd", "g.region"), )), + ("GRASS working environment", ( + ("Mapset access (not functional)", "Set access to other mapsets in current location", "self.OnMapsets", ""), + ("Change working environment", "Change current working session to new mapset, location, or data directory", "self.OnMenuCmd", "g.mapset"), + ("User access", "Change access by other users to current mapset", "self.OnMenuCmd", "g.access"), + ("Show settings", "Show current GRASS environment settings", "self.RunMenuCmd", "g.gisenv "), + ("Change settings", "Change GRASS environment settings", "self.OnMenuCmd", "g.gisenv"), + ("Version", "Show current GRASS version", "self.RunMenuCmd", "g.version -c"), + )), + ("Manage projections", ( + ("Projections", "Show projection information and create projection files", "self.OnMenuCmd", "g.proj"), + ("Convert coordinates", "Convert coordinates from one projection to another", "self.OnMenuCmd", "m.proj"), + )), + ("Display font", "Set default font for GRASS displays", "self.DefaultFont", ""), + )), ("Raster", ( ("Develop map", ( - ("Digitize raster", "Digitize raster", "self.runMenuCmd", "r.digit"), + ("Digitize raster (not functional)", "Digitize raster", "self.OnRDigit", ""), ("","","", ""), - ("Compress/decompress raster file", "Compress/decompress raster file", "self.runMenuCmd", "r.compress"), - ("Manage boundary definition (WHICH COMMAND?)", "Manage boundary definition", "self.runMenuCmd", "r.region"), - ("Manage null values", "Manage null values", "self.runMenuCmd", "r.null"), - ("Manage timestamp for files", "Manage timestamp for files", "self.runMenuCmd", "r.timestamp"), - ("Quantization for floating-point maps", "Quantization for floating-point maps", "self.runMenuCmd", "r.quant"), - ("Resample (change resolution) using nearest neighbor method", "Resample (change resolution) using nearest neighbor method", "self.runMenuCmd", "r.resample"), - ("Resample (change resolution) using regularized spline tension", "Resample (change resolution) using regularized spline tension", "self.runMenuCmd", "r.resamp.rst"), - ("Support file creation and maintenance", "Support file creation and maintenance", "self.runMenuCmd", "r.support.sh"), + ("Compress/decompress raster file", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), + ("Manage boundary definition (WHICH COMMAND?)", "Manage boundary definition", "self.OnMenuCmd", "r.region"), + ("Manage null values", "Manage null values", "self.OnMenuCmd", "r.null"), + ("Manage timestamp for files", "Manage timestamp for files", "self.OnMenuCmd", "r.timestamp"), + ("Quantization for floating-point maps", "Quantization for floating-point maps", "self.OnMenuCmd", "r.quant"), + ("Resample (change resolution) using nearest neighbor method", "Resample (change resolution) using nearest neighbor method", "self.OnMenuCmd", "r.resample"), + ("Resample (change resolution) using regularized spline tension", "Resample (change resolution) using regularized spline tension", "self.OnMenuCmd", "r.resamp.rst"), + ("Support file creation and maintenance", "Support file creation and maintenance", "self.OnMenuCmd", "r.support.sh"), ("","","", ""), - ("Reproject raster from other location", "Reproject raster from other location", "self.runMenuCmd", "r.proj"), - ("Generate tiling for other projection", "Generate tiling for other projection", "self.runMenuCmd", "r.tileset"), + ("Reproject raster from other location", "Reproject raster from other location", "self.OnMenuCmd", "r.proj"), + ("Generate tiling for other projection", "Generate tiling for other projection", "self.OnMenuCmd", "r.tileset"), )), ("Manage map colors", ( - ("Set colors to predefined color tables", "Set colors to predefined color tables", "self.runMenuCmd", "r.colors"), - ("Set colors using color rules", "Set colors using color rules", "self.runMenuCmd", "r.colors.rules"), + ("Set colors to predefined color tables", "Set colors to predefined color tables", "self.OnMenuCmd", "r.colors"), + ("Set colors using color rules", "Set colors using color rules", "self.OnMenuCmd", "r.colors.rules"), ("","","", ""), - ("Blend 2 color maps to produce 3 RGB files", "Blend 2 color maps to produce 3 RGB files", "self.runMenuCmd", "r.blend"), - ("Create color image from RGB files", "Create color image from RGB files", "self.runMenuCmd", "r.composite"), - ("Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.runMenuCmd", "r.his"), + ("Blend 2 color maps to produce 3 RGB files", "Blend 2 color maps to produce 3 RGB files", "self.OnMenuCmd", "r.blend"), + ("Create color image from RGB files", "Create color image from RGB files", "self.OnMenuCmd", "r.composite"), + ("Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.OnMenuCmd", "r.his"), )), ("Query/Profile", ( - ("Query by coordinates", "Query by coordinates", "self.runMenuCmd", "r.what"), + ("Query by coordinates", "Query by coordinates", "self.OnMenuCmd", "r.what"), ("Profile", "Profile of transect", "self.DispProfile", ""), )), ("","","", ""), - ("Create raster MASK", "Develop raster mask", "self.runMenuCmd", "r.mask"), - ("Create raster buffers", "Develop raster buffer", "self.runMenuCmd", "r.buffer"), - ("Map calculator", "Map calculator", "self.runMenuCmd", "scripts/mapcalc_gparser.sh"), + ("Create raster MASK", "Develop raster mask", "self.OnMenuCmd", "r.mask"), + ("Create raster buffers", "Develop raster buffer", "self.OnMenuCmd", "r.buffer"), + ("Map calculator", "Map calculator", "self.OnMenuCmd", "scripts/mapcalc_gparser.sh"), ("","","", ""), ("Overlay maps", ( - ("Cross product", "Cross product", "self.runMenuCmd", "r.cross"), - ("Function of map series (time series)", "Function of map series (time series)", "self.runMenuCmd", "r.series"), - ("Patch maps", "Patch maps", "self.runMenuCmd", "r.patch"), + ("Cross product", "Cross product", "self.OnMenuCmd", "r.cross"), + ("Function of map series (time series)", "Function of map series (time series)", "self.OnMenuCmd", "r.series"), + ("Patch maps", "Patch maps", "self.OnMenuCmd", "r.patch"), ("","","", ""), - ("Statistical calculations for cover map over base map", "Statistical calculations for cover map over base map", "self.runMenuCmd", "r.statistics"), + ("Statistical calculations for cover map over base map", "Statistical calculations for cover map over base map", "self.OnMenuCmd", "r.statistics"), )), ("Transform features", ( - ("Clump small areas (statistics calculated by r.volume)", "Clump small areas (statistics calculated by r.volume)", "self.runMenuCmd", "r.clump"), - ("Grow areas", "Grow areas", "self.runMenuCmd", "r.grow"), - ("Thin linear features", "Thin linear features", "self.runMenuCmd", "r.thin"), + ("Clump small areas (statistics calculated by r.volume)", "Clump small areas (statistics calculated by r.volume)", "self.OnMenuCmd", "r.clump"), + ("Grow areas", "Grow areas", "self.OnMenuCmd", "r.grow"), + ("Thin linear features", "Thin linear features", "self.OnMenuCmd", "r.thin"), )), ("Proximity/Neighborhood analysis", ( - ("Moving window analysis of raster cells", "Moving window analysis of raster cells", "self.runMenuCmd", "r.neighbors"), - ("Analyze vector points in neighborhood of raster cells", "Analyze vector points in neighborhood of raster cells", "self.runMenuCmd", "v.neighbors"), + ("Moving window analysis of raster cells", "Moving window analysis of raster cells", "self.OnMenuCmd", "r.neighbors"), + ("Analyze vector points in neighborhood of raster cells", "Analyze vector points in neighborhood of raster cells", "self.OnMenuCmd", "v.neighbors"), ("","","", ""), - ("Locate closest points between areas in 2 raster maps", "r.distance", "self.runMenuCmd", "r.distance"), + ("Locate closest points between areas in 2 raster maps", "r.distance", "self.OnMenuCmd", "r.distance"), )), ("","","", ""), ("Modeling: Hydrologic", ( - ("Carve stream channels into elevation map using vector streams map", "Carve stream channels into elevation map using vector streams map", "self.runMenuCmd", "r.carve"), - ("Depressionless elevation map and flowline map", "Depressionless elevation map and flowline map", "self.runMenuCmd", "r.fill.dir"), - ("Fill lake from seed point to specified level", "Fill lake from seed point to specified level", "self.runMenuCmd", "r.lake"), - ("Flow accumulation for massive grids (WHICH COMMAND?)", "Flow accumulation for massive grids", "self.runMenuCmd", "r.flow"), - ("Generate flow lines for raster map (WHICH COMMAND?)", "Generate flow lines for raster map", "self.runMenuCmd", "r.flow"), - ("","","", ""), - ("SIMWE overland flow modeling (WHICH COMMAND?)", "SIMWE overland flow modeling", "self.runMenuCmd", "r.simwe"), - ("SIMWE sediment erosion, transport, deposition modeling (WHICH COMMAND?)", "SIMWE sediment erosion, transport, deposition modeling", "self.runMenuCmd", "r.simwe"), - ("Topographic index map", "Topographic index map", "self.runMenuCmd", "r.topidx"), - ("TOPMODEL simulation", "TOPMODEL simulation", "self.runMenuCmd", "r.topmodel"), - ("","","", ""), - ("Watershed subbasins", "Watershed subbasins", "self.runMenuCmd", "r.basins.fill"), - ("Watershed analysis", "Watershed analysis", "self.runMenuCmd", "r.watershed"), - ("Watershed basin creation", "Watershed basin creation", "self.runMenuCmd", "r.water.outlet"), + ("Carve stream channels into elevation map using vector streams map", "Carve stream channels into elevation map using vector streams map", "self.OnMenuCmd", "r.carve"), + ("Depressionless elevation map and flowline map", "Depressionless elevation map and flowline map", "self.OnMenuCmd", "r.fill.dir"), + ("Fill lake from seed point to specified level", "Fill lake from seed point to specified level", "self.OnMenuCmd", "r.lake"), + ("Flow accumulation for massive grids (WHICH COMMAND?)", "Flow accumulation for massive grids", "self.OnMenuCmd", "r.flow"), + ("Generate flow lines for raster map (WHICH COMMAND?)", "Generate flow lines for raster map", "self.OnMenuCmd", "r.flow"), + ("SIMWE overland flow modeling (WHICH COMMAND?)", "SIMWE overland flow modeling", "self.OnMenuCmd", "r.simwe"), + ("SIMWE sediment erosion, transport, deposition modeling (WHICH COMMAND?)", "SIMWE sediment erosion, transport, deposition modeling", "self.OnMenuCmd", "r.simwe"), + ("Topographic index map", "Topographic index map", "self.OnMenuCmd", "r.topidx"), + ("TOPMODEL simulation", "TOPMODEL simulation", "self.OnMenuCmd", "r.topmodel"), + ("Watershed subbasins", "Watershed subbasins", "self.OnMenuCmd", "r.basins.fill"), + ("Watershed analysis", "Watershed analysis", "self.OnMenuCmd", "r.watershed"), + ("Watershed basin creation", "Watershed basin creation", "self.OnMenuCmd", "r.water.outlet"), )), ("Modeling: Landscape structure", ( - ("Set up sampling and analysis framework", "Set up sampling and analysis framework", "self.runMenuCmd", "r.le.setup"), + ("Set up sampling and analysis framework", "Set up sampling and analysis framework", "self.OnMenuCmd", "r.le.setup"), ("","","", ""), - ("Analyze landscape characteristics", "Analyze landscape characteristics", "self.runMenuCmd", "r.le.pixel"), - ("Analyze landscape patch characteristics", "Analyze landscape patch characteristics", "self.runMenuCmd", "r.le.patch"), - ("Output landscape patch information", "Output landscape patch information", "self.runMenuCmd", "r.le.trace"), + ("Analyze landscape characteristics", "Analyze landscape characteristics", "self.OnMenuCmd", "r.le.pixel"), + ("Analyze landscape patch characteristics", "Analyze landscape patch characteristics", "self.OnMenuCmd", "r.le.patch"), + ("Output landscape patch information", "Output landscape patch information", "self.OnMenuCmd", "r.le.trace"), )), - ("Modeling: Terrain and solar", ( - ("Calculate cumulative movement costs between locales", "Calculate cumulative movement costs between locales", "self.runMenuCmd", "r.walk"), - ("Cost surface", "cost surface", "self.runMenuCmd", "r.cost"), - ("Least cost route or flow", "Least cost route or flow", "self.runMenuCmd", "r.drain"), + ("Modeling: Landscape patch analysis", ( + ("Configure and create patch map for analysis", "Configure and create patch map for analysis", "self.RunMenuCmd", "r.li.setup"), ("","","", ""), - ("Shaded relief map", "Shaded relief map", "self.runMenuCmd", "r.shaded.relief"), - ("Slope and aspect", "Slope and aspect", "self.runMenuCmd", "r.slope.aspect"), - ("Terrain parameters", "Terrain parameters", "self.runMenuCmd", "r.param.scale"), - ("","","", ""), - ("Textural features", "Textural features", "self.runMenuCmd", "r.texture"), - ("Visibility/Line of sight", "Visibility/Line of sight", "self.runMenuCmd", "r.los"), - ("","","", ""), - ("Solar irradiance and daily irradiation", "Solar irradiance and daily irradiation", "self.runMenuCmd", "r.sun"), - ("Shadow map for sun position or date/time", "Shadow map for sun position or date/time", "self.runMenuCmd", "r.sunmask"), + ("Contrast weighted edge density index", "Calculate contrast weighted edge density index", "self.RunMenuCmd", "r.li.cwed"), + ("Calculate dominance's diversity index", "Calculate dominance's diversity index", "self.RunMenuCmd", "r.li.dominance"), + ("Edge density index using a 4 neighbour algorithm","Calculate edge density index using a 4 neighbour algorithm", "self.RunMenuCmd", "r.li.edgedensity"), + ("Mean patch size index using a 4 neighbour algorithm", "Calculate mean patch size index using a 4 neighbour algorithm", "self.RunMenuCmd", " r.li.mps"), + ("Coefficient of variation of patch area","Calculate coefficient of variation of patch area", "self.RunMenuCmd", "r.li.padcv"), + ("Range of patch area size", "Calculate range of patch area size", "self.RunMenuCmd", "r.li.padrange"), + ("Standard deviation of patch area","Calculate standard deviation of patch area", "self.RunMenuCmd", "r.li.padsd"), + ("Patch density index using a 4 neighbour algorithm","Calculate patch density index using a 4 neighbour algorithm", "self.RunMenuCmd", "r.li.patchdensity"), + ("Patch number index using a 4 neighbour algorithm", "Calculate patch number index using a 4 neighbour algorithm", "self.RunMenuCmd", "r.li.patchnum"), + ("Dominance's diversity index", "Calculate dominance's diversity index", "self.RunMenuCmd", "r.li.shannon"), + ("Shannon's diversity index", "Calculate Shannon's diversity index", "self.RunMenuCmd", "r.li.richness"), + ("Shape index", "Calculate shape index", "self.RunMenuCmd", "r.li.shape"), + ("Simpson's diversity index", "Calculate Simpson's diversity index", "self.RunMenuCmd", "r.li.simpson"), )), - ("Modeling: Universal Soil Loss Equation (USLE)", ( - ("Rainfall Erosivity (R)", "Rainfall Erosivity (R)", "self.runMenuCmd", "r.usler"), - ("Soil Erodibility (K)", "Soil Erodibility (K)", "self.runMenuCmd", "r.uslek"), - ("Length Slope and Slope (LS)", "Length Slope and Slope (LS)", "self.runMenuCmd", "r.watershed"), + ("Modeling: Terrain and Solar", ( + ("Calculate cumulative movement costs between locales", "Calculate cumulative movement costs between locales", "self.OnMenuCmd", "r.walk"), + ("cost surface", "cost surface", "self.OnMenuCmd", "r.cost"), + ("Least cost route or flow", "Least cost route or flow", "self.OnMenuCmd", "r.drain"), ("","","", ""), + ("Shaded relief map", "Shaded relief map", "self.OnMenuCmd", "r.shaded.relief"), + ("Slope and aspect", "Slope and aspect", "self.OnMenuCmd", "r.slope.aspect"), + ("Terrain parameters", "Terrain parameters", "self.OnMenuCmd", "r.param.scale"), + ("","","", ""), + ("Textural features", "Textural features", "self.OnMenuCmd", "r.texture"), + ("Visibility/Line of sight", "Visibility/Line of sight", "self.OnMenuCmd", "r.los"), + ("","","", ""), + ("Solar irradiance and daily irradiation", "Solar irradiance and daily irradiation", "self.OnMenuCmd", "r.sun"), + ("Shadow map for sun position or date/time", "Shadow map for sun position or date/time", "self.OnMenuCmd", "r.sunmask"), )), ("Modeling: Wildfire", ( - ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.runMenuCmd", "r.ros"), - ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.runMenuCmd", "r.spreadpath"), - ("Simulate anisotropic spread phenomena", "Simulate anisotropic spread phenomena", "self.runMenuCmd", "r.spread"), + ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.OnMenuCmd", "r.ros"), + ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.OnMenuCmd", "r.spreadpath"), + ("Simulate anisotropic spread phenomena", "Simulate anisotropic spread phenomena", "self.OnMenuCmd", "r.spread"), )), ("","","", ""), ("Change category values and labels", ( - ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.runMenuCmd", "d.rast.edit"), + ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.OnMenuCmd", "d.rast.edit"), ("","","", ""), - ("Reclassify categories for areas of specified sizes", "Reclassify categories for areas of specified sizes", "self.runMenuCmd", "r.reclass.area"), - ("Reclassify categories using rules", "Reclassify categories using rules", "self.runMenuCmd", "r.reclass.rules"), - ("Reclassify categories using rules file", "Reclassify categories using rules file", "self.runMenuCmd", "r.reclass.file"), + ("Reclassify categories for areas of specified sizes", "Reclassify categories for areas of specified sizes", "self.OnMenuCmd", "r.reclass.area"), + ("Reclassify categories using rules", "Reclassify categories using rules", "self.OnMenuCmd", "r.reclass.rules"), + ("Reclassify categories using rules file", "Reclassify categories using rules file", "self.OnMenuCmd", "r.reclass.file"), ("","","", ""), - ("Recode categories using rules (create new map)", "Recode categories using rules (create new map)", "self.runMenuCmd", "r.recode.rules"), - ("Recode categories using rules file (create new map)", "Recode categories using rules file (create new map)", "self.runMenuCmd", "r.recode.file"), + ("Recode categories using rules (create new map)", "Recode categories using rules (create new map)", "self.OnMenuCmd", "r.recode.rules"), + ("Recode categories using rules file (create new map)", "Recode categories using rules file (create new map)", "self.OnMenuCmd", "r.recode.file"), ("","","", ""), - ("Rescale categories (create new map)", "Rescale categories (create new map)", "self.runMenuCmd", "r.rescale"), - ("Rescale categories with equalized histogram (create new map)", "Rescale categories with equalized histogram (create new map)", "self.runMenuCmd", "r.rescale.eq"), + ("Rescale categories (create new map)", "Rescale categories (create new map)", "self.OnMenuCmd", "r.rescale"), + ("Rescale categories with equalized histogram (create new map)", "Rescale categories with equalized histogram (create new map)", "self.OnMenuCmd", "r.rescale.eq"), )), ("","","", ""), ("Generate", ( - ("Concentric circles around points", "Concentric circles around points", "self.runMenuCmd", "r.circle"), - ("Density surface using moving Gaussian kernel", "Density surface using moving Gaussian kernel", "self.runMenuCmd", "v.kernel"), - ("Fractal surface", "Fractal surface", "self.runMenuCmd", "r.surf.fractal"), - ("Gaussian deviates surface", "Gaussian deviates surface", "self.runMenuCmd", "r.surf.gauss"), - ("Plane", "Plane", "self.runMenuCmd", "r.plane"), + ("Concentric circles around points", "Generate concentric circles around points", "self.OnMenuCmd", "r.circle"), + ("Density surface using moving Gaussian kernel", "Generate density surface using moving Gaussian kernel", "self.OnMenuCmd", "v.kernel"), + ("Fractal surface", "Generate fractal surface", "self.OnMenuCmd", "r.surf.fractal"), + ("Gaussian deviates surface", "Generate gaussian deviates surface", "self.OnMenuCmd", "r.surf.gauss"), + ("Generate plane", "Generate plane", "self.OnMenuCmd", "r.plane"), ("","","", ""), - ("Random cells", "Random cells", "self.runMenuCmd", "r.random.cells"), - ("Random cells and vector points from raster map", "Random cells and vector points from raster map", "self.runMenuCmd", "r.random"), - ("Random deviates surface", "Random deviates surface", "self.runMenuCmd", "r.surf.random"), - ("Random surface with spatial dependence", "Random surface with spatial dependence", "self.runMenuCmd", "r.random.surface"), + ("Random cells", "Generate random cells", "self.OnMenuCmd", "r.random.cells"), + ("Random cells and vector points from raster map", "Generate random cells and vector points from raster map", "self.OnMenuCmd", "r.random"), + ("Random deviates surface", "Generate random deviates surface", "self.OnMenuCmd", "r.surf.random"), + ("Random surface with spatial dependence", "Generate random surface with spatial dependence", "self.OnMenuCmd", "r.random.surface"), ("","","", ""), - ("Vector contour lines", "Vector contour lines", "self.runMenuCmd", "r.contour"), - )), - ("Interpolate surfaces", ( - ("Bilinear (from raster points)", "Bilinear (from raster points)", "self.runMenuCmd", "r.bilinear"), - ("Inverse distance weighted (from raster points)", "Inverse distance weighted (from raster points)", "self.runMenuCmd", "r.surf.idw"), - ("From raster contour", "From raster contour", "self.runMenuCmd", "r.surf.contour"), + ("Generate vector contour lines", "Generate vector contour lines", "self.OnMenuCmd", "r.contour"), + )), + ("Interpolate surfaces", ( + ("Bilinear interpolation from raster points", "Bilinear interpolation from raster points", "self.OnMenuCmd", "r.bilinear"), + ("Inverse distance weighted interpolation from raster points", "Inverse distance weighted interpolation from raster points", "self.OnMenuCmd", "r.surf.idw"), + ("Interpolation from raster contour", "Interpolation from raster contour", "self.OnMenuCmd", "r.surf.contour"), ("","","", ""), - ("Inverse distance weighted (from vector points)", "Inverse distance weighted (from vector points)", "self.runMenuCmd", "v.surf.idw"), - ("Regularized spline tension (from vector points/contours) (WHICH COMMAND ?)", "Regularized spline tension (from vector points/contours)", "self.runMenuCmd", "v.surf.rst"), + ("Inverse distance weighted interpolation from vector points", "Inverse distance weighted interpolation from vector points", "self.OnMenuCmd", "v.surf.idw"), + ("Regularized spline tension interpolation from vector points or contours (WHICH COMMAND ?)", "Regularized spline tension interpolation from vector points or contours", "self.OnMenuCmd", "v.surf.rst"), ("","","", ""), - ("Fill NULL cells using regularized spline tension", "Fill NULL cells using regularized spline tension", "self.runMenuCmd", "r.fillnulls"), + ("Fill NULL cells by interpolation using regularized spline tension", "Fill NULL cells by interpolation using regularized spline tension", "self.OnMenuCmd", "r.fillnulls"), )), ("","","", ""), ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.runMenuCmd", "r.info"), - ("Report category labels and values", "Report category labels and values", "self.runMenuCmd", "r.cats"), + ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), + ("Report category labels and values", "Report category labels and values", "self.OnMenuCmd", "r.cats"), ("","","", ""), - ("General statistics", "General statistics", "self.runMenuCmd", "r.stats"), - ("Range of all category values", "Range of all category values", "self.runMenuCmd", "r.describe"), + ("General statistics", "General statistics", "self.OnMenuCmd", "r.stats"), + ("Range of all category values", "Range of all category values", "self.OnMenuCmd", "r.describe"), + ("Sum all cell category values", "Sum all cell category values", "self.OnMenuCmd", "r.sum"), + ("Sum area by map and category", "Sum area by map and category", "self.OnMenuCmd", "r.report"), + ("Summary statistics for clumped cells (work with r.clump)", "Summary statistics for clumped cells (work with r.clump)", "self.OnMenuCmd", "r.volume"), + ("Total surface area corrected for topography", "Total surface area corrected for topography", "self.OnMenuCmd", "r.surf.area"), + ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "r.univar"), + ("Univariate statistics (script version)", "Univariate statistics (script version)", "self.OnMenuCmd", "r.univar.sh"), ("","","", ""), - ("Sum all cell category values", "Sum all cell category values", "self.runMenuCmd", "r.sum"), - ("Sum area by map and category", "Sum area by map and category", "self.runMenuCmd", "r.report"), - ("Summary statistics for clumped cells (work with r.clump)", "Summary statistics for clumped cells (work with r.clump)", "self.runMenuCmd", "r.volume"), + ("Sample values along transects", "Sample values along transects", "self.OnMenuCmd", "r.profile"), + ("Sample values along transects (use azimuth, distance)", "Sample values along transects (use azimuth, distance)", "self.OnMenuCmd", "r.transect"), ("","","", ""), - ("Total surface area corrected for topography", "Total surface area corrected for topography", "self.runMenuCmd", "r.surf.area"), - ("Univariate statistics", "Univariate statistics", "self.runMenuCmd", "r.univar"), - ("Univariate statistics (script version)", "Univariate statistics (script version)", "self.runMenuCmd", "r.univar.sh"), - ("","","", ""), - ("Sample values along transects", "Sample values along transects", "self.runMenuCmd", "r.profile"), - ("Sample values along transects (use azimuth, distance)", "Sample values along transects (use azimuth, distance)", "self.runMenuCmd", "r.transect"), - ("","","", ""), - ("Covariance/correlation", "Covariance/correlation", "self.runMenuCmd", "r.covar"), - ("Linear regression between 2 maps", "Linear regression between 2 maps", "self.runMenuCmd", "r.regression.line"), - ("Mutual category occurrences (coincidence)", "Mutual category occurrences (coincidence)", "self.runMenuCmd", "r.coin"), + ("Covariance/correlation", "Covariance/correlation", "self.OnMenuCmd", "r.covar"), + ("Linear regression between 2 maps", "Linear regression between 2 maps", "self.OnMenuCmd", "r.regression.line"), + ("Mutual category occurrences (coincidence)", "Mutual category occurrences (coincidence)", "self.OnMenuCmd", "r.coin"), )), ("","","", "") )), ("Vector", ( ("Develop map", ( - ("Digitize", "Digitize vector", "self.runMenuCmd", "v.digit"), + ("Digitize", "Digitize vector", "self.OnMenuCmd", "v.digit"), ("","","", ""), - ("Create/Rebuild topology", "Create/Rebuild topology", "self.runMenuCmd", "v.build"), - ("Clean vector files", "clean vector files", "self.runMenuCmd", "v.clean"), + ("Create/Rebuild topology", "Create/Rebuild topology", "self.OnMenuCmd", "v.build"), + ("Clean vector files", "clean vector files", "self.OnMenuCmd", "v.clean"), ("","","", ""), - ("Break lines at intersections", "Break lines at intersections", "self.runMenuCmd", "v.topo.check"), - ("Build polylines from adjacent segments", "Build polylines from adjacent segments", "self.runMenuCmd", "v.build.polylines"), - ("Split polylines into segments", "Split polylines into segments", "self.runMenuCmd", "v.segment"), - ("Create lines parallel to existing lines", "Create lines parallel to existing lines", "self.runMenuCmd", "v.parallel"), + ("Break lines at intersections", "Break lines at intersections", "self.OnMenuCmd", "v.topo.check"), + ("Build polylines from adjacent segments", "Build polylines from adjacent segments", "self.OnMenuCmd", "v.build.polylines"), + ("Split polylines into segments", "Split polylines into segments", "self.OnMenuCmd", "v.segment"), + ("Create lines parallel to existing lines", "Create lines parallel to existing lines", "self.OnMenuCmd", "v.parallel"), ("","","", ""), - ("Convert vector feature types", "Convert vector feature types", "self.runMenuCmd", "v.type"), - ("Convert 2D vector to 3D by sampling raster", "Convert 2D vector to 3D by sampling raster", "self.runMenuCmd", "v.drape"), - ("Extrude 2D vector into 3D vector", "Extrude 2D vector into 3D vector", "self.runMenuCmd", "v.extrude"), + ("Convert vector feature types", "Convert vector feature types", "self.OnMenuCmd", "v.type"), + ("Convert 2D vector to 3D by sampling raster", "Convert 2D vector to 3D by sampling raster", "self.OnMenuCmd", "v.drape"), + ("Extrude 2D vector into 3D vector", "Extrude 2D vector into 3D vector", "self.OnMenuCmd", "v.extrude"), ("","","", ""), - ("Create text label file for vector features", "Create text label file for vector features", "self.runMenuCmd", "v.label"), + ("Create text label file for vector features", "Create text label file for vector features", "self.OnMenuCmd", "v.label"), ("","","", ""), - ("Reproject vector from other location", "Reproject vector from other location", "self.runMenuCmd", "v.proj"), + ("Reproject vector from other location", "Reproject vector from other location", "self.OnMenuCmd", "v.proj"), ("","","", "") )), ("","","", ""), ("vector<->database connections", ( - ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.runMenuCmd", "v.external"), - ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.runMenuCmd", "v.db.connect"), + ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), + ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), )), - ("Query by attributes", "Query by attributes", "self.runMenuCmd", "v.extract"), - ("Query by coordinate(s)", "Query by coordinate(s)", "self.runMenuCmd", "v.what"), - ("Query by map features", "Query by map features", "self.runMenuCmd", "v.select"), + ("Query by attributes", "Query by attributes", "self.OnMenuCmd", "v.extract"), + ("Query by coordinate(s)", "Query by coordinate(s)", "self.OnMenuCmd", "v.what"), + ("Query by map features", "Query by map features", "self.OnMenuCmd", "v.select"), ("","","", ""), - ("Create vector buffers", "Create vector buffers", "self.runMenuCmd", "v.buffer"), + ("Create vector buffers", "Create vector buffers", "self.OnMenuCmd", "v.buffer"), ("Linear referencing for vectors", ( - ("Create linear reference system", "Create linear reference system", "self.runMenuCmd", "v.lrs.create"), - ("Create stationing from input lines, and linear reference system", "Create stationing from input lines, and linear reference system", "self.runMenuCmd", "v.lrs.label"), - ("Create points/segments from input lines, linear reference system and positions read from stdin", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.runMenuCmd", "v.lrs.segment"), - ("Find line id and real km+offset for given points in vector map using linear reference system", "Find line id and real km+offset for given points in vector map using linear reference system", "self.runMenuCmd", "v.lrs.where"), + ("Create linear reference system", "Create linear reference system", "self.OnMenuCmd", "v.lrs.create"), + ("Create stationing from input lines, and linear reference system", "Create stationing from input lines, and linear reference system", "self.OnMenuCmd", "v.lrs.label"), + ("Create points/segments from input lines, linear reference system and positions read from stdin", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.OnMenuCmd", "v.lrs.segment"), + ("Find line id and real km+offset for given points in vector map using linear reference system", "Find line id and real km+offset for given points in vector map using linear reference system", "self.OnMenuCmd", "v.lrs.where"), )), ("Neighborhood analysis", ( - ("Locate nearest feature to points or centroids", "Locate nearest feature to points or centroids", "self.runMenuCmd", "v.distance"), - ("Generate Thiessen polygons around points (Voronoi diagram)", "Generate Thiessen polygons around points (Voronoi diagram)", "self.runMenuCmd", "v.voronoi"), - ("Connect points to create Delaunay triangles", "Connect points to create Delaunay triangles", "self.runMenuCmd", "v.delaunay"), + ("Locate nearest feature to points or centroids", "Locate nearest feature to points or centroids", "self.OnMenuCmd", "v.distance"), + ("Generate Thiessen polygons around points (Voronoi diagram)", "Generate Thiessen polygons around points (Voronoi diagram)", "self.OnMenuCmd", "v.voronoi"), + ("Connect points to create Delaunay triangles", "Connect points to create Delaunay triangles", "self.OnMenuCmd", "v.delaunay"), )), ("Network analysis", ( - ("Allocate subnets", "Allocate subnets", "self.runMenuCmd", "v.net.alloc"), - ("Network maintenance", "Network maintenance", "self.runMenuCmd", "v.net"), - ("Shortest route", "Shortest route", "self.runMenuCmd", "v.net.path"), - ("Shortest route (visualization only)", "Shortest route (visualization only)", "self.runMenuCmd", "d.path"), - ("Split net to bands between cost isolines", "Split net to bands between cost isolines", "self.runMenuCmd", "v.net.iso"), - ("Steiner tree", "Steiner tree", "self.runMenuCmd", "v.net.steiner"), - ("Traveling salesman analysis", "Traveling salesman analysis", "self.runMenuCmd", "v.net.salesman"), + ("Allocate subnets", "Allocate subnets", "self.OnMenuCmd", "v.net.alloc"), + ("Network maintenance", "Network maintenance", "self.OnMenuCmd", "v.net"), + ("Shortest route", "Shortest route", "self.OnMenuCmd", "v.net.path"), + ("Shortest route (visualization only)", "Shortest route (visualization only)", "self.OnMenuCmd", "d.path"), + ("Split net to bands between cost isolines", "Split net to bands between cost isolines", "self.OnMenuCmd", "v.net.iso"), + ("Steiner tree", "Steiner tree", "self.OnMenuCmd", "v.net.steiner"), + ("Traveling salesman analysis", "Traveling salesman analysis", "self.OnMenuCmd", "v.net.salesman"), )), ("Overlay maps", ( - ("Overlay/combine 2 vector maps", "Overlay/combine 2 vector maps", "self.runMenuCmd", "v.overlay"), - ("Patch multiple maps (combine)", "Patch multiple maps (combine)", "self.runMenuCmd", "v.patch"), + ("Overlay/combine 2 vector maps", "Overlay/combine 2 vector maps", "self.OnMenuCmd", "v.overlay"), + ("Patch multiple maps (combine)", "Patch multiple maps (combine)", "self.OnMenuCmd", "v.patch"), )), - ("Generate area feature for extent of current region", "Generate area feature for extent of current region", "self.runMenuCmd", "v.in.region"), - ("Generate rectangular vector grid", "Generate rectangular vector grid", "self.runMenuCmd", "v.mkgrid"), + ("Generate area feature for extent of current region", "Generate area feature for extent of current region", "self.OnMenuCmd", "v.in.region"), + ("Generate rectangular vector grid", "Generate rectangular vector grid", "self.OnMenuCmd", "v.mkgrid"), ("","","", ""), ("Change attributes", ( - ("Attach/delete, or report categories", "Attach/delete, or report categories", "self.runMenuCmd", "v.category"), - ("Reclassify features using rules file", "Reclassify features using rules file", "self.runMenuCmd", "v.reclass"), + ("Attach/delete, or report categories", "Attach/delete, or report categories", "self.OnMenuCmd", "v.category"), + ("Reclassify features using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), )), ("","","", ""), ("Work with vector points", ( ("Generate points", ( - ("Generate points from database", "Generate points from database", "self.runMenuCmd", "v.in.db"), - ("Generate random points", "Generate random points", "self.runMenuCmd", "v.random"), - ("Random location perturbations of points", "Random location perturbations of points", "self.runMenuCmd", "v.perturb"), + ("Generate points from database", "Generate points from database", "self.OnMenuCmd", "v.in.db"), + ("Generate random points", "Generate random points", "self.OnMenuCmd", "v.random"), + ("Random location perturbations of points", "Random location perturbations of points", "self.OnMenuCmd", "v.perturb"), )), ("Generate areas from points", ( - ("Generate convex hull for point set", "Generate convex hull for point set", "self.runMenuCmd", "v.hull"), - ("Generate Delaunay triangles for point set", "Generate Delaunay triangles for point set", "self.runMenuCmd", "v.delaunay"), - ("Generate Voronoi diagram/Thiessen polygons for point set", "Generate Voronoi diagram/Thiessen polygons for point set", "self.runMenuCmd", "v.voronoi"), + ("Generate convex hull for point set", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), + ("Generate Delaunay triangles for point set", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), + ("Generate Voronoi diagram/Thiessen polygons for point set", "Generate Voronoi diagram/Thiessen polygons for point set", "self.OnMenuCmd", "v.voronoi"), )), ("Sample raster maps", ( - ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.runMenuCmd", "v.rast.stats"), - ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.runMenuCmd", "v.what.rast"), - ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.runMenuCmd", "v.sample"), + ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.OnMenuCmd", "v.rast.stats"), + ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.OnMenuCmd", "v.what.rast"), + ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.OnMenuCmd", "v.sample"), )), - ("Partition points into test/training sets for k-fold cross validation", "Partition points into test/training sets for k-fold cross validation", "self.runMenuCmd", "v.kcv"), - ("Transfer attribute data from queried vector map to points", "Transfer attribute data from queried vector map to points", "self.runMenuCmd", "v.what.vect"), + ("Partition points into test/training sets for k-fold cross validation", "Partition points into test/training sets for k-fold cross validation", "self.OnMenuCmd", "v.kcv"), + ("Transfer attribute data from queried vector map to points", "Transfer attribute data from queried vector map to points", "self.OnMenuCmd", "v.what.vect"), )), ("","","", ""), ("Reports and statistics", ( - ("Basic information", "Basic information", "self.runMenuCmd", "v.info"), - ("Load vector attributes to database or create reports", "Load vector attributes to database or create reports", "self.runMenuCmd", "v.to.db"), - ("Report areas for vector attribute categories", "Report areas for vector attribute categories", "self.runMenuCmd", "v.report"), - ("Univariate statistics", "Univariate statistics", "self.runMenuCmd", "v.univar"), + ("Basic information", "Basic information", "self.OnMenuCmd", "v.info"), + ("Load vector attributes to database or create reports", "Load vector attributes to database or create reports", "self.OnMenuCmd", "v.to.db"), + ("Report areas for vector attribute categories", "Report areas for vector attribute categories", "self.OnMenuCmd", "v.report"), + ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "v.univar"), ("","","", ""), - ("Test normality of point distribution", "Test normality of point distribution", "self.runMenuCmd", "v.normal"), - ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.runMenuCmd", "v.rast.stats"), - ("Indices of point counts in quadrats", "Indices of point counts in quadrats", "self.runMenuCmd", "v.qcount"), + ("Test normality of point distribution", "Test normality of point distribution", "self.OnMenuCmd", "v.normal"), + ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.OnMenuCmd", "v.rast.stats"), + ("Indices of point counts in quadrats", "Indices of point counts in quadrats", "self.OnMenuCmd", "v.qcount"), )), ("","","", "") )), ("Image", ( ("Develop images and groups", ( - ("Create/edit imagery group", "Create/edit imagery group", "self.runMenuCmd", "i.group"), - ("Target imagery group", "Target imagery group", "self.runMenuCmd", "i.target"), + ("Create/edit imagery group", "Create/edit imagery group", "self.OnMenuCmd", "i.group"), + ("Target imagery group", "Target imagery group", "self.OnMenuCmd", "i.target"), ("","","", ""), - ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.runMenuCmd", "i.image.mosaic"), + ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.OnMenuCmd", "i.image.mosaic"), )), ("Manage image colors", ( - ("Color auto-balance for rgb", "Color auto-balance for rgb", "self.runMenuCmd", "i.landsat.rgb"), - ("Transform HIS to RGB", "Transform HIS to RGB", "self.runMenuCmd", "i.his.rgb"), - ("Transform RGB to HIS", "Transform RGB to HIS", "self.runMenuCmd", "i.rgb.his"), + ("Balance/enhance color tables for rgb display", "Balance/enhance color tables for rgb display", "self.OnMenuCmd", "i.landsat.rgb"), + ("Transform HIS to RGB", "Transform HIS to RGB", "self.OnMenuCmd", "i.his.rgb"), + ("Transform RGB to HIS", "Transform RGB to HIS", "self.OnMenuCmd", "i.rgb.his"), )), ("Rectify and georeference image group", ( - ("Set GCPs from raster map or keyboard entry", "Set GCPs from raster map or keyboard entry", "self.runMenuCmd", "i.points"), - ("Set GCPs from vector map or keyboard entry", "Set GCPs from vector map or keyboard entry", "self.runMenuCmd", "i.vpoints"), - ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.runMenuCmd", "i.rectify"), - ("Ortho Photo rectification", "Ortho Photo rectification", "self.runMenuCmd", "i.ortho.photo"), + ("Set ground control points (GCP's) from raster map or keyboard entry", "Set ground control points (GCP's) from raster map or keyboard entry", "self.OnMenuCmd", "i.points"), + ("Set ground control points (GCP's) from vector map or keyboard entry", "Set ground control points (GCP's) from vector map or keyboard entry", "self.OnMenuCmd", "i.vpoints"), + ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.OnMenuCmd", "i.rectify"), + ("Ortho Photo rectification", "Ortho Photo rectification", "self.OnMenuCmd", "i.ortho.photo"), )), ("","","", ""), - ("GIPE", ( - ("DN2Rad2Ref", ( - ("Landsat 7 ETM+", "Landsat 7 ETM+", "self.runMenuCmd", "i.dn2ref.l7"), - ("Landsat 7 ETM+ (from .met)", "Landsat 7 ETM+ (from .met)", "self.runMenuCmd", "i.dn2full.l7"), - ("Terra-Aster", "Terra-Aster", "self.runMenuCmd", "i.dn2ref.ast"), - ("","","", ""), - ("Atmospheric correction", "Atmospheric correction", "self.runMenuCmd", "i.atcorr"), - ("Dehaze Landsat", "Dehaze Landsat", "self.runMenuCmd", "i.landsat.dehaze"), - )), - ("Basic RS processing", ( - ("Vegetation Indices (13 types)", "Vegetation Indices (13 types)", "self.runMenuCmd", "i.vi"), - ("Vegetation Indices (13 types) cluster", "Vegetation Indices (13 types) cluster", "self.runMenuCmd", "i.vi.mpi"), - ("Vegetation Index (Landsat TM Tasseled cap)", "Vegetation Index (Landsat TM Tasseled cap)", "self.runMenuCmd", "i.tasscap"), - ("","","", ""), - ("Albedo", "Albedo", "self.runMenuCmd", "i.albedo"), - ("Emissivity (generic from NDVI)", "Emissivity (generic from NDVI)", "self.runMenuCmd", "i.emissivity"), - ("","","", ""), - ("Latitude map", "Latitude map", "self.runMenuCmd", "i.latitude"), - ("Sunshine hours (potential)", "Sunshine hours (potential)", "self.runMenuCmd", "i.sunhours"), - ("Satellite overpass time", "Satellite overpass time", "self.runMenuCmd", "i.sattime"), - )), - ("","","", ""), - ("ETo, ETP, ETa", ( - ("Reference ET (Hargreaves)", "Reference ET (Hargreaves)", "self.runMenuCmd", "r.evapo.MH"), - ("","","", ""), - ("Potential ET (Penman-Monteith)", "Potential ET (Penman-Monteith)", "self.runMenuCmd", "r.evapo.PM"), - ("Potential ET (Prestley and Taylor)", "Potential ET (Prestley and Taylor)", "self.runMenuCmd", "i.evapo.PT"), - ("Potential ET (Radiative)", "Potential ET (Radiative)", "self.runMenuCmd", "i.evapo.potrad"), - ("Potential ET (Radiative) from L7DN (.met)", "Potential ET (Radiative) from L7DN (.met)", "self.runMenuCmd", "i.dn2potrad.l7"), - ("","","", ""), - ("Actual ET (SEBAL)", "Actual ET (SEBAL)", "self.runMenuCmd", "i.eb.eta"), - ("Actual ET (TSA)", "Actual ET (TSA)", "self.runMenuCmd", "i.evapo.TSA"), - )), - ("Energy Balance", ( - ("Surface roughness", "surface roughness", "self.runMenuCmd", "i.eb.z0m"), - ("Delta T", "delta T", "self.runMenuCmd", "i.eb.deltat"), - ("Net radiation", "net radiation", "self.runMenuCmd", "i.eb.netrad"), - ("","","", ""), - ("Displacement height", "Displacement height", "self.runMenuCmd", "i.eb.disp"), - ("Monin-Obukov Length", "Monin-Obukov Length", "self.runMenuCmd", "i.eb.molength"), - ("Psichrometric param. for heat", "psichrometric param. for heat", "self.runMenuCmd", "i.eb.psi"), - ("Blending height wind speed", "blending height wind speed", "self.runMenuCmd", "i.eb.ublend"), - ("Nominal wind speed", "nominal wind speed", "self.runMenuCmd", "i.eb.ustar"), - ("Aerod. resis. to heat transp.", "aerod. resis. to heat transp.", "self.runMenuCmd", "i.eb.rah"), - ("","","", ""), - ("Soil heat flux", "soil heat flux", "self.runMenuCmd", "i.eb.g0"), - ("Sensible heat flux", "sensible heat flux", "self.runMenuCmd", "i.eb.h0"), - ("Sensible heat flux iteration (fixed delta T)", "sensible heat flux iteration (fixed delta T)", "self.runMenuCmd", "i.eb.h_iter"), - ("","","", ""), - ("Evaporative fraction", "evaporative fraction", "self.runMenuCmd", "i.eb.evapfr"), - )), - ("","","", ""), - ("Biomass", ( - ("Biomass growth", "Biomass growth", "self.runMenuCmd", "i.biomass"), - )), - ("","","", ""), - )), + ("GIPE", ( + ("DN2Rad2Ref", ( + ("Landsat 7 ETM+", "Landsat 7 ETM+", "self.RunMenuCmd", "i.dn2ref.l7"), + ("Landsat 7 ETM+ (from .met)", "Landsat 7 ETM+ (from .met)", "self.RunMenuCmd", "i.dn2full.l7"), + ("Terra-Aster", "Terra-Aster", "self.RunMenuCmd", "i.dn2ref.ast"), + ("","","", ""), + ("Atmospheric correction", "Atmospheric correction", "self.RunMenuCmd", "i.atcorr"), + ("Dehaze Landsat", "Dehaze Landsat", "self.RunMenuCmd", "i.landsat.dehaze"), + )), + ("Basic RS processing", ( + ("Vegetation Index (Tasseled cap)", "Vegetation index (Tasseled cap)", "self.OnMenuCmd", "i.tasscap"), + ("Vegetation Indices (13 types)", "Vegetation Indices (13 types)", "self.RunMenuCmd", "i.vi"), + ("Vegetation Indices (13 types) cluster", "Vegetation Indices (13 types) cluster", "self.RunMenuCmd", "i.vi.mpi"), + ("","","", ""), + ("Albedo", "Albedo", "self.RunMenuCmd", "i.albedo"), + ("Emissivity (generic from NDVI)", "Emissivity (generic from NDVI)", "self.RunMenuCmd", "i.emissivity"), + ("","","", ""), + ("Latitude map", "Latitude map", "self.RunMenuCmd", "i.latitude"), + ("Sunshine hours (potential)", "Sunshine hours (potential)", "self.RunMenuCmd", "i.sunhours"), + ("Satellite overpass time", "Satellite overpass time", "self.RunMenuCmd", "i.sattime"), + )), + ("","","", ""), + ("ETo, ETP, ETa", ( + ("Reference ET (Hargreaves)", "Reference ET (Hargreaves)", "self.RunMenuCmd", "r.evapo.MH"), + ("","","", ""), + ("Potential ET (Penman-Monteith)", "Potential ET (Penman-Monteith)", "self.RunMenuCmd", "r.evapo.PM"), + ("Potential ET (Prestley and Taylor)", "Potential ET (Prestley and Taylor)", "self.RunMenuCmd", "i.evapo.PT"), + ("Potential ET (Radiative)", "Potential ET (Radiative)", "self.RunMenuCmd", "i.evapo.potrad"), + ("Potential ET (Radiative) from L7DN (.met)", "Potential ET (Radiative) from L7DN (.met)", "self.RunMenuCmd", "i.dn2potrad.l7"), + ("","","", ""), + ("Actual ET (SEBAL)", "Actual ET (SEBAL)", "self.RunMenuCmd", "i.eb.eta"), + ("Actual ET (TSA)", "Actual ET (TSA) NOT WORKING YET", "self.RunMenuCmd", "i.evapo.TSA"), + )), + ("Energy Balance", ( + ("Surface roughness", "surface roughness", "self.RunMenuCmd", "i.eb.z0m"), + ("Delta T", "delta T", "self.RunMenuCmd", "i.eb.deltat"), + ("Net radiation", "net radiation", "self.RunMenuCmd", "i.eb.netrad"), + ("","","", ""), + ("Displacement height", "Displacement height", "self.RunMenuCmd", "i.eb.disp"), + ("Monin-Obukov Length", "Monin-Obukov Length", "self.RunMenuCmd", "i.eb.molength"), + ("Psichrometric param. for heat", "psichrometric param. for heat", "self.RunMenuCmd", "i.eb.psi"), + ("Blending height wind speed", "blending height wind speed", "self.RunMenuCmd", "i.eb.ublend"), + ("Nominal wind speed", "nominal wind speed", "self.RunMenuCmd", "i.eb.ustar"), + ("Aerod. resis. to heat transp.", "aerod. resis. to heat transp.", "self.RunMenuCmd", "i.eb.rah"), + ("","","", ""), + ("Soil heat flux", "soil heat flux", "self.RunMenuCmd", "i.eb.g0"), + ("Sensible heat flux", "sensible heat flux", "self.RunMenuCmd", "i.eb.h0"), + ("Sensible heat flux iteration (fixed delta T)", "sensible heat flux iteration (fixed delta T)", "self.RunMenuCmd", "i.eb.h_iter"), + ("","","", ""), + ("Evaporative fraction", "evaporative fraction", "self.RunMenuCmd", "i.eb.evapfr"), + )), + ("","","", ""), + ("Biomass", ( + ("Biomass growth", "Biomass growth", "self.RunMenuCmd", "i.biomass"), + )), + )), ("Classify image", ( ("Classify using pr library", ( - ("pr_blob", "pr_blob", "self.runMenuCmd", "i.pr_blob"), - ("pr_classify", "pr_classify", "self.runMenuCmd", "i.pr_classify"), - ("pr_features", "pr_features", "self.runMenuCmd", "i.pr_features"), - ("pr_features_additional", "pr_features_additional", "self.runMenuCmd", "i.pr_features_additional"), - ("pr_features_extract", "pr_features_extract", "self.runMenuCmd", "i.pr_features_extract"), - ("pr_features_selection", "pr_features_selection", "self.runMenuCmd", "i.pr_features_selection"), - ("pr_model", "pr_model", "self.runMenuCmd", "i.pr_model"), - ("pr_sites_aggregate", "pr_sites_aggregate", "self.runMenuCmd", "i.pr_sites_aggregate"), - ("pr_statistics", "pr_statistics", "self.runMenuCmd", "i.pr_statistics"), - ("pr_subsets", "pr_subsets", "self.runMenuCmd", "i.pr_subsets"), - ("pr_training", "pr_training", "self.runMenuCmd", "i.pr_training"), - ("pr_uxb", "pr_uxb", "self.runMenuCmd", "i.pr_uxb"), - )), - ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.runMenuCmd", "i.cluster"), + ("blob", "pr_blob", "self.RunMenuCmd", "i.pr_blob"), + ("classify", "pr_classify", "self.RunMenuCmd", "i.pr_classify"), + ("features", "pr_features", "self.RunMenuCmd", "i.pr_features"), + ("features_additional", "pr_features_additional", "self.RunMenuCmd", "i.pr_features_additional"), + ("features_extract", "pr_features_extract", "self.RunMenuCmd", "i.pr_features_extract"), + ("features_selection", "pr_features_selection", "self.RunMenuCmd", "i.pr_features_selection"), + ("model", "pr_model", "self.RunMenuCmd", "i.pr_model"), + ("sites_aggregate", "pr_sites_aggregate", "self.RunMenuCmd", "i.pr_sites_aggregate"), + ("statistics", "pr_statistics", "self.RunMenuCmd", "i.pr_statistics"), + ("subsets", "pr_subsets", "self.RunMenuCmd", "i.pr_subsets"), + ("training", "pr_training", "self.RunMenuCmd", "i.pr_training"), + ("uxb", "pr_uxb", "self.RunMenuCmd", "i.pr_uxb"), + )), + ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.OnMenuCmd", "i.cluster"), ("","","", ""), - ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.runMenuCmd", "i.maxlik"), - ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.runMenuCmd", "i.smap"), + ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.OnMenuCmd", "i.maxlik"), + ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.OnMenuCmd", "i.smap"), ("","","", ""), - ("Interactive input for supervised classification", "Interactive input for supervised classification", "self.runMenuCmd", "i.class"), - ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.runMenuCmd", "i.gensig"), - ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.runMenuCmd", "i.gensigset"), - ("","","", ""), - ("Kappa classification accuracy assessment", "Kappa classification accuracy assessment", "self.runMenuCmd", "r.kappa"), + ("Interactive input for supervised classification", "Interactive input for supervised classification", "self.OnMenuCmd", "i.class"), + ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.OnMenuCmd", "i.gensig"), + ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.OnMenuCmd", "i.gensigset"), + ("","","", ""), + ("Kappa classification accuracy assessment", "Kappa classification accuracy assessment", "self.OnMenuCmd", "r.kappa"), )), + ("Filter image", ( + ("Zero edge crossing detection", "Zero edge crossing detection", "self.OnMenuCmd", "i.zc"), + ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.OnMenuCmd", "r.mfilter"), + )), ("Transform image", ( - ("Brovey transformation and pan sharpening", "Brovey transformation and pan sharpening", "self.runMenuCmd", "i.fusion.brovey"), - ("","","", ""), - ("Canonical component", "Canonical component", "self.runMenuCmd", "i.cca"), - ("Principal component", "Principal component", "self.runMenuCmd", "i.pca"), - ("Fast Fourier Transform", "Fast Fourier Transform", "self.runMenuCmd", "i.fft"), - ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.runMenuCmd", "i.ifft"), + ("Canonical component", "Canonical component", "self.OnMenuCmd", "i.cca"), + ("Principal component", "Principal component", "self.OnMenuCmd", "i.pca"), + ("Fast Fourier Transform", "Fast Fourier Transform", "self.OnMenuCmd", "i.fft"), + ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.OnMenuCmd", "i.ifft"), + ("","","", ""), + ("Brovey pan sharpening", "Brovey pan sharpening", "self.OnMenuCmd", "i.fusion.brovey"), )), - ("Filter image", ( - ("Zero edge crossing detection", "Zero edge crossing detection", "self.runMenuCmd", "i.zc"), - ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.runMenuCmd", "r.mfilter"), - )), ("","","", ""), ("Quality Analysis", ( - ("Bit pattern comparison for ID of low quality pixels", "Bit pattern comparison for ID of low quality pixels", "self.runMenuCmd", "r.bitpattern"), - ("Optimum index factor for LandSat TM", "Optimum index factor for LandSat TM", "self.runMenuCmd", "i.oif"), + ("Bit pattern comparison for ID of low quality pixels", "Bit pattern comparison for ID of low quality pixels", "self.OnMenuCmd", "r.bitpattern"), + ("Optimum index factor for LandSat TM", "Optimum index factor for LandSat TM", "self.OnMenuCmd", "i.oif"), )), ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.runMenuCmd", "r.info"), - ("Range of image values", "Range of image values", "self.runMenuCmd", "r.describe"), - ("Histogram of image values", "Histogram of image values", "self.DispHistogram", ""), - ("Spectral response", "Spectral response", "self.runMenuCmd", "i.spectral"), + ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), + ("Range of image values", "Range of image values", "self.OnMenuCmd", "r.describe"), + ("","","", ""), + ("Histogram image", "Histogram image", "self.DispHistogram", ""), + ("Spectral response", "Spectral response", "self.OnMenuCmd", "i.spectral"), + )), )), + ("Grid3D", ( + ("Develop grid3D volumes", ( + ("Manage nulls for grid3D volume", "Manage nulls for grid3D volume", "self.RunMenuCmd", "r3.null"), + ("Manage timestamp for grid3D volume", "Manage timestamp for grid3D volume", "self.RunMenuCmd", "r3.timestamp"), + )), + ("Create 3D mask for grid3D operations", "Create 3D mask for grid3D operations", "self.RunMenuCmd", "r3.mask"), + ("Create 2D raster cross section from grid3d volume", "Create 2D raster cross section from grid3d volume", "self.RunMenuCmd", "r3.cross.rast"), + ("Map calculator for grid3D operations", "Map calculator for grid3D operations", "self.RunMenuCmd", "r3.mapcalculator"), + ("Interpolate volume from vector points using splines", "Interpolate volume from vector points using splines", "self.RunMenuCmd", "v.vol.rst"), ("","","", ""), + ("Report and Statistics", ( + ("Display information about grid3D volume", "Display information about grid3D volume", "self.RunMenuCmd", "r3.info"), + )), )), - ("Grid3D", ( - ("Develop grid3D volumes", ( - ("Manage nulls for grid3D volume", "Manage nulls for grid3D volume", "self.runMenuCmd", "r3.null"), - ("Manage timestamp for grid3D volume", "Manage timestamp for grid3D volume", "self.runMenuCmd", "r3.timestamp"), + ("DB", ( + ("Manage database", ( + ("Connect to database", "Connect to database", "self.RunMenuCmd", "db.connect"), + ("Login to database", "Login to database", "self.RunMenuCmd", "db.login"), + ("","","", ""), + ("Create and add new attribute table to vector map", "Create and add new attribute table to vector map", "self.RunMenuCmd", "v.db.addtable"), + ("Copy attribute table", "Copy attribute table", "self.RunMenuCmd", "db.copy"), + ("Remove existing attribute table for vector map", "Remove existing attribute table for vector map", "self.RunMenuCmd", "v.db.droptable"), + ("","","", ""), + ("Add columns to table", "Add columns to table", "self.RunMenuCmd", "v.db.addcol"), + ("Change values in a column", "Change values in a column", "self.RunMenuCmd", "v.db.update"), + ("Rename a column", "Rename a column", "self.RunMenuCmd", "v.db.renamecol"), + ("","","", ""), + ("Test database", "Test database", "self.RunMenuCmd", "db.test"), )), - ("Create 3D mask for grid3D operations", "Create 3D mask for grid3D operations", "self.runMenuCmd", "r3.mask"), - ("Create 2D raster cross section from grid3d volume", "Create 2D raster cross section from grid3d volume", "self.runMenuCmd", "r3.cross.rast"), - ("Map calculator for grid3D operations", "Map calculator for grid3D operations", "self.runMenuCmd", "r3.mapcalculator"), - ("Interpolate volume from vector points using splines", "Interpolate volume from vector points using splines", "self.runMenuCmd", "v.vol.rst"), + ("Database information", ( + ("Describe table", "Describe table", "self.RunMenuCmd", "db.describe"), + ("List columns", "List columns", "self.RunMenuCmd", "db.columns"), + ("List drivers", "List drivers", "self.RunMenuCmd", "db.drivers"), + ("List tables", "List tables", "self.RunMenuCmd", "db.tables"), + )), ("","","", ""), - ("Report and Statistics", ( - ("Display information about grid3D volume", "Display information about grid3D volume", "self.runMenuCmd", "r3.info"), + ("Query", ( + ("Query data in any table", "Query data in any table", "self.RunMenuCmd", "db.select"), + ("Query vector attribute data", "Query vector attribute data", "self.RunMenuCmd", "db.select"), + ("Execute SQL statement", "Execute SQL statement", "self.RunMenuCmd", "db.execute"), )), + ("Vector<->database connections", ( + ("Reconnect vector map to attribute database", "Reconnect vector map to attribute database", "self.RunMenuCmd", "v.db.reconnect.all"), + ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.RunMenuCmd", "v.db.connect"), + )), + )), + ("Help", ( + ("GRASS help", "GRASS help", "self.RunMenuCmd", "g.manual"), + ("GIS Manager help", "GIS Manager help", "self.RunMenuCmd", "GIS Manager help"), ("","","", ""), + ("About GRASS", "About GRASS", "self.RunMenuCmd", "About GRASS"), + ("About System", "About System", "self.RunMenuCmd", "About System"), )), - ("Databases", ( - ("Manage database", ( - ("Connect to database", "Connect to database", "self.runMenuCmd", "db.connect"), - ("Login to database", "Login to database", "self.runMenuCmd", "db.login"), - ("","","", ""), - ("Create and add new attribute table to vector map", "Create and add new attribute table to vector map", "self.runMenuCmd", "v.db.addtable"), - ("Copy attribute table", "Copy attribute table", "self.runMenuCmd", "db.copy"), - ("Remove existing attribute table for vector map", "Remove existing attribute table for vector map", "self.runMenuCmd", "v.db.droptable"), - ("","","", ""), - ("Add columns to table", "Add columns to table", "self.runMenuCmd", "v.db.addcol"), - ("Change values in a column", "Change values in a column", "self.runMenuCmd", "v.db.update"), - ("Rename a column", "Rename a column", "self.runMenuCmd", "v.db.renamecol"), - ("","","", ""), - ("Test database", "Test database", "self.runMenuCmd", "db.test"), - )), - ("Database information", ( - ("Describe table", "Describe table", "self.runMenuCmd", "db.describe"), - ("List columns", "List columns", "self.runMenuCmd", "db.columns"), - ("List drivers", "List drivers", "self.runMenuCmd", "db.drivers"), - ("List tables", "List tables", "self.runMenuCmd", "db.tables"), - )), - ("","","", ""), - ("Query", ( - ("Query data in any table", "Query data in any table", "self.runMenuCmd", "db.select"), - ("Query vector attribute data", "Query vector attribute data", "self.runMenuCmd", "db.select"), - ("Execute SQL statement", "Execute SQL statement", "self.runMenuCmd", "db.execute"), - )), - ("Vector<->database connections", ( - ("Reconnect vector map to attribute database", "Reconnect vector map to attribute database", "self.runMenuCmd", "v.db.reconnect.all"), - ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.runMenuCmd", "v.db.connect"), - )), - ("","","", ""), - )), - ("Help", ( - ("GRASS help", "GRASS help", "self.runMenuCmd", "g.manual"), - ("GIS Manager help", "GIS Manager help", "self.runMenuCmd", "GIS Manager help"), - ("About GRASS", "About GRASS", "self.runMenuCmd", "About GRASS"), - ("About System", "About System", "self.runMenuCmd", "About System"), - ("","","", ""), - )), - )] + )] + + + + + + + + + From bundala at grass.itc.it Fri Jun 8 21:58:07 2007 From: bundala at grass.itc.it (bundala@grass.itc.it) Date: Fri Jun 8 21:58:08 2007 Subject: [grass-addons] r809 - trunk/grassaddons/v.generalize Message-ID: <200706081958.l58Jw7FE011520@grass.itc.it> Author: bundala Date: 2007-06-08 21:58:02 +0200 (Fri, 08 Jun 2007) New Revision: 809 Added: trunk/grassaddons/v.generalize/misc.c trunk/grassaddons/v.generalize/misc.h Log: miscellaneous functions Added: trunk/grassaddons/v.generalize/misc.c =================================================================== --- trunk/grassaddons/v.generalize/misc.c (rev 0) +++ trunk/grassaddons/v.generalize/misc.c 2007-06-08 19:58:02 UTC (rev 809) @@ -0,0 +1,85 @@ + +/**************************************************************** + * + * MODULE: v.generalize + * + * AUTHOR(S): Daniel Bundala + * + * PURPOSE: miscellaneous functions of v.generalize + * + * + * COPYRIGHT: (C) 2002-2005 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 +#include +#include +#include "misc.h" + +int check_range(char *s) +{ + int from, to; + char dummy[2]; + if (strlen(s) == 0) + return 0; + + dummy[0] = 0; + if (sscanf(s, "%d-%d%1s", &from, &to, dummy) == 2) + return (from <= to) && (dummy[0] == 0); + + if (sscanf(s, "%d%1s", &from, dummy) == 1) + return (dummy[0] == 0); + + return 0; +}; + +int get_ranges(char **s, RANGE ** out, int *count) +{ + int n, i; + int from, to; + + n = 0; + while (s[n]) + n++; + *count = n; + + *out = (RANGE *) G_malloc(sizeof(RANGE) * n); + + if (!out) { + G_fatal_error(_("Out of memory")); + return 0; + }; + + + for (i = 0; i < n; i++) { + if (strchr(s[i], '-') == NULL) { + sscanf(s[i], "%d", &from); + to = from; + } + else + sscanf(s[i], "%d-%d", &from, &to); + (*out)[i].from = from; + (*out)[i].to = to; + }; + + return 1; +}; + +int cat_test(struct line_cats *Cats, RANGE * r, int n) +{ + int i, j; + + for (i = 0; i < Cats->n_cats; i++) { + for (j = 0; j < n; j++) + if (Cats->cat[i] >= r[j].from && Cats->cat[i] <= r[j].to) + return 1; + }; + + return 0; +}; Property changes on: trunk/grassaddons/v.generalize/misc.c ___________________________________________________________________ Name: svn:executable + * Added: trunk/grassaddons/v.generalize/misc.h =================================================================== --- trunk/grassaddons/v.generalize/misc.h (rev 0) +++ trunk/grassaddons/v.generalize/misc.h 2007-06-08 19:58:02 UTC (rev 809) @@ -0,0 +1,27 @@ +#ifndef MISC_H_ +#define MISC_H_ + +/* denotes the range [from,to] of integers */ +typedef struct +{ + int from, to; +} RANGE; + +/* verifies whether given string is valid (category) range + * either "number-number" where first <= second or "number" + * return 1 on success, 0 otherwise + */ +int check_range(char *s); +/* sets the array of category ranges. Return 1 on success + * this function expects the valid ranges. i.e already checked + * and count is the number of ranges + */ +int get_ranges(char **s, RANGE ** out, int *count); + +/* tests whether at least one cetagory number lies in at least + * one range. Where n is the number of ranges in r. + * return 1 on success, 0 otherwise + */ +int cat_test(struct line_cats *Cats, RANGE * r, int n); + +#endif Property changes on: trunk/grassaddons/v.generalize/misc.h ___________________________________________________________________ Name: svn:executable + * From bundala at grass.itc.it Fri Jun 8 22:01:21 2007 From: bundala at grass.itc.it (bundala@grass.itc.it) Date: Fri Jun 8 22:01:22 2007 Subject: [grass-addons] r810 - trunk/grassaddons/v.generalize Message-ID: <200706082001.l58K1Lpv011559@grass.itc.it> Author: bundala Date: 2007-06-08 22:01:16 +0200 (Fri, 08 Jun 2007) New Revision: 810 Modified: trunk/grassaddons/v.generalize/main.c trunk/grassaddons/v.generalize/point.c trunk/grassaddons/v.generalize/point.h trunk/grassaddons/v.generalize/simplification.c trunk/grassaddons/v.generalize/smoothing.c Log: new features and hermite interpolation Modified: trunk/grassaddons/v.generalize/main.c =================================================================== --- trunk/grassaddons/v.generalize/main.c 2007-06-08 19:58:02 UTC (rev 809) +++ trunk/grassaddons/v.generalize/main.c 2007-06-08 20:01:16 UTC (rev 810) @@ -21,6 +21,7 @@ #include #include #include +#include "misc.h" #define DOUGLASS 0 #define LANG 1 @@ -29,20 +30,25 @@ #define BOYLE 4 #define DISTANCE_WEIGHTING 5 #define CHAIKEN 6 +#define HERMITE 7 int main(int argc, char *argv[]) { struct Map_info In, Out; static struct line_pnts *Points; struct line_cats *Cats; - int i, type, cat; + int i, type, cat, iter; char *mapset; struct GModule *module; /* GRASS module for parsing arguments */ - struct Option *map_in, *map_out, *thresh_opt, *method_opt; + struct Option *map_in, *map_out, *thresh_opt, *method_opt, *look_ahead_opt; + struct Option *iterations_opt, *cat_opt; int with_z; int total_input, total_output; /* Number of points in the input/output map respectively */ double thresh; int method; + int look_ahead, iterations; + RANGE *ranges; + int n_ranges; /* initialize GIS environment */ G_gisinit(argv[0]); /* reads grass env, stores program name to G_program_name() */ @@ -62,7 +68,7 @@ method_opt->required = YES; method_opt->multiple = NO; method_opt->options = - "douglas,lang,reduction,reumann,boyle,distance_weighting,chaiken"; + "douglas,lang,reduction,reumann,boyle,distance_weighting,chaiken,hermite"; method_opt->answer = "douglas"; method_opt->descriptions = "douglas;Douglass-Peucker Algorithm;" "lang;Lang Simplification Algorithm;" @@ -70,7 +76,8 @@ "reumann;Reumann-Witkam Algorithm;" "boyle;Boyle's Forward-Looking Algorithm;" "distance_weighting;McMaster's Distance-Weighting Algorithm;" - "chaiken;Chaiken's Algorithm;"; + "chaiken;Chaiken's Algorithm;" + "hermite;Interpolation by Cubic Hermite Splines;"; method_opt->description = _("Line simplification/smoothing algorithm"); thresh_opt = G_define_option(); @@ -78,14 +85,53 @@ thresh_opt->type = TYPE_DOUBLE; thresh_opt->required = YES; thresh_opt->options = "0-1000000000"; + thresh_opt->answer = "1.0"; thresh_opt->description = _("Maximal tolerance value"); + look_ahead_opt = G_define_option(); + look_ahead_opt->key = "look_ahead"; + look_ahead_opt->type = TYPE_INTEGER; + look_ahead_opt->required = YES; + look_ahead_opt->answer = "7"; + look_ahead_opt->description = _("Look-ahead parameter"); + + iterations_opt = G_define_option(); + iterations_opt->key = "iterations"; + iterations_opt->type = TYPE_INTEGER; + iterations_opt->required = YES; + iterations_opt->answer = "1"; + iterations_opt->description = _("Number of iterations"); + + cat_opt = G_define_option(); + cat_opt->key = "category"; + cat_opt->type = TYPE_STRING; + cat_opt->required = NO; + cat_opt->multiple = YES; + cat_opt->key_desc = "range"; + cat_opt->description = _("Category ranges: e.g. 1,3-8,13"); + /* options and flags parser */ if (G_parser(argc, argv)) exit(EXIT_FAILURE); thresh = atof(thresh_opt->answer); + look_ahead = atoi(look_ahead_opt->answer); + iterations = atoi(iterations_opt->answer); + + /* check and store category ranges */ + if (cat_opt->answer != NULL) { + for (i = 0; cat_opt->answers[i]; i++) + if (!check_range(cat_opt->answers[i])) { + G_fatal_error(_("Bad category range in (%s)"), + cat_opt->answers[i]); + exit(-1); + }; + get_ranges(cat_opt->answers, &ranges, &n_ranges); + } + else + ranges = NULL; + G_message(method_opt->answer); if (method_opt->answer[0] == 'd' && method_opt->answer[1] == 'o') { @@ -106,8 +152,11 @@ else if (method_opt->answer[0] == 'd') { method = DISTANCE_WEIGHTING; } + else if (method_opt->answer[0] == 'c') { + method = CHAIKEN; + } else { - method = CHAIKEN; + method = HERMITE; }; Points = Vect_new_line_struct(); @@ -140,43 +189,53 @@ i = 1; while ((type = Vect_read_next_line(&In, Points, Cats)) > 0) { total_input += Points->n_points; - if (type == GV_LINE || 1 == 1) { + if ((type == GV_LINE || 1 == 1) && + (ranges == NULL || cat_test(Cats, ranges, n_ranges))) { int after = 0; - - if (method == DOUGLASS) { - after = douglass_peucker(Points, thresh, with_z); - } - else if (method == LANG) { - after = lang(Points, thresh, 7, with_z); - } - else if (method == VERTEX_REDUCTION) { - after = vertex_reduction(Points, thresh, with_z); - } - else if (method == REUMANN) { - after = reumann_witkam(Points, thresh, with_z); - } - else if (method == BOYLE) { - after = boyle(Points, 5, with_z); - } - else if (method == DISTANCE_WEIGHTING) { - after = distance_weighting(Points, thresh, 11, with_z); - } - else { - after = chaiken(Points, thresh, with_z); + for (iter = 0; iter < iterations; iter++) { + if (method == DOUGLASS) { + after = douglass_peucker(Points, thresh, with_z); + } + else if (method == LANG) { + after = lang(Points, thresh, look_ahead, with_z); + } + else if (method == VERTEX_REDUCTION) { + after = vertex_reduction(Points, thresh, with_z); + } + else if (method == REUMANN) { + after = reumann_witkam(Points, thresh, with_z); + } + else if (method == BOYLE) { + after = boyle(Points, look_ahead, with_z); + } + else if (method == DISTANCE_WEIGHTING) { + after = + distance_weighting(Points, thresh, look_ahead, with_z); + } + else if (method == CHAIKEN) { + after = chaiken(Points, thresh, with_z); + } + else { + after = hermite(Points, thresh, with_z); + }; }; + after = Points->n_points; total_output += after; Vect_write_line(&Out, type, Points, Cats); } else { - total_output += Vect_write_line(&Out, type, Points, Cats); + total_output += Points->n_points; + Vect_write_line(&Out, type, Points, Cats); }; } G_message("Number of vertices was reduced from %d to %d[%d%%]", total_input, total_output, (total_output * 100) / total_input); + G_free(ranges); + Vect_build(&Out, stdout); Vect_close(&In); Vect_close(&Out); Modified: trunk/grassaddons/v.generalize/point.c =================================================================== --- trunk/grassaddons/v.generalize/point.c 2007-06-08 19:58:02 UTC (rev 809) +++ trunk/grassaddons/v.generalize/point.c 2007-06-08 20:01:16 UTC (rev 810) @@ -98,6 +98,8 @@ }; pl->next = NULL; + if (p.x < 10) + printf("%lf\n", p.x); pl->p = p; return pl; }; @@ -117,7 +119,7 @@ int length, i; POINT_LIST *cur; - cur = &l; + cur = l.next; length = 0; while (cur != NULL) { @@ -130,7 +132,7 @@ Points->n_points = length; - cur = &l; + cur = l.next; for (i = 0; i < length; i++) { Points->x[i] = cur->p.x; Points->y[i] = cur->p.y; @@ -140,3 +142,14 @@ return 0; }; + +void point_list_free(POINT_LIST l) +{ + POINT_LIST *p, *n; + p = l.next; + while (p != NULL) { + n = p->next; + G_free(p); + p = n; + }; +}; Modified: trunk/grassaddons/v.generalize/point.h =================================================================== --- trunk/grassaddons/v.generalize/point.h 2007-06-08 19:58:02 UTC (rev 809) +++ trunk/grassaddons/v.generalize/point.h 2007-06-08 20:01:16 UTC (rev 810) @@ -33,18 +33,33 @@ struct Point_list *next; } POINT_LIST; +/* res = a - b */ extern inline void point_subtract(POINT a, POINT b, POINT * res); +/* res = a + b */ extern inline void point_add(POINT a, POINT b, POINT * res); +/* dot product of two vectors: ax * bx + ay * by + az * bz */ extern double point_dot(POINT a, POINT b); +/* squared distance from the origin */ extern inline double point_dist2(POINT a); +/* assign point Points[index] to the res + * if with z = 0 then res.z = 0 + */ extern inline void point_assign(struct line_pnts *Points, int index, int with_z, POINT * res); +/* res = k * a */ extern inline void point_scalar(POINT a, double k, POINT * res); +/* copy the last point of Points to Points[pos] */ extern inline void points_copy_last(struct line_pnts *Points, int pos); +/* distance between two points */ extern inline double point_dist(POINT a, POINT b); +/* creates empty list of points */ extern POINT_LIST *point_list_new(POINT p); +/* insert new value to the list just after the l. i.e l->next.p = p */ extern void point_list_add(POINT_LIST * l, POINT p); -/* return 0 on success, -1 on out of memory */ +/* copy POINT_LIST structure into line_pnts structure + * return 0 on success, -1 on out of memory + */ extern int point_list_copy_to_line_pnts(POINT_LIST l, struct line_pnts *Points); - +/*free the momory occupied by the list at l.next */ +extern void point_list_free(POINT_LIST l); #endif Modified: trunk/grassaddons/v.generalize/simplification.c =================================================================== --- trunk/grassaddons/v.generalize/simplification.c 2007-06-08 19:58:02 UTC (rev 809) +++ trunk/grassaddons/v.generalize/simplification.c 2007-06-08 20:01:16 UTC (rev 810) @@ -28,17 +28,17 @@ { int *stack = G_malloc(sizeof(int) * Points->n_points * 2); - if (!stack){ - G_fatal_error(_("Out of memory")); - return Points->n_points; + if (!stack) { + G_fatal_error(_("Out of memory")); + return Points->n_points; }; int *index = G_malloc(sizeof(int) * Points->n_points); /* Indices of points in output line */ - if (!index){ - G_fatal_error(_("Out of memory")); - G_fre(stack); - return Points->n_points; + if (!index) { + G_fatal_error(_("Out of memory")); + G_fre(stack); + return Points->n_points; }; int top = 2; /* first free slot in the stack */ Modified: trunk/grassaddons/v.generalize/smoothing.c =================================================================== --- trunk/grassaddons/v.generalize/smoothing.c 2007-06-08 19:58:02 UTC (rev 809) +++ trunk/grassaddons/v.generalize/smoothing.c 2007-06-08 20:01:16 UTC (rev 810) @@ -81,10 +81,10 @@ }; res = (POINT *) G_malloc(sizeof(POINT) * n); - if (!res){ - G_fatal_error(_("Out of memory")); - return n; - }; + if (!res) { + G_fatal_error(_("Out of memory")); + return n; + }; point_assign(Points, 0, with_z, &res[0]); @@ -190,6 +190,113 @@ G_fatal_error(_("Out of Memory")); exit(1); }; + point_list_free(head); + return Points->n_points; +}; + +/* use for refining tangent in hermite interpolation */ +void refine_tangent(POINT * p) +{ + double l = point_dist2(*p); + if (l < 0.0000001) + return; + point_scalar(*p, 1 / sqrt(sqrt(sqrt(l))), p); + return; +}; + +/* approximates given line using hermite cubic spline + * interpolates by steps of length step + * returns the number of point in result + */ +int hermite(struct line_pnts *Points, double step, int with_z) +{ + POINT_LIST head, *last; + POINT p0, p1, t0, t1, tmp, res; + double length, next, length_begin, l; + double s; + double h1, h2, h3, h4; + int n, i; + int ni; + + n = Points->n_points; + + /* line is too short */ + if (n <= 2) { + return 1; + }; + + head.next = NULL; + last = &head; + + /* length of p[0]..p[i+1] */ + i = 0; + point_assign(Points, 0, with_z, &p0); + point_assign(Points, 1, with_z, &p1); + /* length of line 0..i */ + length_begin = 0; + /* length of line from point 0 to i+1 */ + length = point_dist(p0, p1); + next = 0; + /* tangent at p0, p1 */ + point_subtract(p1, p0, &t0); + refine_tangent(&t0); + point_assign(Points, 2, with_z, &tmp); + point_subtract(tmp, p0, &t1); + refine_tangent(&t1); + + + /* we always operate on the segment point[i]..point[i+1] */ + while (i < n - 1) { + if (next > length || (length - length_begin < 0.0000001)) { /* segmet i..i+1 is finished or too short */ + i++; + if (i >= n - 1) + break; /* we are already out out of line */ + point_assign(Points, i, with_z, &p0); + point_assign(Points, i + 1, with_z, &p1); + length_begin = length; + length += point_dist(p0, p1); + ni = i + 2; + if (ni > n - 1) + ni = n - 1; /* ensure that we are in the line */ + t0 = t1; + point_assign(Points, ni, with_z, &tmp); + point_subtract(tmp, p0, &t1); + refine_tangent(&t1); + } + else { + l = length - length_begin; /* length of actual segment */ + s = (next - length_begin) / l; /* 0<=s<=1 where we want to add new point on the line */ + + /* then we need to calculate 4 control polynomials */ + h1 = 2 * s * s * s - 3 * s * s + 1; + h2 = -2 * s * s * s + 3 * s * s; + h3 = s * s * s - 2 * s * s + s; + h4 = s * s * s - s * s; + + point_scalar(p0, h1, &res); + point_scalar(p1, h2, &tmp); + point_add(res, tmp, &res); + point_scalar(t0, h3, &tmp); + point_add(res, tmp, &res); + point_scalar(t1, h4, &tmp); + point_add(res, tmp, &res); + point_list_add(last, res); + last = last->next; + + next += step; + }; + }; + + + point_assign(Points, n - 1, with_z, &p0); + point_list_add(last, p0); + + if (point_list_copy_to_line_pnts(head, Points) == -1) { + G_fatal_error(_("Out of memory")); + exit(1); + }; + + point_list_free(head); return Points->n_points; }; From chemin at grass.itc.it Sat Jun 9 09:34:37 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Sat Jun 9 09:34:39 2007 Subject: [grass-addons] r811 - in trunk/grassaddons/gipe: . i.latitude Message-ID: <200706090734.l597YbVU003172@grass.itc.it> Author: chemin Date: 2007-06-09 09:34:29 +0200 (Sat, 09 Jun 2007) New Revision: 811 Modified: trunk/grassaddons/gipe/Makefile trunk/grassaddons/gipe/i.latitude/description.html trunk/grassaddons/gipe/imagery_Makefile trunk/grassaddons/gipe/install_yanns_grass.sh trunk/grassaddons/gipe/menudata.py Log: Updated installer script and other minor changes Modified: trunk/grassaddons/gipe/Makefile =================================================================== --- trunk/grassaddons/gipe/Makefile 2007-06-08 20:01:16 UTC (rev 810) +++ trunk/grassaddons/gipe/Makefile 2007-06-09 07:34:29 UTC (rev 811) @@ -25,6 +25,7 @@ r.distance \ r.drain \ r.evapo.MH \ + r.evapo.PM \ r.fill.dir \ r.flow \ r.gaswap.serial \ Modified: trunk/grassaddons/gipe/i.latitude/description.html =================================================================== --- trunk/grassaddons/gipe/i.latitude/description.html 2007-06-08 20:01:16 UTC (rev 810) +++ trunk/grassaddons/gipe/i.latitude/description.html 2007-06-09 07:34:29 UTC (rev 811) @@ -1,6 +1,7 @@

DESCRIPTION

i.latitude creates a latitude (degree decimal) map from any map in any projection using PROJ.4 library. +This is an input to r.sun and i.evapo.potrad

NOTES

The proj website. @@ -12,13 +13,14 @@ i.evapo.potrad
+r.sun

AUTHORS

-Yann Chemin, Asian Institute of Technology, Thailand
+Yann Chemin

-Last changed: $Date: 2006/10/13 22:19:55 $ +Last changed: $Date: 2007/06/09 22:19:55 $ Modified: trunk/grassaddons/gipe/imagery_Makefile =================================================================== --- trunk/grassaddons/gipe/imagery_Makefile 2007-06-08 20:01:16 UTC (rev 810) +++ trunk/grassaddons/gipe/imagery_Makefile 2007-06-09 07:34:29 UTC (rev 811) @@ -40,6 +40,18 @@ i.maxlik \ i.ortho.photo \ i.points \ + 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_sites_aggregate \ + i.pr_statistics \ + i.pr_subsets \ + i.pr_training \ + i.pr_uxb \ i.rectify \ i.rgb.his \ i.sattime \ Modified: trunk/grassaddons/gipe/install_yanns_grass.sh =================================================================== --- trunk/grassaddons/gipe/install_yanns_grass.sh 2007-06-08 20:01:16 UTC (rev 810) +++ trunk/grassaddons/gipe/install_yanns_grass.sh 2007-06-09 07:34:29 UTC (rev 811) @@ -13,7 +13,7 @@ SVNDIR=$('pwd') cd HydroFOSS HFDIR=$('pwd') -cd ../GUI +cd ../gui WXDIR=$('pwd') #INSTALL GUI MODIFICATIONS @@ -54,11 +54,11 @@ cd $SVNDIR/ for directory in i.* do - cp -rf $GIPEDIR/$directory $GRASSCVSDIR/imagery/ + cp -rf $SVNDIR/$directory $GRASSCVSDIR/imagery/ done -cd $SVNDIR/ -for directory in i.pr/i.* +cd $SVNDIR/i.pr/ +for directory in i.* do cp -rf $SVNDIR/i.pr/$directory $GRASSCVSDIR/imagery/ done Modified: trunk/grassaddons/gipe/menudata.py =================================================================== --- trunk/grassaddons/gipe/menudata.py 2007-06-08 20:01:16 UTC (rev 810) +++ trunk/grassaddons/gipe/menudata.py 2007-06-09 07:34:29 UTC (rev 811) @@ -441,7 +441,7 @@ ("ETo, ETP, ETa", ( ("Reference ET (Hargreaves)", "Reference ET (Hargreaves)", "self.RunMenuCmd", "r.evapo.MH"), ("","","", ""), - ("Potential ET (Penman-Monteith)", "Potential ET (Penman-Monteith)", "self.RunMenuCmd", "r.evapo.PM"), + ("Potential ET (Penman-Monteith)", "Potential ET (Penman-Monteith)", "self.OnMenuCmd", "r.evapo.PM"), ("Potential ET (Prestley and Taylor)", "Potential ET (Prestley and Taylor)", "self.RunMenuCmd", "i.evapo.PT"), ("Potential ET (Radiative)", "Potential ET (Radiative)", "self.RunMenuCmd", "i.evapo.potrad"), ("Potential ET (Radiative) from L7DN (.met)", "Potential ET (Radiative) from L7DN (.met)", "self.RunMenuCmd", "i.dn2potrad.l7"), From chemin at grass.itc.it Sat Jun 9 11:53:29 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Sat Jun 9 11:53:31 2007 Subject: [grass-addons] r812 - trunk/grassaddons/gipe Message-ID: <200706090953.l599rTTE004275@grass.itc.it> Author: chemin Date: 2007-06-09 11:53:25 +0200 (Sat, 09 Jun 2007) New Revision: 812 Modified: trunk/grassaddons/gipe/imagery_Makefile trunk/grassaddons/gipe/menudata.py Log: Updated GUI for workflow Modified: trunk/grassaddons/gipe/imagery_Makefile =================================================================== --- trunk/grassaddons/gipe/imagery_Makefile 2007-06-09 07:34:29 UTC (rev 811) +++ trunk/grassaddons/gipe/imagery_Makefile 2007-06-09 09:53:25 UTC (rev 812) @@ -37,6 +37,7 @@ i.group \ i.his.rgb \ i.latitude \ + i.landsat.dehaze \ i.maxlik \ i.ortho.photo \ i.points \ Modified: trunk/grassaddons/gipe/menudata.py =================================================================== --- trunk/grassaddons/gipe/menudata.py 2007-06-09 07:34:29 UTC (rev 811) +++ trunk/grassaddons/gipe/menudata.py 2007-06-09 09:53:25 UTC (rev 812) @@ -412,32 +412,32 @@ ("Rectify and georeference image group", ( ("Set ground control points (GCP's) from raster map or keyboard entry", "Set ground control points (GCP's) from raster map or keyboard entry", "self.OnMenuCmd", "i.points"), ("Set ground control points (GCP's) from vector map or keyboard entry", "Set ground control points (GCP's) from vector map or keyboard entry", "self.OnMenuCmd", "i.vpoints"), + ("","","", ""), ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.OnMenuCmd", "i.rectify"), ("Ortho Photo rectification", "Ortho Photo rectification", "self.OnMenuCmd", "i.ortho.photo"), )), ("","","", ""), - ("GIPE", ( - ("DN2Rad2Ref", ( - ("Landsat 7 ETM+", "Landsat 7 ETM+", "self.RunMenuCmd", "i.dn2ref.l7"), - ("Landsat 7 ETM+ (from .met)", "Landsat 7 ETM+ (from .met)", "self.RunMenuCmd", "i.dn2full.l7"), - ("Terra-Aster", "Terra-Aster", "self.RunMenuCmd", "i.dn2ref.ast"), - ("","","", ""), - ("Atmospheric correction", "Atmospheric correction", "self.RunMenuCmd", "i.atcorr"), - ("Dehaze Landsat", "Dehaze Landsat", "self.RunMenuCmd", "i.landsat.dehaze"), - )), - ("Basic RS processing", ( - ("Vegetation Index (Tasseled cap)", "Vegetation index (Tasseled cap)", "self.OnMenuCmd", "i.tasscap"), - ("Vegetation Indices (13 types)", "Vegetation Indices (13 types)", "self.RunMenuCmd", "i.vi"), - ("Vegetation Indices (13 types) cluster", "Vegetation Indices (13 types) cluster", "self.RunMenuCmd", "i.vi.mpi"), - ("","","", ""), - ("Albedo", "Albedo", "self.RunMenuCmd", "i.albedo"), - ("Emissivity (generic from NDVI)", "Emissivity (generic from NDVI)", "self.RunMenuCmd", "i.emissivity"), - ("","","", ""), - ("Latitude map", "Latitude map", "self.RunMenuCmd", "i.latitude"), - ("Sunshine hours (potential)", "Sunshine hours (potential)", "self.RunMenuCmd", "i.sunhours"), - ("Satellite overpass time", "Satellite overpass time", "self.RunMenuCmd", "i.sattime"), - )), + ("RS Pre-Processing (DN->Rad->Ref)", ( + ("Landsat 7 ETM+", "Landsat 7 ETM+", "self.RunMenuCmd", "i.dn2ref.l7"), + ("Landsat 7 ETM+ (from .met)", "Landsat 7 ETM+ (from .met)", "self.RunMenuCmd", "i.dn2full.l7"), + ("Terra-Aster", "Terra-Aster", "self.RunMenuCmd", "i.dn2ref.ast"), ("","","", ""), + ("Atmospheric correction", "Atmospheric correction", "self.RunMenuCmd", "i.atcorr"), + ("Dehaze Landsat", "Dehaze Landsat", "self.RunMenuCmd", "i.landsat.dehaze"), + )), + ("RS Processing (Basic)", ( + ("Vegetation Index (Tasseled cap)", "Vegetation index (Tasseled cap)", "self.OnMenuCmd", "i.tasscap"), + ("Vegetation Indices (13 types)", "Vegetation Indices (13 types)", "self.RunMenuCmd", "i.vi"), + ("Vegetation Indices (13 types) cluster", "Vegetation Indices (13 types) cluster", "self.RunMenuCmd", "i.vi.mpi"), + ("","","", ""), + ("Albedo", "Albedo", "self.RunMenuCmd", "i.albedo"), + ("Emissivity (generic from NDVI)", "Emissivity (generic from NDVI)", "self.RunMenuCmd", "i.emissivity"), + ("","","", ""), + ("Latitude map", "Latitude map", "self.RunMenuCmd", "i.latitude"), + ("Sunshine hours (potential)", "Sunshine hours (potential)", "self.RunMenuCmd", "i.sunhours"), + ("Satellite overpass time", "Satellite overpass time", "self.RunMenuCmd", "i.sattime"), + )), + ("RS Processing (Advanced)", ( ("ETo, ETP, ETa", ( ("Reference ET (Hargreaves)", "Reference ET (Hargreaves)", "self.RunMenuCmd", "r.evapo.MH"), ("","","", ""), @@ -468,25 +468,23 @@ ("Evaporative fraction", "evaporative fraction", "self.RunMenuCmd", "i.eb.evapfr"), )), ("","","", ""), - ("Biomass", ( - ("Biomass growth", "Biomass growth", "self.RunMenuCmd", "i.biomass"), - )), + ("Biomass growth", "Biomass growth", "self.RunMenuCmd", "i.biomass"), )), - ("Classify image", ( - ("Classify using pr library", ( - ("blob", "pr_blob", "self.RunMenuCmd", "i.pr_blob"), - ("classify", "pr_classify", "self.RunMenuCmd", "i.pr_classify"), - ("features", "pr_features", "self.RunMenuCmd", "i.pr_features"), - ("features_additional", "pr_features_additional", "self.RunMenuCmd", "i.pr_features_additional"), - ("features_extract", "pr_features_extract", "self.RunMenuCmd", "i.pr_features_extract"), - ("features_selection", "pr_features_selection", "self.RunMenuCmd", "i.pr_features_selection"), - ("model", "pr_model", "self.RunMenuCmd", "i.pr_model"), - ("sites_aggregate", "pr_sites_aggregate", "self.RunMenuCmd", "i.pr_sites_aggregate"), - ("statistics", "pr_statistics", "self.RunMenuCmd", "i.pr_statistics"), - ("subsets", "pr_subsets", "self.RunMenuCmd", "i.pr_subsets"), - ("training", "pr_training", "self.RunMenuCmd", "i.pr_training"), - ("uxb", "pr_uxb", "self.RunMenuCmd", "i.pr_uxb"), - )), + ("","","", ""), + ("Filter image", ( + ("Zero edge crossing detection", "Zero edge crossing detection", "self.OnMenuCmd", "i.zc"), + ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.OnMenuCmd", "r.mfilter"), + )), + ("Transform image", ( + ("Brovey pan sharpening", "Brovey pan sharpening", "self.OnMenuCmd", "i.fusion.brovey"), + ("","","", ""), + ("Canonical component", "Canonical component", "self.OnMenuCmd", "i.cca"), + ("Principal component", "Principal component", "self.OnMenuCmd", "i.pca"), + ("Fast Fourier Transform", "Fast Fourier Transform", "self.OnMenuCmd", "i.fft"), + ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.OnMenuCmd", "i.ifft"), + )), + ("","","", ""), + ("Classify image (Standard)", ( ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.OnMenuCmd", "i.cluster"), ("","","", ""), ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.OnMenuCmd", "i.maxlik"), @@ -498,18 +496,23 @@ ("","","", ""), ("Kappa classification accuracy assessment", "Kappa classification accuracy assessment", "self.OnMenuCmd", "r.kappa"), )), - ("Filter image", ( - ("Zero edge crossing detection", "Zero edge crossing detection", "self.OnMenuCmd", "i.zc"), - ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.OnMenuCmd", "r.mfilter"), - )), - ("Transform image", ( - ("Canonical component", "Canonical component", "self.OnMenuCmd", "i.cca"), - ("Principal component", "Principal component", "self.OnMenuCmd", "i.pca"), - ("Fast Fourier Transform", "Fast Fourier Transform", "self.OnMenuCmd", "i.fft"), - ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.OnMenuCmd", "i.ifft"), - ("","","", ""), - ("Brovey pan sharpening", "Brovey pan sharpening", "self.OnMenuCmd", "i.fusion.brovey"), - )), + ("Classify image (pr library)", ( + ("subsets", "pr_subsets", "self.RunMenuCmd", "i.pr_subsets"), + ("training", "pr_training", "self.RunMenuCmd", "i.pr_training"), + ("classify", "pr_classify", "self.RunMenuCmd", "i.pr_classify"), + ("","","", ""), + ("features", "pr_features", "self.RunMenuCmd", "i.pr_features"), + ("features_additional", "pr_features_additional", "self.RunMenuCmd", "i.pr_features_additional"), + ("features_extract", "pr_features_extract", "self.RunMenuCmd", "i.pr_features_extract"), + ("features_selection", "pr_features_selection", "self.RunMenuCmd", "i.pr_features_selection"), + ("","","", ""), + ("model", "pr_model", "self.RunMenuCmd", "i.pr_model"), + ("sites_aggregate", "pr_sites_aggregate", "self.RunMenuCmd", "i.pr_sites_aggregate"), + ("blob", "pr_blob", "self.RunMenuCmd", "i.pr_blob"), + ("uxb", "pr_uxb", "self.RunMenuCmd", "i.pr_uxb"), + ("","","", ""), + ("statistics", "pr_statistics", "self.RunMenuCmd", "i.pr_statistics"), + )), ("","","", ""), ("Quality Analysis", ( ("Bit pattern comparison for ID of low quality pixels", "Bit pattern comparison for ID of low quality pixels", "self.OnMenuCmd", "r.bitpattern"), @@ -530,6 +533,7 @@ )), ("Create 3D mask for grid3D operations", "Create 3D mask for grid3D operations", "self.RunMenuCmd", "r3.mask"), ("Create 2D raster cross section from grid3d volume", "Create 2D raster cross section from grid3d volume", "self.RunMenuCmd", "r3.cross.rast"), + ("","","", ""), ("Map calculator for grid3D operations", "Map calculator for grid3D operations", "self.RunMenuCmd", "r3.mapcalculator"), ("Interpolate volume from vector points using splines", "Interpolate volume from vector points using splines", "self.RunMenuCmd", "v.vol.rst"), ("","","", ""), From landa at grass.itc.it Sat Jun 9 13:21:36 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Sat Jun 9 13:21:38 2007 Subject: [grass-addons] r813 - trunk/grassaddons/gui/gui_modules Message-ID: <200706091121.l59BLa7a004403@grass.itc.it> Author: landa Date: 2007-06-09 13:21:24 +0200 (Sat, 09 Jun 2007) New Revision: 813 Modified: trunk/grassaddons/gui/gui_modules/menuform.py Log: minor fix OnCopy(): cmdlist -> cmdstring Modified: trunk/grassaddons/gui/gui_modules/menuform.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menuform.py 2007-06-09 09:53:25 UTC (rev 812) +++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-06-09 11:21:24 UTC (rev 813) @@ -644,13 +644,15 @@ def OnCopy(self, event): """Copy the command""" cmddata = wx.TextDataObject() - cmddata.SetText(self.createCmd(ignoreErrors=True)) + # list -> string + cmdstring = ' '.join(self.createCmd(ignoreErrors=True)) + cmddata.SetText(cmdstring) if wx.TheClipboard.Open(): wx.TheClipboard.UsePrimarySelection(True) wx.TheClipboard.SetData(cmddata) wx.TheClipboard.Close() - self.SetStatusText( _("'%s' copied to clipboard") %\ - (self.createCmd(ignoreErrors=True))) + self.SetStatusText( _("'%s' copied to clipboard") % \ + (cmdstring)) def OnCancel(self, event): """Cancel button pressed""" From landa at grass.itc.it Sat Jun 9 13:41:12 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Sat Jun 9 13:41:13 2007 Subject: [grass-addons] r814 - trunk/grassaddons/gui/gui_modules Message-ID: <200706091141.l59BfC8X004460@grass.itc.it> Author: landa Date: 2007-06-09 13:40:50 +0200 (Sat, 09 Jun 2007) New Revision: 814 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py Log: Reenable query tool, minor code cleaning Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-09 11:21:24 UTC (rev 813) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-09 11:40:50 UTC (rev 814) @@ -640,7 +640,7 @@ Debug.msg (5, "BufferedWindow.OnLeftDown(): use=%s" % \ self.mouse["use"]) - if self.mouse["use"] == "measure" or self.mouse["use"] == "profile" or \ + if self.mouse["use"] in ["measure", "profile"] or \ (self.mouse["use"] == "pointer" and self.parent.digittoolbar): # measure || profile || digit tool if len(self.polycoords) == 0: @@ -652,7 +652,8 @@ self.mouse['begin'] = self.mouse['end'] else: # get decoration id self.lastpos = self.mouse['begin'] = event.GetPositionTuple()[:] - idlist = self.pdc.FindObjects(x=self.lastpos[0], y=self.lastpos[1], radius=self.hitradius) + idlist = self.pdc.FindObjects(x=self.lastpos[0], y=self.lastpos[1], + radius=self.hitradius) if idlist != []: self.dragid = idlist[0] @@ -663,7 +664,7 @@ Debug.msg (5, "BufferedWindow.OnLeftUp(): use=%s" % \ self.mouse["use"]) - if self.mouse['use'] == "zoom" or self.mouse['use'] == "pan": + if self.mouse['use'] in ["zoom", "pan"]: # end point of zoom box or drag self.mouse['end'] = event.GetPositionTuple()[:] @@ -673,21 +674,53 @@ # redraw map self.render=True self.UpdateMap() + elif self.mouse["use"] == "query": # querying self.parent.QueryMap(self.mouse['begin'][0],self.mouse['begin'][1]) - elif self.mouse["use"] == "measure" or self.mouse["use"] == "profile" or \ - (self.mouse["use"] == "pointer" and self.parent.digittoolbar): - # measure || profile || digit tool + + elif self.mouse["use"] in ["measure", "profile"]: + # measure or profile self.mouse['end'] = event.GetPositionTuple()[:] if self.mouse["use"] == "measure": - self.parent.MeasureDist(self.mouse['begin'],self.mouse['end']) + self.parent.MeasureDist(self.mouse['begin'], self.mouse['end']) try: self.polycoords.append(self.mouse['end']) self.pdc.ClearId(self.lineid) self.DrawLines() except: pass + elif self.mouse["use"] == "pointer" and self.parent.digittoolbar: + # digit tool + digit = self.parent.digittoolbar + if digit.action == "add": + try: + map = digit.layers[digit.layerID].name + except: + map = None + dlg = wx.MessageDialog(self, _("No vector map layer selected for editing"), + _("Error"), wx.OK | wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() + + if map: + east, north = self.Pixel2Cell(self.mouse['begin'][0], + self.mouse['begin'][1]) + if digit.type in ["point", "centroid"]: + # add new point + Digit.AddPoint(map=map, + type=digit.type, + x=east, y=north) + elif digit.type in ["line", "boundary"]: + # add new point to the line + Debug.msg (3, "BufferedWindow.MouseAction(): new saved pos=%f,%f" % \ + (east, north)) + self.savedpos.append ((east, north)) + + # redraw map + self.render=True + self.UpdateMap() + elif self.dragid != None: # end drag of overlay decoration self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid) @@ -696,34 +729,7 @@ id = None self.Update() -# # digitizing -# elif self.parent.digittoolbar: -# if self.parent.digittoolbar.action == "add": -# try: -# map = self.parent.digittoolbar.layers[self.parent.digittoolbar.layerID].name -# except: -# map = None -# dlg = wx.MessageDialog(self, _("No vector map layer selected for editing"), -# _("Error"), wx.OK | wx.ICON_ERROR) -# dlg.ShowModal() -# dlg.Destroy() -# if map: -# east, north = self.Pixel2Cell(self.mouse['begin'][0],self.mouse['begin'][1]) -# if self.parent.digittoolbar.type in ["point", "centroid"]: -# # add new point -# Digit.AddPoint(map=map, -# type=self.parent.digittoolbar.type, -# x=east, y=north) -# elif self.parent.digittoolbar.type in ["line", "boundary"]: -# # add new point to the line -# Debug.msg (3, "BufferedWindow.MouseAction(): new saved pos=%f,%f" % (east, north)) -# self.savedpos.append ((east, north)) - -# # redraw map -# self.render=True -# self.UpdateMap() - def OnButtonDClick(self, event): """ Mouse button double click @@ -1121,7 +1127,9 @@ self.layerbook = notebook #GIS Manager layer tree notebook # available cursors self.cursors = { - "default" : wx.StockCursor(wx.CURSOR_DEFAULT), + # default: cross + # "default" : wx.StockCursor(wx.CURSOR_DEFAULT), + "default" : wx.StockCursor(wx.CURSOR_CROSS), "cross" : wx.StockCursor(wx.CURSOR_CROSS), "hand" : wx.StockCursor(wx.CURSOR_HAND), "pencil" : wx.StockCursor(wx.CURSOR_PENCIL), @@ -1485,13 +1493,13 @@ # change the cursor self.MapWindow.SetCursor(self.cursors["cross"]) - def QueryMap(self,x,y): + def QueryMap(self, x, y): """ Run *.what command in gis manager output window """ #set query snap distance for v.what at mapunit equivalent of 10 pixels - qdist = 10.0 * ((self.Map.region['e'] - self.Map.region['w'])/self.Map.width) - east,north = self.MapWindow.Pixel2Cell(x,y) + qdist = 10.0 * ((self.Map.region['e'] - self.Map.region['w']) / self.Map.width) + east,north = self.MapWindow.Pixel2Cell(x, y) if self.tree.GetSelections(): mapname = None @@ -1539,9 +1547,9 @@ # parse query command(s) if self.gismanager: if rcmd: - self.gismanager.goutput.runCmd(' '.join(rcmd)) + self.gismanager.goutput.RunCmd(' '.join(rcmd)) if vcmd: - self.gismanager.goutput.runCmd(' '.join(vcmd)) + self.gismanager.goutput.RunCmd(' '.join(vcmd)) else: os.system(' '.join(rcmd)) os.system(' '.join(vcmd)) From landa at grass.itc.it Sun Jun 10 20:33:46 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Sun Jun 10 20:33:50 2007 Subject: [grass-addons] r815 - in trunk/grassaddons/gui: gui_modules icons Message-ID: <200706101833.l5AIXkLu008419@grass.itc.it> Author: landa Date: 2007-06-10 20:32:44 +0200 (Sun, 10 Jun 2007) New Revision: 815 Modified: trunk/grassaddons/gui/gui_modules/cmd.py trunk/grassaddons/gui/gui_modules/digit.py trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/select.py trunk/grassaddons/gui/gui_modules/toolbars.py trunk/grassaddons/gui/gui_modules/toolbox.py trunk/grassaddons/gui/gui_modules/wxgui_utils.py trunk/grassaddons/gui/icons/icon.py Log: first part of digit tool updates Modified: trunk/grassaddons/gui/gui_modules/cmd.py =================================================================== --- trunk/grassaddons/gui/gui_modules/cmd.py 2007-06-09 11:40:50 UTC (rev 814) +++ trunk/grassaddons/gui/gui_modules/cmd.py 2007-06-10 18:32:44 UTC (rev 815) @@ -114,7 +114,9 @@ print >> sys.stderr, msg[1] if dlgMsg == "gui": - dlg = wx.MessageDialog(None, _("Execution failed: '%s'") % ' '.join(self.cmd), _("Error"), wx.OK | wx.ICON_ERROR) + dlg = wx.MessageDialog(None, _("Execution failed: '%s'") % \ + ' '.join(self.cmd), _("Error"), + wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() else: # otherwise 'txt' @@ -124,7 +126,8 @@ else: self.returncode = None - Debug.msg (3, "Command(): cmd=%s, wait=%d, returncode=%d" % (self.cmd, wait, self.returncode)) + Debug.msg (3, "Command(): cmd=%s, wait=%d, returncode=%d" % \ + (self.cmd, wait, self.returncode)) def Run(self, verbose=False): """ Modified: trunk/grassaddons/gui/gui_modules/digit.py =================================================================== --- trunk/grassaddons/gui/gui_modules/digit.py 2007-06-09 11:40:50 UTC (rev 814) +++ trunk/grassaddons/gui/gui_modules/digit.py 2007-06-10 18:32:44 UTC (rev 815) @@ -29,7 +29,8 @@ """ Abstract digitization class """ - pass + def __init__(self): + pass class VEdit(Digit): """ @@ -37,7 +38,7 @@ Note: This should be replaced by VDigit class. """ - def AddPoint (self, map, type, x, y): + def AddPoint (self, map, type, x, y, z=None): """ Add point/centroid to the vector map layer """ @@ -45,20 +46,20 @@ key = "C" else: key = "P" - - addstring="""%s 1 - %f %f""" % (key, x, y) + + addstring="""%s 1 1 + %f %f\n1 1""" % (key, x, y) Debug.msg (3, "VEdit.AddPoint(): map=%s, type=%s, x=%f, y=%f" % \ (map, type, x, y)) self._AddFeature (map=map, input=addstring) - def AddLine (self, map, type, xy): + def AddLine (self, map, type, coords): """ Add line/boundary to the vector map layer """ - if len(xy) < 2: + if len(coords) < 2: return if type == "boundary": @@ -66,9 +67,10 @@ else: key = "L" - addstring="%s %d 1\n" % (key, len(xy)) - for point in xy: - addstring += "%f %f\n" % (point[0], point [1]) + addstring="""%s %d 1\n""" % (key, len(coords)) + for point in coords: + addstring += """%f %f\n""" % \ + (float(point[0]), float(point [1])) addstring += "1 1" Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-09 11:40:50 UTC (rev 814) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-10 18:32:44 UTC (rev 815) @@ -131,11 +131,12 @@ # # Variable for drawing on DC # - self.pen = None # pen for drawing zoom boxes, etc. - self.polypen = None # pen for drawing polylines (measurements, profiles, etc) - self.polycoords = [] # List of wx.Point tuples defining a polyline - self.lineid = None #ID of rubber band line - self.plineid = None #ID of poly line resulting from cumulative rubber band lines (e.g. measurement) + self.pen = None # pen for drawing zoom boxes, etc. + self.polypen = None # pen for drawing polylines (measurements, profiles, etc) + self.polycoords = [] # List of wx.Point tuples defining a polyline + self.lineid = None # ID of rubber band line + # ID of poly line resulting from cumulative rubber band lines (e.g. measurement) + self.plineid = None # # Event bindings @@ -199,7 +200,6 @@ # vars for handling mouse clicks self.dragid = -1 self.lastpos = (0, 0) - self.savedpos = [] def Draw(self, pdc, img=None, drawid=None, pdctype='image', coords=[0,0,0,0]): """ @@ -509,6 +509,8 @@ """ Drag an overlay decoration item """ + Debug.msg (5, "BufferedWindow.DragItem(): id=%d" % \ + id) x,y = self.lastpos dx = event.GetX() - x dy = event.GetY() - y @@ -531,6 +533,8 @@ """ Mouse zoom rectangles and lines """ + Debug.msg (4, "BufferedWindow.MouseDraw(): use=%s, box=%s" % \ + (self.mouse['use'], self.mouse['box'])) if self.mouse['box'] == "box": boxid = wx.ID_NEW mousecoords = [self.mouse['begin'][0], self.mouse['begin'][1], \ @@ -561,6 +565,10 @@ self.Draw(self.pdc, drawid=self.lineid, pdctype='line', coords=mousecoords) def DrawLines(self): + """Draw polyline in PseudoDC""" + Debug.msg (5, "BufferedWindow.DrawLines(): coords=%s" % \ + self.polycoords) + self.plineid = wx.ID_NEW+1 if len(self.polycoords) > 0: self.Draw(self.pdc, drawid=self.plineid, pdctype='polyline', coords=self.polycoords) @@ -601,15 +609,17 @@ elif event.Dragging(): Debug.msg (5, "BufferedWindow.MouseAction(): Dragging") currpos = event.GetPositionTuple()[:] - end = (currpos[0]-self.mouse['begin'][0], \ - currpos[1]-self.mouse['begin'][1]) + end = (currpos[0] - self.mouse['begin'][0], \ + currpos[1] - self.mouse['begin'][1]) # dragging or drawing box with left button if self.mouse['use'] == 'pan': self.DragMap(end) # dragging decoration overlay item - elif self.mouse['use'] == 'pointer' and self.dragid != None and self.dragid != 99: + elif (self.mouse['use'] == 'pointer' and not self.parent.digittoolbar) and \ + self.dragid != None and \ + self.dragid != 99: self.DragItem(self.dragid, event) # dragging anything else - rubber band box or line @@ -622,6 +632,10 @@ elif event.ButtonDClick(): self.OnButtonDClick(event) + # middle mouse button pressed + elif event.MiddleDown(): + self.OnMiddleDown(event) + # right mouse button pressed elif event.RightDown(): self.OnRightDown(event) @@ -630,6 +644,9 @@ elif event.RightUp(): self.OnRightUp(event) + elif event.Moving(): + self.OnMouseMoving(event) + # store current mouse position self.mouse['pos'] = event.GetPositionTuple()[:] @@ -640,9 +657,8 @@ Debug.msg (5, "BufferedWindow.OnLeftDown(): use=%s" % \ self.mouse["use"]) - if self.mouse["use"] in ["measure", "profile"] or \ - (self.mouse["use"] == "pointer" and self.parent.digittoolbar): - # measure || profile || digit tool + if self.mouse["use"] in ["measure", "profile"]: + # measure || profile if len(self.polycoords) == 0: self.mouse['begin'] = event.GetPositionTuple()[:] self.mouse['end'] = self.mouse['begin'] @@ -650,13 +666,49 @@ self.ClearLines() else: self.mouse['begin'] = self.mouse['end'] - else: # get decoration id + + elif self.mouse["use"] == "pointer" and self.parent.digittoolbar: + # digitization + digit = self.parent.digittoolbar + if digit.action == "add": + try: + map = digit.layers[digit.layerSelectedID].name + except: + map = None + dlg = wx.MessageDialog(self, _("No vector map layer selected for editing"), + _("Error"), wx.OK | wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() + + if map: + if digit.type in ["point", "centroid"]: + # add new point + east, north = self.Pixel2Cell(event.GetPositionTuple()[0], + event.GetPositionTuple()[1]) + + Digit.AddPoint(map=map, + type=digit.type, + x=east, y=north) + + self.render=True + self.UpdateMap() # redraw map + + elif digit.type in ["line", "boundary"]: + # add new point to the line + self.polycoords.append(event.GetPositionTuple()[:]) + self.mouse['begin'] = self.polycoords[-1] + self.DrawLines() + + else: + # get decoration id self.lastpos = self.mouse['begin'] = event.GetPositionTuple()[:] idlist = self.pdc.FindObjects(x=self.lastpos[0], y=self.lastpos[1], radius=self.hitradius) if idlist != []: self.dragid = idlist[0] + event.Skip() + def OnLeftUp(self, event): """ Left mouse button released @@ -690,37 +742,11 @@ self.DrawLines() except: pass + elif self.mouse["use"] == "pointer" and self.parent.digittoolbar: - # digit tool - digit = self.parent.digittoolbar - if digit.action == "add": - try: - map = digit.layers[digit.layerID].name - except: - map = None - dlg = wx.MessageDialog(self, _("No vector map layer selected for editing"), - _("Error"), wx.OK | wx.ICON_ERROR) - dlg.ShowModal() - dlg.Destroy() + # digitization + pass - if map: - east, north = self.Pixel2Cell(self.mouse['begin'][0], - self.mouse['begin'][1]) - if digit.type in ["point", "centroid"]: - # add new point - Digit.AddPoint(map=map, - type=digit.type, - x=east, y=north) - elif digit.type in ["line", "boundary"]: - # add new point to the line - Debug.msg (3, "BufferedWindow.MouseAction(): new saved pos=%f,%f" % \ - (east, north)) - self.savedpos.append ((east, north)) - - # redraw map - self.render=True - self.UpdateMap() - elif self.dragid != None: # end drag of overlay decoration self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid) @@ -729,6 +755,7 @@ id = None self.Update() + event.Skip() def OnButtonDClick(self, event): """ @@ -772,6 +799,8 @@ elif self.dragid == 1: self.parent.AddLegend(None) + event.Skip() + def OnRightDown(self, event): """ Right mouse button pressed @@ -796,6 +825,8 @@ r.Inflate(4,4) self.RefreshRect(r, False) + event.Skip() + def OnRightUp(self, event): """ Right mouse button released @@ -804,26 +835,66 @@ self.mouse["use"]) if self.parent.digittoolbar and self.parent.digittoolbar.action == "add": - if self.parent.digittoolbar.type in ["line", "boundary"]: + digit = self.parent.digittoolbar + if digit.type in ["line", "boundary"]: try: - map = self.parent.digittoolbar.layers[self.parent.digittoolbar.layerID].name + map = digit.layers[digit.layerSelectedID].name except: map = None - dlg = wx.MessageDialog(self, _("No vector map layer is selected"), _("Error"), wx.OK | wx.ICON_ERROR) + dlg = wx.MessageDialog(self, _("No vector map layer is selected"), + _("Error"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() if map: # add new line + mapcoords = [] + # xy -> EN + for coord in self.polycoords: + mapcoords.append(self.Pixel2Cell (coord[0], coord[1])) + Digit.AddLine(map=map, type=self.parent.digittoolbar.type, - xy=self.savedpos) + coords=mapcoords) + # clean up saved positions - self.savedpos = [] + self.polycoords = [] + # redraw map self.render=True self.UpdateMap() + event.Skip() + + def OnMouseMoving(self, event): + """Motion event and no mouse buttons were pressed""" + digit = self.parent.digittoolbar + if self.mouse["use"] == "pointer" and \ + digit and \ + digit.action == 'add' and \ + digit.type in ["line", "boundary"]: + self.mouse['end'] = event.GetPositionTuple()[:] + Debug.msg (5, "BufferedWindow.OnMouseMoving(): coords=%f,%f" % \ + (self.mouse['end'][0], self.mouse['end'][1])) + if len(self.polycoords) > 0: + # draw mouse moving + self.MouseDraw() + + event.Skip() + + def OnMiddleDown(self, event): + """Middle mouse button pressed""" + digit = self.parent.digittoolbar + if self.mouse["use"] == "pointer" and \ + digit and \ + digit.action == 'add' and \ + digit.type in ["line", "boundary"]: + # remove last point from the line + self.polycoords.pop() + self.mouse['begin'] = self.polycoords[-1] + self.ClearLines() + self.DrawLines() + def ClearLines(self): """ Clears lines drawn for measurement and profiling @@ -841,13 +912,13 @@ """ Calculates real word coordinates to image coordinates - Input : x, y - Output: int x, int y + Input : int x, int y + Output: float x, float y """ newx = self.Map.region['w'] + x * self.Map.region["ewres"] newy = self.Map.region['n'] - y * self.Map.region["nsres"] - return newx, newy + return (newx, newy) def Zoom(self, begin, end, zoomtype): """ @@ -1184,21 +1255,26 @@ self.dist = 0.0 #segment length for measurement self.totaldist = 0.0 # total length measured # initialize buffered DC - # self.MapWindow = DrawWindow(self) - self.MapWindow = BufferedWindow(self, id = wx.ID_ANY, Map=self.Map, tree=self.tree) # initialize buffered DC + ## self.MapWindow = DrawWindow(self) + self.MapWindow = BufferedWindow(self, id = wx.ID_ANY, Map=self.Map, tree=self.tree) self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion) self.MapWindow.SetCursor(self.cursors["default"]) # default # # Init zoomhistory # - self.MapWindow.ZoomHistory(self.Map.region['n'],self.Map.region['s'],self.Map.region['e'],self.Map.region['w']) + self.MapWindow.ZoomHistory(self.Map.region['n'], + self.Map.region['s'], + self.Map.region['e'], + self.Map.region['w']) # decoration overlays self.ovlchk = self.MapWindow.ovlchk self.ovlcoords = self.MapWindow.ovlcoords - self.params = {} # previously set decoration options parameters to insert into options dialog - self.propwin = {} # ID of properties window open for overlay, indexed by overlay ID + # previously set decoration options parameters to insert into options dialog + self.params = {} + # ID of properties window open for overlay, indexed by overlay ID + self.propwin = {} # # Bind various events @@ -1250,9 +1326,14 @@ self._mgr.AddPane(self.digittoolbar.toolbar, wx.aui.AuiPaneInfo(). Name("digittoolbar").Caption("Digit Toolbar"). ToolbarPane().Top().Row(1). - LeftDockable(False).RightDockable(True). - BottomDockable(False).TopDockable(False). + LeftDockable(False).RightDockable(False). + BottomDockable(False).TopDockable(True). CloseButton(False).Layer(2)) + # change mouse to draw digitized line + self.MapWindow.mouse['box'] = "point" + self.MapWindow.zoomtype = 0 + self.MapWindow.pen = wx.Pen(colour='red', width=2, style=wx.SHORT_DASH) + self.MapWindow.polypen = wx.Pen(colour='green', width=2, style=wx.SHORT_DASH) self._mgr.Update() @@ -1472,9 +1553,9 @@ #self.Destroy() - def getRender(self): + def GetRender(self): """ - returns the current instance of render.Map() + Returns the current instance of render.Map() """ return self.Map @@ -1595,7 +1676,7 @@ self.MapWindow.mouse['use'] = "measure" self.MapWindow.mouse['box'] = "line" self.MapWindow.zoomtype = 0 - self.MapWindow.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH) + self.MapWindow.pen = wx.Pen(colour='red', width=2, style=wx.SHORT_DASH) self.MapWindow.polypen = wx.Pen(colour='green', width=2, style=wx.SHORT_DASH) # change the cursor @@ -1680,7 +1761,6 @@ outunits = 'deg' # format numbers in a nice way - if (dist/divisor) >= 2500.0: outdist = round(dist/divisor) elif (dist/divisor) >= 1000.0: @@ -1690,7 +1770,7 @@ else: outdist = float('%g' % dist/divisor) - return (outdist,outunits) + return (outdist, outunits) def Histogram(self, event): Modified: trunk/grassaddons/gui/gui_modules/select.py =================================================================== --- trunk/grassaddons/gui/gui_modules/select.py 2007-06-09 11:40:50 UTC (rev 814) +++ trunk/grassaddons/gui/gui_modules/select.py 2007-06-10 18:32:44 UTC (rev 815) @@ -30,7 +30,7 @@ tcp = TreeCtrlComboPopup() self.SetPopupControl(tcp) self.SetPopupExtents(0,100) - tcp.getElementList(type) + tcp.GetElementList(type) class TreeCtrlComboPopup(wx.combo.ComboPopup): """ @@ -100,7 +100,7 @@ def GetAdjustedSize(self, minWidth, prefHeight, maxHeight): return wx.Size(minWidth, min(200, maxHeight)) - def getElementList(self, element): + def GetElementList(self, element): """ Get list of GIS elements in accessible mapsets and display as tree with all relevant elements displayed beneath each mapset branch Modified: trunk/grassaddons/gui/gui_modules/toolbars.py =================================================================== --- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-09 11:40:50 UTC (rev 814) +++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-10 18:32:44 UTC (rev 815) @@ -187,24 +187,63 @@ Toolbar data """ - self.point = self.line = self.boundary = self.centroid = self.exit = None + self.addPoint = self.addLine = self.addBoundary = self.addCentroid = self.exit = None + self.moveVertex = self.addVertex = self.removeVertex = None + self.splitLine = self.editLine = self.moveLine = self.deleteLine = None + self.displayCats = self.displayAttr = self.copyCats = self.settings = None return (("", "", "", "", "", "", ""), - (self.point, "digaddpoint", Icons["digaddpoint"].GetBitmap(), - wx.ITEM_RADIO, Icons["digaddpoint"].GetLabel(), Icons["digaddpoint"].GetDesc(), + (self.addPoint, "digAddPoint", Icons["digAddPoint"].GetBitmap(), + wx.ITEM_RADIO, Icons["digAddPoint"].GetLabel(), Icons["digAddPoint"].GetDesc(), self.OnAddPoint), - (self.line, "digaddline", Icons["digaddline"].GetBitmap(), - wx.ITEM_RADIO, Icons["digaddline"].GetLabel(), Icons["digaddline"].GetDesc(), + (self.addLine, "digAddLine", Icons["digAddLine"].GetBitmap(), + wx.ITEM_RADIO, Icons["digAddLine"].GetLabel(), Icons["digAddLine"].GetDesc(), self.OnAddLine), - (self.boundary, "digaddbound", Icons["digaddbound"].GetBitmap(), - wx.ITEM_RADIO, Icons["digaddbound"].GetLabel(), Icons["digaddbound"].GetDesc(), + (self.addBoundary, "digAddBoundary", Icons["digAddBoundary"].GetBitmap(), + wx.ITEM_RADIO, Icons["digAddBoundary"].GetLabel(), Icons["digAddBoundary"].GetDesc(), self.OnAddBoundary), - (self.centroid, "digaddcentr", Icons["digaddcentr"].GetBitmap(), - wx.ITEM_RADIO, Icons["digaddcentr"].GetLabel(), Icons["digaddcentr"].GetDesc(), + (self.addCentroid, "digAddCentroid", Icons["digAddCentroid"].GetBitmap(), + wx.ITEM_RADIO, Icons["digAddCentroid"].GetLabel(), Icons["digAddCentroid"].GetDesc(), self.OnAddCentroid), ("", "", "", "", "", "", ""), - (self.exit, "digexit", Icons["digexit"].GetBitmap(), - wx.ITEM_NORMAL, Icons["digexit"].GetLabel(), Icons["digexit"].GetDesc(), + (self.moveVertex, "digMoveVertex", Icons["digMoveVertex"].GetBitmap(), + wx.ITEM_RADIO, Icons["digMoveVertex"].GetLabel(), Icons["digMoveVertex"].GetDesc(), + self.OnMoveVertex), + (self.addVertex, "digAddVertex", Icons["digAddVertex"].GetBitmap(), + wx.ITEM_RADIO, Icons["digAddVertex"].GetLabel(), Icons["digAddVertex"].GetDesc(), + self.OnAddVertex), + (self.removeVertex, "digRemoveVertex", Icons["digRemoveVertex"].GetBitmap(), + wx.ITEM_RADIO, Icons["digRemoveVertex"].GetLabel(), Icons["digRemoveVertex"].GetDesc(), + self.OnRemoveVertex), + ("", "", "", "", "", "", ""), + (self.splitLine, "digSplitLine", Icons["digSplitLine"].GetBitmap(), + wx.ITEM_RADIO, Icons["digSplitLine"].GetLabel(), Icons["digSplitLine"].GetDesc(), + self.OnSplitLine), + (self.editLine, "digEditLine", Icons["digEditLine"].GetBitmap(), + wx.ITEM_RADIO, Icons["digEditLine"].GetLabel(), Icons["digEditLine"].GetDesc(), + self.OnEditLine), + (self.moveLine, "digMoveLine", Icons["digMoveLine"].GetBitmap(), + wx.ITEM_RADIO, Icons["digMoveLine"].GetLabel(), Icons["digMoveLine"].GetDesc(), + self.OnMoveLine), + (self.deleteLine, "digDeleteLine", Icons["digDeleteLine"].GetBitmap(), + wx.ITEM_RADIO, Icons["digDeleteLine"].GetLabel(), Icons["digDeleteLine"].GetDesc(), + self.OnDeleteLine), + ("", "", "", "", "", "", ""), + (self.displayCats, "digDispCats", Icons["digDispCats"].GetBitmap(), + wx.ITEM_RADIO, Icons["digDispCats"].GetLabel(), Icons["digDispCats"].GetDesc(), + self.OnDisplayCats), + (self.copyCats, "digCopyCats", Icons["digCopyCats"].GetBitmap(), + wx.ITEM_RADIO, Icons["digCopyCats"].GetLabel(), Icons["digCopyCats"].GetDesc(), + self.OnCopyCats), + (self.displayAttr, "digDispAttr", Icons["digDispAttr"].GetBitmap(), + wx.ITEM_RADIO, Icons["digDispAttr"].GetLabel(), Icons["digDispAttr"].GetDesc(), + self.OnDisplayAttr), + (self.settings, "digSettings", Icons["digSettings"].GetBitmap(), + wx.ITEM_RADIO, Icons["digSettings"].GetLabel(), Icons["digSettings"].GetDesc(), + self.OnSettings), + ("", "", "", "", "", "", ""), + (self.exit, "digExit", Icons["digExit"].GetBitmap(), + wx.ITEM_NORMAL, Icons["digExit"].GetLabel(), Icons["digExit"].GetDesc(), self.OnExit)) def OnAddPoint(self, event): @@ -212,26 +251,29 @@ Debug.msg (3, "DigitToolbar.OnAddPoint()") self.action = "add" self.type = "point" + self.parent.MapWindow.mouse['box'] = 'point' def OnAddLine(self, event): """Add line to the vector map layer""" Debug.msg (3, "DigitToolbar.OnAddLine()") self.action = "add" self.type = "line" + self.parent.MapWindow.mouse['box'] = 'line' def OnAddBoundary(self, event): """Add boundary to the vector map layer""" Debug.msg (3, "DigitToolbar.OnAddBoundary()") self.action = "add" self.type = "boundary" + self.parent.MapWindow.mouse['box'] = 'line' def OnAddCentroid(self, event): """Add centroid to the vector map layer""" Debug.msg (3, "DigitToolbar.OnAddCentroid()") self.action = "add" self.type = "centroid" + self.parent.MapWindow.mouse['box'] = 'point' - def OnExit (self, event): """ Quit digitization tool @@ -242,6 +284,39 @@ # disable the toolbar self.parent.RemoveToolbar ("digit") + def OnMoveVertex(self, event): + pass + + def OnAddVertex(self, event): + pass + + def OnRemoveVertex(self, event): + pass + + def OnSplitLine(self, event): + pass + + def OnEditLine(self, event): + pass + + def OnMoveLine(self, event): + pass + + def OnDeleteLine(self, event): + pass + + def OnDisplayCats(self, event): + pass + + def OnDisplayAttr(self, event): + pass + + def OnCopyCats(self, event): + pass + + def OnSettings(self, event): + pass + def OnSelectMap (self, event): """ Select vector map layer for editing Modified: trunk/grassaddons/gui/gui_modules/toolbox.py =================================================================== --- trunk/grassaddons/gui/gui_modules/toolbox.py 2007-06-09 11:40:50 UTC (rev 814) +++ trunk/grassaddons/gui/gui_modules/toolbox.py 2007-06-10 18:32:44 UTC (rev 815) @@ -45,7 +45,7 @@ class handleQgisGrass: def __init__(self, qgisgrass): - modules = qgisgrass.childNodes[0].getElementsByTagName('modules')[0] + modules = qgisgrass.childNodes[0].GetElementsByTagName('modules')[0] for child in modules.childNodes: if child.localName == 'grass': self.handleGrass( child ) @@ -53,7 +53,7 @@ self.handleSection( child ) def handleSection( self,section ): - for child in section.getElementsByTagName('grass'): + for child in section.GetElementsByTagName('grass'): self.handleGrass( child ) def handleGrass( self, grass ): @@ -79,7 +79,7 @@ class handleQgisGrassModule: def __init__( self, qgisgrassmodule): - qgisgrassm = qgisgrassmodule.getElementsByTagName( "qgisgrassmodule" )[0] + qgisgrassm = qgisgrassmodule.GetElementsByTagName( "qgisgrassmodule" )[0] self.handleAttributes( qgisgrassm ) for inner in qgisgrassm.childNodes: it = inner.localName Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-09 11:40:50 UTC (rev 814) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-10 18:32:44 UTC (rev 815) @@ -88,7 +88,7 @@ self.SetFirstGradientColour(wx.Colour(150, 150, 150)) self.Map = render.Map() # instance of render.Map to be associated with display - self.root = None # ID of layer tree root node + self.root = None # ID of layer tree root node self.groupnode = 0 # index value for layers self.optpage = {} # dictionary of notebook option pages for each map layer self.layer_selected = None # ID of currently selected layer @@ -100,20 +100,20 @@ self.gismgr = gismgr self.notebook = notebook # GIS Manager notebook for layer tree self.treepg = parent # notebook page holding layer tree - self.auimgr = auimgr # aui manager + self.auimgr = auimgr # aui manager - - self.testframe = wx.Frame(self, -1, title='Test Frame') - # init associated map display self.mapdisplay = mapdisp.MapFrame(self, id=wx.ID_ANY, pos=wx.DefaultPosition, size=(640,480), style=wx.DEFAULT_FRAME_STYLE, - tree=self, notebook=self.notebook, gismgr=self.gismgr, page=self.treepg, + tree=self, notebook=self.notebook, + gismgr=self.gismgr, page=self.treepg, Map=self.Map, auimgr=self.auimgr) # title - self.mapdisplay.SetTitle(_("GRASS GIS - Map Display: " + str(self.disp_idx) + " - Location: " + grassenv.env["LOCATION_NAME"])) + self.mapdisplay.SetTitle(_("GRASS GIS - Map Display: " + \ + str(self.disp_idx) + \ + " - Location: " + grassenv.env["LOCATION_NAME"])) #show new display self.mapdisplay.Show() @@ -170,8 +170,8 @@ self.AssignImageList(il) # use when groups implemented - # self.tree.SetItemImage(self.root, fldridx, wx.TreeItemIcon_Normal) - # self.tree.SetItemImage(self.root, fldropenidx, wx.TreeItemIcon_Expanded) + ## self.tree.SetItemImage(self.root, fldridx, wx.TreeItemIcon_Normal) + ## self.tree.SetItemImage(self.root, fldropenidx, wx.TreeItemIcon_Expanded) self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnExpandNode) self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnCollapseNode) @@ -181,7 +181,7 @@ self.Bind(wx.EVT_TREE_DELETE_ITEM, self.OnDeleteLayer) self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnBeginDrag) self.Bind(wx.EVT_TREE_END_DRAG, self.OnEndDrag) - self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu) + self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnContextMenu) self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnChangeLayerName) # self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) @@ -189,9 +189,6 @@ """Change layer name""" Debug.msg (3, "LayerTree.OnChangeLayerName: name=%s" % event.GetLabel()) - if self.layers[self.layer_selected].type != 'group': - self.Map.ChangeLayerName (self.layer_selected, event.GetLabel()) - def OnContextMenu (self, event): """Context Layer Menu""" @@ -204,8 +201,8 @@ Debug.msg (4, "LayerTree.OnContextMenu: layertype=%s" % \ ltype) - pos = event.GetPosition() - pos = self.ScreenToClient(pos) + ## pos = event.GetPosition() + ## pos = self.ScreenToClient(pos) if not hasattr (self, "popupID1"): self.popupID1 = wx.NewId() @@ -259,7 +256,8 @@ self.popupMenu.Append(self.popupID4, _("Histogram")) self.Bind (wx.EVT_MENU, self.OnHistogram, id=self.popupID4) - self.PopupMenu(self.popupMenu, pos) + ## self.PopupMenu(self.popupMenu, pos) + self.PopupMenu(self.popupMenu) self.popupMenu.Destroy() def OnHistogram(self, event): @@ -867,7 +865,7 @@ return wx.Size(minWidth, min(200, maxHeight)) - def getElementList(self, element): + def GetElementList(self, element): """ Get list of GIS elements in accessible mapsets and display as tree with all relevant elements displayed beneath each mapset branch @@ -909,6 +907,7 @@ # helpers def FindItem(self, parentItem, text): + """Find item in the layer tree""" item, cookie = self.tree.GetFirstChild(parentItem) while item: if self.tree.GetItemText(item) == text: @@ -920,6 +919,7 @@ def AddItem(self, value, parent=None): + """Add item to the layer tree""" if not parent: root = self.tree.GetRootItem() if not root: @@ -931,7 +931,7 @@ def OnMotion(self, evt): - # have the selection follow the mouse, like in a real combobox + """Have the selection follow the mouse, like in a real combobox""" item, flags = self.tree.HitTest(evt.GetPosition()) if item and flags & wx.TREE_HITTEST_ONITEMLABEL: self.tree.SelectItem(item) @@ -940,6 +940,7 @@ def OnLeftDown(self, evt): + """Left mouse button released""" # do the combobox selection item, flags = self.tree.HitTest(evt.GetPosition()) if item and flags & wx.TREE_HITTEST_ONITEMLABEL: @@ -1036,9 +1037,9 @@ # cmd = self.console_command.GetLineText(0) try: curr_disp = self.Parent.Parent.curr_page.maptree.mapdisplay - self.Map = curr_disp.getRender() + self.Map = curr_disp.GetRender() except: - # disp_idx = None + ## disp_idx = None curr_disp = None try: Modified: trunk/grassaddons/gui/icons/icon.py =================================================================== --- trunk/grassaddons/gui/icons/icon.py 2007-06-09 11:40:50 UTC (rev 814) +++ trunk/grassaddons/gui/icons/icon.py 2007-06-10 18:32:44 UTC (rev 815) @@ -40,11 +40,22 @@ "printmap" : 'file-print.gif', "overlay" : 'gui-overlay.gif', # digit - "digaddpoint": 'new.point.gif', - "digaddline" : 'new.line.gif', - "digaddbound": 'new.boundary.gif', - "digaddcentr": 'new.centroid.gif', - "digexit" : 'exit.gif', + "digAddPoint": 'new.point.gif', + "digAddLine" : 'new.line.gif', + "digAddBoundary": 'new.boundary.gif', + "digAddCentroid": 'new.centroid.gif', + "digAddVertex" : 'add.vertex.gif', + "digCopyCats" : 'copy.cats.gif', + "digDeleteLine" : 'delete.line.gif', + "digDispAttr" : 'display.attributes.gif', + "digDispCats" : 'display.cats.gif', + "digEditLine" : 'edit.line.gif', + "digMoveLine" : 'move.line.gif', + "digMoveVertex" : 'move.vertex.gif', + "digRemoveVertex" : 'rm.vertex.gif', + "digSettings" : 'settings.gif', + "digSplitLine" : 'split.line.gif', + "digExit" : 'exit.gif', # gis manager "newdisplay" : 'gui-startmon.gif', "addrast" : 'element-cell.gif', @@ -161,16 +172,23 @@ Icons = { # map display "displaymap" : MetaIcon (img=icons_img["displaymap"], label="Display map"), - "rendermap" : MetaIcon (img=icons_img["rendermap"], label="Re-render map", desc="Force re-rendering of all layers"), + "rendermap" : MetaIcon (img=icons_img["rendermap"], label="Re-render map", + desc="Force re-rendering of all layers"), "erase" : MetaIcon (img=icons_img["erase"], label="Erase display"), "pointer" : MetaIcon (img=icons_img["pointer"], label="Pointer"), - "zoom_in" : MetaIcon (img=icons_img["zoom_in"], label="Zoom in", desc="Drag or click mouse to zoom"), - "zoom_out" : MetaIcon (img=icons_img["zoom_out"], label="Zoom out", desc="Drag or click mouse to unzoom"), - "pan" : MetaIcon (img=icons_img["pan"], label="Pan", desc="Drag with mouse to pan"), - "query" : MetaIcon (img=icons_img["query"], label="Query", desc="Query selected map"), + "zoom_in" : MetaIcon (img=icons_img["zoom_in"], label="Zoom in", + desc="Drag or click mouse to zoom"), + "zoom_out" : MetaIcon (img=icons_img["zoom_out"], label="Zoom out", + desc="Drag or click mouse to unzoom"), + "pan" : MetaIcon (img=icons_img["pan"], label="Pan", + desc="Drag with mouse to pan"), + "query" : MetaIcon (img=icons_img["query"], label="Query", + desc="Query selected map"), "zoom_back" : MetaIcon (img=icons_img["zoom_back"], label="Return to previous zoom"), - "zoommenu" : MetaIcon (img=icons_img["zoommenu"], label="Zoom options", desc="Display zoom management"), - "overlay" : MetaIcon (img=icons_img["overlay"], label="Add overlay", desc="Add graphic overlays to map"), + "zoommenu" : MetaIcon (img=icons_img["zoommenu"], label="Zoom options", + desc="Display zoom management"), + "overlay" : MetaIcon (img=icons_img["overlay"], label="Add overlay", + desc="Add graphic overlays to map"), "addbarscale": MetaIcon (img=icons_img["addbarscale"], label="Add scalebar and north arrow"), "addlegend" : MetaIcon (img=icons_img["addlegend"], label="Add legend"), "savefile" : MetaIcon (img=icons_img["savefile"], label="Save display to PNG file"), @@ -196,11 +214,37 @@ "addlabels" : MetaIcon (img=icons_img["addlabels"], label="Add labels"), "addtext" : MetaIcon (img=icons_img["addtext"], label="Add text layer"), # digit - "digaddpoint": MetaIcon (img=icons_img["digaddpoint"], label="Digitize new point"), - "digaddline" : MetaIcon (img=icons_img["digaddline"], label="Digitize new line"), - "digaddbound": MetaIcon (img=icons_img["digaddbound"], label="Digitize new boundary"), - "digaddcentr": MetaIcon (img=icons_img["digaddcentr"], label="Digitize new centroid"), - "digexit" : MetaIcon (img=icons_img["digexit"], label="Quit digitization tool"), + "digAddPoint": MetaIcon (img=icons_img["digAddPoint"], label="Digitize new point", + desc="Left: new point"), + "digAddLine" : MetaIcon (img=icons_img["digAddLine"], label="Digitize new line", + desc="Left: new point - Middle: undo last point - Right: close line"), + "digAddBoundary": MetaIcon (img=icons_img["digAddBoundary"], label="Digitize new boundary", + desc="Left: new point - Middle: undo last point - Right: close line"), + "digAddCentroid": MetaIcon (img=icons_img["digAddCentroid"], label="Digitize new centroid", + desc="Left: new point"), + "digAddVertex": MetaIcon (img=icons_img["digAddVertex"], label="Add new vertex", + desc="Not implemented yet"), + "digCopyCats": MetaIcon (img=icons_img["digCopyCats"], label="", + desc="Not implemented yet"), + "digDeleteLine": MetaIcon (img=icons_img["digDeleteLine"], label="Add new vertex", + desc="Not implemented yet"), + "digDispAttr": MetaIcon (img=icons_img["digDispAttr"], label="Add new vertex", + desc="Not implemented yet"), + "digDispCats": MetaIcon (img=icons_img["digDispCats"], label="Add new vertex", + desc="Not implemented yet"), + "digEditLine": MetaIcon (img=icons_img["digEditLine"], label="Add new vertex", + desc="Not implemented yet"), + "digMoveLine": MetaIcon (img=icons_img["digMoveLine"], label="Add new vertex", + desc="Not implemented yet"), + "digMoveVertex": MetaIcon (img=icons_img["digMoveVertex"], label="Add new vertex", + desc="Not implemented yet"), + "digRemoveVertex": MetaIcon (img=icons_img["digRemoveVertex"], label="Add new vertex", + desc="Not implemented yet"), + "digSettings": MetaIcon (img=icons_img["digSettings"], label="Add new vertex", + desc="Not implemented yet"), + "digSplitLine": MetaIcon (img=icons_img["digSplitLine"], label="Add new vertex", + desc="Not implemented yet"), + "digExit" : MetaIcon (img=icons_img["digExit"], label="Quit digitization tool"), # analyze raster "analyze" : MetaIcon (img=icons_img["analyze"], label="Analyze map"), "measure" : MetaIcon (img=icons_img["measure"], label="Measure distance"), From barton at grass.itc.it Sun Jun 10 21:00:07 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sun Jun 10 21:00:08 2007 Subject: [grass-addons] r816 - trunk/grassaddons/gui/gui_modules Message-ID: <200706101900.l5AJ07wm008476@grass.itc.it> Author: barton Date: 2007-06-10 20:59:58 +0200 (Sun, 10 Jun 2007) New Revision: 816 Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Code cleanup. Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-10 18:32:44 UTC (rev 815) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-10 18:59:58 UTC (rev 816) @@ -6,8 +6,8 @@ gmpath = os.path.join( os.getenv("GISBASE"),"etc","wx","gui_modules" ) sys.path.append(gmpath) -gmpath = os.path.join( os.getenv("GISBASE"),"etc","wx","icons") -sys.path.append(gmpath) +#gmpath = os.path.join( os.getenv("GISBASE"),"etc","wx","icons") +#sys.path.append(gmpath) import select import menuform @@ -1012,8 +1012,9 @@ """ self.gcmdlst = [] gisbase = os.environ['GISBASE'] - self.gcmdlst = os.listdir(gisbase+r'/bin') - self.gcmdlst = self.gcmdlst + os.listdir(gisbase+r'/scripts') + self.gcmdlst = os.listdir(os.path.join(gisbase,'bin')) + self.gcmdlst = self.gcmdlst + os.listdir(os.path.join(gisbase,'scripts')) + self.gcmdlst = self.gcmdlst + os.listdir(os.path.join(gisbase,'etc','gm','script')) return self.gcmdlst @@ -1084,7 +1085,6 @@ Display with focus receives display command(s). """ - print 'cmdlist 0=',cmdlist[0] self.cmd_output.write("$" + ' '.join(cmdlist)) dcmds = command.split(';') From barton at grass.itc.it Sun Jun 10 21:01:50 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sun Jun 10 21:01:51 2007 Subject: [grass-addons] r817 - trunk/grassaddons/gui/gui_modules Message-ID: <200706101901.l5AJ1oYg008528@grass.itc.it> Author: barton Date: 2007-06-10 21:01:41 +0200 (Sun, 10 Jun 2007) New Revision: 817 Added: trunk/grassaddons/gui/gui_modules/rules.py Log: New module to allow interactive creation and editing of rules for color management, reclassification, and recoding. Currently just a simple TextCtrl interface, but could be made much nicer and more sophisticated. Added: trunk/grassaddons/gui/gui_modules/rules.py =================================================================== --- trunk/grassaddons/gui/gui_modules/rules.py (rev 0) +++ trunk/grassaddons/gui/gui_modules/rules.py 2007-06-10 19:01:41 UTC (rev 817) @@ -0,0 +1,135 @@ +import wx +import os +import sys +import select + +class RulesText(wx.Dialog): + def __init__(self, parent, id=wx.ID_ANY, title="Enter rules", + pos=wx.DefaultPosition, size=wx.DefaultSize, + style=wx.DEFAULT_DIALOG_STYLE, + cmd=None): + wx.Dialog.__init__(self, parent, id, title, pos, size, style) + + """ + Dialog for interactively entering rules + for map management commands + """ + self.parent = parent + self.cmd = cmd # map management command + self.inmap = '' # input map to change + self.outmap = '' # output map for reclass/recode + self.rules = '' # rules for changing + + + if self.cmd == 'r.colors': + label1 = 'Create new color table using color rules' + label2 = 'Raster map:' + label3 = None + label4 = 'Enter color rules' + seltype = 'cell' + elif self.cmd == 'r.reclass': + label1 = 'Reclassify raster map using rules' + label2 = 'Map to reclassify:' + label3 = 'Reclassified map:' + label4 = 'Enter reclassification rules' + seltype = 'cell' + elif self.cmd == 'r.recode': + label1 = 'Recode raster map using rules' + label2 = 'Map to recode:' + label3 = 'Recoded map:' + label4 = 'Enter recoding rules' + seltype = 'cell' + elif self.cmd == 'v.reclass': + label1 = 'Reclassify vector map using SQL rules' + label2 = 'Map to reclassify:' + label3 = 'Reclassified map:' + label4 = 'Enter reclassification rules' + seltype = 'vector' + + sizer = wx.BoxSizer(wx.VERTICAL) + + box = wx.BoxSizer(wx.HORIZONTAL) + label = wx.StaticText(self, wx.ID_ANY, label1) + box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + sizer.Add(item=box, proportion=0, + flag=wx.ALIGN_CENTER| + wx.ALL,border=5) + + box = wx.BoxSizer(wx.HORIZONTAL) + label = wx.StaticText(self, wx.ID_ANY, label2) + box.Add(label, 0, wx.ALIGN_RIGHT|wx.ALL, 5) + self.selection = select.Select(self, id=wx.ID_ANY, size=(300,-1), + type=seltype) + box.Add(self.selection, 0, wx.ALIGN_RIGHT|wx.ALL, 5) + sizer.Add(item=box, proportion=0, + flag=wx.ALIGN_CENTER_VERTICAL| + wx.ALIGN_RIGHT| + wx.ALL,border=5) + + if cmd != 'r.colors': + box = wx.BoxSizer(wx.HORIZONTAL) + label = wx.StaticText(self, wx.ID_ANY, label3) + box.Add(label, 0, wx.ALIGN_RIGHT|wx.ALL, 5) + self.textentry = wx.TextCtrl(self, wx.ID_ANY, "", size=(300,-1)) + box.Add(self.textentry, 0, wx.ALIGN_RIGHT|wx.ALL, 5) + self.textentry.Bind(wx.EVT_TEXT, self.OnText) + sizer.Add(item=box, proportion=0, + flag=wx.ALIGN_CENTER_VERTICAL| + wx.ALIGN_RIGHT| + wx.ALL,border=5) + + box = wx.BoxSizer(wx.HORIZONTAL) + label = wx.StaticText(self, wx.ID_ANY, label4) + box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + helpbtn = wx.Button(self, wx.ID_ANY, "Help") + box.Add(helpbtn, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + sizer.Add(item=box, proportion=0, + flag=wx.ALIGN_CENTER| + wx.ALL,border=5) + + box = wx.BoxSizer(wx.HORIZONTAL) + self.rulestxt = wx.TextCtrl(self, id=wx.ID_ANY, value='', + pos=wx.DefaultPosition, size=(400,150), + style=wx.TE_MULTILINE| + wx.HSCROLL| + wx.TE_NOHIDESEL) + self.rulestxt.SetFont(wx.Font(10, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL, 0, '')) + box.Add(self.rulestxt, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + sizer.Add(item=box, proportion=0, + flag=wx.ALIGN_CENTER| + wx.ALL,border=5) + + line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) + sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) + + btnsizer = wx.StdDialogButtonSizer() + + btn = wx.Button(self, wx.ID_OK) + btn.SetDefault() + btnsizer.AddButton(btn) + + btn = wx.Button(self, wx.ID_CANCEL) + btnsizer.AddButton(btn) + btnsizer.Realize() + + sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + self.SetSizer(sizer) + sizer.Fit(self) + + self.Bind(wx.EVT_BUTTON, self.OnHelp, helpbtn) + self.selection.Bind(wx.EVT_TEXT, self.OnSelection) + self.Bind(wx.EVT_TEXT, self.OnRules, self.rulestxt) + + def OnSelection(self, event): + self.inmap = event.GetString() + + def OnText(self, event): + self.outmap = event.GetString() + + def OnRules(self, event): + self.rules = event.GetString() + + def OnHelp(self, event): + os.popen('g.manual --quiet %s ' % self.cmd) + From barton at grass.itc.it Sun Jun 10 21:02:38 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sun Jun 10 21:02:40 2007 Subject: [grass-addons] r818 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200706101902.l5AJ2c0C008555@grass.itc.it> Author: barton Date: 2007-06-10 21:02:27 +0200 (Sun, 10 Jun 2007) New Revision: 818 Modified: trunk/grassaddons/gui/gui_modules/menudata.py trunk/grassaddons/gui/wxgui.py Log: More menu updates. Interactive color rules setting enabled. Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-10 19:01:41 UTC (rev 817) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-10 19:02:27 UTC (rev 818) @@ -1,3 +1,5 @@ +import os + class Data: '''Data object that returns menu descriptions to be used in wxgui.py. Probably could be changed to XML or *.dtd file.''' @@ -113,16 +115,16 @@ )), ("Config", ( ("Region", ( - ("Display region", "Display region settings", "self.RunMenuCmd", "g.region -p"), + ("Display region", "Display region settings", "self.RunMenuCmd", ['g.region', '-p']), ("Set region", "Change region settings", "self.OnMenuCmd", "g.region"), )), ("GRASS working environment", ( ("Mapset access (not functional)", "Set access to other mapsets in current location", "self.OnMapsets", ""), ("Change working environment", "Change current working session to new mapset, location, or data directory", "self.OnMenuCmd", "g.mapset"), ("User access", "Change access by other users to current mapset", "self.OnMenuCmd", "g.access"), - ("Show settings", "Show current GRASS environment settings", "self.RunMenuCmd", "g.gisenv "), + ("Show settings", "Show current GRASS environment settings", "self.RunMenuCmd", ['g.gisenv',' ']), ("Change settings", "Change GRASS environment settings", "self.OnMenuCmd", "g.gisenv"), - ("Version", "Show current GRASS version", "self.RunMenuCmd", "g.version -c"), + ("Version", "Show current GRASS version", "self.RunMenuCmd", ['g.version','-c']), )), ("Manage projections", ( ("Projections", "Show projection information and create projection files", "self.OnMenuCmd", "g.proj"), @@ -134,71 +136,76 @@ ("Develop map", ( ("Digitize raster (not functional)", "Digitize raster", "self.OnRDigit", ""), ("","","", ""), - ("Compress/decompress raster file", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), - ("Manage boundary definition (WHICH COMMAND?)", "Manage boundary definition", "self.OnMenuCmd", "r.region"), - ("Manage null values", "Manage null values", "self.OnMenuCmd", "r.null"), - ("Manage timestamp for files", "Manage timestamp for files", "self.OnMenuCmd", "r.timestamp"), - ("Quantization for floating-point maps", "Quantization for floating-point maps", "self.OnMenuCmd", "r.quant"), - ("Resample (change resolution) using nearest neighbor method", "Resample (change resolution) using nearest neighbor method", "self.OnMenuCmd", "r.resample"), - ("Resample (change resolution) using regularized spline tension", "Resample (change resolution) using regularized spline tension", "self.OnMenuCmd", "r.resamp.rst"), - ("Support file creation and maintenance", "Support file creation and maintenance", "self.OnMenuCmd", "r.support.sh"), + ("Compress/decompress", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), + ("Boundaries", "Manage boundary definition", "self.OnMenuCmd", "r.region"), + ("Null values", "Manage null values", "self.OnMenuCmd", "r.null"), + ("Timestamp", "Manage timestamp for files", "self.OnMenuCmd", "r.timestamp"), + ("Quantization", "Quantization for floating-point maps", "self.OnMenuCmd", "r.quant"), + ("Resample (change resolution)", ( + ("Aggregate statistics", "Resample using aggregate statistics", "self.OnMenuCmd", "r.resamp.stats"), + ("Multiple methods", "Resample select nearest neighbor, bilinear, or bicubic interpolation", "self.OnMenuCmd", "r.resamp.interp"), + ("Nearest neighbor", "Resample using nearest neighbor interpolation", "self.OnMenuCmd", "r.resample"), + ("Regularized spline tension", "Resample using regularized spline tension", "self.OnMenuCmd", "r.resamp.rst"), + )), + ("Support file maintenance", "Support file creation and maintenance", "self.OnMenuCmd", "r.support"), + ("Update map statistics", "Update map statistics", "self.OnMenuCmd", "r.support.stats"), ("","","", ""), - ("Reproject raster from other location", "Reproject raster from other location", "self.OnMenuCmd", "r.proj"), - ("Generate tiling for other projection", "Generate tiling for other projection", "self.OnMenuCmd", "r.tileset"), + ("Reproject", "Reproject raster from other location", "self.OnMenuCmd", "r.proj"), + ("Tiling", "Generate tiling for other projection", "self.OnMenuCmd", "r.tileset"), )), ("Manage map colors", ( - ("Set colors to predefined color tables", "Set colors to predefined color tables", "self.OnMenuCmd", "r.colors"), - ("Set colors using color rules", "Set colors using color rules", "self.OnMenuCmd", "r.colors.rules"), + ("Color tables", "Set colors to predefined color tables", "self.OnMenuCmd", "r.colors"), + ("Color rules", "Set colors using color rules", "self.RulesCmd", "r.colors"), ("","","", ""), - ("Blend 2 color maps to produce 3 RGB files", "Blend 2 color maps to produce 3 RGB files", "self.OnMenuCmd", "r.blend"), - ("Create color image from RGB files", "Create color image from RGB files", "self.OnMenuCmd", "r.composite"), - ("Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.OnMenuCmd", "r.his"), + ("Blend 2 color maps", "Blend 2 color maps to produce 3 RGB files", "self.OnMenuCmd", "r.blend"), + ("Create RGB", "Create color image from RGB files", "self.OnMenuCmd", "r.composite"), + ("RGB to HIS", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.OnMenuCmd", "r.his"), )), ("Query by coordinates", "Query by coordinates", "self.OnMenuCmd", "r.what"), ("","","", ""), - ("Create raster buffers", "Develop raster buffer", "self.OnMenuCmd", "r.buffer"), - ("Create raster MASK", "Develop raster mask", "self.OnMenuCmd", "r.mask"), - ("Locate closest points between areas in 2 raster maps", "r.distance", "self.OnMenuCmd", "r.distance"), + ("Buffers", "Develop raster buffer", "self.OnMenuCmd", "r.buffer"), + ("MASK", "Develop raster mask", "self.OnMenuCmd", "r.mask"), + ("Closest points", "r.distance", "self.OnMenuCmd", "r.distance"), ("Map calculator", "Map calculator", "self.OnMenuCmd", "scripts/mapcalc_gparser.sh"), ("Neighborhood analysis", ( - ("Moving window analysis of raster cells", "Moving window analysis of raster cells", "self.OnMenuCmd", "r.neighbors"), - ("Analyze vector points in neighborhood of raster cells", "Analyze vector points in neighborhood of raster cells", "self.OnMenuCmd", "v.neighbors"), + ("Moving window", "Moving window analysis of raster cells", "self.OnMenuCmd", "r.neighbors"), + ("Neighborhood points", "Analyze vector points in neighborhood of raster cells", "self.OnMenuCmd", "v.neighbors"), )), ("Overlay maps", ( ("Cross product", "Cross product", "self.OnMenuCmd", "r.cross"), - ("Function of map series (time series)", "Function of map series (time series)", "self.OnMenuCmd", "r.series"), + ("Map series", "Function of map series (time series)", "self.OnMenuCmd", "r.series"), ("Patch maps", "Patch maps", "self.OnMenuCmd", "r.patch"), ("","","", ""), - ("Statistical calculations for cover map over base map", "Statistical calculations for cover map over base map", "self.OnMenuCmd", "r.statistics"), + ("Statistical overlay", "Statistical calculations for cover map over base map", "self.OnMenuCmd", "r.statistics"), )), ("Solar radiance and shadows", ( - ("Solar irradiance and daily irradiation", "Solar irradiance and daily irradiation", "self.OnMenuCmd", "r.sun"), - ("Shadow map for sun position or date/time", "Shadow map for sun position or date/time", "self.OnMenuCmd", "r.sunmask"), + ("Solar irradiance and irradiation", "Solar irradiance and daily irradiation", "self.OnMenuCmd", "r.sun"), + ("Shadow map", "Shadow map for sun position or date/time", "self.OnMenuCmd", "r.sunmask"), )), ("Terrain analysis", ( - ("Calculate cumulative movement costs between locales", "Calculate cumulative movement costs between locales", "self.OnMenuCmd", "r.walk"), + ("Cumulative movement costs", "Calculate cumulative movement costs between locales", "self.OnMenuCmd", "r.walk"), ("cost surface", "cost surface", "self.OnMenuCmd", "r.cost"), ("Least cost route or flow", "Least cost route or flow", "self.OnMenuCmd", "r.drain"), - ("Shaded relief map", "Shaded relief map", "self.OnMenuCmd", "r.shaded.relief"), + ("Shaded relief", "Shaded relief map", "self.OnMenuCmd", "r.shaded.relief"), ("Slope and aspect", "Slope and aspect", "self.OnMenuCmd", "r.slope.aspect"), ("Terrain parameters", "Terrain parameters", "self.OnMenuCmd", "r.param.scale"), ("Textural features", "Textural features", "self.OnMenuCmd", "r.texture"), - ("Visibility/Line of sight", "Visibility/Line of sight", "self.OnMenuCmd", "r.los"), + ("Visibility", "Visibility and line of sight", "self.OnMenuCmd", "r.los"), )), ("Transform features", ( - ("Clump small areas (statistics calculated by r.volume)", "Clump small areas (statistics calculated by r.volume)", "self.OnMenuCmd", "r.clump"), - ("Grow areas", "Grow areas", "self.OnMenuCmd", "r.grow"), - ("Thin linear features", "Thin linear features", "self.OnMenuCmd", "r.thin"), + ("Clump", "Clump small areas (statistics calculated by r.volume)", "self.OnMenuCmd", "r.clump"), + ("Grow", "Grow areas", "self.OnMenuCmd", "r.grow"), + ("Thin", "Thin linear features", "self.OnMenuCmd", "r.thin"), )), ("","","", ""), ("Hydrologic modeling", ( - ("Carve stream channels into elevation map using vector streams map", "Carve stream channels into elevation map using vector streams map", "self.OnMenuCmd", "r.carve"), - ("Depressionless elevation map and flowline map", "Depressionless elevation map and flowline map", "self.OnMenuCmd", "r.fill.dir"), - ("Fill lake from seed point to specified level", "Fill lake from seed point to specified level", "self.OnMenuCmd", "r.lake"), - ("Flow accumulation for massive grids (WHICH COMMAND?)", "Flow accumulation for massive grids", "self.OnMenuCmd", "r.flow"), - ("Generate flow lines for raster map (WHICH COMMAND?)", "Generate flow lines for raster map", "self.OnMenuCmd", "r.flow"), - ("SIMWE overland flow modeling (WHICH COMMAND?)", "SIMWE overland flow modeling", "self.OnMenuCmd", "r.simwe"), - ("SIMWE sediment erosion, transport, deposition modeling (WHICH COMMAND?)", "SIMWE sediment erosion, transport, deposition modeling", "self.OnMenuCmd", "r.simwe"), + ("Carve stream channels", "Carve stream channels into elevation map using vector streams map", "self.OnMenuCmd", "r.carve"), + ("Depressionless elevation and flowline map", "Depressionless elevation map and flowline map", "self.OnMenuCmd", "r.fill.dir"), + ("Fill lake", "Fill lake from seed point to specified level", "self.OnMenuCmd", "r.lake"), + ("Flow accumulation", "Flow accumulation for massive grids", "self.OnMenuCmd", "r.terraflow"), + ("Flow lines", "Generate flow lines for raster map", "self.OnMenuCmd", "r.flow"), + ("Overland flow modeling", "SIMWE overland flow modeling", "self.OnMenuCmd", "r.sim.water"), + ("Sediment modeling", "SIMWE sediment erosion, transport, deposition modeling", "self.OnMenuCmd", "r.sim.sediment"), ("Topographic index map", "Topographic index map", "self.OnMenuCmd", "r.topidx"), ("TOPMODEL simulation", "TOPMODEL simulation", "self.OnMenuCmd", "r.topmodel"), ("Watershed subbasins", "Watershed subbasins", "self.OnMenuCmd", "r.basins.fill"), Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-10 19:01:41 UTC (rev 817) +++ trunk/grassaddons/gui/wxgui.py 2007-06-10 19:02:27 UTC (rev 818) @@ -54,6 +54,9 @@ import gui_modules.defaultfont as defaultfont import gui_modules.histogram as histogram import gui_modules.profile as profile +import gui_modules.rules as rules +import gui_modules.utils as utils +import gui_modules.cmd as cmd from icons.icon import Icons as Icons from gui_modules.debug import Debug as Debug @@ -260,8 +263,6 @@ #self.out_sizer.Fit(self.outpage) #self.outpage.Layout() - - self.Centre() return self.notebook @@ -347,6 +348,30 @@ global gmpath menuform.GUI().ParseCommand(cmd,gmpath, parentframe=self) + def RulesCmd(self, event): + """ + Launches dialog for commands that need rules + input and processes rules + """ + menuitem = self.menubar.FindItemById(event.GetId()) + itemtext = menuitem.GetText() + command = menucmd[itemtext] + dlg = rules.RulesText(self, cmd=command) + if dlg.ShowModal() == wx.ID_OK: + if command == 'r.colors': + gtemp = utils.GetTempfile() + output = open(gtemp,"w") + output.write(dlg.rules) + output.close() + cmdlst = [command, 'map=%s' % dlg.inmap,'rules=%s' % gtemp,'--verbose'] + else: + cmdlst = [dlg.rules, '>', command, 'input%s' % dlg.inmap, 'output=%s' % outmap, '--verbose'] + + p = cmd.Command(cmdlst) + + + dlg.Destroy() + def DefaultFont(self, event): """Set default font for GRASS displays""" From barton at grass.itc.it Sun Jun 10 21:03:45 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sun Jun 10 21:03:46 2007 Subject: [grass-addons] r819 - trunk/grassaddons/gui/gui_modules Message-ID: <200706101903.l5AJ3ja0008575@grass.itc.it> Author: barton Date: 2007-06-10 21:03:34 +0200 (Sun, 10 Jun 2007) New Revision: 819 Modified: trunk/grassaddons/gui/gui_modules/__init__.py Log: Update to include new rules module Modified: trunk/grassaddons/gui/gui_modules/__init__.py =================================================================== --- trunk/grassaddons/gui/gui_modules/__init__.py 2007-06-10 19:02:27 UTC (rev 818) +++ trunk/grassaddons/gui/gui_modules/__init__.py 2007-06-10 19:03:34 UTC (rev 819) @@ -5,4 +5,5 @@ "menuform", "select", "digit", + "rules" ] From barton at grass.itc.it Mon Jun 11 07:53:04 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Mon Jun 11 07:53:06 2007 Subject: [grass-addons] r820 - trunk/grassaddons/gui/gui_modules Message-ID: <200706110553.l5B5r4pJ017120@grass.itc.it> Author: barton Date: 2007-06-11 07:52:56 +0200 (Mon, 11 Jun 2007) New Revision: 820 Modified: trunk/grassaddons/gui/gui_modules/select.py Log: Code cleanup. Replace os.popen with subprocess.Popen Modified: trunk/grassaddons/gui/gui_modules/select.py =================================================================== --- trunk/grassaddons/gui/gui_modules/select.py 2007-06-10 19:03:34 UTC (rev 819) +++ trunk/grassaddons/gui/gui_modules/select.py 2007-06-11 05:52:56 UTC (rev 820) @@ -18,6 +18,7 @@ import os import wx import wx.combo +import cmd class Select(wx.combo.ComboCtrl): def __init__(self, parent, id, size, type): @@ -106,9 +107,15 @@ with all relevant elements displayed beneath each mapset branch """ #set environmental variables - gisdbase = os.popen('g.gisenv get=GISDBASE', "r").read().strip() - location = os.popen('g.gisenv get=LOCATION_NAME', "r").read().strip() - curr_mapset = os.popen('g.gisenv get=MAPSET', "r").read().strip() + cmdlist = ['g.gisenv', 'get=GISDBASE'] + gisdbase = cmd.Command(cmdlist).module_stdout.read().strip() + + cmdlist = ['g.gisenv', 'get=LOCATION_NAME'] + location = cmd.Command(cmdlist).module_stdout.read().strip() + + cmdlist = ['g.gisenv', 'get=MAPSET'] + curr_mapset = cmd.Command(cmdlist).module_stdout.read().strip() + location_path = os.path.join (gisdbase,location) windfile = os.path.join (location_path,'PERMANENT','WIND') symbol_path = os.path.join (os.environ['GISBASE'],'etc','symbol') @@ -118,7 +125,8 @@ pass #mapsets in current location - mapsets = os.popen('g.mapsets -p').read().strip().split(' ') + cmdlist = ['g.mapsets', '-p'] + mapsets = cmd.Command(cmdlist).module_stdout.read().strip().split(' ') elementlist = ['cell', 'grid3d', From barton at grass.itc.it Mon Jun 11 07:54:31 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Mon Jun 11 07:54:33 2007 Subject: [grass-addons] r821 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200706110554.l5B5sV9k017152@grass.itc.it> Author: barton Date: 2007-06-11 07:54:19 +0200 (Mon, 11 Jun 2007) New Revision: 821 Modified: trunk/grassaddons/gui/gui_modules/menudata.py trunk/grassaddons/gui/wxgui.py Log: More menu updating. r.reclass and r.recode can now use interactive rule setting. v.reclass should work, but doesn't yet. Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-11 05:52:56 UTC (rev 820) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-11 05:54:19 UTC (rev 821) @@ -134,7 +134,7 @@ )), ("Raster", ( ("Develop map", ( - ("Digitize raster (not functional)", "Digitize raster", "self.OnRDigit", ""), + ("Digitize raster (not functional)", "Digitize raster", "self.OnXTerm", "r.digit"), ("","","", ""), ("Compress/decompress", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), ("Boundaries", "Manage boundary definition", "self.OnMenuCmd", "r.region"), @@ -155,7 +155,7 @@ )), ("Manage map colors", ( ("Color tables", "Set colors to predefined color tables", "self.OnMenuCmd", "r.colors"), - ("Color rules", "Set colors using color rules", "self.RulesCmd", "r.colors"), + ("Color rules", "Set colors interactively with color rules", "self.RulesCmd", "r.colors"), ("","","", ""), ("Blend 2 color maps", "Blend 2 color maps to produce 3 RGB files", "self.OnMenuCmd", "r.blend"), ("Create RGB", "Create color image from RGB files", "self.OnMenuCmd", "r.composite"), @@ -213,12 +213,32 @@ ("Watershed basin creation", "Watershed basin creation", "self.OnMenuCmd", "r.water.outlet"), )), ("Landscape structure modeling", ( - ("Set up sampling and analysis framework", "Set up sampling and analysis framework", "self.OnMenuCmd", "r.le.setup"), + ("Set up", "Set up sampling and analysis framework", "self.OnMenuCmd", "r.le.setup"), ("","","", ""), - ("Analyze landscape characteristics", "Analyze landscape characteristics", "self.OnMenuCmd", "r.le.pixel"), - ("Analyze landscape patch characteristics", "Analyze landscape patch characteristics", "self.OnMenuCmd", "r.le.patch"), - ("Output landscape patch information", "Output landscape patch information", "self.OnMenuCmd", "r.le.trace"), + ("Analyze landscape", "Analyze landscape characteristics", "self.OnMenuCmd", "r.le.pixel"), + ("Analyze patches", "Analyze landscape patch characteristics", "self.OnMenuCmd", "r.le.patch"), + ("Output", "Output landscape patch information", "self.OnMenuCmd", "r.le.trace"), )), + ("Landscape patch analysis", ( + ("Set up sampling and analysis framework", "Configure and create patch map for analysis", "self.OnMenuCmd", "r.li.setup"), + ("","","", ""), + ("Edge density", "Calculate edge density index using a 4 neighbour algorithm", "self.OnMenuCmd", "r.li.edgedensity"), + ("Contrast weighted edge density", "Calculate contrast weighted edge density index", "self.OnMenuCmd", "r.li.cwed"), + ("","","", ""), + ("Patch area mean", "Calculate mean patch size index using a 4 neighbour algorithm", "self.OnMenuCmd", "r.li.mps"), + ("Patch area range", "Calculate range of patch area size", "self.OnMenuCmd", "r.li.padrange"), + ("Patch area SD", "Calculate standard deviation of patch area", "self.OnMenuCmd", "r.li.padsd"), + ("Patch area CV", "Calculate coefficient of variation of patch area", "self.OnMenuCmd", "r.li.padcv"), + ("Patch density", "Calculate patch density index using a 4 neighbour algorithm", "self.OnMenuCmd", "r.li.patchdensity"), + ("Patch number", "Calculate patch number index using a 4 neighbour algorithm", "self.OnMenuCmd", "r.li.patchnum"), + ("","","", ""), + ("Dominance's diversity", "Calculate Dominance's diversity index", "self.OnMenuCmd", "r.li.dominance"), + ("Shannon's diversity", "Calculate Shannon's diversity index", "self.OnMenuCmd", "r.li.shannon"), + ("Simpson's diversity", "Calculate Simpson's diversity index", "self.OnMenuCmd", "r.li.simpson"), + ("","","", ""), + ("Richness", "Calculate richness index", "self.OnMenuCmd", "r.li.richness"), + ("Shape index", "Calculate shape index", "self.OnMenuCmd", "r.li.shape"), + )), ("Wildfire modeling", ( ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.OnMenuCmd", "r.ros"), ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.OnMenuCmd", "r.spreadpath"), @@ -228,15 +248,15 @@ ("Change category values and labels", ( ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.OnMenuCmd", "d.rast.edit"), ("","","", ""), - ("Reclassify categories for areas of specified sizes", "Reclassify categories for areas of specified sizes", "self.OnMenuCmd", "r.reclass.area"), - ("Reclassify categories using rules", "Reclassify categories using rules", "self.OnMenuCmd", "r.reclass.rules"), - ("Reclassify categories using rules file", "Reclassify categories using rules file", "self.OnMenuCmd", "r.reclass.file"), + ("Reclassify by size", "Reclassify categories for areas of specified sizes", "self.OnMenuCmd", "r.reclass.area"), + ("Reclassify using rules", "Reclassify categories interactively with rules", "self.RulesCmd", "r.reclass"), + ("Reclassify using rules file", "Reclassify categories using rules file", "self.OnMenuCmd", "r.reclass.file"), ("","","", ""), - ("Recode categories using rules (create new map)", "Recode categories using rules (create new map)", "self.OnMenuCmd", "r.recode.rules"), - ("Recode categories using rules file (create new map)", "Recode categories using rules file (create new map)", "self.OnMenuCmd", "r.recode.file"), + ("Recode using rules", "Recode categories interactively with rules (create new map)", "self.RulesCmd", "r.recode"), + ("Recode using rules file", "Recode categories using rules file (create new map)", "self.OnMenuCmd", "r.recode.file"), ("","","", ""), - ("Rescale categories (create new map)", "Rescale categories (create new map)", "self.OnMenuCmd", "r.rescale"), - ("Rescale categories with equalized histogram (create new map)", "Rescale categories with equalized histogram (create new map)", "self.OnMenuCmd", "r.rescale.eq"), + ("Rescale", "Rescale categories (create new map)", "self.OnMenuCmd", "r.rescale"), + ("Rescale with histogram", "Rescale categories with equalized histogram (create new map)", "self.OnMenuCmd", "r.rescale.eq"), )), ("","","", ""), ("Generate concentric circles around points", "Generate concentric circles around points", "self.OnMenuCmd", "r.circle"), @@ -245,44 +265,47 @@ ("Generate random cells and vector points from raster map", "Generate random cells and vector points from raster map", "self.OnMenuCmd", "r.random"), )), ("Generate surfaces", ( - ("Generate density surface using moving Gaussian kernel", "Generate density surface using moving Gaussian kernel", "self.OnMenuCmd", "v.kernel"), - ("Generate fractal surface", "Generate fractal surface", "self.OnMenuCmd", "r.surf.fractal"), - ("Generate gaussian deviates surface", "Generate gaussian deviates surface", "self.OnMenuCmd", "r.surf.gauss"), - ("Generate plane", "Generate plane", "self.OnMenuCmd", "r.plane"), - ("Generate random deviates surface", "Generate random deviates surface", "self.OnMenuCmd", "r.surf.random"), - ("Generate random surface with spatial dependence", "Generate random surface with spatial dependence", "self.OnMenuCmd", "r.random.surface"), + ("Fractal surface", "Generate fractal surface", "self.OnMenuCmd", "r.surf.fractal"), + ("","","", ""), + ("Gaussian kernel surface", "Generate density surface using moving Gaussian kernel", "self.OnMenuCmd", "v.kernel"), + ("Gaussian deviates surface", "Generate gaussian deviates surface", "self.OnMenuCmd", "r.surf.gauss"), + ("","","", ""), + ("Plane", "Generate plane", "self.OnMenuCmd", "r.plane"), + ("","","", ""), + ("Random deviates surface", "Generate random deviates surface", "self.OnMenuCmd", "r.surf.random"), + ("Random surface with spatial dependence", "Generate random surface with spatial dependence", "self.OnMenuCmd", "r.random.surface"), )), - ("Generate vector contour lines", "Generate vector contour lines", "self.OnMenuCmd", "r.contour"), + ("Generate contour lines", "Generate vector contour lines", "self.OnMenuCmd", "r.contour"), ("Interpolate surfaces", ( - ("Bilinear interpolation from raster points", "Bilinear interpolation from raster points", "self.OnMenuCmd", "r.bilinear"), - ("Inverse distance weighted interpolation from raster points", "Inverse distance weighted interpolation from raster points", "self.OnMenuCmd", "r.surf.idw"), - ("Interpolation from raster contour", "Interpolation from raster contour", "self.OnMenuCmd", "r.surf.contour"), + ("Bilinear from raster points", "Bilinear interpolation from raster points", "self.OnMenuCmd", "r.bilinear"), + ("Inverse distance weighted from raster points", "Inverse distance weighted interpolation from raster points", "self.OnMenuCmd", "r.surf.idw"), + ("Raster contours", "Interpolation from raster contour", "self.OnMenuCmd", "r.surf.contour"), ("","","", ""), - ("Inverse distance weighted interpolation from vector points", "Inverse distance weighted interpolation from vector points", "self.OnMenuCmd", "v.surf.idw"), - ("Regularized spline tension interpolation from vector points or contours (WHICH COMMAND ?)", "Regularized spline tension interpolation from vector points or contours", "self.OnMenuCmd", "v.surf.rst"), + ("Bilinear/bicubic from vector points", "Bicubic and bilinear interpolation with Tykhonov regularization from vector points", "self.OnMenuCmd", "v.surf.bspline"), + ("Inverse distance weighted from vector points", "Inverse distance weighted interpolation from vector points", "self.OnMenuCmd", "v.surf.idw"), + ("Regularized spline tension from vector points or contours (WHICH COMMAND ?)", "Regularized spline tension interpolation from vector points or contours", "self.OnMenuCmd", "v.surf.rst"), ("","","", ""), - ("Fill NULL cells by interpolation using regularized spline tension", "Fill NULL cells by interpolation using regularized spline tension", "self.OnMenuCmd", "r.fillnulls"), + ("Fill NULL cells", "Fill NULL cells by interpolation using regularized spline tension", "self.OnMenuCmd", "r.fillnulls"), )), ("","","", ""), ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), - ("Report category labels and values", "Report category labels and values", "self.OnMenuCmd", "r.cats"), + ("Report basic information", "Report basic file information", "self.OnMenuCmd", "r.info"), + ("Report category information", "Report category labels and values", "self.OnMenuCmd", "r.cats"), ("","","", ""), ("General statistics", "General statistics", "self.OnMenuCmd", "r.stats"), - ("Range of all category values", "Range of all category values", "self.OnMenuCmd", "r.describe"), - ("Sum all cell category values", "Sum all cell category values", "self.OnMenuCmd", "r.sum"), + ("Range of category values", "Range of all category values", "self.OnMenuCmd", "r.describe"), + ("Sum cell category values", "Sum all cell category values", "self.OnMenuCmd", "r.sum"), ("Sum area by map and category", "Sum area by map and category", "self.OnMenuCmd", "r.report"), - ("Summary statistics for clumped cells (work with r.clump)", "Summary statistics for clumped cells (work with r.clump)", "self.OnMenuCmd", "r.volume"), - ("Total surface area corrected for topography", "Total surface area corrected for topography", "self.OnMenuCmd", "r.surf.area"), + ("Statistics for clumped cells", "Summary statistics for clumped cells (work with r.clump)", "self.OnMenuCmd", "r.volume"), + ("Total corrected area", "Total surface area corrected for topography", "self.OnMenuCmd", "r.surf.area"), ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "r.univar"), - ("Univariate statistics (script version)", "Univariate statistics (script version)", "self.OnMenuCmd", "r.univar.sh"), ("","","", ""), - ("Sample values along transects", "Sample values along transects", "self.OnMenuCmd", "r.profile"), - ("Sample values along transects (use azimuth, distance)", "Sample values along transects (use azimuth, distance)", "self.OnMenuCmd", "r.transect"), + ("Sample transects", "Sample values along transects", "self.OnMenuCmd", "r.profile"), + ("Sample transects (bearing/distance)", "Sample values along transects (use azimuth, distance)", "self.OnMenuCmd", "r.transect"), ("","","", ""), ("Covariance/correlation", "Covariance/correlation", "self.OnMenuCmd", "r.covar"), - ("Linear regression between 2 maps", "Linear regression between 2 maps", "self.OnMenuCmd", "r.regression.line"), - ("Mutual category occurrences (coincidence)", "Mutual category occurrences (coincidence)", "self.OnMenuCmd", "r.coin"), + ("Linear regression", "Linear regression between 2 maps", "self.OnMenuCmd", "r.regression.line"), + ("Mutual category occurrences", "Mutual category occurrences (coincidence)", "self.OnMenuCmd", "r.coin"), )), ("","","", "") )), @@ -291,20 +314,20 @@ ("Digitize", "Digitize vector", "self.OnMenuCmd", "v.digit"), ("","","", ""), ("Create/Rebuild topology", "Create/Rebuild topology", "self.OnMenuCmd", "v.build"), - ("Clean vector files", "clean vector files", "self.OnMenuCmd", "v.clean"), + ("Clean vector", "clean vector files", "self.OnMenuCmd", "v.clean"), ("","","", ""), - ("Break lines at intersections", "Break lines at intersections", "self.OnMenuCmd", "v.topo.check"), - ("Build polylines from adjacent segments", "Build polylines from adjacent segments", "self.OnMenuCmd", "v.build.polylines"), - ("Split polylines into segments", "Split polylines into segments", "self.OnMenuCmd", "v.segment"), - ("Create lines parallel to existing lines", "Create lines parallel to existing lines", "self.OnMenuCmd", "v.parallel"), + ("Break lines", "Break lines at intersections", "self.OnMenuCmd", "v.topo.check"), + ("Build polylines", "Build polylines from adjacent segments", "self.OnMenuCmd", "v.build.polylines"), + ("Split polylines", "Split polylines into segments", "self.OnMenuCmd", "v.segment"), + ("Parallel lines", "Create lines parallel to existing lines", "self.OnMenuCmd", "v.parallel"), ("","","", ""), - ("Convert vector feature types", "Convert vector feature types", "self.OnMenuCmd", "v.type"), - ("Convert 2D vector to 3D by sampling raster", "Convert 2D vector to 3D by sampling raster", "self.OnMenuCmd", "v.drape"), - ("Extrude 2D vector into 3D vector", "Extrude 2D vector into 3D vector", "self.OnMenuCmd", "v.extrude"), + ("Convert feature types", "Convert vector feature types", "self.OnMenuCmd", "v.type"), + ("Convert 2D to 3D", "Convert 2D vector to 3D by sampling raster", "self.OnMenuCmd", "v.drape"), + ("Extrude 3D", "Extrude 2D vector into 3D vector", "self.OnMenuCmd", "v.extrude"), ("","","", ""), - ("Create text label file for vector features", "Create text label file for vector features", "self.OnMenuCmd", "v.label"), + ("Create labels", "Create text label file for vector features", "self.OnMenuCmd", "v.label"), ("","","", ""), - ("Reproject vector from other location", "Reproject vector from other location", "self.OnMenuCmd", "v.proj"), + ("Reproject vector", "Reproject vector from other location", "self.OnMenuCmd", "v.proj"), ("","","", "") )), ("","","", ""), @@ -312,72 +335,69 @@ ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), )), - ("Query by attributes", "Query by attributes", "self.OnMenuCmd", "v.extract"), - ("Query by coordinate(s)", "Query by coordinate(s)", "self.OnMenuCmd", "v.what"), - ("Query by map features", "Query by map features", "self.OnMenuCmd", "v.select"), + ("Query attributes", "Query by attributes", "self.OnMenuCmd", "v.extract"), + ("Query coordinate(s)", "Query by coordinate(s)", "self.OnMenuCmd", "v.what"), + ("Query map features", "Query by map features", "self.OnMenuCmd", "v.select"), ("","","", ""), - ("Create vector buffers", "Create vector buffers", "self.OnMenuCmd", "v.buffer"), - ("Linear referencing for vectors", ( - ("Create linear reference system", "Create linear reference system", "self.OnMenuCmd", "v.lrs.create"), - ("Create stationing from input lines, and linear reference system", "Create stationing from input lines, and linear reference system", "self.OnMenuCmd", "v.lrs.label"), - ("Create points/segments from input lines, linear reference system and positions read from stdin", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.OnMenuCmd", "v.lrs.segment"), - ("Find line id and real km+offset for given points in vector map using linear reference system", "Find line id and real km+offset for given points in vector map using linear reference system", "self.OnMenuCmd", "v.lrs.where"), + ("Buffers", "Create vector buffers", "self.OnMenuCmd", "v.buffer"), + ("Linear referencing", ( + ("Create LRS", "Create linear reference system", "self.OnMenuCmd", "v.lrs.create"), + ("Create stationing", "Create stationing from input lines, and linear reference system", "self.OnMenuCmd", "v.lrs.label"), + ("Create points/segments", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.OnMenuCmd", "v.lrs.segment"), + ("Find line id and offset", "Find line id and real km+offset for given points in vector map using linear reference system", "self.OnMenuCmd", "v.lrs.where"), )), - ("Neighborhood analysis", ( - ("Locate nearest feature to points or centroids", "Locate nearest feature to points or centroids", "self.OnMenuCmd", "v.distance"), - ("Generate Thiessen polygons around points (Voronoi diagram)", "Generate Thiessen polygons around points (Voronoi diagram)", "self.OnMenuCmd", "v.voronoi"), - ("Connect points to create Delaunay triangles", "Connect points to create Delaunay triangles", "self.OnMenuCmd", "v.delaunay"), - )), + ("Nearest features", "Locate nearest feature to points or centroids", "self.OnMenuCmd", "v.distance"), ("Network analysis", ( ("Allocate subnets", "Allocate subnets", "self.OnMenuCmd", "v.net.alloc"), ("Network maintenance", "Network maintenance", "self.OnMenuCmd", "v.net"), ("Shortest route", "Shortest route", "self.OnMenuCmd", "v.net.path"), - ("Shortest route (visualization only)", "Shortest route (visualization only)", "self.OnMenuCmd", "d.path"), - ("Split net to bands between cost isolines", "Split net to bands between cost isolines", "self.OnMenuCmd", "v.net.iso"), + ("Shortest route visualization", "Shortest route (visualization only)", "self.OnMenuCmd", "d.path"), + ("Split net", "Split net into bands between cost isolines", "self.OnMenuCmd", "v.net.iso"), ("Steiner tree", "Steiner tree", "self.OnMenuCmd", "v.net.steiner"), ("Traveling salesman analysis", "Traveling salesman analysis", "self.OnMenuCmd", "v.net.salesman"), )), ("Overlay maps", ( - ("Overlay/combine 2 vector maps", "Overlay/combine 2 vector maps", "self.OnMenuCmd", "v.overlay"), - ("Patch multiple maps (combine)", "Patch multiple maps (combine)", "self.OnMenuCmd", "v.patch"), + ("Overlay maps", "Overlay/combine 2 vector maps", "self.OnMenuCmd", "v.overlay"), + ("Patch maps", "Patch multiple maps (combine)", "self.OnMenuCmd", "v.patch"), )), - ("Generate area feature for extent of current region", "Generate area feature for extent of current region", "self.OnMenuCmd", "v.in.region"), - ("Generate rectangular vector grid", "Generate rectangular vector grid", "self.OnMenuCmd", "v.mkgrid"), + ("Generate area for current region", "Generate area feature for extent of current region", "self.OnMenuCmd", "v.in.region"), + ("Generate grid", "Generate rectangular vector grid", "self.OnMenuCmd", "v.mkgrid"), ("","","", ""), ("Change attributes", ( - ("Attach/delete, or report categories", "Attach/delete, or report categories", "self.OnMenuCmd", "v.category"), - ("Reclassify features using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), + ("Manage or report categories", "Attach/delete, or report categories", "self.OnMenuCmd", "v.category"), + ("Reclassify using rules", "Reclassify features interactively using rules", "self.RulesCmd", "v.reclass"), + ("Reclassify using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), )), ("","","", ""), ("Work with vector points", ( ("Generate points", ( - ("Generate points from database", "Generate points from database", "self.OnMenuCmd", "v.in.db"), - ("Generate random points", "Generate random points", "self.OnMenuCmd", "v.random"), - ("Random location perturbations of points", "Random location perturbations of points", "self.OnMenuCmd", "v.perturb"), + ("Generate from database", "Generate points from database", "self.OnMenuCmd", "v.in.db"), + ("Generate random", "Generate random points", "self.OnMenuCmd", "v.random"), + ("Perturb points", "Random location perturbations of points", "self.OnMenuCmd", "v.perturb"), )), ("Generate areas from points", ( - ("Generate convex hull for point set", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), - ("Generate Delaunay triangles for point set", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), - ("Generate Voronoi diagram/Thiessen polygons for point set", "Generate Voronoi diagram/Thiessen polygons for point set", "self.OnMenuCmd", "v.voronoi"), + ("Convex hull", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), + ("Delaunay triangles", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), + ("Voronoi diagram/Thiessen polygons", "Generate Voronoi diagram/Thiessen polygons for point set", "self.OnMenuCmd", "v.voronoi"), )), ("Sample raster maps", ( ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.OnMenuCmd", "v.rast.stats"), ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.OnMenuCmd", "v.what.rast"), ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.OnMenuCmd", "v.sample"), )), - ("Partition points into test/training sets for k-fold cross validation", "Partition points into test/training sets for k-fold cross validation", "self.OnMenuCmd", "v.kcv"), - ("Transfer attribute data from queried vector map to points", "Transfer attribute data from queried vector map to points", "self.OnMenuCmd", "v.what.vect"), + ("Test/training sets", "Partition points into test/training sets for k-fold cross validation", "self.OnMenuCmd", "v.kcv"), + ("Update point attributes from areas", "Transfer attribute data from queried area map to points", "self.OnMenuCmd", "v.what.vect"), )), ("","","", ""), ("Reports and statistics", ( ("Basic information", "Basic information", "self.OnMenuCmd", "v.info"), - ("Load vector attributes to database or create reports", "Load vector attributes to database or create reports", "self.OnMenuCmd", "v.to.db"), - ("Report areas for vector attribute categories", "Report areas for vector attribute categories", "self.OnMenuCmd", "v.report"), + ("Report topology or load to attributes", "Load vector attributes to database or create reports", "self.OnMenuCmd", "v.to.db"), + ("Report topology by category", "Report areas for vector attribute categories", "self.OnMenuCmd", "v.report"), ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "v.univar"), ("","","", ""), - ("Test normality of point distribution", "Test normality of point distribution", "self.OnMenuCmd", "v.normal"), + ("Test normality", "Test normality of point distribution", "self.OnMenuCmd", "v.normal"), ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.OnMenuCmd", "v.rast.stats"), - ("Indices of point counts in quadrats", "Indices of point counts in quadrats", "self.OnMenuCmd", "v.qcount"), + ("Quadrat indices", "Indices of point counts in quadrats", "self.OnMenuCmd", "v.qcount"), )), ("","","", "") )), Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-11 05:52:56 UTC (rev 820) +++ trunk/grassaddons/gui/wxgui.py 2007-06-11 05:54:19 UTC (rev 821) @@ -32,6 +32,10 @@ import wx.stc import wx.lib.customtreectrl as CT import wx.lib.flatnotebook as FN +try: + import subprocess +except: + from compat import subprocess import gui_modules gmpath = gui_modules.__path__[0] @@ -180,7 +184,7 @@ def __createCommandPrompt(self): """Creates command prompt""" - self.cmdprompt = wx.StaticText(self, -1, " command: ") + self.cmdprompt = wx.StaticText(self, -1, " command") return self.cmdprompt def __createCommandInput(self): @@ -331,20 +335,20 @@ cmd = self.cmdinput.GetValue() self.goutput.RunCmd(cmd) - #menuform.GUI().ParseCommand(cmd, gmpath) - def RunMenuCmd(self, event): + def GetMenuCmd(self, event): menuitem = self.menubar.FindItemById(event.GetId()) itemtext = menuitem.GetText() cmd = menucmd[itemtext] + return cmd + + def RunMenuCmd(self, event): + cmd = self.GetMenuCmd(event) self.goutput.RunCmd(cmd) def OnMenuCmd(self, event): """Run menu command""" - - menuitem = self.menubar.FindItemById(event.GetId()) - itemtext = menuitem.GetText() - cmd = menucmd[itemtext] + cmd = self.GetMenuCmd(event) global gmpath menuform.GUI().ParseCommand(cmd,gmpath, parentframe=self) @@ -353,25 +357,62 @@ Launches dialog for commands that need rules input and processes rules """ - menuitem = self.menubar.FindItemById(event.GetId()) - itemtext = menuitem.GetText() - command = menucmd[itemtext] + command = self.GetMenuCmd(event) dlg = rules.RulesText(self, cmd=command) if dlg.ShowModal() == wx.ID_OK: + gtemp = utils.GetTempfile() + output = open(gtemp,"w") + output.write(dlg.rules) + output.close() if command == 'r.colors': - gtemp = utils.GetTempfile() - output = open(gtemp,"w") - output.write(dlg.rules) - output.close() - cmdlst = [command, 'map=%s' % dlg.inmap,'rules=%s' % gtemp,'--verbose'] + cmdlist = [command, 'map=%s' % dlg.inmap, 'color=rules', '--verbose'] else: - cmdlst = [dlg.rules, '>', command, 'input%s' % dlg.inmap, 'output=%s' % outmap, '--verbose'] + cmdlist = [command, 'input=%s' % dlg.inmap, 'output=%s' % dlg.outmap, '--verbose'] - p = cmd.Command(cmdlst) + p1 = subprocess.Popen(['cat', gtemp], stdout=subprocess.PIPE) + p2 = subprocess.Popen(cmdlist, stdin=p1.stdout, stdout=subprocess.PIPE) - dlg.Destroy() + def OnXTerm(self, event): + """ + Run commands that need interactive xmon + """ + command = self.GetMenuCmd(event) + + # unset display mode + del os.environ['GRASS_RENDER_IMMEDIATE'] + + # open next available xmon + xmonlist = [] + cmdlist = ['d.mon', '-L'] + p = cmd.Command(cmdlist) + + output = p.module_stdout.read().split('\n') + + for outline in output: + outline = outline.strip() + if outline.startswith('x') and 'not running' in outline: + # make list of xmons that are not running + xmonlist.append(outline[0:2]) + xmon = xmonlist[0] + cmdlst = ['d.mon','start=%s' % xmon, '&'] + p = cmd.Command(cmdlst) + + # run the command + cmdlist = ['g.gisenv', 'get=GISDBASE'] + gisdbase = cmd.Command(cmdlist).module_stdout.read().strip() + print 'gisbase=',gisbase + if os.environ['mingw'] == '1': + cmdlist ['cmd.exe', '/c', 'start', os.path.join(gisdbase,'etc','grass-run.bat'), command] + else: + cmdlist [os.path.join(gisdbase,'etc','grass-xterm-wrapper'), '-name', 'xterm-grass', '-e', os.path.join(gisdbase,'etc','grass-run.sh'), command, '&'] + print 'cmdlist =',cmdlist + p = cmd.Command(cmdlist) + + # reset display mode + os.environ['GRASS_RENDER_IMMEDIATE'] = True + def DefaultFont(self, event): """Set default font for GRASS displays""" From cepicky at grass.itc.it Mon Jun 11 08:07:57 2007 From: cepicky at grass.itc.it (cepicky@grass.itc.it) Date: Mon Jun 11 08:07:58 2007 Subject: [grass-addons] r822 - trunk/grassaddons/gui Message-ID: <200706110607.l5B67v08017214@grass.itc.it> Author: cepicky Date: 2007-06-11 08:07:04 +0200 (Mon, 11 Jun 2007) New Revision: 822 Modified: trunk/grassaddons/gui/wxgui.py Log: another promt description Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-11 05:54:19 UTC (rev 821) +++ trunk/grassaddons/gui/wxgui.py 2007-06-11 06:07:04 UTC (rev 822) @@ -184,7 +184,7 @@ def __createCommandPrompt(self): """Creates command prompt""" - self.cmdprompt = wx.StaticText(self, -1, " command") + self.cmdprompt = wx.StaticText(self, -1, "GRASS>") return self.cmdprompt def __createCommandInput(self): From maldacker at grass.itc.it Mon Jun 11 21:22:23 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Mon Jun 11 21:22:31 2007 Subject: [grass-addons] r823 - trunk/grassaddons Message-ID: <200706111922.l5BJMNM2023741@grass.itc.it> Author: maldacker Date: 2007-06-11 21:22:20 +0200 (Mon, 11 Jun 2007) New Revision: 823 Added: trunk/grassaddons/v.path.obstacles/ Log: Created directory v.path.obstacles From maldacker at grass.itc.it Mon Jun 11 21:24:29 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Mon Jun 11 21:24:33 2007 Subject: [grass-addons] r824 - trunk/grassaddons/v.path.obstacles Message-ID: <200706111924.l5BJOTeT024210@grass.itc.it> Author: maldacker Date: 2007-06-11 21:24:21 +0200 (Mon, 11 Jun 2007) New Revision: 824 Added: trunk/grassaddons/v.path.obstacles/Makefile trunk/grassaddons/v.path.obstacles/description.html trunk/grassaddons/v.path.obstacles/main.c trunk/grassaddons/v.path.obstacles/rotation_tree.c trunk/grassaddons/v.path.obstacles/rotation_tree.h trunk/grassaddons/v.path.obstacles/visibility.c trunk/grassaddons/v.path.obstacles/visibility.h Log: initial commit Added: trunk/grassaddons/v.path.obstacles/Makefile =================================================================== --- trunk/grassaddons/v.path.obstacles/Makefile (rev 0) +++ trunk/grassaddons/v.path.obstacles/Makefile 2007-06-11 19:24:21 UTC (rev 824) @@ -0,0 +1,18 @@ + +MODULE_TOPDIR = ../.. + +PGM = v.path.obstacles + +LIBES = $(VECTLIB) $(GISLIB) +DEPENDENCIES = $(VECTDEP) $(GISDEP) +EXTRA_INC = $(VECT_INC) +EXTRA_CFLAGS = $(VECT_CFLAGS) + +include $(MODULE_TOPDIR)/include/Make/Module.make + + +default: cmd + + + + Property changes on: trunk/grassaddons/v.path.obstacles/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/v.path.obstacles/description.html =================================================================== --- trunk/grassaddons/v.path.obstacles/description.html (rev 0) +++ trunk/grassaddons/v.path.obstacles/description.html 2007-06-11 19:24:21 UTC (rev 824) @@ -0,0 +1,136 @@ +

DESCRIPTION

+ +v.net.path can find shortest path(s) on the vector network. +Costs may be either line lengths, or attributes saved in a database +table. These attributes values are taken as costs of whole segments. If read +from the table, arcs' costs may be different in both directions. +Shortest paths are written to output vector map and attached attribute table. +

+ +Nodes can be piped into the program from file or from stdin. The +syntax is as follows: +

+id start_point_category end_point_category
+
+ +or + +
+id start_point_x start_point_y end_point_x end_point_y
+
+ +

+Points specified by category must be exactly on network nodes, +while, when specifying coordinates, the next node to a given +coordinate pair is used. +

+

+Attribute table will contain following attributes: +

+
    +
  • cat - path unique category assigned by module
  • +
  • id - path id (read from input)
  • +
  • fcat - from point category
  • +
  • tcat - to point category
  • +
  • sp - result status: +
      +
    • 0 - OK, path found
    • +
    • 1 - node is not reachable
    • +
    • 2 - point of given category does not exist
    • +
  • +
  • cost - travelling costs (on the network, not to/from network)
  • +
  • fdist - the distance from first point to the network
  • +
  • tdist - the distance from the network to second point
  • +
+ +

NOTE

+ +If the columns 'afcol', 'abcol' and 'ncol' costs are not +specified, the length of network segments is measured and +zero costs are assumed for nodes. +

+When using attributes, the length of segments is not used. To get +more precise results, length should be taken indirectly into account +by attributes. For example, to get the fastest path the columns +'max_speed' and 'length' are required. The correct fastest path can then +be found by specifying afcol=length/max_speed (pg driver). If needed, +the line length can be calculated and written to the attributes table +by v.to.db. + +

EXAMPLE

+ +Shortest path from two digitized nodes: + +
+g.copy vect=roads,myroads
+v.db.addcol myroads col="forward double precision, backward double precision"
+
+# define traveling costs as inverse of speed limit:
+v.db.update myroads col=forward val=1/50
+v.db.update myroads col=backward val=1/50
+v.db.update myroads col=forward val=1/75 where="label='interstate'"
+v.db.update myroads col=backward val=1/75 where="label='interstate'"
+v.db.update myroads col=forward val=1/5 where="label='unimproved road'"
+v.db.update myroads col=backward val=1/5 where="label='unimproved road'"
+v.db.update myroads col=forward val=1/25 where="label='light-duty road, improved surface'"
+v.db.update myroads col=backward val=1/25 where="label='light-duty road, improved surface'"
+v.db.select myroads
+echo "1|601653.5|4922869.2|start|0|0
+2|593330.8|4924096.6|end|0|0" | v.in.ascii cat=1 x=2 y=3 out=startend col="cat integer, \
+                         east double precision, north double precision, label varchar(43), \
+                         forward double precision, backward double precision"
+
+v.db.dropcol startend col=east
+v.db.dropcol startend col=north
+
+#create lines map connecting points to network
+v.distance -p from=startend to=myroads out=connect upload=dist column=dist
+d.vect myroads
+d.vect startend col=red
+d.vect connect col=green
+
+# note that tables needs to be identical for v.patch:
+db.describe myroads -c
+v.db.addtable connect col="label varchar(43), forward double precision, backward double precision"
+# add categories, use cat 0 (no data) for both roads as "off-road":
+v.category in=connect out=connect_cat cat=0 step=0
+# insert attributes:
+echo "INSERT INTO connect_cat (cat, label, forward, backward) VALUES (0, 'no data', 50, 50)" | db.execute
+v.db.select connect_cat
+
+v.info -c connect_cat
+v.info -c startend
+
+#merge all maps into a new one: streets, connections, points:
+v.patch -e myroads,connect_cat,startend out=myroads_n
+
+#fix the topology: break lines, snap to nodes:
+# (note: this removes overpasses, better use v.edit)
+v.clean myroads_n output=myroads_net tool=snap,break,rmdupl thresh=1,0,0
+v.db.select myroads_net
+d.vect myroads_net icon=basic/triangle fcol=green size=12
+d.vect myroads_net disp=cat type=point lsize=14
+# ... the 'start' and 'end' nodes have category number 9 and 10
+
+# ID as first number, then cat1 and cat2
+# (nlayer=1 if no extra table for nodes)
+echo "1 9 10" | v.net.path myroads_net afcol=forward abcol=backward out=mypath nlayer=1
+d.vect mypath col=red width=2
+
+ + +

SEE ALSO

+ +d.path, +v.net, +v.net.alloc, +v.net.iso, +v.net.salesman, +v.net.steiner, +v.to.db + +

AUTHOR

+ +Radim Blazek, ITC-Irst, Trento, Italy + +

Last changed: $Date: 2007/05/04 08:08:36 $ Property changes on: trunk/grassaddons/v.path.obstacles/description.html ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/v.path.obstacles/main.c =================================================================== --- trunk/grassaddons/v.path.obstacles/main.c (rev 0) +++ trunk/grassaddons/v.path.obstacles/main.c 2007-06-11 19:24:21 UTC (rev 824) @@ -0,0 +1,80 @@ +/**************************************************************** + * MODULE: v.path.obstacles + * + * AUTHOR(S): Maximilian Maldacker + * + * + * COPYRIGHT: (C) 2002-2005 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 +#include +#include +#include +#include "visibility.h" + +int main( int argc, char* argv[]) +{ + struct Map_info in, out; + struct GModule *module; /* GRASS module for parsing arguments */ + struct Option *input, *output; /* The input map */ + char*mapset; + + struct Point * points; + struct Line * lines; + int index; + + + + /* initialize GIS environment */ + G_gisinit(argv[0]); /* reads grass env, stores program name to G_program_name() */ + + /* initialize module */ + module = G_define_module(); + module->keywords = _("vector, path, visibility"); + module->description = _("Shortest path in free vector space"); + + /* define the arguments needed */ + input = G_define_standard_option(G_OPT_V_INPUT); + output = G_define_standard_option(G_OPT_V_OUTPUT); + + + /* options and flags parser */ + if (G_parser(argc, argv)) + exit(EXIT_FAILURE); + + Vect_check_input_output_name ( input->answer, output->answer, GV_FATAL_EXIT ); + + Vect_set_open_level(2); + + mapset = G_find_vector2 (input->answer, NULL); /* finds the map */ + + if ( mapset == NULL ) + G_fatal_error("Map <%s> not found", input->answer ); + + if(Vect_open_old(&in, input->answer, mapset) < 1) /* opens the map */ + G_fatal_error(_("Could not open input")); + + if (Vect_open_new(&out, output->answer, WITHOUT_Z) < 0) + { + Vect_close(&in); + G_fatal_error(_("Could not open output")); + } + + index = load_lines( &in, &points, &lines); + + G_message("We have %d lines", index ); + + construct_visibility( points, lines, index, &out ); + + Vect_build(&out, stdout); + Vect_close(&out); + Vect_close(&in); + exit(EXIT_SUCCESS); +} Property changes on: trunk/grassaddons/v.path.obstacles/main.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/v.path.obstacles/rotation_tree.c =================================================================== --- trunk/grassaddons/v.path.obstacles/rotation_tree.c (rev 0) +++ trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-11 19:24:21 UTC (rev 824) @@ -0,0 +1,100 @@ +/**************************************************************** + * MODULE: v.path.obstacles + * + * AUTHOR(S): Maximilian Maldacker + * + * + * COPYRIGHT: (C) 2002-2005 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 "rotation_tree.h" + + +void add_rightmost(struct Point* p, struct Point* q) +{ + q->rightmost_son = p; + p->father = q; +} + +void add_leftof(struct Point* p, struct Point* q) +{ + q->left_brother = p; + p->right_brother = q; + p->father = q->father; +} + +void remove_point(struct Point* p) +{ + struct Point * f = p->father; + struct Point * l = p->left_brother; + struct Point * r = p->right_brother; + + if ( l != NULL ) + l->right_brother = NULL; + if ( r != NULL ) + r->left_brother = NULL; + + if ( f->rightmost_son == p ) + f->rightmost_son = NULL; + + p->father = NULL; + p->left_brother = NULL; + p->right_brother = NULL; + p->rightmost_son = NULL; + +} + +struct Point* right_brother(struct Point* p) +{ + return p->right_brother; +} + +struct Point* left_brother(struct Point* p) +{ + return p->left_brother; +} + +struct Point* father( struct Point* p) +{ + return p->father; +} + +struct Point* rightmost_son( struct Point * p ) +{ + return p->rightmost_son; +} + +struct Line * segment( struct Point * p ) +{ + return p->line; +} + +struct Point * other( struct Point * p ) +{ + if ( p->line->p1 == p ) + return p->line->p2; + else + return p->line->p1; +} + +int before( struct Point * p, struct Point * q, struct Line * e ) +{ + /* true if q lies nearer to p than segment e*/ + + if ( e == NULL ) + return 1; + + double pq = p->x * q->x + p->y*q->y; + double pe1 = p->x * e->p1->x + p->y*e->p1->y; + double pe2 = p->x * e->p2->x + p->y*e->p2->y; + + + return ( pq < pe1 && pq < pe2 ); +} + Property changes on: trunk/grassaddons/v.path.obstacles/rotation_tree.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/v.path.obstacles/rotation_tree.h =================================================================== --- trunk/grassaddons/v.path.obstacles/rotation_tree.h (rev 0) +++ trunk/grassaddons/v.path.obstacles/rotation_tree.h 2007-06-11 19:24:21 UTC (rev 824) @@ -0,0 +1,55 @@ +/**************************************************************** + * MODULE: v.path.obstacles + * + * AUTHOR(S): Maximilian Maldacker + * + * + * COPYRIGHT: (C) 2002-2005 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. + * + ****************************************************************/ + +#ifndef ROTATION_TREE_H +#define ROTATION_TREE_H + +#include +#include + +struct Point +{ + double x; + double y; + struct Line * line; + struct Line * vis; + struct Point * left_brother; + struct Point * right_brother; + struct Point * father; + struct Point * rightmost_son; +}; + +struct Line +{ + struct Point * p1; + struct Point * p2; +}; + +void add_rightmost(struct Point* p, struct Point* q); +void add_leftof(struct Point* p, struct Point* q); +void remove_point(struct Point* p); +struct Point* right_brother(struct Point* p); +struct Point* left_brother(struct Point* p); +struct Point* father( struct Point* p); +struct Point* rightmost_son( struct Point * p ); + +struct Line * segment( struct Point * p ); +struct Point * other( struct Point * p ); +int before( struct Point * p, struct Point * q, struct Line * e ); + + + + +#endif Property changes on: trunk/grassaddons/v.path.obstacles/rotation_tree.h ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/v.path.obstacles/visibility.c =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.c (rev 0) +++ trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-11 19:24:21 UTC (rev 824) @@ -0,0 +1,332 @@ +/**************************************************************** + * MODULE: v.path.obstacles + * + * AUTHOR(S): Maximilian Maldacker + * + * + * COPYRIGHT: (C) 2002-2005 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 "visibility.h" + +int load_lines( struct Map_info * map, struct Point ** points, struct Line ** lines ) +{ + int index_line = 0; + int index_point = 0; + struct line_pnts* sites; + struct line_cats* cats; + int cat,type; + + int nb_lines; + + sites = Vect_new_line_struct(); + cats = Vect_new_cats_struct(); + + nb_lines = Vect_get_num_lines(map); + *points = (struct Point * ) G_malloc( nb_lines*2*sizeof(struct Point) ); + *lines = ( struct Line * ) G_malloc( nb_lines*sizeof(struct Line) ); + + + while( ( type = Vect_read_next_line( map, sites, cats) ) > -1 ) + { + + if ( type != GV_LINE ) + continue; + + Vect_cat_get (cats, 1, &cat); + + (*points)[index_point].x = sites->x[0]; + (*points)[index_point].y = sites->y[0]; + (*points)[index_point].line = &((*lines)[index_line]); + (*points)[index_point].left_brother = NULL; + (*points)[index_point].right_brother = NULL; + (*points)[index_point].father = NULL; + (*points)[index_point].rightmost_son = NULL; + + + index_point++; + + (*points)[index_point].x = sites->x[1]; + (*points)[index_point].y = sites->y[1]; + (*points)[index_point].line = &((*lines)[index_line]); + (*points)[index_point].left_brother = NULL; + (*points)[index_point].right_brother = NULL; + (*points)[index_point].father = NULL; + (*points)[index_point].rightmost_son = NULL; + + + (*lines)[index_line].p1 = &((*points)[index_point-1]); + (*lines)[index_line].p2 = &((*points)[index_point]); + + index_line++; + index_point++; + + G_message("Line %d with points : %f %f %f %f", index_line, (*points)[index_point-1].x, (*points)[index_point-1].y, (*points)[index_point-2].x, (*points)[index_point-2].y ); + + } + + return index_line; +} + + +int left_turn( struct Point * p1, struct Point * p2, struct Point * p3 ) +{ + double a, b, c, d; + + if ( p3 == p_infinity ) + { + return ( p1->x < p2->x || (p1->x == p2->x && p1->y < p2->y ) ); + } + else + { + a = p1->x - p2->x; + b = p1->y - p2->y; + c = p3->x - p2->x; + d = p3->y - p2->y; + + return a*d - b*c < 0; + } +} + +void init_vis( struct Point * points, struct Line * lines, int num ) +{ + int i; + int j; + int current = 0; + int null=0; + double x; + + for ( i = 0 ; i < num ; i++ ) + { + for ( j = 1 ; j < num/2 ; j++ ) + { + + if ( points[i].x < lines[j].p1->x && points[i].x < lines[j].p2->x ) + { + if ( lines[current].p1->x < lines[current].p2->x ) + x = lines[current].p1->x; + else + x = lines[current].p2->x; + + + if ( lines[j].p1->x < x || lines[j].p2->x < x ) + { + current = j; + null =1; + } + } + } + + if ( null == 0 ) + { + points[i].vis = NULL; + } + else + { + points[i].vis = &lines[current]; + } + + current = 0; + null = 0; + } +} + +void handle( struct Point* p, struct Point* q, struct Map_info * out ) +{ + if ( q == other(p) ) + { + report( p, q, out ); + } + else if ( segment(q) == p->vis ) + { + p->vis = q->vis ; + report( p,q, out ); + } + else if ( before(p,q, p->vis ) ) + { + p->vis = segment(q); + report(p,q,out); + } +} + +void report( struct Point * p, struct Point * q, struct Map_info * out ) +{ + struct line_pnts* sites; + struct line_cats* cats; + double * tmpx = G_malloc( 2*sizeof(double)); + double * tmpy = G_malloc( 2*sizeof(double)); + + sites = Vect_new_line_struct (); + cats = Vect_new_cats_struct (); + + tmpx[0] = p->x; tmpx[1] = q->x; + tmpy[0] = p->y; tmpy[1] = q->y; + + Vect_copy_xyz_to_pnts(sites, tmpx, tmpy, 0, 2); + Vect_write_line (out, GV_LINE, sites, cats); + + G_free(tmpx); + G_free(tmpy); +} + + +int cmp_points(const void* v1, const void* v2) { + struct Point *p1, *p2; + p1 = (struct Point*) v1; + p2 = (struct Point*) v2; + + if( p1->x < p2->x ) + return 1; + else if( p1->x > p2->x ) + return -1; + else if ( p1->y < p2->y ) + return 1; + else if ( p1->y > p2->y ) + return -1; + else + return 0; +} + + +int construct_visibility ( struct Point * points, struct Line * lines, int num_lines, struct Map_info * out ) +{ + int num_points = 2*num_lines; + struct Point * p, * p_r, * q, * z; + int i; + + p_ninfinity = G_malloc( sizeof(struct Point )); + p_infinity = G_malloc( sizeof(struct Point )); + + p_ninfinity->x = PORT_DOUBLE_MAX; + p_ninfinity->y = -PORT_DOUBLE_MAX; + p_ninfinity->father = NULL; + p_ninfinity->left_brother = NULL; + p_ninfinity->right_brother = NULL; + p_ninfinity->rightmost_son = NULL; + + p_infinity->x = PORT_DOUBLE_MAX; + p_infinity->y = PORT_DOUBLE_MAX; + p_infinity->father = NULL; + p_infinity->left_brother = NULL; + p_infinity->right_brother = NULL; + p_infinity->rightmost_son = NULL; + + + init_vis( points, lines, num_points ); + + init_stack(num_points); + + /* sort points in decreasing x order*/ + qsort(points, num_points, sizeof(struct Point), cmp_points); + + add_rightmost( p_ninfinity, p_infinity ); + + for ( i = 0; i < num_points ; i ++ ) + { + if ( i != num_points-1 ) + add_leftof( &points[i], &points[i+1] ); + + add_rightmost( &points[i], p_ninfinity ); + } + + push( &points[0] ); + + + G_message("p_infinity is %d and p_ninfinity is %d ", p_infinity, p_ninfinity ); + + while( !empty_stack() ) + { + + p = pop(); + p_r = right_brother(p); + q = father(p); + + G_message("---------"); + G_message("p is %d and q is %d and p_r is %d", p, q ,p_r); + + if ( q != p_ninfinity ) + { + G_message("Handling %d and %d", p,q); + handle(p,q, out); + } + + z = left_brother(q); + + G_message("z is %d", z ); + if ( z!= NULL ) G_message("father(z) is %d", father(z) ); + + remove_point(p); + + if ( z == NULL || !left_turn(p,z, father(z) ) ) + { + G_message("adding p leftof q "); + add_leftof(p,q); + } + else + { + + while( rightmost_son(z) != NULL && left_turn(p, rightmost_son(z),z) ) + z = rightmost_son(z); + + add_rightmost(p,z); + + G_message("add p as rightmost son of z which is %d", z); + + if ( z == top() ) + z = pop(); + } + + G_message("father(p) is now %d", father(p) ); + + if ( left_brother(p) == NULL && father(p) != p_infinity ) + { + G_message("pushing p"); + push(p); + } + + if ( p_r != NULL ) + { + push(p_r); + G_message("pushing p_r "); + } + + G_message("The stack has %d points", stack_index); + } +} + + +struct Point * pop() +{ + stack_index--; + + return stack[stack_index+1]; +} + +struct Point * top() +{ + return stack[stack_index]; +} + +void push(struct Point * p) +{ + stack_index++; + stack[stack_index] = p; +} + +int empty_stack() +{ + return stack_index == 0; +} + +void init_stack(int size) +{ + stack_index = 0; + stack = G_malloc( size * sizeof( struct Point ) ); +} + Property changes on: trunk/grassaddons/v.path.obstacles/visibility.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/grassaddons/v.path.obstacles/visibility.h =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.h (rev 0) +++ trunk/grassaddons/v.path.obstacles/visibility.h 2007-06-11 19:24:21 UTC (rev 824) @@ -0,0 +1,48 @@ +/**************************************************************** + * MODULE: v.path.obstacles + * + * AUTHOR(S): Maximilian Maldacker + * + * + * COPYRIGHT: (C) 2002-2005 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. + * + ****************************************************************/ +#ifndef VISIBILITY_H +#define VISIBILITY_H + + +#include +#include +#include +#include +#include +#include "rotation_tree.h" + +int load_lines( struct Map_info *map, struct Point ** points, struct Line ** lines ); +int construct_visibility( struct Point * points, struct Line * lines, int num_lines, struct Map_info* out ); +int cmp_points(const void* v1, const void* v2); + +int turn_left( struct Point p1, struct Point p2, struct Point p3 ); + +void handle( struct Point* p, struct Point* q, struct Map_info * out ); +void report( struct Point * p, struct Point * q, struct Map_info * out ); + +void init_vis( struct Point * points, struct Line * lines, int num ); + +struct Point * pop(); +struct Point * top(); +void push(struct Point * p); +int empty_stack(); +void init_stack(); + +static int stack_index; +static struct Point ** stack; +static struct Point * p_ninfinity; +static struct Point * p_infinity; + +#endif Property changes on: trunk/grassaddons/v.path.obstacles/visibility.h ___________________________________________________________________ Name: svn:eol-style + native From barton at grass.itc.it Tue Jun 12 07:41:21 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 12 07:41:24 2007 Subject: [grass-addons] r825 - trunk/grassaddons/gui/gui_modules Message-ID: <200706120541.l5C5fL3o030239@grass.itc.it> Author: barton Date: 2007-06-12 07:41:13 +0200 (Tue, 12 Jun 2007) New Revision: 825 Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Code cleanup. Deleted TreeCtrlComboPopup class whose function was moved to select.py some time back. Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-11 19:24:21 UTC (rev 824) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-12 05:41:13 UTC (rev 825) @@ -810,146 +810,6 @@ pass # self.Map.Clean() -class TreeCtrlComboPopup(wx.combo.ComboPopup): - """ - Create a tree ComboBox for selecting maps and other GIS elements - in accessible mapsets within the current location - """ - - # overridden ComboPopup methods - - def Init(self): - self.value = None - self.curitem = None - - - def Create(self, parent): - self.tree = wx.TreeCtrl(parent, style=wx.TR_HIDE_ROOT - |wx.TR_HAS_BUTTONS - |wx.TR_SINGLE - |wx.TR_LINES_AT_ROOT - |wx.SIMPLE_BORDER - |wx.TR_FULL_ROW_HIGHLIGHT) - self.tree.Bind(wx.EVT_MOTION, self.OnMotion) - self.tree.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) - - - def GetControl(self): - return self.tree - - - def GetStringValue(self): - if self.value: - return self.tree.GetItemText(self.value) - return "" - - - def OnPopup(self): - if self.value: - self.tree.EnsureVisible(self.value) - self.tree.SelectItem(self.value) - - - def SetStringValue(self, value): - # this assumes that item strings are unique... - root = self.tree.GetRootItem() - if not root: - return - found = self.FindItem(root, value) - if found: - self.value = found - self.tree.SelectItem(found) - - - def GetAdjustedSize(self, minWidth, prefHeight, maxHeight): - return wx.Size(minWidth, min(200, maxHeight)) - - - def GetElementList(self, element): - """ - Get list of GIS elements in accessible mapsets and display as tree - with all relevant elements displayed beneath each mapset branch - """ - #set environmental variables - gisdbase = os.popen('g.gisenv get=GISDBASE', "r").read().strip() - location = os.popen('g.gisenv get=LOCATION_NAME', "r").read().strip() - curr_mapset = os.popen('g.gisenv get=MAPSET', "r").read().strip() - location_path = os.path.join (gisdbase,location) - windfile = os.path.join (location_path,'PERMANENT','WIND') - symbol_path = os.path.join (os.environ['GISBASE'],'etc','symbol') - - #valid location test if needed - if windfile != None: - pass - - #mapsets in current location - mapsets = os.popen('g.mapsets -p', "r").read().lstrip().rstrip().split(' ') - - #Get directory tree nodes - for dir in mapsets: - if dir == curr_mapset: - #TODO: make current mapset node expanded - dir_node = self.AddItem('Mapset: '+dir) - self.tree.SetItemTextColour(dir_node,wx.Colour(50,50,200)) - self.tree.Expand(dir_node) - elem_list = os.listdir(os.path.join (location_path, dir, element)) - #TODO: sort list items? - for elem in elem_list: - self.AddItem(elem, parent=dir_node) - else: - dir_node = self.AddItem('Mapset: '+dir) - self.tree.SetItemTextColour(dir_node,wx.Colour(50,50,200)) - elem_list = os.listdir(os.path.join (location_path, dir, element)) - #TODO: sort list items? - for elem in elem_list: - self.AddItem(elem+'@'+dir, parent=dir_node) - - # helpers - - def FindItem(self, parentItem, text): - """Find item in the layer tree""" - item, cookie = self.tree.GetFirstChild(parentItem) - while item: - if self.tree.GetItemText(item) == text: - return item - if self.tree.ItemHasChildren(item): - item = self.FindItem(item, text) - item, cookie = self.tree.GetNextChild(parentItem, cookie) - return wx.TreeItemId(); - - - def AddItem(self, value, parent=None): - """Add item to the layer tree""" - if not parent: - root = self.tree.GetRootItem() - if not root: - root = self.tree.AddRoot("") - parent = root - - item = self.tree.AppendItem(parent, value) - return item - - - def OnMotion(self, evt): - """Have the selection follow the mouse, like in a real combobox""" - item, flags = self.tree.HitTest(evt.GetPosition()) - if item and flags & wx.TREE_HITTEST_ONITEMLABEL: - self.tree.SelectItem(item) - self.curitem = item - evt.Skip() - - - def OnLeftDown(self, evt): - """Left mouse button released""" - # do the combobox selection - item, flags = self.tree.HitTest(evt.GetPosition()) - if item and flags & wx.TREE_HITTEST_ONITEMLABEL: - self.curitem = item - self.value = item - self.Dismiss() - evt.Skip() - - class GMConsole(wx.Panel): """ Create and manage output console for commands entered on the From barton at grass.itc.it Tue Jun 12 07:47:14 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 12 07:47:17 2007 Subject: [grass-addons] r826 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200706120547.l5C5lE7q030289@grass.itc.it> Author: barton Date: 2007-06-12 07:47:02 +0200 (Tue, 12 Jun 2007) New Revision: 826 Modified: trunk/grassaddons/gui/gui_modules/menudata.py trunk/grassaddons/gui/wxgui.py Log: More menu updates. Up through vector items. Also have remaining xterm modules now working from wxgrass (automatic launch of xmon and launch of module in interactive xterm). Improved algorithms for using rules. Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-12 05:41:13 UTC (rev 825) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-12 05:47:02 UTC (rev 826) @@ -134,7 +134,7 @@ )), ("Raster", ( ("Develop map", ( - ("Digitize raster (not functional)", "Digitize raster", "self.OnXTerm", "r.digit"), + ("Digitize raster (requires XTerm)", "Digitize raster", "self.OnXTerm", "r.digit"), ("","","", ""), ("Compress/decompress", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), ("Boundaries", "Manage boundary definition", "self.OnMenuCmd", "r.region"), @@ -213,7 +213,7 @@ ("Watershed basin creation", "Watershed basin creation", "self.OnMenuCmd", "r.water.outlet"), )), ("Landscape structure modeling", ( - ("Set up", "Set up sampling and analysis framework", "self.OnMenuCmd", "r.le.setup"), + ("Set up (requires XTerm)", "Set up sampling and analysis framework", "self.OnXTerm", "r.le.setup"), ("","","", ""), ("Analyze landscape", "Analyze landscape characteristics", "self.OnMenuCmd", "r.le.pixel"), ("Analyze patches", "Analyze landscape patch characteristics", "self.OnMenuCmd", "r.le.patch"), @@ -246,7 +246,7 @@ )), ("","","", ""), ("Change category values and labels", ( - ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.OnMenuCmd", "d.rast.edit"), + ("Interactively edit category values (not functional)", "Edit category values of individual cells for displayed raster map", "self.OnMenuCmd", "d.rast.edit"), ("","","", ""), ("Reclassify by size", "Reclassify categories for areas of specified sizes", "self.OnMenuCmd", "r.reclass.area"), ("Reclassify using rules", "Reclassify categories interactively with rules", "self.RulesCmd", "r.reclass"), @@ -351,7 +351,7 @@ ("Allocate subnets", "Allocate subnets", "self.OnMenuCmd", "v.net.alloc"), ("Network maintenance", "Network maintenance", "self.OnMenuCmd", "v.net"), ("Shortest route", "Shortest route", "self.OnMenuCmd", "v.net.path"), - ("Shortest route visualization", "Shortest route (visualization only)", "self.OnMenuCmd", "d.path"), + ("Shortest route visualization (requires XTErm)", "Shortest route (visualization only)", "self.OnXTerm", "d.path"), ("Split net", "Split net into bands between cost isolines", "self.OnMenuCmd", "v.net.iso"), ("Steiner tree", "Steiner tree", "self.OnMenuCmd", "v.net.steiner"), ("Traveling salesman analysis", "Traveling salesman analysis", "self.OnMenuCmd", "v.net.salesman"), @@ -365,8 +365,8 @@ ("","","", ""), ("Change attributes", ( ("Manage or report categories", "Attach/delete, or report categories", "self.OnMenuCmd", "v.category"), - ("Reclassify using rules", "Reclassify features interactively using rules", "self.RulesCmd", "v.reclass"), - ("Reclassify using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), + ("Reclassify vector using rules", "Reclassify features interactively using rules", "self.RulesCmd", "v.reclass"), + ("Reclassify vector using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), )), ("","","", ""), ("Work with vector points", ( Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-12 05:41:13 UTC (rev 825) +++ trunk/grassaddons/gui/wxgui.py 2007-06-12 05:47:02 UTC (rev 826) @@ -358,6 +358,7 @@ input and processes rules """ command = self.GetMenuCmd(event) + print 'command=',command dlg = rules.RulesText(self, cmd=command) if dlg.ShowModal() == wx.ID_OK: gtemp = utils.GetTempfile() @@ -365,13 +366,17 @@ output.write(dlg.rules) output.close() if command == 'r.colors': - cmdlist = [command, 'map=%s' % dlg.inmap, 'color=rules', '--verbose'] + cmdlist = [command, 'map=%s' % dlg.inmap, 'rules=%s' % gtemp, '--verbose'] + cmd.Command(cmdlist) + elif command == 'v.reclass': + cmdlist = [command, 'input=%s' % dlg.inmap, 'output=%s' % dlg.outmap, 'rules=%s' % gtemp, '--verbose'] + cmd.Command(cmdlist) else: cmdlist = [command, 'input=%s' % dlg.inmap, 'output=%s' % dlg.outmap, '--verbose'] + input = open(gtemp,"r") + p = subprocess.Popen(cmdlist, stdin=input, stdout=subprocess.PIPE) + input.close() - p1 = subprocess.Popen(['cat', gtemp], stdout=subprocess.PIPE) - p2 = subprocess.Popen(cmdlist, stdin=p1.stdout, stdout=subprocess.PIPE) - dlg.Destroy() def OnXTerm(self, event): @@ -385,33 +390,32 @@ # open next available xmon xmonlist = [] + gisbase = os.environ['GISBASE'] + + # make list of xmons that are not running cmdlist = ['d.mon', '-L'] p = cmd.Command(cmdlist) - output = p.module_stdout.read().split('\n') - for outline in output: outline = outline.strip() if outline.startswith('x') and 'not running' in outline: - # make list of xmons that are not running + xmonlist.append(outline[0:2]) + + # open available xmon xmon = xmonlist[0] - cmdlst = ['d.mon','start=%s' % xmon, '&'] - p = cmd.Command(cmdlst) + cmdlist = ['d.mon','start=%s' % xmon] + p = subprocess.Popen(cmdlist) # run the command - cmdlist = ['g.gisenv', 'get=GISDBASE'] - gisdbase = cmd.Command(cmdlist).module_stdout.read().strip() - print 'gisbase=',gisbase - if os.environ['mingw'] == '1': - cmdlist ['cmd.exe', '/c', 'start', os.path.join(gisdbase,'etc','grass-run.bat'), command] + if 'OS' in os.environ and os.environ['OS'] == "Windows_NT": + cmdlist = ['cmd.exe', '/c', 'start', os.path.join(gisbase,'etc','grass-run.bat'), command] else: - cmdlist [os.path.join(gisdbase,'etc','grass-xterm-wrapper'), '-name', 'xterm-grass', '-e', os.path.join(gisdbase,'etc','grass-run.sh'), command, '&'] - print 'cmdlist =',cmdlist - p = cmd.Command(cmdlist) + cmdlist = [os.path.join(gisbase,'etc','grass-xterm-wrapper'), '-name', 'xterm-grass', '-e', os.path.join(gisbase,'etc','grass-run.sh'), command] + cmd.Command(cmdlist) # reset display mode - os.environ['GRASS_RENDER_IMMEDIATE'] = True + os.environ['GRASS_RENDER_IMMEDIATE'] = 'TRUE' def DefaultFont(self, event): """Set default font for GRASS displays""" From barton at grass.itc.it Tue Jun 12 08:19:57 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 12 08:20:00 2007 Subject: [grass-addons] r827 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200706120619.l5C6Jvr3031212@grass.itc.it> Author: barton Date: 2007-06-12 08:19:20 +0200 (Tue, 12 Jun 2007) New Revision: 827 Modified: trunk/grassaddons/gui/gui_modules/cmd.py trunk/grassaddons/gui/gui_modules/dbm.py trunk/grassaddons/gui/gui_modules/defaultfont.py trunk/grassaddons/gui/gui_modules/disp_print.py trunk/grassaddons/gui/gui_modules/histogram.py trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/menudata.py trunk/grassaddons/gui/gui_modules/render.py trunk/grassaddons/gui/gui_modules/rules.py trunk/grassaddons/gui/gui_modules/toolbars.py trunk/grassaddons/gui/gui_modules/utils.py trunk/grassaddons/gui/gui_modules/wxgui_utils.py trunk/grassaddons/gui/wxgui.py Log: Update module headers for classes, authorship, copyright information, etc. Modified: trunk/grassaddons/gui/gui_modules/cmd.py =================================================================== --- trunk/grassaddons/gui/gui_modules/cmd.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/cmd.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,8 +1,12 @@ """ PACKAGE: cmd -PURPOSE: Command interface +CLASSES: + * EndOfCommand + * Command +PURPOSE: Command interface + AUTHORS: The GRASS Development Team Original author: Jachym Cepicky Martin Landa @@ -46,7 +50,7 @@ verbose - verbose mode (GRASS commands '--v') wait - wait for childer execution dlgMsg - type of error message (None, gui, txt) [only if wait=True] - + Usage: cmd = Command(cmd=['d.rast', 'elevation.dem'], verbose=True, wait=True) @@ -56,7 +60,7 @@ print 'SUCCESS' else: print 'FAILURE (%d)' % cmd.returncode - + for msg in cmd.module_msg: if msg[0] == 'GRASS_INFO_PERCENT': print 'Percent done: %d' % (int(msg[1])) @@ -69,7 +73,7 @@ self.cmd = cmd self.module = None - + # output self.module_stderr = None self.module_msg = [] # list of messages (msgtype, content) @@ -94,7 +98,7 @@ if stdin: self.module_stdin.write(stdin) self.module_stdin.close() - + os.environ["GRASS_MESSAGE_FORMAT"] = "text" try: @@ -122,7 +126,7 @@ else: # otherwise 'txt' print >> sys.stderr, _("Execution failed: '%s'") % self.cmd - + else: self.returncode = None @@ -140,14 +144,14 @@ while 1: line = self.module_stderr.readline() if not line or line.find("GRASS_INFO_END") > -1: - raise EndOfCommand + raise EndOfCommand if line.find(':') > -1: msgtype, content = line.split(":", 1) if verbose: self.module_msg.append((msgtype, content.strip())) else: # write only fatal errors and warnigs if msgtype.find("GRASS_INFO_ERROR") > -1 or \ - msgtype.find("GRASS_INFO_WARNING") > -1: + msgtype.find("GRASS_INFO_WARNING") > -1: self.module_msg.append((msgtype, content.strip())) return @@ -167,13 +171,13 @@ print "SUCCESS" else: print "FAILURE (%d)" % cmd.returncode - + for msg in cmd.module_msg: if msg[0] == "GRASS_INFO_PERCENT": print "Percent done: %d" % (int(msg[1])) else: print "General message:", msg[1] - + # v.net.path silently, wait for process termination print "Running v.net.path for 0 593527.6875 4925297.0625 602083.875 4917545.8125..." Modified: trunk/grassaddons/gui/gui_modules/dbm.py =================================================================== --- trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,9 +1,14 @@ """ MODULE: dbm.py +CLASSES: + * Log + * VirtualAttributeList + * AttributeManager + PURPOSE: GRASS attribute table manager - This program is based on FileHunter, publicated in 'The wxPython Linux + This program is based on FileHunter, published in 'The wxPython Linux Tutorial' on wxPython WIKI pages. It also uses some functions at @@ -94,10 +99,10 @@ i = 0 # FIXME: Maximal number of columns, when the GUI is still usable dbDescribe = cmd.Command (cmd = ["db.describe", "-c", - "table=%s" % self.parent.tablename, - "driver=%s" % self.parent.driver, - "database=%s" % self.parent.database]) - + "table=%s" % self.parent.tablename, + "driver=%s" % self.parent.driver, + "database=%s" % self.parent.database]) + for line in dbDescribe.module_stdout.readlines()[1:]: x,column,type,length = line.strip().split(":") # FIXME: here will be more types @@ -158,20 +163,20 @@ # prepare command string cmdv = ["db.select", "-c", - "table=%s" % self.parent.tablename, - "database=%s" % self.parent.database, - "driver=%s" % self.parent.driver] + "table=%s" % self.parent.tablename, + "database=%s" % self.parent.database, + "driver=%s" % self.parent.driver] if where: self.ClearAll() cmdv = ["db.select", "-c", - "sql=SELECT * FROM %s WHERE %s" % (self.parent.tablename, where), - "database=%s" % self.parent.database, - "driver=%s" % self.parent.driver] + "sql=SELECT * FROM %s WHERE %s" % (self.parent.tablename, where), + "database=%s" % self.parent.database, + "driver=%s" % self.parent.driver] # run command vDbSelect = cmd.Command (cmd=cmdv) - + # FIXME: Max. number of rows, while the GUI is still usable i = 0 # read data @@ -479,7 +484,7 @@ class AttributeManager(wx.Frame): """ The main window - + This is where you populate the frame with a panel from the demo. original line in runTest (in the demo source): win = TestPanel(nb, log) @@ -509,7 +514,7 @@ wx.Frame.__init__(self, parent, id, title, size=size, style=style) self.CreateStatusBar(1) - + self.vectmap = vectmap self.parent = parent self.gismgr = parent @@ -523,7 +528,7 @@ self.btn_apply = wx.Button(self, -1, "Apply") # self.btn_unselect = wx.Button(self, -1, "Unselect") self.btn_sqlbuilder = wx.Button(self, -1, "SQL Builder") - + # check # self.check_add_to_selection = wx.CheckBox(self, -1, "Add to selection") @@ -533,15 +538,15 @@ # label self.sqlabel=wx.StaticText(self,-1,"SELECT * FROM %s WHERE " % self.tablename) self.label_query = wx.StaticText(self,-1,"") - + # box self.sqlbox = wx.StaticBox(self, -1, "SQL Query:") - + self.btn_sqlbuilder.Bind(wx.EVT_BUTTON, self.OnBuilder) - + self.__layout() self.Show() - + def OnBuilder(self,event): import sqlbuilder self.builder = sqlbuilder.SQLFrame(self,-1,"SQL Builder",self.vectmap) Modified: trunk/grassaddons/gui/gui_modules/defaultfont.py =================================================================== --- trunk/grassaddons/gui/gui_modules/defaultfont.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/defaultfont.py 2007-06-12 06:19:20 UTC (rev 827) @@ -7,6 +7,7 @@ PURPOSE: Sets default display font AUTHORS: The GRASS Development Team + Michael Barton (Arizona State University) COPYRIGHT: (C) 2007 by the GRASS Development Team This program is free software under the GNU General Public Modified: trunk/grassaddons/gui/gui_modules/disp_print.py =================================================================== --- trunk/grassaddons/gui/gui_modules/disp_print.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/disp_print.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,17 +1,28 @@ +""" +MODULE: disp_print.py + +CLASSES: + * MapPrint + * PrintOptions + +PURPOSE: Print context and utility functions for printing + contents of map display window. + +AUTHORS: The GRASS Development Team + Michael Barton (Arizona State University) + Based on generic example code from wxPython + demo program by Robin Dunn + +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. + +""" + import wx -# Based on wxPython demo -# This is the header from the main.py wxPython calling program -# -# Author: Robin Dunn -# -# Created: A long time ago, in a galaxy far, far away... -# RCS-ID: $Id: Main.py,v 1.213 2007/01/17 23:39:00 RD Exp $ -# Copyright: (c) 1999 by Total Control Software -# Licence: wxWindows license -#---------------------------------------------------------------------- - class MapPrint(wx.Printout): def __init__(self, canvas): wx.Printout.__init__(self) Modified: trunk/grassaddons/gui/gui_modules/histogram.py =================================================================== --- trunk/grassaddons/gui/gui_modules/histogram.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/histogram.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,6 +1,10 @@ """ MODULE: histogram +CLASSES: + * BufferedWindow + * HistFrame + PURPOSE: Plotting histogram AUTHORS: The GRASS Development Team @@ -399,12 +403,12 @@ for item in cmd: if 'map=' in item: self.mapname = item.split('=')[1] - + self.layer = self.Map.ChangeLayer(layer=self.layer, type="command", name='', command=cmd, l_active=True, l_hidden=False, l_opacity=1, l_render=False) return self.layer - + def SetHistFont(self, event): """ Set font for histogram. If not Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,8 +1,19 @@ """ -MODULE: mapdisp +MODULE: mapdisp.py -PURPOSE: To be used either from GIS Manager or as p.mon backend +CLASSES: + * Command + * BufferedWindow + * MapFrame + * DecDialog + * TextDialog + * SavedRegion + * MapApp +PURPOSE: GIS map display canvas, with toolbar for various display + management functions, and second toolbar for vector + digitizing. Can be used either from GIS Manager or as p.mon backend + Usage: python mapdisp.py monitor-identifier /path/to/command/file @@ -136,7 +147,7 @@ self.polycoords = [] # List of wx.Point tuples defining a polyline self.lineid = None # ID of rubber band line # ID of poly line resulting from cumulative rubber band lines (e.g. measurement) - self.plineid = None + self.plineid = None # # Event bindings @@ -679,7 +690,7 @@ _("Error"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() - + if map: if digit.type in ["point", "centroid"]: # add new point @@ -689,7 +700,7 @@ Digit.AddPoint(map=map, type=digit.type, x=east, y=north) - + self.render=True self.UpdateMap() # redraw map @@ -698,7 +709,7 @@ self.polycoords.append(event.GetPositionTuple()[:]) self.mouse['begin'] = self.polycoords[-1] self.DrawLines() - + else: # get decoration id self.lastpos = self.mouse['begin'] = event.GetPositionTuple()[:] @@ -732,7 +743,7 @@ self.parent.QueryMap(self.mouse['begin'][0],self.mouse['begin'][1]) elif self.mouse["use"] in ["measure", "profile"]: - # measure or profile + # measure or profile self.mouse['end'] = event.GetPositionTuple()[:] if self.mouse["use"] == "measure": self.parent.MeasureDist(self.mouse['begin'], self.mouse['end']) @@ -841,7 +852,7 @@ map = digit.layers[digit.layerSelectedID].name except: map = None - dlg = wx.MessageDialog(self, _("No vector map layer is selected"), + dlg = wx.MessageDialog(self, _("No vector map layer is selected"), _("Error"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() @@ -856,7 +867,7 @@ Digit.AddLine(map=map, type=self.parent.digittoolbar.type, coords=mapcoords) - + # clean up saved positions self.polycoords = [] @@ -1256,7 +1267,7 @@ self.totaldist = 0.0 # total length measured # initialize buffered DC ## self.MapWindow = DrawWindow(self) - self.MapWindow = BufferedWindow(self, id = wx.ID_ANY, Map=self.Map, tree=self.tree) + self.MapWindow = BufferedWindow(self, id = wx.ID_ANY, Map=self.Map, tree=self.tree) self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion) self.MapWindow.SetCursor(self.cursors["default"]) # default @@ -1272,9 +1283,9 @@ self.ovlchk = self.MapWindow.ovlchk self.ovlcoords = self.MapWindow.ovlcoords # previously set decoration options parameters to insert into options dialog - self.params = {} + self.params = {} # ID of properties window open for overlay, indexed by overlay ID - self.propwin = {} + self.propwin = {} # # Bind various events Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,3 +1,22 @@ +""" +MODULE: menudata.py + +CLASSES: + * Data + +PURPOSE: Complex list for main menu entries for GRASS wxPython GUI. + +AUTHORS: The GRASS Development Team + Michael Barton (Arizona State University) + Yann Chemin + +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. + +""" + import os class Data: Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,6 +1,10 @@ """ MODULE: render +CLASSES: + * MapLayer + * Map + PURPOSE: Rendering AUTHORS: The GRASS Development Team Modified: trunk/grassaddons/gui/gui_modules/rules.py =================================================================== --- trunk/grassaddons/gui/gui_modules/rules.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/rules.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,3 +1,22 @@ +""" +MODULE: rules.py + +CLASSES: + * RulesText + +PURPOSE: Dialog for interactive entry of rules for r.colors, + r.reclass, r.recode, and v.reclass + +AUTHORS: The GRASS Development Team + Michael Barton (Arizona State University) + +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. + +""" + import wx import os import sys @@ -20,7 +39,6 @@ self.outmap = '' # output map for reclass/recode self.rules = '' # rules for changing - if self.cmd == 'r.colors': label1 = 'Create new color table using color rules' label2 = 'Raster map:' Modified: trunk/grassaddons/gui/gui_modules/toolbars.py =================================================================== --- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,6 +1,12 @@ """ MODULE: toolbar + +CLASSES: + * AbstractToolbar + * MapToolbar + * DigitToolbar + PURPOSE: Toolbars for Map Display window AUTHORS: The GRASS Development Team @@ -42,7 +48,7 @@ def CreateTool(self, parent, toolbar, tool, label, bitmap, kind, shortHelp, longHelp, handler): """Add tool to the toolbar""" - + bmpDisabled=wx.NullBitmap if label: @@ -98,7 +104,7 @@ (self.erase, "erase", Icons["erase"].GetBitmap(), wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(), self.mapdisplay.OnErase), - ("", "", "", "", "", "", ""), + ("", "", "", "", "", "", ""), (self.pointer, "pointer", Icons["pointer"].GetBitmap(), wx.ITEM_RADIO, Icons["pointer"].GetLabel(), Icons["pointer"].GetDesc(), self.mapdisplay.Pointer), @@ -107,7 +113,7 @@ self.mapdisplay.OnQuery), (self.pan, "pan", Icons["pan"].GetBitmap(), wx.ITEM_RADIO, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(), - self.mapdisplay.OnPan), + self.mapdisplay.OnPan), (self.zoomin, "zoom_in", Icons["zoom_in"].GetBitmap(), wx.ITEM_RADIO, Icons["zoom_in"].GetLabel(), Icons["zoom_in"].GetDesc(), self.mapdisplay.OnZoomIn), @@ -280,7 +286,7 @@ """ # stop editing of the currently selected map layer self.StopEditing() - + # disable the toolbar self.parent.RemoveToolbar ("digit") @@ -307,7 +313,7 @@ def OnDisplayCats(self, event): pass - + def OnDisplayAttr(self, event): pass @@ -358,11 +364,11 @@ self.layers[self.layerSelectedID].name) else: Debug.msg (4, "DigitToolbar.StopEditing(): layer=None") - + self.layerSelectedID = None self.combo.SetValue ('Select vector map') # TODO - + def UpdateListOfLayers (self, updateTool=False): """ Update list of available vector map layers. Modified: trunk/grassaddons/gui/gui_modules/utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/utils.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/utils.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,3 +1,18 @@ +""" +MODULE: utils.py + +CLASSES: + * GetTempfile + +PURPOSE: Misc utilities for GRASS wxPython GUI + +AUTHORS: The GRASS Development Team + +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. +""" import os def GetTempfile( pref=None): @@ -8,7 +23,7 @@ Path to file name (string) or None """ - tempfile = os.popen("g.tempfile pid=%d" % + tempfile = os.popen("g.tempfile pid=%d" % os.getpid()).readlines()[0].strip() if not tempfile: Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,3 +1,27 @@ +""" +MODULE: wxgui_utils.py + +CLASSES: + * AbstractLayer + * Layer + * LayerTree + * GMConsole + +PURPOSE: Utility classes for GRASS wxPython GUI. Main functions include tree control + for GIS map layer management, command console, and command parsing. + +AUTHORS: The GRASS Development Team + Michael Barton (Arizona State University) & + Jachym Cepicky (Mendel University of Agriculture) + Martin Landa + +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. + +""" + import os,sys import wx import wx.lib.customtreectrl as CT Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-12 05:47:02 UTC (rev 826) +++ trunk/grassaddons/gui/wxgui.py 2007-06-12 06:19:20 UTC (rev 827) @@ -1,22 +1,27 @@ -#!/usr/bin/env python +#!/usr/bin python """ -MODULE: wxgui.py +MODULE: wxgui.py -PURPOSE: Main Python app to set up GIS Manager window and trap commands - Only command console is working currently, but windows for - panels and layer tree done and demo tree items appear +CLASSES: + * GRasterDialog + * GMFrame + * GMApp -AUTHORS: The GRASS Development Team - Michael Barton (Arizona State University) & - Jachym Cepicky (Mendel University of Agriculture) - Martin Landa +PURPOSE: Main Python app for GRASS wxPython GUI. Main menu, layer management + toolbar, notebook control for display management and access to + command console. -COPYRIGHT: (C) 2006-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. +AUTHORS: The GRASS Development Team + Michael Barton (Arizona State University) & + Jachym Cepicky (Mendel University of Agriculture) + Martin Landa +COPYRIGHT: (C) 2006-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. + """ import sys From barton at grass.itc.it Tue Jun 12 08:38:26 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 12 08:38:27 2007 Subject: [grass-addons] r828 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200706120638.l5C6cQYK031298@grass.itc.it> Author: barton Date: 2007-06-12 08:38:14 +0200 (Tue, 12 Jun 2007) New Revision: 828 Modified: trunk/grassaddons/gui/gui_modules/rules.py trunk/grassaddons/gui/wxgui.py Log: Add overwrite option for interactive reclassify and recode. Modified: trunk/grassaddons/gui/gui_modules/rules.py =================================================================== --- trunk/grassaddons/gui/gui_modules/rules.py 2007-06-12 06:19:20 UTC (rev 827) +++ trunk/grassaddons/gui/gui_modules/rules.py 2007-06-12 06:38:14 UTC (rev 828) @@ -38,6 +38,7 @@ self.inmap = '' # input map to change self.outmap = '' # output map for reclass/recode self.rules = '' # rules for changing + self.overwrite = False if self.cmd == 'r.colors': label1 = 'Create new color table using color rules' @@ -96,6 +97,16 @@ wx.ALIGN_RIGHT| wx.ALL,border=5) + box = wx.BoxSizer(wx.HORIZONTAL) + self.ovrwrtcheck = wx.CheckBox(self, wx.ID_ANY, 'overwrite existing file') + self.ovrwrtcheck.SetValue(self.overwrite) + box.Add(self.ovrwrtcheck, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + sizer.Add(item=box, proportion=0, + flag=wx.ALIGN_CENTER_VERTICAL| + wx.ALIGN_RIGHT| + wx.ALL,border=5) + self.Bind(wx.EVT_CHECKBOX, self.OnOverwrite, self.ovrwrtcheck) + box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, wx.ID_ANY, label4) box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) @@ -151,3 +162,5 @@ def OnHelp(self, event): os.popen('g.manual --quiet %s ' % self.cmd) + def OnOverwrite(self, event): + self.overwrite = event.IsChecked() Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-12 06:19:20 UTC (rev 827) +++ trunk/grassaddons/gui/wxgui.py 2007-06-12 06:38:14 UTC (rev 828) @@ -370,14 +370,19 @@ output = open(gtemp,"w") output.write(dlg.rules) output.close() + if dlg.overwrite == True: + overwrite = '--o' + else: + overwrite -= '' + if command == 'r.colors': - cmdlist = [command, 'map=%s' % dlg.inmap, 'rules=%s' % gtemp, '--verbose'] + cmdlist = [command,'map=%s' % dlg.inmap,'rules=%s' % gtemp,'--verbose'] cmd.Command(cmdlist) elif command == 'v.reclass': - cmdlist = [command, 'input=%s' % dlg.inmap, 'output=%s' % dlg.outmap, 'rules=%s' % gtemp, '--verbose'] + cmdlist = [command,'input=%s' % dlg.inmap,'output=%s' % dlg.outmap,'rules=%s' % gtemp,overwrite,'--verbose'] cmd.Command(cmdlist) else: - cmdlist = [command, 'input=%s' % dlg.inmap, 'output=%s' % dlg.outmap, '--verbose'] + cmdlist = [command,'input=%s' % dlg.inmap,'output=%s' % dlg.outmap,overwrite,'--verbose'] input = open(gtemp,"r") p = subprocess.Popen(cmdlist, stdin=input, stdout=subprocess.PIPE) input.close() From barton at grass.itc.it Tue Jun 12 08:53:49 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 12 08:53:51 2007 Subject: [grass-addons] r829 - trunk/grassaddons/gui/gui_modules Message-ID: <200706120653.l5C6rnNq031360@grass.itc.it> Author: barton Date: 2007-06-12 08:53:39 +0200 (Tue, 12 Jun 2007) New Revision: 829 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Menu update. Reduce all menu nesting to max of 2 levels. Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-12 06:38:14 UTC (rev 828) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-12 06:53:39 UTC (rev 829) @@ -25,81 +25,76 @@ def GetMenu(self): return [( ("Files", ( - ("Import", ( - ("Raster map", ( - ("Multiple formats using GDAL", "Import multiple formats using GDAL", "self.OnMenuCmd", "r.in.gdal"), - ("","","", ""), - ("Aggregate ASCII xyz", "Import aggregate ASCII xyz data", "self.OnMenuCmd", "r.in.xyz"), - ("ASCII grid", "Import ASCII GRID (includes GRASS ASCII)", "self.OnMenuCmd", "r.in.ascii"), - ("ASCII polygons and lines", "Import Polygons and lines from ASCII file", "self.OnMenuCmd", "r.in.poly"), - ("","","", ""), - ("Binary", "Import binary file (includes GTOPO30 format)", "self.OnMenuCmd", "r.in.bin"), - ("ESRI Arc/Info ASCII grid", "Import ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.in.arc"), - ("GRIDATB.FOR", "Import GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.in.gridatb"), - ("MAT-File (v.4)", "Import MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.in.mat"), - ("SPOT NDVI", "Import SPOT vegetation NDVI data sets", "self.OnMenuCmd", "r.in.spotvgt"), - ("SRTM HGT", "Import SRTM hgt files", "self.OnMenuCmd", "r.in.srtm"), - ("Terra ASTER HDF", "Import Terra ASTER HDF files", "self.OnMenuCmd", "r.in.aster"), - ("","","", ""), - ("WMS", "Import Web Mapping Server", "self.OnMenuCmd", "r.in.wms"), - )), - ("Vector map", ( - ("Multiple formats using OGR", "Import multiple formats using OGR", "self.OnMenuCmd", "v.in.ogr"), - ("","","", ""), - ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.in.ascii"), - ("Old GRASS vector", "Import old GRASS vector format", "self.OnMenuCmd", "v.convert"), - ("","","", ""), - ("DXF", "Import DXF file", "self.OnMenuCmd", "v.in.dxf"), - ("ESRI e00", "Import ESRI e00 file", "self.OnMenuCmd", "v.in.e00"), - ("Garmin GPS", "Import Garmin GPS Waypoints/Routes/Tracks", "self.OnMenuCmd", "v.in.garmin"), - ("GPSBabel GPS", "Import GPS Waypoints/Routes/Tracks using GPSBabel", "self.OnMenuCmd", "v.in.gpsbabel"), - ("GEOnet", "Import GEOnet Name server country files (US-NGA GNS)", "self.OnMenuCmd", "v.in.gns"), - ("Matlab and MapGen", "Import Matlab and MapGen files", "self.OnMenuCmd", "v.in.mapgen"), - )), - - ("Grid 3D", ( - ("ASCII 3D", "Import ASCII 3D file", "self.OnMenuCmd", "r3.in.ascii"), - ("Vis5D", "Import Vis5D file", "self.OnMenuCmd", "r3.in.v5d"), - )), + ("Import raster map", ( + ("Multiple formats using GDAL", "Import multiple formats using GDAL", "self.OnMenuCmd", "r.in.gdal"), + ("","","", ""), + ("Aggregate ASCII xyz", "Import aggregate ASCII xyz data", "self.OnMenuCmd", "r.in.xyz"), + ("ASCII grid", "Import ASCII GRID (includes GRASS ASCII)", "self.OnMenuCmd", "r.in.ascii"), + ("ASCII polygons and lines", "Import Polygons and lines from ASCII file", "self.OnMenuCmd", "r.in.poly"), + ("","","", ""), + ("Binary", "Import binary file (includes GTOPO30 format)", "self.OnMenuCmd", "r.in.bin"), + ("ESRI Arc/Info ASCII grid", "Import ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.in.arc"), + ("GRIDATB.FOR", "Import GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.in.gridatb"), + ("MAT-File (v.4)", "Import MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.in.mat"), + ("SPOT NDVI", "Import SPOT vegetation NDVI data sets", "self.OnMenuCmd", "r.in.spotvgt"), + ("SRTM HGT", "Import SRTM hgt files", "self.OnMenuCmd", "r.in.srtm"), + ("Terra ASTER HDF", "Import Terra ASTER HDF files", "self.OnMenuCmd", "r.in.aster"), + ("","","", ""), + ("WMS", "Import Web Mapping Server", "self.OnMenuCmd", "r.in.wms"), )), - ("Export", ( - ("Raster map", ( - ("Multiple formats using GDAL", "Export multiple formats using GDAL", "self.OnMenuCmd", "r.out.gdal"), - ("","","", ""), - ("ASCII grid", "Export ASCII grid (for GRASS, Surfer, Modflow, etc)", "self.OnMenuCmd", "r.out.ascii"), - ("ASCII x,y,z", "Export ASCII x,y,z values of cell centers", "self.OnMenuCmd", "r.out.xyz"), - ("","","", ""), - ("ESRI ASCII grid", "Export ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.out.arc"), - ("GRIDATB.FOR", "Export GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.out.gridatb"), - ("MAT-File (v.4)", "Export MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.out.mat"), - ("","","", ""), - ("Binary", "Export binary file", "self.OnMenuCmd", "r.out.bin"), - ("","","", ""), - ("MPEG-1", "Export MPEG-1 animations", "self.OnMenuCmd", "r.out.mpeg"), - ("PNG", "Export PNG image (not georeferenced)", "self.OnMenuCmd", "r.out.png"), - ("PPM", "Export PPM image (24bit)", "self.OnMenuCmd", "r.out.ppm"), - ("POV-Ray", "Export POVray height-field", "self.OnMenuCmd", "r.out.pov"), - ("TIFF", "Export TIFF image (8/24bit)", "self.OnMenuCmd", "r.out.tiff"), - ("VRML", "Export VRML file", "self.OnMenuCmd", "r.out.vrml"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r.out.vtk"), - )), - ("Vector map", ( - ("Multiple formats using OGR", "Export multiple formats using OGR", "self.OnMenuCmd", "v.out.ogr"), - ("","","", ""), - ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.out.ascii"), + ("Import vector map", ( + ("Multiple formats using OGR", "Import multiple formats using OGR", "self.OnMenuCmd", "v.in.ogr"), + ("","","", ""), + ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.in.ascii"), + ("Old GRASS vector", "Import old GRASS vector format", "self.OnMenuCmd", "v.convert"), + ("","","", ""), + ("DXF", "Import DXF file", "self.OnMenuCmd", "v.in.dxf"), + ("ESRI e00", "Import ESRI e00 file", "self.OnMenuCmd", "v.in.e00"), + ("Garmin GPS", "Import Garmin GPS Waypoints/Routes/Tracks", "self.OnMenuCmd", "v.in.garmin"), + ("GPSBabel GPS", "Import GPS Waypoints/Routes/Tracks using GPSBabel", "self.OnMenuCmd", "v.in.gpsbabel"), + ("GEOnet", "Import GEOnet Name server country files (US-NGA GNS)", "self.OnMenuCmd", "v.in.gns"), + ("Matlab and MapGen", "Import Matlab and MapGen files", "self.OnMenuCmd", "v.in.mapgen"), + )), + ("Import grid 3D volume", ( + ("ASCII 3D", "Import ASCII 3D file", "self.OnMenuCmd", "r3.in.ascii"), + ("Vis5D", "Import Vis5D file", "self.OnMenuCmd", "r3.in.v5d"), + )), + ("","","", ""), + ("Export raster map", ( + ("Multiple formats using GDAL", "Export multiple formats using GDAL", "self.OnMenuCmd", "r.out.gdal"), + ("","","", ""), + ("ASCII grid", "Export ASCII grid (for GRASS, Surfer, Modflow, etc)", "self.OnMenuCmd", "r.out.ascii"), + ("ASCII x,y,z", "Export ASCII x,y,z values of cell centers", "self.OnMenuCmd", "r.out.xyz"), + ("","","", ""), + ("ESRI ASCII grid", "Export ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.out.arc"), + ("GRIDATB.FOR", "Export GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.out.gridatb"), + ("MAT-File (v.4)", "Export MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.out.mat"), + ("","","", ""), + ("Binary", "Export binary file", "self.OnMenuCmd", "r.out.bin"), + ("","","", ""), + ("MPEG-1", "Export MPEG-1 animations", "self.OnMenuCmd", "r.out.mpeg"), + ("PNG", "Export PNG image (not georeferenced)", "self.OnMenuCmd", "r.out.png"), + ("PPM", "Export PPM image (24bit)", "self.OnMenuCmd", "r.out.ppm"), + ("POV-Ray", "Export POVray height-field", "self.OnMenuCmd", "r.out.pov"), + ("TIFF", "Export TIFF image (8/24bit)", "self.OnMenuCmd", "r.out.tiff"), + ("VRML", "Export VRML file", "self.OnMenuCmd", "r.out.vrml"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r.out.vtk"), + )), + ("Export vector map", ( + ("Multiple formats using OGR", "Export multiple formats using OGR", "self.OnMenuCmd", "v.out.ogr"), + ("","","", ""), + ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.out.ascii"), - ("DXF", "Export DXF file", "self.OnMenuCmd", "v.out.dxf"), - ("POV-Ray", "Export POV-Ray format file", "self.OnMenuCmd", "v.out.pov"), - ("SVG", "Export SVG file", "self.OnMenuCmd", "v.out.svg"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "v.out.vtk"), - )), - - ("Grid 3D", ( - ("ASCII 3D", "Export ASCII 3D file", "self.OnMenuCmd", "r3.out.ascii"), - ("Vis5D", "Export Vis5D file", "self.OnMenuCmd", "r3.out.v5d"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r3.out.vtk"), - )), + ("DXF", "Export DXF file", "self.OnMenuCmd", "v.out.dxf"), + ("POV-Ray", "Export POV-Ray format file", "self.OnMenuCmd", "v.out.pov"), + ("SVG", "Export SVG file", "self.OnMenuCmd", "v.out.svg"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "v.out.vtk"), )), + ("Export grid 3D volume", ( + ("ASCII 3D", "Export ASCII 3D file", "self.OnMenuCmd", "r3.out.ascii"), + ("Vis5D", "Export Vis5D file", "self.OnMenuCmd", "r3.out.v5d"), + ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r3.out.vtk"), + )), ("","","", ""), ("Manage maps and volumes", ( ("Copy", "Copy maps within mapsets or between mapsets", "self.OnMenuCmd", "g.copy"), @@ -156,16 +151,17 @@ ("Digitize raster (requires XTerm)", "Digitize raster", "self.OnXTerm", "r.digit"), ("","","", ""), ("Compress/decompress", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), + ("","","", ""), ("Boundaries", "Manage boundary definition", "self.OnMenuCmd", "r.region"), ("Null values", "Manage null values", "self.OnMenuCmd", "r.null"), ("Timestamp", "Manage timestamp for files", "self.OnMenuCmd", "r.timestamp"), ("Quantization", "Quantization for floating-point maps", "self.OnMenuCmd", "r.quant"), - ("Resample (change resolution)", ( - ("Aggregate statistics", "Resample using aggregate statistics", "self.OnMenuCmd", "r.resamp.stats"), - ("Multiple methods", "Resample select nearest neighbor, bilinear, or bicubic interpolation", "self.OnMenuCmd", "r.resamp.interp"), - ("Nearest neighbor", "Resample using nearest neighbor interpolation", "self.OnMenuCmd", "r.resample"), - ("Regularized spline tension", "Resample using regularized spline tension", "self.OnMenuCmd", "r.resamp.rst"), - )), + ("","","", ""), + ("Resample using aggregate statistics", "Resample (change resolution) using aggregate statistics", "self.OnMenuCmd", "r.resamp.stats"), + ("Resample using multiple methods", "Resample (change resolution) using nearest neighbor, bilinear, or bicubic interpolation", "self.OnMenuCmd", "r.resamp.interp"), + ("Resample using nearest neighbor", "Resample (change resolution) using nearest neighbor interpolation", "self.OnMenuCmd", "r.resample"), + ("Resample using spline tension", "Resample (change resolution) using regularized spline tension", "self.OnMenuCmd", "r.resamp.rst"), + ("","","", ""), ("Support file maintenance", "Support file creation and maintenance", "self.OnMenuCmd", "r.support"), ("Update map statistics", "Update map statistics", "self.OnMenuCmd", "r.support.stats"), ("","","", ""), @@ -388,25 +384,23 @@ ("Reclassify vector using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), )), ("","","", ""), - ("Work with vector points", ( - ("Generate points", ( - ("Generate from database", "Generate points from database", "self.OnMenuCmd", "v.in.db"), - ("Generate random", "Generate random points", "self.OnMenuCmd", "v.random"), - ("Perturb points", "Random location perturbations of points", "self.OnMenuCmd", "v.perturb"), - )), - ("Generate areas from points", ( - ("Convex hull", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), - ("Delaunay triangles", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), - ("Voronoi diagram/Thiessen polygons", "Generate Voronoi diagram/Thiessen polygons for point set", "self.OnMenuCmd", "v.voronoi"), - )), - ("Sample raster maps", ( - ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.OnMenuCmd", "v.rast.stats"), - ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.OnMenuCmd", "v.what.rast"), - ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.OnMenuCmd", "v.sample"), - )), - ("Test/training sets", "Partition points into test/training sets for k-fold cross validation", "self.OnMenuCmd", "v.kcv"), - ("Update point attributes from areas", "Transfer attribute data from queried area map to points", "self.OnMenuCmd", "v.what.vect"), - )), + ("Generate points", ( + ("Generate from database", "Generate points from database", "self.OnMenuCmd", "v.in.db"), + ("Generate random", "Generate random points", "self.OnMenuCmd", "v.random"), + ("Perturb points", "Random location perturbations of points", "self.OnMenuCmd", "v.perturb"), + )), + ("Generate areas from points", ( + ("Convex hull", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), + ("Delaunay triangles", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), + ("Voronoi diagram/Thiessen polygons", "Generate Voronoi diagram/Thiessen polygons for point set", "self.OnMenuCmd", "v.voronoi"), + )), + ("Sample raster maps at point locations", ( + ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.OnMenuCmd", "v.rast.stats"), + ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.OnMenuCmd", "v.what.rast"), + ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.OnMenuCmd", "v.sample"), + )), + ("Test/training point sets", "Partition points into test/training sets for k-fold cross validation", "self.OnMenuCmd", "v.kcv"), + ("Update point attributes from areas", "Transfer attribute data from queried area map to points", "self.OnMenuCmd", "v.what.vect"), ("","","", ""), ("Reports and statistics", ( ("Basic information", "Basic information", "self.OnMenuCmd", "v.info"), From barton at grass.itc.it Tue Jun 12 09:35:16 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 12 09:35:17 2007 Subject: [grass-addons] r830 - trunk/grassaddons/gui/gui_modules Message-ID: <200706120735.l5C7ZGSU031672@grass.itc.it> Author: barton Date: 2007-06-12 09:35:06 +0200 (Tue, 12 Jun 2007) New Revision: 830 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Add menu entry for nviz Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-12 06:53:39 UTC (rev 829) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-12 07:35:06 UTC (rev 830) @@ -121,6 +121,8 @@ ("","","", ""), ("Georectify (not functional)", "Georectify raster and vector maps", "self.OnGeorectify", ""), ("","","", ""), + ("NViz (requires TclTk)", "N-Dimensional visualization of maps and volumes", "self.OnMenuCmd", "nviz"), + ("","","", ""), ("Bearing/distance to coordinates", "Convert between bearing/distance and coordinates", "self.OnMenuCmd", "m.cogo"), ("","","", ""), ("Postscript plot", "Create cartographic PostScript plot", "self.OnMenuCmd", "ps.map"), From maldacker at grass.itc.it Tue Jun 12 18:27:33 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Tue Jun 12 18:27:35 2007 Subject: [grass-addons] r831 - trunk/grassaddons/v.path.obstacles Message-ID: <200706121627.l5CGRXVn003760@grass.itc.it> Author: maldacker Date: 2007-06-12 18:27:31 +0200 (Tue, 12 Jun 2007) New Revision: 831 Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.c trunk/grassaddons/v.path.obstacles/visibility.c Log: change in the add_leftof and add_rightmost functions. Now it checks if there is already a left node or righmost son and behave appropriatly. Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.c =================================================================== --- trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-12 07:35:06 UTC (rev 830) +++ trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-12 16:27:31 UTC (rev 831) @@ -18,14 +18,50 @@ void add_rightmost(struct Point* p, struct Point* q) { - q->rightmost_son = p; + struct Point * right; + + p->left_brother = NULL; + p->right_brother = NULL; + + if ( q->rightmost_son == NULL ) + { + q->rightmost_son = p; + } + else + { + right = q->rightmost_son; + + right->right_brother = p; + p->left_brother = right; + + q->rightmost_son = p; + } + p->father = q; + + } void add_leftof(struct Point* p, struct Point* q) { - q->left_brother = p; - p->right_brother = q; + struct Point * left; + + if ( q->left_brother == NULL ) + { + p->left_brother = NULL; + q->left_brother = p; + p->right_brother = q; + } + else + { + left = q->left_brother; + p->left_brother = left; + left->right_brother = p; + p->right_brother = q; + q->left_brother = p; + } + + p->father = q->father; } @@ -46,8 +82,8 @@ p->father = NULL; p->left_brother = NULL; p->right_brother = NULL; - p->rightmost_son = NULL; - + /*p->rightmost_son = NULL;*/ + } struct Point* right_brother(struct Point* p) @@ -90,9 +126,9 @@ if ( e == NULL ) return 1; - double pq = p->x * q->x + p->y*q->y; - double pe1 = p->x * e->p1->x + p->y*e->p1->y; - double pe2 = p->x * e->p2->x + p->y*e->p2->y; + double pq = (p->x - q->x)*(p->x - q->x) + (p->y - q->y)*(p->y - q->y); + double pe1 = (p->x - e->p1->x)*(p->x - e->p1->x) + ( p->y - e->p1->y)*( p->y - e->p1->y) ; + double pe2 = (p->x - e->p2->x)*(p->x - e->p2->x) + (p->y - e->p2->y)*(p->y - e->p2->y); return ( pq < pe1 && pq < pe2 ); Modified: trunk/grassaddons/v.path.obstacles/visibility.c =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-12 07:35:06 UTC (rev 830) +++ trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-12 16:27:31 UTC (rev 831) @@ -100,22 +100,21 @@ int j; int current = 0; int null=0; - double x; + double y; for ( i = 0 ; i < num ; i++ ) { for ( j = 1 ; j < num/2 ; j++ ) { - if ( points[i].x < lines[j].p1->x && points[i].x < lines[j].p2->x ) + if ( points[i].y < lines[j].p1->y && points[i].y < lines[j].p2->y ) { - if ( lines[current].p1->x < lines[current].p2->x ) - x = lines[current].p1->x; + if ( lines[current].p1->y < lines[current].p2->y ) + y = lines[current].p1->y; else - x = lines[current].p2->x; + y = lines[current].p2->y; - - if ( lines[j].p1->x < x || lines[j].p2->x < x ) + if ( lines[j].p1->y < y || lines[j].p2->y < y ) { current = j; null =1; @@ -229,12 +228,9 @@ for ( i = 0; i < num_points ; i ++ ) { - if ( i != num_points-1 ) - add_leftof( &points[i], &points[i+1] ); - - add_rightmost( &points[i], p_ninfinity ); + add_rightmost( &points[i], p_ninfinity ); } - + push( &points[0] ); From cannata at grass.itc.it Tue Jun 12 18:41:55 2007 From: cannata at grass.itc.it (cannata@grass.itc.it) Date: Tue Jun 12 18:41:57 2007 Subject: [grass-addons] r832 - trunk/grassaddons/HydroFOSS/r.evapo.PM Message-ID: <200706121641.l5CGftqC003910@grass.itc.it> Author: cannata Date: 2007-06-12 18:41:54 +0200 (Tue, 12 Jun 2007) New Revision: 832 Modified: trunk/grassaddons/HydroFOSS/r.evapo.PM/main.c Log: updated to follow submitting rules Modified: trunk/grassaddons/HydroFOSS/r.evapo.PM/main.c =================================================================== --- trunk/grassaddons/HydroFOSS/r.evapo.PM/main.c 2007-06-12 16:27:31 UTC (rev 831) +++ trunk/grassaddons/HydroFOSS/r.evapo.PM/main.c 2007-06-12 16:41:54 UTC (rev 832) @@ -2,11 +2,13 @@ /* This file will not be overwritten */ #include +#include #include -#include +#include #include #include #include "local_proto.h" +#include int main(int argc, char *argv[]) @@ -28,9 +30,8 @@ DCELL d_EPo; int d_night; - - //mat_struct *mD, *mEo; - //RASTER_MAP_TYPE data_type; + + struct History history; struct GModule *module; struct Option *input_DEM, *input_T, *input_RH, *input_u2, *input_Rn, *input_hc, *output; struct Flag *flag1, *day, *zero; @@ -39,9 +40,7 @@ G_gisinit(argv[0]); module = G_define_module(); - module->description = - "Potontial Evapotranspiration Calculation " - "Penman-Monteith formulation"; + module->description = _("Potontial Evapotranspiration Calculation with hourly Penman-Monteith"); /* Define different options */ input_DEM = G_define_option(); @@ -49,49 +48,49 @@ input_DEM->type = TYPE_STRING; input_DEM->required = YES; input_DEM->gisprompt = "old,cell,raster"; - input_DEM->description = "Name of DEM raster map [m a.s.l.]"; + input_DEM->description = _("Name of DEM raster map [m a.s.l.]"); input_T = G_define_option(); input_T->key = "T"; input_T->type = TYPE_STRING; input_T->required = YES; input_T->gisprompt = "old,cell,raster"; - input_T->description = "Name of Temperature raster map [?C]"; + input_T->description = _("Name of Temperature raster map [?C]"); input_RH = G_define_option(); input_RH->key = "RU"; input_RH->type = TYPE_STRING; input_RH->required = YES; input_RH->gisprompt = "old,cell,raster"; - input_RH->description = "Name of Relative Umidity raster map [%]"; + input_RH->description = _("Name of Relative Umidity raster map [%]"); input_u2 = G_define_option(); input_u2->key = "WS"; input_u2->type = TYPE_STRING; input_u2->required = YES; input_u2->gisprompt = "old,cell,raster"; - input_u2->description = "Name of Wind Speed raster map [m/s]"; + input_u2->description = _("Name of Wind Speed raster map [m/s]"); input_Rn = G_define_option(); input_Rn->key = "NSR"; input_Rn->type = TYPE_STRING; input_Rn->required = YES; input_Rn->gisprompt = "old,cell,raster"; - input_Rn->description = "Name of Net Solar Radiation raster map [MJ/m2/h]"; + input_Rn->description = _("Name of Net Solar Radiation raster map [MJ/m2/h]"); input_hc = G_define_option(); input_hc->key = "Vh"; input_hc->type = TYPE_STRING; input_hc->required = YES; input_hc->gisprompt = "old,cell,raster"; - input_hc->description = "Name of crop height raster map [m]"; + input_hc->description = _("Name of crop height raster map [m]"); output = G_define_option() ; output->key = "EPo"; output->type = TYPE_STRING; output->required = YES; output->gisprompt = "new,cell,raster" ; - output->description= "Name of output Reference Potential Evapotranspiration layer [mm/h]"; + output->description= _("Name of output Reference Potential Evapotranspiration layer [mm/h]"); /* Define the different flags */ //flag1 = G_define_flag() ; @@ -100,14 +99,14 @@ zero = G_define_flag() ; zero->key = 'z' ; - zero->description = "set negative evapo to zero" ; + zero->description = _("set negative evapo to zero"); day = G_define_flag() ; day->key = 'n' ; - day->description = "night-time" ; + day->description = _("night-time"); if (G_parser(argc, argv)) - exit (-1); + exit(EXIT_FAILURE); /* get entered parameters */ T=input_T->answer; @@ -128,57 +127,57 @@ /* find maps in mapset */ mapset_T = G_find_cell2 (T, ""); if (mapset_T == NULL) - G_fatal_error ("cell file [%s] not found", T); + G_fatal_error (_("cell file [%s] not found"), T); mapset_RH = G_find_cell2 (RH, ""); if (mapset_RH == NULL) - G_fatal_error ("cell file [%s] not found", RH); + G_fatal_error (_("cell file [%s] not found"), RH); mapset_u2 = G_find_cell2 (u2, ""); if (mapset_u2 == NULL) - G_fatal_error ("cell file [%s] not found", u2); + G_fatal_error (_("cell file [%s] not found"), u2); mapset_Rn = G_find_cell2 (Rn, ""); if (mapset_Rn == NULL) - G_fatal_error ("cell file [%s] not found", Rn); + G_fatal_error (_("cell file [%s] not found"), Rn); mapset_DEM = G_find_cell2 (DEM, ""); if (mapset_DEM == NULL) - G_fatal_error ("cell file [%s] not found", DEM); + G_fatal_error (_("cell file [%s] not found"), DEM); mapset_hc = G_find_cell2 (hc, ""); if (mapset_hc == NULL) - G_fatal_error ("cell file [%s] not found", hc); + G_fatal_error (_("cell file [%s] not found"), hc); /* check legal output name */ if (G_legal_filename (EPo) < 0) - G_fatal_error ("[%s] is an illegal name", EPo); + G_fatal_error (_("[%s] is an illegal name"), EPo); /* determine the input map type (CELL/FCELL/DCELL) */ //data_type = G_raster_map_type(T, mapset); if ( (infd_T = G_open_cell_old (T, mapset_T)) < 0) - G_fatal_error ("Cannot open cell file [%s]", T); + G_fatal_error (_("Cannot open cell file [%s]"), T); if ( (infd_RH = G_open_cell_old (RH, mapset_RH)) < 0) - G_fatal_error ("Cannot open cell file [%s]",RH); + G_fatal_error (_("Cannot open cell file [%s]"),RH); if ( (infd_u2 = G_open_cell_old (u2, mapset_u2)) < 0) - G_fatal_error ("Cannot open cell file [%s]",u2); + G_fatal_error (_("Cannot open cell file [%s]"),u2); if ( (infd_Rn = G_open_cell_old (Rn, mapset_Rn)) < 0) - G_fatal_error ("Cannot open cell file [%s]",Rn); + G_fatal_error (_("Cannot open cell file [%s]"),Rn); if ( (infd_DEM = G_open_cell_old (DEM, mapset_DEM)) < 0) - G_fatal_error ("Cannot open cell file [%s]",DEM); + G_fatal_error (_("Cannot open cell file [%s]"),DEM); if ( (infd_hc = G_open_cell_old (hc, mapset_hc)) < 0) - G_fatal_error ("Cannot open cell file [%s]",hc); + G_fatal_error (_("Cannot open cell file [%s]"),hc); if (G_get_cellhd (T, mapset_T, &cellhd) < 0) - G_fatal_error ("Cannot read file header of [%s]", T); + G_fatal_error (_("Cannot read file header of [%s]"), T); if (G_get_cellhd (RH, mapset_RH, &cellhd) < 0) - G_fatal_error ("Cannot read file header of [%s]", RH); + G_fatal_error (_("Cannot read file header of [%s]"), RH); if (G_get_cellhd (u2, mapset_u2, &cellhd) < 0) - G_fatal_error ("Cannot read file header of [%s]", u2); + G_fatal_error (_("Cannot read file header of [%s]"), u2); if (G_get_cellhd (Rn, mapset_Rn, &cellhd) < 0) - G_fatal_error ("Cannot read file header of [%s]", Rn); + G_fatal_error (_("Cannot read file header of [%s]"), Rn); if (G_get_cellhd (DEM, mapset_DEM, &cellhd) < 0) - G_fatal_error ("Cannot read file header of [%s]", DEM); + G_fatal_error (_("Cannot read file header of [%s]"), DEM); if (G_get_cellhd (hc, mapset_hc, &cellhd) < 0) - G_fatal_error ("Cannot read file header of [%s]", hc); + G_fatal_error (_("Cannot read file header of [%s]"), hc); /* Allocate input buffer */ inrast_T = G_allocate_d_raster_buf(); @@ -194,24 +193,24 @@ outrast = G_allocate_d_raster_buf(); if ( (outfd = G_open_raster_new (EPo,DCELL_TYPE)) < 0) - G_fatal_error ("Could not open <%s>",T); + G_fatal_error (_("Could not open <%s>"),T); for (row = 0; row < nrows; row++) { /* read a line input maps into buffers*/ if (G_get_d_raster_row (infd_T, inrast_T, row) < 0) - G_fatal_error ("Could not read from <%s>",T); + G_fatal_error (_("Could not read from <%s>"),T); if (G_get_d_raster_row (infd_RH, inrast_RH, row) < 0) - G_fatal_error ("Could not read from <%s>",RH); + G_fatal_error (_("Could not read from <%s>"),RH); if (G_get_d_raster_row (infd_u2, inrast_u2, row) < 0) - G_fatal_error ("Could not read from <%s>",u2); + G_fatal_error (_("Could not read from <%s>"),u2); if (G_get_d_raster_row (infd_Rn, inrast_Rn, row) < 0) - G_fatal_error ("Could not read from <%s>",Rn); + G_fatal_error (_("Could not read from <%s>"),Rn); if (G_get_d_raster_row (infd_DEM, inrast_DEM, row) < 0) - G_fatal_error ("Could not read from <%s>",DEM); + G_fatal_error (_("Could not read from <%s>"),DEM); if (G_get_d_raster_row (infd_hc, inrast_hc, row) < 0) - G_fatal_error ("Could not read from <%s>",hc); + G_fatal_error (_("Could not read from <%s>"),hc); /* read every cell in the line buffers */ for (col=0; col < ncols; col++) @@ -240,7 +239,7 @@ } if (G_put_d_raster_row (outfd, outrast) < 0) - G_fatal_error ("Cannot write to <%s>",EPo); + G_fatal_error (_("Cannot write to <%s>"),EPo); } G_free(inrast_T); @@ -258,5 +257,10 @@ G_close_cell (infd_hc); G_close_cell (outfd); - return (0); + /* add command line incantation to history file */ + G_short_history(output, "raster", &history); + G_command_history(&history); + G_write_history(output, &history); + + exit(EXIT_SUCCESS); } From barton at grass.itc.it Wed Jun 13 03:38:31 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Jun 13 03:38:37 2007 Subject: [grass-addons] r833 - trunk/grassaddons/gui/gui_modules Message-ID: <200706130138.l5D1cVA6009751@grass.itc.it> Author: barton Date: 2007-06-13 03:37:52 +0200 (Wed, 13 Jun 2007) New Revision: 833 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Finished menu updating. Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-12 16:41:54 UTC (rev 832) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-13 01:37:52 UTC (rev 833) @@ -342,21 +342,24 @@ ("Convert 2D to 3D", "Convert 2D vector to 3D by sampling raster", "self.OnMenuCmd", "v.drape"), ("Extrude 3D", "Extrude 2D vector into 3D vector", "self.OnMenuCmd", "v.extrude"), ("","","", ""), + ("Link to OGR", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), + ("","","", ""), ("Create labels", "Create text label file for vector features", "self.OnMenuCmd", "v.label"), ("","","", ""), ("Reproject vector", "Reproject vector from other location", "self.OnMenuCmd", "v.proj"), ("","","", "") )), ("","","", ""), - ("vector<->database connections", ( - ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), - ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), - )), ("Query attributes", "Query by attributes", "self.OnMenuCmd", "v.extract"), ("Query coordinate(s)", "Query by coordinate(s)", "self.OnMenuCmd", "v.what"), ("Query map features", "Query by map features", "self.OnMenuCmd", "v.select"), ("","","", ""), ("Buffers", "Create vector buffers", "self.OnMenuCmd", "v.buffer"), + ("Lidar analysis", ( + ("Detect edges", "Detect object edges in Lidar data", "self.OnMenuCmd", "v.lidar.edgedetection"), + ("Detect interiors", "Detect interior of objects in Lidar data", "self.OnMenuCmd", "v.lidar.growing"), + ("Correct and reclassify objects", "Correct and reclassify objects detected in Lidar data", "self.OnMenuCmd", "v.lidar.correction"), + )), ("Linear referencing", ( ("Create LRS", "Create linear reference system", "self.OnMenuCmd", "v.lrs.create"), ("Create stationing", "Create stationing from input lines, and linear reference system", "self.OnMenuCmd", "v.lrs.label"), @@ -377,8 +380,6 @@ ("Overlay maps", "Overlay/combine 2 vector maps", "self.OnMenuCmd", "v.overlay"), ("Patch maps", "Patch multiple maps (combine)", "self.OnMenuCmd", "v.patch"), )), - ("Generate area for current region", "Generate area feature for extent of current region", "self.OnMenuCmd", "v.in.region"), - ("Generate grid", "Generate rectangular vector grid", "self.OnMenuCmd", "v.mkgrid"), ("","","", ""), ("Change attributes", ( ("Manage or report categories", "Attach/delete, or report categories", "self.OnMenuCmd", "v.category"), @@ -386,16 +387,18 @@ ("Reclassify vector using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), )), ("","","", ""), + ("Generate area for current region", "Generate area feature for extent of current region", "self.OnMenuCmd", "v.in.region"), + ("Generate areas from points", ( + ("Convex hull", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), + ("Delaunay triangles", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), + ("Voronoi diagram/Thiessen polygons", "Generate Voronoi diagram/Thiessen polygons for point set", "self.OnMenuCmd", "v.voronoi"), + )), + ("Generate grid", "Generate rectangular vector grid", "self.OnMenuCmd", "v.mkgrid"), ("Generate points", ( ("Generate from database", "Generate points from database", "self.OnMenuCmd", "v.in.db"), ("Generate random", "Generate random points", "self.OnMenuCmd", "v.random"), ("Perturb points", "Random location perturbations of points", "self.OnMenuCmd", "v.perturb"), )), - ("Generate areas from points", ( - ("Convex hull", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), - ("Delaunay triangles", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), - ("Voronoi diagram/Thiessen polygons", "Generate Voronoi diagram/Thiessen polygons for point set", "self.OnMenuCmd", "v.voronoi"), - )), ("Sample raster maps at point locations", ( ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.OnMenuCmd", "v.rast.stats"), ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.OnMenuCmd", "v.what.rast"), @@ -416,7 +419,7 @@ )), ("","","", "") )), - ("Image", ( + ("Imagery", ( ("Develop images and groups", ( ("Create/edit imagery group", "Create/edit imagery group", "self.OnMenuCmd", "i.group"), ("Target imagery group", "Target imagery group", "self.OnMenuCmd", "i.target"), @@ -424,31 +427,31 @@ ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.OnMenuCmd", "i.image.mosaic"), )), ("Manage image colors", ( - ("Color balance and enhance color tables of multiband imagery for rgb display", "Color balance and enhance color tables of multiband imagery for rgb display", "self.OnMenuCmd", "i.landsat.rgb"), - ("Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "self.OnMenuCmd", "i.his.rgb"), - ("Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "self.OnMenuCmd", "i.rgb.his"), + ("Color balance for RGB", "Color balance and enhance color tables of multiband imagery for rgb display", "self.OnMenuCmd", "i.landsat.rgb"), + ("HIS to RGB", "Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "self.OnMenuCmd", "i.his.rgb"), + ("RGB to HIS", "Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "self.OnMenuCmd", "i.rgb.his"), )), ("Rectify and georeference image group", ( - ("Set ground control points (GCP's) from raster map or keyboard entry", "Set ground control points (GCP's) from raster map or keyboard entry", "self.OnMenuCmd", "i.points"), - ("Set ground control points (GCP's) from vector map or keyboard entry", "Set ground control points (GCP's) from vector map or keyboard entry", "self.OnMenuCmd", "i.vpoints"), - ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.OnMenuCmd", "i.rectify"), - ("Ortho Photo rectification", "Ortho Photo rectification", "self.OnMenuCmd", "i.ortho.photo"), + ("Set GCP's from raster map (requires Xterm)", "Set ground control points (GCP's) from raster map or keyboard entry", "self.OnXTerm", "i.points"), + ("Set GCP's from vector map (requires Xterm)", "Set ground control points (GCP's) from vector map or keyboard entry", "self.OnXTerm", "i.vpoints"), + ("Georectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.OnMenuCmd", "i.rectify"), + ("Ortho photo rectification (requies Xterm)", "Ortho Photo rectification", "self.OnXTerm", "i.ortho.photo"), )), ("","","", ""), - ("Brovey transformation and pan sharpening", "Brovey transformation and pan sharpening", "self.OnMenuCmd", "i.fusion.brovey"), + ("Brovey sharpening", "Brovey transformation and pan sharpening", "self.OnMenuCmd", "i.fusion.brovey"), ("Classify image", ( ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.OnMenuCmd", "i.cluster"), ("","","", ""), ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.OnMenuCmd", "i.maxlik"), ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.OnMenuCmd", "i.smap"), ("","","", ""), - ("Interactive input for supervised classification", "Interactive input for supervised classification", "self.OnMenuCmd", "i.class"), + ("Interactive input for supervised classification (requires Xterm)", "Interactive input for supervised classification", "self.OnXTerm", "i.class"), ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.OnMenuCmd", "i.gensig"), ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.OnMenuCmd", "i.gensigset"), )), ("Filter image", ( ("Zero edge crossing detection", "Zero edge crossing detection", "self.OnMenuCmd", "i.zc"), - ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.OnMenuCmd", "r.mfilter"), + ("Matrix/convolving filter", "User defined matrix/convolving filter", "self.OnMenuCmd", "r.mfilter"), )), ("Histogram image", "Histogram image", "self.DispHistogram", ""), ("Spectral response", "Spectral response", "self.OnMenuCmd", "i.spectral"), @@ -460,27 +463,65 @@ ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.OnMenuCmd", "i.ifft"), )), ("","","", ""), - ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), - ("Range of image values", "Range of image values", "self.OnMenuCmd", "r.describe"), - ("","","", ""), - ("Bit pattern comparison for ID of low quality pixels", "Bit pattern comparison for ID of low quality pixels", "self.OnMenuCmd", "r.bitpattern"), - ("Kappa classification accuracy assessment", "Kappa classification accuracy assessment", "self.OnMenuCmd", "r.kappa"), - ("Optimum index factor for LandSat TM", "Optimum index factor for LandSat TM", "self.OnMenuCmd", "i.oif"), + ("Report and statistics (also use raster reporting and stats)", ( + ("Bit pattern comparison ", "Bit pattern comparison for ID of low quality pixels", "self.OnMenuCmd", "r.bitpattern"), + ("Kappa analysis", "Kappa classification accuracy assessment", "self.OnMenuCmd", "r.kappa"), + ("OIF for LandSat TM", "Optimum index factor for LandSat TM", "self.OnMenuCmd", "i.oif"), )), ("","","", "") )), + ("Volumes", ( + ("Develop grid3D volumes", ( + ("Manage nulls", "Manage nulls for grid3D volume", "self.OnMenuCmd", "r3.null"), + ("Manage timestamp", "Manage timestamp for grid3D volume", "self.OnMenuCmd", "r3.timestamp"), + )), + ("","","", ""), + ("3D MASK", "Create 3D mask for grid3D operations", "self.OnMenuCmd", "r3.mask"), + ("Cross section", "Create 2D raster cross section from grid3d volume", "self.OnMenuCmd", "r3.cross.rast"), + ("Map calculator", "Map calculator for grid3D volume operations", "self.OnMenuCmd", "r3.mapcalculator"), + ("Interpoloate volume from points", "Interpolate volume from vector points using splines", "self.OnMenuCmd", "v.vol.rst"), + ("","","", ""), + ("Report and Statistics", ( + ("Basic information", "Report basic information about grid3D volume", "self.OnMenuCmd", "r3.info"), + )), + ("","","", "") + )), ("Database", ( - ("Query", "Query database", "self.Nomethod", ""), + ("Database information", ( + ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), + ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), + )), + ("","","", ""), + ("Manage databases", ( + ("Connect", "Connect to database", "self.OnMenuCmd", "db.connect"), + ("Login", "Login to database", "self.OnMenuCmd", "db.login"), + ("","","", ""), + ("New table", "Create and add new attribute table to vector map", "self.OnMenuCmd", "v.db.addtable"), + ("Copy table", "Copy attribute table", "self.OnMenuCmd", "db.copy"), + ("Remove table", "Remove existing attribute table for vector map", "self.OnMenuCmd", "db.login"), + ("","","", ""), + ("Add columns", "Add columns to table", "self.OnMenuCmd", "v.db.addcol"), + ("Change values", "Change values in a column", "self.OnMenuCmd", "v.db.update"), + ("Rename column", "Rename a column", "self.OnMenuCmd", "v.db.renamecol"), + ("","","", ""), + ("Test", "Test database", "self.OnMenuCmd", "db.test"), + ("","","", "") + )), + ("Query", ( + ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), + ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), + )), + ("","","", ""), + ("Vector<->database connections", ( + ("Reconnect vector to database", "Reconnect vector map to attribute database", "self.OnMenuCmd", "v.db.reconnect.all"), + ("Set vector - database connection", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), + )), ("","","", "") + )), + ("Help", ( + ("GRASS help", "GRASS help", "self.RunMenuCmd", ['g.manual', '-i']), + ("GIS Manager help", "GIS Manager help", "self.RunMenuCmd", ['g.manual', 'gis.m']), + ("About GRASS (not functional)", "About GRASS", "self.OnMenuCmd", ""), + ("About system (not functional)", "About system", "self.OnMenuCmd", ""), + ("","","", "") )))] - - - - - - - - - - From chemin at grass.itc.it Wed Jun 13 08:50:50 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Wed Jun 13 08:52:04 2007 Subject: [grass-addons] r834 - trunk/grassaddons/tutorials/grass_starter Message-ID: <200706130650.l5D6ooih015134@grass.itc.it> Author: chemin Date: 2007-06-13 08:48:41 +0200 (Wed, 13 Jun 2007) New Revision: 834 Added: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex trunk/grassaddons/tutorials/grass_starter/FR_main_document.tex Log: Starting Translation of grass_starter in French, initial copies non-translated Added: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex (rev 0) +++ trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 06:48:41 UTC (rev 834) @@ -0,0 +1,816 @@ +% Template GRASS newsletter - Article +% Language: Latex +% + +% Head + +\title{Starter Manual to GRASS GIS} +\subtitle{GRASS Original} +\author{GRASS Development Team} + +\maketitle + +\section{Introduction} + +This screenshot is GRASS GIS running natively on Windows +(http://geni.ath.cx/grass.html).Fig.~\ref{fig:grass000} +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.15]{grass000.png} + %caption of the figure + \caption{Windows Native GRASS} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass000} +\end{figure} + +Starting GRASS GIS: Select Spearfish60 Location by a click on +``Enter GRASS'':Fig.~\ref{fig:grass001} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.3]{grass001.png} + %caption of the figure + \caption{Welcome Screen} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass001} +\end{figure} + +At this point it should (somewhat) look this way: Fig.~\ref{fig:grass002} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass002.png} + %caption of the figure + \caption{GIS Manager} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass002} +\end{figure} + +Some more GRASS GUI information is found in Appendix A \ref{appendixA}. + +Load the elevation.10m layer by clicking on the raster display button +(second button from left):Fig.~\ref{fig:grass003} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.5]{grass003.png} + %caption of the figure + \caption{Basic Display} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass003} +\end{figure} + +Once selected, the main GRASS GUI will have a new layer like one of +these:Fig.~\ref{fig:grass004} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass004.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass004} +\end{figure} + +By selecting the new layer, you will be given a contextual menu below:Fig.~\ref{fig:grass005} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass005.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass005} +\end{figure} + +Then add a vector using the 8th icon from the left. Fig.~\ref{fig:grass006} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.5]{grass006.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass006} +\end{figure} + +Add a stream layer (blue color) and a road layer (brown color). Below is +the example for the streams Fig.~\ref{fig:grass007} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.45]{grass007.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass007} +\end{figure} + +Result should look like this (somehow):Fig.~\ref{fig:grass008} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass008.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass008} +\end{figure} + +\section{DEM MANIPULATIONS} +Display a dem:Fig.~\ref{fig:grass009} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass009.png} + %caption of the figure + \caption{Display a DEM} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass009} +\end{figure} + +\subsection{Compute slope and aspect} +Raster/Terrain Analysis/Slope and Aspect. Fig.~\ref{fig:grass010} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass010.png} + %caption of the figure + \caption{Slope} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass010} +\end{figure} + +Compute a shaded relief map ( in Raster/Terrain Analysis/Shaded Relief Map). +The Shaded Relief map should be like this when a elevation.10m map is overlaid to it with 0.75 opacity: Fig.~\ref{fig:grass011} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass011.png} + %caption of the figure + \caption{Shaded Relief} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass011} +\end{figure} + +\subsection{Watershed Basin Analysis Program} +Raster/Hydrologic modeling/Watershed Analysis. +Fill in the Elevation input map with ``elevation.10m''. The minimum size of an exterior watershed basin should be 5000 cells. Fill up output names for all the output maps available (i.e. ``\_cells\_nbr'', ``\_drain\_dir'', ``\_drain\_dir'', ``\_basins'', ``\_streams'', ``\_half\_basins'', ``\_visual'', ``\_LS'', ``\_S''). + +Output should state the following: + +SECTION 1a (of 6): Initiating Memory. + +SECTION 1b (of 6): Determining Offmap Flow. + +SECTION 2: A * Search. + +SECTION 3: Accumulating Surface Flow. + +SECTION 4: Length Slope determination. + +SECTION 5: Watershed determination. + +SECTION 6: Closing Maps. + +Output of ``\_basins'' should look like this:Fig.~\ref{fig:grass012} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass012.png} + %caption of the figure + \caption{Generated Basins} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass012} +\end{figure} + + +Output of ``\_streams'' should look like this: Fig.~\ref{fig:grass013} compare it with +the vector map ``streams''. + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass013.png} + %caption of the figure + \caption{Generated streams} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass013} +\end{figure} + +Relaunch with various values instead of 5000 cells, i.e. 2000 and 10000. +Compare by vectorizing the streams generated. Vectorization follows +these steps: +1-Raster/Neighborhood Analysis/Thin Linear Features +2-File/Map Type Conversion/Raster to Vector Map +3-Vector/Develop Map/Create-Rebuild Topology (optional) + +\subsection{Stream Pollution Monitoring Station site identification} +Assuming a Wood Processing Factory is requesting permit to setup a new processing plant in the country side. It is remote from major mapped streams (598713.35(E) 4920069.15(N)), the local council gave you a notice to assess the path of some minor effluents that may be draining to the major stream from the future factory, and especially their meeting point coordinates where the council will establish an automatic monitoring station. +Use Raster/Terrain Analysis/Least Cost Route Or Flow, your output should look like this: Fig.~\ref{fig:grass014} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass014.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass014} +\end{figure} + +What is the location (Easting,Northing) of the generated stream crossing +the mapped stream where it is proposed to install a monitoring +station? + +\section{GRASS GIS Habitat Analysis} +\subsection{Introduction} + +http://www.udel.edu/johnmack/frec682/682proj2.html + +This course is available online under the course name ``FREC 682 Spatial Analysis''. This material is a modified version to accommodate with GRASS 6.3+. + +In this session, the features needed are the following essentially (look in RASTER from the main interface): +The BUFFERING Module: Raster/Create buffers Fig.~\ref{fig:grass015} +The MAP CALCULATOR Module: Raster/Map Calculator Fig.~\ref{fig:grass016} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass015.png} + %caption of the figure + \caption{BUFFERING} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass015} +\end{figure} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass016.png} + %caption of the figure + \caption{MAP CALCULATOR} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass016} +\end{figure} + +Additional modules for the later part of the lab + +Query map with mouse: +In the Map display window, look for: Fig.~\ref{fig:grass017} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=1]{grass017.png} + %caption of the figure + \caption{Query Map with mouse} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass017} +\end{figure} + +NULL values: Raster/Develop Map/Manage Null values + +CLUMP: Raster/Transform features/Clump small Areas + +STATISTICS: Raster/Reports \& Statistics = General statistics + +R2V: File/Map type Conversions/Raster to vector + +Vector Build: Vector/Develop Map/Create/Rebuild Topology + +Vector Export: File/Export/Vector map/Various format using OGR (SHAPE, etc) + +Start New Display Window: +In the main GRASS GUI look for: Fig.~\ref{fig:grass018} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=1]{grass018.png} + %caption of the figure + \caption{Launch New Display} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass018} +\end{figure} + +Erase Display: +In the Map display window, look for: Fig.~\ref{fig:grass019} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=1]{grass019.png} + %caption of the figure + \caption{Erase Display Icon} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass019} +\end{figure} + +Redraw map: +In the Map display window, look for: Fig.~\ref{fig:grass020} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=1]{grass020.png} + %caption of the figure + \caption{Redraw Icon} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass020} +\end{figure} + +\subsection{HABITAT PRESERVATION MISSION} +The pickled strumpet (Trollopensus bibulosa) has recently been added to the Endangered Species List, and the Fish and Wildlife Service is identifying likely habitat areas in the Spearfish area for protection from development. They have constructed the following habitat scoring system based on the species observed habitat preferences: + +\subsection{HABITAT SCORING SYSTEM (from Fish and Wildlife Service) } + +Map number Environmental conditions Score to be given +1 within 500 meters of streams where slope <= 5 degrees +2 points +2 within 500 meters of streams where slope >5 degrees +5 points +3 within 500 meters of a road -5 points +4 coniferous forest +4 points +5 mixed forest +1 point +6 northern exposure (aspect from NW to NE) +3 points +7 western or eastern exposure (SW to NW or SE to NE) +1 point +8 1200-1400 meters elevation +2 points +9 1400-1600 meters elevation +4 points +10 over 1600 meters elevation +2 points + +Use r.buffer (..=> Create buffers) and r.mapcalc (..=> Map calculator) to create an aggregate habitat score map of the entire area, summing all the partial scores as defined above. (hint: you have to convert all null values of buffer output maps into zero values) +When finished with numbers 1 to 10 above, sum all the maps in a map that you may call scoreindivsum. Then identify suitable habitat areas by converting to zeroes all cells with overall habitat scores below 9, and all cells within 100 meters of a road (hint: you have to make a new buffer map here, and remove its null values for calculations). Make a final scoring map that you may call scorefinal and change 0 values to NULL (..=>Manage null values) for next laboratory part. + +\subsection{PROCESSING THE SCORING MAPS} + +In the processing of number 1 and 2, please use the Map Calculator with an input following an 'if statement'. The structure goes this +way: +\begin{smallverbatim} +if(condition, action_if_true, action_if_not_true) +\end{smallverbatim} +In the case of a map application use it this way: +\begin{smallverbatim} +if(MapA==value1, score_value1, score_value2) +\end{smallverbatim} +Since one may want to give two input maps together, a double if statement can be formulated this way: + +A practical example for number 1: +\begin{smallverbatim} +if(stream_buff_500==2,if(slope=5,2,0),0) +\end{smallverbatim} +In case one wants to select a range of values (inclusive or exclusive), use of OR and AND is necessary. Query to check aspect map (..=>Query with mouse), East=1 and North=+90 degrees. + +Practical examples for 7a and 7b: +\begin{smallverbatim} +7a) if(aspect<225 && aspect>135, 1, 0) + +7b) if(aspect<45 || aspect>314 && aspect!=0, 1, 0) +\end{smallverbatim} +Example 7b has an added constraint ``\&\& aspect !=0'' because aspect value 0 means no aspect was calculated (usually out of data boundary in +the image). + +This Set of instructions shows how GRASS GIS does the reclassification work under scripting mode. This is useful when you need to reuse the same set of GIS manipulations/models several times on different or new datasets. + +\subsection{HABITAT SCORING SCRIPT} + +Map number Environmental conditions Score to be given: + +\textbf{ +1) within 500 meters of streams where slope <= 5 degrees: +2 points} +\begin{smallverbatim} +r.buffer input=streams output=_bstreams500 + distances=500 units=meters --overwrite + +r.null map=_bstreams500 null=0 + +r.mapcalc _rbstreams500="if(_bstreams500==2,1,0)" + +r.null map=_rbstreams500 null=0 +\end{smallverbatim} + +\textbf{ +2) within 500 meters of streams where slope >5 degrees: +5 points} +\begin{smallverbatim} +r.buffer input=roads output=_broads500 distances=500 + units=meters --overwrite + +r.mapcalc _s_sl="if(_rbstreams500==1,if( + slope<=5,2,5),0)" +\end{smallverbatim} + +\textbf{ +3) within 500 meters of a road: -5 points} +\begin{smallverbatim} +r.mapcalc _rbroads500="float(if( + _broads500==2,-5.0,0))" +\end{smallverbatim} + +\textbf{ +4) coniferous forest: +4 points} +\begin{smallverbatim} +r.mapcalc _for="if(vegcover==3,4,0)" +\end{smallverbatim} + +\textbf{ +5) mixed forest: +1 point} +\begin{smallverbatim} +r.mapcalc _for1="if(vegcover==5,1,0)" +\end{smallverbatim} + +\textbf{ +6) northern exposure (aspect from NW to NE): +3 points} +\begin{smallverbatim} +r.mapcalc _exp3="if(aspect<=135.0 && aspect>=45.0 + && aspect != 0,3,0)" +\end{smallverbatim} + +\textbf{ +7a) western or eastern exposure (SW to NW or SE to NE): +1 point} +\begin{smallverbatim} +r.mapcalc _exp1="if(aspect<45.0 || aspect>314.0,1,0)" +r.mapcalc _exp2="if(aspect<225.0 && aspect>135.0,1,0)" +\end{smallverbatim} + +\textbf{ +7b) 1200-1400 meters elevation: +2 points} +\begin{smallverbatim} +r.mapcalc _elev1="if(elevation.10m<1400 + && elevation.10m>1200,2,0)" +\end{smallverbatim} + +\textbf{ +8) 1400-1600 meters elevation: +4 points} +\begin{smallverbatim} +r.mapcalc _elev2="if(elevation.10m<1600 + && elevation.10m>=1400,4,0)" +\end{smallverbatim} + +\textbf{ +9) over 1600 meters elevation: +2 points} +\begin{smallverbatim} +r.mapcalc _elev3="if(elevation.10m>=1600,2,0)" +\end{smallverbatim} + +\subsection{FINALIZING THE SCORING MAP} + +\begin{smallverbatim} +r.buffer input=roads output=_br100 + distances=100 units=meters --overwrite + +r.null map=_br100 null=0 + +r.mapcalc _add="float(_s_sl+_rbroads500+_for+ + _for1+_exp1+_exp2+_exp3+_elev1+_elev2+_elev3)" + +r.mapcalc _clas="if(_add>9,1,null())" + +r.mapcalc _class="if(_clas==1&&_br100==0,1,null())" +\end{smallverbatim} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass021.png} + %caption of the figure + \caption{Scoring Map} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass021} +\end{figure} + +\subsection{CLUMPING SUITABLE AREAS} +WARNING: This part of the Laboratory involves the use of the command line (command prompt). + +What is ``clumping''? +Recategorizes data in a raster map layer by grouping cells that form physically discrete areas into unique categories. + +Now find the discrete areas (clumps) of aggregated habitat scores. +Run \textit{r.clump (..=>Clump Small Areas) }on the ``\textit{score\_final}'' map to give each clump its own category number. You may call the output ``\textit{score\_clumped}''. + +\begin{smallverbatim} +r.clump input=score_final output=score_clumped +\end{smallverbatim} + +Display your newly clumped map ``\textit{score\_clumped}''. It should somewhat look like this one:Fig.~\ref{fig:grass022} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass022.png} + %caption of the figure + \caption{Clumped map} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass022} +\end{figure} + + +Since this species is most viable in larger clumps, extract the clumps greater than 50 hectares to a separate map. You may use the command line for reclassification by area threshold to select area superior to 50 hectares: + +\begin{smallverbatim} +r.reclass.area input = score_final greater=50 + output=selected_habitat_area +\end{smallverbatim} + +Output ``selected\_habitat\_area'' at this level should be similar to this one:Fig.~\ref{fig:grass023} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass023.png} + %caption of the figure + \caption{Seleceted Habitat Areas} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass023} +\end{figure} + +\subsection{EXPORT RESULTS TO VECTOR} +Since the users work in vector GIS, we are going to convert the results in vector format and export them from GRASS GIS to shapefile. + +Vectorize the clumped map you just produced (File/Map type conversion/raster to vector) and check that you +have effectively created a polygon vector map by displaying your vector using random colors.Fig.~\ref{fig:grass024} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{grass024.png} + %caption of the figure + \caption{Vector Export} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass024} +\end{figure} + +Export this selected habitat vector file along with the ``\textit{roads}'' and ``\textit{streams}'' vector files into shapefile. Please be sure that you export the same type of vectors (areas for ``\textit{selected\_habitat\_area}'' and lines for ``\textit{roads}'' and ``\textit{streams}''). Display and query them using Quantum GIS. + +\begin{smallverbatim} +v.out.ogr input=selected_habitat_area type=area + dsn=QGISDATA layer=1 format=ESRI_Shapefile + +v.out.ogr input=roads type=line dsn=QGISDATA + layer=1 format=ESRI_Shapefile + +v.out.ogr input=streams type=line dsn=QGISDATA + layer=1 format=ESRI_Shapefile +\end{smallverbatim} + +Additional processing..... + +The pickled strumpet is quite intolerant of edge disturbances, so you would like to weight interior areas of the habitat clumps more highly than edge areas. Create interior 100-meter-interval buffers within the large habitat clumps, where interior pixels within 100 meters of a clump edge have a weight of 1, interior pixels 100-200 meters from a clump edge have a weight of 2, interior pixels 200-300 meters from a clump edge have a weight of 3, etc., and pixels outside the largest clumps have a weight of zero. + +Use \textit{r.mapcalc} to multiply the aggregate habitat score map by these interior buffer weights. +Now run \textit{r.volume }on this buffer-weighted habitat score map to obtain the sum and average of each clump s cell habitat scores. +Use \textit{awk} to create reclass rules files, then use \textit{r.reclass} to map the largest clumps by sum and average habitat scores. +Which clump has the highest weighted total habitat score? Which has the highest weighted average habitat score? +Use \textit{r.grow} to create a map of clump edges only (subtracting the input map from the output map). +Use the edge map to index the perimeter of each of the major clumps. +Calculate the compactness (area divided by perimeter squared) of each clump. +Map the largest clumps by compactness. Create a jazzy display script to demonstrate your procedures and explain your findings. +(See \href{http://www.udel.edu/johnmack/frec682/script_ideas.html}) + +A script for some parts of the Lab is in \textbf{Appendix B} \ref{appendixB}. + +\newpage + +\subsection{Appendix A: Overview of Grass GUI} +\label{appendixA} + +Overview of the available commands in the modules:Fig.~\ref{fig:grass025} Fig.~\ref{fig:grass026} Fig.~\ref{fig:grass027} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.4]{grass025.png} + %caption of the figure + \caption{GRASS Menus (1/3)} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass025} +\end{figure} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.4]{grass026.png} + %caption of the figure + \caption{GRASS Menus (2/3)} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass026} +\end{figure} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.4]{grass027.png} + %caption of the figure + \caption{GRASS Menus (3/3)} + %label of the figure, which has to correspond to \ref{}: + \label{fig:grass027} +\end{figure} + +\newpage + +\subsection{Appendix B: GRASS SCRIPT} +\label{appendixB} + +Please put this into a file that you may name \textit{script.sh}\textup{and from a }\textit{Terminal}\textup{ type: ``chmod 0755}\textit{script.sh''}\textup{. Then you can run the script }by typing the command: ``./script.sh''. + +\begin{smallverbatim} +#!/bin/bash +# main map names variables +dem=elevation.dem +r=roads +s=streams +# buffer streams and roads variables +_bs=_bstreams500 +_br=_broads500 +# reclassed buffer streams and roads variables +_rbs=_rbstreams500 +_rbr=_rbroads500 +#-------------------------------------------------- +# General Presentation: Start Monitor 0 +#-------------------------------------------------- +d.mon start=x0 +d.erase color=grey +d.rast map=\$dem +sleep 1 +d.vect map=\$r color=brown +sleep 1 +d.vect map=\$s color=blue +sleep 1 +d.barscale bcolor=white tcolor=black at=30.0,95.0 +sleep 2 +#-------------------------------------------------- +# Buffering: Start Monitor 1 +#-------------------------------------------------- +d.mon start=x1 +d.mon select=x1 +d.erase color=grey +r.buffer input=\$s output=\$_bs distances=500 + units=meters --overwrite +r.null map=\$_bs null=0 +d.rast map=\$_bs +d.vect map=\$s color=blue +d.barscale bcolor=white tcolor=black at=30.0,95.0 +r.buffer input=\$r output=\$_br distances=500 + units=meters --overwrite +r.null map=\$_br null=0 +d.rast map=\$_br +d.vect map=\$s color=blue +d.barscale bcolor=white tcolor=black at=30.0,95.0 +#-------------------------------------------------- +# Reclassification: Start Monitor 2 +#-------------------------------------------------- +d.mon start=x2 +d.mon select=x2 +d.erase color=grey +echo "...Reclassify..." +r.mapcalc \$_rbs="if(\$_bs==2,1,0)" +r.mapcalc _s_sl="if(\$_rbs==1,if(slope<=5,2,5),0)" +r.mapcalc \$_rbr="float(if(\$_br==2,-5.0,0))" +r.mapcalc _for="if(vegcover==3,4,0)" +r.mapcalc _for1="if(vegcover==5,1,0)" +r.mapcalc _exp1="if(aspect<45.0 || aspect>314.0 && + aspect != 0.0,1,0)" +r.mapcalc _exp2="if(aspect<225.0 && aspect>135. + 0,1,0)" +r.mapcalc _exp3="if(aspect<=135.0 && aspect>=45.0, + 3,0)" +r.mapcalc _elev1="if(\$dem<1400 &&\$dem>1200,2,0)" +r.mapcalc _elev2="if(\$dem<1600 &&\$dem>=1400,4,0)" +r.mapcalc _elev3="if(\$dem>=1600,2,0)" +#-------------------------------------------------- +r.buffer input=\$r output=_br100 distances=100 + units=meters --overwrite +r.null map=\_br100 null=0 +r.mapcalc _add="float(_s_sl+\$_rbr+_for+_for1+ + _exp1+_exp2+_exp3+_elev1+_elev2+_elev3)" +r.mapcalc _clas="if(_add{>9,1,null())" +r.mapcalc _class="if(_clas==1&&_br100==0,1,null())" +echo "Reclassification...done." +d.rast map="\$_rbs" +sleep 1 +d.rast map="_s_sl" +d.rast map="\$_rbr" +d.rast map="_for" +d.rast map="_for1" +d.rast map="_exp1" +d.rast map="_exp2" +d.rast map="_exp3" +d.rast map="_elev1" +d.rast map="_elev2" +d.rast map="_elev3" +d.rast map="_br100" +sleep 1 +#r.colors color=grey map="_add" +d.rast map="_add" +sleep 1 +d.rast map="_class" +sleep 1 +#d.erase +d.vect map="\$s" color=blue +d.vect map="\$r" color=brown +d.barscale bcolor=white tcolor=black at=30.0,95.0 +sleep 5 +g.remove +rast="\$_rbs,_s_sl,\$_rbr,_for,_for1"} +g.remove +rast="_exp1,_exp2,_exp3,_elev1"} +g.remove +rast="_elev2,_elev3,_br100,_add"} +g.remove rast="\$_bs,\$_br,_clas"} +sleep 1 +echo "" +echo "finished" +sleep 1 +#-------------------------------------------------- +# Clumping: Start Monitor 3 +#-------------------------------------------------- +d.mon start=x3 +d.mon select=x3 +d.erase color=grey +g.remove rast=_clump.clump._rclumpnew +r.clump input=_class output=_clump --overwrite +r.colors color=gyr map="_clump" +d.rast map="_clump" +sleep 1 +r.reclass.area input=_clump greater=50 + output=_rclumpnew --overwrite +r.colors color=gyr map="_rclumpnew" +d.erase color=white +d.rast map="_rclumpnew" +sleep 1 +d.vect map="streams" color=blue +d.vect map="roads" color=brown +d.barscale bcolor=white tcolor=black at=30.0,95.0 +sleep 1 +g.remove rast="_clump,_class" +#-------------------------------------------------- +# R2V and Export: Start Monitor 4 +#-------------------------------------------------- +d.mon start=x4 +d.mon select=x4 +d.erase color=white +r.to.vect -s input=_rclumpnew output=rclump + feature=area --overwrite +d.vect -c map=rclump type=area color=black +d.vect map="streams" color=blue +d.vect map="roads" color=brown +d.barscale bcolor=white tcolor=black at=30.0,95.0 +sleep 1 +v.out.ogr input=rclump type=area dsn=QGISDATA + layer=1 format=ESRI_Shapefile --overwrite +g.remove rast="_rclumpnew" +g.remove vect="rclump" +d.mon stop=x4 +d.mon stop=x3 +d.mon stop=x2 +d.mon stop=x1 +d.mon stop=x0 +\end{smallverbatim} + +\address{GRASS Development Team\\ + \url{http://grass.itc.it}\\ + \email{weblist@grass.itc.it}} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: main_document.tex +%%% End: + Added: trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex (rev 0) +++ trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex 2007-06-13 06:48:41 UTC (rev 834) @@ -0,0 +1,639 @@ +% Template GRASS newsletter - Article +% Language: Latex +% + +% Head + +\title{Starter Manual to Quantum GIS for GRASS GIS} +\subtitle{} +\author{GRASS Development Team} + +\maketitle + +\section{QUANTUM GIS INTRODUCTION} + +This Manual is valid for QGIS version 0.8+ (http://www.qgis.org) +\textbf{Start QGIS}, the first time it should look like Fig.~\ref{fig:qgis000} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis000.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis000} +\end{figure} + +Open some vector layers from QGIS sample data set Fig.~\ref{fig:qgis001} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis001.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis001} +\end{figure} + +Select all the layers (Ctrl+a) Fig.~\ref{fig:qgis002} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis002.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis002} +\end{figure} + +The layers displayed should look like Fig.~\ref{fig:qgis003} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis003.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis003} +\end{figure} + +Zoom to all layers extents... Fig.~\ref{fig:qgis004} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis004.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis004} +\end{figure} + +Result after zooming to all layers Fig.~\ref{fig:qgis005} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis005.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis005} +\end{figure} + +Set the first layer in the overview frame Fig.~\ref{fig:qgis006} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis006.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis006} +\end{figure} + +Result... Fig.~\ref{fig:qgis007} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis007.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis007} +\end{figure} + +Open the plugin menu Fig.~\ref{fig:qgis008} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis008.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis008} +\end{figure} + +It should look like this Fig.~\ref{fig:qgis009} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis009.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis009} +\end{figure} + +Select those plugins Fig.~\ref{fig:qgis010} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis010.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis010} +\end{figure} + + +Some new menus have appeared! Fig.~\ref{fig:qgis011} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis011.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis011} +\end{figure} + + +Maximizing QGIS makes more icons appearing... Fig.~\ref{fig:qgis012} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis012.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis012} +\end{figure} + + +Drag the new menus below to make them glue to a second level of +toolbars... Fig.~\ref{fig:qgis013} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis013.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis013} +\end{figure} + +\section{QUANTUM GIS GRASS PLUGIN} + +Open a GRASS raster layer by clicking on the second button from the +left Fig.~\ref{fig:qgis014} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.45]{qgis014.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis014} +\end{figure} + +This is the contextual menu that opens, select the Map name as +``elevation.10m'' Fig.~\ref{fig:qgis015} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.85]{qgis015.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis015} +\end{figure} + + +This is the result of loading the GRASS Raster Layer Fig.~\ref{fig:qgis016} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis016.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis016} +\end{figure} + +Very similarly with other types of data, add the layer to overview Fig.~\ref{fig:qgis017} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis017.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis0017} +\end{figure} + +Result Fig.~\ref{fig:qgis018} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis018.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis018} +\end{figure} + +Add a GRASS Vector Layer by selecting the first Icon from the left Fig.~\ref{fig:qgis019} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.75]{qgis019.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis019} +\end{figure} + +This is the contextual menu that opens, select the Map name as +``streams'' and the layer name as ``1\_Line'' Fig.~\ref{fig:qgis020} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.45]{qgis020.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis020} +\end{figure} + +This is the streams vector layer, open the properties by a right{}-click +on the name Fig.~\ref{fig:qgis021} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis021.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis021} +\end{figure} + +The Properties box looks like this, and select the ``fill color'' button +to open a color selection dialog box. Change the color to a common Blue +and apply Fig.~\ref{fig:qgis022} Fig.~\ref{fig:qgis023} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis022.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis022} +\end{figure} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis023.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis023} +\end{figure} + +Select the first button on the right side to start GRASS vector editing +module Fig.~\ref{fig:qgis024} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.4]{qgis024.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis024} +\end{figure} + +The Edit GRASS Vector dialog box can only be opened when a vector is +selected in the main QGIS window Fig.~\ref{fig:qgis025} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis025.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis025} +\end{figure} + +Select the ``moving vertex'' button (5th from the +left) and move the red cross on the map Fig.~\ref{fig:qgis026} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis026.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis026} +\end{figure} + +The result should look like this (Fig.~\ref{fig:qgis026}). The last button in the toolbar will +commit the modifications to the vector layer and rebuild it Fig.~\ref{fig:qgis027} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.75]{qgis027.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis027} +\end{figure} + +In the launching terminal, the commit changes are described Fig.~\ref{fig:qgis028} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis028.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis028} +\end{figure} + +Set GRASS plugin environment for processing... Fig.~\ref{fig:qgis029} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis029.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis029} +\end{figure} + +Following this, select the 3rd icon from the left on +the GRASS toolbar. This will open the GRASS processing tool as shown +(mostly) in the next three pages. This GRASS tool is a thin +representation of the GRASS GIS capacities, but it will serve the +purpose of this introduction. It comes with a browser of the GRASS +mapset used. It also acts as a data management interface. Fig.~\ref{fig:qgis030} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.4]{qgis030.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis030} +\end{figure} + +The browser has the capacity to expand header information and metadata +pertaining to the layer selected Fig.~\ref{fig:qgis031} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.3]{qgis031.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis031} +\end{figure} + +The GRASS modules available are listed in the next two pages. More are +being ported everyday, The actual number of GRASS GIS modules exceeds +400, you can see that there is still some work to do, and the community +of volunteers are working on it Fig.~\ref{fig:qgis032} Fig.~\ref{fig:qgis033} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.4]{qgis032.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis032} +\end{figure} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.4]{qgis033.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis033} +\end{figure} + +\subsection{GRASS PLUGIN PROCESSING} + +Let us create some buffers... Select buffering of vectors from the +Modules list. It should looks like this. Choose 500 meters buffer +size Fig.~\ref{fig:qgis034} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.3]{qgis034.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis034} +\end{figure} + +Processing is going on... Fig.~\ref{fig:qgis035} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.3]{qgis035.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis035} +\end{figure} + +Finishing the processing Fig.~\ref{fig:qgis036} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.3]{qgis036.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis036} +\end{figure} + +Result should look like this (you have to load the map yourself!) Fig.~\ref{fig:qgis037} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis037.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis037} +\end{figure} + +Now create another buffer from streams but this time at 100 meters... +Like this Fig.~\ref{fig:qgis038} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis038.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis038} +\end{figure} + +Now we are going to subtract the 100m buffer to the 500m buffer, because +we want to exclude the streams and its proximity from our area of +selection. Find this module! Fig.~\ref{fig:qgis039} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis039.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis039} +\end{figure} + +Processing the overlay with boolean operator ``NOT'' Fig.~\ref{fig:qgis040} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.35]{qgis040.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis040} +\end{figure} + +Result is discarding all under 100m from the streams, and all above 500 +meters from the streams. Fig.~\ref{fig:qgis041} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis041.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis041} +\end{figure} + +Process an aspect map from the elevation map Fig.~\ref{fig:qgis042} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.45]{qgis042.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis042} +\end{figure} + +Processing... Fig.~\ref{fig:qgis043} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.45]{qgis043.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis043} +\end{figure} + +Result Fig.~\ref{fig:qgis044} + +%\setkeys{Gin}{width=1\textwidth} +\begin{figure}[htbp] + \centering + %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: + \includegraphics[scale=0.2]{qgis044.png} + %caption of the figure + \caption{} + %label of the figure, which has to correspond to \ref{}: + \label{fig:qgis044} +\end{figure} + +\address{GRASS Development Team\\ + \url{http://grass.itc.it}\\ + \email{weblist@grass.itc.it}} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: main_document.tex +%%% End: + Added: trunk/grassaddons/tutorials/grass_starter/FR_main_document.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_main_document.tex (rev 0) +++ trunk/grassaddons/tutorials/grass_starter/FR_main_document.tex 2007-06-13 06:48:41 UTC (rev 834) @@ -0,0 +1,49 @@ +% Main document GRASS Tutorials +% Language: Latex +% +% DON'T EDIT THIS FILE! + +\documentclass[a4paper]{report} + +% for boot +\usepackage{amssymb,amsmath} +% Note: we currently need to include amsmath before GRASSnews, because the +% latter redefines the equation environment ... +\usepackage{GRASSnews} +\usepackage[round]{natbib} +% for Sweave +\usepackage{listings} +% for tcltk-update +\usepackage{shortvrb} +%\usepackage{chapterbib} + + +\sloppy{} + + +\begin{document} + +\volume{1} +\volnumber{1} +\date{June 2007} +\titlepage + + + +\begin{article} + \input{FR_article_QGIS} +\end{article} + +\newpage + +\begin{article} + \input{FR_article_GRASS} +\end{article} + + +\end{document} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: main_document.tex +%%% End: From chemin at grass.itc.it Wed Jun 13 11:32:51 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Wed Jun 13 11:32:53 2007 Subject: [grass-addons] r835 - trunk/grassaddons/tutorials/grass_starter Message-ID: <200706130932.l5D9Wp5d016433@grass.itc.it> Author: chemin Date: 2007-06-13 11:32:46 +0200 (Wed, 13 Jun 2007) New Revision: 835 Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex Log: Commencement de l'article de GRASS en Francais Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 06:48:41 UTC (rev 834) +++ trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 09:32:46 UTC (rev 835) @@ -4,15 +4,15 @@ % Head -\title{Starter Manual to GRASS GIS} -\subtitle{GRASS Original} +\title{Manuel pour d\'ebuter avec le SIG GRASS} +\subtitle{GRASS en version originale} \author{GRASS Development Team} \maketitle \section{Introduction} -This screenshot is GRASS GIS running natively on Windows +Cette capture d'\'ecran est le SIG GRASS en version original sous Windows (http://geni.ath.cx/grass.html).Fig.~\ref{fig:grass000} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -20,12 +20,12 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.15]{grass000.png} %caption of the figure - \caption{Windows Native GRASS} + \caption{GRASS en version original sous Windows} %label of the figure, which has to correspond to \ref{}: \label{fig:grass000} \end{figure} -Starting GRASS GIS: Select Spearfish60 Location by a click on +Lancer le SIG GRASS: S\'electionnez la Location Spearfish60 et cliquez sur ``Enter GRASS'':Fig.~\ref{fig:grass001} %\setkeys{Gin}{width=1\textwidth} @@ -34,12 +34,12 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.3]{grass001.png} %caption of the figure - \caption{Welcome Screen} + \caption{Ecran d'acceuil} %label of the figure, which has to correspond to \ref{}: \label{fig:grass001} \end{figure} -At this point it should (somewhat) look this way: Fig.~\ref{fig:grass002} +A ce moment cel\`a devrait ressembler \`a: Fig.~\ref{fig:grass002} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -47,15 +47,14 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.35]{grass002.png} %caption of the figure - \caption{GIS Manager} + \caption{Gestionnaire du SIG} %label of the figure, which has to correspond to \ref{}: \label{fig:grass002} \end{figure} -Some more GRASS GUI information is found in Appendix A \ref{appendixA}. +Plus d'information sur le GUI se trouve dans l'appendice A \ref{appendixA}. -Load the elevation.10m layer by clicking on the raster display button -(second button from left):Fig.~\ref{fig:grass003} +Chargez la couche elevation.10m en cliquant sur le bouton de d'affichage raster (second bouton \`a partir de gauche):Fig.~\ref{fig:grass003} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -63,13 +62,12 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.5]{grass003.png} %caption of the figure - \caption{Basic Display} + \caption{Affichage \'el\'ementaire} %label of the figure, which has to correspond to \ref{}: \label{fig:grass003} \end{figure} -Once selected, the main GRASS GUI will have a new layer like one of -these:Fig.~\ref{fig:grass004} +Une fois s\'electionn\'e, l'interface d'utilisation de GRASS aura une nouvelle couche comme cell-ci:Fig.~\ref{fig:grass004} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -82,7 +80,7 @@ \label{fig:grass004} \end{figure} -By selecting the new layer, you will be given a contextual menu below:Fig.~\ref{fig:grass005} +En s\'electionnant la nouvelle couche, vous aurez acc\`es \`a un menu contextuel comme ceci:Fig.~\ref{fig:grass005} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -95,7 +93,7 @@ \label{fig:grass005} \end{figure} -Then add a vector using the 8th icon from the left. Fig.~\ref{fig:grass006} +Ajoutez une couche vectorielle en utilisant la 8\`eme ic\^one \`a partir de la gauche. Fig.~\ref{fig:grass006} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -108,8 +106,7 @@ \label{fig:grass006} \end{figure} -Add a stream layer (blue color) and a road layer (brown color). Below is -the example for the streams Fig.~\ref{fig:grass007} +Ajoutez une couche vectorielle "stream" (de couleur bleue) et "road" de couleur amrron. Ci-dessous est l'exemple pour "stream" Fig.~\ref{fig:grass007} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -122,7 +119,7 @@ \label{fig:grass007} \end{figure} -Result should look like this (somehow):Fig.~\ref{fig:grass008} +Le r\'esultat devrait \^etre comme ceci (plus ou moins):Fig.~\ref{fig:grass008} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -135,8 +132,8 @@ \label{fig:grass008} \end{figure} -\section{DEM MANIPULATIONS} -Display a dem:Fig.~\ref{fig:grass009} +\section{MANIPULATIONS DE DEM} +Affichage du dem:Fig.~\ref{fig:grass009} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -144,12 +141,12 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.35]{grass009.png} %caption of the figure - \caption{Display a DEM} + \caption{Affichage du DEM} %label of the figure, which has to correspond to \ref{}: \label{fig:grass009} \end{figure} -\subsection{Compute slope and aspect} +\subsection{Calcul de pente et d'aspect} Raster/Terrain Analysis/Slope and Aspect. Fig.~\ref{fig:grass010} %\setkeys{Gin}{width=1\textwidth} @@ -158,13 +155,13 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.35]{grass010.png} %caption of the figure - \caption{Slope} + \caption{Pente} %label of the figure, which has to correspond to \ref{}: \label{fig:grass010} \end{figure} -Compute a shaded relief map ( in Raster/Terrain Analysis/Shaded Relief Map). -The Shaded Relief map should be like this when a elevation.10m map is overlaid to it with 0.75 opacity: Fig.~\ref{fig:grass011} +Calcul de carte de relief ombrag\'e ( prenez Raster/Terrain Analysis/Shaded Relief Map). +La carte de relief ombrag\'e devrait \^etre comme ceci quand la carte "elevation.10m" est superimpos\'ee dessus avec une opacit\'e de 0.75: Fig.~\ref{fig:grass011} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -172,16 +169,16 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.35]{grass011.png} %caption of the figure - \caption{Shaded Relief} + \caption{Relief Ombrag\'e} %label of the figure, which has to correspond to \ref{}: \label{fig:grass011} \end{figure} -\subsection{Watershed Basin Analysis Program} +\subsection{Programme d'analyse de basin versant} Raster/Hydrologic modeling/Watershed Analysis. -Fill in the Elevation input map with ``elevation.10m''. The minimum size of an exterior watershed basin should be 5000 cells. Fill up output names for all the output maps available (i.e. ``\_cells\_nbr'', ``\_drain\_dir'', ``\_drain\_dir'', ``\_basins'', ``\_streams'', ``\_half\_basins'', ``\_visual'', ``\_LS'', ``\_S''). +Remplissezs les param\`etres d'entr\'e de la carte d'altitude avec ``elevation.10m''. La taille minimum de l'ext\'erieur d'un bassin versant doit \^etre de 5000 pixels. Remplissez les param\`etres de sortie pour toutes les cartes disponibles (i.e. ``\_cells\_nbr'', ``\_drain\_dir'', ``\_drain\_dir'', ``\_basins'', ``\_streams'', ``\_half\_basins'', ``\_visual'', ``\_LS'', ``\_S''). -Output should state the following: +Voici ce que doit dire l' ex\'ecution du module: SECTION 1a (of 6): Initiating Memory. @@ -197,7 +194,7 @@ SECTION 6: Closing Maps. -Output of ``\_basins'' should look like this:Fig.~\ref{fig:grass012} +La carte r\'esultante ``\_basins'' devrait ressembler \`a cel\`a:Fig.~\ref{fig:grass012} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -205,14 +202,13 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.35]{grass012.png} %caption of the figure - \caption{Generated Basins} + \caption{Carte de basins versants} %label of the figure, which has to correspond to \ref{}: \label{fig:grass012} \end{figure} -Output of ``\_streams'' should look like this: Fig.~\ref{fig:grass013} compare it with -the vector map ``streams''. +La carte r\'esultante ``\_streams'' devrait ressembler \`a cel\`a: Fig.~\ref{fig:grass013} comparez-l\`a avec la carte vectorielle ``streams''. %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -220,21 +216,20 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.35]{grass013.png} %caption of the figure - \caption{Generated streams} + \caption{Carte de r\'eseau hydrologique} %label of the figure, which has to correspond to \ref{}: \label{fig:grass013} \end{figure} -Relaunch with various values instead of 5000 cells, i.e. 2000 and 10000. -Compare by vectorizing the streams generated. Vectorization follows -these steps: +Relancez avec des valuers diff\'erentes au lieu de 5000 pixels, i.e. 2000 et 10000. +Comparez en vectorisant les r\'eseaux hydrologiques g\'en\'er\'es. La vectorisation suit ces \'etapes: 1-Raster/Neighborhood Analysis/Thin Linear Features 2-File/Map Type Conversion/Raster to Vector Map 3-Vector/Develop Map/Create-Rebuild Topology (optional) -\subsection{Stream Pollution Monitoring Station site identification} -Assuming a Wood Processing Factory is requesting permit to setup a new processing plant in the country side. It is remote from major mapped streams (598713.35(E) 4920069.15(N)), the local council gave you a notice to assess the path of some minor effluents that may be draining to the major stream from the future factory, and especially their meeting point coordinates where the council will establish an automatic monitoring station. -Use Raster/Terrain Analysis/Least Cost Route Or Flow, your output should look like this: Fig.~\ref{fig:grass014} +\subsection{Identification de site de station de suivit de la Pollution d'un ruisseau} +En consid\'erant qu'une usine de transformation/traitement de bois fasse une demande de permis pour mettre en place une nouvelle usine dans le basin versant. La localisation est distante du r\'eseau hydrologique majeur cartographi\'e (598713.35(E) 4920069.15(N)), le conseil local vous a employ\'e pour \'evaluer le chemin de quelques effluents mineurs qui pourraient se retrouver dans le r\'eseau majeur \`a partir de l'usine qui va \^etre install\'ee, et sp\'ecialement leurs coordonn\'ees g\'eographiques du point de rencontre o\`u le conseil va mettre en place une station de suivit automatique. +Utilisez Raster/Terrain Analysis/Least Cost Route Or Flow, v\^otre r\'esultat devrait ressembler a cel\`a: Fig.~\ref{fig:grass014} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -247,20 +242,18 @@ \label{fig:grass014} \end{figure} -What is the location (Easting,Northing) of the generated stream crossing -the mapped stream where it is proposed to install a monitoring -station? +Quelle est la localisation (Est,Nord) du chemin hydrologique g\'en\'er\'e rejoignant la rivi\`ere cartographi\'ee, et donc lieu propos\'e pour installer une station de suivit? -\section{GRASS GIS Habitat Analysis} +\section{Analyse d'habitat avec le SIG GRASS} \subsection{Introduction} http://www.udel.edu/johnmack/frec682/682proj2.html -This course is available online under the course name ``FREC 682 Spatial Analysis''. This material is a modified version to accommodate with GRASS 6.3+. +Ce cours est disponible en ligne sous le nom ``FREC 682 Spatial Analysis''. Ce mat\'eriel a \'et\'e modifi\'e pour r\'epondre aux changements venant avec GRASS version 6.3 et additionnelles. -In this session, the features needed are the following essentially (look in RASTER from the main interface): -The BUFFERING Module: Raster/Create buffers Fig.~\ref{fig:grass015} -The MAP CALCULATOR Module: Raster/Map Calculator Fig.~\ref{fig:grass016} +Dans cette session, les \'el\'ements dont vous aurez besoins sont essentiellement (regardez dans la partie RASTER de l'interface principale): +Le module BUFFERING: Raster/Create buffers Fig.~\ref{fig:grass015} +Le module MAP CALCULATOR: Raster/Map Calculator Fig.~\ref{fig:grass016} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -284,10 +277,10 @@ \label{fig:grass016} \end{figure} -Additional modules for the later part of the lab +Certains modules additionnels pour plus tard -Query map with mouse: -In the Map display window, look for: Fig.~\ref{fig:grass017} +Questionner une carte avec la souris: +Dans la fen\^etre d'affichage, cherchez: Fig.~\ref{fig:grass017} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -295,25 +288,25 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=1]{grass017.png} %caption of the figure - \caption{Query Map with mouse} + \caption{Questionner une carte avec la souris} %label of the figure, which has to correspond to \ref{}: \label{fig:grass017} \end{figure} -NULL values: Raster/Develop Map/Manage Null values +Valeurs NULL dans les cartes: Raster/Develop Map/Manage Null values CLUMP: Raster/Transform features/Clump small Areas -STATISTICS: Raster/Reports \& Statistics = General statistics +STATISTIQUES: Raster/Reports \& Statistics = General statistics R2V: File/Map type Conversions/Raster to vector -Vector Build: Vector/Develop Map/Create/Rebuild Topology +Construction Vectorielle: Vector/Develop Map/Create/Rebuild Topology -Vector Export: File/Export/Vector map/Various format using OGR (SHAPE, etc) +Export Vectoriel: File/Export/Vector map/Various format using OGR (SHAPE, etc) -Start New Display Window: -In the main GRASS GUI look for: Fig.~\ref{fig:grass018} +Lanc\'e une nouvelle fen\^etre: +Dans l'interface principal de GRASS, cherchez : Fig.~\ref{fig:grass018} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -321,13 +314,13 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=1]{grass018.png} %caption of the figure - \caption{Launch New Display} + \caption{Lanacer une nouvelle fen\^etre d'affichage} %label of the figure, which has to correspond to \ref{}: \label{fig:grass018} \end{figure} -Erase Display: -In the Map display window, look for: Fig.~\ref{fig:grass019} +Effacer l'affichage: +Dans la fen\^etre d'affichage, cherchez: Fig.~\ref{fig:grass019} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -335,13 +328,13 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=1]{grass019.png} %caption of the figure - \caption{Erase Display Icon} + \caption{Ic\^one d'effacement d'affichage} %label of the figure, which has to correspond to \ref{}: \label{fig:grass019} \end{figure} -Redraw map: -In the Map display window, look for: Fig.~\ref{fig:grass020} +Redessiner la carte: +Dans la fen\^etre d'affichage, cherchez: Fig.~\ref{fig:grass020} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -349,27 +342,27 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=1]{grass020.png} %caption of the figure - \caption{Redraw Icon} + \caption{Ic\^one de redessinage} %label of the figure, which has to correspond to \ref{}: \label{fig:grass020} \end{figure} -\subsection{HABITAT PRESERVATION MISSION} -The pickled strumpet (Trollopensus bibulosa) has recently been added to the Endangered Species List, and the Fish and Wildlife Service is identifying likely habitat areas in the Spearfish area for protection from development. They have constructed the following habitat scoring system based on the species observed habitat preferences: +\subsection{MISSION DE PRESERVATION D'UN HABITAT} +La Trollopensus bibulosa a recemment \'et\'e ajout\'ee sur la liste des esp\`eces en danger, et le service en charge de la faune sauvage est en train d'identifier des habitats probables dans la zone sp\'eciale de Spearfish pour prot\'eger contre le d\'eveloppement. Ils ont construit le syst\`emes de points suivant pour cet habitat bas\'e sur les statistiques de pr\'ef\'erences des esp\`eces observ\'ees: -\subsection{HABITAT SCORING SYSTEM (from Fish and Wildlife Service) } +\subsection{SYSTEME DE POINTS POUR L'HABITAT (venant du service de la faune sauvage) } -Map number Environmental conditions Score to be given -1 within 500 meters of streams where slope <= 5 degrees +2 points -2 within 500 meters of streams where slope >5 degrees +5 points -3 within 500 meters of a road -5 points -4 coniferous forest +4 points -5 mixed forest +1 point -6 northern exposure (aspect from NW to NE) +3 points -7 western or eastern exposure (SW to NW or SE to NE) +1 point -8 1200-1400 meters elevation +2 points -9 1400-1600 meters elevation +4 points -10 over 1600 meters elevation +2 points +Num\'ero de carte Conditions environnementales Score \`a donner +1 dans 500 m\`etres d'un cours d'eau o\` la pente <= 5 degr\'es +2 points +2 dans 500 m\`etres d'un cours d'eau o\` la pente >5 degr\'es +5 points +3 dans 500 m\`etres d'une route -5 points +4 for\^et de conif\`eres +4 points +5 for\^et mixte +1 point +6 exposition au Nord (aspect de NO \`a NE) +3 points +7 exposition \`a l'Ouest ou l'Est (SO au NO ou SE to NE) +1 point +8 1200-1400 m\`etres d'altitude +2 points +9 1400-1600 m\`etres d'altitude +4 points +10 over 1600 m\`etres d'altitude +2 points Use r.buffer (..=> Create buffers) and r.mapcalc (..=> Map calculator) to create an aggregate habitat score map of the entire area, summing all the partial scores as defined above. (hint: you have to convert all null values of buffer output maps into zero values) When finished with numbers 1 to 10 above, sum all the maps in a map that you may call scoreindivsum. Then identify suitable habitat areas by converting to zeroes all cells with overall habitat scores below 9, and all cells within 100 meters of a road (hint: you have to make a new buffer map here, and remove its null values for calculations). Make a final scoring map that you may call scorefinal and change 0 values to NULL (..=>Manage null values) for next laboratory part. From chemin at grass.itc.it Wed Jun 13 13:12:26 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Wed Jun 13 13:12:28 2007 Subject: [grass-addons] r836 - trunk/grassaddons/tutorials/grass_starter Message-ID: <200706131112.l5DBCQgu016694@grass.itc.it> Author: chemin Date: 2007-06-13 13:11:49 +0200 (Wed, 13 Jun 2007) New Revision: 836 Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex Log: More French Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 09:32:46 UTC (rev 835) +++ trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 11:11:49 UTC (rev 836) @@ -364,29 +364,28 @@ 9 1400-1600 m\`etres d'altitude +4 points 10 over 1600 m\`etres d'altitude +2 points -Use r.buffer (..=> Create buffers) and r.mapcalc (..=> Map calculator) to create an aggregate habitat score map of the entire area, summing all the partial scores as defined above. (hint: you have to convert all null values of buffer output maps into zero values) -When finished with numbers 1 to 10 above, sum all the maps in a map that you may call scoreindivsum. Then identify suitable habitat areas by converting to zeroes all cells with overall habitat scores below 9, and all cells within 100 meters of a road (hint: you have to make a new buffer map here, and remove its null values for calculations). Make a final scoring map that you may call scorefinal and change 0 values to NULL (..=>Manage null values) for next laboratory part. +Utilisez r.buffer (..=> Create buffers) et r.mapcalc (..=> Map calculator) pour cr\'eer une carte de score d'habitat pour toute la zone, en additionnant tous les scores partiels comme d\'efinis ci-dessus. (conseil: vous devez convertir toutes les valuers nulles des cartes de r\'esultats de buffer en valuers z\'ero) +Quand vous serez termin\'e avec les cartes 1 \`a 10 ci-dessus, additionnez-les toutes en une seule carte que vous pourriez appeler "scoreindivsum". Ensuite, identifiez une zone d'habitat souhaitable en convertissant les valeurs z\'ero des pixels pour tout r\'esultat inf\'erieur \`a 9, et tout pixel dans les 100 m\`etres d'une route (conseil: vous devz faire une nouvelle carte de buffer ici, et enlever ses valeurs nulles pour les calculs). Faites une carte finale que vous pourriez appeler "scorefinal" et changez en les valeurs z\'ero en NULL (..=>Manage null values) pour atteindre la prochaine partie de cet exercice. -\subsection{PROCESSING THE SCORING MAPS} +\subsection{PREPARATION DES CARTES DE SCORE} -In the processing of number 1 and 2, please use the Map Calculator with an input following an 'if statement'. The structure goes this -way: +Pour calculer les cartes 1 et 2, utilisez le "Map Calculator" avec un syntaxte comprenant une structure conditionnelle (if). Cel\`a se trouve \^etre dans l'exemple suivant: \begin{smallverbatim} -if(condition, action_if_true, action_if_not_true) +if(condition, action_si_vrai, action_si_faux) \end{smallverbatim} -In the case of a map application use it this way: +Dans le cas d'une carte: \begin{smallverbatim} -if(MapA==value1, score_value1, score_value2) +if(CarteA==valeur1, score_valeur1, score_valeur2) \end{smallverbatim} -Since one may want to give two input maps together, a double if statement can be formulated this way: +Dans le cas ou deux cartes sont utilis\'ees ensemble, un syst\`eme conditionnel double peut \^etre d\'ecrit comme ceci: -A practical example for number 1: +Un exemple pratique pour la carte num\'ero 1: \begin{smallverbatim} if(stream_buff_500==2,if(slope=5,2,0),0) \end{smallverbatim} -In case one wants to select a range of values (inclusive or exclusive), use of OR and AND is necessary. Query to check aspect map (..=>Query with mouse), East=1 and North=+90 degrees. +Dans le cas o\'u l'on voudrait s\'electionner une gamme de valeurs (inclusive ou exclusive), utilisez les op\'erants "OR" et "AND". Questionnez la carte d'aspect (..=>Query with mouse), Est=1 et Nord=+90 degr\'es. -Practical examples for 7a and 7b: +Exemples practiques pour 7a et 7b: \begin{smallverbatim} 7a) if(aspect<225 && aspect>135, 1, 0) From chemin at grass.itc.it Wed Jun 13 13:27:19 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Wed Jun 13 13:27:20 2007 Subject: [grass-addons] r837 - trunk/grassaddons/tutorials/grass_starter Message-ID: <200706131127.l5DBRJ3p016762@grass.itc.it> Author: chemin Date: 2007-06-13 13:26:42 +0200 (Wed, 13 Jun 2007) New Revision: 837 Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex Log: More French Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 11:11:49 UTC (rev 836) +++ trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 11:26:42 UTC (rev 837) @@ -391,17 +391,16 @@ 7b) if(aspect<45 || aspect>314 && aspect!=0, 1, 0) \end{smallverbatim} -Example 7b has an added constraint ``\&\& aspect !=0'' because aspect value 0 means no aspect was calculated (usually out of data boundary in -the image). +L'exemple 7b a une contrainte additionnelle ``\&\& aspect !=0'' car la valeur d'aspect 0 veut dire pas d'aspect calcul\'e (g\'en\'eralement en dehors de la zone de donn\'ees de l'image). -This Set of instructions shows how GRASS GIS does the reclassification work under scripting mode. This is useful when you need to reuse the same set of GIS manipulations/models several times on different or new datasets. +Ce jeu d'instructions montre comment le SIG GRASS produit une reclassification en mode "script". Ceci devient tr\`es utile quand vous avez besoin de r\'e-utiliser une analyse SIG complex plusieurs fois de suite sur d'autre jeux de donn\'ees par exemple. \subsection{HABITAT SCORING SCRIPT} -Map number Environmental conditions Score to be given: +Num\'ero de carte Conditions environnementales Score \`a donner: \textbf{ -1) within 500 meters of streams where slope <= 5 degrees: +2 points} +1) Dans 500 m\`etres des cours d'eau o\`u la pente <= 5 degr\'es: +2 points} \begin{smallverbatim} r.buffer input=streams output=_bstreams500 distances=500 units=meters --overwrite @@ -414,7 +413,7 @@ \end{smallverbatim} \textbf{ -2) within 500 meters of streams where slope >5 degrees: +5 points} +2) Dans 500 m\`etres des cours d'eau o\`u la pente >5 degr\'es: +5 points} \begin{smallverbatim} r.buffer input=roads output=_broads500 distances=500 units=meters --overwrite @@ -424,59 +423,59 @@ \end{smallverbatim} \textbf{ -3) within 500 meters of a road: -5 points} +3) Dans 500 m\`etres d'une route: -5 points} \begin{smallverbatim} r.mapcalc _rbroads500="float(if( _broads500==2,-5.0,0))" \end{smallverbatim} \textbf{ -4) coniferous forest: +4 points} +4) for\^et de conif\`eres: +4 points} \begin{smallverbatim} r.mapcalc _for="if(vegcover==3,4,0)" \end{smallverbatim} \textbf{ -5) mixed forest: +1 point} +5) for\^et mixte: +1 point} \begin{smallverbatim} r.mapcalc _for1="if(vegcover==5,1,0)" \end{smallverbatim} \textbf{ -6) northern exposure (aspect from NW to NE): +3 points} +6) Exposition Nord (aspect de NO \`a NE): +3 points} \begin{smallverbatim} r.mapcalc _exp3="if(aspect<=135.0 && aspect>=45.0 && aspect != 0,3,0)" \end{smallverbatim} \textbf{ -7a) western or eastern exposure (SW to NW or SE to NE): +1 point} +7a) Exposition Ouest ou Est (SO \`a NO ou SE \`a NE): +1 point} \begin{smallverbatim} r.mapcalc _exp1="if(aspect<45.0 || aspect>314.0,1,0)" r.mapcalc _exp2="if(aspect<225.0 && aspect>135.0,1,0)" \end{smallverbatim} \textbf{ -7b) 1200-1400 meters elevation: +2 points} +7b) 1200-1400 m\`etres d'altitude: +2 points} \begin{smallverbatim} r.mapcalc _elev1="if(elevation.10m<1400 && elevation.10m>1200,2,0)" \end{smallverbatim} \textbf{ -8) 1400-1600 meters elevation: +4 points} +8) 1400-1600 m\`etres d'altitude: +4 points} \begin{smallverbatim} r.mapcalc _elev2="if(elevation.10m<1600 && elevation.10m>=1400,4,0)" \end{smallverbatim} \textbf{ -9) over 1600 meters elevation: +2 points} +9) plus de 1600 m\`etres d'altitude: +2 points} \begin{smallverbatim} r.mapcalc _elev3="if(elevation.10m>=1600,2,0)" \end{smallverbatim} -\subsection{FINALIZING THE SCORING MAP} +\subsection{FINALISATION DE LA CARTE DE SCORE} \begin{smallverbatim} r.buffer input=roads output=_br100 @@ -498,7 +497,7 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.35]{grass021.png} %caption of the figure - \caption{Scoring Map} + \caption{Carte de score} %label of the figure, which has to correspond to \ref{}: \label{fig:grass021} \end{figure} From chemin at grass.itc.it Wed Jun 13 13:54:24 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Wed Jun 13 13:54:26 2007 Subject: [grass-addons] r838 - trunk/grassaddons/tutorials/grass_starter Message-ID: <200706131154.l5DBsOHh017736@grass.itc.it> Author: chemin Date: 2007-06-13 13:54:17 +0200 (Wed, 13 Jun 2007) New Revision: 838 Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex Log: More French Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 11:26:42 UTC (rev 837) +++ trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 11:54:17 UTC (rev 838) @@ -502,20 +502,20 @@ \label{fig:grass021} \end{figure} -\subsection{CLUMPING SUITABLE AREAS} -WARNING: This part of the Laboratory involves the use of the command line (command prompt). +\subsection{METTRE EN BLOC LES ZONES SOUHAITABLES} +ATTENTION: Cette partie demande l'utilisation du prompt/terminal avec des commandes en ligne. -What is ``clumping''? -Recategorizes data in a raster map layer by grouping cells that form physically discrete areas into unique categories. +Qu'est-ce que ``mettre en bloc''? +Re-cat\'egoriser les donn\'ees dans une carte raster en groupant les pixels qui form des surfaces continues physiquement en d'uniques cat\'egories. -Now find the discrete areas (clumps) of aggregated habitat scores. -Run \textit{r.clump (..=>Clump Small Areas) }on the ``\textit{score\_final}'' map to give each clump its own category number. You may call the output ``\textit{score\_clumped}''. +Maintenant, trouvez les zones discr\`etes/continues (ou clumps) des scores d'aggr\'egation d'habitat. +Lancez \textit{r.clump (..=>Clump Small Areas) }sur la carte ``\textit{score\_final}'' pour donner \`a chaque bloc son propre num\'ero de cat\'egorie. Vous pourriez appeler la carte r\'esultante ``\textit{score\_clumped}''. \begin{smallverbatim} r.clump input=score_final output=score_clumped \end{smallverbatim} -Display your newly clumped map ``\textit{score\_clumped}''. It should somewhat look like this one:Fig.~\ref{fig:grass022} +Affichez votre nouvelle carte de blocs ``\textit{score\_clumped}''. Elle devrait plus ou moins ressembler \`a cel\`a:Fig.~\ref{fig:grass022} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -523,20 +523,20 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.35]{grass022.png} %caption of the figure - \caption{Clumped map} + \caption{Carte des blocs} %label of the figure, which has to correspond to \ref{}: \label{fig:grass022} \end{figure} -Since this species is most viable in larger clumps, extract the clumps greater than 50 hectares to a separate map. You may use the command line for reclassification by area threshold to select area superior to 50 hectares: +Puisque cette esp\`ece est mieux dans de larges blocs, faites une extraction des blocs sup\'erieurs a 50 hectares dans une carte sp\'epar\'ee. Vous pourriez utilisez le terminal pour reclassifier par seuil de surface sup\'erieur \`a 50 hectares: \begin{smallverbatim} r.reclass.area input = score_final greater=50 output=selected_habitat_area \end{smallverbatim} -Output ``selected\_habitat\_area'' at this level should be similar to this one:Fig.~\ref{fig:grass023} +R\'esultat ``selected\_habitat\_area'' \`a ce niveau devrait \^etre similaire \`a ceci:Fig.~\ref{fig:grass023} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -544,16 +544,15 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.35]{grass023.png} %caption of the figure - \caption{Seleceted Habitat Areas} + \caption{Zones d'habitat s\'electionn\'ees} %label of the figure, which has to correspond to \ref{}: \label{fig:grass023} \end{figure} -\subsection{EXPORT RESULTS TO VECTOR} -Since the users work in vector GIS, we are going to convert the results in vector format and export them from GRASS GIS to shapefile. +\subsection{EXPORT DES RESULTATS SOUS FORMAT VECTORIEL} +Puisque nos clients travaillent sous SIG \`a format vectoriel, nous allons convertir les r\'esultats en format vectoriel et les exporter de GRASS \`a ESRI shapefile. -Vectorize the clumped map you just produced (File/Map type conversion/raster to vector) and check that you -have effectively created a polygon vector map by displaying your vector using random colors.Fig.~\ref{fig:grass024} +Vectorisez larte de blocs que vous venez de produire (File/Map type conversion/raster to vector) et v\'erifiez que vous avez effectivement cr\'ee une carte vectorielle \`a \'el\'ements de type polygones en affichant votre couche vectorielle avec des couleurs al\'eatoires.Fig.~\ref{fig:grass024} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -561,12 +560,12 @@ %name of your graphic, without the path AND in PNG (screnshots etc)/PDF (drawings) format: \includegraphics[scale=0.35]{grass024.png} %caption of the figure - \caption{Vector Export} + \caption{Export de fichier vectoriel} %label of the figure, which has to correspond to \ref{}: \label{fig:grass024} \end{figure} -Export this selected habitat vector file along with the ``\textit{roads}'' and ``\textit{streams}'' vector files into shapefile. Please be sure that you export the same type of vectors (areas for ``\textit{selected\_habitat\_area}'' and lines for ``\textit{roads}'' and ``\textit{streams}''). Display and query them using Quantum GIS. +Exportez ce fichier vectoriel d'habitat avec ``\textit{roads}'' et ``\textit{streams}'' aussi en format shapefile. Soyez s\^ur que vous exportez le m\^eme type d'\'el\'ements vectoriels (area pour ``\textit{selected\_habitat\_area}'' et lines pour ``\textit{roads}'' et ``\textit{streams}''). Affichez et questionnez ces fichiers dans le SIG Quantum. \begin{smallverbatim} v.out.ogr input=selected_habitat_area type=area From chemin at grass.itc.it Wed Jun 13 14:28:21 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Wed Jun 13 14:28:23 2007 Subject: [grass-addons] r839 - trunk/grassaddons/tutorials/grass_starter Message-ID: <200706131228.l5DCSL5f018504@grass.itc.it> Author: chemin Date: 2007-06-13 14:28:17 +0200 (Wed, 13 Jun 2007) New Revision: 839 Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex Log: More French Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 11:54:17 UTC (rev 838) +++ trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 12:28:17 UTC (rev 839) @@ -578,25 +578,25 @@ layer=1 format=ESRI_Shapefile \end{smallverbatim} -Additional processing..... +Bonus de traitement de donn\'ees..... -The pickled strumpet is quite intolerant of edge disturbances, so you would like to weight interior areas of the habitat clumps more highly than edge areas. Create interior 100-meter-interval buffers within the large habitat clumps, where interior pixels within 100 meters of a clump edge have a weight of 1, interior pixels 100-200 meters from a clump edge have a weight of 2, interior pixels 200-300 meters from a clump edge have a weight of 3, etc., and pixels outside the largest clumps have a weight of zero. +Cette esp\`ece est assez intol\'erante des perturbations aux fronti\`eres de zones, donc vous devriez faire un poids plus lourd pour les zones internes que frontali\`eres des blocs d'habitat. Cr\'eez des buffers internes concentriques de 100 m\`etres pour chaque bloc, avec un poids de 1 pour le premier buffer en fronti\`ere (0-100 m\`etres internes), 2 pour le second vers l'interieur (100-200 m\`etres), 3 pour 200-300 m\`etres, etc..., quand aux pixels en dehors des blocs, leurs valeurs sont de z\'ero. -Use \textit{r.mapcalc} to multiply the aggregate habitat score map by these interior buffer weights. -Now run \textit{r.volume }on this buffer-weighted habitat score map to obtain the sum and average of each clump s cell habitat scores. -Use \textit{awk} to create reclass rules files, then use \textit{r.reclass} to map the largest clumps by sum and average habitat scores. -Which clump has the highest weighted total habitat score? Which has the highest weighted average habitat score? -Use \textit{r.grow} to create a map of clump edges only (subtracting the input map from the output map). -Use the edge map to index the perimeter of each of the major clumps. -Calculate the compactness (area divided by perimeter squared) of each clump. -Map the largest clumps by compactness. Create a jazzy display script to demonstrate your procedures and explain your findings. -(See \href{http://www.udel.edu/johnmack/frec682/script_ideas.html}) +Utilisez \textit{r.mapcalc} pour multiplier la carte d'habitat par les poids des buffers internes. +Maintenant lancez \textit{r.volume }sur cette carte r\'esultante pour obtenir la somme et la moyenne de chaque bloc. +Utilisez \textit{awk} pour cr\'eer des fichiers de r\`egles de r\'eclassification, puis utilisez \textit{r.reclass} pour cartographier les blocs par somme et moyenne. +Quel bloc a le nouveau total maximum? Lequel a la nouvelle moyenne maximum? +Utilisez \textit{r.grow} pour cr\'eer une carte de fronti\`eres de blocs (soustraire les cartes d'origines aux cartes r\'esultantes). +Utilisez les cartes de fronti\`eres de blocs pour indexer le p\'erimetre de chaque bloc majeur. +Calculez la compacit\'e (surface divis\'ee par le carr\'e du p\'erimetre) de chaque bloc. +Cartographiez les blocs par compacit\'e. Cr\'eez un script d'affichage cool pour d\'emontrer vos proc\'edures et expliquez ce que vous avez trouv\'e. +(Pour cel\`a voyez: \href{http://www.udel.edu/johnmack/frec682/script_ideas.html}) -A script for some parts of the Lab is in \textbf{Appendix B} \ref{appendixB}. +Un script de quelques pqrties de cet exercice est dans l'\textbf{Appendice B} \ref{appendixB}. \newpage -\subsection{Appendix A: Overview of Grass GUI} +\subsection{Appendice A: Overview of Grass GUI} \label{appendixA} Overview of the available commands in the modules:Fig.~\ref{fig:grass025} Fig.~\ref{fig:grass026} Fig.~\ref{fig:grass027} From chemin at grass.itc.it Wed Jun 13 14:39:20 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Wed Jun 13 14:39:21 2007 Subject: [grass-addons] r840 - trunk/grassaddons/tutorials/grass_starter Message-ID: <200706131239.l5DCdKCN018894@grass.itc.it> Author: chemin Date: 2007-06-13 14:39:16 +0200 (Wed, 13 Jun 2007) New Revision: 840 Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex Log: More French, end of article_GRASS part Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 12:28:17 UTC (rev 839) +++ trunk/grassaddons/tutorials/grass_starter/FR_article_GRASS.tex 2007-06-13 12:39:16 UTC (rev 840) @@ -596,10 +596,10 @@ \newpage -\subsection{Appendice A: Overview of Grass GUI} +\subsection{Appendice A: SUrvol de l'interface principale de GRASS} \label{appendixA} -Overview of the available commands in the modules:Fig.~\ref{fig:grass025} Fig.~\ref{fig:grass026} Fig.~\ref{fig:grass027} +Survol des commandes disponibles dans les modules:Fig.~\ref{fig:grass025} Fig.~\ref{fig:grass026} Fig.~\ref{fig:grass027} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -636,25 +636,25 @@ \newpage -\subsection{Appendix B: GRASS SCRIPT} +\subsection{Appendice B: SCRIPT dans GRASS} \label{appendixB} -Please put this into a file that you may name \textit{script.sh}\textup{and from a }\textit{Terminal}\textup{ type: ``chmod 0755}\textit{script.sh''}\textup{. Then you can run the script }by typing the command: ``./script.sh''. +Veuillez mettre ceci dans un fichier \textit{script.sh}\textup{et dans un }\textit{Terminal}\textup{ \'ecrivez: ``chmod 0755}\textit{script.sh''}\textup{. Ensuite vous pouvez lancer le script }en \'ecrivant la commande: ``./script.sh''. \begin{smallverbatim} #!/bin/bash -# main map names variables +# Noms des variables de cartes dem=elevation.dem r=roads s=streams -# buffer streams and roads variables +# buffer cours d'eau et routes _bs=_bstreams500 _br=_broads500 -# reclassed buffer streams and roads variables +# reclassement des buffer cours d'eau et routes _rbs=_rbstreams500 _rbr=_rbroads500 #-------------------------------------------------- -# General Presentation: Start Monitor 0 +# Pr\'esentation g\'en\'erale: D\'ebut Affichage 0 #-------------------------------------------------- d.mon start=x0 d.erase color=grey @@ -667,7 +667,7 @@ d.barscale bcolor=white tcolor=black at=30.0,95.0 sleep 2 #-------------------------------------------------- -# Buffering: Start Monitor 1 +# Cr\'eation de buffer: D\'ebut Affichage 1 #-------------------------------------------------- d.mon start=x1 d.mon select=x1 @@ -685,12 +685,12 @@ d.vect map=\$s color=blue d.barscale bcolor=white tcolor=black at=30.0,95.0 #-------------------------------------------------- -# Reclassification: Start Monitor 2 +# Reclassification: D\'ebut Affichage 2 #-------------------------------------------------- d.mon start=x2 d.mon select=x2 d.erase color=grey -echo "...Reclassify..." +echo "...Reclassification..." r.mapcalc \$_rbs="if(\$_bs==2,1,0)" r.mapcalc _s_sl="if(\$_rbs==1,if(slope<=5,2,5),0)" r.mapcalc \$_rbr="float(if(\$_br==2,-5.0,0))" @@ -713,7 +713,7 @@ _exp1+_exp2+_exp3+_elev1+_elev2+_elev3)" r.mapcalc _clas="if(_add{>9,1,null())" r.mapcalc _class="if(_clas==1&&_br100==0,1,null())" -echo "Reclassification...done." +echo "Reclassification...Fin." d.rast map="\$_rbs" sleep 1 d.rast map="_s_sl" @@ -747,10 +747,10 @@ g.remove rast="\$_bs,\$_br,_clas"} sleep 1 echo "" -echo "finished" +echo "fin" sleep 1 #-------------------------------------------------- -# Clumping: Start Monitor 3 +# Mettre en bloc: D\'ebut Affichage 3 #-------------------------------------------------- d.mon start=x3 d.mon select=x3 @@ -772,7 +772,7 @@ sleep 1 g.remove rast="_clump,_class" #-------------------------------------------------- -# R2V and Export: Start Monitor 4 +# R2V et Export: D\'ebut Affichage 4 #-------------------------------------------------- d.mon start=x4 d.mon select=x4 From chemin at grass.itc.it Wed Jun 13 15:08:49 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Wed Jun 13 15:08:50 2007 Subject: [grass-addons] r841 - trunk/grassaddons/tutorials/grass_starter Message-ID: <200706131308.l5DD8nab019124@grass.itc.it> Author: chemin Date: 2007-06-13 15:08:41 +0200 (Wed, 13 Jun 2007) New Revision: 841 Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex Log: More French, beginning of article_QGIS part Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex 2007-06-13 12:39:16 UTC (rev 840) +++ trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex 2007-06-13 13:08:41 UTC (rev 841) @@ -4,16 +4,16 @@ % Head -\title{Starter Manual to Quantum GIS for GRASS GIS} +\title{Manuel de d\'butant du SIG Quantum pour le SIG GRASS} \subtitle{} \author{GRASS Development Team} \maketitle -\section{QUANTUM GIS INTRODUCTION} +\section{INTRODUCTION AU SIG QUANTUM} -This Manual is valid for QGIS version 0.8+ (http://www.qgis.org) -\textbf{Start QGIS}, the first time it should look like Fig.~\ref{fig:qgis000} +Ce Manuel est valide pour QGIS version 0.8 et plus (http://www.qgis.org) +\textbf{Lancez QGIS}, la premi\`ere fois cel\`a doit ressembler \`a Fig.~\ref{fig:qgis000} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -26,7 +26,7 @@ \label{fig:qgis000} \end{figure} -Open some vector layers from QGIS sample data set Fig.~\ref{fig:qgis001} +Ouvrez quelques couches vectorielles venant des exemples de donn\'ees fournies avec QGIS Fig.~\ref{fig:qgis001} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -39,7 +39,7 @@ \label{fig:qgis001} \end{figure} -Select all the layers (Ctrl+a) Fig.~\ref{fig:qgis002} +S\'electionnez toutes les couches (Ctrl+a) Fig.~\ref{fig:qgis002} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -52,7 +52,7 @@ \label{fig:qgis002} \end{figure} -The layers displayed should look like Fig.~\ref{fig:qgis003} +Les couches affich\'ees devraient ressembler \`a cel\`a Fig.~\ref{fig:qgis003} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -65,7 +65,7 @@ \label{fig:qgis003} \end{figure} -Zoom to all layers extents... Fig.~\ref{fig:qgis004} +Zoomez \`a l'\'etendue de toutes les couches ensemble... Fig.~\ref{fig:qgis004} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -78,7 +78,7 @@ \label{fig:qgis004} \end{figure} -Result after zooming to all layers Fig.~\ref{fig:qgis005} +R\'esultat apr\`es le zoom Fig.~\ref{fig:qgis005} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -91,7 +91,7 @@ \label{fig:qgis005} \end{figure} -Set the first layer in the overview frame Fig.~\ref{fig:qgis006} +Mettez la premi\`ere couche dans le cadre de survol Fig.~\ref{fig:qgis006} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -104,7 +104,7 @@ \label{fig:qgis006} \end{figure} -Result... Fig.~\ref{fig:qgis007} +R\'esultat... Fig.~\ref{fig:qgis007} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -117,7 +117,7 @@ \label{fig:qgis007} \end{figure} -Open the plugin menu Fig.~\ref{fig:qgis008} +Ouvrez le menu des plugins Fig.~\ref{fig:qgis008} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -130,7 +130,7 @@ \label{fig:qgis008} \end{figure} -It should look like this Fig.~\ref{fig:qgis009} +Cel\`a devrait ressembler \`a la Fig.~\ref{fig:qgis009} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -143,7 +143,7 @@ \label{fig:qgis009} \end{figure} -Select those plugins Fig.~\ref{fig:qgis010} +S\'electionnez ces plugins Fig.~\ref{fig:qgis010} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -157,7 +157,7 @@ \end{figure} -Some new menus have appeared! Fig.~\ref{fig:qgis011} +De nouveaux menus sont apparus! Fig.~\ref{fig:qgis011} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -171,7 +171,7 @@ \end{figure} -Maximizing QGIS makes more icons appearing... Fig.~\ref{fig:qgis012} +En maximisant QGIS, plus d'ic\^ones apparaissent... Fig.~\ref{fig:qgis012} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -185,8 +185,7 @@ \end{figure} -Drag the new menus below to make them glue to a second level of -toolbars... Fig.~\ref{fig:qgis013} +Tirez les nouveaux menus en-dessous pour les faire coller au deuxi\`eme niveau de barre d'outil... Fig.~\ref{fig:qgis013} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -199,10 +198,9 @@ \label{fig:qgis013} \end{figure} -\section{QUANTUM GIS GRASS PLUGIN} +\section{LE PLUGIN GRASS DANS LE SIG QUANTUM} -Open a GRASS raster layer by clicking on the second button from the -left Fig.~\ref{fig:qgis014} +Ouvrez une couche raster GRASS en cliquant sur le second bouton \`a partir de la gauche Fig.~\ref{fig:qgis014} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -215,8 +213,7 @@ \label{fig:qgis014} \end{figure} -This is the contextual menu that opens, select the Map name as -``elevation.10m'' Fig.~\ref{fig:qgis015} +Ceci est le menu contextuel s'ouvrant, s\'electionnez le nom de carte ``elevation.10m'' Fig.~\ref{fig:qgis015} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -230,7 +227,7 @@ \end{figure} -This is the result of loading the GRASS Raster Layer Fig.~\ref{fig:qgis016} +Ceci est le r\'esultat du chargement de la couche raster de GRASS Fig.~\ref{fig:qgis016} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -243,7 +240,7 @@ \label{fig:qgis016} \end{figure} -Very similarly with other types of data, add the layer to overview Fig.~\ref{fig:qgis017} +De la m\^eme mani\`ere avec d'autres types de donn\'ees, ajoutez cette couche dans le cadre de survol Fig.~\ref{fig:qgis017} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -256,7 +253,7 @@ \label{fig:qgis0017} \end{figure} -Result Fig.~\ref{fig:qgis018} +R\'esultat Fig.~\ref{fig:qgis018} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -269,7 +266,7 @@ \label{fig:qgis018} \end{figure} -Add a GRASS Vector Layer by selecting the first Icon from the left Fig.~\ref{fig:qgis019} +Ajoutez une couche vectorielle de GRASS en s\'electionnant la premi\`ere ic\^one\`a partir de la gauche Fig.~\ref{fig:qgis019} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -282,8 +279,7 @@ \label{fig:qgis019} \end{figure} -This is the contextual menu that opens, select the Map name as -``streams'' and the layer name as ``1\_Line'' Fig.~\ref{fig:qgis020} +Voici le menu contextuel qui s'ouvre, s\'electionnez la carte ayant le nom ``streams'' et sa couche de donn\'ees ``1\_Line'' Fig.~\ref{fig:qgis020} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -296,8 +292,7 @@ \label{fig:qgis020} \end{figure} -This is the streams vector layer, open the properties by a right{}-click -on the name Fig.~\ref{fig:qgis021} +Ceci est la couche vectorielle ``streams'', ouvrez les propri\'et\'es en cliquant sur le bouton droit sur le nom Fig.~\ref{fig:qgis021} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -310,9 +305,7 @@ \label{fig:qgis021} \end{figure} -The Properties box looks like this, and select the ``fill color'' button -to open a color selection dialog box. Change the color to a common Blue -and apply Fig.~\ref{fig:qgis022} Fig.~\ref{fig:qgis023} +La bo\^ite de propri\'et\'es ressemble \`a cel\`a, s\'electionnez le bouton ``fill color'' pour ouvrir une bo\^ite d'outils de s\'election de couleurs. Changez la couleur en un bleu commun et validez Fig.~\ref{fig:qgis022} Fig.~\ref{fig:qgis023} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -336,8 +329,7 @@ \label{fig:qgis023} \end{figure} -Select the first button on the right side to start GRASS vector editing -module Fig.~\ref{fig:qgis024} +S\'electionnez le premier bouton sur la droite pour commencer le module d'\'edition de vecteurs de GRASS Fig.~\ref{fig:qgis024} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -350,8 +342,7 @@ \label{fig:qgis024} \end{figure} -The Edit GRASS Vector dialog box can only be opened when a vector is -selected in the main QGIS window Fig.~\ref{fig:qgis025} +La bo\^ite de dialogue de l'\'editeur de vecteurs de GRASS peut seulement \^etre ouverte si une couche vectorielle est s\'electionn\'ee dans la fen\^etre principale de QGIS Fig.~\ref{fig:qgis025} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -364,8 +355,7 @@ \label{fig:qgis025} \end{figure} -Select the ``moving vertex'' button (5th from the -left) and move the red cross on the map Fig.~\ref{fig:qgis026} +S\'electionnez le bouton ``moving vertex'' (5\`eme de la gauche) et bougez la croix rouge sur la carte Fig.~\ref{fig:qgis026} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -378,8 +368,7 @@ \label{fig:qgis026} \end{figure} -The result should look like this (Fig.~\ref{fig:qgis026}). The last button in the toolbar will -commit the modifications to the vector layer and rebuild it Fig.~\ref{fig:qgis027} +Le r\'esultat devrait ressembler \`a ceci (Fig.~\ref{fig:qgis026}). Le dernier bouton de la barre d'outils va enregistrer les modifications effectu\'ees sur la couche vectorielle et la reconstruire Fig.~\ref{fig:qgis027} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -392,7 +381,7 @@ \label{fig:qgis027} \end{figure} -In the launching terminal, the commit changes are described Fig.~\ref{fig:qgis028} +Dans le terminal de lancement, l'enregistrement des changements apparaissent Fig.~\ref{fig:qgis028} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -405,7 +394,7 @@ \label{fig:qgis028} \end{figure} -Set GRASS plugin environment for processing... Fig.~\ref{fig:qgis029} +Mettez en place l'environnement du plugin GRASS pour le traitement de donn\'ees... Fig.~\ref{fig:qgis029} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] From chemin at grass.itc.it Wed Jun 13 15:42:31 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Wed Jun 13 15:42:32 2007 Subject: [grass-addons] r842 - trunk/grassaddons/tutorials/grass_starter Message-ID: <200706131342.l5DDgVjM019181@grass.itc.it> Author: chemin Date: 2007-06-13 15:42:24 +0200 (Wed, 13 Jun 2007) New Revision: 842 Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex Log: More French, article_QGIS done Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex 2007-06-13 13:08:41 UTC (rev 841) +++ trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex 2007-06-13 13:42:24 UTC (rev 842) @@ -407,12 +407,7 @@ \label{fig:qgis029} \end{figure} -Following this, select the 3rd icon from the left on -the GRASS toolbar. This will open the GRASS processing tool as shown -(mostly) in the next three pages. This GRASS tool is a thin -representation of the GRASS GIS capacities, but it will serve the -purpose of this introduction. It comes with a browser of the GRASS -mapset used. It also acts as a data management interface. Fig.~\ref{fig:qgis030} +Suivant ceci, s\'electionnez la 3\`eme ic\^one de gauche sur la barre d'outil GRASS. Cel\`a ouvrira l'outil de traitement de donn\'ees comme vu plus ou moins dans les 3 prochaines pages. Cet outil GRASS est une repr\'esentation mince des capacit\'es de GRASS, mais il va suffir aux besoins de cette introduction. Il est fournit avec un navigateur de jeu de cartes GRASS. Il agit aussi en temps qu'interface de gestion de donn\'ees. Fig.~\ref{fig:qgis030} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -425,8 +420,7 @@ \label{fig:qgis030} \end{figure} -The browser has the capacity to expand header information and metadata -pertaining to the layer selected Fig.~\ref{fig:qgis031} +Le navigateur a la capacit\'e d'ouvrir les informations d'en-t\^ete et de m\'eta-donn\'ees contenues dans les couches s\'electionn\'ees Fig.~\ref{fig:qgis031} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -439,10 +433,7 @@ \label{fig:qgis031} \end{figure} -The GRASS modules available are listed in the next two pages. More are -being ported everyday, The actual number of GRASS GIS modules exceeds -400, you can see that there is still some work to do, and the community -of volunteers are working on it Fig.~\ref{fig:qgis032} Fig.~\ref{fig:qgis033} +Les modules GRASS disponibles sont list\'es dans les deux prochaines pages. Plus de modules sont int\'egr\'es tous les jours, le nombre actuel de modules de GRASS d\'epasse les 400, vous pouvez voir qu'il y a toujours du travail \`a faire, et que la communaut\'e de volontaires y travaillent Fig.~\ref{fig:qgis032} Fig.~\ref{fig:qgis033} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -466,11 +457,9 @@ \label{fig:qgis033} \end{figure} -\subsection{GRASS PLUGIN PROCESSING} +\subsection{TRAITEMENT DE DONNEES AVEC LE PLUGIN GRASS} -Let us create some buffers... Select buffering of vectors from the -Modules list. It should looks like this. Choose 500 meters buffer -size Fig.~\ref{fig:qgis034} +Cr\'eons quelques buffers (zones tampon)... S\'electionnez ``buffering of vectors'' dans la liste des modules. Cel\`a devrait ressembler \`a ceci. Choisissez ue taille de zone tampon de 500 m\`etres Fig.~\ref{fig:qgis034} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -483,7 +472,7 @@ \label{fig:qgis034} \end{figure} -Processing is going on... Fig.~\ref{fig:qgis035} +Traitement de donn\'ees en cours... Fig.~\ref{fig:qgis035} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -496,7 +485,7 @@ \label{fig:qgis035} \end{figure} -Finishing the processing Fig.~\ref{fig:qgis036} +Fin du traitement de donn\'ees Fig.~\ref{fig:qgis036} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -509,7 +498,7 @@ \label{fig:qgis036} \end{figure} -Result should look like this (you have to load the map yourself!) Fig.~\ref{fig:qgis037} +Le r\'esultat devrait ressembler \`a cel\`a (Vous devrez charger la carte vous-m\^eme!) Fig.~\ref{fig:qgis037} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -522,8 +511,7 @@ \label{fig:qgis037} \end{figure} -Now create another buffer from streams but this time at 100 meters... -Like this Fig.~\ref{fig:qgis038} +Maintenant cr\'eez une autre zone tampon \`a partir de ``streams'' mais cette fois de 100 m\`etres... Comme ceci Fig.~\ref{fig:qgis038} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -536,9 +524,7 @@ \label{fig:qgis038} \end{figure} -Now we are going to subtract the 100m buffer to the 500m buffer, because -we want to exclude the streams and its proximity from our area of -selection. Find this module! Fig.~\ref{fig:qgis039} +Maintenant nous allons soustraire le buffer de 100m au buffer de 500m, car nous voulons exclure le cours d'eau et sa zone de proximit\'e de notre zone de s\'election. Trouvez ce module! Fig.~\ref{fig:qgis039} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -551,7 +537,7 @@ \label{fig:qgis039} \end{figure} -Processing the overlay with boolean operator ``NOT'' Fig.~\ref{fig:qgis040} +Traitement de la superimposition de couches avec l'op\'erateur bool\'een ``NOT'' Fig.~\ref{fig:qgis040} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -564,8 +550,7 @@ \label{fig:qgis040} \end{figure} -Result is discarding all under 100m from the streams, and all above 500 -meters from the streams. Fig.~\ref{fig:qgis041} +Le r\'esultat est d'enlever tout dans les 100m des cours d'eau, et tout au-del\`a des 500m des cours d'eau. Fig.~\ref{fig:qgis041} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -578,7 +563,7 @@ \label{fig:qgis041} \end{figure} -Process an aspect map from the elevation map Fig.~\ref{fig:qgis042} +Traitement d'un carte d'aspect \`a partir de la carte d'altitude Fig.~\ref{fig:qgis042} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] @@ -591,7 +576,7 @@ \label{fig:qgis042} \end{figure} -Processing... Fig.~\ref{fig:qgis043} +Traitement en cours... Fig.~\ref{fig:qgis043} %\setkeys{Gin}{width=1\textwidth} \begin{figure}[htbp] From chemin at grass.itc.it Wed Jun 13 15:48:06 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Wed Jun 13 15:48:07 2007 Subject: [grass-addons] r843 - trunk/grassaddons/tutorials/grass_starter Message-ID: <200706131348.l5DDm6FD019223@grass.itc.it> Author: chemin Date: 2007-06-13 15:47:55 +0200 (Wed, 13 Jun 2007) New Revision: 843 Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex Log: More French, article_QGIS typo Modified: trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex =================================================================== --- trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex 2007-06-13 13:42:24 UTC (rev 842) +++ trunk/grassaddons/tutorials/grass_starter/FR_article_QGIS.tex 2007-06-13 13:47:55 UTC (rev 843) @@ -4,7 +4,7 @@ % Head -\title{Manuel de d\'butant du SIG Quantum pour le SIG GRASS} +\title{Manuel de de\'butant du SIG Quantum pour le SIG GRASS} \subtitle{} \author{GRASS Development Team} From barton at grass.itc.it Thu Jun 14 07:24:46 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Jun 14 07:24:48 2007 Subject: [grass-addons] r844 - trunk/grassaddons/gui/gui_modules Message-ID: <200706140524.l5E5OkJ8031065@grass.itc.it> Author: barton Date: 2007-06-14 07:24:38 +0200 (Thu, 14 Jun 2007) New Revision: 844 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Added in v.transform. Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-13 13:47:55 UTC (rev 843) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-14 05:24:38 UTC (rev 844) @@ -346,6 +346,7 @@ ("","","", ""), ("Create labels", "Create text label file for vector features", "self.OnMenuCmd", "v.label"), ("","","", ""), + ("Reposition vector", "Reposition (shift and rotate) vector file in coordinate space", "self.OnMenuCmd", "v.transform"), ("Reproject vector", "Reproject vector from other location", "self.OnMenuCmd", "v.proj"), ("","","", "") )), From maldacker at grass.itc.it Thu Jun 14 16:18:01 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Thu Jun 14 16:18:02 2007 Subject: [grass-addons] r845 - trunk/grassaddons/v.path.obstacles Message-ID: <200706141418.l5EEI1TQ003042@grass.itc.it> Author: maldacker Date: 2007-06-14 16:17:56 +0200 (Thu, 14 Jun 2007) New Revision: 845 Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.c trunk/grassaddons/v.path.obstacles/rotation_tree.h trunk/grassaddons/v.path.obstacles/visibility.c Log: modified the before function to actually compute the correct distance from a point to a line Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.c =================================================================== --- trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-14 05:24:38 UTC (rev 844) +++ trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-14 14:17:56 UTC (rev 845) @@ -119,18 +119,45 @@ return p->line->p1; } +double segment_sqdistance( struct Point * q, struct Line * e ) +{ + double e2e1x = e->p1->x - e->p2->x ; + double e2e1y = e->p1->y - e->p2->y; + + double qe1x = q->x - e->p1->x; + double qe1y = q->y - e->p1->y; + + double qe2x = q->x - e->p2->x; + double qe2y = q->y - e->p2->y; + + double s = e2e1x * qe2x + e2e1y * qe2y; + double t; + + if ( s <= 0 ) + return qe2x * qe2x + qe2y * qe2y; + + t = e2e1x * e2e1x + e2e1y * e2e1y; + + if ( s >= t ) + return qe1x * qe1x + qe1y * qe1y; + + return qe2x * qe2x + qe2y * qe2y - s * s / t ; + +} + int before( struct Point * p, struct Point * q, struct Line * e ) { /* true if q lies nearer to p than segment e*/ - if ( e == NULL ) - return 1; + /* first determine the square distance between p and e */ - double pq = (p->x - q->x)*(p->x - q->x) + (p->y - q->y)*(p->y - q->y); - double pe1 = (p->x - e->p1->x)*(p->x - e->p1->x) + ( p->y - e->p1->y)*( p->y - e->p1->y) ; - double pe2 = (p->x - e->p2->x)*(p->x - e->p2->x) + (p->y - e->p2->y)*(p->y - e->p2->y); + G_message("Computing distances with line %d", e); + //if ( e == NULL ) + return 1; - return ( pq < pe1 && pq < pe2 ); + /*double e_distance = segment_sqdistance(p, e); + double pq_distance = ( p->x - q->x ) * ( p->x - q->x ) + ( p->y - q->y ) * ( p->y - q->y ); + */ } Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.h =================================================================== --- trunk/grassaddons/v.path.obstacles/rotation_tree.h 2007-06-14 05:24:38 UTC (rev 844) +++ trunk/grassaddons/v.path.obstacles/rotation_tree.h 2007-06-14 14:17:56 UTC (rev 845) @@ -49,7 +49,9 @@ struct Point * other( struct Point * p ); int before( struct Point * p, struct Point * q, struct Line * e ); +double segment_sqdistance( struct Point * p, struct Line * e ); + #endif Modified: trunk/grassaddons/v.path.obstacles/visibility.c =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-14 05:24:38 UTC (rev 844) +++ trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-14 14:17:56 UTC (rev 845) @@ -96,43 +96,50 @@ void init_vis( struct Point * points, struct Line * lines, int num ) { + /* this algorithm can be optimised with a scan line technic which runs in O( n log n ) instead of O( n^2 ); */ int i; int j; - int current = 0; - int null=0; - double y; + int current = -1; + double current_distance = PORT_DOUBLE_MAX; + double s; for ( i = 0 ; i < num ; i++ ) { - for ( j = 1 ; j < num/2 ; j++ ) + for ( j = 0 ; j < num/2 ; j++ ) { + if ( &lines[j] == segment( &points[i]) ) + continue; + if ( points[i].y < lines[j].p1->y && points[i].y < lines[j].p2->y ) { - if ( lines[current].p1->y < lines[current].p2->y ) - y = lines[current].p1->y; - else - y = lines[current].p2->y; - - if ( lines[j].p1->y < y || lines[j].p2->y < y ) + //G_message("considering line %d", &lines[j]); + + s = segment_sqdistance( &points[i], &lines[j]); + + //G_message("Distance to considered line is %f and to current line is %f", s,current_distance); + + if( s < current_distance) { current = j; - null =1; + current_distance = s; } } } - if ( null == 0 ) + if ( current == -1 ) { points[i].vis = NULL; } else { points[i].vis = &lines[current]; + current = -1; + current_distance = PORT_DOUBLE_MAX; } - current = 0; - null = 0; + G_message("VIS of point %d is %d", &points[i], points[i].vis ); + } } @@ -140,15 +147,18 @@ { if ( q == other(p) ) { + G_message("It's the other"); report( p, q, out ); } else if ( segment(q) == p->vis ) { + G_message("Its the vis!!!!"); p->vis = q->vis ; report( p,q, out ); } else if ( before(p,q, p->vis ) ) { + G_message("before!!"); p->vis = segment(q); report(p,q,out); } @@ -234,7 +244,7 @@ push( &points[0] ); - G_message("p_infinity is %d and p_ninfinity is %d ", p_infinity, p_ninfinity ); + //G_message("p_infinity is %d and p_ninfinity is %d ", p_infinity, p_ninfinity ); while( !empty_stack() ) { @@ -243,8 +253,8 @@ p_r = right_brother(p); q = father(p); - G_message("---------"); - G_message("p is %d and q is %d and p_r is %d", p, q ,p_r); + //G_message("---------"); + //G_message("p is %d and q is %d and p_r is %d", p, q ,p_r); if ( q != p_ninfinity ) { @@ -254,14 +264,14 @@ z = left_brother(q); - G_message("z is %d", z ); - if ( z!= NULL ) G_message("father(z) is %d", father(z) ); + //G_message("z is %d", z ); + //if ( z!= NULL ) G_message("father(z) is %d", father(z) ); remove_point(p); if ( z == NULL || !left_turn(p,z, father(z) ) ) { - G_message("adding p leftof q "); + //G_message("adding p leftof q "); add_leftof(p,q); } else @@ -272,27 +282,27 @@ add_rightmost(p,z); - G_message("add p as rightmost son of z which is %d", z); + //G_message("add p as rightmost son of z which is %d", z); if ( z == top() ) z = pop(); } - G_message("father(p) is now %d", father(p) ); + //G_message("father(p) is now %d", father(p) ); if ( left_brother(p) == NULL && father(p) != p_infinity ) { - G_message("pushing p"); + //G_message("pushing p"); push(p); } if ( p_r != NULL ) { push(p_r); - G_message("pushing p_r "); + //G_message("pushing p_r "); } - G_message("The stack has %d points", stack_index); + //G_message("The stack has %d points", stack_index); } } From barton at grass.itc.it Thu Jun 14 21:06:57 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Jun 14 21:06:58 2007 Subject: [grass-addons] r846 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200706141906.l5EJ6ven006698@grass.itc.it> Author: barton Date: 2007-06-14 21:06:49 +0200 (Thu, 14 Jun 2007) New Revision: 846 Modified: trunk/grassaddons/gui/gui_modules/menudata.py trunk/grassaddons/gui/wxgui.py Log: Added new mapset access setting dialog. Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-14 14:17:56 UTC (rev 845) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-14 19:06:49 UTC (rev 846) @@ -135,7 +135,7 @@ ("Set region", "Change region settings", "self.OnMenuCmd", "g.region"), )), ("GRASS working environment", ( - ("Mapset access (not functional)", "Set access to other mapsets in current location", "self.OnMapsets", ""), + ("Mapset access", "Set/unset access to other mapsets in current location", "self.OnMapsets", ""), ("Change working environment", "Change current working session to new mapset, location, or data directory", "self.OnMenuCmd", "g.mapset"), ("User access", "Change access by other users to current mapset", "self.OnMenuCmd", "g.access"), ("Show settings", "Show current GRASS environment settings", "self.RunMenuCmd", ['g.gisenv',' ']), Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-14 14:17:56 UTC (rev 845) +++ trunk/grassaddons/gui/wxgui.py 2007-06-14 19:06:49 UTC (rev 846) @@ -297,10 +297,29 @@ def OnMapsets(self, event): """ - Launch mapset access module + Launch mapset access dialog """ - pass + dlg = MapsetAccess(self, wx.ID_ANY) + dlg.CenterOnScreen() + + # if OK is pressed... + if dlg.ShowModal() == wx.ID_OK: + # create string of accessible mapsets + ms_string = 'PERMANENT' + if dlg.curr_mapset == 'PERMANENT': + ms_string = 'PERMANENT' + else: + ms_string = 'PERMANENT,%s' % dlg.curr_mapset + for mset in dlg.all_mapsets: + index = dlg.all_mapsets.index(mset) + if dlg.mapsetlb.IsChecked(index): + ms_string += ',%s' % mset + + # run g.mapsets with string of accessible mapsets + cmdlist = ['g.mapsets', 'mapset=%s' % ms_string] + cmd.Command(cmdlist) + def OnRDigit(self, event): """ Launch raster digitizing module @@ -363,7 +382,6 @@ input and processes rules """ command = self.GetMenuCmd(event) - print 'command=',command dlg = rules.RulesText(self, cmd=command) if dlg.ShowModal() == wx.ID_OK: gtemp = utils.GetTempfile() @@ -786,6 +804,86 @@ dlg.ShowModal() dlg.Destroy() +class MapsetAccess(wx.Dialog): + """ + Controls setting options and displaying/hiding map overlay decorations + """ + def __init__(self, parent, id, title=_('Set/unset access to mapsets in current location'), + pos=wx.DefaultPosition, size=(-1,-1), + style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER): + wx.Dialog.__init__(self, parent, id, title, pos, size, style) + + cmdlist = ['g.mapsets', '-l'] + self.all_mapsets = cmd.Command(cmdlist).module_stdout.read().strip().split(' ') + for mset in self.all_mapsets: + indx = self.all_mapsets.index(mset) + self.all_mapsets[indx] = mset.strip('\n') + + cmdlist = ['g.mapsets', '-p'] + self.accessible_mapsets = cmd.Command(cmdlist).module_stdout.read().strip().split(' ') + for mset in self.accessible_mapsets: + indx = self.accessible_mapsets.index(mset) + self.accessible_mapsets[indx] = mset.strip('\n') + + cmdlist = ['g.gisenv', 'get=MAPSET'] + self.curr_mapset = cmd.Command(cmdlist).module_stdout.read().strip() + + + # remove PERMANENT and current mapset from list because they are always accessible + self.PERMANENT_ndx = self.all_mapsets.index("PERMANENT") + self.all_mapsets.pop(self.PERMANENT_ndx) + if self.curr_mapset != "PERMANENT": + self.curr_ndx = self.all_mapsets.index(self.curr_mapset) + self.all_mapsets.pop(self.curr_ndx) + + # make a checklistbox from available mapsets and check those that are active + sizer = wx.BoxSizer(wx.VERTICAL) + + box = wx.BoxSizer(wx.HORIZONTAL) + if len(self.all_mapsets) == 0: + label = wx.StaticText(self, -1, "No other accessible mapsets besides \ + \nPERMANENT and current mapset.", + style=wx.ALIGN_CENTRE) + else: + label = wx.StaticText(self, -1, "Check mapset to make it accessible, uncheck it to hide it.\ + \nPERMANENT and current mapset are always accessible.", + style=wx.ALIGN_CENTRE) + box.Add(label, 0, wx.ALIGN_CENTRE) + sizer.Add(box, 0, wx.ALIGN_CENTRE|wx.TOP|wx.BOTTOM, 5) + + box = wx.BoxSizer(wx.HORIZONTAL) + self.mapsetlb = wx.CheckListBox(self, -1, pos=wx.DefaultPosition, + size=(350,200), choices=self.all_mapsets) + box.Add(self.mapsetlb, 0, wx.ALIGN_CENTRE) + sizer.Add(box, 0, wx.ALIGN_CENTRE|wx.TOP|wx.BOTTOM, 5) + + # check all accessible mapsets + for mset in self.accessible_mapsets: + if mset != 'PERMANENT' and mset != self.curr_mapset: + self.mapsetlb.Check(self.all_mapsets.index(mset),True) + + # dialog buttons + line = wx.StaticLine(self, -1, size=(-1,-1), style=wx.LI_HORIZONTAL) + sizer.Add(line, 0, wx.EXPAND|wx.ALIGN_CENTRE|wx.TOP|wx.BOTTOM, 5) + + btnsizer = wx.StdDialogButtonSizer() + + okbtn = wx.Button(self, wx.ID_OK) + okbtn.SetDefault() + btnsizer.AddButton(okbtn) + + cancelbtn = wx.Button(self, wx.ID_CANCEL) + btnsizer.AddButton(cancelbtn) + btnsizer.Realize() + + sizer.Add(btnsizer, 0, wx.EXPAND|wx.ALIGN_RIGHT|wx.ALL, 5) + + self.Layout() + self.SetSizer(sizer) + + sizer.Fit(self) + + class GMApp(wx.App): """ GMApp class From barton at grass.itc.it Fri Jun 15 06:59:20 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 15 06:59:23 2007 Subject: [grass-addons] r847 - trunk/grassaddons/gui/gui_modules Message-ID: <200706150459.l5F4xKgv011685@grass.itc.it> Author: barton Date: 2007-06-15 06:59:11 +0200 (Fri, 15 Jun 2007) New Revision: 847 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Added r.out.ppm3 to menu Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-14 19:06:49 UTC (rev 846) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-15 04:59:11 UTC (rev 847) @@ -75,6 +75,7 @@ ("MPEG-1", "Export MPEG-1 animations", "self.OnMenuCmd", "r.out.mpeg"), ("PNG", "Export PNG image (not georeferenced)", "self.OnMenuCmd", "r.out.png"), ("PPM", "Export PPM image (24bit)", "self.OnMenuCmd", "r.out.ppm"), + ("PPM from RGB", "Export PPM image from red, green, blue raster maps", "self.OnMenuCmd", "r.out.ppm3"), ("POV-Ray", "Export POVray height-field", "self.OnMenuCmd", "r.out.pov"), ("TIFF", "Export TIFF image (8/24bit)", "self.OnMenuCmd", "r.out.tiff"), ("VRML", "Export VRML file", "self.OnMenuCmd", "r.out.vrml"), From barton at grass.itc.it Fri Jun 15 07:13:52 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 15 07:13:53 2007 Subject: [grass-addons] r848 - trunk/grassaddons/gui/gui_modules Message-ID: <200706150513.l5F5Dqk3011720@grass.itc.it> Author: barton Date: 2007-06-15 07:13:44 +0200 (Fri, 15 Jun 2007) New Revision: 848 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Minor name change Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-15 04:59:11 UTC (rev 847) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-15 05:13:44 UTC (rev 848) @@ -85,7 +85,6 @@ ("Multiple formats using OGR", "Export multiple formats using OGR", "self.OnMenuCmd", "v.out.ogr"), ("","","", ""), ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.out.ascii"), - ("DXF", "Export DXF file", "self.OnMenuCmd", "v.out.dxf"), ("POV-Ray", "Export POV-Ray format file", "self.OnMenuCmd", "v.out.pov"), ("SVG", "Export SVG file", "self.OnMenuCmd", "v.out.svg"), @@ -117,7 +116,7 @@ ("Vector to volume", "Convert vector 3D points to volume voxels", "self.OnMenuCmd", "v.to.rast3"), ("Sites to vector", "Convert sites (GRASS 5) to vector map", "self.OnMenuCmd", "v.in.sites"), ("","","", ""), - ("Volumes to raster series", "Convert raster to vector map", "self.OnMenuCmd", "r3.to.rast"), + ("Volume to raster series", "Convert raster to vector map", "self.OnMenuCmd", "r3.to.rast"), )), ("","","", ""), ("Georectify (not functional)", "Georectify raster and vector maps", "self.OnGeorectify", ""), From barton at grass.itc.it Fri Jun 15 09:57:35 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 15 09:57:37 2007 Subject: [grass-addons] r849 - trunk/grassaddons/gui/gui_modules Message-ID: <200706150757.l5F7vZLQ013270@grass.itc.it> Author: barton Date: 2007-06-15 09:57:26 +0200 (Fri, 15 Jun 2007) New Revision: 849 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Minor menu updates and corrections Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-15 05:13:44 UTC (rev 848) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-15 07:57:26 UTC (rev 849) @@ -143,7 +143,9 @@ ("Version", "Show current GRASS version", "self.RunMenuCmd", ['g.version','-c']), )), ("Manage projections", ( - ("Projections", "Show projection information and create projection files", "self.OnMenuCmd", "g.proj"), + ("Manage projections", "Show projection information and create projection files", "self.OnMenuCmd", "g.proj"), + ("Projection for current location", "Create/edit projection information for current location", "self.OnXTerm", "g.setproj"), + ("","","", ""), ("Convert coordinates", "Convert coordinates from one projection to another", "self.OnMenuCmd", "m.proj"), )), ("Display font", "Set default font for GRASS displays", "self.DefaultFont", ""), @@ -156,8 +158,8 @@ ("","","", ""), ("Boundaries", "Manage boundary definition", "self.OnMenuCmd", "r.region"), ("Null values", "Manage null values", "self.OnMenuCmd", "r.null"), + ("Quantization", "Quantization for floating-point maps", "self.OnMenuCmd", "r.quant"), ("Timestamp", "Manage timestamp for files", "self.OnMenuCmd", "r.timestamp"), - ("Quantization", "Quantization for floating-point maps", "self.OnMenuCmd", "r.quant"), ("","","", ""), ("Resample using aggregate statistics", "Resample (change resolution) using aggregate statistics", "self.OnMenuCmd", "r.resamp.stats"), ("Resample using multiple methods", "Resample (change resolution) using nearest neighbor, bilinear, or bicubic interpolation", "self.OnMenuCmd", "r.resamp.interp"), @@ -181,8 +183,8 @@ ("Query by coordinates", "Query by coordinates", "self.OnMenuCmd", "r.what"), ("","","", ""), ("Buffers", "Develop raster buffer", "self.OnMenuCmd", "r.buffer"), + ("Closest points", "r.distance", "self.OnMenuCmd", "r.distance"), ("MASK", "Develop raster mask", "self.OnMenuCmd", "r.mask"), - ("Closest points", "r.distance", "self.OnMenuCmd", "r.distance"), ("Map calculator", "Map calculator", "self.OnMenuCmd", "scripts/mapcalc_gparser.sh"), ("Neighborhood analysis", ( ("Moving window", "Moving window analysis of raster cells", "self.OnMenuCmd", "r.neighbors"), @@ -197,16 +199,19 @@ )), ("Solar radiance and shadows", ( ("Solar irradiance and irradiation", "Solar irradiance and daily irradiation", "self.OnMenuCmd", "r.sun"), - ("Shadow map", "Shadow map for sun position or date/time", "self.OnMenuCmd", "r.sunmask"), + ("Shadows map", "Shadows map for sun position or date/time", "self.OnMenuCmd", "r.sunmask"), )), ("Terrain analysis", ( ("Cumulative movement costs", "Calculate cumulative movement costs between locales", "self.OnMenuCmd", "r.walk"), - ("cost surface", "cost surface", "self.OnMenuCmd", "r.cost"), + ("Cost surface", "cost surface", "self.OnMenuCmd", "r.cost"), ("Least cost route or flow", "Least cost route or flow", "self.OnMenuCmd", "r.drain"), + ("","","", ""), ("Shaded relief", "Shaded relief map", "self.OnMenuCmd", "r.shaded.relief"), + ("","","", ""), ("Slope and aspect", "Slope and aspect", "self.OnMenuCmd", "r.slope.aspect"), ("Terrain parameters", "Terrain parameters", "self.OnMenuCmd", "r.param.scale"), ("Textural features", "Textural features", "self.OnMenuCmd", "r.texture"), + ("","","", ""), ("Visibility", "Visibility and line of sight", "self.OnMenuCmd", "r.los"), )), ("Transform features", ( @@ -217,14 +222,18 @@ ("","","", ""), ("Hydrologic modeling", ( ("Carve stream channels", "Carve stream channels into elevation map using vector streams map", "self.OnMenuCmd", "r.carve"), - ("Depressionless elevation and flowline map", "Depressionless elevation map and flowline map", "self.OnMenuCmd", "r.fill.dir"), ("Fill lake", "Fill lake from seed point to specified level", "self.OnMenuCmd", "r.lake"), + ("","","", ""), + ("Depressionless map and flowlines", "Depressionless elevation map and flowline map", "self.OnMenuCmd", "r.fill.dir"), ("Flow accumulation", "Flow accumulation for massive grids", "self.OnMenuCmd", "r.terraflow"), ("Flow lines", "Generate flow lines for raster map", "self.OnMenuCmd", "r.flow"), - ("Overland flow modeling", "SIMWE overland flow modeling", "self.OnMenuCmd", "r.sim.water"), - ("Sediment modeling", "SIMWE sediment erosion, transport, deposition modeling", "self.OnMenuCmd", "r.sim.sediment"), + ("","","", ""), + ("SIMWE Overland flow modeling", "SIMWE overland flow modeling", "self.OnMenuCmd", "r.sim.water"), + ("SIMWE Sediment flux modeling", "SIMWE sediment erosion, transport, deposition modeling", "self.OnMenuCmd", "r.sim.sediment"), + ("","","", ""), ("Topographic index map", "Topographic index map", "self.OnMenuCmd", "r.topidx"), ("TOPMODEL simulation", "TOPMODEL simulation", "self.OnMenuCmd", "r.topmodel"), + ("","","", ""), ("Watershed subbasins", "Watershed subbasins", "self.OnMenuCmd", "r.basins.fill"), ("Watershed analysis", "Watershed analysis", "self.OnMenuCmd", "r.watershed"), ("Watershed basin creation", "Watershed basin creation", "self.OnMenuCmd", "r.water.outlet"), @@ -244,8 +253,8 @@ ("","","", ""), ("Patch area mean", "Calculate mean patch size index using a 4 neighbour algorithm", "self.OnMenuCmd", "r.li.mps"), ("Patch area range", "Calculate range of patch area size", "self.OnMenuCmd", "r.li.padrange"), - ("Patch area SD", "Calculate standard deviation of patch area", "self.OnMenuCmd", "r.li.padsd"), - ("Patch area CV", "Calculate coefficient of variation of patch area", "self.OnMenuCmd", "r.li.padcv"), + ("Patch area Std Dev", "Calculate standard deviation of patch area", "self.OnMenuCmd", "r.li.padsd"), + ("Patch area Coeff Var", "Calculate coefficient of variation of patch area", "self.OnMenuCmd", "r.li.padcv"), ("Patch density", "Calculate patch density index using a 4 neighbour algorithm", "self.OnMenuCmd", "r.li.patchdensity"), ("Patch number", "Calculate patch number index using a 4 neighbour algorithm", "self.OnMenuCmd", "r.li.patchnum"), ("","","", ""), @@ -257,13 +266,13 @@ ("Shape index", "Calculate shape index", "self.OnMenuCmd", "r.li.shape"), )), ("Wildfire modeling", ( - ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.OnMenuCmd", "r.ros"), - ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.OnMenuCmd", "r.spreadpath"), - ("Simulate anisotropic spread phenomena", "Simulate anisotropic spread phenomena", "self.OnMenuCmd", "r.spread"), + ("Rate of spread", "Generate rate of spread (ROS) maps", "self.OnMenuCmd", "r.ros"), + ("Least-cost spread paths", "Generate least-cost spread paths", "self.OnMenuCmd", "r.spreadpath"), + ("Anisotropic spread simulation", "Simulate anisotropic spread phenomena", "self.OnMenuCmd", "r.spread"), )), ("","","", ""), ("Change category values and labels", ( - ("Interactively edit category values (not functional)", "Edit category values of individual cells for displayed raster map", "self.OnMenuCmd", "d.rast.edit"), + ("Interactively edit category values", "Edit category values of individual cells for displayed raster map", "self.OnMenuCmd", "d.rast.edit"), ("","","", ""), ("Reclassify by size", "Reclassify categories for areas of specified sizes", "self.OnMenuCmd", "r.reclass.area"), ("Reclassify using rules", "Reclassify categories interactively with rules", "self.RulesCmd", "r.reclass"), @@ -276,15 +285,15 @@ ("Rescale with histogram", "Rescale categories with equalized histogram (create new map)", "self.OnMenuCmd", "r.rescale.eq"), )), ("","","", ""), - ("Generate concentric circles around points", "Generate concentric circles around points", "self.OnMenuCmd", "r.circle"), - ("Generate random raster cells", ( - ("Generate random cells", "Generate random cells", "self.OnMenuCmd", "r.random.cells"), - ("Generate random cells and vector points from raster map", "Generate random cells and vector points from raster map", "self.OnMenuCmd", "r.random"), + ("Concentric circles", "Generate concentric circles around points", "self.OnMenuCmd", "r.circle"), + ("Generate random cells", ( + ("Random cells", "Generate random cells", "self.OnMenuCmd", "r.random.cells"), + ("Random cells and vector points ", "Generate random cells and vector points from raster map", "self.OnMenuCmd", "r.random"), )), ("Generate surfaces", ( ("Fractal surface", "Generate fractal surface", "self.OnMenuCmd", "r.surf.fractal"), ("","","", ""), - ("Gaussian kernel surface", "Generate density surface using moving Gaussian kernel", "self.OnMenuCmd", "v.kernel"), + ("Gaussian kernel density surface", "Generate density surface using moving Gaussian kernel", "self.OnMenuCmd", "v.kernel"), ("Gaussian deviates surface", "Generate gaussian deviates surface", "self.OnMenuCmd", "r.surf.gauss"), ("","","", ""), ("Plane", "Generate plane", "self.OnMenuCmd", "r.plane"), @@ -295,13 +304,14 @@ ("Generate contour lines", "Generate vector contour lines", "self.OnMenuCmd", "r.contour"), ("Interpolate surfaces", ( ("Bilinear from raster points", "Bilinear interpolation from raster points", "self.OnMenuCmd", "r.bilinear"), - ("Inverse distance weighted from raster points", "Inverse distance weighted interpolation from raster points", "self.OnMenuCmd", "r.surf.idw"), + ("Bilinear and bicubic from vector points", "Bicubic and bilinear interpolation with Tykhonov regularization from vector points", "self.OnMenuCmd", "v.surf.bspline"), + ("","","", ""), + ("IDW from raster points", "Inverse distance weighted interpolation from raster points", "self.OnMenuCmd", "r.surf.idw"), + ("IDW from vector points", "Inverse distance weighted interpolation from vector points", "self.OnMenuCmd", "v.surf.idw"), + ("","","", ""), ("Raster contours", "Interpolation from raster contour", "self.OnMenuCmd", "r.surf.contour"), + ("Regularized spline tension ", "Regularized spline tension interpolation from vector points or contours", "self.OnMenuCmd", "v.surf.rst"), ("","","", ""), - ("Bilinear/bicubic from vector points", "Bicubic and bilinear interpolation with Tykhonov regularization from vector points", "self.OnMenuCmd", "v.surf.bspline"), - ("Inverse distance weighted from vector points", "Inverse distance weighted interpolation from vector points", "self.OnMenuCmd", "v.surf.idw"), - ("Regularized spline tension from vector points or contours (WHICH COMMAND ?)", "Regularized spline tension interpolation from vector points or contours", "self.OnMenuCmd", "v.surf.rst"), - ("","","", ""), ("Fill NULL cells", "Fill NULL cells by interpolation using regularized spline tension", "self.OnMenuCmd", "r.fillnulls"), )), ("","","", ""), From barton at grass.itc.it Fri Jun 15 17:35:40 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 15 17:35:42 2007 Subject: [grass-addons] r850 - trunk/grassaddons/gui/gui_modules Message-ID: <200706151535.l5FFZesB017918@grass.itc.it> Author: barton Date: 2007-06-15 17:35:32 +0200 (Fri, 15 Jun 2007) New Revision: 850 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Update database menu Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-15 07:57:26 UTC (rev 849) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-15 15:35:32 UTC (rev 850) @@ -488,8 +488,8 @@ )), ("","","", ""), ("3D MASK", "Create 3D mask for grid3D operations", "self.OnMenuCmd", "r3.mask"), + ("3D map calculator", "Map calculator for grid3D volume operations", "self.OnMenuCmd", "r3.mapcalculator"), ("Cross section", "Create 2D raster cross section from grid3d volume", "self.OnMenuCmd", "r3.cross.rast"), - ("Map calculator", "Map calculator for grid3D volume operations", "self.OnMenuCmd", "r3.mapcalculator"), ("Interpoloate volume from points", "Interpolate volume from vector points using splines", "self.OnMenuCmd", "v.vol.rst"), ("","","", ""), ("Report and Statistics", ( @@ -499,16 +499,18 @@ )), ("Database", ( ("Database information", ( - ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), - ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), + ("Describe table", "Describe table structure and attributes", "self.OnMenuCmd", "db.describe"), + ("List columns", "List columns for selected table", "self.OnMenuCmd", "db.columns"), + ("List drivers", "List available database drivers", "self.OnMenuCmd", "db.drivers"), + ("List tables", "List tables in database", "self.OnMenuCmd", "db.tables"), )), ("","","", ""), ("Manage databases", ( ("Connect", "Connect to database", "self.OnMenuCmd", "db.connect"), ("Login", "Login to database", "self.OnMenuCmd", "db.login"), ("","","", ""), - ("New table", "Create and add new attribute table to vector map", "self.OnMenuCmd", "v.db.addtable"), ("Copy table", "Copy attribute table", "self.OnMenuCmd", "db.copy"), + ("New table", "Create and connect new attribute table to vector map", "self.OnMenuCmd", "v.db.addtable"), ("Remove table", "Remove existing attribute table for vector map", "self.OnMenuCmd", "db.login"), ("","","", ""), ("Add columns", "Add columns to table", "self.OnMenuCmd", "v.db.addcol"), @@ -519,8 +521,9 @@ ("","","", "") )), ("Query", ( - ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), - ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), + ("Query any table", "Query data in any table", "self.OnMenuCmd", "db.select"), + ("Query vector attribute table", "Query vector attribute data", "self.OnMenuCmd", "v.db.select"), + ("SQL statement", "Execute SQL statement", "self.OnMenuCmd", "db.execute"), )), ("","","", ""), ("Vector<->database connections", ( From barton at grass.itc.it Sat Jun 16 04:11:20 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Jun 16 04:11:23 2007 Subject: [grass-addons] r851 - trunk/grassaddons/gui/gui_modules Message-ID: <200706160211.l5G2BKXA024158@grass.itc.it> Author: barton Date: 2007-06-16 04:11:12 +0200 (Sat, 16 Jun 2007) New Revision: 851 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Minor menu updates Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-15 15:35:32 UTC (rev 850) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-16 02:11:12 UTC (rev 851) @@ -432,10 +432,10 @@ )), ("Imagery", ( ("Develop images and groups", ( - ("Create/edit imagery group", "Create/edit imagery group", "self.OnMenuCmd", "i.group"), - ("Target imagery group", "Target imagery group", "self.OnMenuCmd", "i.target"), + ("Create/edit group", "Create/edit imagery group", "self.OnMenuCmd", "i.group"), + ("Target group", "Target imagery group", "self.OnMenuCmd", "i.target"), ("","","", ""), - ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.OnMenuCmd", "i.image.mosaic"), + ("Mosaic images", "Mosaic up to 4 adjacent images", "self.OnMenuCmd", "i.image.mosaic"), )), ("Manage image colors", ( ("Color balance for RGB", "Color balance and enhance color tables of multiband imagery for rgb display", "self.OnMenuCmd", "i.landsat.rgb"), @@ -453,28 +453,28 @@ ("Classify image", ( ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.OnMenuCmd", "i.cluster"), ("","","", ""), - ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.OnMenuCmd", "i.maxlik"), + ("Maximum likelihood classification (MLC)", "Maximum likelihood Classification", "self.OnMenuCmd", "i.maxlik"), ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.OnMenuCmd", "i.smap"), ("","","", ""), ("Interactive input for supervised classification (requires Xterm)", "Interactive input for supervised classification", "self.OnXTerm", "i.class"), - ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.OnMenuCmd", "i.gensig"), - ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.OnMenuCmd", "i.gensigset"), + ("Input for supervised MLC", "Non-interactive input for supervised classification (MLC)", "self.OnMenuCmd", "i.gensig"), + ("Input for supervised SMAP", "Non-interactive input for supervised classification (SMAP)", "self.OnMenuCmd", "i.gensigset"), )), ("Filter image", ( - ("Zero edge crossing detection", "Zero edge crossing detection", "self.OnMenuCmd", "i.zc"), + ("Edge detection", "Zero edge crossing detection", "self.OnMenuCmd", "i.zc"), ("Matrix/convolving filter", "User defined matrix/convolving filter", "self.OnMenuCmd", "r.mfilter"), )), ("Histogram image", "Histogram image", "self.DispHistogram", ""), ("Spectral response", "Spectral response", "self.OnMenuCmd", "i.spectral"), ("Tasseled cap vegetation index", "Tasseled cap vegetation index", "self.OnMenuCmd", "i.tasscap"), ("Transform image", ( - ("Canonical component", "Canonical component", "self.OnMenuCmd", "i.cca"), - ("Principal component", "Principal component", "self.OnMenuCmd", "i.pca"), - ("Fast Fourier Transform", "Fast Fourier Transform", "self.OnMenuCmd", "i.fft"), - ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.OnMenuCmd", "i.ifft"), + ("Canonical correlation", "Canonical correlation (discriminant analysis)", "self.OnMenuCmd", "i.cca"), + ("Principal components", "Principal components analysis", "self.OnMenuCmd", "i.pca"), + ("Fast Fourier", "Fast Fourier Transform", "self.OnMenuCmd", "i.fft"), + ("Inverse Fast Fourier", "Inverse Fast Fourier Transform", "self.OnMenuCmd", "i.ifft"), )), ("","","", ""), - ("Report and statistics (also use raster reporting and stats)", ( + ("Report and statistics (also see raster reports and stats)", ( ("Bit pattern comparison ", "Bit pattern comparison for ID of low quality pixels", "self.OnMenuCmd", "r.bitpattern"), ("Kappa analysis", "Kappa classification accuracy assessment", "self.OnMenuCmd", "r.kappa"), ("OIF for LandSat TM", "Optimum index factor for LandSat TM", "self.OnMenuCmd", "i.oif"), From barton at grass.itc.it Sat Jun 16 04:19:12 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Jun 16 04:19:13 2007 Subject: [grass-addons] r852 - trunk/grassaddons/gui/gui_modules Message-ID: <200706160219.l5G2JCJK024200@grass.itc.it> Author: barton Date: 2007-06-16 04:19:04 +0200 (Sat, 16 Jun 2007) New Revision: 852 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Minor updates Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-16 02:11:12 UTC (rev 851) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-16 02:19:04 UTC (rev 852) @@ -474,7 +474,7 @@ ("Inverse Fast Fourier", "Inverse Fast Fourier Transform", "self.OnMenuCmd", "i.ifft"), )), ("","","", ""), - ("Report and statistics (also see raster reports and stats)", ( + ("Report and statistics", ( ("Bit pattern comparison ", "Bit pattern comparison for ID of low quality pixels", "self.OnMenuCmd", "r.bitpattern"), ("Kappa analysis", "Kappa classification accuracy assessment", "self.OnMenuCmd", "r.kappa"), ("OIF for LandSat TM", "Optimum index factor for LandSat TM", "self.OnMenuCmd", "i.oif"), From maldacker at grass.itc.it Mon Jun 18 16:32:44 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Mon Jun 18 16:32:45 2007 Subject: [grass-addons] r853 - trunk/grassaddons/v.path.obstacles Message-ID: <200706181432.l5IEWiKg023214@grass.itc.it> Author: maldacker Date: 2007-06-18 16:32:37 +0200 (Mon, 18 Jun 2007) New Revision: 853 Modified: trunk/grassaddons/v.path.obstacles/main.c trunk/grassaddons/v.path.obstacles/rotation_tree.c trunk/grassaddons/v.path.obstacles/visibility.c trunk/grassaddons/v.path.obstacles/visibility.h Log: changes in the initialisation of the VIS structure and in the way the VIS structure is updated Modified: trunk/grassaddons/v.path.obstacles/main.c =================================================================== --- trunk/grassaddons/v.path.obstacles/main.c 2007-06-16 02:19:04 UTC (rev 852) +++ trunk/grassaddons/v.path.obstacles/main.c 2007-06-18 14:32:37 UTC (rev 853) @@ -67,6 +67,10 @@ G_fatal_error(_("Could not open output")); } + + if (G_projection () == PROJECTION_LL) + G_warning("We are in LL projection"); + index = load_lines( &in, &points, &lines); G_message("We have %d lines", index ); Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.c =================================================================== --- trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-16 02:19:04 UTC (rev 852) +++ trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-18 14:32:37 UTC (rev 853) @@ -70,11 +70,11 @@ struct Point * f = p->father; struct Point * l = p->left_brother; struct Point * r = p->right_brother; - + if ( l != NULL ) - l->right_brother = NULL; + l->right_brother = r; if ( r != NULL ) - r->left_brother = NULL; + r->left_brother = l; if ( f->rightmost_son == p ) f->rightmost_son = NULL; @@ -82,7 +82,6 @@ p->father = NULL; p->left_brother = NULL; p->right_brother = NULL; - /*p->rightmost_son = NULL;*/ } @@ -145,19 +144,49 @@ } + +double segment_sqdistance2( struct Point * q, struct Line * e ) +{ + + double dx = e->p1->x - e->p2->x; + double dy = e->p1->y - e->p2->y; + + double t = t = (dx * (q->x - e->p2->x) + dy * (q->y - e->p2->y)) / (dx * dx + dy * dy); + + if (t < 0.0) + { + t = 0.0; + } + else if (t > 1.0) + { + t = 1.0; + } + + dx = dx * t + e->p2->x - q->x; + dy = dy * t + e->p2->y - q->y; + + return (dx * dx + dy * dy); + +} + + int before( struct Point * p, struct Point * q, struct Line * e ) { /* true if q lies nearer to p than segment e*/ /* first determine the square distance between p and e */ - G_message("Computing distances with line %d", e); - - //if ( e == NULL ) + if ( e == NULL ) return 1; - /*double e_distance = segment_sqdistance(p, e); - double pq_distance = ( p->x - q->x ) * ( p->x - q->x ) + ( p->y - q->y ) * ( p->y - q->y ); - */ + double e_distance = segment_sqdistance2(p, e); + //double e_distance = dig_distance2_point_to_line( p->x, p->y, 0, e->p1->x, e->p1->y, 0, e->p2->x, e->p2->y, 0, 0, 0, 0, 0, 0, 0 ); + double pqx = q->x - p->x; + double pqy = q->y - p->y; + double pq_distance = pqx*pqx + pqy*pqy; + + G_message("Distances with line %f and with point %f", e_distance, pq_distance); + + return pq_distance < e_distance ; } Modified: trunk/grassaddons/v.path.obstacles/visibility.c =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-16 02:19:04 UTC (rev 852) +++ trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-18 14:32:37 UTC (rev 853) @@ -32,6 +32,8 @@ *points = (struct Point * ) G_malloc( nb_lines*2*sizeof(struct Point) ); *lines = ( struct Line * ) G_malloc( nb_lines*sizeof(struct Line) ); + /* TODO here is only the first segment of a line that is copied, need to fix that + each point is associated with two segments except for the starting and ending point ( for line and boundary ) */ while( ( type = Vect_read_next_line( map, sites, cats) ) > -1 ) { @@ -67,7 +69,7 @@ index_line++; index_point++; - G_message("Line %d with points : %f %f %f %f", index_line, (*points)[index_point-1].x, (*points)[index_point-1].y, (*points)[index_point-2].x, (*points)[index_point-2].y ); + G_message("Line %d with points : %f %f %f %f", &((*lines)[index_line-1]), (*points)[index_point-1].x, (*points)[index_point-1].y, (*points)[index_point-2].x, (*points)[index_point-2].y ); } @@ -78,6 +80,7 @@ int left_turn( struct Point * p1, struct Point * p2, struct Point * p3 ) { double a, b, c, d; + double r; if ( p3 == p_infinity ) { @@ -89,8 +92,8 @@ b = p1->y - p2->y; c = p3->x - p2->x; d = p3->y - p2->y; - - return a*d - b*c < 0; + + return a*d-b*c < 0.0; } } @@ -108,16 +111,17 @@ for ( j = 0 ; j < num/2 ; j++ ) { - if ( &lines[j] == segment( &points[i]) ) - continue; + + //if ( &lines[j] == segment( &points[i]) ) + // continue; - if ( points[i].y < lines[j].p1->y && points[i].y < lines[j].p2->y ) - { - //G_message("considering line %d", &lines[j]); - + //G_message("For point %d with height %f we're considering line %d width height between %f and %f", &points[i], points[i].y, &lines[j], lines[j].p1->y, lines[j].p2->y ); + + if ( points[i].y > lines[j].p1->y && points[i].y > lines[j].p2->y && ( points[i].x < lines[j].p1->x || points[i].x < lines[j].p2->x )) + { s = segment_sqdistance( &points[i], &lines[j]); - //G_message("Distance to considered line is %f and to current line is %f", s,current_distance); + //G_message("The line is below the point and its distance is %f", s); if( s < current_distance) { @@ -134,31 +138,36 @@ else { points[i].vis = &lines[current]; - current = -1; - current_distance = PORT_DOUBLE_MAX; } - G_message("VIS of point %d is %d", &points[i], points[i].vis ); + current = -1; + current_distance = PORT_DOUBLE_MAX; + + G_message("VIS of point %d, ( %f ; %f) is %d", &points[i], points[i].x, points[i].y, points[i].vis ); } } void handle( struct Point* p, struct Point* q, struct Map_info * out ) -{ +{ + //G_message("Handling ( %f ; %f ) and ( %f ; %f )", p->x, p->y, q->x, q->y); + G_message("Handling %d and %d Point %d with VIS %d and segment(q) = %d", p,q,p, p->vis, segment(q) ); + if ( q == other(p) ) { - G_message("It's the other"); + //G_message("It's the other"); + //p->vis = q->vis ; report( p, q, out ); } else if ( segment(q) == p->vis ) { - G_message("Its the vis!!!!"); - p->vis = q->vis ; + //G_message("Its the vis!!!! New VIS is %d", q->vis); + //p->vis = q->vis ; report( p,q, out ); } else if ( before(p,q, p->vis ) ) { - G_message("before!!"); + //G_message("before!! New VIS %d", segment(q)); p->vis = segment(q); report(p,q,out); } @@ -185,7 +194,7 @@ } -int cmp_points(const void* v1, const void* v2) { +int cmp_points(struct Point * v1, struct Point* v2) { struct Point *p1, *p2; p1 = (struct Point*) v1; p2 = (struct Point*) v2; @@ -225,15 +234,15 @@ p_infinity->left_brother = NULL; p_infinity->right_brother = NULL; p_infinity->rightmost_son = NULL; - - init_vis( points, lines, num_points ); - init_stack(num_points); /* sort points in decreasing x order*/ - qsort(points, num_points, sizeof(struct Point), cmp_points); + //qsort(points, num_points, sizeof(struct Point), cmp_points); + quickSort( points, 0, num_points-1 ); + init_vis( points, lines, num_points ); + add_rightmost( p_ninfinity, p_infinity ); for ( i = 0; i < num_points ; i ++ ) @@ -258,7 +267,6 @@ if ( q != p_ninfinity ) { - G_message("Handling %d and %d", p,q); handle(p,q, out); } @@ -336,3 +344,58 @@ stack = G_malloc( size * sizeof( struct Point ) ); } + +void quickSort( struct Point a[], int l, int r) +{ + int j; + + if( l < r ) + { + // divide and conquer + j = partition( a, l, r); + quickSort( a, l, j-1); + quickSort( a, j+1, r); + } + +} + +/* TODO take in account if it is long/lat projection */ + +int partition( struct Point a[], int l, int r) +{ + int i, j; + + struct Point t,pivot; + + pivot = a[l]; + i = l; j = r+1; + + while( 1) + { + do ++i; while( cmp_points(&a[i], &pivot) < 1 && i <= r ); + do --j; while( cmp_points(&a[j], &pivot) == 1 ); + + if( i >= j ) break; + + if ( a[i].line->p1 == &a[i] ) a[i].line->p1 = &a[j]; + else a[i].line->p2 = &a[j]; + + if ( a[j].line->p1 == &a[j] ) a[j].line->p1 = &a[i]; + else a[j].line->p2 = &a[i]; + + t = a[i]; a[i] = a[j]; a[j] = t; + + } + + if ( a[l].line->p1 == &a[l] ) a[l].line->p1 = &a[j]; + else a[l].line->p2 = &a[j]; + + if ( a[j].line->p1 == &a[j] ) a[j].line->p1 = &a[l]; + else a[j].line->p2 = &a[l]; + + t = a[l]; a[l] = a[j]; a[j] = t; + + + return j; +} + Modified: trunk/grassaddons/v.path.obstacles/visibility.h =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.h 2007-06-16 02:19:04 UTC (rev 852) +++ trunk/grassaddons/v.path.obstacles/visibility.h 2007-06-18 14:32:37 UTC (rev 853) @@ -25,7 +25,7 @@ int load_lines( struct Map_info *map, struct Point ** points, struct Line ** lines ); int construct_visibility( struct Point * points, struct Line * lines, int num_lines, struct Map_info* out ); -int cmp_points(const void* v1, const void* v2); +int cmp_points(struct Point * v1, struct Point* v2); int turn_left( struct Point p1, struct Point p2, struct Point p3 ); @@ -40,6 +40,9 @@ int empty_stack(); void init_stack(); +void quickSort( struct Point a[], int l, int r); +int partition( struct Point a[], int l, int r); + static int stack_index; static struct Point ** stack; static struct Point * p_ninfinity; From maldacker at grass.itc.it Mon Jun 18 20:40:15 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Mon Jun 18 20:40:17 2007 Subject: [grass-addons] r854 - trunk/grassaddons/v.path.obstacles Message-ID: <200706181840.l5IIeF42027797@grass.itc.it> Author: maldacker Date: 2007-06-18 20:40:12 +0200 (Mon, 18 Jun 2007) New Revision: 854 Modified: trunk/grassaddons/v.path.obstacles/visibility.c Log: change in VIS construction Modified: trunk/grassaddons/v.path.obstacles/visibility.c =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-18 14:32:37 UTC (rev 853) +++ trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-18 18:40:12 UTC (rev 854) @@ -97,6 +97,20 @@ } } + +int in_between( struct Point * p, struct Line * e ) +{ + int a = e->p1->x < p->x && e->p2->x > p->x ; + int b = e->p2->x < p->x && e->p1->x > p->x; + + return a || b; +} + +int below( struct Point * p, struct Line * e ) +{ + return e->p1->y < p->y || e->p2->y < p->y ; +} + void init_vis( struct Point * points, struct Line * lines, int num ) { /* this algorithm can be optimised with a scan line technic which runs in O( n log n ) instead of O( n^2 ); */ @@ -117,7 +131,7 @@ //G_message("For point %d with height %f we're considering line %d width height between %f and %f", &points[i], points[i].y, &lines[j], lines[j].p1->y, lines[j].p2->y ); - if ( points[i].y > lines[j].p1->y && points[i].y > lines[j].p2->y && ( points[i].x < lines[j].p1->x || points[i].x < lines[j].p2->x )) + if ( below( &points[i], &lines[j] ) && in_between( &points[i], &lines[j] ) ) { s = segment_sqdistance( &points[i], &lines[j]); @@ -162,7 +176,7 @@ else if ( segment(q) == p->vis ) { //G_message("Its the vis!!!! New VIS is %d", q->vis); - //p->vis = q->vis ; + p->vis = q->vis ; report( p,q, out ); } else if ( before(p,q, p->vis ) ) @@ -252,6 +266,7 @@ push( &points[0] ); + int count = 0; //G_message("p_infinity is %d and p_ninfinity is %d ", p_infinity, p_ninfinity ); @@ -268,6 +283,7 @@ if ( q != p_ninfinity ) { handle(p,q, out); + count++; } z = left_brother(q); @@ -312,6 +328,8 @@ //G_message("The stack has %d points", stack_index); } + + G_warning("There was %d comparisons for %d points", count, num_points); } From maldacker at grass.itc.it Tue Jun 19 05:13:22 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Tue Jun 19 05:13:24 2007 Subject: [grass-addons] r855 - trunk/grassaddons/v.path.obstacles Message-ID: <200706190313.l5J3DMaG001602@grass.itc.it> Author: maldacker Date: 2007-06-19 05:13:17 +0200 (Tue, 19 Jun 2007) New Revision: 855 Modified: trunk/grassaddons/v.path.obstacles/main.c trunk/grassaddons/v.path.obstacles/rotation_tree.c trunk/grassaddons/v.path.obstacles/visibility.c Log: cleaning of code Modified: trunk/grassaddons/v.path.obstacles/main.c =================================================================== --- trunk/grassaddons/v.path.obstacles/main.c 2007-06-18 18:40:12 UTC (rev 854) +++ trunk/grassaddons/v.path.obstacles/main.c 2007-06-19 03:13:17 UTC (rev 855) @@ -73,8 +73,6 @@ index = load_lines( &in, &points, &lines); - G_message("We have %d lines", index ); - construct_visibility( points, lines, index, &out ); Vect_build(&out, stdout); Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.c =================================================================== --- trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-18 18:40:12 UTC (rev 854) +++ trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-19 03:13:17 UTC (rev 855) @@ -180,13 +180,10 @@ return 1; double e_distance = segment_sqdistance2(p, e); - //double e_distance = dig_distance2_point_to_line( p->x, p->y, 0, e->p1->x, e->p1->y, 0, e->p2->x, e->p2->y, 0, 0, 0, 0, 0, 0, 0 ); double pqx = q->x - p->x; double pqy = q->y - p->y; double pq_distance = pqx*pqx + pqy*pqy; - - G_message("Distances with line %f and with point %f", e_distance, pq_distance); - + return pq_distance < e_distance ; } Modified: trunk/grassaddons/v.path.obstacles/visibility.c =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-18 18:40:12 UTC (rev 854) +++ trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-19 03:13:17 UTC (rev 855) @@ -13,8 +13,16 @@ * ****************************************************************/ + +/* TODO take in account if it is long/lat projection */ +/* TODO here is only the first segment of a line that is copied, need to fix that +each point is associated with two segments except for the starting and ending point ( for line and boundary ) */ +/* TODO vis initialisation algorithm can be optimised with a scan line technic which runs in O( n log n ) instead of O( n^2 ); */ + #include "visibility.h" +/** Get the lines from the map and load them in an array +*/ int load_lines( struct Map_info * map, struct Point ** points, struct Line ** lines ) { int index_line = 0; @@ -32,9 +40,6 @@ *points = (struct Point * ) G_malloc( nb_lines*2*sizeof(struct Point) ); *lines = ( struct Line * ) G_malloc( nb_lines*sizeof(struct Line) ); - /* TODO here is only the first segment of a line that is copied, need to fix that - each point is associated with two segments except for the starting and ending point ( for line and boundary ) */ - while( ( type = Vect_read_next_line( map, sites, cats) ) > -1 ) { @@ -77,6 +82,8 @@ } +/** returns true if p3 is left of the directed line p1p2 +*/ int left_turn( struct Point * p1, struct Point * p2, struct Point * p3 ) { double a, b, c, d; @@ -97,7 +104,8 @@ } } - +/** returns true if p is inbetween the segment e along the x axis +*/ int in_between( struct Point * p, struct Line * e ) { int a = e->p1->x < p->x && e->p2->x > p->x ; @@ -106,14 +114,19 @@ return a || b; } +/** returns true if p is above the segment e ( y axis ) +*/ int below( struct Point * p, struct Line * e ) { return e->p1->y < p->y || e->p2->y < p->y ; } + +/** for all points initiate their vis line to the one directly below +*/ void init_vis( struct Point * points, struct Line * lines, int num ) { - /* this algorithm can be optimised with a scan line technic which runs in O( n log n ) instead of O( n^2 ); */ + int i; int j; int current = -1; @@ -126,17 +139,14 @@ { - //if ( &lines[j] == segment( &points[i]) ) - // continue; - - //G_message("For point %d with height %f we're considering line %d width height between %f and %f", &points[i], points[i].y, &lines[j], lines[j].p1->y, lines[j].p2->y ); + if ( &lines[j] == segment( &points[i]) ) + continue; + /* if it's directly below, compute its distance to the last smallest found */ if ( below( &points[i], &lines[j] ) && in_between( &points[i], &lines[j] ) ) { s = segment_sqdistance( &points[i], &lines[j]); - //G_message("The line is below the point and its distance is %f", s); - if( s < current_distance) { current = j; @@ -156,37 +166,32 @@ current = -1; current_distance = PORT_DOUBLE_MAX; - - G_message("VIS of point %d, ( %f ; %f) is %d", &points[i], points[i].x, points[i].y, points[i].vis ); - } } +/** for a pair (p, q) of points, add the edge pq if their are visibile to each other +*/ void handle( struct Point* p, struct Point* q, struct Map_info * out ) { - //G_message("Handling ( %f ; %f ) and ( %f ; %f )", p->x, p->y, q->x, q->y); - G_message("Handling %d and %d Point %d with VIS %d and segment(q) = %d", p,q,p, p->vis, segment(q) ); if ( q == other(p) ) { - //G_message("It's the other"); - //p->vis = q->vis ; report( p, q, out ); } else if ( segment(q) == p->vis ) { - //G_message("Its the vis!!!! New VIS is %d", q->vis); p->vis = q->vis ; report( p,q, out ); } else if ( before(p,q, p->vis ) ) { - //G_message("before!! New VIS %d", segment(q)); p->vis = segment(q); report(p,q,out); } } +/** add the edge pq to the map out +*/ void report( struct Point * p, struct Point * q, struct Map_info * out ) { struct line_pnts* sites; @@ -208,6 +213,8 @@ } +/** compare the points along the x axis +*/ int cmp_points(struct Point * v1, struct Point* v2) { struct Point *p1, *p2; p1 = (struct Point*) v1; @@ -225,7 +232,8 @@ return 0; } - +/** the algorithm that computes the visibility graph +*/ int construct_visibility ( struct Point * points, struct Line * lines, int num_lines, struct Map_info * out ) { int num_points = 2*num_lines; @@ -252,7 +260,6 @@ init_stack(num_points); /* sort points in decreasing x order*/ - //qsort(points, num_points, sizeof(struct Point), cmp_points); quickSort( points, 0, num_points-1 ); init_vis( points, lines, num_points ); @@ -267,9 +274,9 @@ push( &points[0] ); int count = 0; - - //G_message("p_infinity is %d and p_ninfinity is %d ", p_infinity, p_ninfinity ); + + /* main loop */ while( !empty_stack() ) { @@ -277,9 +284,7 @@ p_r = right_brother(p); q = father(p); - //G_message("---------"); - //G_message("p is %d and q is %d and p_r is %d", p, q ,p_r); - + /* if the father is not -infinity, handle p and q */ if ( q != p_ninfinity ) { handle(p,q, out); @@ -288,14 +293,11 @@ z = left_brother(q); - //G_message("z is %d", z ); - //if ( z!= NULL ) G_message("father(z) is %d", father(z) ); - remove_point(p); + /* remove and reattach p to the tree */ if ( z == NULL || !left_turn(p,z, father(z) ) ) { - //G_message("adding p leftof q "); add_leftof(p,q); } else @@ -306,30 +308,22 @@ add_rightmost(p,z); - //G_message("add p as rightmost son of z which is %d", z); - if ( z == top() ) z = pop(); } - //G_message("father(p) is now %d", father(p) ); - + /* if p not attached to infinity, then p has more points to visit */ if ( left_brother(p) == NULL && father(p) != p_infinity ) { - //G_message("pushing p"); push(p); } + /* and continue with the next one ( from left to right )*/ if ( p_r != NULL ) { push(p_r); - //G_message("pushing p_r "); } - - //G_message("The stack has %d points", stack_index); } - - G_warning("There was %d comparisons for %d points", count, num_points); } @@ -377,7 +371,6 @@ } -/* TODO take in account if it is long/lat projection */ int partition( struct Point a[], int l, int r) { From maldacker at grass.itc.it Tue Jun 19 05:21:14 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Tue Jun 19 05:21:15 2007 Subject: [grass-addons] r856 - trunk/grassaddons/v.path.obstacles Message-ID: <200706190321.l5J3LEgs001651@grass.itc.it> Author: maldacker Date: 2007-06-19 05:21:11 +0200 (Tue, 19 Jun 2007) New Revision: 856 Modified: trunk/grassaddons/v.path.obstacles/description.html Log: initial writting Modified: trunk/grassaddons/v.path.obstacles/description.html =================================================================== --- trunk/grassaddons/v.path.obstacles/description.html 2007-06-19 03:13:17 UTC (rev 855) +++ trunk/grassaddons/v.path.obstacles/description.html 2007-06-19 03:21:11 UTC (rev 856) @@ -1,124 +1,26 @@

DESCRIPTION

-v.net.path can find shortest path(s) on the vector network. -Costs may be either line lengths, or attributes saved in a database -table. These attributes values are taken as costs of whole segments. If read -from the table, arcs' costs may be different in both directions. -Shortest paths are written to output vector map and attached attribute table. +v.path.obstacles Computes the visibility graph of a map containing lines. This is the graph with vertices the end point of the lines and the edges are between two visibiles vertices. Two points are visibible if there no segments in between them, i.e. there are no lines e where the segment pq intersects it.

-Nodes can be piped into the program from file or from stdin. The -syntax is as follows: +The first argument is the input map. The module will only take in account the first segment of every lines. For the algorithm to work, lines must not be intersecting.

-id start_point_category end_point_category
+input=map
 
-or +The result map containing the visibility graph of the input map
-id start_point_x start_point_y end_point_x end_point_y
+output=map2
 
-

-Points specified by category must be exactly on network nodes, -while, when specifying coordinates, the next node to a given -coordinate pair is used. -

-

-Attribute table will contain following attributes: -

-
    -
  • cat - path unique category assigned by module
  • -
  • id - path id (read from input)
  • -
  • fcat - from point category
  • -
  • tcat - to point category
  • -
  • sp - result status: -
      -
    • 0 - OK, path found
    • -
    • 1 - node is not reachable
    • -
    • 2 - point of given category does not exist
    • -
  • -
  • cost - travelling costs (on the network, not to/from network)
  • -
  • fdist - the distance from first point to the network
  • -
  • tdist - the distance from the network to second point
  • -
- -

NOTE

- -If the columns 'afcol', 'abcol' and 'ncol' costs are not -specified, the length of network segments is measured and -zero costs are assumed for nodes. -

-When using attributes, the length of segments is not used. To get -more precise results, length should be taken indirectly into account -by attributes. For example, to get the fastest path the columns -'max_speed' and 'length' are required. The correct fastest path can then -be found by specifying afcol=length/max_speed (pg driver). If needed, -the line length can be calculated and written to the attributes table -by v.to.db. -

EXAMPLE

-Shortest path from two digitized nodes: +v.path.obstacles input=lines output=graph +d.vect graph +d.vect lines col=red -
-g.copy vect=roads,myroads
-v.db.addcol myroads col="forward double precision, backward double precision"
 
-# define traveling costs as inverse of speed limit:
-v.db.update myroads col=forward val=1/50
-v.db.update myroads col=backward val=1/50
-v.db.update myroads col=forward val=1/75 where="label='interstate'"
-v.db.update myroads col=backward val=1/75 where="label='interstate'"
-v.db.update myroads col=forward val=1/5 where="label='unimproved road'"
-v.db.update myroads col=backward val=1/5 where="label='unimproved road'"
-v.db.update myroads col=forward val=1/25 where="label='light-duty road, improved surface'"
-v.db.update myroads col=backward val=1/25 where="label='light-duty road, improved surface'"
-v.db.select myroads
-echo "1|601653.5|4922869.2|start|0|0
-2|593330.8|4924096.6|end|0|0" | v.in.ascii cat=1 x=2 y=3 out=startend col="cat integer, \
-                         east double precision, north double precision, label varchar(43), \
-                         forward double precision, backward double precision"
-
-v.db.dropcol startend col=east
-v.db.dropcol startend col=north
-
-#create lines map connecting points to network
-v.distance -p from=startend to=myroads out=connect upload=dist column=dist
-d.vect myroads
-d.vect startend col=red
-d.vect connect col=green
-
-# note that tables needs to be identical for v.patch:
-db.describe myroads -c
-v.db.addtable connect col="label varchar(43), forward double precision, backward double precision"
-# add categories, use cat 0 (no data) for both roads as "off-road":
-v.category in=connect out=connect_cat cat=0 step=0
-# insert attributes:
-echo "INSERT INTO connect_cat (cat, label, forward, backward) VALUES (0, 'no data', 50, 50)" | db.execute
-v.db.select connect_cat
-
-v.info -c connect_cat
-v.info -c startend
-
-#merge all maps into a new one: streets, connections, points:
-v.patch -e myroads,connect_cat,startend out=myroads_n
-
-#fix the topology: break lines, snap to nodes:
-# (note: this removes overpasses, better use v.edit)
-v.clean myroads_n output=myroads_net tool=snap,break,rmdupl thresh=1,0,0
-v.db.select myroads_net
-d.vect myroads_net icon=basic/triangle fcol=green size=12
-d.vect myroads_net disp=cat type=point lsize=14
-# ... the 'start' and 'end' nodes have category number 9 and 10
-
-# ID as first number, then cat1 and cat2
-# (nlayer=1 if no extra table for nodes)
-echo "1 9 10" | v.net.path myroads_net afcol=forward abcol=backward out=mypath nlayer=1
-d.vect mypath col=red width=2
-
- -

SEE ALSO

d.path, @@ -131,6 +33,6 @@

AUTHOR

-Radim Blazek, ITC-Irst, Trento, Italy +Maximilian Maldacker -

Last changed: $Date: 2007/05/04 08:08:36 $ +

Last changed: $Date: 2007/06/19 04:21:32 $ From maldacker at grass.itc.it Tue Jun 19 05:22:52 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Tue Jun 19 05:22:52 2007 Subject: [grass-addons] r857 - trunk/grassaddons/v.path.obstacles Message-ID: <200706190322.l5J3MqWE001674@grass.itc.it> Author: maldacker Date: 2007-06-19 05:22:49 +0200 (Tue, 19 Jun 2007) New Revision: 857 Modified: trunk/grassaddons/v.path.obstacles/description.html Log: corrections Modified: trunk/grassaddons/v.path.obstacles/description.html =================================================================== --- trunk/grassaddons/v.path.obstacles/description.html 2007-06-19 03:21:11 UTC (rev 856) +++ trunk/grassaddons/v.path.obstacles/description.html 2007-06-19 03:22:49 UTC (rev 857) @@ -16,11 +16,12 @@

EXAMPLE

-v.path.obstacles input=lines output=graph -d.vect graph -d.vect lines col=red +
+v.path.obstacles input=lines output=graph 
+d.vect graph
+d.vect lines col=red
+
-

SEE ALSO

d.path, From landa at grass.itc.it Tue Jun 19 13:36:22 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Tue Jun 19 13:36:24 2007 Subject: [grass-addons] r858 - trunk/grassaddons/gui/screenshots Message-ID: <200706191136.l5JBaM9D005905@grass.itc.it> Author: landa Date: 2007-06-19 13:36:22 +0200 (Tue, 19 Jun 2007) New Revision: 858 Added: trunk/grassaddons/gui/screenshots/wxgrass-aui-toolbars.png trunk/grassaddons/gui/screenshots/wxgrass63-2007-05.png Log: Added two other screenshots (GNU/Linux) Added: trunk/grassaddons/gui/screenshots/wxgrass-aui-toolbars.png =================================================================== (Binary files differ) Property changes on: trunk/grassaddons/gui/screenshots/wxgrass-aui-toolbars.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/grassaddons/gui/screenshots/wxgrass63-2007-05.png =================================================================== (Binary files differ) Property changes on: trunk/grassaddons/gui/screenshots/wxgrass63-2007-05.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream From landa at grass.itc.it Tue Jun 19 17:05:30 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Tue Jun 19 17:05:31 2007 Subject: [grass-addons] r859 - in trunk/grassaddons/gui: . gui_modules icons Message-ID: <200706191505.l5JF5UtW010842@grass.itc.it> Author: landa Date: 2007-06-19 17:05:29 +0200 (Tue, 19 Jun 2007) New Revision: 859 Modified: trunk/grassaddons/gui/gui_modules/digit.py trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/toolbars.py trunk/grassaddons/gui/gui_modules/wxgui_utils.py trunk/grassaddons/gui/icons/icon.py trunk/grassaddons/gui/wxgui.py Log: Digitization tool is progress... (minor changes) Modified: trunk/grassaddons/gui/gui_modules/digit.py =================================================================== --- trunk/grassaddons/gui/gui_modules/digit.py 2007-06-19 11:36:22 UTC (rev 858) +++ trunk/grassaddons/gui/gui_modules/digit.py 2007-06-19 15:05:29 UTC (rev 859) @@ -4,7 +4,8 @@ CLASSES: * VEdit * VDigit - + * SettingsDialog + PURPOSE: Digitization tool wxPython GUI prototype Note: Initial version under development @@ -22,6 +23,9 @@ for details. """ +import wx +import wx.lib.colourselect as csel + import cmd from debug import Debug as Debug @@ -96,7 +100,132 @@ """ pass +class DigitSettingsDialog(wx.Dialog): + """ + Standard settings dialog for digitization purposes + """ + def __init__(self, parent, title, style): + wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style) + # notebook + notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT) + self.__CreateSymbologyPage(notebook) + self.__CreateSettingsPage(notebook) + + # buttons + btnApply = wx.Button(self, wx.ID_APPLY, _("Apply") ) + btnCancel = wx.Button(self, wx.ID_CANCEL) + btnOk = wx.Button(self, wx.ID_OK, _("OK") ) + btnOk.SetDefault() + + # bindigs + #btnApply.Bind(wx.EVT_BUTTON, self.OnApply) + #btn_ok.Bind(wx.EVT_BUTTON, self.OnOK) + + # sizers + btnSizer = wx.StdDialogButtonSizer() + btnSizer.AddButton(btnCancel) + btnSizer.AddButton(btnApply) + btnSizer.AddButton(btnOk) + btnSizer.Realize() + + mainSizer = wx.BoxSizer(wx.VERTICAL) + mainSizer.Add(item=notebook, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) + mainSizer.Add(item=btnSizer, proportion=0, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) + + self.SetSizer(mainSizer) + mainSizer.Fit(self) + + def __CreateSymbologyPage(self, notebook): + """Create notebook page concerning with symbology settings""" + + panel = wx.Panel(parent=notebook, id=wx.ID_ANY) + notebook.AddPage(page=panel, text=_("Symbology")) + + sizer = wx.BoxSizer(wx.VERTICAL) + + flexSizer = wx.FlexGridSizer (cols=3, hgap=5, vgap=5) + flexSizer.AddGrowableCol(0) + + for label, isCheckbox, color in self.__SymbologyData(): + textLabel = wx.StaticText(panel, wx.ID_ANY, label) + if isCheckbox: + enabled = wx.CheckBox(panel, id=wx.ID_ANY, label="") + else: + enabled = (1, 1) + color = csel.ColourSelect(panel, id=wx.ID_ANY, colour=color, size=(25, 25)) + + flexSizer.Add(textLabel, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) + flexSizer.Add(enabled, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE) + flexSizer.Add(color, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE) + + sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) + + panel.SetSizer(sizer) + + return panel + + def __CreateSettingsPage(self, notebook): + """Create notebook page concerning with symbology settings""" + + panel = wx.Panel(parent=notebook, id=wx.ID_ANY) + notebook.AddPage(page=panel, text=_("Settings")) + + sizer = wx.BoxSizer(wx.VERTICAL) + + flexSizer = wx.FlexGridSizer (cols=3, hgap=5, vgap=5) + flexSizer.AddGrowableCol(0) + + for label, defaultValue in self.__SettingsData(): + textLabel = wx.StaticText(parent=panel, id=wx.ID_ANY, label=label) + value = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, value=defaultValue, min=1, max=1e6) + units = wx.Choice(parent=panel, id=wx.ID_ANY, choices=["screen pixels", "map units"]) + + flexSizer.Add(textLabel, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL) + flexSizer.Add(value, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE) + flexSizer.Add(units, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE) + + sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) + + panel.SetSizer(sizer) + + return panel + + def __SymbologyData(self): + """ + Data for __CreateSymbologyPage() + + label | checkbox | color + """ + + return ( + ("Background", False, "white"), + ("Highlight", False, "yellow"), + ("Point", True, "black"), + ("Line", True, "black"), + ("Boundary (no area)", True, "grey"), + ("Boundary (one area)", True, "orange"), + ("Boundary (two areas)", True, "green"), + ("Centroid (in area)", True, "blue"), + ("Centroid (outside area)", True, "brown"), + ("Centroid (duplicate in area)", True, "violet"), + ("Node (one line)", True, "red"), + ("Node (two lines)", True, "dark green")) + + def __SettingsData(self): + """ + Data for __CreateSettingsPage() + + label | checkbox | default value + """ + + return ( + (_("Snapping threshold"), "10"), + (_("Line width"), "2") + ) + + + ############################## # digitization class instance ############################## Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-19 11:36:22 UTC (rev 858) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-19 15:05:29 UTC (rev 859) @@ -1334,12 +1334,15 @@ elif name == "digit": self.digittoolbar = toolbars.DigitToolbar(self, self.Map) - self._mgr.AddPane(self.digittoolbar.toolbar, wx.aui.AuiPaneInfo(). - Name("digittoolbar").Caption("Digit Toolbar"). - ToolbarPane().Top().Row(1). - LeftDockable(False).RightDockable(False). - BottomDockable(False).TopDockable(True). - CloseButton(False).Layer(2)) + for toolRow in range(0,2): + self._mgr.AddPane(self.digittoolbar.toolbar[toolRow], + wx.aui.AuiPaneInfo(). + Name("digittoolbar" + str(toolRow)).Caption("Digit Toolbar"). + ToolbarPane().Top().Row(toolRow + 1). + LeftDockable(False).RightDockable(False). + BottomDockable(False).TopDockable(True). + CloseButton(False).Layer(2)) + # change mouse to draw digitized line self.MapWindow.mouse['box'] = "point" self.MapWindow.zoomtype = 0 @@ -1360,8 +1363,9 @@ return elif name == "digit": # TODO: not destroy only hide - self._mgr.DetachPane (self.digittoolbar.toolbar) - self.digittoolbar.toolbar.Destroy() + for toolRow in range(0,2): + self._mgr.DetachPane (self.digittoolbar.toolbar[toolRow]) + self.digittoolbar.toolbar[toolRow].Destroy() self.digittoolbar = None self.maptoolbar.combo.SetValue (""); Modified: trunk/grassaddons/gui/gui_modules/toolbars.py =================================================================== --- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-19 11:36:22 UTC (rev 858) +++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-19 15:05:29 UTC (rev 859) @@ -26,6 +26,7 @@ import cmd import grassenv +import digit from debug import Debug as Debug from icon import Icons as Icons @@ -34,11 +35,11 @@ def __init__(): pass - def InitToolbar(self, parent): + def InitToolbar(self, parent, toolbar, toolData): """Initialize toolbar, i.e. add tools to the toolbar""" - for tool in self.ToolbarData(): - self.CreateTool(parent, self.toolbar, *tool) + for tool in toolData: + self.CreateTool(parent, toolbar, *tool) def ToolbarData(self): """Toolbar data""" @@ -74,7 +75,7 @@ tsize = (24, 24) self.toolbar.SetToolBitmapSize(tsize) - self.InitToolbar(self.mapdisplay) + self.InitToolbar(self.mapdisplay, self.toolbar, self.ToolbarData()) # optional tools self.combo = wx.ComboBox(parent=self.toolbar, id=wx.ID_ANY, value='Tools', @@ -173,11 +174,14 @@ self.comboid = None # create toolbar - self.toolbar = wx.ToolBar(parent=self.parent, id=wx.ID_ANY) - self.toolbar.SetToolBitmapSize(wx.Size(24,24)) + self.toolbar = [] + numOfRows = 2 + for row in range(0, numOfRows): + self.toolbar.append(wx.ToolBar(parent=self.parent, id=wx.ID_ANY)) + self.toolbar[row].SetToolBitmapSize(wx.Size(24,24)) - # create toolbar - self.InitToolbar(self.parent) + # create toolbar + self.InitToolbar(self.parent, self.toolbar[row], self.ToolbarData(row)) # list of available vector maps self.UpdateListOfLayers(updateTool=True) @@ -186,72 +190,74 @@ self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectMap, self.comboid) # realize toolbar - self.toolbar.Realize() + for row in range(0, numOfRows): + self.toolbar[row].Realize() - def ToolbarData(self): + def ToolbarData(self, row): """ Toolbar data """ - self.addPoint = self.addLine = self.addBoundary = self.addCentroid = self.exit = None - self.moveVertex = self.addVertex = self.removeVertex = None - self.splitLine = self.editLine = self.moveLine = self.deleteLine = None - self.displayCats = self.displayAttr = self.copyCats = self.settings = None + if row == 0: + self.displayCats = self.displayAttr = self.copyCats = None + self.settings = self.exit = None - return (("", "", "", "", "", "", ""), - (self.addPoint, "digAddPoint", Icons["digAddPoint"].GetBitmap(), - wx.ITEM_RADIO, Icons["digAddPoint"].GetLabel(), Icons["digAddPoint"].GetDesc(), - self.OnAddPoint), - (self.addLine, "digAddLine", Icons["digAddLine"].GetBitmap(), - wx.ITEM_RADIO, Icons["digAddLine"].GetLabel(), Icons["digAddLine"].GetDesc(), - self.OnAddLine), - (self.addBoundary, "digAddBoundary", Icons["digAddBoundary"].GetBitmap(), - wx.ITEM_RADIO, Icons["digAddBoundary"].GetLabel(), Icons["digAddBoundary"].GetDesc(), - self.OnAddBoundary), - (self.addCentroid, "digAddCentroid", Icons["digAddCentroid"].GetBitmap(), - wx.ITEM_RADIO, Icons["digAddCentroid"].GetLabel(), Icons["digAddCentroid"].GetDesc(), - self.OnAddCentroid), - ("", "", "", "", "", "", ""), - (self.moveVertex, "digMoveVertex", Icons["digMoveVertex"].GetBitmap(), - wx.ITEM_RADIO, Icons["digMoveVertex"].GetLabel(), Icons["digMoveVertex"].GetDesc(), - self.OnMoveVertex), - (self.addVertex, "digAddVertex", Icons["digAddVertex"].GetBitmap(), - wx.ITEM_RADIO, Icons["digAddVertex"].GetLabel(), Icons["digAddVertex"].GetDesc(), - self.OnAddVertex), - (self.removeVertex, "digRemoveVertex", Icons["digRemoveVertex"].GetBitmap(), - wx.ITEM_RADIO, Icons["digRemoveVertex"].GetLabel(), Icons["digRemoveVertex"].GetDesc(), - self.OnRemoveVertex), - ("", "", "", "", "", "", ""), - (self.splitLine, "digSplitLine", Icons["digSplitLine"].GetBitmap(), - wx.ITEM_RADIO, Icons["digSplitLine"].GetLabel(), Icons["digSplitLine"].GetDesc(), - self.OnSplitLine), - (self.editLine, "digEditLine", Icons["digEditLine"].GetBitmap(), - wx.ITEM_RADIO, Icons["digEditLine"].GetLabel(), Icons["digEditLine"].GetDesc(), - self.OnEditLine), - (self.moveLine, "digMoveLine", Icons["digMoveLine"].GetBitmap(), - wx.ITEM_RADIO, Icons["digMoveLine"].GetLabel(), Icons["digMoveLine"].GetDesc(), - self.OnMoveLine), - (self.deleteLine, "digDeleteLine", Icons["digDeleteLine"].GetBitmap(), - wx.ITEM_RADIO, Icons["digDeleteLine"].GetLabel(), Icons["digDeleteLine"].GetDesc(), - self.OnDeleteLine), - ("", "", "", "", "", "", ""), - (self.displayCats, "digDispCats", Icons["digDispCats"].GetBitmap(), - wx.ITEM_RADIO, Icons["digDispCats"].GetLabel(), Icons["digDispCats"].GetDesc(), - self.OnDisplayCats), - (self.copyCats, "digCopyCats", Icons["digCopyCats"].GetBitmap(), - wx.ITEM_RADIO, Icons["digCopyCats"].GetLabel(), Icons["digCopyCats"].GetDesc(), - self.OnCopyCats), - (self.displayAttr, "digDispAttr", Icons["digDispAttr"].GetBitmap(), - wx.ITEM_RADIO, Icons["digDispAttr"].GetLabel(), Icons["digDispAttr"].GetDesc(), - self.OnDisplayAttr), - (self.settings, "digSettings", Icons["digSettings"].GetBitmap(), - wx.ITEM_RADIO, Icons["digSettings"].GetLabel(), Icons["digSettings"].GetDesc(), - self.OnSettings), - ("", "", "", "", "", "", ""), - (self.exit, "digExit", Icons["digExit"].GetBitmap(), - wx.ITEM_NORMAL, Icons["digExit"].GetLabel(), Icons["digExit"].GetDesc(), - self.OnExit)) + return (("", "", "", "", "", "", ""), + (self.displayCats, "digDispCats", Icons["digDispCats"].GetBitmap(), + wx.ITEM_RADIO, Icons["digDispCats"].GetLabel(), Icons["digDispCats"].GetDesc(), + self.OnDisplayCats), + (self.copyCats, "digCopyCats", Icons["digCopyCats"].GetBitmap(), + wx.ITEM_RADIO, Icons["digCopyCats"].GetLabel(), Icons["digCopyCats"].GetDesc(), + self.OnCopyCats), + (self.displayAttr, "digDispAttr", Icons["digDispAttr"].GetBitmap(), + wx.ITEM_RADIO, Icons["digDispAttr"].GetLabel(), Icons["digDispAttr"].GetDesc(), + self.OnDisplayAttr), + ("", "", "", "", "", "", ""), + (self.settings, "digSettings", Icons["digSettings"].GetBitmap(), + wx.ITEM_NORMAL, Icons["digSettings"].GetLabel(), Icons["digSettings"].GetDesc(), + self.OnSettings), + (self.exit, "digExit", Icons["digExit"].GetBitmap(), + wx.ITEM_NORMAL, Icons["digExit"].GetLabel(), Icons["digExit"].GetDesc(), + self.OnExit)) + else: + self.addPoint = self.addLine = self.addBoundary = self.addCentroid = None + self.moveVertex = self.addVertex = self.removeVertex = None + self.splitLine = self.editLine = self.moveLine = self.deleteLine = None + return ((self.addPoint, "digAddPoint", Icons["digAddPoint"].GetBitmap(), + wx.ITEM_RADIO, Icons["digAddPoint"].GetLabel(), Icons["digAddPoint"].GetDesc(), + self.OnAddPoint), + (self.addLine, "digAddLine", Icons["digAddLine"].GetBitmap(), + wx.ITEM_RADIO, Icons["digAddLine"].GetLabel(), Icons["digAddLine"].GetDesc(), + self.OnAddLine), + (self.addBoundary, "digAddBoundary", Icons["digAddBoundary"].GetBitmap(), + wx.ITEM_RADIO, Icons["digAddBoundary"].GetLabel(), Icons["digAddBoundary"].GetDesc(), + self.OnAddBoundary), + (self.addCentroid, "digAddCentroid", Icons["digAddCentroid"].GetBitmap(), + wx.ITEM_RADIO, Icons["digAddCentroid"].GetLabel(), Icons["digAddCentroid"].GetDesc(), + self.OnAddCentroid), + (self.moveVertex, "digMoveVertex", Icons["digMoveVertex"].GetBitmap(), + wx.ITEM_RADIO, Icons["digMoveVertex"].GetLabel(), Icons["digMoveVertex"].GetDesc(), + self.OnMoveVertex), + (self.addVertex, "digAddVertex", Icons["digAddVertex"].GetBitmap(), + wx.ITEM_RADIO, Icons["digAddVertex"].GetLabel(), Icons["digAddVertex"].GetDesc(), + self.OnAddVertex), + (self.removeVertex, "digRemoveVertex", Icons["digRemoveVertex"].GetBitmap(), + wx.ITEM_RADIO, Icons["digRemoveVertex"].GetLabel(), Icons["digRemoveVertex"].GetDesc(), + self.OnRemoveVertex), + (self.splitLine, "digSplitLine", Icons["digSplitLine"].GetBitmap(), + wx.ITEM_RADIO, Icons["digSplitLine"].GetLabel(), Icons["digSplitLine"].GetDesc(), + self.OnSplitLine), + (self.editLine, "digEditLine", Icons["digEditLine"].GetBitmap(), + wx.ITEM_RADIO, Icons["digEditLine"].GetLabel(), Icons["digEditLine"].GetDesc(), + self.OnEditLine), + (self.moveLine, "digMoveLine", Icons["digMoveLine"].GetBitmap(), + wx.ITEM_RADIO, Icons["digMoveLine"].GetLabel(), Icons["digMoveLine"].GetDesc(), + self.OnMoveLine), + (self.deleteLine, "digDeleteLine", Icons["digDeleteLine"].GetBitmap(), + wx.ITEM_RADIO, Icons["digDeleteLine"].GetLabel(), Icons["digDeleteLine"].GetDesc(), + self.OnDeleteLine)) + def OnAddPoint(self, event): """Add point to the vector map layer""" Debug.msg (3, "DigitToolbar.OnAddPoint()") @@ -265,7 +271,7 @@ self.action = "add" self.type = "line" self.parent.MapWindow.mouse['box'] = 'line' - + def OnAddBoundary(self, event): """Add boundary to the vector map layer""" Debug.msg (3, "DigitToolbar.OnAddBoundary()") @@ -285,7 +291,7 @@ Quit digitization tool """ # stop editing of the currently selected map layer - self.StopEditing() + self.StopEditing(self.layers[self.layerSelectedID]) # disable the toolbar self.parent.RemoveToolbar ("digit") @@ -321,8 +327,11 @@ pass def OnSettings(self, event): - pass - + """Show settings dialog""" + settingsDialog = digit.DigitSettingsDialog(parent=self.parent, title=_("Digitization settings"), + style=wx.DEFAULT_DIALOG_STYLE) + settingsDialog.Show() + def OnSelectMap (self, event): """ Select vector map layer for editing @@ -355,20 +364,20 @@ except: return False - def StopEditing (self): + def StopEditing (self, layerSelected): """ Unmark currently enabled map layer. """ - if self.layerSelectedID: - Debug.msg (4, "DigitToolbar.StopEditing(): layer=%s" % \ - self.layers[self.layerSelectedID].name) - else: - Debug.msg (4, "DigitToolbar.StopEditing(): layer=None") + try: + if self.layers[self.layerSelectedID] == layerSelected: + self.layerSelectedID = None + Debug.msg (4, "DigitToolbar.StopEditing(): layerSelectedID=%d layer=%s" % \ + (self.layerSelectedID, self.layers[self.layerSelectedID].name)) + self.combo.SetValue ('Select vector map') + return True + except: + return False - self.layerSelectedID = None - self.combo.SetValue ('Select vector map') - # TODO - def UpdateListOfLayers (self, updateTool=False): """ Update list of available vector map layers. @@ -396,13 +405,13 @@ # ugly ... if self.comboid: - self.toolbar.DeleteToolByPos(0) + self.toolbar[0].DeleteToolByPos(0) #self.combo.Destroy() - self.combo = wx.ComboBox(self.toolbar, id=wx.ID_ANY, value=value, + self.combo = wx.ComboBox(self.toolbar[0], id=wx.ID_ANY, value=value, choices=layerNameList, size=(150, -1)) - self.comboid = self.toolbar.InsertControl(0, self.combo) - self.toolbar.Realize() + self.comboid = self.toolbar[0].InsertControl(0, self.combo) + self.toolbar[0].Realize() return layerNameList Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-19 11:36:22 UTC (rev 858) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-19 15:05:29 UTC (rev 859) @@ -265,14 +265,18 @@ self.popupMenu.Append(self.popupID5, text=_("Start editing")) self.popupMenu.Append(self.popupID6, text=_("Stop editing")) + self.popupMenu.Enable(self.popupID6, False) self.Bind (wx.EVT_MENU, self.OnStartEditing, id=self.popupID5) self.Bind (wx.EVT_MENU, self.OnStopEditing, id=self.popupID6) layer = self.layers[self.layer_selected].maplayer # enable editing only for vector map layers available in the current mapset - if layer.GetMapset() != grassenv.env["MAPSET"]: + digit = self.mapdisplay.digittoolbar + if layer.GetMapset() != grassenv.env["MAPSET"] or \ + (digit and digit.layerSelectedID != None and \ + digit.layers[digit.layerSelectedID] == layer): self.popupMenu.Enable (self.popupID5, False) - self.popupMenu.Enable(self.popupID6, False) + self.popupMenu.Enable (self.popupID6, True) # raster elif mltype and mltype == "raster": @@ -326,14 +330,24 @@ # mark layer as 'edited' self.mapdisplay.digittoolbar.StartEditing (maplayer) - # enable 'stop editing' - self.popupMenu.Enable (self.popupID5, False) - self.popupMenu.Enable (self.popupID6, True) - self.popupMenu.UpdateUI(self) - def OnStopEditing (self, event): - pass + """ + Stop editing the current vector map layer + """ + try: + maplayer = self.layers[self.layer_selected].maplayer + except: + event.Skip() + return + if self.mapdisplay.digittoolbar: # disable the tool + self.mapdisplay.RemoveToolbar("digit") + else: # tool already enabled + pass + + # mark layer as 'edited' + self.mapdisplay.digittoolbar.StopEditing (maplayer) + def OnPopupProperties (self, event): """Popup properties dialog""" self.PropertiesDialog(self.layer_selected) Modified: trunk/grassaddons/gui/icons/icon.py =================================================================== --- trunk/grassaddons/gui/icons/icon.py 2007-06-19 11:36:22 UTC (rev 858) +++ trunk/grassaddons/gui/icons/icon.py 2007-06-19 15:05:29 UTC (rev 859) @@ -224,25 +224,25 @@ desc="Left: new point"), "digAddVertex": MetaIcon (img=icons_img["digAddVertex"], label="Add new vertex", desc="Not implemented yet"), - "digCopyCats": MetaIcon (img=icons_img["digCopyCats"], label="", + "digCopyCats": MetaIcon (img=icons_img["digCopyCats"], label="Copy categories", desc="Not implemented yet"), - "digDeleteLine": MetaIcon (img=icons_img["digDeleteLine"], label="Add new vertex", + "digDeleteLine": MetaIcon (img=icons_img["digDeleteLine"], label="Delete line", desc="Not implemented yet"), - "digDispAttr": MetaIcon (img=icons_img["digDispAttr"], label="Add new vertex", + "digDispAttr": MetaIcon (img=icons_img["digDispAttr"], label="Display attributes", desc="Not implemented yet"), - "digDispCats": MetaIcon (img=icons_img["digDispCats"], label="Add new vertex", + "digDispCats": MetaIcon (img=icons_img["digDispCats"], label="Display categories", desc="Not implemented yet"), - "digEditLine": MetaIcon (img=icons_img["digEditLine"], label="Add new vertex", + "digEditLine": MetaIcon (img=icons_img["digEditLine"], label="Edit line", desc="Not implemented yet"), - "digMoveLine": MetaIcon (img=icons_img["digMoveLine"], label="Add new vertex", + "digMoveLine": MetaIcon (img=icons_img["digMoveLine"], label="Move line", desc="Not implemented yet"), - "digMoveVertex": MetaIcon (img=icons_img["digMoveVertex"], label="Add new vertex", + "digMoveVertex": MetaIcon (img=icons_img["digMoveVertex"], label="Move vertex", desc="Not implemented yet"), - "digRemoveVertex": MetaIcon (img=icons_img["digRemoveVertex"], label="Add new vertex", + "digRemoveVertex": MetaIcon (img=icons_img["digRemoveVertex"], label="Remove vertex", desc="Not implemented yet"), - "digSettings": MetaIcon (img=icons_img["digSettings"], label="Add new vertex", + "digSettings": MetaIcon (img=icons_img["digSettings"], label="Settings", desc="Not implemented yet"), - "digSplitLine": MetaIcon (img=icons_img["digSplitLine"], label="Add new vertex", + "digSplitLine": MetaIcon (img=icons_img["digSplitLine"], label="Split line", desc="Not implemented yet"), "digExit" : MetaIcon (img=icons_img["digExit"], label="Quit digitization tool"), # analyze raster @@ -258,7 +258,6 @@ "options" : MetaIcon (img=icons_img["options"], label="Set histogram options"), "analyze" : MetaIcon (img=icons_img["analyze"], label="Analyze")} - # testing ... if __name__ == "__main__": for k,v in Icons.iteritems(): Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-19 11:36:22 UTC (rev 858) +++ trunk/grassaddons/gui/wxgui.py 2007-06-19 15:05:29 UTC (rev 859) @@ -140,7 +140,7 @@ # do layout self.SetTitle(_("GRASS GIS Manager - wxPython Prototype")) - self.SetMinSize((400, 350)) + self.SetMinSize((500, 400)) self.SetIcon(wx.Icon(os.path.join(imagepath,'grass.smlogo.gif'), wx.BITMAP_TYPE_ANY)) # set environmental variables @@ -194,9 +194,7 @@ def __createCommandInput(self): """Creates command input area""" - #l = wx.StaticText(self, -1, "GRASS> ") - - self.cmdinput = wx.TextCtrl(self, id=wx.ID_ANY, value="", style=wx.HSCROLL|wx.TE_LINEWRAP| + self.cmdinput = wx.TextCtrl(self, id=wx.ID_ANY, value="", style=wx.HSCROLL | wx.TE_LINEWRAP | wx.TE_PROCESS_ENTER) self.cmdinput.SetFont(wx.Font(10, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL, 0, '')) From landa at grass.itc.it Wed Jun 20 17:44:59 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Wed Jun 20 17:45:02 2007 Subject: [grass-addons] r860 - trunk/grassaddons/gui/gui_modules Message-ID: <200706201544.l5KFixU5029966@grass.itc.it> Author: landa Date: 2007-06-20 17:44:58 +0200 (Wed, 20 Jun 2007) New Revision: 860 Modified: trunk/grassaddons/gui/gui_modules/dbm.py trunk/grassaddons/gui/gui_modules/digit.py trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/sqlbuilder.py trunk/grassaddons/gui/gui_modules/toolbars.py Log: Digitization tool: added new dialogs (settings, add new record into table), etc. Modified: trunk/grassaddons/gui/gui_modules/dbm.py =================================================================== --- trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-19 15:05:29 UTC (rev 859) +++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-20 15:44:58 UTC (rev 860) @@ -12,11 +12,11 @@ Tutorial' on wxPython WIKI pages. It also uses some functions at - http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/426407 + http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/426407 - dbm.py vectorm@mapset + dbm.py vector@mapset -AUTHOR(S): GRASS Development Tean +AUTHOR(S): GRASS Development Team Original author: Jachym Cepicky Martin Landa @@ -38,13 +38,12 @@ try: import subprocess except: - gmpath = os.getenv("GISBASE") + "/etc/wx" + gmpath = os.path.join(os.getenv("GISBASE"), "etc/wx") sys.path.append(gmpath) from compat import subprocess class Log: """ - Needed by the wxdemos. The log output is redirected to the status bar of the containing frame. """ def __init__(self,parent): @@ -94,8 +93,7 @@ self.mapdisp = self.parent.gismgr.curr_page.maptree.mapdisplay self.map = self.parent.gismgr.curr_page.maptree.Map - - #building the columns + # building the columns i = 0 # FIXME: Maximal number of columns, when the GUI is still usable dbDescribe = cmd.Command (cmd = ["db.describe", "-c", @@ -163,16 +161,16 @@ # prepare command string cmdv = ["db.select", "-c", - "table=%s" % self.parent.tablename, - "database=%s" % self.parent.database, - "driver=%s" % self.parent.driver] + "table=%s" % self.parent.tablename, + "database=%s" % self.parent.database, + "driver=%s" % self.parent.driver] if where: self.ClearAll() cmdv = ["db.select", "-c", - "sql=SELECT * FROM %s WHERE %s" % (self.parent.tablename, where), - "database=%s" % self.parent.database, - "driver=%s" % self.parent.driver] + "sql=SELECT * FROM %s WHERE %s" % (self.parent.tablename, where), + "database=%s" % self.parent.database, + "driver=%s" % self.parent.driver] # run command vDbSelect = cmd.Command (cmd=cmdv) @@ -203,11 +201,12 @@ i += 1 if i >= 32000: - self.log.write("Can display only 32000 lines") + self.log.write(_("Can display only 32000 lines")) break def OnCloseWindow(self, event): - if self.qlayer: self.map.delLayer(item='qlayer') + if self.qlayer: + self.map.delLayer(item='qlayer') def OnColClick(self,event): self._col = event.GetColumn() @@ -292,52 +291,52 @@ event.Skip() - #--------------------------------------------------- - # These methods are callbacks for implementing the - # "virtualness" of the list... - - # def OnGetItemText(self, item, col): - # index=self.itemIndexMap[item] - # s = self.itemDataMap[index][col] - # return s - - # def OnGetItemImage(self, item): - # index=self.itemIndexMap[item] - # if ( index % 2) == 0: - + # --------------------------------------------------- + # These methods are callbacks for implementing the + # "virtualness" of the list... + + # def OnGetItemText(self, item, col): + # index=self.itemIndexMap[item] + # s = self.itemDataMap[index][col] + # return s + + # def OnGetItemImage(self, item): + # index=self.itemIndexMap[item] + # if ( index % 2) == 0: + def OnGetItemAttr(self, item): index=self.itemIndexMap[item] return self.attr2 - #if ( index % 2) == 0: + # if ( index % 2) == 0: # return self.attr2 - #else: + # else: # return self.attr1 - #--------------------------------------------------- - # Matt C, 2006/02/22 - # Here's a better SortItems() method -- - # the ColumnSorterMixin.__ColumnSorter() method already handles the ascending/descending, - # and it knows to sort on another column if the chosen columns have the same value. - - # def SortItems(self,sorter=cmp): - # items = list(self.itemDataMap.keys()) - # # for i in range(len(items)): - # # items[i] = self.columns[self.columnNumber]["type"](items[i]) - # items.sort(self.Sorter) - # #items.sort(sorter) - # # for i in range(len(items)): - # # items[i] = str(items[i]) - # self.itemIndexMap = items - - # # redraw the list - # self.Refresh() - - # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py + # --------------------------------------------------- + # Matt C, 2006/02/22 + # Here's a better SortItems() method -- + # the ColumnSorterMixin.__ColumnSorter() method already handles the ascending/descending, + # and it knows to sort on another column if the chosen columns have the same value. + + # def SortItems(self,sorter=cmp): + # items = list(self.itemDataMap.keys()) + # # for i in range(len(items)): + # # items[i] = self.columns[self.columnNumber]["type"](items[i]) + # items.sort(self.Sorter) + # #items.sort(sorter) + # # for i in range(len(items)): + # # items[i] = str(items[i]) + # self.itemIndexMap = items + + # # redraw the list + # self.Refresh() + + # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py def GetListCtrl(self): return self - # # stolen from python2.4/site-packages/wx-2.8-gtk2-unicode/wx/lib/mixins/listctrl.py + # stolen from python2.4/site-packages/wx-2.8-gtk2-unicode/wx/lib/mixins/listctrl.py # def Sorter(self, key1,key2): # col = self._col # ascending = self._colSortFlag[col] @@ -374,8 +373,8 @@ def GetSortImages(self): return (self.sm_dn, self.sm_up) - #XXX Looks okay to remove this one (was present in the original demo) - #def getColumnText(self, index, col): + # XXX Looks okay to remove this one (was present in the original demo) + # def getColumnText(self, index, col): # item = self.GetItem(index, col) # return item.GetText() @@ -410,77 +409,72 @@ self.Select(idx,False) -# try: -# os.environ["GRASS_MESSAGE_FORMAT"] = "gui" -# cmd = "v.what -a east_north=%d,%d distance=%d map=%@%" % (x,y,100,self.tablename, self.self.mapset) -## self.cmd_output.write(cmd+"\n----------\n") -# p = Popen(cmd +" --verbose", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) -# -# oline = p.stderr.readline() -# while oline: -# oline = oline.strip() -# oline = p.stderr.readline() -# if oline.find("GRASS_INFO_MESSAGE")>-1: -# self.cmd_output.write(string.split(oline,maxsplit=1)[1]+"\n") -# elif oline.find("GRASS_INFO_WARNING")>-1: -# self.cmd_output.write("WARNING: "+string.split(oline,maxsplit=1)[1]+"\n") -# elif oline.find("GRASS_INFO_ERROR")>-1: -# self.cmd_output.write("ERROR: "+string.split(oline,maxsplit=1)[1]+"\n") -# -# oline = p.stdout.readline() -# while oline: -# oline = oline.strip() -## self.cmd_output.write(oline+"\n") -# print oline+"\n" -# print >> sys.stderr, oline -# oline = p.stdout.readline() -# -# if p.stdout < 0: -# print >> sys.stderr, "Child was terminated by signal", p.stdout -# elif p.stdout > 0: -# print >> sys.stderr, p.stdout -# pass -# except OSError, e: -# print >> sys.stderr, "Execution failed:", e + # try: + # os.environ["GRASS_MESSAGE_FORMAT"] = "gui" + # cmd = "v.what -a east_north=%d,%d distance=%d map=%@%" % (x,y,100,self.tablename, self.self.mapset) + # self.cmd_output.write(cmd+"\n----------\n") + # p = Popen(cmd +" --verbose", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) + # + # oline = p.stderr.readline() + # while oline: + # oline = oline.strip() + # oline = p.stderr.readline() + # if oline.find("GRASS_INFO_MESSAGE")>-1: + # self.cmd_output.write(string.split(oline,maxsplit=1)[1]+"\n") + # elif oline.find("GRASS_INFO_WARNING")>-1: + # self.cmd_output.write("WARNING: "+string.split(oline,maxsplit=1)[1]+"\n") + # elif oline.find("GRASS_INFO_ERROR")>-1: + # self.cmd_output.write("ERROR: "+string.split(oline,maxsplit=1)[1]+"\n") + # + # oline = p.stdout.readline() + # while oline: + # oline = oline.strip() + # self.cmd_output.write(oline+"\n") + # print oline+"\n" + # print >> sys.stderr, oline + # oline = p.stdout.readline() + # + # if p.stdout < 0: + # print >> sys.stderr, "Child was terminated by signal", p.stdout + # elif p.stdout > 0: + # print >> sys.stderr, p.stdout + # pass + # except OSError, e: + # print >> sys.stderr, "Execution failed:", e + # try: + # os.environ["GRASS_MESSAGE_FORMAT"] = "gui" + # cmd = "v.what -a east_north=%d,%d distance=%d map=%@%" % (x,y,100,self.tablename, self.self.mapset) + # self.cmd_output.write(cmd+"\n----------\n") + # p = Popen(cmd +" --verbose", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) + # + # oline = p.stderr.readline() + # while oline: + # oline = oline.strip() + # oline = p.stderr.readline() + # if oline.find("GRASS_INFO_MESSAGE")>-1: + # self.cmd_output.write(string.split(oline,maxsplit=1)[1]+"\n") + # elif oline.find("GRASS_INFO_WARNING")>-1: + # self.cmd_output.write("WARNING: "+string.split(oline,maxsplit=1)[1]+"\n") + # elif oline.find("GRASS_INFO_ERROR")>-1: + # self.cmd_output.write("ERROR: "+string.split(oline,maxsplit=1)[1]+"\n") + # + # oline = p.stdout.readline() + # while oline: + # oline = oline.strip() + # self.cmd_output.write(oline+"\n") + # print oline+"\n" + # print >> sys.stderr, oline + # oline = p.stdout.readline() + # + # if p.stdout < 0: + # print >> sys.stderr, "Child was terminated by signal", p.stdout + # elif p.stdout > 0: + # print >> sys.stderr, p.stdout + # pass + # except OSError, e: + # print >> sys.stderr, "Execution failed:", e - - - - -# try: -# os.environ["GRASS_MESSAGE_FORMAT"] = "gui" -# cmd = "v.what -a east_north=%d,%d distance=%d map=%@%" % (x,y,100,self.tablename, self.self.mapset) -## self.cmd_output.write(cmd+"\n----------\n") -# p = Popen(cmd +" --verbose", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) -# -# oline = p.stderr.readline() -# while oline: -# oline = oline.strip() -# oline = p.stderr.readline() -# if oline.find("GRASS_INFO_MESSAGE")>-1: -# self.cmd_output.write(string.split(oline,maxsplit=1)[1]+"\n") -# elif oline.find("GRASS_INFO_WARNING")>-1: -# self.cmd_output.write("WARNING: "+string.split(oline,maxsplit=1)[1]+"\n") -# elif oline.find("GRASS_INFO_ERROR")>-1: -# self.cmd_output.write("ERROR: "+string.split(oline,maxsplit=1)[1]+"\n") -# -# oline = p.stdout.readline() -# while oline: -# oline = oline.strip() -## self.cmd_output.write(oline+"\n") -# print oline+"\n" -# print >> sys.stderr, oline -# oline = p.stdout.readline() -# -# if p.stdout < 0: -# print >> sys.stderr, "Child was terminated by signal", p.stdout -# elif p.stdout > 0: -# print >> sys.stderr, p.stdout -# pass -# except OSError, e: -# print >> sys.stderr, "Execution failed:", e - class AttributeManager(wx.Frame): """ The main window @@ -590,6 +584,86 @@ pagesizer.Fit(self) self.Layout() +class UpdateRecordDialog(wx.Dialog): + """ + Standard dialog used for adding new record into the attribute table + """ + def __init__(self, parent, map, layer=1, cat=1, title=_("Add new record into table"), style=wx.DEFAULT_DIALOG_STYLE): + wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style) + + # dialog body + flexSizer = wx.FlexGridSizer (cols=4, hgap=3, vgap=3) + flexSizer.AddGrowableCol(0) + + selectCommand = cmd.Command(cmd=["v.db.select", "-c", + "map=%s" % map, "layer=%d" % layer, + "where=cat=%d" % cat, "--q"]) + + if selectCommand.returncode == 0: + values = [] + valueString = selectCommand.module_stdout.readline().replace("\n", "") + for value in valueString.split('|'): + values.append (value) + values.reverse() # reverse list because of calling 'pop' + else: + values = None + + + columnsCommand = cmd.Command (cmd=["v.info", "-c", + "map=%s" % map, "layer=%d" % layer, "--q"]) + + + # determine column names and types + columns = [] + if columnsCommand.returncode == 0: + while True: + columnDef = columnsCommand.module_stdout.readline() # type|name + if not columnDef: + break + columnType, columnName = columnDef.replace("\n","").split('|') + columns.append ((columnName, columnType)) + else: + pass + + for name, type in columns: + colName = wx.StaticText(parent=self, id=wx.ID_ANY, label=name) + colType = wx.StaticText(parent=self, id=wx.ID_ANY, label="[" + type + "]") + delimiter = wx.StaticText(parent=self, id=wx.ID_ANY, label=":") + if name == "cat": + colValue = wx.StaticText(parent=self, id=wx.ID_ANY, label=values.pop()) + else: + colValue = wx.TextCtrl(parent=self, id=wx.ID_ANY, value=values.pop(), size=(250, -1)) # TODO: validator + + flexSizer.Add(colName, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(colType, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(delimiter, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(colValue, proportion=0, flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL) + + # buttons + btnCancel = wx.Button(self, wx.ID_CANCEL) + btnOk = wx.Button(self, wx.ID_OK, _("OK") ) + btnOk.SetDefault() + + # bindigs + #btnApply.Bind(wx.EVT_BUTTON, self.OnApply) + #btn_ok.Bind(wx.EVT_BUTTON, self.OnOK) + + # sizers + border = wx.BoxSizer(wx.VERTICAL) + border.Add(item=flexSizer, proportion=1, flag=wx.ALL, border=5) + + btnSizer = wx.StdDialogButtonSizer() + btnSizer.AddButton(btnCancel) + btnSizer.AddButton(btnOk) + btnSizer.Realize() + + mainSizer = wx.BoxSizer(wx.VERTICAL) + mainSizer.Add(item=border, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) + mainSizer.Add(item=btnSizer, proportion=0, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) + + self.SetSizer(mainSizer) + mainSizer.Fit(self) + def main(argv=None): if argv is None: argv = sys.argv @@ -607,7 +681,7 @@ #wx.InitAllImageHandlers() app = wx.PySimpleApp() - f = AttributeManager(parent=None, id=wx.ID_ANY, title="GRASS Attribute Table Manager", size=(700,600), vectmap=argv[1]) + f = AttributeManager(parent=None, id=wx.ID_ANY, title=_("GRASS Attribute Table Manager"), size=(700,600), vectmap=argv[1]) app.MainLoop() if __name__ == '__main__': Modified: trunk/grassaddons/gui/gui_modules/digit.py =================================================================== --- trunk/grassaddons/gui/gui_modules/digit.py 2007-06-19 15:05:29 UTC (rev 859) +++ trunk/grassaddons/gui/gui_modules/digit.py 2007-06-20 15:44:58 UTC (rev 860) @@ -15,7 +15,7 @@ (2) Reimplentation of v.digit (VDigit) AUTHORS: The GRASS Development Team - Martin Landa + Martin Landa COPYRIGHT: (C) 2007 by the GRASS Development Team This program is free software under the GNU General Public @@ -27,6 +27,7 @@ import wx.lib.colourselect as csel import cmd +import dbm from debug import Debug as Debug class Digit: @@ -91,7 +92,7 @@ # run the command vedit = cmd.Command(cmd=command, stdin=input) - + class VDigit(Digit): """ Prototype of digitization class based on v.digit reimplementation @@ -171,11 +172,16 @@ panel = wx.Panel(parent=notebook, id=wx.ID_ANY) notebook.AddPage(page=panel, text=_("Settings")) - sizer = wx.BoxSizer(wx.VERTICAL) + border = wx.BoxSizer(wx.VERTICAL) + box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Display")) + sizer = wx.StaticBoxSizer(box, wx.VERTICAL) + + # + # display section + # flexSizer = wx.FlexGridSizer (cols=3, hgap=5, vgap=5) flexSizer.AddGrowableCol(0) - for label, defaultValue in self.__SettingsData(): textLabel = wx.StaticText(parent=panel, id=wx.ID_ANY, label=label) value = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, value=defaultValue, min=1, max=1e6) @@ -184,11 +190,34 @@ flexSizer.Add(textLabel, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL) flexSizer.Add(value, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE) flexSizer.Add(units, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE) + sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) + border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=10) + + # + # attributes + # + box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Digitize new feature")) + sizer = wx.StaticBoxSizer(box, wx.VERTICAL) + # checkbox + addRecord = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_("Add new record into table")) + sizer.Add(item=addRecord, proportion=0, flag=wx.ALL, border=5) + # settings + flexSizer = wx.FlexGridSizer(cols=2, hgap=3, vgap=3) + settings = ((_("Layer"), 1), (_("Category"), 1), (_("Mode"), _("Next to use"))) + for label, value in settings: + text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=label) + if label is not "Mode": + value = wx.TextCtrl(parent=panel, id=wx.ID_ANY, value=str(value)) # TODO: validator + else: + value = wx.Choice(parent=panel, id=wx.ID_ANY, choices=[_("Next to use"), _("Manual entry"), _("No category")]) + flexSizer.Add(item=text, proportion=0, flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(item=value, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + + sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1) + border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10) + + panel.SetSizer(border) - sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) - - panel.SetSizer(sizer) - return panel def __SymbologyData(self): Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-19 15:05:29 UTC (rev 859) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-20 15:44:58 UTC (rev 860) @@ -53,6 +53,7 @@ import select import disp_print import cmd +import dbm import defaultfont as defaultfont import histogram as histogram import profile as profile @@ -701,6 +702,10 @@ type=digit.type, x=east, y=north) + # add new record into atribute table + if dbm.UpdateRecordDialog(parent=self, map=map, layer=1).ShowModal() == wx.ID_OK: + pass + self.render=True self.UpdateMap() # redraw map Modified: trunk/grassaddons/gui/gui_modules/sqlbuilder.py =================================================================== --- trunk/grassaddons/gui/gui_modules/sqlbuilder.py 2007-06-19 15:05:29 UTC (rev 859) +++ trunk/grassaddons/gui/gui_modules/sqlbuilder.py 2007-06-20 15:44:58 UTC (rev 860) @@ -10,9 +10,9 @@ import time import grassenv -import images -imagepath = images.__path__[0] -sys.path.append(imagepath) +#import images +#imagepath = images.__path__[0] +#sys.path.append(imagepath) class SQLFrame(wx.Frame): Modified: trunk/grassaddons/gui/gui_modules/toolbars.py =================================================================== --- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-19 15:05:29 UTC (rev 859) +++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-20 15:44:58 UTC (rev 860) @@ -291,8 +291,11 @@ Quit digitization tool """ # stop editing of the currently selected map layer - self.StopEditing(self.layers[self.layerSelectedID]) - + try: + self.StopEditing(self.layers[self.layerSelectedID]) + except: + pass + # disable the toolbar self.parent.RemoveToolbar ("digit") From landa at grass.itc.it Thu Jun 21 11:08:46 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Thu Jun 21 11:08:48 2007 Subject: [grass-addons] r861 - trunk/grassaddons/gui/gui_modules Message-ID: <200706210908.l5L98kwr007957@grass.itc.it> Author: landa Date: 2007-06-21 11:08:46 +0200 (Thu, 21 Jun 2007) New Revision: 861 Modified: trunk/grassaddons/gui/gui_modules/cmd.py Log: Fix minor bug in debug mode Modified: trunk/grassaddons/gui/gui_modules/cmd.py =================================================================== --- trunk/grassaddons/gui/gui_modules/cmd.py 2007-06-20 15:44:58 UTC (rev 860) +++ trunk/grassaddons/gui/gui_modules/cmd.py 2007-06-21 09:08:46 UTC (rev 861) @@ -17,21 +17,24 @@ for details. """ +# use Popen class or os.popen3 method +usePopenClass = True + import os, sys import wx -from debug import Debug as Debug - -usePopenClass = True - try: import subprocess except: - CompatPath = os.getenv("GISBASE") + "/etc/wx" + CompatPath = os.path.join(os.getenv("GISBASE"), "etc", "wx", "compat") sys.path.append(CompatPath) - from compat import subprocess as subprocess + import subprocess +GuiModulePath = os.path.join(os.getenv("GISBASE"), "etc", "wx", "gui_modules") +sys.path.append(GuiModulePath) + import grassenv +from debug import Debug as Debug class EndOfCommand(Exception): """ @@ -118,20 +121,23 @@ print >> sys.stderr, msg[1] if dlgMsg == "gui": - dlg = wx.MessageDialog(None, _("Execution failed: '%s'") % \ - ' '.join(self.cmd), _("Error"), - wx.OK | wx.ICON_ERROR) + dlg = wx.MessageDialog(None, _("Execution failed: '%s'") % (' '.join(self.cmd)), + _("Error"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() else: # otherwise 'txt' - print >> sys.stderr, _("Execution failed: '%s'") % self.cmd + print >> sys.stderr, "Execution failed: '%s'" % (' '.join(self.cmd)) else: self.returncode = None - Debug.msg (3, "Command(): cmd=%s, wait=%d, returncode=%d" % \ - (self.cmd, wait, self.returncode)) + if self.returncode is not None: + Debug.msg (3, "Command(): cmd=%s, wait=%d, returncode=%d" % \ + (' '.join(self.cmd), wait, self.returncode)) + else: + Debug.msg (3, "Command(): cmd=%s, wait=%d, returncode=?" % \ + (' '.join(self.cmd), wait)) def Run(self, verbose=False): """ @@ -163,7 +169,7 @@ # d.rast verbosely, wait for process termination print "Running d.rast..." - cmd = Command(cmd=["d.rast", "elevation.dem"], verbose=True, wait=True) + cmd = Command(cmd=["d.rast", "elevation.dem"], verbose=True, wait=True, dlgMsg='txt') if cmd.returncode == None: print "RUNNING" @@ -184,7 +190,7 @@ cmd = Command(cmd=["v.net.path", "in=roads@PERMANENT", "out=tmp dmax=100000", "--o"], stdin="0 593527.6875 4925297.0625 602083.875 4917545.8125", verbose=False, - wait=True) + wait=True, dlgMsg='txt') if cmd.returncode == None: print "RUNNING" @@ -197,7 +203,7 @@ # returncode will be None print "Running d.vect tmp..." - cmd = Command(["d.vect", "tmp"], verbose=False, wait=False) + cmd = Command(["d.vect", "tmp"], verbose=False, wait=False, dlgMsg='txt') if cmd.returncode == None: print "RUNNING" From landa at grass.itc.it Thu Jun 21 17:35:02 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Thu Jun 21 17:35:05 2007 Subject: [grass-addons] r862 - trunk/grassaddons/gui/gui_modules Message-ID: <200706211535.l5LFZ2fD011632@grass.itc.it> Author: landa Date: 2007-06-21 17:35:02 +0200 (Thu, 21 Jun 2007) New Revision: 862 Modified: trunk/grassaddons/gui/gui_modules/dbm.py trunk/grassaddons/gui/gui_modules/digit.py trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/select.py trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Digitization tool: dialog 'settings' improved Modified: trunk/grassaddons/gui/gui_modules/dbm.py =================================================================== --- trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-21 09:08:46 UTC (rev 861) +++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-21 15:35:02 UTC (rev 862) @@ -5,7 +5,8 @@ * Log * VirtualAttributeList * AttributeManager - + * UpdateRecordDialog + PURPOSE: GRASS attribute table manager This program is based on FileHunter, published in 'The wxPython Linux @@ -591,10 +592,7 @@ def __init__(self, parent, map, layer=1, cat=1, title=_("Add new record into table"), style=wx.DEFAULT_DIALOG_STYLE): wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style) - # dialog body - flexSizer = wx.FlexGridSizer (cols=4, hgap=3, vgap=3) - flexSizer.AddGrowableCol(0) - + # select values selectCommand = cmd.Command(cmd=["v.db.select", "-c", "map=%s" % map, "layer=%d" % layer, "where=cat=%d" % cat, "--q"]) @@ -608,12 +606,12 @@ else: values = None + + # determine column names and types columnsCommand = cmd.Command (cmd=["v.info", "-c", "map=%s" % map, "layer=%d" % layer, "--q"]) - - # determine column names and types columns = [] if columnsCommand.returncode == 0: while True: @@ -625,9 +623,16 @@ else: pass + # dialog body + border = wx.BoxSizer(wx.VERTICAL) + box = wx.StaticBox (parent=self, id=wx.ID_ANY, label=" %s " % _("Attributes")) + sizer = wx.StaticBoxSizer(box, wx.VERTICAL) + flexSizer = wx.FlexGridSizer (cols=4, hgap=3, vgap=3) + flexSizer.AddGrowableCol(0) + for name, type in columns: colName = wx.StaticText(parent=self, id=wx.ID_ANY, label=name) - colType = wx.StaticText(parent=self, id=wx.ID_ANY, label="[" + type + "]") + colType = wx.StaticText(parent=self, id=wx.ID_ANY, label="[" + type.lower() + "]") delimiter = wx.StaticText(parent=self, id=wx.ID_ANY, label=":") if name == "cat": colValue = wx.StaticText(parent=self, id=wx.ID_ANY, label=values.pop()) @@ -649,8 +654,8 @@ #btn_ok.Bind(wx.EVT_BUTTON, self.OnOK) # sizers - border = wx.BoxSizer(wx.VERTICAL) - border.Add(item=flexSizer, proportion=1, flag=wx.ALL, border=5) + sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) + border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1) btnSizer = wx.StdDialogButtonSizer() btnSizer.AddButton(btnCancel) Modified: trunk/grassaddons/gui/gui_modules/digit.py =================================================================== --- trunk/grassaddons/gui/gui_modules/digit.py 2007-06-21 09:08:46 UTC (rev 861) +++ trunk/grassaddons/gui/gui_modules/digit.py 2007-06-21 15:35:02 UTC (rev 862) @@ -34,15 +34,43 @@ """ Abstract digitization class """ - def __init__(self): - pass - + def __init__(self, settings=None): + if not settings: + self.settings = {} + # symbology + self.settings["symbolBackground"] = (None, "white") # enabled, color + self.settings["symbolHighlight"] = (None, "yellow") + self.settings["symbolPoint"] = (True, "black") + self.settings["symbolLine"] = (True, "black") + self.settings["symbolBoundaryNo"] = (True, "grey") + self.settings["symbolBoundaryOne"] = (True, "orange") + self.settings["symbolBoundaryTwo"] = (True, "green") + self.settings["symbolCentroidIn"] = (True, "blue") + self.settings["symbolCentroidOut"] = (True, "brown") + self.settings["symbolCentroidDup"] = (True, "violet") + self.settings["symbolNodeOne"] = (True, "red") + self.settings["symbolNodeTwo"] = (True, "dark green") + + # display + self.settings["snapping"] = (10, "screen pixels") # value, unit + self.settings["lineWidth"] = (2, "screen pixels") + # digitize new record + self.settings["addRecord"] = True + self.settings["layer"] = 1 + self.settings["category"] = 1 + self.settings["categoryMode"] = "Next to use" + else: + self.settings = settings + class VEdit(Digit): """ Prototype of digitization class based on v.edit command Note: This should be replaced by VDigit class. """ + def __init__(self, settings=None): + Digit.__init__(self, settings) + def AddPoint (self, map, type, x, y, z=None): """ Add point/centroid to the vector map layer @@ -108,6 +136,8 @@ def __init__(self, parent, title, style): wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style) + self.parent = parent # mapdisplay.BufferedWindow class instance + # notebook notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT) self.__CreateSymbologyPage(notebook) @@ -120,8 +150,8 @@ btnOk.SetDefault() # bindigs - #btnApply.Bind(wx.EVT_BUTTON, self.OnApply) - #btn_ok.Bind(wx.EVT_BUTTON, self.OnOK) + btnApply.Bind(wx.EVT_BUTTON, self.OnApply) + btnOk.Bind(wx.EVT_BUTTON, self.OnOK) # sizers btnSizer = wx.StdDialogButtonSizer() @@ -147,16 +177,21 @@ flexSizer = wx.FlexGridSizer (cols=3, hgap=5, vgap=5) flexSizer.AddGrowableCol(0) - - for label, isCheckbox, color in self.__SymbologyData(): + + self.symbology = {} + for label, key in self.__SymbologyData(): textLabel = wx.StaticText(panel, wx.ID_ANY, label) - if isCheckbox: + color = csel.ColourSelect(panel, id=wx.ID_ANY, colour=Digit.settings[key][1], size=(25, 25)) + isEnabled = Digit.settings[key][0] + if isEnabled is not None: enabled = wx.CheckBox(panel, id=wx.ID_ANY, label="") + enabled.SetValue(isEnabled) + self.symbology[key] = (enabled, color) else: enabled = (1, 1) - color = csel.ColourSelect(panel, id=wx.ID_ANY, colour=color, size=(25, 25)) + self.symbology[key] = (None, color) - flexSizer.Add(textLabel, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) + flexSizer.Add(textLabel, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(enabled, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE) flexSizer.Add(color, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE) @@ -174,48 +209,84 @@ border = wx.BoxSizer(wx.VERTICAL) - box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Display")) - sizer = wx.StaticBoxSizer(box, wx.VERTICAL) - # # display section # + box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Display")) + sizer = wx.StaticBoxSizer(box, wx.VERTICAL) flexSizer = wx.FlexGridSizer (cols=3, hgap=5, vgap=5) flexSizer.AddGrowableCol(0) - for label, defaultValue in self.__SettingsData(): - textLabel = wx.StaticText(parent=panel, id=wx.ID_ANY, label=label) - value = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, value=defaultValue, min=1, max=1e6) - units = wx.Choice(parent=panel, id=wx.ID_ANY, choices=["screen pixels", "map units"]) - - flexSizer.Add(textLabel, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL) - flexSizer.Add(value, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE) - flexSizer.Add(units, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE) - sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) - border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=10) + # snapping + text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Snapping threshold")) + self.snappingValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(50, -1), + value=str(Digit.settings["snapping"][0]), min=1, max=1e6) + self.snappingUnit = wx.ComboBox(parent=panel, id=wx.ID_ANY, size=(125, -1), + choices=["screen pixels", "map units"]) + self.snappingUnit.SetValue(Digit.settings["snapping"][1]) + flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(self.snappingValue, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE) + flexSizer.Add(self.snappingUnit, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE) + # line width + text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Line width")) + self.lineWidthValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(50, -1), + value=str(Digit.settings["lineWidth"][0]), min=1, max=1e6) + self.lineWidthUnit = wx.ComboBox(parent=panel, id=wx.ID_ANY, size=(125, -1), + choices=["screen pixels", "map units"]) + self.lineWidthUnit.SetValue(Digit.settings["lineWidth"][1]) + flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(self.lineWidthValue, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE) + flexSizer.Add(self.lineWidthUnit, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE) + sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1) + border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5) + # # attributes # box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Digitize new feature")) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) # checkbox - addRecord = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_("Add new record into table")) - sizer.Add(item=addRecord, proportion=0, flag=wx.ALL, border=5) + self.addRecord = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_("Add new record into table")) + self.addRecord.SetValue(Digit.settings["addRecord"]) + sizer.Add(item=self.addRecord, proportion=0, flag=wx.ALL | wx.EXPAND, border=1) # settings flexSizer = wx.FlexGridSizer(cols=2, hgap=3, vgap=3) + flexSizer.AddGrowableCol(0) settings = ((_("Layer"), 1), (_("Category"), 1), (_("Mode"), _("Next to use"))) - for label, value in settings: - text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=label) - if label is not "Mode": - value = wx.TextCtrl(parent=panel, id=wx.ID_ANY, value=str(value)) # TODO: validator - else: - value = wx.Choice(parent=panel, id=wx.ID_ANY, choices=[_("Next to use"), _("Manual entry"), _("No category")]) - flexSizer.Add(item=text, proportion=0, flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL) - flexSizer.Add(item=value, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) - + # layer + text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Layer")) + self.layer = wx.TextCtrl(parent=panel, id=wx.ID_ANY, size=(125, -1), + value=str(Digit.settings["layer"])) # TODO: validator + if not self.addRecord.IsChecked(): + self.layer.Enable(False) + flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(item=self.layer, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + # category number + text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Category number")) + self.category = wx.TextCtrl(parent=panel, id=wx.ID_ANY, size=(125, -1), + value=str(Digit.settings["category"])) # TODO: validator + if Digit.settings["categoryMode"] != "Manual entry" or not self.addRecord.IsChecked(): + self.category.SetEditable(False) + self.category.Enable(False) + flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(item=self.category, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + # category mode + text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Category mode")) + self.categoryMode = wx.ComboBox(parent=panel, id=wx.ID_ANY, style=wx.CB_SIMPLE | wx.CB_READONLY, size=(125, -1), + choices=[_("Next to use"), _("Manual entry"), _("No category")]) + self.categoryMode.SetValue(Digit.settings["categoryMode"]) + if not self.addRecord.IsChecked(): + self.categoryMode.Enable(False) + flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(item=self.categoryMode, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1) - border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10) + border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5) + # bindings + self.Bind(wx.EVT_CHECKBOX, self.OnChangeAddRecord, self.addRecord) + self.Bind(wx.EVT_COMBOBOX, self.OnChangeCategoryMode, self.categoryMode) + panel.SetSizer(border) return panel @@ -226,35 +297,77 @@ label | checkbox | color """ - + return ( - ("Background", False, "white"), - ("Highlight", False, "yellow"), - ("Point", True, "black"), - ("Line", True, "black"), - ("Boundary (no area)", True, "grey"), - ("Boundary (one area)", True, "orange"), - ("Boundary (two areas)", True, "green"), - ("Centroid (in area)", True, "blue"), - ("Centroid (outside area)", True, "brown"), - ("Centroid (duplicate in area)", True, "violet"), - ("Node (one line)", True, "red"), - ("Node (two lines)", True, "dark green")) + ("Background", "symbolBackground"), + ("Highlight", "symbolHighlight"), + ("Point", "symbolPoint"), + ("Line", "symbolLine"), + ("Boundary (no area)", "symbolBoundaryNo"), + ("Boundary (one area)", "symbolBoundaryOne"), + ("Boundary (two areas)", "symbolBoundaryTwo"), + ("Centroid (in area)", "symbolCentroidIn"), + ("Centroid (outside area)", "symbolCentroidOut"), + ("Centroid (duplicate in area)", "symbolCentroidDup"), + ("Node (one line)", "symbolNodeOne"), + ("Node (two lines)", "symbolNodeTwo")) - def __SettingsData(self): - """ - Data for __CreateSettingsPage() + def OnChangeCategoryMode(self, event): + """Change category mode""" - label | checkbox | default value - """ + mode = event.GetString() + if mode == "Manual entry": # enable + self.category.Enable(True) + self.category.SetEditable(True) + elif self.category.IsEnabled(): # disable + self.category.SetEditable(False) + self.category.Enable(False) - return ( - (_("Snapping threshold"), "10"), - (_("Line width"), "2") - ) - + def OnChangeAddRecord(self, event): + """Checkbox 'Add new record' status changed""" + if not event.IsChecked(): + status = False + else: + status = True + + self.layer.Enable(status) + if status == False: + self.category.Enable(status) + elif status == True and self.categoryMode.GetCurrentSelection() == 1: + self.category.Enable(status) + self.categoryMode.Enable(status) + def OnOK(self, event): + """Button 'OK' clicked""" + self.UpdateSettings() + self.Close() + def OnApply(self, event): + """Button 'Apply' clicked""" + self.UpdateSettings() + + def UpdateSettings(self): + """Update Digit.settings""" + try: + # symbology + for key, (enabled, color) in self.symbology.iteritems(): + if enabled: + Digit.settings[key] = (enabled.IsChecked(), color.GetColour()) + else: + Digit.settings[key] = (None, color.GetColour()) + # display + Digit.settings["snapping"] = (int(self.snappingValue.GetValue()), # value + self.snappingUnit.GetValue()) # unit + Digit.settings["lineWidth"] = (int(self.lineWidthValue.GetValue()), + self.lineWidthUnit.GetValue()) + # digitize new feature + Digit.settings["addRecord"] = self.addRecord.IsChecked() + Digit.settings["layer"] = int(self.layer.GetValue()) + Digit.settings["category"] = int(self.category.GetValue()) + Digit.settings["categoryMode"] = self.categoryMode.GetValue() + except: + pass + ############################## # digitization class instance ############################## Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-21 09:08:46 UTC (rev 861) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-21 15:35:02 UTC (rev 862) @@ -251,7 +251,7 @@ pdc.EndDrawing() return - if pdctype == 'image': + if pdctype == 'image': # draw selected image bitmap = wx.BitmapFromImage(img) w,h = bitmap.GetSize() pdc.DrawBitmap(bitmap, coords[0], coords[1], True) # draw the composite map @@ -298,15 +298,15 @@ pdc.SetIdBounds(drawid,(x1,y1,x2,y2)) self.ovlcoords[drawid] = [x1,y1,x2,y2] - elif pdctype == 'point': #draw point - pen = self.RandomPen() - pdc.SetPen(pen) + elif pdctype == 'point': # draw point + ## pen = self.RandomPen() + pdc.SetPen(self.pen) pdc.DrawPoint(coords[0], coords[1]) - coords[0] = coords[0] - 5 - coords[1] = coords[1] - 5 - coords[2] = coords[0] + 5 - coords[3] = coords[1] + 5 - pdc.SetIdBounds(drawid,(coords[0], coords[1], coords[2], coords[3])) + coordsBound = (coords[0] - 5, + coords[1] - 5, + coords[0] + 5, + coords[1] + 5) + pdc.SetIdBounds(drawid, coordsBound) self.ovlcoords[drawid] = coords elif pdctype == 'text': # draw text on top of map @@ -581,7 +581,7 @@ Debug.msg (5, "BufferedWindow.DrawLines(): coords=%s" % \ self.polycoords) - self.plineid = wx.ID_NEW+1 + self.plineid = wx.ID_NEW + 1 if len(self.polycoords) > 0: self.Draw(self.pdc, drawid=self.plineid, pdctype='polyline', coords=self.polycoords) @@ -695,13 +695,13 @@ if map: if digit.type in ["point", "centroid"]: # add new point + self.mouse['begin'] = event.GetPositionTuple()[:] + self.Draw(self.pdc, drawid=self.lineid, pdctype='point', coords=self.mouse['begin']) east, north = self.Pixel2Cell(event.GetPositionTuple()[0], event.GetPositionTuple()[1]) - Digit.AddPoint(map=map, type=digit.type, x=east, y=north) - # add new record into atribute table if dbm.UpdateRecordDialog(parent=self, map=map, layer=1).ShowModal() == wx.ID_OK: pass Modified: trunk/grassaddons/gui/gui_modules/select.py =================================================================== --- trunk/grassaddons/gui/gui_modules/select.py 2007-06-21 09:08:46 UTC (rev 861) +++ trunk/grassaddons/gui/gui_modules/select.py 2007-06-21 15:35:02 UTC (rev 862) @@ -16,8 +16,14 @@ """ import os +import sys + import wx import wx.combo + +GuiModulePath = os.path.join(os.getenv("GISBASE"), "etc", "wx", "gui_modules") +sys.path.append(GuiModulePath) + import cmd class Select(wx.combo.ComboCtrl): Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-21 09:08:46 UTC (rev 861) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-21 15:35:02 UTC (rev 862) @@ -354,7 +354,7 @@ def RenameLayer (self, event): """Rename layer""" - pass + self.EditLabel(self.layer_selected) def AddLayer(self, ltype): """Add layer, create MapLayer instance""" From landa at grass.itc.it Fri Jun 22 14:19:47 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Fri Jun 22 14:19:49 2007 Subject: [grass-addons] r863 - trunk/grassaddons/gui/gui_modules Message-ID: <200706221219.l5MCJlKD026268@grass.itc.it> Author: landa Date: 2007-06-22 14:19:47 +0200 (Fri, 22 Jun 2007) New Revision: 863 Modified: trunk/grassaddons/gui/gui_modules/cmd.py Log: ReadStdOutput() method added to Command class. Set py-indent-offset to 4 Modified: trunk/grassaddons/gui/gui_modules/cmd.py =================================================================== --- trunk/grassaddons/gui/gui_modules/cmd.py 2007-06-21 15:35:02 UTC (rev 862) +++ trunk/grassaddons/gui/gui_modules/cmd.py 2007-06-22 12:19:47 UTC (rev 863) @@ -10,7 +10,7 @@ AUTHORS: The GRASS Development Team Original author: Jachym Cepicky Martin Landa - + 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 @@ -24,15 +24,15 @@ import wx try: - import subprocess + import subprocess except: - CompatPath = os.path.join(os.getenv("GISBASE"), "etc", "wx", "compat") - sys.path.append(CompatPath) - import subprocess - -GuiModulePath = os.path.join(os.getenv("GISBASE"), "etc", "wx", "gui_modules") -sys.path.append(GuiModulePath) - + CompatPath = os.path.join(os.getenv("GISBASE"), "etc", "wx", "compat") + sys.path.append(CompatPath) + import subprocess + + GuiModulePath = os.path.join(os.getenv("GISBASE"), "etc", "wx", "gui_modules") + sys.path.append(GuiModulePath) + import grassenv from debug import Debug as Debug @@ -41,19 +41,19 @@ End of command indicator """ def __str__(self): - return "End of command" - + return "End of command" + class Command: """ Run command on the background - + Parameters: - cmd - command string (given as list) - stdin - standard input stream - verbose - verbose mode (GRASS commands '--v') - wait - wait for childer execution - dlgMsg - type of error message (None, gui, txt) [only if wait=True] - + cmd - command string (given as list) + stdin - standard input stream + verbose - verbose mode (GRASS commands '--v') + wait - wait for childer execution + dlgMsg - type of error message (None, gui, txt) [only if wait=True] + Usage: cmd = Command(cmd=['d.rast', 'elevation.dem'], verbose=True, wait=True) @@ -74,40 +74,40 @@ # input self.module_stdin = None self.cmd = cmd - + self.module = None - + # output self.module_stderr = None self.module_msg = [] # list of messages (msgtype, content) - + os.environ["GRASS_MESSAGE_FORMAT"] = "gui" # run command if not usePopenClass: - Debug.msg(3, "Command.__init__(): [popen3] cmd=%s" % ' '.join(cmd)) - (self.module_stdin, self.module_stdout, self.module_stderr) = \ - os.popen3(' '.join(self.cmd)) + Debug.msg(3, "Command.__init__(): [popen3] cmd=%s" % ' '.join(cmd)) + (self.module_stdin, self.module_stdout, self.module_stderr) = \ + os.popen3(' '.join(self.cmd)) else: - Debug.msg(3, "Command.__init__(): [Popen] cmd=%s" % ' '.join(cmd)) - self.module = subprocess.Popen(self.cmd, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - close_fds=True) - self.module_stdin = self.module.stdin - self.module_stderr = self.module.stderr - self.module_stdout = self.module.stdout - + Debug.msg(3, "Command.__init__(): [Popen] cmd=%s" % ' '.join(cmd)) + self.module = subprocess.Popen(self.cmd, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + close_fds=True) + self.module_stdin = self.module.stdin + self.module_stderr = self.module.stderr + self.module_stdout = self.module.stdout + if stdin: - self.module_stdin.write(stdin) - self.module_stdin.close() + self.module_stdin.write(stdin) + self.module_stdin.close() os.environ["GRASS_MESSAGE_FORMAT"] = "text" try: - self.Run(verbose) + self.Run(verbose) except EndOfCommand: - pass + pass if self.module: if wait: @@ -116,28 +116,26 @@ # failed? if dlgMsg and self.returncode != 0: - # print error messages - for msg in self.module_msg: - print >> sys.stderr, msg[1] + # print error messages + for msg in self.module_msg: + print >> sys.stderr, msg[1] - if dlgMsg == "gui": - dlg = wx.MessageDialog(None, _("Execution failed: '%s'") % (' '.join(self.cmd)), - _("Error"), wx.OK | wx.ICON_ERROR) - dlg.ShowModal() - dlg.Destroy() - else: # otherwise 'txt' - print >> sys.stderr, "Execution failed: '%s'" % (' '.join(self.cmd)) - - + if dlgMsg == "gui": + dlg = wx.MessageDialog(None, _("Execution failed: '%s'") % (' '.join(self.cmd)), + _("Error"), wx.OK | wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() + else: # otherwise 'txt' + print >> sys.stderr, "Execution failed: '%s'" % (' '.join(self.cmd)) else: self.returncode = None - + if self.returncode is not None: - Debug.msg (3, "Command(): cmd=%s, wait=%d, returncode=%d" % \ - (' '.join(self.cmd), wait, self.returncode)) + Debug.msg (3, "Command(): cmd=%s, wait=%d, returncode=%d" % \ + (' '.join(self.cmd), wait, self.returncode)) else: - Debug.msg (3, "Command(): cmd=%s, wait=%d, returncode=?" % \ - (' '.join(self.cmd), wait)) + Debug.msg (3, "Command(): cmd=%s, wait=%d, returncode=?" % \ + (' '.join(self.cmd), wait)) def Run(self, verbose=False): """ @@ -157,20 +155,35 @@ self.module_msg.append((msgtype, content.strip())) else: # write only fatal errors and warnigs if msgtype.find("GRASS_INFO_ERROR") > -1 or \ - msgtype.find("GRASS_INFO_WARNING") > -1: + msgtype.find("GRASS_INFO_WARNING") > -1: self.module_msg.append((msgtype, content.strip())) + + return - return - + def ReadStdOutput(self): + """Read standard output and return list of lines + + Note: Remove '\n' from the lines (TODO: '\r\n' ??) + """ + lineList = [] + while True: + line = self.module_stdout.readline() + if not line: + break + line.replace('\n', '') + lineList.append(line) + + return lineList + # testing ... if __name__ == "__main__": #print __doc__ - + # d.rast verbosely, wait for process termination print "Running d.rast..." - + cmd = Command(cmd=["d.rast", "elevation.dem"], verbose=True, wait=True, dlgMsg='txt') - + if cmd.returncode == None: print "RUNNING" elif cmd.returncode == 0: From landa at grass.itc.it Fri Jun 22 17:01:51 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Fri Jun 22 17:01:52 2007 Subject: [grass-addons] r864 - trunk/grassaddons/gui/gui_modules Message-ID: <200706221501.l5MF1pqN028343@grass.itc.it> Author: landa Date: 2007-06-22 17:01:50 +0200 (Fri, 22 Jun 2007) New Revision: 864 Modified: trunk/grassaddons/gui/gui_modules/dbm.py trunk/grassaddons/gui/gui_modules/digit.py trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/toolbars.py Log: Digitization tool: minor updates Modified: trunk/grassaddons/gui/gui_modules/dbm.py =================================================================== --- trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-22 12:19:47 UTC (rev 863) +++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-22 15:01:50 UTC (rev 864) @@ -589,85 +589,121 @@ """ Standard dialog used for adding new record into the attribute table """ - def __init__(self, parent, map, layer=1, cat=1, title=_("Add new record into table"), style=wx.DEFAULT_DIALOG_STYLE): - wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style) + def __init__(self, parent, map, layer=1, cat=1, title=_("Add new record into table"), + style=wx.DEFAULT_DIALOG_STYLE, pos=wx.DefaultPosition): + wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style, pos=pos) + # determine column names and types + columnsCommand = cmd.Command (cmd=["v.db.connect", "-c", + "map=%s" % map, "layer=%d" % layer, "--q"]) + + self.table = None + self.columns = [] # (name, type, value) + if columnsCommand.returncode == 0: + output = columnsCommand.ReadStdOutput() + for line in output: + columnType, columnName = line.split('|') + self.columns.append ([columnName.replace('\n', ''), columnType]) + else: + return + # select values selectCommand = cmd.Command(cmd=["v.db.select", "-c", "map=%s" % map, "layer=%d" % layer, "where=cat=%d" % cat, "--q"]) if selectCommand.returncode == 0: - values = [] - valueString = selectCommand.module_stdout.readline().replace("\n", "") - for value in valueString.split('|'): - values.append (value) - values.reverse() # reverse list because of calling 'pop' - else: - values = None + idx = 0 + try: + valueString = selectCommand.ReadStdOutput()[0] # read first line + for value in valueString.split('|'): + self.columns[idx].append(value.replace('\n', '')) + idx = idx + 1 + except: # default values + for col in self.columns: + col.append("") + if idx > 0: + self.SetTitle(_("Update existing record")) + + print "#", self.columns - - - # determine column names and types - columnsCommand = cmd.Command (cmd=["v.info", "-c", - "map=%s" % map, "layer=%d" % layer, "--q"]) - - columns = [] - if columnsCommand.returncode == 0: - while True: - columnDef = columnsCommand.module_stdout.readline() # type|name - if not columnDef: - break - columnType, columnName = columnDef.replace("\n","").split('|') - columns.append ((columnName, columnType)) - else: - pass - # dialog body + mainSizer = wx.BoxSizer(wx.VERTICAL) + border = wx.BoxSizer(wx.VERTICAL) - box = wx.StaticBox (parent=self, id=wx.ID_ANY, label=" %s " % _("Attributes")) + box = wx.StaticBox (parent=self, id=wx.ID_ANY, label=" %s %d " % (_("Layer"), layer)) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) flexSizer = wx.FlexGridSizer (cols=4, hgap=3, vgap=3) flexSizer.AddGrowableCol(0) - for name, type in columns: + # columns + for colIdx in range(len(self.columns)): + name = self.columns[colIdx][0] + type = self.columns[colIdx][1] + value = self.columns[colIdx][2] colName = wx.StaticText(parent=self, id=wx.ID_ANY, label=name) colType = wx.StaticText(parent=self, id=wx.ID_ANY, label="[" + type.lower() + "]") delimiter = wx.StaticText(parent=self, id=wx.ID_ANY, label=":") - if name == "cat": - colValue = wx.StaticText(parent=self, id=wx.ID_ANY, label=values.pop()) + if name.lower() == "cat": + colValue = wx.StaticText(parent=self, id=wx.ID_ANY, label=str(cat)) else: - colValue = wx.TextCtrl(parent=self, id=wx.ID_ANY, value=values.pop(), size=(250, -1)) # TODO: validator + colValue = wx.TextCtrl(parent=self, id=wx.ID_ANY, value=value, size=(250, -1)) # TODO: validator + + # add widget reference to self.columns + self.columns[colIdx].append(colValue) + flexSizer.Add(colName, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(colType, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(delimiter, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(colValue, proportion=0, flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL) + sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) + border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1) + + # sql box + box = wx.StaticBox (parent=self, id=wx.ID_ANY, label=" %s " % _("SQL statement")) + sizer = wx.StaticBoxSizer(box, wx.VERTICAL) + sql = wx.StaticText(parent=self, id=wx.ID_ANY, + label="INSERT into %s (cat) VALUES (%d)" % ("table", cat)) + sizer.Add(item=sql, proportion=0, flag=wx.ALL | wx.EXPAND, border=5) + border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1) + + mainSizer.Add(item=border, proportion=1, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5) + # buttons btnCancel = wx.Button(self, wx.ID_CANCEL) - btnOk = wx.Button(self, wx.ID_OK, _("OK") ) - btnOk.SetDefault() + btnReset = wx.Button(self, wx.ID_APPLY, _("&Reset")) + btnSubmit = wx.Button(self, wx.ID_OK, _("&Submit")) + btnSubmit.SetDefault() - # bindigs - #btnApply.Bind(wx.EVT_BUTTON, self.OnApply) - #btn_ok.Bind(wx.EVT_BUTTON, self.OnOK) - - # sizers - sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) - border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1) - btnSizer = wx.StdDialogButtonSizer() btnSizer.AddButton(btnCancel) - btnSizer.AddButton(btnOk) + btnSizer.AddButton(btnReset) + btnSizer.AddButton(btnSubmit) btnSizer.Realize() - - mainSizer = wx.BoxSizer(wx.VERTICAL) - mainSizer.Add(item=border, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) + mainSizer.Add(item=btnSizer, proportion=0, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) + # bindigs + btnReset.Bind(wx.EVT_BUTTON, self.OnReset) + btnSubmit.Bind(wx.EVT_BUTTON, self.OnSubmit) + self.SetSizer(mainSizer) mainSizer.Fit(self) + + def OnReset(self, event): + """Reset form""" + for colIdx in range(len(self.columns)): + name = self.columns[colIdx][0] + value = self.columns[colIdx][2] + win = self.columns[colIdx][3] + if name.lower() != "cat": + win.SetValue(value) + + def OnSubmit(self, event): + """Submit record""" + self.Close() def main(argv=None): if argv is None: Modified: trunk/grassaddons/gui/gui_modules/digit.py =================================================================== --- trunk/grassaddons/gui/gui_modules/digit.py 2007-06-22 12:19:47 UTC (rev 863) +++ trunk/grassaddons/gui/gui_modules/digit.py 2007-06-22 15:01:50 UTC (rev 864) @@ -30,11 +30,12 @@ import dbm from debug import Debug as Debug -class Digit: +class AbstractDigit: """ Abstract digitization class """ def __init__(self, settings=None): + self.map = None if not settings: self.settings = {} # symbology @@ -61,16 +62,53 @@ self.settings["categoryMode"] = "Next to use" else: self.settings = settings + + def SetCategoryNextToUse(self): + """Find maximum category number in the map layer + and update Digit.settings['category'] + + Returns 'True' on success, 'False' on failure + """ + + categoryCmd = cmd.Command(cmd=["v.category", "-g", "--q", + "input=%s" % self.map, + "option=report", + "layer=%d" % self.settings["layer"]]) + + if categoryCmd.returncode != 0: + return -class VEdit(Digit): + for line in categoryCmd.ReadStdOutput(): + if "all" in line: + try: + maxCat = int(line.split(' ')[-1]) + 1 + self.settings['category'] = maxCat + except: + return False + return True + + def SetCategory(self): + """Return category number to use (according Settings)""" + + if self.map and self.settings["categoryMode"] == "Next to use": + self.SetCategoryNextToUse() + + return Digit.settings["category"] + + def ReInitialize(self, map): + """Re-initialize settings according selected map layer""" + self.map = map + self.SetCategory() + +class VEdit(AbstractDigit): """ Prototype of digitization class based on v.edit command Note: This should be replaced by VDigit class. """ def __init__(self, settings=None): - Digit.__init__(self, settings) - + AbstractDigit.__init__(self, settings) + def AddPoint (self, map, type, x, y, z=None): """ Add point/centroid to the vector map layer @@ -79,12 +117,15 @@ key = "C" else: key = "P" + + layer = self.settings["layer"] + cat = self.SetCategory() addstring="""%s 1 1 - %f %f\n1 1""" % (key, x, y) + %f %f\n%d %d""" % (key, x, y, layer, cat) - Debug.msg (3, "VEdit.AddPoint(): map=%s, type=%s, x=%f, y=%f" % \ - (map, type, x, y)) + Debug.msg (3, "VEdit.AddPoint(): map=%s, type=%s, layer=%d, cat=%d, x=%f, y=%f" % \ + (map, type, layer, cat, x, y)) self._AddFeature (map=map, input=addstring) @@ -121,7 +162,7 @@ # run the command vedit = cmd.Command(cmd=command, stdin=input) -class VDigit(Digit): +class VDigit(AbstractDigit): """ Prototype of digitization class based on v.digit reimplementation @@ -133,14 +174,15 @@ """ Standard settings dialog for digitization purposes """ - def __init__(self, parent, title, style): + def __init__(self, parent, title, style=wx.DEFAULT_DIALOG_STYLE): wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style) self.parent = parent # mapdisplay.BufferedWindow class instance - + # notebook notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT) self.__CreateSymbologyPage(notebook) + Digit.SetCategory() # update category number (next to use) self.__CreateSettingsPage(notebook) # buttons @@ -257,15 +299,13 @@ text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Layer")) self.layer = wx.TextCtrl(parent=panel, id=wx.ID_ANY, size=(125, -1), value=str(Digit.settings["layer"])) # TODO: validator - if not self.addRecord.IsChecked(): - self.layer.Enable(False) flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(item=self.layer, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) # category number text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Category number")) self.category = wx.TextCtrl(parent=panel, id=wx.ID_ANY, size=(125, -1), value=str(Digit.settings["category"])) # TODO: validator - if Digit.settings["categoryMode"] != "Manual entry" or not self.addRecord.IsChecked(): + if Digit.settings["categoryMode"] != "Manual entry": self.category.SetEditable(False) self.category.Enable(False) flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) @@ -275,8 +315,6 @@ self.categoryMode = wx.ComboBox(parent=panel, id=wx.ID_ANY, style=wx.CB_SIMPLE | wx.CB_READONLY, size=(125, -1), choices=[_("Next to use"), _("Manual entry"), _("No category")]) self.categoryMode.SetValue(Digit.settings["categoryMode"]) - if not self.addRecord.IsChecked(): - self.categoryMode.Enable(False) flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(item=self.categoryMode, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) @@ -323,20 +361,16 @@ self.category.SetEditable(False) self.category.Enable(False) + if mode == "No category": + self.category.SetValue("None") + else: + Digit.SetCategory() + self.category.SetValue(str(Digit.settings['category'])) + def OnChangeAddRecord(self, event): """Checkbox 'Add new record' status changed""" - if not event.IsChecked(): - status = False - else: - status = True + Digit.settings["addRecord"] = event.IsChecked() - self.layer.Enable(status) - if status == False: - self.category.Enable(status) - elif status == True and self.categoryMode.GetCurrentSelection() == 1: - self.category.Enable(status) - self.categoryMode.Enable(status) - def OnOK(self, event): """Button 'OK' clicked""" self.UpdateSettings() @@ -363,7 +397,10 @@ # digitize new feature Digit.settings["addRecord"] = self.addRecord.IsChecked() Digit.settings["layer"] = int(self.layer.GetValue()) - Digit.settings["category"] = int(self.category.GetValue()) + if Digit.settings["categoryMode"] == "No category": + Digit.settings["category"] = None + else: + Digit.settings["category"] = int(self.category.GetValue()) Digit.settings["categoryMode"] = self.categoryMode.GetValue() except: pass Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-22 12:19:47 UTC (rev 863) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-22 15:01:50 UTC (rev 864) @@ -585,6 +585,17 @@ if len(self.polycoords) > 0: self.Draw(self.pdc, drawid=self.plineid, pdctype='polyline', coords=self.polycoords) + def DrawCross(self, coords, size, rotation=0): + """Draw cross in PseudoDC + + TODO: implement rotation + """ + coordsCross = ((coords[0] - size, coords[1], coords[0] + size, coords[1]), + (coords[0], coords[1] - size, coords[0], coords[1] + size)) + for lineCoords in coordsCross: + self.lineid = wx.ID_NEW + 1 + self.Draw(self.pdc, drawid=self.lineid, pdctype='line', coords=lineCoords) + def MouseActions(self, event): """ Mouse motion and button click notifier @@ -696,16 +707,25 @@ if digit.type in ["point", "centroid"]: # add new point self.mouse['begin'] = event.GetPositionTuple()[:] - self.Draw(self.pdc, drawid=self.lineid, pdctype='point', coords=self.mouse['begin']) - east, north = self.Pixel2Cell(event.GetPositionTuple()[0], - event.GetPositionTuple()[1]) + self.DrawCross(self.mouse['begin'], 5) + east, north = self.Pixel2Cell(self.mouse['begin'][0], + self.mouse['begin'][1]) Digit.AddPoint(map=map, type=digit.type, x=east, y=north) + # add new record into atribute table - if dbm.UpdateRecordDialog(parent=self, map=map, layer=1).ShowModal() == wx.ID_OK: - pass + if Digit.settings["addRecord"]: + offset = 5 + posWindow = self.ClientToScreen((self.mouse['begin'][0] + offset, + self.mouse['begin'][1] + offset)) + if dbm.UpdateRecordDialog(parent=self, map=map, + layer=Digit.settings["layer"], + cat=Digit.settings["category"], + pos=posWindow).ShowModal() == wx.ID_OK: + pass + self.render=True self.UpdateMap() # redraw map @@ -1351,8 +1371,8 @@ # change mouse to draw digitized line self.MapWindow.mouse['box'] = "point" self.MapWindow.zoomtype = 0 - self.MapWindow.pen = wx.Pen(colour='red', width=2, style=wx.SHORT_DASH) - self.MapWindow.polypen = wx.Pen(colour='green', width=2, style=wx.SHORT_DASH) + self.MapWindow.pen = wx.Pen(colour='red', width=2, style=wx.SOLID) + self.MapWindow.polypen = wx.Pen(colour='green', width=2, style=wx.SOLID) self._mgr.Update() Modified: trunk/grassaddons/gui/gui_modules/toolbars.py =================================================================== --- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-22 12:19:47 UTC (rev 863) +++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-22 15:01:50 UTC (rev 864) @@ -359,14 +359,22 @@ """ try: self.layerSelectedID = self.layers.index(layerSelected) - self.combo.SetValue (layerSelected.name) - self.parent.maptoolbar.combo.SetValue ('Digitize') - Debug.msg (4, "DigitToolbar.StartEditing(): layerSelectedID=%d layer=%s" % \ - (self.layerSelectedID, self.layers[self.layerSelectedID].name)) - return True + mapName = self.layers[self.layerSelectedID].name except: return False + # update toolbar + self.combo.SetValue (layerSelected.name) + self.parent.maptoolbar.combo.SetValue ('Digitize') + # set initial category number for new features (layer=1), etc. + + Debug.msg (4, "DigitToolbar.StartEditing(): layerSelectedID=%d layer=%s" % \ + (self.layerSelectedID, mapName)) + + digit.Digit.ReInitialize(mapName) + + return True + def StopEditing (self, layerSelected): """ Unmark currently enabled map layer. From barton at grass.itc.it Sun Jun 24 01:12:48 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sun Jun 24 01:12:51 2007 Subject: [grass-addons] r865 - trunk/grassaddons/gui/gui_modules Message-ID: <200706232312.l5NNCmUC031339@grass.itc.it> Author: barton Date: 2007-06-24 01:12:40 +0200 (Sun, 24 Jun 2007) New Revision: 865 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Remove duplicate menu entry text so that commands execute properly. Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-22 15:01:50 UTC (rev 864) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-23 23:12:40 UTC (rev 865) @@ -26,74 +26,74 @@ return [( ("Files", ( ("Import raster map", ( - ("Multiple formats using GDAL", "Import multiple formats using GDAL", "self.OnMenuCmd", "r.in.gdal"), + ("Multiple import formats using GDAL", "Import multiple formats using GDAL", "self.OnMenuCmd", "r.in.gdal"), ("","","", ""), - ("Aggregate ASCII xyz", "Import aggregate ASCII xyz data", "self.OnMenuCmd", "r.in.xyz"), - ("ASCII grid", "Import ASCII GRID (includes GRASS ASCII)", "self.OnMenuCmd", "r.in.ascii"), - ("ASCII polygons and lines", "Import Polygons and lines from ASCII file", "self.OnMenuCmd", "r.in.poly"), + ("Aggregate ASCII xyz import", "Import aggregate ASCII xyz data", "self.OnMenuCmd", "r.in.xyz"), + ("ASCII grid import", "Import ASCII GRID (includes GRASS ASCII)", "self.OnMenuCmd", "r.in.ascii"), + ("ASCII polygons and lines import", "Import Polygons and lines from ASCII file", "self.OnMenuCmd", "r.in.poly"), ("","","", ""), - ("Binary", "Import binary file (includes GTOPO30 format)", "self.OnMenuCmd", "r.in.bin"), - ("ESRI Arc/Info ASCII grid", "Import ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.in.arc"), - ("GRIDATB.FOR", "Import GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.in.gridatb"), - ("MAT-File (v.4)", "Import MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.in.mat"), - ("SPOT NDVI", "Import SPOT vegetation NDVI data sets", "self.OnMenuCmd", "r.in.spotvgt"), - ("SRTM HGT", "Import SRTM hgt files", "self.OnMenuCmd", "r.in.srtm"), - ("Terra ASTER HDF", "Import Terra ASTER HDF files", "self.OnMenuCmd", "r.in.aster"), + ("Binary import", "Import binary file (includes GTOPO30 format)", "self.OnMenuCmd", "r.in.bin"), + ("ESRI ASCII grid import", "Import ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.in.arc"), + ("GRIDATB.FOR import", "Import GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.in.gridatb"), + ("MAT-File (v.4) import", "Import MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.in.mat"), + ("SPOT NDVI import", "Import SPOT vegetation NDVI data sets", "self.OnMenuCmd", "r.in.spotvgt"), + ("SRTM HGT import", "Import SRTM hgt files", "self.OnMenuCmd", "r.in.srtm"), + ("Terra ASTER HDF import", "Import Terra ASTER HDF files", "self.OnMenuCmd", "r.in.aster"), ("","","", ""), - ("WMS", "Import Web Mapping Server", "self.OnMenuCmd", "r.in.wms"), + ("WMS import", "Import Web Mapping Server", "self.OnMenuCmd", "r.in.wms"), )), ("Import vector map", ( - ("Multiple formats using OGR", "Import multiple formats using OGR", "self.OnMenuCmd", "v.in.ogr"), + ("Multiple import formats using OGR", "Import multiple formats using OGR", "self.OnMenuCmd", "v.in.ogr"), ("","","", ""), - ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.in.ascii"), - ("Old GRASS vector", "Import old GRASS vector format", "self.OnMenuCmd", "v.convert"), + ("ASCII points/GRASS ASCII vector import", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.in.ascii"), + ("Old GRASS vector import", "Import old GRASS vector format", "self.OnMenuCmd", "v.convert"), ("","","", ""), - ("DXF", "Import DXF file", "self.OnMenuCmd", "v.in.dxf"), - ("ESRI e00", "Import ESRI e00 file", "self.OnMenuCmd", "v.in.e00"), - ("Garmin GPS", "Import Garmin GPS Waypoints/Routes/Tracks", "self.OnMenuCmd", "v.in.garmin"), - ("GPSBabel GPS", "Import GPS Waypoints/Routes/Tracks using GPSBabel", "self.OnMenuCmd", "v.in.gpsbabel"), - ("GEOnet", "Import GEOnet Name server country files (US-NGA GNS)", "self.OnMenuCmd", "v.in.gns"), - ("Matlab and MapGen", "Import Matlab and MapGen files", "self.OnMenuCmd", "v.in.mapgen"), + ("DXF import", "Import DXF file", "self.OnMenuCmd", "v.in.dxf"), + ("ESRI e00 import", "Import ESRI e00 file", "self.OnMenuCmd", "v.in.e00"), + ("Garmin GPS import", "Import Garmin GPS Waypoints/Routes/Tracks", "self.OnMenuCmd", "v.in.garmin"), + ("GPSBabel GPS import", "Import GPS Waypoints/Routes/Tracks using GPSBabel", "self.OnMenuCmd", "v.in.gpsbabel"), + ("GEOnet import", "Import GEOnet Name server country files (US-NGA GNS)", "self.OnMenuCmd", "v.in.gns"), + ("Matlab and MapGen import", "Import Matlab and MapGen files", "self.OnMenuCmd", "v.in.mapgen"), )), ("Import grid 3D volume", ( - ("ASCII 3D", "Import ASCII 3D file", "self.OnMenuCmd", "r3.in.ascii"), - ("Vis5D", "Import Vis5D file", "self.OnMenuCmd", "r3.in.v5d"), + ("ASCII 3D import", "Import ASCII 3D file", "self.OnMenuCmd", "r3.in.ascii"), + ("Vis5D import", "Import Vis5D file", "self.OnMenuCmd", "r3.in.v5d"), )), ("","","", ""), ("Export raster map", ( - ("Multiple formats using GDAL", "Export multiple formats using GDAL", "self.OnMenuCmd", "r.out.gdal"), + ("Multiple export formats using GDAL", "Export multiple formats using GDAL", "self.OnMenuCmd", "r.out.gdal"), ("","","", ""), - ("ASCII grid", "Export ASCII grid (for GRASS, Surfer, Modflow, etc)", "self.OnMenuCmd", "r.out.ascii"), - ("ASCII x,y,z", "Export ASCII x,y,z values of cell centers", "self.OnMenuCmd", "r.out.xyz"), + ("ASCII grid export", "Export ASCII grid (for GRASS, Surfer, Modflow, etc)", "self.OnMenuCmd", "r.out.ascii"), + ("ASCII x,y,z export", "Export ASCII x,y,z values of cell centers", "self.OnMenuCmd", "r.out.xyz"), ("","","", ""), - ("ESRI ASCII grid", "Export ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.out.arc"), - ("GRIDATB.FOR", "Export GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.out.gridatb"), - ("MAT-File (v.4)", "Export MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.out.mat"), + ("ESRI ASCII grid export", "Export ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.out.arc"), + ("GRIDATB.FOR export", "Export GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.out.gridatb"), + ("MAT-File (v.4) export", "Export MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.out.mat"), ("","","", ""), - ("Binary", "Export binary file", "self.OnMenuCmd", "r.out.bin"), + ("Binary export", "Export binary file", "self.OnMenuCmd", "r.out.bin"), ("","","", ""), - ("MPEG-1", "Export MPEG-1 animations", "self.OnMenuCmd", "r.out.mpeg"), - ("PNG", "Export PNG image (not georeferenced)", "self.OnMenuCmd", "r.out.png"), - ("PPM", "Export PPM image (24bit)", "self.OnMenuCmd", "r.out.ppm"), - ("PPM from RGB", "Export PPM image from red, green, blue raster maps", "self.OnMenuCmd", "r.out.ppm3"), - ("POV-Ray", "Export POVray height-field", "self.OnMenuCmd", "r.out.pov"), - ("TIFF", "Export TIFF image (8/24bit)", "self.OnMenuCmd", "r.out.tiff"), - ("VRML", "Export VRML file", "self.OnMenuCmd", "r.out.vrml"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r.out.vtk"), + ("MPEG-1 export", "Export MPEG-1 animations", "self.OnMenuCmd", "r.out.mpeg"), + ("PNG export", "Export PNG image (not georeferenced)", "self.OnMenuCmd", "r.out.png"), + ("PPM export", "Export PPM image (24bit)", "self.OnMenuCmd", "r.out.ppm"), + ("PPM from RGB export", "Export PPM image from red, green, blue raster maps", "self.OnMenuCmd", "r.out.ppm3"), + ("POV-Ray export", "Export POVray height-field", "self.OnMenuCmd", "r.out.pov"), + ("TIFF export", "Export TIFF image (8/24bit)", "self.OnMenuCmd", "r.out.tiff"), + ("VRML export", "Export VRML file", "self.OnMenuCmd", "r.out.vrml"), + ("VTK export", "Export VTK ASCII file", "self.OnMenuCmd", "r.out.vtk"), )), ("Export vector map", ( - ("Multiple formats using OGR", "Export multiple formats using OGR", "self.OnMenuCmd", "v.out.ogr"), + ("Multiple export formats using OGR", "Export multiple formats using OGR", "self.OnMenuCmd", "v.out.ogr"), ("","","", ""), - ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.out.ascii"), - ("DXF", "Export DXF file", "self.OnMenuCmd", "v.out.dxf"), - ("POV-Ray", "Export POV-Ray format file", "self.OnMenuCmd", "v.out.pov"), - ("SVG", "Export SVG file", "self.OnMenuCmd", "v.out.svg"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "v.out.vtk"), + ("ASCII points/GRASS ASCII vector export", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.out.ascii"), + ("DXF export", "Export DXF file", "self.OnMenuCmd", "v.out.dxf"), + ("POV-Ray export", "Export POV-Ray format file", "self.OnMenuCmd", "v.out.pov"), + ("SVG export", "Export SVG file", "self.OnMenuCmd", "v.out.svg"), + ("VTK export", "Export VTK ASCII file", "self.OnMenuCmd", "v.out.vtk"), )), ("Export grid 3D volume", ( - ("ASCII 3D", "Export ASCII 3D file", "self.OnMenuCmd", "r3.out.ascii"), - ("Vis5D", "Export Vis5D file", "self.OnMenuCmd", "r3.out.v5d"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r3.out.vtk"), + ("ASCII 3D export", "Export ASCII 3D file", "self.OnMenuCmd", "r3.out.ascii"), + ("Vis5D export", "Export Vis5D file", "self.OnMenuCmd", "r3.out.v5d"), + ("VTK export", "Export VTK ASCII file", "self.OnMenuCmd", "r3.out.vtk"), )), ("","","", ""), ("Manage maps and volumes", ( From barton at grass.itc.it Sun Jun 24 01:23:26 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sun Jun 24 01:23:26 2007 Subject: [grass-addons] r866 - trunk/grassaddons/gui/gui_modules Message-ID: <200706232323.l5NNNQBL031367@grass.itc.it> Author: barton Date: 2007-06-24 01:23:17 +0200 (Sun, 24 Jun 2007) New Revision: 866 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Differentiate more duplicate menu text items Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-23 23:12:40 UTC (rev 865) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-23 23:23:17 UTC (rev 866) @@ -157,7 +157,7 @@ ("Compress/decompress", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), ("","","", ""), ("Boundaries", "Manage boundary definition", "self.OnMenuCmd", "r.region"), - ("Null values", "Manage null values", "self.OnMenuCmd", "r.null"), + ("Manage NULL values", "Manage NULL values", "self.OnMenuCmd", "r.null"), ("Quantization", "Quantization for floating-point maps", "self.OnMenuCmd", "r.quant"), ("Timestamp", "Manage timestamp for files", "self.OnMenuCmd", "r.timestamp"), ("","","", ""), @@ -169,7 +169,7 @@ ("Support file maintenance", "Support file creation and maintenance", "self.OnMenuCmd", "r.support"), ("Update map statistics", "Update map statistics", "self.OnMenuCmd", "r.support.stats"), ("","","", ""), - ("Reproject", "Reproject raster from other location", "self.OnMenuCmd", "r.proj"), + ("Reproject raster", "Reproject raster from other location", "self.OnMenuCmd", "r.proj"), ("Tiling", "Generate tiling for other projection", "self.OnMenuCmd", "r.tileset"), )), ("Manage map colors", ( @@ -182,10 +182,10 @@ )), ("Query by coordinates", "Query by coordinates", "self.OnMenuCmd", "r.what"), ("","","", ""), - ("Buffers", "Develop raster buffer", "self.OnMenuCmd", "r.buffer"), + ("Buffer rasters", "Create raster buffers around raster objects", "self.OnMenuCmd", "r.buffer"), ("Closest points", "r.distance", "self.OnMenuCmd", "r.distance"), ("MASK", "Develop raster mask", "self.OnMenuCmd", "r.mask"), - ("Map calculator", "Map calculator", "self.OnMenuCmd", "scripts/mapcalc_gparser.sh"), + ("Map calculator", "Map calculator for map algebra", "self.OnMenuCmd", "scripts/mapcalc_gparser.sh"), ("Neighborhood analysis", ( ("Moving window", "Moving window analysis of raster cells", "self.OnMenuCmd", "r.neighbors"), ("Neighborhood points", "Analyze vector points in neighborhood of raster cells", "self.OnMenuCmd", "v.neighbors"), @@ -193,7 +193,7 @@ ("Overlay maps", ( ("Cross product", "Cross product", "self.OnMenuCmd", "r.cross"), ("Map series", "Function of map series (time series)", "self.OnMenuCmd", "r.series"), - ("Patch maps", "Patch maps", "self.OnMenuCmd", "r.patch"), + ("Patch raster maps", "Patch maps", "self.OnMenuCmd", "r.patch"), ("","","", ""), ("Statistical overlay", "Statistical calculations for cover map over base map", "self.OnMenuCmd", "r.statistics"), )), @@ -316,7 +316,7 @@ )), ("","","", ""), ("Report and statistics", ( - ("Report basic information", "Report basic file information", "self.OnMenuCmd", "r.info"), + ("Basic raster information", "Report basic file information", "self.OnMenuCmd", "r.info"), ("Report category information", "Report category labels and values", "self.OnMenuCmd", "r.cats"), ("","","", ""), ("General statistics", "General statistics", "self.OnMenuCmd", "r.stats"), @@ -325,7 +325,7 @@ ("Sum area by map and category", "Sum area by map and category", "self.OnMenuCmd", "r.report"), ("Statistics for clumped cells", "Summary statistics for clumped cells (work with r.clump)", "self.OnMenuCmd", "r.volume"), ("Total corrected area", "Total surface area corrected for topography", "self.OnMenuCmd", "r.surf.area"), - ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "r.univar"), + ("Univariate raster statistics", "Calculate univariate statistics for raster categories", "self.OnMenuCmd", "r.univar"), ("","","", ""), ("Sample transects", "Sample values along transects", "self.OnMenuCmd", "r.profile"), ("Sample transects (bearing/distance)", "Sample values along transects (use azimuth, distance)", "self.OnMenuCmd", "r.transect"), @@ -365,7 +365,7 @@ ("Query coordinate(s)", "Query by coordinate(s)", "self.OnMenuCmd", "v.what"), ("Query map features", "Query by map features", "self.OnMenuCmd", "v.select"), ("","","", ""), - ("Buffers", "Create vector buffers", "self.OnMenuCmd", "v.buffer"), + ("Buffer vectors", "Create vector buffers around vector objects", "self.OnMenuCmd", "v.buffer"), ("Lidar analysis", ( ("Detect edges", "Detect object edges in Lidar data", "self.OnMenuCmd", "v.lidar.edgedetection"), ("Detect interiors", "Detect interior of objects in Lidar data", "self.OnMenuCmd", "v.lidar.growing"), @@ -389,7 +389,7 @@ )), ("Overlay maps", ( ("Overlay maps", "Overlay/combine 2 vector maps", "self.OnMenuCmd", "v.overlay"), - ("Patch maps", "Patch multiple maps (combine)", "self.OnMenuCmd", "v.patch"), + ("Patch vector maps", "Patch multiple maps (combine)", "self.OnMenuCmd", "v.patch"), )), ("","","", ""), ("Change attributes", ( @@ -419,10 +419,10 @@ ("Update point attributes from areas", "Transfer attribute data from queried area map to points", "self.OnMenuCmd", "v.what.vect"), ("","","", ""), ("Reports and statistics", ( - ("Basic information", "Basic information", "self.OnMenuCmd", "v.info"), + ("Basic vector information", "Basic information", "self.OnMenuCmd", "v.info"), ("Report topology or load to attributes", "Load vector attributes to database or create reports", "self.OnMenuCmd", "v.to.db"), ("Report topology by category", "Report areas for vector attribute categories", "self.OnMenuCmd", "v.report"), - ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "v.univar"), + ("Univariate attribute statistics", "Calculate univariate statistics for vector attributes", "self.OnMenuCmd", "v.univar"), ("","","", ""), ("Test normality", "Test normality of point distribution", "self.OnMenuCmd", "v.normal"), ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.OnMenuCmd", "v.rast.stats"), @@ -483,17 +483,17 @@ )), ("Volumes", ( ("Develop grid3D volumes", ( - ("Manage nulls", "Manage nulls for grid3D volume", "self.OnMenuCmd", "r3.null"), + ("Manage 3d NULL values", "Manage NULL values for grid3D volume", "self.OnMenuCmd", "r3.null"), ("Manage timestamp", "Manage timestamp for grid3D volume", "self.OnMenuCmd", "r3.timestamp"), )), ("","","", ""), ("3D MASK", "Create 3D mask for grid3D operations", "self.OnMenuCmd", "r3.mask"), - ("3D map calculator", "Map calculator for grid3D volume operations", "self.OnMenuCmd", "r3.mapcalculator"), + ("3D map calculator", "Map calculator for volumetric map algebra", "self.OnMenuCmd", "r3.mapcalculator"), ("Cross section", "Create 2D raster cross section from grid3d volume", "self.OnMenuCmd", "r3.cross.rast"), ("Interpoloate volume from points", "Interpolate volume from vector points using splines", "self.OnMenuCmd", "v.vol.rst"), ("","","", ""), ("Report and Statistics", ( - ("Basic information", "Report basic information about grid3D volume", "self.OnMenuCmd", "r3.info"), + ("Basic volume information", "Report basic information about grid3D volume", "self.OnMenuCmd", "r3.info"), )), ("","","", "") )), From barton at grass.itc.it Sun Jun 24 04:16:55 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sun Jun 24 04:16:57 2007 Subject: [grass-addons] r867 - trunk/grassaddons/gui/gui_modules Message-ID: <200706240216.l5O2GtQm000497@grass.itc.it> Author: barton Date: 2007-06-24 04:16:47 +0200 (Sun, 24 Jun 2007) New Revision: 867 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Updates to vector menu Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-23 23:23:17 UTC (rev 866) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-24 02:16:47 UTC (rev 867) @@ -152,7 +152,7 @@ )), ("Raster", ( ("Develop map", ( - ("Digitize raster (requires XTerm)", "Digitize raster", "self.OnXTerm", "r.digit"), + ("Digitize raster (requires XTerm)", "Digitize new raster map", "self.OnXTerm", "r.digit"), ("","","", ""), ("Compress/decompress", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), ("","","", ""), @@ -338,37 +338,41 @@ )), ("Vector", ( ("Develop map", ( - ("Digitize", "Digitize vector", "self.OnMenuCmd", "v.digit"), + ("Digitize vector", "Digitize/edit vector map", "self.OnMenuCmd", "v.digit"), ("","","", ""), - ("Create/Rebuild topology", "Create/Rebuild topology", "self.OnMenuCmd", "v.build"), - ("Clean vector", "clean vector files", "self.OnMenuCmd", "v.clean"), + ("Create/rebuild topology", "Create or rebuild topology of vector objects", "self.OnMenuCmd", "v.build"), + ("Clean vector", "Clean vector objects", "self.OnMenuCmd", "v.clean"), ("","","", ""), - ("Break lines", "Break lines at intersections", "self.OnMenuCmd", "v.topo.check"), + ("Convert object types", "Convert vector objects from one feature type to another", "self.OnMenuCmd", "v.type.sh"), + ("","","", ""), + ("Add centroids", "Add centroids to closed boundaries to create areas", "self.OnMenuCmd", "v.centroids"), + ("","","", ""), ("Build polylines", "Build polylines from adjacent segments", "self.OnMenuCmd", "v.build.polylines"), - ("Split polylines", "Split polylines into segments", "self.OnMenuCmd", "v.segment"), + ("Split polylines", "Split polylines into points and segments", "self.OnMenuCmd", "v.segment"), ("Parallel lines", "Create lines parallel to existing lines", "self.OnMenuCmd", "v.parallel"), ("","","", ""), - ("Convert feature types", "Convert vector feature types", "self.OnMenuCmd", "v.type"), - ("Convert 2D to 3D", "Convert 2D vector to 3D by sampling raster", "self.OnMenuCmd", "v.drape"), - ("Extrude 3D", "Extrude 2D vector into 3D vector", "self.OnMenuCmd", "v.extrude"), + ("Dissolve boundaries", "Dissolve common boundaries of areas", "self.OnMenuCmd", "v.dissolve"), ("","","", ""), + ("Create 3D vector over raster", "Create 3D objects by sampling raster with 2D vector", "self.OnMenuCmd", "v.drape"), + ("Extrude 3D vector", "Extrude 3D objects from 2D vector", "self.OnMenuCmd", "v.extrude"), + ("","","", ""), ("Link to OGR", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), ("","","", ""), ("Create labels", "Create text label file for vector features", "self.OnMenuCmd", "v.label"), ("","","", ""), - ("Reposition vector", "Reposition (shift and rotate) vector file in coordinate space", "self.OnMenuCmd", "v.transform"), + ("Reposition vector", "Reposition (shift, rotate, skew) vector file in coordinate space", "self.OnMenuCmd", "v.transform"), ("Reproject vector", "Reproject vector from other location", "self.OnMenuCmd", "v.proj"), ("","","", "") )), ("","","", ""), - ("Query attributes", "Query by attributes", "self.OnMenuCmd", "v.extract"), - ("Query coordinate(s)", "Query by coordinate(s)", "self.OnMenuCmd", "v.what"), - ("Query map features", "Query by map features", "self.OnMenuCmd", "v.select"), + ("Query with attributes", "Query vector objects by attribute values", "self.OnMenuCmd", "v.extract"), + ("Query with coordinate(s)", "Query vector objects by coordinate(s)", "self.OnMenuCmd", "v.what"), + ("Query with another map", "Query objects using objects from a second map", "self.OnMenuCmd", "v.select"), ("","","", ""), ("Buffer vectors", "Create vector buffers around vector objects", "self.OnMenuCmd", "v.buffer"), ("Lidar analysis", ( ("Detect edges", "Detect object edges in Lidar data", "self.OnMenuCmd", "v.lidar.edgedetection"), - ("Detect interiors", "Detect interior of objects in Lidar data", "self.OnMenuCmd", "v.lidar.growing"), + ("Detect interiors", "Detect interiors of objects in Lidar data", "self.OnMenuCmd", "v.lidar.growing"), ("Correct and reclassify objects", "Correct and reclassify objects detected in Lidar data", "self.OnMenuCmd", "v.lidar.correction"), )), ("Linear referencing", ( @@ -379,26 +383,26 @@ )), ("Nearest features", "Locate nearest feature to points or centroids", "self.OnMenuCmd", "v.distance"), ("Network analysis", ( - ("Allocate subnets", "Allocate subnets", "self.OnMenuCmd", "v.net.alloc"), + ("Allocate subnets", "Allocate subnets for nearest centers", "self.OnMenuCmd", "v.net.alloc"), ("Network maintenance", "Network maintenance", "self.OnMenuCmd", "v.net"), - ("Shortest route", "Shortest route", "self.OnMenuCmd", "v.net.path"), - ("Shortest route visualization (requires XTErm)", "Shortest route (visualization only)", "self.OnXTerm", "d.path"), + ("Shortest route", "Calculate shortest route along network between 2 nodes", "self.OnMenuCmd", "v.net.path"), + ("Display shortest route (requires XTerm)", " Display shortest route along network between 2 nodes (visualization only)", "self.OnXTerm", "d.path"), ("Split net", "Split net into bands between cost isolines", "self.OnMenuCmd", "v.net.iso"), - ("Steiner tree", "Steiner tree", "self.OnMenuCmd", "v.net.steiner"), - ("Traveling salesman analysis", "Traveling salesman analysis", "self.OnMenuCmd", "v.net.salesman"), + ("Steiner tree", "Create Steiner tree for network and given terminals", "self.OnMenuCmd", "v.net.steiner"), + ("Traveling salesman analysis", "Calculate shortest route connecting given set of nodes (Traveling salesman analysis)", "self.OnMenuCmd", "v.net.salesman"), )), ("Overlay maps", ( - ("Overlay maps", "Overlay/combine 2 vector maps", "self.OnMenuCmd", "v.overlay"), - ("Patch vector maps", "Patch multiple maps (combine)", "self.OnMenuCmd", "v.patch"), + ("Overlay vector maps", "Boolean overlay of 2 vector maps", "self.OnMenuCmd", "v.overlay"), + ("Patch vector maps", "Patch/combine multiple maps (Boolean OR)", "self.OnMenuCmd", "v.patch"), )), ("","","", ""), ("Change attributes", ( ("Manage or report categories", "Attach/delete, or report categories", "self.OnMenuCmd", "v.category"), - ("Reclassify vector using rules", "Reclassify features interactively using rules", "self.RulesCmd", "v.reclass"), - ("Reclassify vector using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), + ("Reclassify objects using rules", "Reclassify vector objects interactively using rules", "self.RulesCmd", "v.reclass"), + ("Reclassify objects using rules file", "Reclassify vector objects using rules file", "self.OnMenuCmd", "v.reclass"), )), ("","","", ""), - ("Generate area for current region", "Generate area feature for extent of current region", "self.OnMenuCmd", "v.in.region"), + ("Generate area for current region", "Generate area object for extent of current region", "self.OnMenuCmd", "v.in.region"), ("Generate areas from points", ( ("Convex hull", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), ("Delaunay triangles", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), @@ -406,27 +410,32 @@ )), ("Generate grid", "Generate rectangular vector grid", "self.OnMenuCmd", "v.mkgrid"), ("Generate points", ( - ("Generate from database", "Generate points from database", "self.OnMenuCmd", "v.in.db"), - ("Generate random", "Generate random points", "self.OnMenuCmd", "v.random"), - ("Perturb points", "Random location perturbations of points", "self.OnMenuCmd", "v.perturb"), + ("Generate from database", "Generate points from database with x/y coordinates", "self.OnMenuCmd", "v.in.db"), + ("Generate points along lines", "Generate points along vector lines/boundaries", "self.OnMenuCmd", "v.to.points"), + ("Generate random points", "Generate random points", "self.OnMenuCmd", "v.random"), + ("Perturb points", "Random perturbations of point locations", "self.OnMenuCmd", "v.perturb"), )), - ("Sample raster maps at point locations", ( - ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.OnMenuCmd", "v.rast.stats"), + ("","","", ""), + ("Remove outliers in point sets", "Remove outliers from vector point set", "self.OnMenuCmd", "v.outlier"), + ("Test/training point sets", "Partition points into test/training sets for k-fold cross validation", "self.OnMenuCmd", "v.kcv"), + ("","","", ""), + ("Update area attributes from raster", "Update area attribute data from univariate statistics on raster map", "self.OnMenuCmd", "v.rast.stats"), + ("Update point attributes from areas", "Update point attribute data from vector area map", "self.OnMenuCmd", "v.what.vect"), + ("Update point attributes from raster", ( ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.OnMenuCmd", "v.what.rast"), ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.OnMenuCmd", "v.sample"), )), - ("Test/training point sets", "Partition points into test/training sets for k-fold cross validation", "self.OnMenuCmd", "v.kcv"), - ("Update point attributes from areas", "Transfer attribute data from queried area map to points", "self.OnMenuCmd", "v.what.vect"), ("","","", ""), ("Reports and statistics", ( - ("Basic vector information", "Basic information", "self.OnMenuCmd", "v.info"), - ("Report topology or load to attributes", "Load vector attributes to database or create reports", "self.OnMenuCmd", "v.to.db"), + ("Basic vector information", "Basic vector information", "self.OnMenuCmd", "v.info"), + ("","","", ""), ("Report topology by category", "Report areas for vector attribute categories", "self.OnMenuCmd", "v.report"), + ("Upload or report topology", "Update database fields or create reports from vector topology", "self.OnMenuCmd", "v.to.db"), + ("","","", ""), ("Univariate attribute statistics", "Calculate univariate statistics for vector attributes", "self.OnMenuCmd", "v.univar"), ("","","", ""), + ("Quadrat indices", "Indices of point counts in quadrats", "self.OnMenuCmd", "v.qcount"), ("Test normality", "Test normality of point distribution", "self.OnMenuCmd", "v.normal"), - ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.OnMenuCmd", "v.rast.stats"), - ("Quadrat indices", "Indices of point counts in quadrats", "self.OnMenuCmd", "v.qcount"), )), ("","","", "") )), From maldacker at grass.itc.it Mon Jun 25 17:24:57 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Mon Jun 25 17:24:59 2007 Subject: [grass-addons] r868 - trunk/grassaddons/v.path.obstacles Message-ID: <200706251524.l5PFOvwR004589@grass.itc.it> Author: maldacker Date: 2007-06-25 17:24:36 +0200 (Mon, 25 Jun 2007) New Revision: 868 Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.c trunk/grassaddons/v.path.obstacles/rotation_tree.h trunk/grassaddons/v.path.obstacles/visibility.c trunk/grassaddons/v.path.obstacles/visibility.h Log: added the support for multiple segment lines Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.c =================================================================== --- trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-24 02:16:47 UTC (rev 867) +++ trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-25 15:24:36 UTC (rev 868) @@ -105,19 +105,33 @@ return p->rightmost_son; } -struct Line * segment( struct Point * p ) +struct Line * segment1( struct Point * p ) { - return p->line; + return p->line1; } -struct Point * other( struct Point * p ) + +struct Line * segment2( struct Point * p ) +{ + return p->line2; +} + +struct Point * other1( struct Point * p ) { - if ( p->line->p1 == p ) - return p->line->p2; + if ( p->line1->p1 == p ) + return p->line1->p2; else - return p->line->p1; + return p->line1->p1; } +struct Point * other2( struct Point * p ) +{ + if ( p->line2->p1 == p ) + return p->line2->p2; + else + return p->line2->p1; +} + double segment_sqdistance( struct Point * q, struct Line * e ) { double e2e1x = e->p1->x - e->p2->x ; @@ -151,7 +165,7 @@ double dx = e->p1->x - e->p2->x; double dy = e->p1->y - e->p2->y; - double t = t = (dx * (q->x - e->p2->x) + dy * (q->y - e->p2->y)) / (dx * dx + dy * dy); + double t = (dx * (q->x - e->p2->x) + dy * (q->y - e->p2->y)) / (dx * dx + dy * dy); if (t < 0.0) { Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.h =================================================================== --- trunk/grassaddons/v.path.obstacles/rotation_tree.h 2007-06-24 02:16:47 UTC (rev 867) +++ trunk/grassaddons/v.path.obstacles/rotation_tree.h 2007-06-25 15:24:36 UTC (rev 868) @@ -23,7 +23,9 @@ { double x; double y; - struct Line * line; + struct Line * line1; + struct Line * line2; + struct Line * vis; struct Point * left_brother; struct Point * right_brother; @@ -45,8 +47,10 @@ struct Point* father( struct Point* p); struct Point* rightmost_son( struct Point * p ); -struct Line * segment( struct Point * p ); -struct Point * other( struct Point * p ); +struct Line * segment1( struct Point * p ); +struct Line * segment2( struct Point * p ); +struct Point * other1( struct Point * p ); +struct Point * other2( struct Point * p ); int before( struct Point * p, struct Point * q, struct Line * e ); double segment_sqdistance( struct Point * p, struct Line * e ); Modified: trunk/grassaddons/v.path.obstacles/visibility.c =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-24 02:16:47 UTC (rev 867) +++ trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-25 15:24:36 UTC (rev 868) @@ -28,6 +28,7 @@ int index_line = 0; int index_point = 0; struct line_pnts* sites; + int i; struct line_cats* cats; int cat,type; @@ -48,36 +49,58 @@ Vect_cat_get (cats, 1, &cat); - (*points)[index_point].x = sites->x[0]; - (*points)[index_point].y = sites->y[0]; - (*points)[index_point].line = &((*lines)[index_line]); - (*points)[index_point].left_brother = NULL; - (*points)[index_point].right_brother = NULL; - (*points)[index_point].father = NULL; - (*points)[index_point].rightmost_son = NULL; + G_message("This line has %d points", sites->n_points); + for ( i = 0; i < sites->n_points-1; i++ ) + { - index_point++; + (*points)[index_point].x = sites->x[i]; + (*points)[index_point].y = sites->y[i]; + + if ( i == 0 ) + (*points)[index_point].line1 = NULL; + else + (*points)[index_point].line1 = &((*lines)[index_line-1]); + + (*points)[index_point].line2 = &((*lines)[index_line]); + + (*points)[index_point].left_brother = NULL; + (*points)[index_point].right_brother = NULL; + (*points)[index_point].father = NULL; + (*points)[index_point].rightmost_son = NULL; - (*points)[index_point].x = sites->x[1]; - (*points)[index_point].y = sites->y[1]; - (*points)[index_point].line = &((*lines)[index_line]); - (*points)[index_point].left_brother = NULL; - (*points)[index_point].right_brother = NULL; - (*points)[index_point].father = NULL; - (*points)[index_point].rightmost_son = NULL; + index_point++; - (*lines)[index_line].p1 = &((*points)[index_point-1]); - (*lines)[index_line].p2 = &((*points)[index_point]); + (*points)[index_point].x = sites->x[i+1]; + (*points)[index_point].y = sites->y[i+1]; + + (*points)[index_point].line1 = &((*lines)[index_line]); + + if ( i == sites->n_points-1 ) + (*points)[index_point].line2 = NULL; + else + (*points)[index_point].line2 = &((*lines)[index_line+1]); + + (*points)[index_point].left_brother = NULL; + (*points)[index_point].right_brother = NULL; + (*points)[index_point].father = NULL; + (*points)[index_point].rightmost_son = NULL; + + + (*lines)[index_line].p1 = &((*points)[index_point-1]); + (*lines)[index_line].p2 = &((*points)[index_point]); - index_line++; - index_point++; + index_line++; + index_point++; - G_message("Line %d with points : %f %f %f %f", &((*lines)[index_line-1]), (*points)[index_point-1].x, (*points)[index_point-1].y, (*points)[index_point-2].x, (*points)[index_point-2].y ); + G_message("Segment %d with points : %f %f %f %f", &((*lines)[index_line-1]), (*points)[index_point-2].x, (*points)[index_point-2].y, (*points)[index_point-1].x, (*points)[index_point-1].y ); + } } + G_message("End of load lines, total segments : %d", index_line); + return index_line; } @@ -89,7 +112,7 @@ double a, b, c, d; double r; - if ( p3 == p_infinity ) + if ( p3->y == PORT_DOUBLE_MAX) { return ( p1->x < p2->x || (p1->x == p2->x && p1->y < p2->y ) ); } @@ -139,7 +162,7 @@ { - if ( &lines[j] == segment( &points[i]) ) + if ( &lines[j] == segment1( &points[i]) || &lines[j] == segment2( &points[i])) continue; /* if it's directly below, compute its distance to the last smallest found */ @@ -173,19 +196,35 @@ */ void handle( struct Point* p, struct Point* q, struct Map_info * out ) { + G_message("Handling %d and %d", p, q ); - if ( q == other(p) ) + if ( q == other1(p) || q == other2(p) ) { report( p, q, out ); } - else if ( segment(q) == p->vis ) + else if ( segment1(q) == p->vis && segment1(q) != NULL) { - p->vis = q->vis ; + if ( segment2(q) != NULL && left_turn(p, q, other2(q))) + p->vis = segment2(q); + else + p->vis = q->vis ; + report( p,q, out ); } + else if ( segment2(q) == p->vis && segment1(q) != NULL ) + { + if ( segment1(q) != NULL && left_turn(p, q, other1(q) )) + p->vis = segment1(q); + else + p->vis = q->vis; + } else if ( before(p,q, p->vis ) ) { - p->vis = segment(q); + if ( segment1(q) != NULL && left_turn(p, q, segment1(q)) ) + p->vis = segment1(q); + else + p->vis = segment2(q); + report(p,q,out); } } @@ -236,13 +275,20 @@ */ int construct_visibility ( struct Point * points, struct Line * lines, int num_lines, struct Map_info * out ) { + + G_message("Entering contruct_visibility"); + int num_points = 2*num_lines; struct Point * p, * p_r, * q, * z; + struct Point * p_infinity,* p_ninfinity; int i; - p_ninfinity = G_malloc( sizeof(struct Point )); - p_infinity = G_malloc( sizeof(struct Point )); + G_message("Why is the malloc fucking up?"); + p_ninfinity = (struct Point * ) G_malloc( sizeof(struct Point )); + p_infinity = (struct Point * ) G_malloc( sizeof(struct Point )); + + G_message("Or maybe this part?"); p_ninfinity->x = PORT_DOUBLE_MAX; p_ninfinity->y = -PORT_DOUBLE_MAX; p_ninfinity->father = NULL; @@ -257,13 +303,20 @@ p_infinity->right_brother = NULL; p_infinity->rightmost_son = NULL; + + G_message("Initialisation of the stack ... "); init_stack(num_points); + G_message("Sorting the points by decreasing order..."); /* sort points in decreasing x order*/ quickSort( points, 0, num_points-1 ); + + G_message("initialisation of the vis..."); init_vis( points, lines, num_points ); + + G_message("Initialisation of the rotation tree..."); add_rightmost( p_ninfinity, p_infinity ); for ( i = 0; i < num_points ; i ++ ) @@ -275,6 +328,7 @@ int count = 0; + G_message("Start of the main loop ... "); /* main loop */ while( !empty_stack() ) @@ -388,21 +442,33 @@ if( i >= j ) break; - if ( a[i].line->p1 == &a[i] ) a[i].line->p1 = &a[j]; - else a[i].line->p2 = &a[j]; + if ( a[i].line1 != NULL && a[i].line1->p1 == &a[i] ) a[i].line1->p1 = &a[j]; + else a[i].line1->p2 = &a[j]; - if ( a[j].line->p1 == &a[j] ) a[j].line->p1 = &a[i]; - else a[j].line->p2 = &a[i]; + if ( a[j].line1 != NULL && a[j].line1->p1 == &a[j] ) a[j].line1->p1 = &a[i]; + else a[j].line1->p2 = &a[i]; + + if ( a[i].line2 != NULL && a[i].line2->p1 == &a[i] ) a[i].line2->p1 = &a[j]; + else a[i].line2->p2 = &a[j]; + if ( a[j].line2 != NULL && a[j].line2->p1 == &a[j] ) a[j].line2->p1 = &a[i]; + else a[j].line2->p2 = &a[i]; + t = a[i]; a[i] = a[j]; a[j] = t; } - if ( a[l].line->p1 == &a[l] ) a[l].line->p1 = &a[j]; - else a[l].line->p2 = &a[j]; + if ( a[l].line1 != NULL && a[l].line1->p1 == &a[l] ) a[l].line1->p1 = &a[j]; + else a[l].line1->p2 = &a[j]; - if ( a[j].line->p1 == &a[j] ) a[j].line->p1 = &a[l]; - else a[j].line->p2 = &a[l]; + if ( a[j].line1 != NULL && a[j].line1->p1 == &a[j] ) a[j].line1->p1 = &a[l]; + else a[j].line1->p2 = &a[l]; + + if ( a[l].line2 != NULL && a[l].line2->p1 == &a[l] ) a[l].line2->p1 = &a[j]; + else a[l].line2->p2 = &a[j]; + + if ( a[j].line2 != NULL && a[j].line2->p1 == &a[j] ) a[j].line2->p1 = &a[l]; + else a[j].line2->p2 = &a[l]; t = a[l]; a[l] = a[j]; a[j] = t; Modified: trunk/grassaddons/v.path.obstacles/visibility.h =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.h 2007-06-24 02:16:47 UTC (rev 867) +++ trunk/grassaddons/v.path.obstacles/visibility.h 2007-06-25 15:24:36 UTC (rev 868) @@ -45,7 +45,5 @@ static int stack_index; static struct Point ** stack; -static struct Point * p_ninfinity; -static struct Point * p_infinity; #endif From chemin at grass.itc.it Mon Jun 25 17:34:46 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Mon Jun 25 17:34:48 2007 Subject: [grass-addons] r869 - trunk/grassaddons/gipe Message-ID: <200706251534.l5PFYkSX005109@grass.itc.it> Author: chemin Date: 2007-06-25 17:34:10 +0200 (Mon, 25 Jun 2007) New Revision: 869 Removed: trunk/grassaddons/gipe/i.atcorr/ Modified: trunk/grassaddons/gipe/imagery_Makefile Log: Remove i.atcorr, now in main grass cvs Modified: trunk/grassaddons/gipe/imagery_Makefile =================================================================== --- trunk/grassaddons/gipe/imagery_Makefile 2007-06-25 15:24:36 UTC (rev 868) +++ trunk/grassaddons/gipe/imagery_Makefile 2007-06-25 15:34:10 UTC (rev 869) @@ -5,7 +5,6 @@ SUBDIRS1 = \ i.albedo \ i.ask \ - i.atcorr \ i.biomass \ i.class \ i.cluster \ From maldacker at grass.itc.it Mon Jun 25 18:11:37 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Mon Jun 25 18:11:38 2007 Subject: [grass-addons] r870 - trunk/grassaddons/v.path.obstacles Message-ID: <200706251611.l5PGBbKK005797@grass.itc.it> Author: maldacker Date: 2007-06-25 18:11:32 +0200 (Mon, 25 Jun 2007) New Revision: 870 Modified: trunk/grassaddons/v.path.obstacles/main.c trunk/grassaddons/v.path.obstacles/rotation_tree.h trunk/grassaddons/v.path.obstacles/visibility.c Log: memory allocation problem fixed Modified: trunk/grassaddons/v.path.obstacles/main.c =================================================================== --- trunk/grassaddons/v.path.obstacles/main.c 2007-06-25 15:34:10 UTC (rev 869) +++ trunk/grassaddons/v.path.obstacles/main.c 2007-06-25 16:11:32 UTC (rev 870) @@ -75,6 +75,9 @@ construct_visibility( points, lines, index, &out ); + G_free(points); + G_free(lines); + Vect_build(&out, stdout); Vect_close(&out); Vect_close(&in); Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.h =================================================================== --- trunk/grassaddons/v.path.obstacles/rotation_tree.h 2007-06-25 15:34:10 UTC (rev 869) +++ trunk/grassaddons/v.path.obstacles/rotation_tree.h 2007-06-25 16:11:32 UTC (rev 870) @@ -23,10 +23,12 @@ { double x; double y; + struct Line * line1; struct Line * line2; struct Line * vis; + struct Point * left_brother; struct Point * right_brother; struct Point * father; Modified: trunk/grassaddons/v.path.obstacles/visibility.c =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-25 15:34:10 UTC (rev 869) +++ trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-25 16:11:32 UTC (rev 870) @@ -21,6 +21,8 @@ #include "visibility.h" +#define ALLOC_CHUNK 256 + /** Get the lines from the map and load them in an array */ int load_lines( struct Map_info * map, struct Point ** points, struct Line ** lines ) @@ -32,15 +34,18 @@ struct line_cats* cats; int cat,type; - int nb_lines; + //int nb_lines; sites = Vect_new_line_struct(); cats = Vect_new_cats_struct(); - nb_lines = Vect_get_num_lines(map); - *points = (struct Point * ) G_malloc( nb_lines*2*sizeof(struct Point) ); - *lines = ( struct Line * ) G_malloc( nb_lines*sizeof(struct Line) ); + //nb_lines = Vect_get_num_lines(map); + //*points = (struct Point * ) G_malloc( nb_lines*2*sizeof(struct Point) ); + //*lines = ( struct Line * ) G_malloc( nb_lines*sizeof(struct Line) ); + *points = NULL; + *lines = NULL; + while( ( type = Vect_read_next_line( map, sites, cats) ) > -1 ) { @@ -53,6 +58,10 @@ for ( i = 0; i < sites->n_points-1; i++ ) { + if ((index_line % ALLOC_CHUNK) == 0) + *lines = (struct Line *) G_realloc(*lines, (index_line + ALLOC_CHUNK) * sizeof(struct Line)); + if ((index_point % ALLOC_CHUNK) == 0 ) + *points = (struct Point * ) G_realloc(*points, (index_point + ALLOC_CHUNK) * sizeof(struct Point)); (*points)[index_point].x = sites->x[i]; (*points)[index_point].y = sites->y[i]; @@ -275,20 +284,15 @@ */ int construct_visibility ( struct Point * points, struct Line * lines, int num_lines, struct Map_info * out ) { - - G_message("Entering contruct_visibility"); int num_points = 2*num_lines; struct Point * p, * p_r, * q, * z; struct Point * p_infinity,* p_ninfinity; int i; + + p_ninfinity = (struct Point * ) malloc( sizeof(struct Point )); + p_infinity = (struct Point * ) malloc( sizeof(struct Point )); - G_message("Why is the malloc fucking up?"); - - p_ninfinity = (struct Point * ) G_malloc( sizeof(struct Point )); - p_infinity = (struct Point * ) G_malloc( sizeof(struct Point )); - - G_message("Or maybe this part?"); p_ninfinity->x = PORT_DOUBLE_MAX; p_ninfinity->y = -PORT_DOUBLE_MAX; p_ninfinity->father = NULL; @@ -378,6 +382,9 @@ push(p_r); } } + + G_free(p_infinity); + G_free(p_ninfinity); } @@ -442,33 +449,57 @@ if( i >= j ) break; - if ( a[i].line1 != NULL && a[i].line1->p1 == &a[i] ) a[i].line1->p1 = &a[j]; - else a[i].line1->p2 = &a[j]; + if ( a[i].line1 != NULL) + { + if ( a[i].line1->p1 == &a[i] ) a[i].line1->p1 = &a[j]; + else a[i].line1->p2 = &a[j]; + } - if ( a[j].line1 != NULL && a[j].line1->p1 == &a[j] ) a[j].line1->p1 = &a[i]; - else a[j].line1->p2 = &a[i]; + if ( a[j].line1 != NULL ) + { + if(a[j].line1->p1 == &a[j] ) a[j].line1->p1 = &a[i]; + else a[j].line1->p2 = &a[i]; + } - if ( a[i].line2 != NULL && a[i].line2->p1 == &a[i] ) a[i].line2->p1 = &a[j]; - else a[i].line2->p2 = &a[j]; + if ( a[i].line2 != NULL ) + { + if( a[i].line2->p1 == &a[i] ) a[i].line2->p1 = &a[j]; + else a[i].line2->p2 = &a[j]; + } - if ( a[j].line2 != NULL && a[j].line2->p1 == &a[j] ) a[j].line2->p1 = &a[i]; - else a[j].line2->p2 = &a[i]; + if ( a[j].line2 != NULL ) + { + if(a[j].line2->p1 == &a[j] ) a[j].line2->p1 = &a[i]; + else a[j].line2->p2 = &a[i]; + } t = a[i]; a[i] = a[j]; a[j] = t; } - if ( a[l].line1 != NULL && a[l].line1->p1 == &a[l] ) a[l].line1->p1 = &a[j]; - else a[l].line1->p2 = &a[j]; + if ( a[l].line1 != NULL ) + { + if(a[l].line1->p1 == &a[l] ) a[l].line1->p1 = &a[j]; + else a[l].line1->p2 = &a[j]; + } - if ( a[j].line1 != NULL && a[j].line1->p1 == &a[j] ) a[j].line1->p1 = &a[l]; - else a[j].line1->p2 = &a[l]; + if ( a[j].line1 != NULL ) + { + if(a[j].line1->p1 == &a[j] ) a[j].line1->p1 = &a[l]; + else a[j].line1->p2 = &a[l]; + } - if ( a[l].line2 != NULL && a[l].line2->p1 == &a[l] ) a[l].line2->p1 = &a[j]; - else a[l].line2->p2 = &a[j]; + if ( a[l].line2 != NULL ) + { + if( a[l].line2->p1 == &a[l] ) a[l].line2->p1 = &a[j]; + else a[l].line2->p2 = &a[j]; + } - if ( a[j].line2 != NULL && a[j].line2->p1 == &a[j] ) a[j].line2->p1 = &a[l]; - else a[j].line2->p2 = &a[l]; + if ( a[j].line2 != NULL ) + { + if( a[j].line2->p1 == &a[j] ) a[j].line2->p1 = &a[l]; + else a[j].line2->p2 = &a[l]; + } t = a[l]; a[l] = a[j]; a[j] = t; From barton at grass.itc.it Tue Jun 26 06:55:51 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Jun 26 06:55:52 2007 Subject: [grass-addons] r871 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200706260455.l5Q4tpfo015303@grass.itc.it> Author: barton Date: 2007-06-26 06:55:25 +0200 (Tue, 26 Jun 2007) New Revision: 871 Modified: trunk/grassaddons/gui/gui_modules/menudata.py trunk/grassaddons/gui/wxgui.py Log: Update menu and rules entry to make use of new rules= option for r.reclass and r.recode. Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-25 16:11:32 UTC (rev 870) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-06-26 04:55:25 UTC (rev 871) @@ -174,7 +174,7 @@ )), ("Manage map colors", ( ("Color tables", "Set colors to predefined color tables", "self.OnMenuCmd", "r.colors"), - ("Color rules", "Set colors interactively with color rules", "self.RulesCmd", "r.colors"), + ("Color rules", "Set colors interactively by entering color rules", "self.RulesCmd", "r.colors"), ("","","", ""), ("Blend 2 color maps", "Blend 2 color maps to produce 3 RGB files", "self.OnMenuCmd", "r.blend"), ("Create RGB", "Create color image from RGB files", "self.OnMenuCmd", "r.composite"), @@ -275,11 +275,11 @@ ("Interactively edit category values", "Edit category values of individual cells for displayed raster map", "self.OnMenuCmd", "d.rast.edit"), ("","","", ""), ("Reclassify by size", "Reclassify categories for areas of specified sizes", "self.OnMenuCmd", "r.reclass.area"), - ("Reclassify using rules", "Reclassify categories interactively with rules", "self.RulesCmd", "r.reclass"), - ("Reclassify using rules file", "Reclassify categories using rules file", "self.OnMenuCmd", "r.reclass.file"), + ("Reclassify interactively", "Reclassify categories interactively by entering reclass rules", "self.RulesCmd", "r.reclass"), + ("Reclassify using rules file", "Reclassify categories by inputting reclass rules from a text file", "self.OnMenuCmd", "r.reclass"), ("","","", ""), - ("Recode using rules", "Recode categories interactively with rules (create new map)", "self.RulesCmd", "r.recode"), - ("Recode using rules file", "Recode categories using rules file (create new map)", "self.OnMenuCmd", "r.recode.file"), + ("Recode interactively", "Recode categories interactively by entering recode rules (create new map)", "self.RulesCmd", "r.recode"), + ("Recode using rules file", "Recode categories by inputting recode rules from a text file (create new map)", "self.OnMenuCmd", "r.recode.file"), ("","","", ""), ("Rescale", "Rescale categories (create new map)", "self.OnMenuCmd", "r.rescale"), ("Rescale with histogram", "Rescale categories with equalized histogram (create new map)", "self.OnMenuCmd", "r.rescale.eq"), @@ -398,8 +398,8 @@ ("","","", ""), ("Change attributes", ( ("Manage or report categories", "Attach/delete, or report categories", "self.OnMenuCmd", "v.category"), - ("Reclassify objects using rules", "Reclassify vector objects interactively using rules", "self.RulesCmd", "v.reclass"), - ("Reclassify objects using rules file", "Reclassify vector objects using rules file", "self.OnMenuCmd", "v.reclass"), + ("Reclassify objects interactively", "Reclassify vector objects interactively by entering SQL rules", "self.RulesCmd", "v.reclass"), + ("Reclassify objects using rules file", "Reclassify vector objects by inputting SQL rules from a text file", "self.OnMenuCmd", "v.reclass"), )), ("","","", ""), ("Generate area for current region", "Generate area object for extent of current region", "self.OnMenuCmd", "v.in.region"), Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-06-25 16:11:32 UTC (rev 870) +++ trunk/grassaddons/gui/wxgui.py 2007-06-26 04:55:25 UTC (rev 871) @@ -386,23 +386,19 @@ output = open(gtemp,"w") output.write(dlg.rules) output.close() - if dlg.overwrite == True: - overwrite = '--o' - else: - overwrite -= '' if command == 'r.colors': cmdlist = [command,'map=%s' % dlg.inmap,'rules=%s' % gtemp,'--verbose'] - cmd.Command(cmdlist) - elif command == 'v.reclass': - cmdlist = [command,'input=%s' % dlg.inmap,'output=%s' % dlg.outmap,'rules=%s' % gtemp,overwrite,'--verbose'] - cmd.Command(cmdlist) else: - cmdlist = [command,'input=%s' % dlg.inmap,'output=%s' % dlg.outmap,overwrite,'--verbose'] - input = open(gtemp,"r") - p = subprocess.Popen(cmdlist, stdin=input, stdout=subprocess.PIPE) - input.close() + cmdlist = [command,'input=%s' % dlg.inmap,'output=%s' % dlg.outmap,'rules=%s' % gtemp] + if dlg.overwrite == True: + cmdlist.append('--o') + + cmdlist.append('--verbose') + + cmd.Command(cmdlist) + dlg.Destroy() def OnXTerm(self, event): From barton at grass.itc.it Wed Jun 27 07:21:22 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Jun 27 07:21:27 2007 Subject: [grass-addons] r872 - trunk/grassaddons Message-ID: <200706270521.l5R5LMM6002901@grass.itc.it> Author: barton Date: 2007-06-27 07:19:48 +0200 (Wed, 27 Jun 2007) New Revision: 872 Added: trunk/grassaddons/landscape_evol/ Log: Making a new project for landscape evolution scripts from the Mediterranean Landscape Dynamics Project, ASU. From landa at grass.itc.it Wed Jun 27 11:37:03 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Wed Jun 27 11:37:05 2007 Subject: [grass-addons] r873 - trunk/grassaddons/gui/gui_modules Message-ID: <200706270937.l5R9b3wA006642@grass.itc.it> Author: landa Date: 2007-06-27 11:37:02 +0200 (Wed, 27 Jun 2007) New Revision: 873 Modified: trunk/grassaddons/gui/gui_modules/dbm.py trunk/grassaddons/gui/gui_modules/render.py Log: Fix bug in dbm.RedrawMap Modified: trunk/grassaddons/gui/gui_modules/dbm.py =================================================================== --- trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-27 05:19:48 UTC (rev 872) +++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-27 09:37:02 UTC (rev 873) @@ -229,7 +229,8 @@ def RedrawMap(self): if self.lastTurnSelectedCats[:] != self.selectedCats[:]: - if self.qlayer: self.map.delLayer(item='qlayer') + if self.qlayer: + self.map.DeleteLayer(self.qlayer) cats = self.selectedCats catstr = "" @@ -265,12 +266,19 @@ # FIXME: width=1, because of maybe bug in PNG driver elusion # should be width=3 or something like this - cmd = "d.vect map=%s color=yellow fcolor=yellow cats=%s width=3" % (self.vectmap, catstr) + cmd = ["d.vect", + "map=%s" % self.vectmap, + "color=yellow", + "fcolor=yellow", + "cats=%s" % catstr, + "width=3"] #print cmd - if self.icon: cmd = cmd +" icon=%s" % (self.icon) - if self.pointsize: cmd = cmd + " size=%s" % (self.pointsize) + if self.icon: + cmd.append("icon=%s" % (self.icon)) + if self.pointsize: + cmd.append("size=%s" % (self.pointsize)) - self.qlayer = self.map.AddLayer(item='qlayer', type="vector", name='', command=cmd, + self.qlayer = self.map.AddLayer(type="vector", name='qlayer', command=cmd, l_active=True, l_hidden=True, l_opacity=1, l_render=False) self.mapdisp.ReDraw(None) self.lastTurnSelectedCats = self.selectedCats[:] Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-06-27 05:19:48 UTC (rev 872) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-06-27 09:37:02 UTC (rev 873) @@ -584,8 +584,8 @@ try: # render map layers for layer in self.layers + self.overlays: - # skip if hidden or not active - if layer == None or layer.active == False or layer.hidden == True: + # skip if not active + if layer == None or layer.active == False: continue # render if there is no mapfile @@ -682,12 +682,9 @@ def DeleteLayer(self, layer): """ - Removes layer from list of layers, defined by layer - tree item ID + Removes layer from list of layers, + defined by reference to MapLayer instance - Parameters: - item - wxPython ID for layer tree item - Returns: Removed layer on success or None """ From maldacker at grass.itc.it Wed Jun 27 18:32:34 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Wed Jun 27 18:32:36 2007 Subject: [grass-addons] r874 - trunk/grassaddons/v.path.obstacles Message-ID: <200706271632.l5RGWY2Y013001@grass.itc.it> Author: maldacker Date: 2007-06-27 18:32:25 +0200 (Wed, 27 Jun 2007) New Revision: 874 Modified: trunk/grassaddons/v.path.obstacles/main.c trunk/grassaddons/v.path.obstacles/rotation_tree.c trunk/grassaddons/v.path.obstacles/visibility.c trunk/grassaddons/v.path.obstacles/visibility.h Log: bug fixes Modified: trunk/grassaddons/v.path.obstacles/main.c =================================================================== --- trunk/grassaddons/v.path.obstacles/main.c 2007-06-27 09:37:02 UTC (rev 873) +++ trunk/grassaddons/v.path.obstacles/main.c 2007-06-27 16:32:25 UTC (rev 874) @@ -28,7 +28,7 @@ struct Point * points; struct Line * lines; - int index; + int num_points, num_lines; @@ -71,9 +71,9 @@ if (G_projection () == PROJECTION_LL) G_warning("We are in LL projection"); - index = load_lines( &in, &points, &lines); + load_lines( &in, &points, &num_points, &lines, &num_lines); - construct_visibility( points, lines, index, &out ); + construct_visibility( points, num_points, lines, num_lines, &out ); G_free(points); G_free(lines); Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.c =================================================================== --- trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-27 09:37:02 UTC (rev 873) +++ trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-06-27 16:32:25 UTC (rev 874) @@ -118,6 +118,9 @@ struct Point * other1( struct Point * p ) { + if ( p->line1 == NULL) + return NULL; + if ( p->line1->p1 == p ) return p->line1->p2; else @@ -126,6 +129,9 @@ struct Point * other2( struct Point * p ) { + if( p->line2 == NULL ) + return NULL; + if ( p->line2->p1 == p ) return p->line2->p2; else @@ -159,31 +165,6 @@ } -double segment_sqdistance2( struct Point * q, struct Line * e ) -{ - - double dx = e->p1->x - e->p2->x; - double dy = e->p1->y - e->p2->y; - - double t = (dx * (q->x - e->p2->x) + dy * (q->y - e->p2->y)) / (dx * dx + dy * dy); - - if (t < 0.0) - { - t = 0.0; - } - else if (t > 1.0) - { - t = 1.0; - } - - dx = dx * t + e->p2->x - q->x; - dy = dy * t + e->p2->y - q->y; - - return (dx * dx + dy * dy); - -} - - int before( struct Point * p, struct Point * q, struct Line * e ) { /* true if q lies nearer to p than segment e*/ @@ -193,7 +174,7 @@ if ( e == NULL ) return 1; - double e_distance = segment_sqdistance2(p, e); + double e_distance = segment_sqdistance(p, e); double pqx = q->x - p->x; double pqy = q->y - p->y; double pq_distance = pqx*pqx + pqy*pqy; Modified: trunk/grassaddons/v.path.obstacles/visibility.c =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-27 09:37:02 UTC (rev 873) +++ trunk/grassaddons/v.path.obstacles/visibility.c 2007-06-27 16:32:25 UTC (rev 874) @@ -25,7 +25,7 @@ /** Get the lines from the map and load them in an array */ -int load_lines( struct Map_info * map, struct Point ** points, struct Line ** lines ) +void load_lines( struct Map_info * map, struct Point ** points, int * num_points, struct Line ** lines, int * num_lines ) { int index_line = 0; int index_point = 0; @@ -86,7 +86,7 @@ (*points)[index_point].line1 = &((*lines)[index_line]); - if ( i == sites->n_points-1 ) + if ( i == sites->n_points-2 ) (*points)[index_point].line2 = NULL; else (*points)[index_point].line2 = &((*lines)[index_line+1]); @@ -101,16 +101,20 @@ (*lines)[index_line].p2 = &((*points)[index_point]); index_line++; - index_point++; + //index_point++; - G_message("Segment %d with points : %f %f %f %f", &((*lines)[index_line-1]), (*points)[index_point-2].x, (*points)[index_point-2].y, (*points)[index_point-1].x, (*points)[index_point-1].y ); + G_message("Segment %d with two points %d and %d with coor : %f %f %f %f", &((*lines)[index_line-1]), &((*points)[index_point-1]), &((*points)[index_point]), (*points)[index_point-1].x, (*points)[index_point-1].y, (*points)[index_point].x, (*points)[index_point].y ); } + index_point++; + } G_message("End of load lines, total segments : %d", index_line); + G_message("total nodes : %d", index_point); - return index_line; + *num_points = index_point; + *num_lines = index_line; } @@ -156,7 +160,7 @@ /** for all points initiate their vis line to the one directly below */ -void init_vis( struct Point * points, struct Line * lines, int num ) +void init_vis( struct Point * points, int num_points, struct Line * lines, int num_lines ) { int i; @@ -165,9 +169,9 @@ double current_distance = PORT_DOUBLE_MAX; double s; - for ( i = 0 ; i < num ; i++ ) + for ( i = 0 ; i < num_points ; i++ ) { - for ( j = 0 ; j < num/2 ; j++ ) + for ( j = 0 ; j < num_lines ; j++ ) { @@ -176,9 +180,11 @@ /* if it's directly below, compute its distance to the last smallest found */ if ( below( &points[i], &lines[j] ) && in_between( &points[i], &lines[j] ) ) - { + { + G_message("Handling point %d with line %d", &points[i], &lines[j] ); s = segment_sqdistance( &points[i], &lines[j]); + if( s < current_distance) { current = j; @@ -205,14 +211,21 @@ */ void handle( struct Point* p, struct Point* q, struct Map_info * out ) { - G_message("Handling %d and %d", p, q ); + //G_message("- Handling %d and %d", p, q ); + //G_message("--- Segment of q are %d and %d", segment1(q), segment2(q)); + //G_message("--- Others of q are %d and %d", other1(q), other2(q)); + //G_message("--- VIS is %d", p->vis); if ( q == other1(p) || q == other2(p) ) { + /* TODO problem for the vis */ + //G_message("It's the other"); report( p, q, out ); } else if ( segment1(q) == p->vis && segment1(q) != NULL) { + //G_message("--- It's segment1"); + if ( segment2(q) != NULL && left_turn(p, q, other2(q))) p->vis = segment2(q); else @@ -220,16 +233,20 @@ report( p,q, out ); } - else if ( segment2(q) == p->vis && segment1(q) != NULL ) + else if ( segment2(q) == p->vis && segment2(q) != NULL ) { + //G_message("--- It's segment2"); if ( segment1(q) != NULL && left_turn(p, q, other1(q) )) p->vis = segment1(q); else p->vis = q->vis; + + report( p,q, out ); } else if ( before(p,q, p->vis ) ) { - if ( segment1(q) != NULL && left_turn(p, q, segment1(q)) ) + //G_message("--- There is a point in between "); + if ( segment1(q) != NULL && left_turn(p, q, other1(q)) ) p->vis = segment1(q); else p->vis = segment2(q); @@ -282,10 +299,8 @@ /** the algorithm that computes the visibility graph */ -int construct_visibility ( struct Point * points, struct Line * lines, int num_lines, struct Map_info * out ) +int construct_visibility ( struct Point * points, int num_points, struct Line * lines, int num_lines, struct Map_info * out ) { - - int num_points = 2*num_lines; struct Point * p, * p_r, * q, * z; struct Point * p_infinity,* p_ninfinity; int i; @@ -316,8 +331,11 @@ quickSort( points, 0, num_points-1 ); + for ( i = 0 ; i < num_points ; i++ ) + G_message("Point %d ( %f, %f ) has segment %d and %d and the others are %d and %d", &points[i], points[i].x, points[i].y, segment1(&points[i]), segment2(&points[i]), other1(&points[i]), other2(&points[i])); + G_message("initialisation of the vis..."); - init_vis( points, lines, num_points ); + init_vis( points, num_points, lines, num_lines ); G_message("Initialisation of the rotation tree..."); Modified: trunk/grassaddons/v.path.obstacles/visibility.h =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.h 2007-06-27 09:37:02 UTC (rev 873) +++ trunk/grassaddons/v.path.obstacles/visibility.h 2007-06-27 16:32:25 UTC (rev 874) @@ -23,8 +23,8 @@ #include #include "rotation_tree.h" -int load_lines( struct Map_info *map, struct Point ** points, struct Line ** lines ); -int construct_visibility( struct Point * points, struct Line * lines, int num_lines, struct Map_info* out ); +void load_lines( struct Map_info *map, struct Point ** points, int * num_points, struct Line ** lines, int * num_lines ); +int construct_visibility( struct Point * points, int num_points, struct Line * lines, int num_lines, struct Map_info* out ); int cmp_points(struct Point * v1, struct Point* v2); int turn_left( struct Point p1, struct Point p2, struct Point p3 ); @@ -32,7 +32,7 @@ void handle( struct Point* p, struct Point* q, struct Map_info * out ); void report( struct Point * p, struct Point * q, struct Map_info * out ); -void init_vis( struct Point * points, struct Line * lines, int num ); +void init_vis( struct Point * points, int num_points, struct Line * lines, int num_lines ); struct Point * pop(); struct Point * top(); From barton at grass.itc.it Thu Jun 28 00:44:09 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Jun 28 00:44:11 2007 Subject: [grass-addons] r875 - trunk/grassaddons/landscape_evol Message-ID: <200706272244.l5RMi9Qq017420@grass.itc.it> Author: barton Date: 2007-06-28 00:44:04 +0200 (Thu, 28 Jun 2007) New Revision: 875 Added: trunk/grassaddons/landscape_evol/r.landscape.evol Log: Main script to implement USPED model in GRASS Added: trunk/grassaddons/landscape_evol/r.landscape.evol =================================================================== --- trunk/grassaddons/landscape_evol/r.landscape.evol (rev 0) +++ trunk/grassaddons/landscape_evol/r.landscape.evol 2007-06-27 22:44:04 UTC (rev 875) @@ -0,0 +1,1279 @@ +#!/bin/sh +# +############################################################################ +# +# MODULE: r.landscape.evol +# AUTHOR(S): Isaac Ullah, Michael Barton, Arizona State University +# Helena Mitasova, North Carolina State University +# PURPOSE: Create raster maps of net erosion/depostion, the modified terrain surface (DEM) after net +# erosion/deposition using the USPED equation, bedrock elevations after soil production, and soil +# depth maps. This module uses appropriate flow on different landforms by default; however, +# singular flow regimes can be chosen instead. +# ACKNOWLEDGEMENTS:National Science Foundation Grant #BCS0410269 +# Based on work of H. Mitasova and C. S. Thaxton, and Heimsath et al, 1997. +# COPYRIGHT: (C) 2007 by Isaac Ullah, Michael Barton, Arizona State University +# This program is free software under the GNU General Public +# License (>=v2). Read the file COPYING that comes with GRASS +# for details. +# +############################################################################# + + +#%Module +#% description: Create raster maps of net erosion/depostion, the modified terrain surface (DEM) after net erosion/deposition using the USPED equation, bedrock elevations after soil production, and soil depth maps. This module uses appropriate flow on different landforms by default; however, singular flow regimes can be chosen instead. THIS SCRIPT WILL PRODUCE MANY TEMPORARY MAPS AND REQUIRES A LOT OF FREE FILE SPACE! +#%End + +#%option +#% key: elev +#% type: string +#% gisprompt: old,cell,raster +#% description: Input elevation map (DEM) +#% required : yes +#% guisection: Input +#%end +#%option +#% key: initbdrk +#% type: string +#% gisprompt: old,cell,raster +#% description: Initial bedrock elevations map (for first iteration only) +#% answer: +#% required : yes +#% guisection: Input +#%end +#%option +#% key: prefx +#% type: string +#% description: Prefix for all output maps +#% answer: usped +#% required : yes +#% guisection: Input +#%end +#%flag +#% key: n +#% description: -n Do not output maps of net erosion/deposition +#% guisection: Input +#%end +#%flag +#% key: l +#% description: -l Do not output maps of soil depths +#% guisection: Input +#%end +#%flag +#% key: k +#% description: -k Keep all intermediate files as well +#% guisection: Input +#%end +#%flag +#% key: z +#% description: -z Keep region zoomed to output maps +#% answer: 1 +#% guisection: Input +#%end +#%flag +#% key: b +#% description: -b Use static bedrock elavations (do not create new soil) +#% answer: 1 +#% guisection: Input +#%end + + +#%option +#% key: R +#% type: string +#% description: Rainfall (R factor) constant or map +#% gisprompt: old,cell,raster +#% answer: 5 +#% required : yes +#% guisection: Variables +#%end +#%option +#% key: K +#% type: string +#% gisprompt: old,cell,raster +#% description: Soil erodability index (K factor) map or constant +#% answer: 0.32 +#% required : yes +#% guisection: Variables +#%end +#%option +#% key: C +#% type: string +#% gisprompt: old,cell,raster +#% description: Landcover index (C factor) map or constant +#% answer: 0.01 +#% required : yes +#% guisection: Variables +#%end +#%option +#% key: kappa +#% type: string +#% gisprompt: old,cell,raster +#% description: Hillslope diffusion (Kappa) rate map or constant (meters per kiloyear) +#% answer: 1 +#% required : yes +#% guisection: Variables +#%end +#%option +#% key: cutoff +#% type: string +#% description: Flow accumultion breakpoint value for shift from diffusion to overland flow (number of cells) +#% answer: 8 +#% required : yes +#% guisection: Variables +#%end +#%option +#% key: number +#% type: integer +#% description: number of iterations to run +#% answer: 1 +#% required : yes +#% guisection: Variables +#%end + + +#these are commented out as we currently utilize the profile curvature method described by Heimsath et al... +# #%option +# #% key: Ba +# #% type: string +# #% description: Rate of average soil production (Ba) +# #% answer: 0.00008 +# #% required : yes +# #% guisection: Variables +# #%end +# #%option +# #% key: Bb +# #% type: string +# #% description: Relationship between soil depth and production rate (Bb) +# #% answer: 0.1 +# #% required : yes +# #% guisection: Variables +# #%end + +#%flag +#% key: y +#% description: -y Don't smooth the map (faster, but spikes in erosion/deposition may result) +#% guisection: Smoothing_Filter +#%end +#%option +#% key: nbhood +#% type: string +#% description: Band-pass filter neighborhood size +#% answer: 3 +#% options: 1,3,5,7,9,11,13,15,17,19,21,23,25 +#% required : yes +#% guisection: Smoothing_Filter +#%end +#%option +#% key: sigma +#% type: string +#% description: Band-pass filter threshold value, sigma (meters) +#% answer: 0.10 +#% required : yes +#% guisection: Smoothing_Filter +#%end +#%option +#% key: method +#% type: string +#% description: Neighborhood smoothing method +#% answer: median +#% options: median,mode,average +#% required : yes +#% guisection: Smoothing_Filter +#%end + +#%flag +#% key: c +#% description: -c Output cumulative erosion/depostition map from data for all iterations +#% guisection: Statistics +#%end +#%flag +#% key: m +#% description: -m Output mean erosion/depostition map from data for all iterations +#% guisection: Statistics +#%end +#%flag +#% key: t +#% description: -t Output standard deviation of erosion/depostition map from data for all iterations +#% guisection: Statistics +#%end +#%flag +#% key: x +#% description: -x Output maximum erosion/depostition map from data for all iterations +#% guisection: Statistics +#%end +#%flag +#% key: i +#% description: -i Output minimum erosion/depostition map from data for all iterations +#% guisection: Statistics +#%end +#%flag +#% key: s +#% description: -s Output mean soil depths map from data for all iterations +#% guisection: Statistics +#%end +#%flag +#% key: v +#% description: -v Output standard deviation soil depths map from data for all iterations +#% guisection: Statistics +#%end +#%flag +#% key: a +#% description: -a Output maximum soil depths map from data for all iterations +#% guisection: Statistics +#%end +#%flag +#% key: u +#% description: -u Output minimum soil depths map from data for all iterations +#% guisection: Statistics +#%end + +#%flag +#% key: w +#% description: -w Calcuate for only sheetwash across entire map +#% guisection: Flow_type +#%end +#%flag +#% key: r +#% description: -r Calcuate for only channelized flow across entire map +#% guisection: Flow_type +#%end +#%flag +#% key: d +#% description: -d Calcuate for only diffusive flow (soil creep) across entire map +#% guisection: Flow_type +#%end +#%flag +#% key: f +#% description: -f Use r.terrflow instead of r.flow to calculate flow accumulation (better for massive grids) +#% guisection: Flow_type +#%end + + + +if [ -z "$GISBASE" ] ; then + echo "You must be in GRASS GIS to run this program." >&2 + exit 1 +fi + +if [ "$1" != "@ARGS_PARSED@" ] ; then + exec g.parser "$0" "$@" +fi + +prefx=$GIS_OPT_prefx +elev=$GIS_OPT_elev +initbdrk=$GIS_OPT_initbdrk +R=$GIS_OPT_R +K=$GIS_OPT_K +C=$GIS_OPT_C +kappa=$GIS_OPT_kappa +Ba=$GIS_OPT_Ba +Bb=$GIS_OPT_Bb +aplpha=$GIS_OPT_method +sigma=$GIS_OPT_sigma +nbhood=$GIS_OPT_nbhood +cutoff=$GIS_OPT_cutoff +echo "The following temporary files will be created:" +echo "" +neighbors=$prefx".neighbors1" +echo "neighbors=$neighbors" +tempsmoothdz=$prefx".tempsmoothdz1" +echo "tempsmoothdz=$tempsmoothdz" +smoothdz=$prefx"_smoothdz1" +echo "smoothdz=$smoothdz" +tempsmoothdz=$prefx".tempsmoothdz1" +echo "temsmoothpdz=$tempsmoothdz" +flowacc=$prefx".flowacc1" +echo "flowacc=$flowacc" +slope=$prefx".slope1" +echo "slope=$slope" +aspect=$prefx".aspect1" +echo "aspect=$aspect" +pc=$prefx".pc1" +echo "pc=$pc" +tc=$prefx".tc1" +echo "tc=$tc" +meancurv=$prefx".meancurv1" +echo "meancurv=$meancurv" +rate=$prefx".rate1" +echo "rate=$rate" +sflowtopo=$prefx".sflowtopo1" +echo "sflowtopo=$sflowtopo" +qsx=$prefx".qsx1" +echo "qsx=$qsx" +qsy=$prefx".qsy1" +echo "qsy=$qsy" +qsxdx=$prefx".qsx.dx1" +echo "qsxdx=$qsxdx" +qsydy=$prefx".qsy.dy1" +echo "qsydy=$qsydy" +m=$prefx".m1" +echo "m=$m" +n=$prefx".n1" +echo "n=$n" +erdep=$prefx".erosdep1" +echo "erdep=$erdep" +initsoil=$prefx".initsoil" + +echo "" + +new_soil=$prefx"_new_soil1" +new_dem=$prefx"_new_dem1" +initsoil=$prefx"_initsoil" +echo "Initial soil depths calculated will be in $initsoil" +echo "The new dem for this iteration will be called $new_dem" +echo "The new soil depth map for this iteration will be called $new_soil" + +if [ "$GIS_FLAG_b" -eq 1 ]; then + +echo "" + +else + +new_bdrk=$prefx"_new_bdrk1" +echo "The new bedrock elevation map for this iteration will be called $new_bdrk" + +fi + +#let's grab the current resolution +res1=`eval g.region -p -m | grep "nsres:" | cut -d : -f 2` + +# we must set the region to the map being used. otherwise r.flow will not work +echo "" +echo "Setting region to $elev" +g.region rast=$elev + +#now lets show before: +echo "" +echo "Original Resolution = $res1" + +#...and after: +res=`eval g.region -p -m | grep "nsres:" | cut -d : -f 2` +echo "" +echo "New Resolution = $res" + + +echo "" +echo "_____________________________________________________________" +echo "Beginning iteration sequence. This will take some time." +echo "" +echo "Process is not finished until you see the message: 'Done with everything' " +echo "_____________________________________________________________" +# the first iteration must be run before the loop to set up the input data for the loop and to use the "initsoil" map to set up soil production function +echo "" +echo "##################################################" +echo "##################################################" +echo "" +echo "ITERATION 1" +echo "" +echo "##################################################" +echo "" +echo "*************************" +echo "step 1 of 8: calculating slope and aspect (if initial aspect not specified)" +echo "*************************" +echo "" + + +r.slope.aspect --q $elev slope=$slope aspect=$aspect pcurv=$pc tcurv=$tc + +echo "" +echo "*************************" +echo "step 2 of 8: calculating upslope accumulated flow" +echo "*************************" +echo "" + +if [ "$GIS_FLAG_f" -eq 1 ]; then + +echo "using r.terraflow to calculate overland flow accumulation per cell (number of cells uplsope from each cell)" +echo "" + +#First we need to grab the amount of free RAM for r.terraflow + +mem=`eval free -mo | grep "Mem" | tr -s /[:blank:] /[:] | cut -d":" -f4` + +#r.terraflow can't handle it if you tell it to use more than 2 Gigs of RAM, so if you have more than that, we have to tell r.terraflow to only use up to 2 Gigs of the free RAM... + +if [ "$mem" -lt "2000" ]; then + +mem=$mem + +else + +mem="2000" + +fi + + +echo "Amount of free RAM being allocated for this step: $mem Megabites" + +r.terraflow --q elev=$elev filled=$prefx".filled" direction=$prefx".direct" swatershed=$prefx".sink" accumulation=$prefx".tmpflacc" tci=$prefx".tci" d8cut=infinity memory=$mem STREAM_DIR=/var/tmp + +r.mapcalc "$flowacc=$prefx".tmpflacc"/$res" + +g.remove --q rast=$prefx".filled",$prefx".direct",$prefx".sink",$prefx".tci",$prefx".tmpflacc" +rm -f /var/tmp/STREAM* + +else + +echo "using r.flow to calculate overland flow accumulation per cell (number of cells uplsope from each cell)" + +tmpflacc=$prefx".tmpflacc" + +r.flow -3 --quiet elevin=$elev aspin=$aspect dsout=$tmpflacc + +r.mapcalc "$flowacc=$tmpflacc*$res" + +g.remove --quiet rast=$tmpflacc + +fi + +echo "" +echo "*************************" +echo "step 3 of 8: calculating basic sediment transport rates" +echo "*************************" +echo "" + + + + + +if [ "$GIS_FLAG_w" -eq 1 -a "$GIS_FLAG_d" -eq 0 -a "$GIS_FLAG_r" -eq 0 ]; then + +echo "" +echo "calculating for sheetwash across the entire map" + r.mapcalc "$sflowtopo=$flowacc * sin($slope)" + +elif [ "$GIS_FLAG_r" -eq 1 -a "$GIS_FLAG_d" -eq 0 -a "$GIS_FLAG_w" -eq 0 ] +then + +echo "" +echo "calculating for channelzed flow across the entire map" + r.mapcalc "$sflowtopo=exp(($flowacc),1.6) * exp(sin($slope),1.3)" + + + +elif [ "$GIS_FLAG_d" -eq 1 -a "$GIS_FLAG_r" -eq 0 -a "$GIS_FLAG_w" -eq 0 ] +then + +echo "" +echo "calculating for diffusive flow across the entire map" + r.mapcalc "$sflowtopo=$kappa * exp(($res),2) * sin($slope)" + + +elif [ "$GIS_FLAG_d" -eq 1 -a "$GIS_FLAG_r" -eq 1 -a "$GIS_FLAG_w" -eq 0 ] +then + +echo "" +echo "############################################################" +echo "!!!!!!!!!YOU MUST SELECT ONLY ONE TYPE OF EROSION!!!!!!!!!!!" +echo "############################################################" +echo "" + +elif [ "$GIS_FLAG_d" -eq 0 -a "$GIS_FLAG_r" -eq 1 -a "$GIS_FLAG_w" -eq 1 ] +then + +echo "" +echo "############################################################" +echo "!!!!!!!!!YOU MUST SELECT ONLY ONE TYPE OF EROSION!!!!!!!!!!!" +echo "############################################################" +echo "" + +elif [ "$GIS_FLAG_d" -eq 1 -a "$GIS_FLAG_r" -eq 0 -a "$GIS_FLAG_w" -eq 1 ] +then + +echo "" +echo "############################################################" +echo "!!!!!!!!!YOU MUST SELECT ONLY ONE TYPE OF EROSION!!!!!!!!!!!" +echo "############################################################" +echo "" + +elif [ "$GIS_FLAG_d" -eq 1 -a "$GIS_FLAG_r" -eq 1 -a "$GIS_FLAG_w" -eq 1 ] +then + +echo "" +echo "############################################################" +echo "!!!!!!!!!YOU MUST SELECT ONLY ONE TYPE OF EROSION!!!!!!!!!!!" +echo "############################################################" +echo "" + +else + +maxflow=`eval r.univar -g map=$flowacc percentile=90 | grep "max=" | cut -d"=" -f2` +minflow=`eval r.univar -g map=$flowacc percentile=90 | grep "min=" | cut -d"=" -f2` + +echo "" +echo "The raw max ($maxflow) and min ($minflow) flow accumulation will be used to scale flow exponents 'm' and 'n' " +echo "" + +echo "" +echo "Calculating with appropriate flow types on different landforms" + +r.mapcalc "$m=1+($flowacc * (0.6/($maxflow - $minflow)))" +r.mapcalc "$n=1+($flowacc * (0.3/($maxflow - $minflow)))" + +report1=`eval r.info -r map=$m | grep "max=" | cut -d"=" -f2` +report2=`eval r.info -r map=$m | grep "min=" | cut -d"=" -f2` + +echo "" +echo "(for diagnostics only) max m = $report1, min m = $report2" + + +r.mapcalc "$sflowtopo=if ($flowacc >= $cutoff, exp(($flowacc),$m) * exp(sin($slope),$n), ($kappa * exp(($res),2) *sin($slope)))" + + +fi + +echo "" +echo "*************************" +echo "step 4 of 8: calculating sediment transport capacity in x and y directions" +echo "*************************" +echo "" + +r.mapcalc "$qsx=if ("$initbdrk" >= "$elev", 0, ($R * $K * $C * $sflowtopo * cos($aspect)))" +r.mapcalc "$qsy=if ("$initbdrk" >= "$elev", 0, ($R * $K * $C * $sflowtopo * sin($aspect)))" + + +echo "" +echo "*************************" +echo "step 5 of 8: calculating partial derivatives for sediment transport" +echo "*************************" +echo "" + + +r.slope.aspect --q $qsx dx=$qsxdx +r.slope.aspect --q $qsy dy=$qsydy + + +echo "" +echo "*************************" +echo "step 6 of 8: calculating net erosion and deposition" +echo "*************************" +echo "" + + +#this is commented out because I don't fully understand why we should multiply by the resolution again here. I think that it is actually a typo incorporated into every version of the script since the beginning. +#echo "calculating for rill erosion" +# r.mapcalc "$erdep=$res * ($qsxdx + $qsydy)" + + +r.mapcalc "$erdep=$qsxdx + $qsydy" + +r.mapcalc "$initsoil=$elev - $initbdrk" + +echo "" +echo "*************************" +echo "step 7 of 8: running band-pass filter" +echo "*************************" +echo "" + +if [ "$GIS_FLAG_y" -eq 1 ]; then + +echo ""echo "You have selected not to smooth your files... Oh Well!" +echo "" + +r.mapcalc "$smoothdz=if((-1 * $erdep) >= $initsoil, (-1 * $initsoil), $erdep)" + +else + + +r.neighbors --q input=$erdep output=$neighbors method=$GIS_OPT_method size=$GIS_OPT_nbhood +r.mapcalc "$tempsmoothdz=if((-1 * $erdep) >= $initsoil, (-1 * $initsoil), $erdep)" +r.mapcalc "$smoothdz=if((abs($tempsmoothdz-$neighbors)) > $GIS_OPT_sigma , $neighbors , $tempsmoothdz)" + +fi + +# create temporary file to code colors for $smoothdz +TMP1=`g.tempfile pid=$$` + +if [ $? -ne 0 ] || [ -z "$TMP1" ]; then + echo "ERROR: unable to create temporary file for colors" 1>&2 + exit 1 +else + + echo "creating temporary file to code colors" + +fi + + +echo "0% 255 000 255" > $TMP1 +echo "-5 255 000 255" >> $TMP1 +echo "-3 red" >> $TMP1 +echo "-1 orange" >> $TMP1 +echo "-0.5 yellow" >> $TMP1 +echo "0 white" >> $TMP1 +echo "0.5 green" >> $TMP1 +echo "1 cyan" >> $TMP1 +echo "3 aqua" >> $TMP1 +echo "5 violet" $TMP1 +echo "100% 104 034 139" >> $TMP1 +echo "end" >> $TMP1 + + +cat $TMP1 | r.colors --q map=$smoothdz color=rules + +echo "" +echo "*************************" +echo "step 8 of 8: calculating terrain evolution, new bedrock elevations, and new soil depths" +echo "*************************" +echo "" + +r.mapcalc "$new_dem=$smoothdz + $elev" + +r.colors --q map=$new_dem rast=$elev + +if [ $GIS_FLAG_b -eq 1 ]; then + +echo "" +echo "Calculating new soil depths keeping bedrock elevations static" + + +new_bdrk=$initbdrk +r.mapcalc "$new_soil=if (($new_dem - $new_bdrk) < 0, 0, ($new_dem - $new_bdrk))" + +else + +echo "" +echo "step 8.5: Calculating new soil depths from landscape curvature" + +r.mapcalc "$meancurv=(($pc + $tc) / 2)" + + +max=`eval r.info -r map=$meancurv | grep "max=" | cut -d"=" -f2` +min=`eval r.info -r map=$meancurv | grep "min=" | cut -d"=" -f2` + +echo "" +echo "The raw max ($max) and min ($min) curvature will be rescaled from 2 to 0 " +echo "" + + +r.mapcalc "$rate=$kappa*(2-($meancurv*(2/($max)-($min))))" + +#rate is actually the net change in bedrock elevation due to soil production, so lets use it to find the new bedrock elev, and the new soil depth! + +r.mapcalc "$new_bdrk=$initbdrk - $rate" +r.mapcalc "$new_soil=if (($new_dem - $new_bdrk) < 0, 0, ($new_dem - $new_bdrk))" + +fi + + +#these are the old soil equations that I failed to be able to implement... I leave them in for documentation purposes +#r.mapcalc "$new_bdrk=$initbdrk - ($Ba * ($Bb*($smoothdz - $initbdrk)))" +#r.mapcalc "$new_soil=if (($smoothdz - $initbdrk) < 0, 0, ($smoothdz - $initbdrk))" + +#grabsomestats +tmperosion=$prfx"_tmperosion1" +tmpdep=$prfx"_tmpdep1" + +r.mapcalc "$tmperosion=if($smoothdz < 0, $smoothdz, null())" +r.mapcalc "$tmpdep=if($smoothdz > 0, $smoothdz, null())" + +avesoil=`eval r.univar -g map=$new_soil percentile=90 | grep "mean=" | cut -d'=' -f2` +aveeros=`eval r.univar -g map=$tmperosion percentile=90 | grep "mean=" | cut -d'=' -f2` +avedep=`eval r.univar -g map=$tmpdep percentile=90 | grep "mean=" | cut -d'=' -f2` + +g.remove --quiet rast=$tmperosion,$tmpdep + +txtout=$prefx"_erdep_stats.txt" + +echo "outputing stats to textfile: $txtout" + +echo "Stats for erosion and deposition simulation with starting map: $elev" > $txtout +echo "" >> $txtout +echo "Year,Mean Erosion, Mean Deposition,Mean Soil Depth" >> $txtout +echo "1,$aveeros,$avedep,$avesoil" >> $txtout + + +echo "" +echo "*************************" +echo "Done with this iteration" +echo "*************************" + + + +echo "" +echo "Raster map $smoothdz shows filtered net erosion/deposition" +echo "" +echo "Raster map $new_dem shows new landscape (new elevations) after net erosion/depostion" +echo "*************************" +echo "" + + +#This is replaced by the large g.mremove process at the end of the script. I leave it commented because one might like to have the files for each iteration cleaned up as the process runs instead of one batch process at the end. +#if [ "$GIS_FLAG_k" -eq 1 ]; then +# echo "" +# echo "Done" +# echo "" +#else +# echo "" +# echo "Cleaning up..." +# g.remove rast=$flowacc,$slope,$aspect,$sflowtopo,$qsx,$qsy,$qsxdx,$qsydy,$erdep,$neighbors +# echo "" +# echo "Done" +#fi + + +#remove the temp files to avoid confusion...\rm -f $TMP1 $TMP1.sort + + +number=$GIS_OPT_number +echo "total number of iterations to be run= $number" +step=1 + +# now we must go into a loop to get the rest of the dem's + +while [ "$step" -lt "$number" ] +do + laststep=$step + step=$(($step+1)) # here is how we are controlling the iteration loop + + +old_dem=$prefx"_new_dem"$laststep + +echo "The following temporary files will be created:" +echo "" +neighbors=$prefx".neighbors"$step +echo "neighbors=$neighbors" +tempsmoothdz=$prefx".tempsmoothdz"$step +echo "tempsmoothdz=$tempsmoothdz" +temp2smoothdz=$prefx".temp2smoothdz"$step +echo "temp2smoothdz=$temp2smoothdz" +smoothdz=$prefx"_smoothdz"$step +echo "smoothdz=$smoothdz" +flowacc=$prefx".flowacc"$step +echo "flowacc=$flowacc" +slope=$prefx".slope"$step +echo "slope=$slope" +aspect=$prefx".aspect"$step +echo "aspect=$aspect" +pc=$prefx".pc"$step +echo "pc=$pc" +tc=$prefx".tc"$step +echo "tc=$tc" +meancurv=$prefx".meancurv"$step +echo "meancurv=$meancurv" +rate=$prefx".rate"$step +echo "rate=$rate" +sflowtopo=$prefx".sflowtopo"$step +echo "sflowtopo=$sflowtopo" +qsx=$prefx".qsx"$step +echo "qsx=$qsx" +qsy=$prefx".qsy"$step +echo "qsy=$qsy" +qsxdx=$prefx".qsx.dx"$step +echo "qsxdx=$qsxdx" +qsydy=$prefx".qsy.dy"$step +echo "qsydy=$qsydy" +m=$prefx".m"$step +echo "m=$m" +n=$prefx".n"$step +echo "n=$n" +erdep=$prefx".erosdep"$step +echo "erdep=$erdep" +old_bdrk=$prefx"_new_bdrk"$laststep +echo "old_bdrk=$old_bdrk" +old_soil=$prefx"_new_soil"$laststep +echo "old_soil=$old_soil" +echo "" + +new_soil=$prefx"_new_soil"$step +new_dem=$prefx"_new_dem"$step +echo "The new dem for this iteration will be called $new_dem" +echo "The new soil depth map for this iteration will be called $new_soil" + +if [ "$GIS_FLAG_b" -eq 1 ]; then + +echo "" + +else + +new_bdrk=$prefx"_new_bdrk"$step +echo "The new bedrock elevation map for this iteration will be called $new_bdrk" + +fi + +echo "" +echo "##################################################" +echo "##################################################" +echo "" +echo "ITERATION $step" +echo "" +echo "##################################################" +echo "" +echo "*************************" +echo "step 1 of 8: calculating slope and aspect" +echo "*************************" +echo "" + +r.slope.aspect --q elevation=$old_dem slope=$slope aspect=$aspect pcurv=$pc tcurv=$tc + + +echo "" +echo "*************************" +echo "step 2 of 8: calculating upslope accumulated flow" +echo "*************************" +echo "" + + + +if [ "$GIS_FLAG_f" -eq 1 ]; then + +echo "using r.terraflow to calculate overland flow accumulation per cell (number of cells uplsope from each cell)" +echo "" + +#First we need to grab the amount of free RAM for r.terraflow + +mem=`eval free -mo | grep "Mem" | tr -s /[:blank:] /[:] | cut -d":" -f4` + +#r.terraflow can't handle it if you tell it to use more than 2 Gigs of RAM, so if you have more than that, we have to tell r.terraflow to only use up to 2 Gigs of the free RAM... + +if [ "$mem" -lt "2000" ]; then + +mem=$mem + +else + +mem="2000" + +fi + + +echo "Amount of free RAM being allocated for this step: $mem Megabites" + +r.terraflow --q elev=$elev filled=$prefx".filled" direction=$prefx".direct" swatershed=$prefx".sink" accumulation=$prefx".tmpflacc" tci=$prefx".tci" d8cut=infinity memory=$mem STREAM_DIR=/var/tmp + +r.mapcalc "$flowacc=$prefx".tmpflacc"/$res" + +g.remove --q rast=$prefx".filled",$prefx".direct",$prefx".sink",$prefx".tci",$prefx".tmpflacc" +rm -f /var/tmp/STREAM* + +else + +echo "using r.flow to calculate overland flow accumulation per cell (number of cells uplsope from each cell)" + +tmpflacc=$prefx".tmpflacc" +r.flow -3 --quiet elevin=$elev aspin=$aspect dsout=$tmpflacc + +r.mapcalc "$flowacc=$tmpflacc*$res" + +g.remove --quiet rast=$tmpflacc + +fi + + + +echo "" +echo "*************************" +echo "step 3 of 8: calculating basic sediment transport rates" +echo "*************************" +echo "" + + +initbdrk + +if [ "$GIS_FLAG_w" -eq 1 -a "$GIS_FLAG_d" -eq 0 -a "$GIS_FLAG_r" -eq 0 ]; then + +echo "" +echo "calculating for sheetwash across the entire map" + r.mapcalc "$sflowtopo=$flowacc * sin($slope)" + +elif [ "$GIS_FLAG_r" -eq 1 -a "$GIS_FLAG_d" -eq 0 -a "$GIS_FLAG_w" -eq 0 ] +then + +echo "" +echo "calculating for channelzed flow across the entire map" + r.mapcalc "$sflowtopo=exp(($flowacc),$m) * exp(sin($slope),$n)" + + +elif [ "$GIS_FLAG_d" -eq 1 -a "$GIS_FLAG_r" -eq 0 -a "$GIS_FLAG_w" -eq 0 ] +then + +echo "" +echo "calculating for diffusive flow across the entire map" + r.mapcalc "$sflowtopo=$kappa * exp(($res),2) * sin($slope)" + + +elif [ "$GIS_FLAG_d" -eq 1 -a "$GIS_FLAG_r" -eq 1 -a "$GIS_FLAG_w" -eq 0 ] +then + +echo "" +echo "############################################################" +echo "!!!!!!!!!YOU MUST SELECT ONLY ONE TYPE OF EROSION!!!!!!!!!!!" +echo "############################################################" +echo "" + +elif [ "$GIS_FLAG_d" -eq 0 -a "$GIS_FLAG_r" -eq 1 -a "$GIS_FLAG_w" -eq 1 ] +then + +echo "" +echo "############################################################" +echo "!!!!!!!!!YOU MUST SELECT ONLY ONE TYPE OF EROSION!!!!!!!!!!!" +echo "############################################################" +echo "" + +elif [ "$GIS_FLAG_d" -eq 1 -a "$GIS_FLAG_r" -eq 0 -a "$GIS_FLAG_w" -eq 1 ] +then + +echo "" +echo "############################################################" +echo "!!!!!!!!!YOU MUST SELECT ONLY ONE TYPE OF EROSION!!!!!!!!!!!" +echo "############################################################" +echo "" + +elif [ "$GIS_FLAG_d" -eq 1 -a "$GIS_FLAG_r" -eq 1 -a "$GIS_FLAG_w" -eq 1 ] +then + +echo "" +echo "############################################################" +echo "!!!!!!!!!YOU MUST SELECT ONLY ONE TYPE OF EROSION!!!!!!!!!!!" +echo "############################################################" +echo "" + +else + +maxflow=`eval r.univar -g map=$flowacc percentile=90 | grep "max=" | cut -d"=" -f2` +minflow=`eval r.univar -g map=$flowacc percentile=90 | grep "min=" | cut -d"=" -f2` + + +echo "" +echo "The raw max ($maxflow) and min ($minflow) flow accumulation will be used to scale flow exponents 'm' and 'n' " +echo "" + +echo "" +echo "calculating with appropriate flow types on different landforms" + +r.mapcalc "$m=1+($flowacc * (0.6/($maxflow - $minflow)))" +r.mapcalc "$n=1+($flowacc * (0.3/($maxflow - $minflow)))" + +r.mapcalc "$sflowtopo=if ($flowacc >= $cutoff, exp(($flowacc),$m) * exp(sin($slope),$n), ($kappa * exp(($res),2) *sin($slope)))" + +fi + + + +echo "" +echo "*************************" +echo "step 4 of 8: calculating sediment transport capacity in x and y directions" +echo "*************************" +echo "" + + +r.mapcalc "$qsx= if ($old_soil <= 0, 0, ($R * $K * $C * $sflowtopo * cos($aspect)))" +r.mapcalc "$qsy= if ($old_soil <= 0, 0, ($R * $K * $C * $sflowtopo * sin($aspect)))" + + +echo "" +echo "*************************" +echo "step 5 of 8: calculating partial derivatives for sediment transport" +echo "*************************" +echo "" + + +r.slope.aspect --q $qsx dx=$qsxdx +r.slope.aspect --q $qsy dy=$qsydy + + +echo "" +echo "*************************" +echo "step 6 of 8: calculating net erosion and deposition" +echo "*************************" +echo "" + + + + r.mapcalc "$erdep=$qsxdx + $qsydy" + + +echo "" +echo "*************************" +echo "step 7 of 8: running band-pass filter" +echo "*************************" +echo "" + +lastsmooth=$prefx"_smoothdz"$laststep + +if [ "$GIS_FLAG_y" -eq 1 ]; then +echo "" +echo "You have selected not to smooth your files... Oh Well!" +echo "" + +r.mapcalc "$temp2smoothdz=if((-1 * $erdep) >= $old_soil, (-1 * $old_soil), $erdep)" + +else + +r.neighbors --q input=$erdep output=$neighbors method=$GIS_OPT_method size=$GIS_OPT_nbhood +r.mapcalc "$tempsmoothdz=if((-1 * $erdep) >= $old_soil, (-1 * $old_soil), $erdep)" +r.mapcalc "$temp2smoothdz=if((abs($tempsmoothdz-$neighbors)) > $GIS_OPT_sigma , $neighbors , $tempsmoothdz)" + +fi + +#now we must correct for the incredible edge shrinking effect by patching the last smoothdz underneath the new smoothdz +r.patch input=$temp2smoothdz,$lastsmooth output=$smoothdz + + +# create temporary file to code colors for $smoothdz +TMP1=`g.tempfile pid=$$` + +if [ $? -ne 0 ] || [ -z "$TMP1" ] ; then + echo "ERROR: unable to create temporary file for colors" 1>&2 + exit 1 +else + echo "creating temporary file to code colors" + +fi + +echo "0% 255 000 255" > $TMP1 +echo "-5 255 000 255" >> $TMP1 +echo "-3 red" >> $TMP1 +echo "-1 orange" >> $TMP1 +echo "-0.5 yellow" >> $TMP1 +echo "0 white" >> $TMP1 +echo "0.5 green" >> $TMP1 +echo "1 cyan" >> $TMP1 +echo "3 aqua" >> $TMP1 +echo "5 violet" $TMP1 +echo "100% 104 034 139" >> $TMP1 +echo "end" >> $TMP1 + + +cat $TMP1 | r.colors --q map=$smoothdz color=rules + +echo "" +echo "*************************" +echo "step 8 of 8: calculating terrain evolution and new soil depths/bedrock elevations" +echo "*************************" +echo "" + +r.mapcalc "$new_dem=$smoothdz + $old_dem" +r.colors --q map=$new_dem rast=$elev + +if [ $GIS_FLAG_b -eq 1 ]; then + +echo "" +echo "Calculating new soil depths keeping bedrock elevations static" + + +new_bdrk=$old_bdrk +r.mapcalc "$new_soil=if (($new_dem - $new_bdrk) < 0, 0, ($new_dem - $new_bdrk))" + +else + +echo "" +echo "step 8.5: Calculating new soil depths from landscape curvature" + +r.mapcalc "$meancurv=($pc+$tc/2)" + +# create temporary file to clip the max and min to +TMP5=`g.tempfile pid=$$` + + +max=`eval r.info -r map=$meancurv | grep "max=" | cut -d"=" -f2` +min=`eval r.info -r map=$meancurv | grep "min=" | cut -d"=" -f2` + +echo "" +echo "The raw max ($max) and min ($min) will be rescaled from 2 to 0 " +echo "" + +r.mapcalc "$rate=$kappa*(2-($meancurv*(2/($max)-($min))))" + +#rate is actually the net change in bedrock elevation due to soil production, so lets use it to find the new bedrock elev, and the new soil depth! + +r.mapcalc "$new_bdrk=$old_bdrk - $rate" +r.mapcalc "$new_soil=if (($new_dem - $new_bdrk) < 0, 0, ($new_dem - $new_bdrk))" + +fi + +#these are the old soil equations that I failed to be able to implement... I leave them in for documentation purposes +#r.mapcalc "$new_bdrk= $old_bdrk - ($Ba * (exp(($smoothdz - $old_bdrk),$Bb)))" +#r.mapcalc "$new_soil=if (($smoothdz - $old_bdrk) < 0, 0, ($smoothdz - $old_bdrk))" + + +#grabsomestats +tmperosion=$prfx"_tmperosion"$step +tmpdep=$prfx"_tmpdep"$step + +r.mapcalc "$tmperosion=if($smoothdz < 0, $smoothdz, null())" +r.mapcalc "$tmpdep=if($smoothdz > 0, $smoothdz, null())" + +avesoil=`eval r.univar -g map=$new_soil percentile=90 | grep "mean=" | cut -d'=' -f2` +aveeros=`eval r.univar -g map=$tmperosion percentile=90 | grep "mean=" | cut -d'=' -f2` +avedep=`eval r.univar -g map=$tmpdep percentile=90 | grep "mean=" | cut -d'=' -f2` + +g.remove --quiet rast=$tmperosion,$tmpdep + +echo "outputing stats to textfile: $txtout" + +echo "$step,$aveeros,$avedep,$avesoil" >> $txtout + + +echo "" +echo "*************************" +echo "Done with this iteration" +echo "*************************" + + + + +echo "" +echo "Raster map $smoothdz shows filtered net erosion/deposition" +echo "" +echo "Raster map $new_dem shows new landscape (new elevations) after net erosion/depostion" +echo "*************************" +echo "########################################################" +echo "" + +#remove the temp files to avoid confusion... +\rm -f $TMP1 $TMP1.sort + +done + +# now we have met the loop critereon set by us above, so we have broken out. We must now reset the region settings + + +# create temporary file to list all the smoothdz files for statistics +TMP2=`g.tempfile pid=$$` +if [ $? -ne 0 ] || [ -z "$TMP2" ] ; then + echo "ERROR: unable to create temporary file to list all the smoothdz files for statistics" 1>&2 + exit 1 +fi + + +g.mlist type=rast sep=, pattern=$prefx"_smoothdz*" > $TMP2 +liststring=`cat $TMP2` + +echo "Any selected statistics will be performed using the following smoothdz files: $liststring" + +if [ "$GIS_FLAG_c" -eq 1 ]; then + +r.series --q input=$liststring output=$prefx"_cum_erdep" method=sum +fi + +if [ "$GIS_FLAG_m" -eq 1 ]; then + +r.series --q input=$liststring output=$prefx"_ave_erdep" method=average +fi + +if [ "$GIS_FLAG_t" -eq 1 ]; then + +r.series --q input=$liststring output=$prefx"_sdev_erdep" method=stddev +fi + +if [ "$GIS_FLAG_x" -eq 1 ]; then + +r.series --q input=$liststring output=$prefx"_max_erdep" method=maximum +fi + +if [ "$GIS_FLAG_i" -eq 1 ]; then + +r.series --q input=$liststring output=$prefx"_min_erdep" method=minimum +fi + + + +# create temporary file to list all the soil depth files for statistics +TMP3=`g.tempfile pid=$$` +if [ $? -ne 0 ] || [ -z "$TMP3" ] ; then + echo "ERROR: unable to create temporary file to list all the soil depth files for statistics" 1>&2 + exit 1 +fi + +g.mlist type=rast sep=, pattern=$prefx"_new_soil*" > $TMP3 + +liststring2=`cat $TMP3` + +echo "Any selected statistics will be performed using the following soil depth files: $liststring2" + +if [ "$GIS_FLAG_s" -eq 1 ]; then + +r.series --q input=$liststring2 output=$prefx"_ave_soil" method=average +fi + +if [ "$GIS_FLAG_v" -eq 1 ]; then + +r.series --q input=$liststring2 output=$prefx"_sdev_soil" method=stddev +fi + +if [ "$GIS_FLAG_a" -eq 1 ]; then + +r.series --q input=$liststring2 output=$prefx"_max_soil" method=maximum +fi + + +if [ "$GIS_FLAG_u" -eq 1 ]; then + +r.series --q input=$liststring2 output=$prefx"_min_soil" method=minimum +fi +\rm -f $TMP2 $TMP2.sort +\rm -f $TMP3 $TMP3.sort + + +echo "************************" + +if [ "$GIS_FLAG_k" -eq 1 ]; then + +echo "" +echo "Done" +echo "" + +else + +echo "" +echo "Cleaning up..." + +g.mremove -f --q rast=$prefx".neighbors*" +g.mremove -f --q rast=$prefx".smoothdz*" +g.mremove -f --q rast=$prefx".flowacc*" +g.mremove -f --q rast=$prefx".slope*" +g.mremove -f --q rast=$prefx".aspect*" +g.mremove -f --q rast=$prefx".sflowtopo*" +g.mremove -f --q rast=$prefx".qsx*" +g.mremove -f --q rast=$prefx".qsy*" +g.mremove -f --q rast=$prefx".qsx.dx*" +g.mremove -f --q rast=$prefx".qsy.dy*" +g.mremove -f --q rast=$prefx".erosdep*" +g.mremove -f --q rast=$prefx".pc*" +g.mremove -f --q rast=$prefx".tc*" +g.mremove -f --q rast=$prefx".meancurv*" +g.mremove -f --q rast=$prefx".rate*" +g.mremove -f --q rast=$prefx".tempsmoothdz*" +g.mremove -f --q rast=$prefx".temp2smoothdz*" +g.mremove -f --q rast=$prefx".m*" +g.mremove -f --q rast=$prefx".n*" + + echo "" + echo "Done" + +fi + +if [ "$GIS_FLAG_n" -eq 1 ]; then + + g.mremove --q rast=$prefx"_smoothdz*" +fi + +if [ "$GIS_FLAG_l" -eq 1 ]; then + + g.mremove --q rast=$prefx"_new_soil*" +fi + +if [ "$GIS_FLAG_z" -eq 1 ]; then +echo "" +echo "Iterations complete, keeping region set to output maps" +echo "" +else +echo "" +echo "Iterations complete, restoring default region settings" +echo "" + +g.region -d -g + +echo "" +fi +echo "###################################################" +echo "###################################################" +echo "___________________________________________________" +echo "" +echo " DONE WITH EVERYHTING" +echo "" +echo "___________________________________________________" + + + + From barton at grass.itc.it Thu Jun 28 09:06:15 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Jun 28 09:06:18 2007 Subject: [grass-addons] r876 - trunk/grassaddons/gui Message-ID: <200706280706.l5S76FZD022454@grass.itc.it> Author: barton Date: 2007-06-28 09:06:07 +0200 (Thu, 28 Jun 2007) New Revision: 876 Modified: trunk/grassaddons/gui/location_wizard.py Log: EPSG code location creation now working in wizard Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-06-27 22:44:04 UTC (rev 875) +++ trunk/grassaddons/gui/location_wizard.py 2007-06-28 07:06:07 UTC (rev 876) @@ -8,6 +8,12 @@ import string import re +import gui_modules +gmpath = gui_modules.__path__[0] +sys.path.append(gmpath) + +import gui_modules.cmd as cmd + global coordsys global epsgcode global georeffile @@ -19,6 +25,7 @@ global east global west global resolution +global wizerror coordsys = '' epsgcode = '' @@ -252,8 +259,8 @@ except IOError, e: self.transformlist.DeleteAllItems() - dlg = wx.MessageDialog(self, "Could not read datum params: %s " - % e,"Can not read file", wx.OK|wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self, "Could not read datum params: %s " % e, + "Could not read file", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() @@ -284,8 +291,8 @@ f.close() self.datumlist.SendSizeEvent() except IOError, e: - dlg = wx.MessageDialog(self, "Could not read datums: %s " - % e,"Can not read file", wx.OK|wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self, "Could not read datums: %s " % e, + "Could not read file", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() @@ -401,8 +408,8 @@ self.lmessage = wx.StaticText(self,-1, "", size=(300,50)) # buttons - self.bbrowsegdal = self.MakeButton("Browse ...", size=(150,-1)) - self.bbrowseogr = self.MakeButton("Browse ...", size=(150,-1)) + self.bbrowsegdal = self.MakeButton("Browse...", size=(150,-1)) + self.bbrowseogr = self.MakeButton("Browse...", size=(150,-1)) self.bgetlayers = self.MakeButton("Get Layers", size=(150,-1)) self.bset = self.MakeButton("Set coordinates", size=(150,-1)) @@ -853,8 +860,8 @@ f.close() self.SendSizeEvent() except StandardError, e: - dlg = wx.MessageDialog(self, "Could not read datums: %s " - % e,"Can not read file", wx.OK|wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self, "Could not read datums: %s " % e, + "Could not read file", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() @@ -870,7 +877,7 @@ self.lfile= wx.StaticText(self, -1, "Georeferenced file: ", style=wx.ALIGN_RIGHT) self.tfile = wx.TextCtrl(self,-1, "", size=(150,-1)) - self.bbrowse = self.MakeButton("Browse ...") + self.bbrowse = self.MakeButton("Browse...") # do layout self.sizer.Add(self.lfile, 0, wx.ALIGN_RIGHT | @@ -920,8 +927,8 @@ self.tcode = wx.TextCtrl(self,-1, "", size=(200,-1)) # buttons - self.bbrowse = wx.Button(self, -1, "Browse ...", size=(100,-1)) - self.bbcodes = wx.Button(self, -1, "Browse Codes") + self.bbrowse = wx.Button(self, -1, "Browse...") + self.bbcodes = wx.Button(self, -1, "Browse Codes...") # search box self.searchb = wx.SearchCtrl(self, size=(200,-1), style=wx.TE_PROCESS_ENTER) @@ -980,7 +987,7 @@ def onPageChange(self, event): global epsgcode epsgcode = self.tcode.GetValue() - self.parent.datumpage.SetPrev(self) + self.parent.bboxpage.SetPrev(self) #wx.MessageBox("setting epsgcode to %s" % (epsgcode)) def OnDoSearch(self,event): @@ -1008,6 +1015,7 @@ def OnItemSelected(self,event): item = event.GetItem() + #wx.MessageBox("item = %s" % (item.GetText())) self.tcode.SetValue(str(item.GetText())) def OnBrowseCodes(self,event,search=None): @@ -1049,8 +1057,8 @@ self.epsgs.SetColumnWidth(2, wx.LIST_AUTOSIZE) self.SendSizeEvent() except StandardError, e: - dlg = wx.MessageDialog(self, "Could not read EPGS codes: %s " - % e,"Can not read file", wx.OK|wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self, "Could not read EPGS codes: %s " % e, + "Could not read file", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() @@ -1070,11 +1078,11 @@ self.cs = "xy" # toggles - self.radio1 = wx.RadioButton( self, -1, " XY ", style = wx.RB_GROUP ) - self.radio2 = wx.RadioButton( self, -1, " Lat/Long " ) - self.radio3 = wx.RadioButton( self, -1, " UTM " ) - self.radio4 = wx.RadioButton( self, -1, " Custom " ) - self.radio5 = wx.RadioButton( self, -1, " EPSG " ) + self.radio1 = wx.RadioButton( self, -1, " XY (arbitrary non-earth coordinate system)", style = wx.RB_GROUP ) + self.radio2 = wx.RadioButton( self, -1, " Latitude/Longitude (geographical) " ) + self.radio3 = wx.RadioButton( self, -1, " Universal Transverse Mercator (UTM) " ) + self.radio4 = wx.RadioButton( self, -1, " Other coordinate system " ) + self.radio5 = wx.RadioButton( self, -1, " Based on EPSG code " ) self.radio6 = wx.RadioButton( self, -1, " Based on Georeferenced file " ) # layout @@ -1129,7 +1137,7 @@ self.parent.bboxpage.cstate.Enable(False) else: self.parent.bboxpage.cstate.Enable(True) - + class UTMPage(TitledPage): def __init__(self, wizard, parent): TitledPage.__init__(self, wizard, "Choose zone for UTM coordinate system") @@ -1152,7 +1160,7 @@ TitledPage.__init__(self, wizard, "Define GRASS database and new Location Name") # buttons - self.bbrowse = self.MakeButton("Browse ...", size=wx.DefaultSize) + self.bbrowse = self.MakeButton("Browse...") # text controls self.tgisdbase = self.MakeTextCtrl(grassdatabase, size=(300, -1)) @@ -1199,7 +1207,7 @@ def onPageChanging(self,event=None): if os.path.isdir(os.path.join(self.tgisdbase.GetValue(),self.tlocation.GetValue())): dlg = wx.MessageDialog(self, "Could not create new location: <%s> directory exists "\ - % str(self.tlocation.GetValue()),"Can not create location", wx.OK|wx.ICON_INFORMATION) + % str(self.tlocation.GetValue()),"Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() event.Veto() @@ -1207,7 +1215,7 @@ if not self.tlocation.GetValue(): dlg = wx.MessageDialog(self, "Could not create new location: not set "\ - ,"Can not create location", wx.OK|wx.ICON_INFORMATION) + ,"Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() event.Veto() @@ -1226,18 +1234,20 @@ wizbmp = wx.Image(os.path.join(os.getenv("GISBASE"),"etc","wx","images","wizard.png"), wx.BITMAP_TYPE_PNG) wizbmp.Rescale(250,600) wizbmp = wizbmp.ConvertToBitmap() - wizard = wiz.Wizard(parent, -1, "Define new Location", + self.wizard = wiz.Wizard(parent, -1, "Define new Location", bitmap=wizbmp) - self.startpage = DatabasePage(wizard, self, grassdatabase) - self.csystemspage = CoordinateSystemPage(wizard, self) - self.epsgpage = EPSGPage(wizard, self) - self.bboxpage = BBoxPage(wizard, self) - self.filepage = GeoreferencedFilePage(wizard, self) - self.projpage = ProjectionsPage(wizard, self) - self.sumpage = SummaryPage(wizard, self) - self.datumpage = DatumPage(wizard, self) - self.utmpage = UTMPage(wizard,self) + self.startpage = DatabasePage(self.wizard, self, grassdatabase) + self.csystemspage = CoordinateSystemPage(self.wizard, self) + self.epsgpage = EPSGPage(self.wizard, self) + self.bboxpage = BBoxPage(self.wizard, self) + self.filepage = GeoreferencedFilePage(self.wizard, self) + self.projpage = ProjectionsPage(self.wizard, self) + self.sumpage = SummaryPage(self.wizard, self) + self.datumpage = DatumPage(self.wizard, self) + self.utmpage = UTMPage(self.wizard,self) + global coordsys + # Set the initial order of the pages # it should follow the epsg line self.startpage.SetNext(self.csystemspage) @@ -1246,17 +1256,25 @@ self.csystemspage.SetNext(self.bboxpage) self.epsgpage.SetPrev(self.csystemspage) - self.epsgpage.SetNext(self.datumpage) + self.epsgpage.SetNext(self.bboxpage) self.projpage.SetPrev(self.csystemspage) self.projpage.SetNext(self.datumpage) self.filepage.SetPrev(self.csystemspage) - self.filepage.SetNext(self.sumpage) + self.filepage.SetNext(self.bboxpage) self.datumpage.SetNext(self.bboxpage) - self.bboxpage.SetPrev(self.csystemspage) + if coordsys == "epsg": + self.bboxpage.SetPrev(self.epsgpage) + elif coordsys == "file": + self.bboxpage.SetPrev(self.filepage) + elif coordsys == "xy": + self.bboxpage.SetPrev(self.startpage) + else: + self.bboxpage.SetPrev(self.csystemspage) + self.bboxpage.SetNext(self.sumpage) self.sumpage.SetPrev(self.bboxpage) @@ -1264,24 +1282,25 @@ self.utmpage.SetPrev(self.csystemspage) self.utmpage.SetNext(self.datumpage) - wizard.FitToPage(self.bboxpage) - if wizard.RunWizard(self.startpage): + self.wizard.FitToPage(self.bboxpage) + if self.wizard.RunWizard(self.startpage): self.onWizFinished() wx.MessageBox("New location created.") else: wx.MessageBox("Location wizard canceled. New location not created.") - wizard.Destroy() + self.wizard.Destroy() def onWizFinished(self): database = self.startpage.tgisdbase.GetValue() location = self.startpage.tlocation.GetValue() global coordsys - wx.MessageBox("finished database: %s, location: %s, coordsys: %s" % (database, location, coordsys)) +# wx.MessageBox("finished database: %s, location: %s, coordsys: %s" % (database, location, coordsys)) if os.path.isdir(os.path.join(database,location)): dlg = wx.MessageDialog(self, "Could not create new location: %s already exists" - % os.path.join(self.parent.gisdbase,location),"Can not create location", wx.OK|wx.ICON_INFORMATION) + % os.path.join(self.parent.gisdbase,location),"Could not create location", + wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return @@ -1298,9 +1317,9 @@ elif coordsys == "custom": self.customCreate elif coordsys == "epsg": - self.epsgCreate - elif "file": - self.fileCreate + self.EPSGCreate() + elif coordsys == "file": + self.FileCreate def xyCreate(self): """ @@ -1326,19 +1345,20 @@ """ pass - def epsgCreate(self): + def EPSGCreate(self): """ Create a new location from an EPSG code. """ global epsgcode - global database - global location + database = self.startpage.tgisdbase.GetValue() + location = self.startpage.tlocation.GetValue() + cmdlist = [] wx.MessageBox("Database: %s, Location: %s, EPSG code: %s" % (database, location, epsgcode)) if not epsgcode: - dlg = wx.MessageDialog(self, "Could not create new location: EPSG Code value missing", - "Can not create location", wx.OK|wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self.wizard, "Could not create new location: EPSG Code value missing", + "Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return @@ -1347,11 +1367,13 @@ # all credit to Michael Barton and his file_option.tcl and # Markus Neteler try: - dtoptions = os.popen3(" g.proj epsg=%s datumtrans=-1" % (epsgcode))[1].read() + cmdlist = ['g.proj','epsg=%s' % epsgcode,'datumtrans=-1'] + p = cmd.Command(cmdlist) + dtoptions = p.module_stdout.read() if dtoptions != None: # open a dialog to select datum transform number dtoptions = 'Select the number of a datum transformation to use: \n'+dtoptions - dlg = wx.TextEntryDialog(self, dtoptions) + dlg = wx.TextEntryDialog(self.wizard, dtoptions) dlg.SetValue('1') if dlg.ShowModal() == wx.ID_OK: @@ -1359,13 +1381,15 @@ dlg.Destroy() - cmd = os.system("g.proj -c epsg=%s location=%s datumtrans=%s" % (epsgcode, location, dtrans)) + cmdlist = ['g.proj','-c','epsg=%s' % epsgcode,'location=%s' % location,'datumtrans=%s' % dtrans] else: - os.system("g.proj -c epsg=%s location=%s datumtrans=1" % (epsgcode, location)) + cmdlist = ['g.proj','-c','epsg=%s' % epsgcode,'location=%s' % location,'datumtrans=1'] + cmd.Command(cmdlist) + except StandardError, e: - dlg = wx.MessageDialog(self, "Could not create new location: %s " - % str(e),"Can not create location", wx.OK|wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), + "Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() @@ -1377,15 +1401,15 @@ global database global location if not os.path.isfile(georeffile): - dlg = wx.MessageDialog(self, "Could not create new location: %s not file" - % georeffile,"Can not create location", wx.OK|wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s; Could not find file" % georeffile, + "Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return if not sgeoreffile: - dlg = wx.MessageDialog(self, "Could not create new location: name not set", - "Can not create location", wx.OK|wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self.wizard, "Could not create new location: name not set", + "Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return @@ -1398,8 +1422,8 @@ os.system("g.proj -c georef=%s location=%s >&2" % (georeffile, location)) except StandardError, e: - dlg = wx.MessageDialog(self, "Could not create new location: %s " - % str(e),"Can not create location", wx.OK|wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), + "Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() From barton at grass.itc.it Fri Jun 29 04:25:01 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 29 04:25:03 2007 Subject: [grass-addons] r877 - trunk/grassaddons/gui/gui_modules Message-ID: <200706290225.l5T2P1r2012269@grass.itc.it> Author: barton Date: 2007-06-29 04:24:51 +0200 (Fri, 29 Jun 2007) New Revision: 877 Modified: trunk/grassaddons/gui/gui_modules/rules.py Log: Add newline to rules for r.recode Modified: trunk/grassaddons/gui/gui_modules/rules.py =================================================================== --- trunk/grassaddons/gui/gui_modules/rules.py 2007-06-28 07:06:07 UTC (rev 876) +++ trunk/grassaddons/gui/gui_modules/rules.py 2007-06-29 02:24:51 UTC (rev 877) @@ -157,7 +157,9 @@ self.outmap = event.GetString() def OnRules(self, event): - self.rules = event.GetString() + self.rules = event.GetString().strip() + if self.cmd == 'r.recode': + self.rules = self.rules+'\n' def OnHelp(self, event): os.popen('g.manual --quiet %s ' % self.cmd) From barton at grass.itc.it Fri Jun 29 08:55:24 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 29 08:55:27 2007 Subject: [grass-addons] r878 - trunk/grassaddons/gui Message-ID: <200706290655.l5T6tOo7015570@grass.itc.it> Author: barton Date: 2007-06-29 08:55:13 +0200 (Fri, 29 Jun 2007) New Revision: 878 Modified: trunk/grassaddons/gui/gis_set.py trunk/grassaddons/gui/location_wizard.py Log: Location wizard functional for EPSG and georeferenced files for location setting. Updated gis_set.py to remove buttons for individual EPSG and file options now that wizard is working. Some code cleanup in both modules. Modified: trunk/grassaddons/gui/gis_set.py =================================================================== --- trunk/grassaddons/gui/gis_set.py 2007-06-29 02:24:51 UTC (rev 877) +++ trunk/grassaddons/gui/gis_set.py 2007-06-29 06:55:13 UTC (rev 878) @@ -425,7 +425,7 @@ self.llocation = wx.StaticText(self, -1, "Project Location\n(projection/coordinate system)", style=wx.ALIGN_CENTRE) self.lmapset = wx.StaticText(self, -1, "Accessible Mapsets\n(directories of GIS files)", style=wx.ALIGN_CENTRE) self.lcreate = wx.StaticText(self, -1, "Create new mapset\nin selected location", style=wx.ALIGN_CENTRE) - self.ldefine = wx.StaticText(self, -1, "Define new location with ...", style=wx.ALIGN_CENTRE) + self.ldefine = wx.StaticText(self, -1, "Define new location...", style=wx.ALIGN_CENTRE) # buttons buttonsize1 = (150,-1) @@ -437,9 +437,9 @@ self.bhelp = wx.Button(self, -1, "Help", size=buttonsize2) self.bbrowse = wx.Button(self, -1, "Browse ...", size=(-1,-1)) self.bmapset = wx.Button(self, -1, "Create new mapset", size=buttonsize1) - self.bgeoreferenced = wx.Button(self, -1, "Georeferenced file", size=buttonsize1) - self.bepsg = wx.Button(self, -1, "EPSG codes", size=buttonsize1) - self.bwizard = wx.Button(self, -1, "Run Wizard", size=buttonsize1) +# self.bgeoreferenced = wx.Button(self, -1, "Georeferenced file", size=buttonsize1) +# self.bepsg = wx.Button(self, -1, "EPSG codes", size=buttonsize1) + self.bwizard = wx.Button(self, -1, "Location wizard", size=buttonsize1) # textinputs @@ -464,18 +464,25 @@ self.__do_layout() # events - wx.EVT_BUTTON(self, self.bbrowse.GetId(), self.OnBrowse) - wx.EVT_BUTTON(self, self.bstart.GetId(), self.OnStart) - wx.EVT_BUTTON(self, self.bexit.GetId(), self.OnExit) - wx.EVT_BUTTON(self, self.bhelp.GetId(), self.OnHelp) - wx.EVT_BUTTON(self, self.bmapset.GetId(), self.OnCreateMapset) - wx.EVT_BUTTON(self, self.bgeoreferenced.GetId(), self.OnGeoreferenced) - wx.EVT_BUTTON(self, self.bepsg.GetId(), self.OnEpsg) - wx.EVT_BUTTON(self, self.bwizard.GetId(), self.OnWizard) +# wx.EVT_BUTTON(self, self.bbrowse.GetId(), self.OnBrowse) + self.bbrowse.Bind(wx.EVT_BUTTON, self.OnBrowse) +# wx.EVT_BUTTON(self, self.bstart.GetId(), self.OnStart) + self.bstart.Bind(wx.EVT_BUTTON, self.OnStart) +# wx.EVT_BUTTON(self, self.bexit.GetId(), self.OnExit) + self.bexit.Bind(wx.EVT_BUTTON, self.OnExit) +# wx.EVT_BUTTON(self, self.bhelp.GetId(), self.OnHelp) + self.bhelp.Bind(wx.EVT_BUTTON, self.OnHelp) +# wx.EVT_BUTTON(self, self.bmapset.GetId(), self.OnCreateMapset) + self.bmapset.Bind(wx.EVT_BUTTON, self.OnCreateMapset) +# wx.EVT_BUTTON(self, self.bgeoreferenced.GetId(), self.OnGeoreferenced) +# wx.EVT_BUTTON(self, self.bepsg.GetId(), self.OnEpsg) + self.bwizard.Bind(wx.EVT_BUTTON, self.OnWizard) self.lblocations.Bind(wx.EVT_LISTBOX, self.OnSelectLocation) self.lbmapsets.Bind(wx.EVT_LISTBOX, self.OnSelectMapset) - wx.EVT_KEY_DOWN(self.tgisdbase, self.OnKeyPressedInDbase) - wx.EVT_KEY_DOWN(self.tnewmapset, self.OnKeyPressedInMapset) +# wx.EVT_KEY_DOWN(self.tgisdbase, self.OnKeyPressedInDbase) + self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressedInDbase, self.tgisdbase) +# wx.EVT_KEY_DOWN(self.tnewmapset, self.OnKeyPressedInMapset) + self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressedInMapset, self.tnewmapset) self.Bind(wx.EVT_CLOSE, self.onCloseWindow) def __set_properties(self): @@ -531,8 +538,8 @@ mapset_sizer.Add(self.tnewmapset, 0, label_style|wx.BOTTOM, 5) mapset_sizer.Add(self.bmapset, 0, label_style|wx.BOTTOM, 10) mapset_sizer.Add(self.ldefine, 0, label_style|wx.RIGHT|wx.LEFT, 5) - mapset_sizer.Add(self.bgeoreferenced, 0, label_style|wx.TOP, 5) - mapset_sizer.Add(self.bepsg, 0, label_style|wx.TOP, 5) +# mapset_sizer.Add(self.bgeoreferenced, 0, label_style|wx.TOP, 5) +# mapset_sizer.Add(self.bepsg, 0, label_style|wx.TOP, 5) mapset_sizer.Add(self.bwizard, 0, label_style|wx.TOP, 5) mapset_sizer.Add((5,0)) @@ -717,7 +724,7 @@ self.Destroy() def OnHelp(self, event): - print "Event handler `OnHelp' not implemented!" + wx.MessageBox("Help not yet implemented") event.Skip() def onCloseWindow(self, event): Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-06-29 02:24:51 UTC (rev 877) +++ trunk/grassaddons/gui/location_wizard.py 2007-06-29 06:55:13 UTC (rev 878) @@ -876,8 +876,8 @@ # create controls self.lfile= wx.StaticText(self, -1, "Georeferenced file: ", style=wx.ALIGN_RIGHT) - self.tfile = wx.TextCtrl(self,-1, "", size=(150,-1)) - self.bbrowse = self.MakeButton("Browse...") + self.tfile = wx.TextCtrl(self,-1, "", size=(300,-1)) + self.bbrowse = wx.Button(self, -1, "Browse...") # do layout self.sizer.Add(self.lfile, 0, wx.ALIGN_RIGHT | @@ -889,12 +889,12 @@ self.sizer.Add(self.bbrowse, 0, wx.ALIGN_LEFT | wx.ALL, 5, row=1, col=4) - wx.EVT_BUTTON(self, self.bbrowse.GetId(), self.OnBrowse) - self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.onPageChange) + self.bbrowse.Bind(wx.EVT_BUTTON, self.OnBrowse) + self.Bind(wx.EVT_TEXT, self.OnText, self.tfile) - def onPageChange(self, event): + def OnText(self, event): global georeffile - georeffile = self.tfile + georeffile = event.GetString() def OnBrowse(self, event): @@ -910,7 +910,6 @@ class EPSGPage(TitledPage): def __init__(self, wizard, parent): TitledPage.__init__(self, wizard, "Choose EPSG Code") - #wx.MessageBox("in epsgpage") self.parent = parent # labels @@ -988,7 +987,6 @@ global epsgcode epsgcode = self.tcode.GetValue() self.parent.bboxpage.SetPrev(self) - #wx.MessageBox("setting epsgcode to %s" % (epsgcode)) def OnDoSearch(self,event): str = self.searchb.GetValue() @@ -1144,7 +1142,7 @@ self.parent = parent self.text_utm = self.MakeTextCtrl(size=(300,-1)) - self.label_utm= self.MakeLabel("Set your UTM zone: ") + self.label_utm = self.MakeLabel("Set UTM zone: ") self.sizer.Add(self.label_utm, 0, wx.ALIGN_LEFT, 5, row=1,col=1) self.sizer.Add(self.text_utm, 0, wx.ALIGN_LEFT, 5, row=1,col=2) @@ -1214,7 +1212,7 @@ return if not self.tlocation.GetValue(): - dlg = wx.MessageDialog(self, "Could not create new location: not set "\ + dlg = wx.MessageDialog(self, "Could not create new location: location not set "\ ,"Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() @@ -1283,9 +1281,15 @@ self.utmpage.SetNext(self.datumpage) self.wizard.FitToPage(self.bboxpage) + + success = False + if self.wizard.RunWizard(self.startpage): - self.onWizFinished() - wx.MessageBox("New location created.") + success = self.onWizFinished() + if success == True: + wx.MessageBox("New location created.") + else: + wx.MessageBox("Unable to create new location.") else: wx.MessageBox("Location wizard canceled. New location not created.") @@ -1295,6 +1299,7 @@ database = self.startpage.tgisdbase.GetValue() location = self.startpage.tlocation.GetValue() global coordsys + success = '' # wx.MessageBox("finished database: %s, location: %s, coordsys: %s" % (database, location, coordsys)) if os.path.isdir(os.path.join(database,location)): @@ -1303,43 +1308,45 @@ wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() - return + return False if coordsys == "xy": - self.xyCreate + success = self.XYCreate() elif coordsys == "latlong": rows = int(round((float(north)-float(south))/float(resolution))) cols = int(round((float(east)-float(west))/float(resolution))) cells = int(rows*cols) - self.latlongCreate + success = self.LatlongCreate() elif coordsys == "utm": - self.utmCreate + success = self.UTMCreate() elif coordsys == "custom": - self.customCreate + success = self.CustomCreate() elif coordsys == "epsg": - self.EPSGCreate() + success = self.EPSGCreate() elif coordsys == "file": - self.FileCreate + success = self.FileCreate() - def xyCreate(self): + return success + + def XYCreate(self): """ Create an XY location """ pass - def latlongCreate(self): + def LatlongCreate(self): """ Create a new Lat/Long location """ pass - def utmCreate(self): + def UTMCreate(self): """ Create a new UTM location """ pass - def customCreate(self): + def CustomCreate(self): """ Create a new custom-defined location """ @@ -1350,19 +1357,25 @@ Create a new location from an EPSG code. """ global epsgcode - database = self.startpage.tgisdbase.GetValue() location = self.startpage.tlocation.GetValue() cmdlist = [] - wx.MessageBox("Database: %s, Location: %s, EPSG code: %s" % (database, location, epsgcode)) - if not epsgcode: dlg = wx.MessageDialog(self.wizard, "Could not create new location: EPSG Code value missing", "Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() - return + return False + dlg = wx.MessageDialog(self.wizard, "New location '%s' will be created georeferenced to EPSG code %s"\ + % (location, epsgcode), "Create new location from EPSG code?", + wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION) + if dlg.ShowModal() == wx.ID_NO: + dlg.Destroy() + return False + else: + dlg.Destroy() + # creating location # all credit to Michael Barton and his file_option.tcl and # Markus Neteler @@ -1371,61 +1384,86 @@ p = cmd.Command(cmdlist) dtoptions = p.module_stdout.read() if dtoptions != None: + dtrans = '' # open a dialog to select datum transform number - dtoptions = 'Select the number of a datum transformation to use: \n'+dtoptions - dlg = wx.TextEntryDialog(self.wizard, dtoptions) - dlg.SetValue('1') + dlg = wx.TextEntryDialog(self.wizard, dtoptions, + caption='Select the number of a datum transformation to use', + defaultValue='1', + style=wx.TE_WORDWRAP|wx.MINIMIZE_BOX|wx.MAXIMIZE_BOX| + wx.RESIZE_BORDER|wx.VSCROLL| + wx.OK|wx.CANCEL) - if dlg.ShowModal() == wx.ID_OK: + if dlg.ShowModal() == wx.ID_CANCEL: + dlg.Destroy() + return False + else: dtrans = dlg.GetValue() + if dtrans != '': + dlg.Destroy() + else: + wx.MessageBox('You must select a datum transform') + return False - dlg.Destroy() - cmdlist = ['g.proj','-c','epsg=%s' % epsgcode,'location=%s' % location,'datumtrans=%s' % dtrans] else: cmdlist = ['g.proj','-c','epsg=%s' % epsgcode,'location=%s' % location,'datumtrans=1'] cmd.Command(cmdlist) + return True except StandardError, e: dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), "Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() + return False def FileCreate(self): """ Create a new location from a georeferenced file """ global georeffile - global database - global location + location = self.startpage.tlocation.GetValue() + + cmdlist = [] + + dlg = wx.MessageDialog(self.wizard, "New location '%s' will be created georeferenced to file '%s'"\ + % (location, georeffile), "Create new location from georeferenced file?", + wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION) + if dlg.ShowModal() == wx.ID_NO: + dlg.Destroy() + return False + else: + dlg.Destroy() + if not os.path.isfile(georeffile): - dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s; Could not find file" % georeffile, + dlg = wx.MessageDialog(self.wizard, "Could not create new location: could not find file %s" % georeffile, "Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() - return + return False - if not sgeoreffile: - dlg = wx.MessageDialog(self.wizard, "Could not create new location: name not set", + if not georeffile: + dlg = wx.MessageDialog(self.wizard, "Could not create new location: georeferenced file not set", "Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() - return + return False # creating location # all credit to Michael Barton and his file_option.tcl and # Markus Neteler try: - # FIXME: this does not need to work on windows - os.system("g.proj -c georef=%s location=%s >&2" % (georeffile, location)) + cmdlist = ['g.proj','-c','georef=%s' % georeffile,'location=%s' % location] + cmd.Command(cmdlist) + return True except StandardError, e: dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), "Could not create location", wx.OK|wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() + return False if __name__ == "__main__": gWizard = GWizard(None, "") From barton at grass.itc.it Fri Jun 29 09:18:05 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Jun 29 09:18:06 2007 Subject: [grass-addons] r879 - trunk/grassaddons/gui Message-ID: <200706290718.l5T7I5bJ015624@grass.itc.it> Author: barton Date: 2007-06-29 09:17:56 +0200 (Fri, 29 Jun 2007) New Revision: 879 Modified: trunk/grassaddons/gui/location_wizard.py Log: Working toward custom coordinate system/projection setting. Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-06-29 06:55:13 UTC (rev 878) +++ trunk/grassaddons/gui/location_wizard.py 2007-06-29 07:17:56 UTC (rev 879) @@ -867,7 +867,7 @@ def onPageChange(self,event): global projection - projection = self.tproj + projection = self.tproj.GetValue() class GeoreferencedFilePage(TitledPage): def __init__(self, wizard, parent): @@ -1332,26 +1332,42 @@ """ Create an XY location """ - pass + wx.MessageBox('Not implemented: Create xy location') def LatlongCreate(self): """ Create a new Lat/Long location """ - pass + projection = self.projpage.tproj.GetValue() + datum = self.datumpage.tdatum.GetValue() + transform = self.datumpage.ttrans.GetValue() + wx.MessageBox('Not implemented: Create input for g.proj from \n%s \n%s \n%s' % + (projection, datum, transform)) + def UTMCreate(self): """ Create a new UTM location """ - pass + projection = self.projpage.tproj.GetValue() + datum = self.datumpage.tdatum.GetValue() + transform = self.datumpage.ttrans.GetValue() + + wx.MessageBox('Not implemented: Create input for g.proj from \n%s \n%s \n%s' % + (projection, datum, transform)) + def CustomCreate(self): """ Create a new custom-defined location """ - pass + projection = self.projpage.tproj.GetValue() + datum = self.datumpage.tdatum.GetValue() + transform = self.datumpage.ttrans.GetValue() + wx.MessageBox('Not implemented: Create input for g.proj from \n%s \n%s \n%s' % + (projection, datum, transform)) + def EPSGCreate(self): """ Create a new location from an EPSG code. From neteler at grass.itc.it Fri Jun 29 10:47:33 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Fri Jun 29 10:47:34 2007 Subject: [grass-addons] r880 - trunk/grassaddons Message-ID: <200706290847.l5T8lX15016071@grass.itc.it> Author: neteler Date: 2007-06-29 10:47:33 +0200 (Fri, 29 Jun 2007) New Revision: 880 Modified: trunk/grassaddons/contributors.csv Log: +Isaac Ullah Modified: trunk/grassaddons/contributors.csv =================================================================== --- trunk/grassaddons/contributors.csv 2007-06-29 07:17:56 UTC (rev 879) +++ trunk/grassaddons/contributors.csv 2007-06-29 08:47:33 UTC (rev 880) @@ -10,3 +10,4 @@ landa,Martin Landa maldacker,Maximilian Maldacker neteler,Markus Neteler +ullah,Isaac Ullah From landa at grass.itc.it Fri Jun 29 16:50:02 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Fri Jun 29 16:50:04 2007 Subject: [grass-addons] r881 - in trunk/grassaddons/gui: gui_modules icons Message-ID: <200706291450.l5TEo2jO022246@grass.itc.it> Author: landa Date: 2007-06-29 16:50:01 +0200 (Fri, 29 Jun 2007) New Revision: 881 Modified: trunk/grassaddons/gui/gui_modules/cmd.py trunk/grassaddons/gui/gui_modules/dbm.py trunk/grassaddons/gui/gui_modules/digit.py trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/toolbars.py trunk/grassaddons/gui/gui_modules/wxgui_utils.py trunk/grassaddons/gui/icons/icon.py Log: Digitization tool: * DisplayAttributesDialog * Various minor fixes Modified: trunk/grassaddons/gui/gui_modules/cmd.py =================================================================== --- trunk/grassaddons/gui/gui_modules/cmd.py 2007-06-29 08:47:33 UTC (rev 880) +++ trunk/grassaddons/gui/gui_modules/cmd.py 2007-06-29 14:50:01 UTC (rev 881) @@ -170,7 +170,7 @@ line = self.module_stdout.readline() if not line: break - line.replace('\n', '') + line = line.replace('\n', '') lineList.append(line) return lineList Modified: trunk/grassaddons/gui/gui_modules/dbm.py =================================================================== --- trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-29 08:47:33 UTC (rev 880) +++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-06-29 14:50:01 UTC (rev 881) @@ -5,7 +5,7 @@ * Log * VirtualAttributeList * AttributeManager - * UpdateRecordDialog + * DisplayAttributesDialog PURPOSE: GRASS attribute table manager @@ -35,6 +35,7 @@ import grassenv import cmd +from debug import Debug as Debug try: import subprocess @@ -103,7 +104,7 @@ "database=%s" % self.parent.database]) for line in dbDescribe.module_stdout.readlines()[1:]: - x,column,type,length = line.strip().split(":") + column, type, length = line.strip().split(":") # FIXME: here will be more types if type.lower().find("integer") > -1: self.columns.append({"name":column,"type":int}) @@ -231,7 +232,7 @@ if self.lastTurnSelectedCats[:] != self.selectedCats[:]: if self.qlayer: self.map.DeleteLayer(self.qlayer) - + cats = self.selectedCats catstr = "" i = 0 @@ -593,126 +594,314 @@ pagesizer.Fit(self) self.Layout() -class UpdateRecordDialog(wx.Dialog): +class DisplayAttributesDialog(wx.Dialog): """ - Standard dialog used for adding new record into the attribute table + Standard dialog used for adding new/updating existing or + displaying (read-only mode) attributes of vector map layers. + + Attribute data can be selected based on layer and category number + or coordinates. If layer=-1 all layer are queried. """ - def __init__(self, parent, map, layer=1, cat=1, title=_("Add new record into table"), - style=wx.DEFAULT_DIALOG_STYLE, pos=wx.DefaultPosition): - wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style, pos=pos) + def __init__(self, parent, map, + layer=1, cat=1, queryCoords=None, qdist=1, + style=wx.DEFAULT_DIALOG_STYLE, pos=wx.DefaultPosition, + action="add"): - # determine column names and types - columnsCommand = cmd.Command (cmd=["v.db.connect", "-c", - "map=%s" % map, "layer=%d" % layer, "--q"]) + self.map = map + self.layer = layer + self.cat = cat + self.queryCoords = queryCoords + self.qdist = qdist + self.action = action - self.table = None - self.columns = [] # (name, type, value) - if columnsCommand.returncode == 0: - output = columnsCommand.ReadStdOutput() - for line in output: - columnType, columnName = line.split('|') - self.columns.append ([columnName.replace('\n', ''), columnType]) - else: + self.mapInfo = VectorAttributesInfo(self.map) + + if self.layer > 0 and \ + self.layer not in self.mapInfo.layers.keys(): + dlg = wx.MessageDialog(None, + _("Layer %d is not available in vector map <%s>") % \ + (layer, self.map), + _("Error"), wx.OK | wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() + self.mapInfo = None return + + wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, + title="", style=style, pos=pos) - # select values - selectCommand = cmd.Command(cmd=["v.db.select", "-c", - "map=%s" % map, "layer=%d" % layer, - "where=cat=%d" % cat, "--q"]) - - if selectCommand.returncode == 0: - idx = 0 - try: - valueString = selectCommand.ReadStdOutput()[0] # read first line - for value in valueString.split('|'): - self.columns[idx].append(value.replace('\n', '')) - idx = idx + 1 - except: # default values - for col in self.columns: - col.append("") - if idx > 0: - self.SetTitle(_("Update existing record")) - - print "#", self.columns - # dialog body mainSizer = wx.BoxSizer(wx.VERTICAL) - - border = wx.BoxSizer(wx.VERTICAL) - box = wx.StaticBox (parent=self, id=wx.ID_ANY, label=" %s %d " % (_("Layer"), layer)) - sizer = wx.StaticBoxSizer(box, wx.VERTICAL) - flexSizer = wx.FlexGridSizer (cols=4, hgap=3, vgap=3) - flexSizer.AddGrowableCol(0) - # columns - for colIdx in range(len(self.columns)): - name = self.columns[colIdx][0] - type = self.columns[colIdx][1] - value = self.columns[colIdx][2] - colName = wx.StaticText(parent=self, id=wx.ID_ANY, label=name) - colType = wx.StaticText(parent=self, id=wx.ID_ANY, label="[" + type.lower() + "]") - delimiter = wx.StaticText(parent=self, id=wx.ID_ANY, label=":") - if name.lower() == "cat": - colValue = wx.StaticText(parent=self, id=wx.ID_ANY, label=str(cat)) + # notebook + notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT) + for layer in self.mapInfo.layers.keys(): + if self.layer > 0 and \ + self.layer != layer: + continue + + selected = self.mapInfo.SelectFromTable(layer, self.cat, self.queryCoords, self.qdist) + if (self.action == "add" and selected > 0) or \ + self.action == "update": + self.SetTitle(_("Update attributes")) + elif self.action == "add": + self.SetTitle(_("Add attributes")) else: - colValue = wx.TextCtrl(parent=self, id=wx.ID_ANY, value=value, size=(250, -1)) # TODO: validator + self.SetTitle(_("Display attributes")) + if (self.action == "display" or self.action == "update") and \ + selected == 0: + continue + + panel = wx.Panel(parent=notebook, id=wx.ID_ANY) + notebook.AddPage(page=panel, text=_(" %s %d ") % (_("Layer"), layer)) - # add widget reference to self.columns - self.columns[colIdx].append(colValue) - - flexSizer.Add(colName, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) - flexSizer.Add(colType, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) - flexSizer.Add(delimiter, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) - flexSizer.Add(colValue, proportion=0, flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL) + # notebook body + border = wx.BoxSizer(wx.VERTICAL) + box = wx.StaticBox (parent=panel, id=wx.ID_ANY, + label="") + boxFont = self.GetFont() + boxFont.SetWeight(wx.FONTWEIGHT_BOLD) + box.SetFont(boxFont) + sizer = wx.StaticBoxSizer(box, wx.VERTICAL) + flexSizer = wx.FlexGridSizer (cols=4, hgap=3, vgap=3) + flexSizer.AddGrowableCol(0) - sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) - border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1) - - # sql box - box = wx.StaticBox (parent=self, id=wx.ID_ANY, label=" %s " % _("SQL statement")) - sizer = wx.StaticBoxSizer(box, wx.VERTICAL) - sql = wx.StaticText(parent=self, id=wx.ID_ANY, - label="INSERT into %s (cat) VALUES (%d)" % ("table", cat)) - sizer.Add(item=sql, proportion=0, flag=wx.ALL | wx.EXPAND, border=5) - border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1) + table = self.mapInfo.layers[layer]["table"] + columns = self.mapInfo.tables[table] + # columns + for name in columns.keys(): + type = columns[name][0] + value = columns[name][1] + if name.lower() == "cat": + box.SetLabel(" %s %s " % (_("Category"), value)) + colValue = box + else: + colName = wx.StaticText(parent=panel, id=wx.ID_ANY, label=name) + colType = wx.StaticText(parent=panel, id=wx.ID_ANY, label="[" + type.lower() + "]") + delimiter = wx.StaticText(parent=panel, id=wx.ID_ANY, label=":") + + colValue = wx.TextCtrl(parent=panel, id=wx.ID_ANY, value=value, size=(250, -1)) # TODO: validator + colValue.SetName(name) + self.Bind(wx.EVT_TEXT, self.OnSQLStatement, colValue) + + flexSizer.Add(colName, proportion=0, + flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(colType, proportion=0, + flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(delimiter, proportion=0, + flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(colValue, proportion=0, + flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL) - mainSizer.Add(item=border, proportion=1, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5) + sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) + border.Add(item=sizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) + panel.SetSizer(border) + + # add widget reference to self.columns + columns[name].append(colValue.GetId()) # buttons + btnSizer = wx.StdDialogButtonSizer() btnCancel = wx.Button(self, wx.ID_CANCEL) + btnSizer.AddButton(btnCancel) btnReset = wx.Button(self, wx.ID_APPLY, _("&Reset")) - btnSubmit = wx.Button(self, wx.ID_OK, _("&Submit")) + btnSizer.AddButton(btnReset) + btnSubmit = wx.Button(self, wx.ID_OK, _("Submit")) btnSubmit.SetDefault() - - btnSizer = wx.StdDialogButtonSizer() - btnSizer.AddButton(btnCancel) - btnSizer.AddButton(btnReset) btnSizer.AddButton(btnSubmit) btnSizer.Realize() - mainSizer.Add(item=btnSizer, proportion=0, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) + mainSizer.Add(item=notebook, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) + #mainSizer.Add(item=border, proportion=1, + #flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5) + mainSizer.Add(item=btnSizer, proportion=0, + flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) # bindigs btnReset.Bind(wx.EVT_BUTTON, self.OnReset) - btnSubmit.Bind(wx.EVT_BUTTON, self.OnSubmit) self.SetSizer(mainSizer) mainSizer.Fit(self) + if notebook.GetPageCount() == 0: + self.mapInfo = None + + def __SelectAttributes(self, layer): + """Select attributes""" + + def OnSQLStatement(self, event): + """Update SQL statement""" + pass + + def GetSQLString(self): + """Create SQL statement string based on self.sqlStatement""" + for layer in self.mapInfo.layers.keys(): + table = self.mapInfo.layers[layer]["table"] + columns = self.mapInfo.tables[table] + cat = columns["cat"][1] + # find updated values + updatedColumns = [] + updatedValues = [] + for name in columns.keys(): + if name == "cat": + continue + type, value, id = columns[name] + try: + newvalue = self.FindWindowById(id).GetValue() + except: + newvalue = self.FindWindowById(id).GetLabel() + if newvalue != value: + updatedColumns.append(name) + if type != 'character': + updatedValues.append(newvalue) + else: + updatedValues.append("'" + newvalue + "'") + + if self.action != "add" and len(updatedValues) == 0: + sqlString = "" + Debug.msg(3, "DisplayAttributesDialog.GetSQLString(): %s" % sqlString) + return sqlString + + if self.action == "add": + sqlString = "INSERT INTO %s (cat," % table + else: + sqlString = "UPDATE %s SET " % table + + for idx in range(len(updatedColumns)): + name = updatedColumns[idx] + if self.action == "add": + sqlString += name + "," + else: + sqlString += name + "=" + updatedValues[idx] + "," + + sqlString = sqlString[:-1] # remove last comma + + if self.action == "add": + sqlString += ") VALUES (%s," % cat + for value in updatedValues: + sqlString += str(value) + "," + sqlString = sqlString[:-1] # remove last comma + sqlString += ")" + else: + sqlString += " WHERE cat=%s" % cat + + Debug.msg(3, "DisplayAttributesDialog.GetSQLString(): %s" % sqlString) + return sqlString + def OnReset(self, event): """Reset form""" - for colIdx in range(len(self.columns)): - name = self.columns[colIdx][0] - value = self.columns[colIdx][2] - win = self.columns[colIdx][3] + for layer in self.mapInfo.layers.keys(): + table = self.mapInfo.layers[layer]["table"] + columns = self.mapInfo.tables[table] + for name in columns.keys(): + type, value, id = columns[name] if name.lower() != "cat": - win.SetValue(value) + self.FindWindowById(id).SetValue(value) def OnSubmit(self, event): """Submit record""" + self.Close() + +class VectorAttributesInfo: + """Class providing information about attributes + linked to the vector map""" + def __init__(self, map): + self.map = map + # {layer number : {table, database, driver}) + self.layers = {} + # {table : [(column name, type, value)]} + self.tables = {} + if not self.__CheckDBConnection(): # -> self.layers + return + + self.__DescribeTables() # -> self.tables + def __CheckDBConnection(self): + """Check DB connection""" + layerCommand = cmd.Command(cmd=["v.db.connect", + "-g", "--q", + "map=%s" % self.map]) + if layerCommand.returncode != 0: + return False + + # list of available layers & (table, database, driver) + for line in layerCommand.ReadStdOutput(): + lineList = line.split(' ') + self.layers[int(lineList[0])] = { "table" : lineList[1], + "database" : lineList[3], + "driver" : lineList[4] } + + if (len(self.layers.keys()) == 0): + return False + + return True + + def __DescribeTables(self): + """Describe linked tables""" + for layer in self.layers.keys(): + # determine column names and types + columnsCommand = cmd.Command (cmd=["v.db.connect", "-c", "--q", + "map=%s" % self.map, + "layer=%d" % layer]) + table = self.layers[layer]["table"] + + columns = {} # {name: [type, value]} + + if columnsCommand.returncode == 0: + for line in columnsCommand.ReadStdOutput(): + columnType, columnName = line.split('|') + columnType = columnType.lower().strip() + columns[columnName] = [columnType, ""] # default value ("") + else: + pass + + self.tables[table] = columns + + def SelectFromTable(self, layer=1, cat=1, queryCoords=None, qdist=1): + """Select records from the table + + Based on coordinates or category + """ + table = self.layers[layer]["table"] + selected = 0 + if queryCoords: + # snapping distance + cmdWhat = cmd.Command(cmd=['v.what', + '-a', '--q', + 'map=%s' % self.map, + 'east_north=%f,%f' % \ + (float(queryCoords[0]), float(queryCoords[1])), + 'distance=%f' % qdist]) + + if cmdWhat.returncode == 0: + read = False + for item in cmdWhat.ReadStdOutput(): + if read: + name, value = item.split(':') + name = name.strip() + self.tables[table][name][1] = value.strip() + selected+=1; + if "category" in item.lower(): + self.tables[table]["cat"][1] = item.split(':')[1].strip() + elif "key column" in item.lower(): + read = True + else: + # select values + selectCommand = cmd.Command(cmd=["v.db.select", "-v", "--q", + "map=%s" % self.map, + "layer=%d" % layer, + "where=cat=%d" % cat]) + self.tables[table]["cat"][1] = str(cat) + if selectCommand.returncode == 0: + for line in selectCommand.ReadStdOutput(): + name, value = line.split('|') + self.tables[table][name][1] = value + selected+=1 + + return selected + def main(argv=None): if argv is None: argv = sys.argv Modified: trunk/grassaddons/gui/gui_modules/digit.py =================================================================== --- trunk/grassaddons/gui/gui_modules/digit.py 2007-06-29 08:47:33 UTC (rev 880) +++ trunk/grassaddons/gui/gui_modules/digit.py 2007-06-29 14:50:01 UTC (rev 881) @@ -70,30 +70,37 @@ Returns 'True' on success, 'False' on failure """ - categoryCmd = cmd.Command(cmd=["v.category", "-g", "--q", - "input=%s" % self.map, - "option=report", - "layer=%d" % self.settings["layer"]]) + if self.map: + categoryCmd = cmd.Command(cmd=["v.category", "-g", "--q", + "input=%s" % self.map, + "option=report", + "layer=%d" % self.settings["layer"]]) - if categoryCmd.returncode != 0: - return + if categoryCmd.returncode != 0: + return - for line in categoryCmd.ReadStdOutput(): - if "all" in line: - try: - maxCat = int(line.split(' ')[-1]) + 1 - self.settings['category'] = maxCat - except: - return False - return True + for line in categoryCmd.ReadStdOutput(): + if "all" in line: + try: + maxCat = int(line.split(' ')[-1]) + 1 + self.settings['category'] = maxCat + except: + return False + return True + else: + self.settings["category"] = 1 def SetCategory(self): """Return category number to use (according Settings)""" - - if self.map and self.settings["categoryMode"] == "Next to use": + if self.settings["categoryMode"] == "No category": + self.settings["category"] = "None" + elif self.settings["categoryMode"] == "Next to use": self.SetCategoryNextToUse() + else: + if self.settings["category"] == "None": + self.SetCategoryNextToUse() - return Digit.settings["category"] + return self.settings["category"] def ReInitialize(self, map): """Re-initialize settings according selected map layer""" @@ -136,6 +143,9 @@ if len(coords) < 2: return + layer = self.settings["layer"] + cat = self.SetCategory() + if type == "boundary": key = "B" else: @@ -146,7 +156,7 @@ addstring += """%f %f\n""" % \ (float(point[0]), float(point [1])) - addstring += "1 1" + addstring += "%d %d" % (layer, cat) Debug.msg (3, "VEdit.AddPoint(): map=%s, type=%s" % \ (map, type)) @@ -204,7 +214,8 @@ mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(item=notebook, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) - mainSizer.Add(item=btnSizer, proportion=0, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) + mainSizer.Add(item=btnSizer, proportion=0, + flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) self.SetSizer(mainSizer) mainSizer.Fit(self) @@ -223,7 +234,8 @@ self.symbology = {} for label, key in self.__SymbologyData(): textLabel = wx.StaticText(panel, wx.ID_ANY, label) - color = csel.ColourSelect(panel, id=wx.ID_ANY, colour=Digit.settings[key][1], size=(25, 25)) + color = csel.ColourSelect(panel, id=wx.ID_ANY, + colour=Digit.settings[key][1], size=(25, 25)) isEnabled = Digit.settings[key][0] if isEnabled is not None: enabled = wx.CheckBox(panel, id=wx.ID_ANY, label="") @@ -271,7 +283,8 @@ # line width text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Line width")) self.lineWidthValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(50, -1), - value=str(Digit.settings["lineWidth"][0]), min=1, max=1e6) + value=str(Digit.settings["lineWidth"][0]), + min=1, max=1e6) self.lineWidthUnit = wx.ComboBox(parent=panel, id=wx.ID_ANY, size=(125, -1), choices=["screen pixels", "map units"]) self.lineWidthUnit.SetValue(Digit.settings["lineWidth"][1]) @@ -288,7 +301,8 @@ box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Digitize new feature")) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) # checkbox - self.addRecord = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_("Add new record into table")) + self.addRecord = wx.CheckBox(parent=panel, id=wx.ID_ANY, + label=_("Add new record into table")) self.addRecord.SetValue(Digit.settings["addRecord"]) sizer.Add(item=self.addRecord, proportion=0, flag=wx.ALL | wx.EXPAND, border=1) # settings @@ -300,7 +314,8 @@ self.layer = wx.TextCtrl(parent=panel, id=wx.ID_ANY, size=(125, -1), value=str(Digit.settings["layer"])) # TODO: validator flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) - flexSizer.Add(item=self.layer, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(item=self.layer, proportion=0, + flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) # category number text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Category number")) self.category = wx.TextCtrl(parent=panel, id=wx.ID_ANY, size=(125, -1), @@ -309,17 +324,21 @@ self.category.SetEditable(False) self.category.Enable(False) flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) - flexSizer.Add(item=self.category, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(item=self.category, proportion=0, + flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) # category mode text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Category mode")) - self.categoryMode = wx.ComboBox(parent=panel, id=wx.ID_ANY, style=wx.CB_SIMPLE | wx.CB_READONLY, size=(125, -1), + self.categoryMode = wx.ComboBox(parent=panel, id=wx.ID_ANY, + style=wx.CB_SIMPLE | wx.CB_READONLY, size=(125, -1), choices=[_("Next to use"), _("Manual entry"), _("No category")]) self.categoryMode.SetValue(Digit.settings["categoryMode"]) flexSizer.Add(item=text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) - flexSizer.Add(item=self.categoryMode, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) + flexSizer.Add(item=self.categoryMode, proportion=0, + flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1) - border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5) + border.Add(item=sizer, proportion=0, + flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5) # bindings self.Bind(wx.EVT_CHECKBOX, self.OnChangeAddRecord, self.addRecord) @@ -354,6 +373,7 @@ """Change category mode""" mode = event.GetString() + Digit.settings["categoryMode"] = mode if mode == "Manual entry": # enable self.category.Enable(True) self.category.SetEditable(True) @@ -361,15 +381,14 @@ self.category.SetEditable(False) self.category.Enable(False) - if mode == "No category": - self.category.SetValue("None") - else: - Digit.SetCategory() - self.category.SetValue(str(Digit.settings['category'])) + if mode == "No category" and self.addRecord.IsChecked(): + self.addRecord.SetValue(False) + Digit.SetCategory() + self.category.SetValue(str(Digit.settings['category'])) def OnChangeAddRecord(self, event): """Checkbox 'Add new record' status changed""" - Digit.settings["addRecord"] = event.IsChecked() + self.category.SetValue(str(Digit.SetCategory())) def OnOK(self, event): """Button 'OK' clicked""" Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-29 08:47:33 UTC (rev 880) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-06-29 14:50:01 UTC (rev 881) @@ -28,9 +28,15 @@ for details. """ +import os +import sys +import time +import glob +import math +import tempfile + import wx import wx.aui -import os, sys, time, glob, math from threading import Thread try: @@ -693,48 +699,79 @@ elif self.mouse["use"] == "pointer" and self.parent.digittoolbar: # digitization digit = self.parent.digittoolbar + self.mouse['begin'] = event.GetPositionTuple()[:] + east, north = self.Pixel2Cell(self.mouse['begin'][0], + self.mouse['begin'][1]) + + try: + map = digit.layers[digit.layerSelectedID].name + except: + map = None + dlg = wx.MessageDialog(self, _("No vector map layer selected for editing"), + _("Error"), wx.OK | wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() + event.Skip() + return + + # calculate position of 'update record' dialog + offset = 5 + posWindow = self.ClientToScreen((self.mouse['begin'][0] + offset, + self.mouse['begin'][1] + offset)) + if digit.action == "add": - try: - map = digit.layers[digit.layerSelectedID].name - except: - map = None - dlg = wx.MessageDialog(self, _("No vector map layer selected for editing"), - _("Error"), wx.OK | wx.ICON_ERROR) - dlg.ShowModal() - dlg.Destroy() - - if map: - if digit.type in ["point", "centroid"]: - # add new point - self.mouse['begin'] = event.GetPositionTuple()[:] - self.DrawCross(self.mouse['begin'], 5) - east, north = self.Pixel2Cell(self.mouse['begin'][0], - self.mouse['begin'][1]) - Digit.AddPoint(map=map, - type=digit.type, - x=east, y=north) + if digit.type in ["point", "centroid"]: + # add new point + self.DrawCross(self.mouse['begin'], 5) + Digit.AddPoint(map=map, + type=digit.type, + x=east, y=north) - # add new record into atribute table - if Digit.settings["addRecord"]: - offset = 5 - posWindow = self.ClientToScreen((self.mouse['begin'][0] + offset, - self.mouse['begin'][1] + offset)) + # add new record into atribute table + if Digit.settings["addRecord"]: + # select attributes based on layer and category + addRecordDlg = dbm.DisplayAttributesDialog(parent=self, map=map, + layer=Digit.settings["layer"], + cat=Digit.settings["category"], + pos=posWindow, + action="add") + if addRecordDlg.mapInfo and \ + addRecordDlg.ShowModal() == wx.ID_OK: + sqlfile = tempfile.NamedTemporaryFile(mode="w") + sqlfile.file.write(addRecordDlg.GetSQLString()) + sqlfile.file.flush() + executeCommand = cmd.Command(cmd=["db.execute", + "--q", + "input=%s" % sqlfile.name]) + self.render=True + self.UpdateMap() # redraw map - if dbm.UpdateRecordDialog(parent=self, map=map, - layer=Digit.settings["layer"], - cat=Digit.settings["category"], - pos=posWindow).ShowModal() == wx.ID_OK: - pass - - self.render=True - self.UpdateMap() # redraw map - - elif digit.type in ["line", "boundary"]: - # add new point to the line - self.polycoords.append(event.GetPositionTuple()[:]) - self.mouse['begin'] = self.polycoords[-1] - self.DrawLines() - + elif digit.type in ["line", "boundary"]: + # add new point to the line + self.polycoords.append(event.GetPositionTuple()[:]) + self.mouse['begin'] = self.polycoords[-1] + self.DrawLines() + elif digit.action == "dispAttr": + qdist = 10.0 * ((self.Map.region['e'] - self.Map.region['w']) / self.Map.width) + # select attributes based on coordinates (all layers) + updateRecordDlg = dbm.DisplayAttributesDialog(parent=self, map=map, + layer=-1, queryCoords=(east, north), qdist=qdist, + pos=posWindow, + action="update") + if not updateRecordDlg.mapInfo and \ + Digit.settings["addRecord"]: + updateRecordDlg = dbm.DisplayAttributesDialog(parent=self, map=map, + layer=-1, queryCoords=(east, north), qdist=qdist, + pos=posWindow, + action="add") + if updateRecordDlg.mapInfo and \ + updateRecordDlg.ShowModal() == wx.ID_OK: + sqlfile = tempfile.NamedTemporaryFile(mode="w") + sqlfile.file.write(updateRecordDlg.GetSQLString()) + sqlfile.file.flush() + executeCommand = cmd.Command(cmd=["db.execute", + "--q", + "input=%s" % sqlfile.name]) else: # get decoration id self.lastpos = self.mouse['begin'] = event.GetPositionTuple()[:] @@ -893,6 +930,27 @@ type=self.parent.digittoolbar.type, coords=mapcoords) + # add new record into atribute table + if Digit.settings["addRecord"]: + offset = 5 + posWindow = self.ClientToScreen((self.polycoords[-1][0] + offset, + self.polycoords[-1][1] + offset)) + + # select attributes based on layer and category + addRecordDlg = dbm.DisplayAttributesDialog(parent=self, map=map, + layer=Digit.settings["layer"], + cat=Digit.settings["category"], + pos=posWindow, + action="add") + if addRecordDlg.mapInfo and \ + addRecordDlg.ShowModal() == wx.ID_OK: + sqlfile = tempfile.NamedTemporaryFile(mode="w") + sqlfile.file.write(addRecordDlg.GetSQLString()) + sqlfile.file.flush() + executeCommand = cmd.Command(cmd=["db.execute", + "--q", + "input=%s" % sqlfile.name]) + # clean up saved positions self.polycoords = [] Modified: trunk/grassaddons/gui/gui_modules/toolbars.py =================================================================== --- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-29 08:47:33 UTC (rev 880) +++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-06-29 14:50:01 UTC (rev 881) @@ -203,16 +203,6 @@ self.settings = self.exit = None return (("", "", "", "", "", "", ""), - (self.displayCats, "digDispCats", Icons["digDispCats"].GetBitmap(), - wx.ITEM_RADIO, Icons["digDispCats"].GetLabel(), Icons["digDispCats"].GetDesc(), - self.OnDisplayCats), - (self.copyCats, "digCopyCats", Icons["digCopyCats"].GetBitmap(), - wx.ITEM_RADIO, Icons["digCopyCats"].GetLabel(), Icons["digCopyCats"].GetDesc(), - self.OnCopyCats), - (self.displayAttr, "digDispAttr", Icons["digDispAttr"].GetBitmap(), - wx.ITEM_RADIO, Icons["digDispAttr"].GetLabel(), Icons["digDispAttr"].GetDesc(), - self.OnDisplayAttr), - ("", "", "", "", "", "", ""), (self.settings, "digSettings", Icons["digSettings"].GetBitmap(), wx.ITEM_NORMAL, Icons["digSettings"].GetLabel(), Icons["digSettings"].GetDesc(), self.OnSettings), @@ -256,7 +246,16 @@ self.OnMoveLine), (self.deleteLine, "digDeleteLine", Icons["digDeleteLine"].GetBitmap(), wx.ITEM_RADIO, Icons["digDeleteLine"].GetLabel(), Icons["digDeleteLine"].GetDesc(), - self.OnDeleteLine)) + self.OnDeleteLine), + (self.displayCats, "digDispCats", Icons["digDispCats"].GetBitmap(), + wx.ITEM_RADIO, Icons["digDispCats"].GetLabel(), Icons["digDispCats"].GetDesc(), + self.OnDisplayCats), + (self.copyCats, "digCopyCats", Icons["digCopyCats"].GetBitmap(), + wx.ITEM_RADIO, Icons["digCopyCats"].GetLabel(), Icons["digCopyCats"].GetDesc(), + self.OnCopyCats), + (self.displayAttr, "digDispAttr", Icons["digDispAttr"].GetBitmap(), + wx.ITEM_RADIO, Icons["digDispAttr"].GetLabel(), Icons["digDispAttr"].GetDesc(), + self.OnDisplayAttr)) def OnAddPoint(self, event): """Add point to the vector map layer""" @@ -324,7 +323,8 @@ pass def OnDisplayAttr(self, event): - pass + self.action="dispAttr" + Debug.msg(4, "Digittoolbar.OnDisplayAttr():") def OnCopyCats(self, event): pass Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-29 08:47:33 UTC (rev 880) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-06-29 14:50:01 UTC (rev 881) @@ -912,7 +912,7 @@ gisbase = os.environ['GISBASE'] self.gcmdlst = os.listdir(os.path.join(gisbase,'bin')) self.gcmdlst = self.gcmdlst + os.listdir(os.path.join(gisbase,'scripts')) - self.gcmdlst = self.gcmdlst + os.listdir(os.path.join(gisbase,'etc','gm','script')) + #self.gcmdlst = self.gcmdlst + os.listdir(os.path.join(gisbase,'etc','gm','script')) return self.gcmdlst Modified: trunk/grassaddons/gui/icons/icon.py =================================================================== --- trunk/grassaddons/gui/icons/icon.py 2007-06-29 08:47:33 UTC (rev 880) +++ trunk/grassaddons/gui/icons/icon.py 2007-06-29 14:50:01 UTC (rev 881) @@ -20,8 +20,8 @@ import os import wx -iconpath_default = os.getenv("GISBASE") + "/etc/gui/icons/" -iconpath_vdigit = os.getenv("GISBASE") + "/etc/v.digit/" +iconpath_default = os.path.join(os.getenv("GISBASE"), "etc", "gui", "icons") +iconpath_vdigit = os.path.join(os.getenv("GISBASE"), "etc", "v.digit") iconpath = os.getenv("GRASS_ICONPATH") icons_default = { @@ -229,7 +229,7 @@ "digDeleteLine": MetaIcon (img=icons_img["digDeleteLine"], label="Delete line", desc="Not implemented yet"), "digDispAttr": MetaIcon (img=icons_img["digDispAttr"], label="Display attributes", - desc="Not implemented yet"), + desc="Display attributes of given feature"), "digDispCats": MetaIcon (img=icons_img["digDispCats"], label="Display categories", desc="Not implemented yet"), "digEditLine": MetaIcon (img=icons_img["digEditLine"], label="Edit line", @@ -241,7 +241,7 @@ "digRemoveVertex": MetaIcon (img=icons_img["digRemoveVertex"], label="Remove vertex", desc="Not implemented yet"), "digSettings": MetaIcon (img=icons_img["digSettings"], label="Settings", - desc="Not implemented yet"), + desc="Settings dialog for digitization tool"), "digSplitLine": MetaIcon (img=icons_img["digSplitLine"], label="Split line", desc="Not implemented yet"), "digExit" : MetaIcon (img=icons_img["digExit"], label="Quit digitization tool"), From chemin at grass.itc.it Fri Jun 29 18:15:39 2007 From: chemin at grass.itc.it (chemin@grass.itc.it) Date: Fri Jun 29 18:15:43 2007 Subject: [grass-addons] r882 - in trunk/grassaddons/gipe: . script_generator Message-ID: <200706291615.l5TGFdmg023207@grass.itc.it> Author: chemin Date: 2007-06-29 18:13:32 +0200 (Fri, 29 Jun 2007) New Revision: 882 Modified: trunk/grassaddons/gipe/gmmenu.tcl trunk/grassaddons/gipe/menudata.py trunk/grassaddons/gipe/script_generator/l7_in_read.c Log: Minor fixes/changes Modified: trunk/grassaddons/gipe/gmmenu.tcl =================================================================== --- trunk/grassaddons/gipe/gmmenu.tcl 2007-06-29 14:50:01 UTC (rev 881) +++ trunk/grassaddons/gipe/gmmenu.tcl 2007-06-29 16:13:32 UTC (rev 882) @@ -1,11 +1,13 @@ ############################################################### -# gmmenu.tcl - menu file for GRASS GIS Manager -# January 2006 Michael Barton, Arizona State University -# COPYRIGHT: (C) 1999 - 2006 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. +# File: gmmenu.tcl +# Purpose: menu file for GRASS GIS Manager +# Author: Michael Barton, Arizona State University +# Based originally on menu for d.m and tcltkgrass +# Additions by Cedrick Shock and Benjamin Ducke +# COPYRIGHT: (C) 2006-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. ############################################################### # our job is simply to make a variable called descmenu @@ -88,442 +90,451 @@ {command {[G_msg "Save as..."]} {} "Save gis.m workspace file as new name" {} -command { set filename($mon) "" ; Gm::SaveFileBox }} {command {[G_msg "Close"]} {} "Close gis.m workspace" {} -accelerator $keyctrl-W -command { GmTree::FileClose {}}} }} - {cascad {[G_msg "Import"]} {} "" $tmenu { - {cascad {[G_msg "Raster map"]} {} "" $tmenu { - {command {[G_msg "Multiple formats using GDAL"]} {} "r.in.gdal" {} -command { execute r.in.gdal }} - {separator} - {command {[G_msg "Aggregate ASCII xyz data into raster grid"]} {} "r.in.xyz" {} -command { execute r.in.xyz }} - {command {[G_msg "ASCII GRID (includes GRASS ASCII)"]} {} "r.in.ascii" {} -command { execute r.in.ascii }} - {command {[G_msg "Polygons and lines from ASCII file"]} {} "r.in.poly" {} -command { execute r.in.poly }} - {separator} - {command {[G_msg "Binary file (includes GTOPO30 format)"]} {} "r.in.bin" {} -command { execute r.in.bin }} - {command {[G_msg "ESRI Arc/Info ASCII grid"]} {} "r.in.arc" {} -command { execute r.in.arc }} - {command {[G_msg "GRIDATB.FOR map file (TOPMODEL)"]} {} "r.in.gridatb" {} -command { execute r.in.gridatb }} - {command {[G_msg "MAT-File (v.4) array (Matlab or Octave)"]} {} "r.in.mat" {} -command { execute r.in.mat }} - {command {[G_msg "SPOT vegetation NDVI data sets"]} {} "i.in.spotvgt" {} -command { execute i.in.spotvgt }} - {command {[G_msg "SRTM hgt files"]} {} "r.in.srtm" {} -command { execute r.in.srtm }} - {command {[G_msg "Terra ASTER HDF files"]} {} "r.in.aster" {} -command { execute r.in.aster }} - {separator} - {command {[G_msg "Web Mapping Server"]} {} "r.in.wms" {} -command { execute r.in.wms }} - }} - {cascad {[G_msg "Vector map"]} {} "" $tmenu { - {command {[G_msg "Various formats using OGR"]} {} "v.in.ogr" {} -command { execute v.in.ogr }} - {separator} - {command {[G_msg "ASCII points file or GRASS ASCII vector file"]} {} "v.in.ascii" {} -command { execute v.in.ascii }} - {command {[G_msg "Import old GRASS vector format"]} {} "v.convert" {} -command { execute v.convert }} - {separator} - {command {[G_msg "DXF file"]} {} "v.in.dxf" {} -command { execute v.in.dxf }} - {command {[G_msg "ESRI e00 format"]} {} "v.in.e00" {} -command { execute v.in.e00 }} - {command {[G_msg "Garmin GPS Waypoints/Routes/Tracks"]} {} "v.in.garmin" {} -command { execute v.in.garmin }} - {command {[G_msg "GPS Waypoints/Routes/Tracks using GPSBabel"]} {} "v.in.gpsbabel" {} -command { execute v.in.gpsbabel }} - {command {[G_msg "GEOnet Name server country files (US-NGA GNS)"]} {} "v.in.gns" {} -command { execute v.in.gns }} - {command {[G_msg "Matlab and MapGen files"]} {} "v.in.mapgen" {} -command { execute v.in.mapgen }} - }} - {cascad {[G_msg "Grid 3D"]} {} "" $tmenu { - {command {[G_msg "ASCII 3D file"]} {} "r3.in.ascii" {} -command { execute r3.in.ascii }} - {command {[G_msg "Vis5D file"]} {} "r3.in.v5d" {} -command { execute r3.in.v5d }} - }} + {separator} + {cascad {[G_msg "Import raster map"]} {} "" $tmenu { + {command {[G_msg "Multiple formats using GDAL"]} {} "r.in.gdal: Import multiple formats using GDAL" {} -command { execute r.in.gdal }} + {separator} + {command {[G_msg "Aggregate ASCII xyz"]} {} "r.in.xyz: Import aggregate ASCII xyz data into raster grid" {} -command { execute r.in.xyz }} + {command {[G_msg "ASCII grid"]} {} "r.in.ascii: Import ASCII grid (includes GRASS ASCII)" {} -command { execute r.in.ascii }} + {command {[G_msg "ASCII polygons and lines"]} {} "r.in.poly: Import polygons and lines from ASCII file" {} -command { execute r.in.poly }} + {separator} + {command {[G_msg "Binary"]} {} "r.in.bin: Import binary file (includes GTOPO30 format)" {} -command { execute r.in.bin }} + {command {[G_msg "ESRI grid"]} {} "r.in.arc: Import ESRI Arc/Info ASCII grid" {} -command { execute r.in.arc }} + {command {[G_msg "GRIDATB.FOR"]} {} "r.in.gridatbk: Import GRIDATB.FOR map file (TOPMODEL)" {} -command { execute r.in.gridatb }} + {command {[G_msg "MAT-File (v.4)"]} {} "r.in.mat: Import MAT-File (v.4) array (Matlab or Octave)" {} -command { execute r.in.mat }} + {command {[G_msg "SPOT NDVI"]} {} "i.in.spotvgt: Import SPOT vegetation NDVI data sets" {} -command { execute i.in.spotvgt }} + {command {[G_msg "SRTM hgt"]} {} "r.in.srtm: Import SRTM hgt files" {} -command { execute r.in.srtm }} + {command {[G_msg "Terra ASTER"]} {} "r.in.aster: Import Terra ASTER HDF files" {} -command { execute r.in.aster }} + {separator} + {command {[G_msg "Web Mapping Server"]} {} "r.in.wms: Import Web Mapping Server files" {} -command { execute r.in.wms }} }} - {cascad {[G_msg "Export"]} {} "" $tmenu { - {cascad {[G_msg "Raster map"]} {} "" $tmenu { - {command {[G_msg "Multiple formats using GDAL"]} {} "r.out.gdal" {} -command { execute r.out.gdal }} - {separator} - {command {[G_msg "ASCII grid (for GRASS, Surfer, Modflow, etc)"]} {} "r.out.ascii" {} -command { execute r.out.ascii }} - {command {[G_msg "ASCII x,y,z values of cell centers"]} {} "r.out.xyz" {} -command { execute r.out.xyz }} - {separator} - {command {[G_msg "ESRI Arc/Info ASCII grid"]} {} "r.out.arc" {} -command { execute r.out.arc }} - {command {[G_msg "GRIDATB.FOR map file (TOPMODEL)"]} {} "r.out.gridatb" {} -command { execute r.out.gridatb }} - {command {[G_msg "MAT-File (v.4) array (Matlab or Octave)"]} {} "r.out.mat" {} -command { execute r.out.mat }} - {separator} - {command {[G_msg "Binary file"]} {} "r.out.bin" {} -command { execute r.out.bin }} - {separator} - {command {[G_msg "MPEG-1 animations"]} {} "r.out.mpeg" {} -command { execute r.out.mpeg }} - {command {[G_msg "PNG image (not georeferenced)"]} {} "r.out.png" {} -command { execute r.out.png }} - {command {[G_msg "PPM image (24bit)"]} {} "r.out.ppm" {} -command { execute r.out.ppm }} - {command {[G_msg "PPM image from red, green, blue raster maps"]} {} "r.out.ppm3" {} -command { execute r.out.ppm3 }} - {command {[G_msg "POVray height-field"]} {} "r.out.pov" {} -command { execute r.out.pov }} - {command {[G_msg "TIFF image (8/24bit)"]} {} "r.out.tiff" {} -command { execute r.out.tiff }} - {command {[G_msg "VRML file"]} {} "r.out.vrml" {} -command { execute r.out.vrml }} - {command {[G_msg "VTK ASCII file"]} {} "r.out.vtk" {} -command { execute r.out.vtk }} - }} - {cascad {[G_msg "Vector map"]} {} "" $tmenu { - {command {[G_msg "Various formats using OGR (SHAPE, MapInfo etc)"]} {} "v.out.ogr" {} -command { execute v.out.ogr }} - {separator} - {command {[G_msg "DXF file (ASCII)"]} {} "v.out.dxf" {} -command { execute v.out.dxf }} - {command {[G_msg "ASCII vector or point file/old GRASS ASCII vector file"]} {} "v.out.ascii" {} -command { execute v.out.ascii }} - {command {[G_msg "POV-Ray format"]} {} "v.out.pov" {} -command { execute v.out.pov }} - {command {[G_msg "SVG file"]} {} "v.out.svg" {} -command { execute v.out.svg }} - {command {[G_msg "VTK ASCII file"]} {} "v.out.vtk" {} -command { execute v.out.vtk }} - }} - {cascad {[G_msg "Grid 3D"]} {} "" $tmenu { - {command {[G_msg "ASCII 3D file"]} {} "r3.out.ascii" {} -command { execute r3.out.ascii }} - {command {[G_msg "Vis5D file"]} {} "r3.out.v5d" {} -command { execute r3.out.v5d }} - {command {[G_msg "VTK ASCII file"]} {} "r3.out.vtk" {} -command { execute r3.out.vtk }} - }} + {cascad {[G_msg "Import vector map"]} {} "" $tmenu { + {command {[G_msg "Multiple formats using OGR"]} {} "v.in.ogr: Import multiple formats using OGR" {} -command { execute v.in.ogr }} + {separator} + {command {[G_msg "ASCII points or GRASS ASCII vector"]} {} "v.in.ascii: Import ASCII points file or GRASS ASCII vector file" {} -command { execute v.in.ascii }} + {command {[G_msg "Old GRASS vector"]} {} "v.convert: Import old GRASS vector format" {} -command { execute v.convert }} + {separator} + {command {[G_msg "DXF"]} {} "v.in.dxf: Import DXF file" {} -command { execute v.in.dxf }} + {command {[G_msg "ESRI e00"]} {} "v.in.e00: Import ESRI e00 format" {} -command { execute v.in.e00 }} + {command {[G_msg "Garmin GPS"]} {} "v.in.garmin: Import Garmin GPS waypoints/routes/tracks" {} -command { execute v.in.garmin }} + {command {[G_msg "GPSBabel GPS"]} {} "v.in.gpsbabel: Import GPS waypoints/routes/tracks using GPSBabel" {} -command { execute v.in.gpsbabel }} + {command {[G_msg "GEOnet"]} {} "v.in.gns: Import GEOnet Name server country files (US-NGA GNS)" {} -command { execute v.in.gns }} + {command {[G_msg "Matlab and MapGen"]} {} "v.in.mapgen: Import Matlab and MapGen files" {} -command { execute v.in.mapgen }} }} + {cascad {[G_msg "Import grid 3D volume"]} {} "" $tmenu { + {command {[G_msg "ASCII 3D"]} {} "r3.in.ascii: Import ASCII 3D file" {} -command { execute r3.in.ascii }} + {command {[G_msg "Vis5D"]} {} "r3.in.v5d: Import Vis5D file" {} -command { execute r3.in.v5d }} + }} {separator} + {cascad {[G_msg "Export raster map"]} {} "" $tmenu { + {command {[G_msg "Multiple formats using GDAL"]} {} "r.out.gdal: Export multiple formats using GDAL" {} -command { execute r.out.gdal }} + {separator} + {command {[G_msg "ASCII grid"]} {} "r.out.ascii: Export ASCII grid (for GRASS, Surfer, Modflow, etc)" {} -command { execute r.out.ascii }} + {command {[G_msg "ASCII x,y,z"]} {} "r.out.xyz: Export ASCII x,y,z values of cell centers" {} -command { execute r.out.xyz }} + {separator} + {command {[G_msg "ESRI ASCII grid"]} {} "r.out.arc" {} -command { execute r.out.arc }} + {command {[G_msg "GRIDATB.FOR"]} {} "r.out.gridatb: Export GRIDATB.FOR map file (TOPMODEL)" {} -command { execute r.out.gridatb }} + {command {[G_msg "MAT-File (v.4)"]} {} "r.out.mat: Export MAT-File (v.4) array (Matlab or Octave)" {} -command { execute r.out.mat }} + {separator} + {command {[G_msg "Binary"]} {} "r.out.bin: Export binary file" {} -command { execute r.out.bin }} + {separator} + {command {[G_msg "MPEG-1"]} {} "r.out.mpeg: Export MPEG-1 animations" {} -command { execute r.out.mpeg }} + {command {[G_msg "PNG"]} {} "r.out.png: Export PNG image (not georeferenced)" {} -command { execute r.out.png }} + {command {[G_msg "PPM"]} {} "r.out.ppm: Export PPM image (24bit)" {} -command { execute r.out.ppm }} + {command {[G_msg "PPM from RGB"]} {} "r.out.ppm3: Export PPM image from red, green, blue raster maps" {} -command { execute r.out.ppm3 }} + {command {[G_msg "POV-Ray"]} {} "r.out.pov: Export POV-Ray height-field" {} -command { execute r.out.pov }} + {command {[G_msg "TIFF"]} {} "r.out.tiff: Export TIFF image (8/24bit)" {} -command { execute r.out.tiff }} + {command {[G_msg "VRML"]} {} "r.out.vrml: Export VRML file" {} -command { execute r.out.vrml }} + {command {[G_msg "VTK"]} {} "r.out.vtk: Export VTK ASCII file" {} -command { execute r.out.vtk }} + }} + {cascad {[G_msg "Export vector map"]} {} "" $tmenu { + {command {[G_msg "Multiple formats using OGR"]} {} "v.out.ogr: Export multiple formats using OGR (SHAPE, MapInfo etc)" {} -command { execute v.out.ogr }} + {separator} + {command {[G_msg "ASCII points or GRASS ASCII vector"]} {} "v.out.ascii: Export ASCII vector or point file/old GRASS ASCII vector file" {} -command { execute v.out.ascii }} + {command {[G_msg "DXF"]} {} "v.out.dxf: Export DXF file (ASCII)" {} -command { execute v.out.dxf }} + {command {[G_msg "POV-Ray"]} {} "v.out.pov: Export POV-Ray format" {} -command { execute v.out.pov }} + {command {[G_msg "SVG"]} {} "v.out.svg: Export SVG file" {} -command { execute v.out.svg }} + {command {[G_msg "VTK"]} {} "v.out.vtk: Export VTK ASCII file" {} -command { execute v.out.vtk }} + }} + {cascad {[G_msg "Exort grid 3D volume"]} {} "" $tmenu { + {command {[G_msg "ASCII 3D"]} {} "r3.out.ascii: Export ASCII 3D file" {} -command { execute r3.out.ascii }} + {command {[G_msg "Vis5D"]} {} "r3.out.v5d: Export Vis5D file" {} -command { execute r3.out.v5d }} + {command {[G_msg "VTK"]} {} "r3.out.vtk: Export VTK ASCII file" {} -command { execute r3.out.vtk }} + }} + {separator} {cascad {[G_msg "Manage maps and volumes"]} {} "" $tmenu { - {command {[G_msg "Copy maps"]} {} "g.copy" {} -command {execute g.copy }} - {command {[G_msg "List maps"]} {} "g.list" {} -command {execute g.list}} - {command {[G_msg "List maps using expressions and 'wildcards'"]} {} "g.mlist" {} -command {execute g.mlist }} - {command {[G_msg "Rename maps"]} {} "g.rename" {} -command {execute g.rename }} - {command {[G_msg "Remove maps"]} {} "g.remove" {} -command {execute g.remove }} - {command {[G_msg "Remove maps using expressions and 'wildcards'"]} {} "g.mremove" {} -command {execute g.mremove }} + {command {[G_msg "Copy"]} {} "g.copy: Copy maps" {} -command {execute g.copy }} + {separator} + {command {[G_msg "List"]} {} "g.list: List maps" {} -command {execute g.list}} + {command {[G_msg "List filtered"]} {} "g.mlist: List maps using expressions and 'wildcards'" {} -command {execute g.mlist }} + {separator} + {command {[G_msg "Rename"]} {} "g.rename: Rename maps" {} -command {execute g.rename }} + {separator} + {command {[G_msg "Delete"]} {} "g.remove: Delete maps" {} -command {execute g.remove }} + {command {[G_msg "Delete filtered"]} {} "g.mremove: Delete maps using expressions and 'wildcards'" {} -command {execute g.mremove }} }} {cascad {[G_msg "Map type conversions"]} {} "" $tmenu { - {command {[G_msg "Raster to vector map"]} {} "r.to.vect" {} -command {execute r.to.vect }} - {command {[G_msg "Raster map series to volume"]} {} "r.to.rast3" {} -command {execute r.to.rast3 }} - {command {[G_msg "Raster 2.5D map to volume"]} {} "r.to.rast3elev" {} -command {execute r.to.rast3elev }} - {command {[G_msg "Vector to raster"]} {} "v.to.rast" {} -command {execute v.to.rast }} - {command {[G_msg "Vector to vector"]} {} "v.type" {} -command {execute v.type }} - {command {[G_msg "Vector lines to points"]} {} "v.to.points" {} -command {execute v.to.points }} - {command {[G_msg "Vector 3D points to volume voxels"]} {} "v.to.rast3" {} -command {execute v.to.rast3 }} - {command {[G_msg "Sites (GRASS 5) to vector"]} {} "v.in.sites" {} -command {execute v.in.sites }} - {command {[G_msg "Volumes to raster map series"]} {} "r3.to.rast" {} -command {execute r3.to.rast }} + {command {[G_msg "Raster to vector"]} {} "r.to.vect: Convert aster to vector map" {} -command {execute r.to.vect }} + {command {[G_msg "Raster series to volume"]} {} "r.to.rast3: Convert raster map series to volume" {} -command {execute r.to.rast3 }} + {command {[G_msg "Raster 2.5D to volume"]} {} "r.to.rast3elev: Convert raster 2.5D map to volume" {} -command {execute r.to.rast3elev }} + {separator} + {command {[G_msg "Vector to raster"]} {} "v.to.rast: Convert vector to raster map" {} -command {execute v.to.rast }} + {command {[G_msg "Vector to volume"]} {} "v.to.rast3: Convert vector 3D points to volume voxels" {} -command {execute v.to.rast3 }} + {command {[G_msg "Sites to vector"]} {} "v.in.sites: Convert GRASS 5 sites to vector points" {} -command {execute v.in.sites }} + {separator} + {command {[G_msg "Volume to raster series"]} {} "r3.to.rast: Convert volume to raster map series" {} -command {execute r3.to.rast }} }} {separator} {command {[G_msg "Georectify"]} {} "Georectify raster map in XY location" {} -command { GRMap::startup }} {separator} - {command {[G_msg "Convert between bearing/distance and coordinates"]} {} "m.cogo" {} -command { execute m.cogo }} + {command {[G_msg "Bearing/distance to coordinates"]} {} "m.cogo: Convert between bearing/distance and coordinates" {} -command { execute m.cogo }} {separator} - {command {[G_msg "Create cartographic PostScript plot"]} {} "ps.map" {} -command { execute ps.map }} + {command {[G_msg "PostScript plot"]} {} "ps.map: Create cartographic PostScript plot" {} -command { execute ps.map }} {separator} {command {[G_msg "E&xit"]} {} "Exit GIS Manager" {} -accelerator $keyctrl-Q -command { exit } } } {[G_msg "&Config"]} all options $tmenu { {cascad {[G_msg "Region"]} {} "" $tmenu { - {command {[G_msg "Display region settings"]} {} "g.region -p" {} -command {run_panel "g.region -p" }} - {command {[G_msg "Change region settings"]} {} "g.region" {} -command {execute g.region }} - {command {[G_msg "Zoom to maximum extent of all displayed maps"]} {} "d.extend" {} -command {run_panel d.extend }} + {command {[G_msg "Display region settings"]} {} "g.region -p: Display region settings" {} -command {run_panel "g.region -p" }} + {command {[G_msg "Change region settings"]} {} "g.region: " {} -command {execute g.region }} }} {cascad {[G_msg "GRASS working environment"]} {} "" $tmenu { - {command {[G_msg "Access other mapsets in current location"]} {} "g.mapsets.tcl" {} -command {spawn $env(GISBASE)/etc/g.mapsets.tcl}} - {command {[G_msg "Change current working session to new mapset, location, or GISDBASE"]} {} "g.mapset" {} -command {execute g.mapset }} - {command {[G_msg "Modify access by other users to current mapset"]} {} "g.access" {} -command {execute g.access }} - {command {[G_msg "Show current GRASS environment settings"]} {} "g.gisenv" {} -command {run_panel g.gisenv }} - {command {[G_msg "Set GRASS environment settings"]} {} "g.gisenv" {} -command {execute g.gisenv }} - {command {[G_msg "Show current GRASS version"]} {} "g.version -c" {} -command {run_panel "g.version -c" }} + {command {[G_msg "Mapset access"]} {} "g.mapsets.tcl: Access other mapsets in current location" {} -command {spawn $env(GISBASE)/etc/g.mapsets.tcl}} + {command {[G_msg "Change working environment"]} {} "g.mapset: Change current working session to new mapset, location, or GISDBASE" {} -command {execute g.mapset }} + {command {[G_msg "User access"]} {} "g.access: Modify access by other users to current mapset" {} -command {execute g.access }} + {command {[G_msg "Show settings"]} {} "g.gisenv: Show current GRASS environment settings" {} -command {run_panel g.gisenv }} + {command {[G_msg "Change settings"]} {} "g.gisenv: Set GRASS environment settings" {} -command {execute g.gisenv }} + {command {[G_msg "Show current GRASS version"]} {} "g.version -c: Show current GRASS version" {} -command {run_panel "g.version -c" }} }} {cascad {[G_msg "Manage projections"]} {} "" $tmenu { - {command {[G_msg "Create/edit projection information for current location"]} {} "g.setproj" {} -command {term g.setproj }} - {command {[G_msg "Show projection information and create projection files"]} {} "g.proj" {} -command {execute g.proj }} + {command {[G_msg "Manage projections"]} {} "g.proj: Show projection information and create projection files" {} -command {execute g.proj }} + {command {[G_msg "Projection for current location"]} {} "g.setproj: Create/edit projection information for current location" {} -command {term g.setproj }} {separator} - {command {[G_msg "Convert coordinates from one projection to another"]} {} "m.proj" {} -command {execute m.proj }} + {command {[G_msg "Convert coordinates"]} {} "m.proj: Convert coordinates from one projection to another" {} -command {execute m.proj }} }} - {cascad {[G_msg "X-monitor displays"]} {} "" $tmenu { - {command {[G_msg "Configure xmonitor displays"]} {} "d.mon" {} -command {execute d.mon }} - {command {[G_msg "Configure frames for xmonitors"]} {} "d.frame" {} -command {execute d.frame }} - {command {[G_msg "Start/restart xmonitor at specified window size"]} {} "d.monsize" {} -command {execute d.monsize }} - {command {[G_msg "Set active xmonitor to specified size"]} {} "d.resize" {} -command {execute d.resize }} - {command {[G_msg "Display information about active xmonitor"]} {} "d.info" {} -command {execute d.info }} - }} - {separator} - {command {[G_msg "Install GRASS Extensions"]} {} "m.gem" {} -command {execute m.gem }} + {command {[G_msg "Display font"]} {} "Set default display font" {} -command {Gm:DefaultFont "menu" }} } {[G_msg "&Raster"]} all options $tmenu { {cascad {[G_msg "Develop map"]} {} "" $tmenu { - {command {[G_msg "Digitize raster"]} {} "r.digit" {} -command {guarantee_xmon; term r.digit }} + {command {[G_msg "Digitize raster"]} {} "r.digit" {} -command { + unset env(GRASS_RENDER_IMMEDIATE) + guarantee_xmon + term r.digit + set env(GRASS_RENDER_IMMEDIATE) "TRUE"}} {separator} - {command {[G_msg "Compress/decompress raster file"]} {} "r.compress" {} -command {execute r.compress }} - {command {[G_msg "Manage boundary definitions"]} {} "r.region" {} -command {execute r.region }} - {command {[G_msg "Manage null values"]} {} "r.null" {} -command {execute r.null }} - {command {[G_msg "Manage timestamps for files"]} {} "r.timestamp" {} -command {execute r.timestamp }} - {command {[G_msg "Quantization for floating-point maps"]} {} "r.quant" {} -command {execute r.quant }} - {cascad {[G_msg "Resample (change resolution)"]} {} "" $tmenu { - {command {[G_msg "Resample using nearest neighbor method"]} {} "r.resample" {} -command {execute r.resample }} - {command {[G_msg "Resample using various interpolation methods"]} {} "r.resamp.interp" {} -command {execute r.resamp.interp }} - {command {[G_msg "Resample using aggregate statistics"]} {} "r.resamp.stats" {} -command {execute r.resamp.stats }} - {command {[G_msg "Resample using regularized spline with tension method"]} {} "r.resamp.rst" {} -command {execute r.resamp.rst }} - }} - {command {[G_msg "Support file creation and maintenance"]} {} "r.support" {} -command {term r.support }} - {command {[G_msg "Update raster map statistics"]} {} "r.support.stats" {} -command {execute r.support.stats }} + {command {[G_msg "Compress/decompress"]} {} "r.compress: Compress/decompress raster file" {} -command {execute r.compress }} {separator} - {command {[G_msg "Reproject raster from other location"]} {} "r.proj" {} -command {execute r.proj }} - {command {[G_msg "Generate tiling for other projection"]} {} "r.tileset" {} -command {execute r.tileset }} + {command {[G_msg "Boundaries"]} {} "r.region: Manage boundary definitions" {} -command {execute r.region }} + {command {[G_msg "Null values"]} {} "r.null:Manage null values" {} -command {execute r.null }} + {command {[G_msg "Quantization"]} {} "r.quant: Quantization for floating-point maps" {} -command {execute r.quant }} + {command {[G_msg "Timestamps"]} {} "r.timestamp: Manage timestamps for files" {} -command {execute r.timestamp }} + {separator} + {command {[G_msg "Resample using aggregate statistics"]} {} "r.resamp.stats: Resample (change resolution) using aggregate statistics sing regularized spline tension" {} -command {execute r.resamp.stats }} + {command {[G_msg "Resample using multiple methods"]} {} "r.resamp.interp: Resample (change resolution) using nearest neighbor, bilinear, or bicubic interpolation" {} -command {execute r.resamp.interp }} + {command {[G_msg "Resample using nearest neighbor"]} {} "r.resample: Resample (change resolution) using nearest neighbor interpolation" {} -command {execute r.resample }} + {command {[G_msg "Resample using spline tension"]} {} "r.resamp.rst: Resample (change resolution)" {} -command {execute r.resamp.rst }} + {separator} + {command {[G_msg "Support file maintenance"]} {} "r.support: Support file maintenance" {} -command {term r.support }} + {command {[G_msg "Update map statistics"]} {} "r.support.stats: Update map statistics" {} -command {execute r.support.stats }} + {separator} + {command {[G_msg "Reproject"]} {} "r.proj: Reproject raster from other location" {} -command {execute r.proj }} + {command {[G_msg "Tiling"]} {} "r.tileset: Generate tiling for other projection" {} -command {execute r.tileset }} }} {cascad {[G_msg "Manage map colors"]} {} "" $tmenu { - {command {[G_msg "Set colors to predefined color tables"]} {} "r.colors" {} -command {execute r.colors }} - {command {[G_msg "Set colors using color rules"]} {} "r.colors.rules" {} -command {execute $env(GISBASE)/etc/gm/script/r.colors.rules }} + {command {[G_msg "Color tables"]} {} "r.colors: Set colors to predefined color tables or from another raster map" {} -command {execute r.colors }} + {command {[G_msg "Color rules"]} {} "Set colors interactively by entering color rules" {} -command {GmRules::main "r.colors" }} {separator} - {command {[G_msg "Blend 2 color maps to produce 3 RGB files"]} {} "r.blend" {} -command {execute r.blend }} - {command {[G_msg "Create color image from RGB files"]} {} "r.composite" {} -command {execute r.composite }} - {command {[G_msg "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps"]} {} "r.his" {} -command {execute r.his }} + {command {[G_msg "Blend"]} {} "r.blend: Blend 2 color maps to produce 3 RGB files" {} -command {execute r.blend }} + {command {[G_msg "Create RGB"]} {} "r.composite: Create color image from RGB files" {} -command {execute r.composite }} + {command {[G_msg "HIS to RGB"]} {} "r.his: Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps" {} -command {execute r.his }} }} - {cascad {[G_msg "Query/Profile"]} {} "" $tmenu { - {command {[G_msg "Query by coordinate(s)"]} {} "r.what" {} -command { execute r.what }} - {command {[G_msg "Profile analysis"]} {} "d.profile" {} -command {guarantee_xmon; execute d.profile }} - }} {separator} - {command {[G_msg "Create raster MASK"]} {} "r.mask" {} -command { execute r.mask }} - {command {[G_msg "Create raster buffers"]} {} "r.buffer" {} -command { execute r.buffer }} - {command {[G_msg "Map calculator"]} {} "r.mapcalculator" {} -command { execute r.mapcalculator }} + {command {[G_msg "Query by coordinate(s)"]} {} "r.what: Query by coordinate(s)" {} -command { execute r.what }} {separator} + {command {[G_msg "Buffers"]} {} "r.buffer: Create raster buffers" {} -command { execute r.buffer }} + {command {[G_msg "Closest points"]} {} "r.distance: Locate closest points between areas in 2 raster maps" {} -command { execute r.distance }} + {command {[G_msg "MASK"]} {} "r.mask: Create raster MASK (defines map areas for GIS operations)" {} -command { execute r.mask }} + {command {[G_msg "Map calculator"]} {} "r.mapcalculator: Map calculator" {} -command { execute r.mapcalculator }} + {cascad {[G_msg "Neighborhood analysis"]} {} "" $tmenu { + {command {[G_msg "Moving window"]} {} "r.neighbors: Moving window analysis of raster cells" {} -command { execute r.neighbors }} + {command {[G_msg "Neighborhood points"]} {} "v.neighbors: Analyze vector points in neighborhood of raster cells" {} -command { execute v.neighbors }} + }} {cascad {[G_msg "Overlay maps"]} {} "" $tmenu { - {command {[G_msg "Cross product"]} {} "r.cross" {} -command {execute r.cross }} - {command {[G_msg "Function of map series (time series)"]} {} "r.series" {} -command {execute r.series }} - {command {[G_msg "Patch maps"]} {} "r.patch" {} -command {execute r.patch }} + {command {[G_msg "Cross product"]} {} "r.cross: Cross product" {} -command {execute r.cross }} + {command {[G_msg "Map series"]} {} "r.series: Function of map series (time series)" {} -command {execute r.series }} + {command {[G_msg "Patch maps"]} {} "r.patch: Patch maps" {} -command {execute r.patch }} {separator} - {command {[G_msg "Statistical calculations for cover map over base map"]} {} "r.statistics" {} -command {execute r.statistics }} + {command {[G_msg "Statistical overlay"]} {} "r.statistics: Statistical calculations for cover map over base map" {} -command {execute r.statistics }} }} - {cascad {[G_msg "Transform features"]} {} "" $tmenu { - {command {[G_msg "Clump small areas (statistics calculated by r.volume)"]} {} "r.clump" {} -command {execute r.clump }} - {command {[G_msg "Grow areas"]} {} "r.grow" {} -command {execute r.grow }} - {command {[G_msg "Thin linear features"]} {} "r.thin" {} -command {execute r.thin }} + {cascad {[G_msg "Solar radiance and shadows"]} {} "" $tmenu { + {command {[G_msg "Solar irradiance irradiation"]} {} "r.sun: Solar irradiance and daily irradiation" {} -command {execute r.sun }} + {command {[G_msg "Shadows map"]} {} "r.sunmask: Shadows map for sun position or date/time" {} -command {execute r.sunmask }} }} - {cascad {[G_msg "Proximity/Neighborhood analysis"]} {} "" $tmenu { - {command {[G_msg "Moving window analysis of raster cells"]} {} "r.neighbors" {} -command { execute r.neighbors }} - {command {[G_msg "Analyze vector points in neighborhood of raster cells"]} {} "v.neighbors" {} -command { execute v.neighbors }} + {cascad {[G_msg "Terrain analysis"]} {} "" $tmenu { + {command {[G_msg "Cumulative movement costs"]} {} "r.walk: Calculate cumulative movement costs between locales" {} -command {execute r.walk }} + {command {[G_msg "Cost surface"]} {} "r.cost: Cost surface" {} -command {execute r.cost }} + {command {[G_msg "Least cost route or flow"]} {} "r.drain: Least cost route or flow" {} -command {execute r.drain }} {separator} - {command {[G_msg "Locate closest points between areas in 2 raster maps"]} {} "r.distance" {} -command { execute r.distance }} + {command {[G_msg "Shaded relief"]} {} "r.shaded.relief: Shaded relief map" {} -command {execute r.shaded.relief }} + {separator} + {command {[G_msg "Slope and aspect"]} {} "r.slope.aspect: Slope and aspect" {} -command {execute r.slope.aspect }} + {command {[G_msg "Terrain parameters"]} {} "r.param.scale: Terrain parameters" {} -command {execute r.param.scale }} + {command {[G_msg "Textural features"]} {} "r.texture: Textural features" {} -command {execute r.texture }} + {separator} + {command {[G_msg "Visibility"]} {} "r.los: Visibility/line of sight" {} -command {execute r.los }} }} + {cascad {[G_msg "Transform features"]} {} "" $tmenu { + {command {[G_msg "Clump"]} {} "r.clump: Clump small areas (statistics calculated by r.volume)" {} -command {execute r.clump }} + {command {[G_msg "Grow"]} {} "r.grow: Grow areas" {} -command {execute r.grow }} + {command {[G_msg "Thin"]} {} "r.thin: Thin linear features" {} -command {execute r.thin }} + }} {separator} - {cascad {[G_msg "Modeling: Hydrologic"]} {} "" $tmenu { - {command {[G_msg "Carve stream channels into elevation map using vector streams map"]} {} "r.carve" {} -command {execute r.carve }} - {command {[G_msg "Depressionless elevation map and flowline map"]} {} "r.fill.dir" {} -command {execute r.fill.dir }} - {command {[G_msg "Fill lake from seed point to specified level"]} {} "r.lake" {} -command {execute r.lake }} - {command {[G_msg "Flow accumulation for massive grids"]} {} "r.terraflow" {} -command {execute r.terraflow }} - {command {[G_msg "Generate flow lines for raster map"]} {} "r.flow" {} -command {execute r.flow }} - {command {[G_msg "SIMWE overland flow modeling"]} {} "r.sim.water" {} -command {execute r.sim.water }} - {command {[G_msg "SIMWE sediment erosion, transport, & deposition modeling"]} {} "r.sim.sediment" {} -command {execute r.sim.sediment }} - {command {[G_msg "Topographic index map"]} {} "r.topidx" {} -command {execute r.topidx }} - {command {[G_msg "TOPMODEL simulation"]} {} "r.topmodel" {} -command {execute r.topmodel }} - {command {[G_msg "Watershed subbasins"]} {} "r.basins.fill" {} -command {execute r.basins.fill }} - {command {[G_msg "Watershed analysis"]} {} "r.watershed" {} -command {execute r.watershed }} - {command {[G_msg "Watershed basin creation"]} {} "r.water.outlet" {} -command {execute r.water.outlet }} + {cascad {[G_msg "Universal Soil Loss Equation (USLE)"]} {} "" $tmenu { + {command {[G_msg "Rainfall Erosivity (R)"]} {} "r.usler" {} -command {execute r.usler }} + {command {[G_msg "Soil Erodibility (K)"]} {} "r.uslek" {} -command {execute r.uslek }} + {command {[G_msg "Length Slope and Slope (LS)"]} {} "r.watershed" {} -command {execute r.watershed }} }} - {cascad {[G_msg "Modeling: Landscape structure"]} {} "" $tmenu { - {command {[G_msg "Set up sampling and analysis framework"]} {} "r.le.setup" {} -command {guarantee_xmon; term r.le.setup }} + {cascad {[G_msg "Hydrologic modeling"]} {} "" $tmenu { + {command {[G_msg "Carve stream channels"]} {} "r.carve: Carve stream channels into elevation map using vector streams map" {} -command {execute r.carve }} + {command {[G_msg "Fill lake"]} {} "r.lake: Fill lake from seed point to specified level" {} -command {execute r.lake }} {separator} - {command {[G_msg "Analyze landscape characteristics"]} {} "r.le.pixel" {} -command {execute r.le.pixel }} - {command {[G_msg "Analyze landscape patch characteristics"]} {} " r.le.patch" {} -command {execute r.le.patch }} - {command {[G_msg "Output landscape patch information"]} {} "r.le.trace" {} -command {execute r.le.trace }} + {command {[G_msg "Depressionless map and flowlines"]} {} "r.fill.dir: Depressionless elevation map and flowline map" {} -command {execute r.fill.dir }} + {command {[G_msg "Flow accumulation"]} {} "r.terraflow: Flow accumulation for massive grids" {} -command {execute r.terraflow }} + {command {[G_msg "Flow lines"]} {} "r.flow: " {} -command {execute r.flow }} + {separator} + {command {[G_msg "SIMWE overland flow modeling"]} {} "r.sim.water: SIMWE overland flow modeling" {} -command {execute r.sim.water }} + {command {[G_msg "SIMWE sediment flux modeling"]} {} "r.sim.sediment: SIMWE sediment erosion, transport, & deposition modeling" {} -command {execute r.sim.sediment }} + {separator} + {command {[G_msg "Topographic index map"]} {} "r.topidx: Topographic index map" {} -command {execute r.topidx }} + {command {[G_msg "TOPMODEL simulation"]} {} "r.topmodel: TOPMODEL simulation" {} -command {execute r.topmodel }} + {separator} + {command {[G_msg "Watershed subbasins"]} {} "r.basins.fill: Watershed subbasins" {} -command {execute r.basins.fill }} + {command {[G_msg "Watershed analysis"]} {} "r.watershed: Watershed analysis" {} -command {execute r.watershed }} + {command {[G_msg "Watershed basin creation"]} {} "r.water.outlet: Watershed basin creation" {} -command {execute r.water.outlet }} }} - {cascad {[G_msg "Modeling: Landscape patch analysis"]} {} "" $tmenu { - {command {[G_msg "Configure and create patch map for analysis"]} {} "r.li.setup" {} -command {execute r.li.setup }} + {cascad {[G_msg "Landscape structure modeling"]} {} "" $tmenu { + {command {[G_msg "Set up"]} {} "r.le.setup: Set up sampling and analysis framework" {} -command { + unset env(GRASS_RENDER_IMMEDIATE) + guarantee_xmon + term r.le.setup + set env(GRASS_RENDER_IMMEDIATE) "TRUE"}} {separator} - {command {[G_msg "Calculate contrast weighted edge density index"]} {} "r.li.cwed" {} -command {execute r.li.cwed }} - {command {[G_msg "Calculate dominance's diversity index"]} {} "r.li.dominance" {} -command {execute r.li.dominance }} - {command {[G_msg "Calculate edge density index using a 4 neighbour algorithm"]} {} "r.li.edgedensity" {} -command {execute r.li.edgedensity }} - {command {[G_msg "Calculate mean patch size index using a 4 neighbour algorithm"]} {} " r.li.mps" {} -command {execute r.li.mps }} - {command {[G_msg "Calculate coefficient of variation of patch area"]} {} " r.li.padcv" {} -command {execute r.li.padcv }} - {command {[G_msg "Calculate range of patch area size"]} {} "r.li.padrange" {} -command {execute r.li.padrange }} - {command {[G_msg "Calculate standard deviation of patch area"]} {} "r.li.padsd" {} -command {execute r.li.padsd }} - {command {[G_msg "Calculate patch density index using a 4 neighbour algorithm"]} {} "r.li.patchdensity" {} -command {execute r.li.patchdensity }} - {command {[G_msg "Calculate patch number index using a 4 neighbour algorithm"]} {} "r.li.patchnum" {} -command {execute r.li.patchnum }} - {command {[G_msg "Calculate dominance's diversity index"]} {} "r.li.shannon" {} -command {execute r.li.shannon }} - {command {[G_msg "Calculate Shannon's diversity index"]} {} "r.li.richness" {} -command {execute r.li.richness }} - {command {[G_msg "Calculate shape index"]} {} "r.li.shape" {} -command {execute r.li.shape }} - {command {[G_msg "Calculate Simpson's diversity index"]} {} "r.li.simpson" {} -command {execute r.li.simpson }} + {command {[G_msg "Analyze landscape"]} {} "r.le.pixel: Analyze landscape characteristics" {} -command {execute r.le.pixel }} + {command {[G_msg "Analyze patches"]} {} " r.le.patch: Analyze landscape patch characteristics" {} -command {execute r.le.patch }} + {command {[G_msg "Output"]} {} "r.le.trace: Output landscape patch information" {} -command {execute r.le.trace }} }} - {cascad {[G_msg "Modeling: Terrain and solar"]} {} "" $tmenu { - {command {[G_msg "Calculate cumulative movement costs between locales"]} {} "r.walk" {} -command {execute r.walk }} - {command {[G_msg "Cost surface"]} {} "r.cost" {} -command {execute r.cost }} - {command {[G_msg "Least cost route or flow"]} {} "r.drain" {} -command {execute r.drain }} + {cascad {[G_msg "Landscape patch analysis"]} {} "" $tmenu { + {command {[G_msg "Set up sampling and analysis framework"]} {} "r.li.setup: Configure and create patch map for analysis" {} -command {execute r.li.setup }} {separator} - {command {[G_msg "Shaded relief map"]} {} "r.shaded.relief" {} -command {execute r.shaded.relief }} - {command {[G_msg "Slope and aspect"]} {} "r.slope.aspect" {} -command {execute r.slope.aspect }} - {command {[G_msg "Terrain parameters"]} {} "r.param.scale" {} -command {execute r.param.scale }} + {command {[G_msg "Edge density"]} {} "r.li.edgedensity: Calculate edge density index using a 4 neighbour algorithm" {} -command {execute r.li.edgedensity }} + {command {[G_msg "Contrast weighted edge density"]} {} "r.li.cwed: Calculate contrast weighted edge density index" {} -command {execute r.li.cwed }} {separator} - {command {[G_msg "Textural features"]} {} "r.texture" {} -command {execute r.texture }} - {command {[G_msg "Visibility/line of sight"]} {} "r.los" {} -command {execute r.los }} + {command {[G_msg "Patch size mean"]} {} "r.li.mps: Calculate mean patch size index using a 4 neighbour algorithm" {} -command {execute r.li.mps }} + {command {[G_msg "Patch area range"]} {} "r.li.padrange: Calculate range of patch area size" {} -command {execute r.li.padrange }} + {command {[G_msg "Patch area Std Dev"]} {} "r.li.padsd: Calculate standard deviation of patch area" {} -command {execute r.li.padsd }} + {command {[G_msg "Patch area Coeff Var"]} {} "r.li.padcv: Calculate coefficient of variation of patch area" {} -command {execute r.li.padcv }} + {command {[G_msg "Patch density"]} {} "r.li.patchdensity: Calculate patch density index using a 4 neighbour algorithm" {} -command {execute r.li.patchdensity }} + {command {[G_msg "Patch number"]} {} "r.li.patchnum: Calculate patch number index using a 4 neighbour algorithm" {} -command {execute r.li.patchnum }} {separator} - {command {[G_msg "Solar irradiance and daily irradiation"]} {} "r.sun" {} -command {execute r.sun }} - {command {[G_msg "Shadows map for sun position or date/time"]} {} "r.sunmask" {} -command {execute r.sunmask }} + {command {[G_msg "Dominance's diversity"]} {} "r.li.dominance: Calculate Dominance's diversity index" {} -command {execute r.li.dominance }} + {command {[G_msg "Shannon's diversity"]} {} "r.li.shannon: Calculate Shannon's diversity index" {} -command {execute r.li.shannon }} + {command {[G_msg "Simpson's diversity"]} {} "r.li.simpson: Calculate Simpson's diversity index" {} -command {execute r.li.simpson }} + {separator} + {command {[G_msg "Ricness"]} {} "r.li.richness: Calculate ricness index" {} -command {execute r.li.richness }} + {command {[G_msg "Shape index"]} {} "r.li.shape: Calculate shape index" {} -command {execute r.li.shape }} }} - {separator} - {cascad {[G_msg "Modeling: Universal Soil Loss Equation (USLE)"]} {} "" $tmenu { - {command {[G_msg "Rainfall Erosivity (R)"]} {} "r.usler" {} -command {execute r.usler }} - {command {[G_msg "Soil Erodibility (K)"]} {} "r.uslek" {} -command {execute r.uslek }} - {command {[G_msg "Length Slope and Slope (LS)"]} {} "r.watershed" {} -command {execute r.watershed }} + {cascad {[G_msg "Wildfire modeling"]} {} "" $tmenu { + {command {[G_msg "Rate of spread"]} {} "r.ros: Generate rate of spread (ROS) maps" {} -command {execute r.ros }} + {command {[G_msg "Least-cost spread paths"]} {} "r.spreadpath: Generate least-cost spread paths" {} -command {execute r.spreadpath }} + {command {[G_msg "Anisotropic spread simulation"]} {} "r.spread: Simulate anisotropic spread phenomena" {} -command {execute r.spread }} }} - {cascad {[G_msg "Modeling: Wildfire modeling"]} {} "" $tmenu { - {command {[G_msg "Generate rate of spread (ROS) maps"]} {} "r.ros" {} -command {execute r.ros }} - {command {[G_msg "Generate least-cost spread paths"]} {} "r.spreadpath" {} -command {execute r.spreadpath }} - {command {[G_msg "Simulate anisotropic spread phenomena"]} {} "r.spread" {} -command {execute r.spread }} - }} {separator} {cascad {[G_msg "Change category values and labels"]} {} "" $tmenu { - {command {[G_msg "Edit category values of individual cells for displayed raster map"]} {} "d.rast.edit" {} \ - -command {guarantee_xmon; term d.rast.edit }} + {command {[G_msg "Interactively edit category values"]} {} "d.rast.edit: Edit category values of individual cells for displayed raster map" {} -command {execute d.rast.edit }} {separator} - {command {[G_msg "Reclassify categories for areas of specified sizes"]} {} "r.reclass.area" {} -command {execute r.reclass.area }} - {command {[G_msg "Reclassify categories using rules"]} {} "r.reclass.rules" {} -command {execute $env(GISBASE)/etc/gm/script/r.reclass.rules }} - {command {[G_msg "Reclassify categories using rules file"]} {} "r.reclass.file" {} -command {execute $env(GISBASE)/etc/gm/script/r.reclass.file }} + {command {[G_msg "Reclassify by size"]} {} "r.reclass.area: Reclassify categories for areas of specified sizes" {} -command {execute r.reclass.area }} + {command {[G_msg "Reclassify interactively"]} {} "Reclassify categories interactively by entering reclass rules" {} -command {GmRules::main "r.reclass" }} + {command {[G_msg "Reclassify using rules file"]} {} "r.reclass: Reclassify categories by inputting rules from a text file" {} -command {execute r.reclass}} {separator} - {command {[G_msg "Recode categories using rules (create new map)"]} {} "r.recode.rules" {} -command {execute $env(GISBASE)/etc/gm/script/r.recode.rules }} - {command {[G_msg "Recode categories using rules file (create new map)"]} {} "r.recode.file " {} -command {execute $env(GISBASE)/etc/gm/script/r.recode.file }} + {command {[G_msg "Recode interactively"]} {} "Recode categories interactively by entering recode rules (create new map)" {} -command {GmRules::main "r.recode" }} + {command {[G_msg "Recode using rules file"]} {} "r.recode: Recode categories by inputting rules from a text file (create new map)" {} -command {execute r.recode }} {separator} - {command {[G_msg "Rescale categories (create new map)"]} {} "r.rescale" {} -command {execute r.rescale }} - {command {[G_msg "Rescale categories with equalized histogram (create new map)"]} {} "r.rescale.eq" {} -command {execute r.rescale.eq }} + {command {[G_msg "Rescale"]} {} "r.rescale: Rescale categories (create new map)" {} -command {execute r.rescale }} + {command {[G_msg "Rescale with histogram"]} {} "r.rescale.eq: Rescale categories with equalized histogram (create new map)" {} -command {execute r.rescale.eq }} }} {separator} - {cascad {[G_msg "Generate"]} {} "" $tmenu { - {command {[G_msg "Concentric circles around points"]} {} "r.circle" {} -command { execute r.circle }} - {command {[G_msg "Density surface using moving Gausian kernal"]} {} "v.kernel" {} -command {execute v.kernel }} - {command {[G_msg "Fractal surface"]} {} "r.surf.fractal" {} -command {execute r.surf.fractal }} - {command {[G_msg "Gaussian deviates surface"]} {} "r.surf.gauss" {} -command {execute r.surf.gauss }} - {command {[G_msg "Plane"]} {} "r.plane" {} -command {execute r.plane }} + {command {[G_msg "Concentric circles"]} {} "r.circle: Generate concentric circles around points" {} -command { execute r.circle }} + {cascad {[G_msg "Generate random cells"]} {} "" $tmenu { + {command {[G_msg "Random cells"]} {} "r.random.cells: Generate random cells" {} -command {execute r.random.cells }} + {command {[G_msg "Random cells and vector points"]} {} "r.random: Generate random cells and vector points from raster map" {} -command {execute r.random }} + }} + {cascad {[G_msg "Generate surfaces"]} {} "" $tmenu { + {command {[G_msg "Fractal surface"]} {} "r.surf.fractal: Generate fractal surface" {} -command {execute r.surf.fractal }} {separator} - {command {[G_msg "Random cells"]} {} "r.random.cells" {} -command {execute r.random.cells }} - {command {[G_msg "Random cells and vector points from raster map"]} {} "r.random" {} -command {execute r.random }} - {command {[G_msg "Random deviates surface"]} {} "r.surf.random" {} -command {execute r.surf.random }} - {command {[G_msg "Random surface with spatial dependence"]} {} "r.random.surface" {} -command {execute r.random.surface }} + {command {[G_msg "Gausian kernal density surface"]} {} "v.kernel: Generate density surface using moving Gausian kernal" {} -command {execute v.kernel }} + {command {[G_msg "Gaussian deviates surface"]} {} "r.surf.gauss: Generate gaussian deviates surface" {} -command {execute r.surf.gauss }} {separator} - {command {[G_msg "Vector contour lines"]} {} "r.contour" {} -command { execute r.contour }} + {command {[G_msg "Plane"]} {} "r.plane: Generate plane" {} -command {execute r.plane }} + {separator} + {command {[G_msg "Random deviates surface"]} {} "r.surf.random: Generate random deviates surface" {} -command {execute r.surf.random }} + {command {[G_msg "Random surface with spatial dependence"]} {} "r.random.surface: Generate random surface with spatial dependence" {} -command {execute r.random.surface }} }} + {command {[G_msg "Contour lines"]} {} "r.contour: Generate vector contour lines" {} -command { execute r.contour }} {cascad {[G_msg "Interpolate surfaces"]} {} "" $tmenu { - {command {[G_msg "Bicubic and bilinear interpolation with Tykhonov regularization from vector points"]} {} "v.surf.bspline" {} -command { execute v.surf.bspline }} - {command {[G_msg "Bilinear interpolation from raster points"]} {} "r.bilinear" {} -command { execute r.bilinear }} - {command {[G_msg "Inverse distance weighted interpolation from raster points"]} {} "r.surf.idw" {} -command { execute r.surf.idw }} - {command {[G_msg "Interpolation from raster contours"]} {} "r.surf.contour" {} -command { execute r.surf.contour }} + {command {[G_msg "Bilinear from raster points"]} {} "r.bilinear: Bilinear interpolation from raster points" {} -command { execute r.bilinear }} + {command {[G_msg "Bilinear and bicubic from vector points"]} {} "v.surf.bspline: Bicubic and bilinear interpolation with Tykhonov regularization from vector points" {} -command { execute v.surf.bspline }} {separator} - {command {[G_msg "Inverse distance weighted interpolation from vector points"]} {} "v.surf.idw" {} -command { execute v.surf.idw }} - {command {[G_msg "Regularized spline tension interpolation from vector points or contours"]} {} "v.surf.rst" {} -command { execute v.surf.rst }} + {command {[G_msg "IDW from raster points"]} {} "r.surf.idw: Inverse distance weighted interpolation from raster points" {} -command { execute r.surf.idw }} + {command {[G_msg "IDW from vector points"]} {} "v.surf.idw: Inverse distance weighted interpolation from vector points" {} -command { execute v.surf.idw }} {separator} - {command {[G_msg "Fill NULL cells by interpolation using regularized spline tension"]} {} " r.fillnulls" {} -command {execute r.fillnulls }} + {command {[G_msg "Raster contours"]} {} "r.surf.contour: Interpolation from raster contours" {} -command { execute r.surf.contour }} + {command {[G_msg "Regularized spline tension"]} {} "v.surf.rst: Regularized spline tension interpolation from vector points or contours" {} -command { execute v.surf.rst }} + {separator} + {command {[G_msg "Fill NULL cells"]} {} " r.fillnulls: Fill NULL cells by interpolation using regularized spline tension" {} -command {execute r.fillnulls }} }} {separator} {cascad {[G_msg "Reports and statistics"]} {} "" $tmenu { - {command {[G_msg "Report basic file information"]} {} "r.info" {} -command {execute r.info }} - {command {[G_msg "Report category labels and values"]} {} "r.cats" {} -command {execute r.cats }} + {command {[G_msg "Report basic file information"]} {} "r.info: Report basic file information" {} -command {execute r.info }} + {command {[G_msg "Report category information"]} {} "r.cats: Report category labels and values" {} -command {execute r.cats }} {separator} - {command {[G_msg "General statistics"]} {} "r.stats" {} -command {execute r.stats }} - {command {[G_msg "Range of all category values"]} {} "r.describe" {} -command {execute r.describe }} - {command {[G_msg "Sum all cell category values"]} {} "r.sum" {} -command {execute r.sum }} - {command {[G_msg "Sum area by map and category"]} {} "r.report" {} -command {execute r.report }} - {command {[G_msg "Summary statistics for clumped cells (works with r.clump)"]} {} "r.volume" {} -command {execute r.volume }} + {command {[G_msg "General statistics"]} {} "r.stats: General statistics" {} -command {execute r.stats }} + {command {[G_msg "Range of category values"]} {} "r.describe: Range of all category values" {} -command {execute r.describe }} + {command {[G_msg "Sum cell category values"]} {} "r.sum: Sum all cell category values" {} -command {execute r.sum }} + {command {[G_msg "Sum area by map and category"]} {} "r.report:Sum area by map and category" {} -command {execute r.report }} + {command {[G_msg "Statistics for clumped cells (works with r.clump)"]} {} "r.volume: " {} -command {execute r.volume }} + {command {[G_msg "Total surface area corrected for topography"]} {} "r.surf.area: Total surface area corrected for topography" {} -command {execute r.surf.area }} + {command {[G_msg "Univariate statistics"]} {} "r.univar: Univariate statistics" {} -command {execute r.univar }} {separator} - {command {[G_msg "Total surface area corrected for topography"]} {} "r.surf.area" {} -command {execute r.surf.area }} - {command {[G_msg "Univariate statistics"]} {} "r.univar" {} -command {execute r.univar }} - {command {[G_msg "Univariate statistics (script version)"]} {} " r.univar" {} -command {execute r.univar }} + {command {[G_msg "Sample transects"]} {} "r.profile: Sample values along transects" {} -command {execute r.profile }} + {command {[G_msg "Sample transects (bearing/distance)"]} {} " r.transect: Sample values along transects (use azimuth, distance)" {} -command {execute r.transect }} {separator} - {command {[G_msg "Sample values along transects"]} {} "r.profile" {} -command {execute r.profile }} - {command {[G_msg "Sample values along transects (use azimuth, distance)"]} {} " r.transect" {} -command {execute r.transect }} - {separator} - {command {[G_msg "Covariance/correlation"]} {} "r.covar" {} -command {execute r.covar }} - {command {[G_msg "Linear regression between 2 maps"]} {} "r.regression.line" {} -command {execute r.regression.line }} - {command {[G_msg "Mutual category occurences (coincidence)"]} {} "r.coin" {} -command {execute r.coin }} + {command {[G_msg "Covariance/correlation"]} {} "r.covar: Covariance/correlation" {} -command {execute r.covar }} + {command {[G_msg "Linear regression"]} {} "r.regression.line: Linear regression between 2 maps" {} -command {execute r.regression.line }} + {command {[G_msg "Mutual category occurences"]} {} "r.coin: Mutual category occurences (coincidence)" {} -command {execute r.coin }} }} } {[G_msg "&Vector"]} all options $tmenu { {cascad {[G_msg "Develop map"]} {} "" $tmenu { - {command {[G_msg "Digitize"]} {} "v.digit" {} -command {execute v.digit }} + {command {[G_msg "Digitize"]} {} "v.digit: Digitize/edit vector map" {} -command {execute v.digit }} {separator} - {command {[G_msg "Create/rebuild topology"]} {} "v.build" {} -command {execute v.build }} - {command {[G_msg "Clean vector files"]} {} "v.clean" {} -command {execute v.clean }} - {command {[G_msg "Add missing centroids"]} {} "v.centroids" {} -command {execute v.centroids }} + {command {[G_msg "Create/rebuild topology: "]} {} "v.build: Create or rebuild topology of vector objects" {} -command {execute v.build }} + {command {[G_msg "Clean vector"]} {} "v.clean: Clean vector objects" {} -command {execute v.clean }} {separator} - {command {[G_msg "Build polylines from adjacent segments"]} {} "v.build.polylines" {} -command {execute v.build.polylines }} - {command {[G_msg "Split polylines into segments"]} {} "v.segment" {} -command {execute v.segment }} - {command {[G_msg "Create lines parallel to existing lines"]} {} "v.parallel" {} -command {execute v.parallel }} - {command {[G_msg "Dissolve common boundaries"]} {} "v.dissolve" {} -command {execute v.dissolve }} + {command {[G_msg "Convert object types"]} {} "v.type: Convert vector objects from one feature type to another" {} -command {execute $env(GISBASE)/etc/gui/scripts/v.type.sh }} {separator} - {command {[G_msg "Convert vector feature types"]} {} "v.type" {} -command {execute v.type }} - {command {[G_msg "Convert 2D vector to 3D by sampling raster"]} {} "v.drape" {} -command {execute v.drape }} - {command {[G_msg "Extrude 2D vector into 3D vector"]} {} "v.extrude" {} -command {execute v.extrude }} + {command {[G_msg "Add centroids"]} {} "v.centroids: Add centroids to closed boundaries to create areas" {} -command {execute v.centroids }} {separator} - {command {[G_msg "Create new vector as link to external OGR layer"]} {} "v.external" {} -command {execute v.external }} + {command {[G_msg "Build polylines"]} {} "v.build.polylines: Build polylines from adjacent segments" {} -command {execute v.build.polylines }} + {command {[G_msg "Split polylines"]} {} "v.segment: Split polylines into points and segments" {} -command {execute v.segment }} + {command {[G_msg "Parallel lines"]} {} "v.parallel: Create lines parallel to existing lines" {} -command {execute v.parallel }} {separator} - {command {[G_msg "Create text label file for vector features"]} {} "v.label" {} -command {execute v.label }} + {command {[G_msg "Dissolve boundaries"]} {} "v.dissolve: Dissolve common boundaries of areas" {} -command {execute v.dissolve }} {separator} - {command {[G_msg "Reproject vector from other location"]} {} "v.proj" {} -command {execute v.proj }} + {command {[G_msg "Create 3D vector over raster"]} {} "v.drape: Create 3D objects by sampling raster with 2D vector" {} -command {execute v.drape }} + {command {[G_msg "Extrude 3D vector"]} {} "v.extrude: Extrude 3D objects from 2D vector" {} -command {execute v.extrude }} + {separator} + {command {[G_msg "Link to OGR"]} {} "v.external: Create new vector as link to external OGR layer" {} -command {execute v.external }} + {separator} + {command {[G_msg "Create labels"]} {} "v.label: Create text label file for vector objects" {} -command {execute v.label }} + {separator} + {command {[G_msg "Reposition vector"]} {} "v.transform: Reposition (shift, rotate, skew) vector file in coordinate space" {} -command {execute v.transform }} + {command {[G_msg "Reproject vector"]} {} "v.proj: Reproject vector from other location" {} -command {execute v.proj }} }} - {command {[G_msg "Rectify and georeference vector map"]} {} "v.transform" {} -command {execute v.transform }} {separator} - {command {[G_msg "Query by attributes"]} {} "v.extract" {} -command {execute v.extract }} - {command {[G_msg "Query by coordinate(s)"]} {} "v.what" {} -command { execute v.what }} - {command {[G_msg "Query by map features"]} {} " v.select" {} -command {execute v.select }} + {command {[G_msg "Query with attributes"]} {} "v.extract: Query vector objects by attribute values" {} -command {execute v.extract }} + {command {[G_msg "Query with coordinate(s)"]} {} "v.what: Query vector objects by coordinate(s)" {} -command { execute v.what }} + {command {[G_msg "Query with another map"]} {} " v.select: Query objects using objects from a second map" {} -command {execute v.select }} {separator} - {command {[G_msg "Create vector buffers"]} {} "v.buffer" {} -command {execute v.buffer }} - {cascad {[G_msg "Lidar object filtering and detection"]} {} "" $tmenu { - {command {[G_msg "Detect object edges in LIdar data"]} {} "v.lidar.edgedetection" {} -command {execute v.lidar.edgedetection }} - {command {[G_msg "Detect interior of objects in Lidar data"]} {} "v.lidar.growing" {} -command {execute v.lidar.growing }} - {command {[G_msg "Correct and reclassify objects detected in Lidar data"]} {} "v.lidar.correction" {} -command {execute v.lidar.correction }} + {command {[G_msg "Buffer vectors"]} {} "v.buffer: Create vector buffers around vector objects" {} -command {execute v.buffer }} + {cascad {[G_msg "Lidar analysis"]} {} "" $tmenu { + {command {[G_msg "Detect edges"]} {} "v.lidar.edgedetection: Detect object edges in Lidar data" {} -command {execute v.lidar.edgedetection }} + {command {[G_msg "Detect interiors"]} {} "v.lidar.growing: Detect interiors of objects in Lidar data" {} -command {execute v.lidar.growing }} + {command {[G_msg "Correct and reclassify objects"]} {} "v.lidar.correction: Correct and reclassify objects detected in Lidar data" {} -command {execute v.lidar.correction }} }} - {cascad {[G_msg "Linear referencing for vectors"]} {} "" $tmenu { - {command {[G_msg "Create linear reference system"]} {} "v.lrs.create" {} -command {execute v.lrs.create }} - {command {[G_msg "Create stationing from imput lines, and linear reference system"]} {} "v.lrs.label" {} -command {execute v.lrs.label }} - {command {[G_msg "Create points/segments from input lines, linear reference system and positions read from stdin"]} {} "v.lrs.segment" {} -command {execute v.lrs.segment }} - {command {[G_msg "Find line id and real km+offset for given points in vector map using linear reference system"]} {} "v.lrs.where" {} -command {execute v.lrs.where }} - }} - {cascad {[G_msg "Neighborhood analysis"]} {} "" $tmenu { - {command {[G_msg "Locate nearest features to points or centroids"]} {} "v.distance" {} -command {execute v.distance }} - {command {[G_msg "Generate Thiessen polygons around points (Voronoi diagram)"]} {} "v.voronoi" {} -command {execute v.voronoi }} - {command {[G_msg "Connect points to create Delaunay triangles"]} {} "v.delaunay" {} -command {execute v.delaunay }} - }} + {cascad {[G_msg "Linear referencing"]} {} "" $tmenu { + {command {[G_msg "Create LRS"]} {} "v.lrs.create: Create linear reference system" {} -command {execute v.lrs.create }} + {command {[G_msg "Create stationing"]} {} "v.lrs.label: Create stationing from input lines and a linear reference system" {} -command {execute v.lrs.label }} + {command {[G_msg "Create points/segments"]} {} "v.lrs.segment: Create points and line segments along a linear reference system" {} -command {execute v.lrs.segment }} + {command {[G_msg "Find ID and offset"]} {} "v.lrs.where: Find line ID and real km+offset for given points in vector map using linear reference system" {} -command {execute v.lrs.where }} + }} + {command {[G_msg "Nearest features"]} {} "v.distance: Locate nearest features to points or centroids" {} -command {execute v.distance }} {cascad {[G_msg "Network analysis"]} {} "" $tmenu { - {command {[G_msg "Allocate subnets"]} {} "v.net.alloc" {} -command {execute v.net.alloc }} - {command {[G_msg "Network maintenance"]} {} "v.net" {} -command {execute v.net }} - {command {[G_msg "Shortest route"]} {} "v.net.path" {} -command {execute v.net.path }} - {command {[G_msg "Shortest route (visualization only)"]} {} "d.path" {} -command {guarantee_xmon; spawn d.path.sh -b --ui }} - {command {[G_msg "Split net to bands between cost isolines"]} {} "v.net.iso" {} -command {execute v.net.iso }} - {command {[G_msg "Steiner tree"]} {} "v.net.steiner" {} -command {execute v.net.steiner }} - {command {[G_msg "Traveling salesman analysis"]} {} "v.net.salesman" {} -command {execute v.net.salesman }} + {command {[G_msg "Allocate subnets"]} {} "v.net.alloc: Allocate subnets for nearest centers" {} -command {execute v.net.alloc }} + {command {[G_msg "Network maintenance"]} {} "v.net: Network maintenance" {} -command {execute v.net }} + {command {[G_msg "Shortest route"]} {} "v.net.path: Calculate shortest route along network between 2 nodes" {} -command {execute v.net.path }} + {command {[G_msg "Display shortest route"]} {} "d.path: Display shortest route along network between 2 nodes (visualization only)" {} -command { + unset env(GRASS_RENDER_IMMEDIATE) + guarantee_xmon + spawn d.path.sh -b --ui + set env(GRASS_RENDER_IMMEDIATE) "TRUE"}} + {command {[G_msg "Split net"]} {} "v.net.iso: Split net into bands between cost isolines" {} -command {execute v.net.iso }} + {command {[G_msg "Steiner tree"]} {} "v.net.steiner: Create Steiner tree for network and given terminals" {} -command {execute v.net.steiner }} + {command {[G_msg "Traveling salesman analysis"]} {} "v.net.salesman: Calculate shortest route connecting given set of nodes (Traveling salesman analysis)" {} -command {execute v.net.salesman }} }} {cascad {[G_msg "Overlay maps"]} {} "" $tmenu { - {command {[G_msg "Overlay/combine 2 vector maps"]} {} "v.overlay" {} -command {execute v.overlay }} - {command {[G_msg "Patch multiple maps (combine)"]} {} "v.patch" {} -command {execute v.patch }} + {command {[G_msg "Overlay"]} {} "v.overlay: Boolean overlay of 2 vector maps" {} -command {execute v.overlay }} + {command {[G_msg "Patch (combine)"]} {} "v.patch: Patch/combine multiple maps (Boolean OR)" {} -command {execute v.patch }} }} - {command {[G_msg "Generate area feature for extent of current region"]} {} "v.in.region" {} -command {execute v.in.region }} - {command {[G_msg "Generate rectangular vector grid"]} {} "v.mkgrid" {} -command {execute v.mkgrid }} {separator} {cascad {[G_msg "Change attributes"]} {} "" $tmenu { - {command {[G_msg "Attach, delete, or report categories"]} {} "v.category" {} -command {execute v.category }} - {command {[G_msg "Reclassify features using rules file"]} {} "v.reclass" {} -command {execute v.reclass }} + {command {[G_msg "Manage or report categories"]} {} "v.category: Attach, delete, or report categories" {} -command {execute v.category }} + {command {[G_msg "Reclassify objects interactively"]} {} "Reclassify objects interactively by entering SQL rules" {} -command {GmRules::main "v.reclass" }} + {command {[G_msg "Reclassify using rules file"]} {} "v.reclass: Reclassify objects by inputting rules from a text file" {} -command {execute v.reclass }} }} {separator} - {cascad {[G_msg "Work with vector points"]} {} "" $tmenu { - {cascad {[G_msg "Generate points"]} {} "" $tmenu { - {command {[G_msg "Generate points from database with x/y coordinates"]} {} "v.in.db" {} -command {execute v.in.db }} - {command {[G_msg "Generate random points"]} {} "v.random" {} -command {execute v.random }} - {command {[G_msg "Random location perturbations of points"]} {} "v.perturb" {} -command {execute v.perturb }} - }} - {cascad {[G_msg "Generate areas from points"]} {} "" $tmenu { - {command {[G_msg "Generate convex hull for point set"]} {} "v.hull" {} -command {execute v.hull }} - {command {[G_msg "Generate Delaunay triangles for point set"]} {} "v.delaunay" {} -command {execute v.delaunay }} - {command {[G_msg "Generate Voronoi diagram/Thiessen polygons for point set"]} {} "v.voronoi" {} -command {execute v.voronoi }} - }} - {cascad {[G_msg "Sample raster maps"]} {} "" $tmenu { - {command {[G_msg "Calculate statistics for raster map overlain by vector map"]} {} "v.rast.stats" {} -command {execute v.rast.stats }} - {command {[G_msg "Sample raster map at point locations"]} {} "v.what.rast" {} -command {execute v.what.rast }} - {command {[G_msg "Sample raster neighborhood around points"]} {} "v.sample" {} -command {execute v.sample }} - }} - {command {[G_msg "Partition points into test/training sets for k-fold cross validatation"]} {} "v.kcv" {} -command {execute v.kcv }} - {command {[G_msg "Remove outliers from vector point set"]} {} "v.outlier" {} -command {execute v.outlier }} - {command {[G_msg "Transfer attribute data from queried vector map to points"]} {} "v.what.vect" {} -command {execute v.what.vect }} + {command {[G_msg "Generate area for current region"]} {} "v.in.region: Generate area object for extent of current region" {} -command {execute v.in.region }} + {cascad {[G_msg "Generate areas from points"]} {} "" $tmenu { + {command {[G_msg "Convex hull"]} {} "v.hull: Generate convex hull for point set" {} -command {execute v.hull }} + {command {[G_msg "Delaunay triangles"]} {} "v.delaunay: Generate Delaunay triangles for point set" {} -command {execute v.delaunay }} + {command {[G_msg "Voronoi diagram/Thiessen polygons"]} {} "v.voronoi: Generate Voronoi diagram/Thiessen polygons for point set" {} -command {execute v.voronoi }} }} + {command {[G_msg "Generate grid"]} {} "v.mkgrid: Generate rectangular vector grid" {} -command {execute v.mkgrid }} + {cascad {[G_msg "Generate points"]} {} "" $tmenu { + {command {[G_msg "Generate points from database"]} {} "v.in.db: Generate points from database with x/y coordinates" {} -command {execute v.in.db }} + {command {[G_msg "Generate points along lines"]} {} "v.to.points: Generate points along vector lines/boundaries" {} -command {execute v.to.points }} + {command {[G_msg "Generate random points"]} {} "v.random: Generate random points" {} -command {execute v.random }} + {command {[G_msg "Perturb points"]} {} "v.perturb: Random perturbations of point locations" {} -command {execute v.perturb }} + }} {separator} + {command {[G_msg "Remove outliers in point sets"]} {} "v.outlier: Remove outliers from vector point set" {} -command {execute v.outlier }} + {command {[G_msg "Test/training sets"]} {} "v.kcv: Partition points into test/training sets for k-fold cross validatation" {} -command {execute v.kcv }} + {separator} + {command {[G_msg "Update area attributes from raster"]} {} "v.rast.stats: Update area attribute data from univariate statistics on raster map" {} -command {execute v.rast.stats }} + {command {[G_msg "Update point attributes from areas"]} {} "v.what.vect: Update point attribute data from vector area map" {} -command {execute v.what.vect }} + {cascad {[G_msg "Update point attributes from raster"]} {} "" $tmenu { + {command {[G_msg "Sample raster map at point locations"]} {} "v.what.rast: " {} -command {execute v.what.rast }} + {command {[G_msg "Sample raster neighborhood around points"]} {} "v.sample: " {} -command {execute v.sample }} + }} + {separator} {cascad {[G_msg "Reports and statistics"]} {} "" $tmenu { - {command {[G_msg "Basic information"]} {} "v.info" {} -command {execute v.info }} - {command {[G_msg "Load vector attributes to database or create reports"]} {} "v.to.db" {} -command {execute v.to.db }} - {command {[G_msg "Report areas for vector attribute categories"]} {} "v.report" {} -command {execute v.report }} - {command {[G_msg "Univariate statistics"]} {} "v.univar" {} -command {execute v.univar }} + {command {[G_msg "Basic information"]} {} "v.info: Basic information" {} -command {execute v.info }} {separator} - {command {[G_msg "Test normality of point distribution"]} {} "v.normal" {} -command {execute v.normal }} - {command {[G_msg "Calculate stats for raster map underlying vector objects"]} {} "v.rast.stats" {} -command {execute v.rast.stats }} - {command {[G_msg "Indices of point counts in quadrats"]} {} "v.qcount" {} -command {execute v.qcount }} + {command {[G_msg "Report topology by category"]} {} "v.report: Report areas for vector attribute categories" {} -command {execute v.report }} + {command {[G_msg "Upload or report topology"]} {} "v.to.db: Update database fields or create reports from vector topology" {} -command {execute v.to.db }} + {separator} + {command {[G_msg "Univariate attribute statistics"]} {} "v.univar: Calculate univariate statistics for vector attributes" {} -command {execute v.univar }} + {separator} + {command {[G_msg "Quadrat indices"]} {} "v.qcount: Indices of point counts in quadrats" {} -command {execute v.qcount }} + {command {[G_msg "Test normality"]} {} "v.normal: Test normality of point distribution" {} -command {execute v.normal }} }} } {[G_msg "&Imagery"]} all options $tmenu { {cascad {[G_msg "Develop images and groups"]} {} "" $tmenu { - {command {[G_msg "Create/edit imagery group"]} {} "i.group" {} -command {execute i.group }} - {command {[G_msg "Target imagery group"]} {} "i.target" {} -command {execute i.target }} + {command {[G_msg "Create/edit group"]} {} "i.group: Create/edit imagery group" {} -command {execute i.group }} + {command {[G_msg "Target group"]} {} "i.target: Target imagery group" {} -command {execute i.target }} {separator} - {command {[G_msg "Mosaic up to 4 adjacent images"]} {} "i.image.mosaic" {} -command {execute i.image.mosaic }} + {command {[G_msg "Mosaic images"]} {} "i.image.mosaic: Mosaic up to 4 adjacent images" {} -command {execute i.image.mosaic }} }} {cascad {[G_msg "Manage image colors"]} {} "" $tmenu { - {command {[G_msg "Color balance/enhance color tables for rgb display"]} {} "i.landsat.rgb" {} -command {execute i.landsat.rgb }} - {command {[G_msg "Transform HIS to RGB"]} {} "i.his.rgb" {} -command {execute i.his.rgb }} - {command {[G_msg "Transform RGB to HIS"]} {} "i.rgb.his" {} -command {execute i.rgb.his }} + {command {[G_msg "Color balance for RGB"]} {} "i.landsat.rgb: Color balance and enhance color tables of multiband imagery for rgb display" {} -command {execute i.landsat.rgb }} + {command {[G_msg "HIS to RGB"]} {} "i.his.rgb: Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)" {} -command {execute i.his.rgb }} + {command {[G_msg "RGB to HIS"]} {} "i.rgb.his: Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)" {} -command {execute i.rgb.his }} }} - {cascad {[G_msg "Rectify and georeference image group"]} {} "" $tmenu { - {command {[G_msg "Set ground control points (GCP's) from raster map or keyboard entry"]} {} "i.points" {} \ - -command {guarantee_xmon; term i.points }} - {command {[G_msg "Set ground control points (GCP's) from vector map or keyboard entry"]} {} "i.vpoints" {} \ - -command {guarantee_xmon; term i.vpoints }} - {command {[G_msg "Affine and Polynomial rectification (rubber sheet)"]} {} "i.rectify" {} -command {execute i.rectify }} - {command {[G_msg "Ortho photo rectification"]} {} "i.ortho.photo" {} -command {term i.ortho.photo }} - }} + {command {[G_msg "Ortho photo rectification"]} {} "i.ortho.photo: Ortho photo rectification" {} -command { + unset env(GRASS_RENDER_IMMEDIATE) + guarantee_xmon + term i.ortho.photo + set env(GRASS_RENDER_IMMEDIATE) "TRUE"}} {separator} {cascad {[G_msg "GIPE"]} {} "" $tmenu { {cascad {[G_msg "DN2Rad2Ref"]} {} "" $tmenu { @@ -582,99 +593,81 @@ }} }} {cascad {[G_msg "Classify image"]} {} "" $tmenu { - {cascad {[G_msg "Classify image using pr library"]} {} "" $tmenu { - {command {[G_msg "pr_blob"]} {} "i.pr_blob" {} -command {execute i.pr_blob }} - {command {[G_msg "pr_classify"]} {} "pr_classify" {} -command {execute i.pr_classify}} - {command {[G_msg "pr_features"]} {} "pr_features" {} -command {execute i.pr_features}} - {command {[G_msg "pr_features_additional"]} {} "pr_features_additional" {} -command {execute i.pr_features_additional}} - {command {[G_msg "pr_features_extract"]} {} "pr_features_extract" {} -command {execute i.pr_features_extract}} - {command {[G_msg "pr_features_selection"]} {} "pr_features_selection" {} -command {execute i.pr_features_selection}} - {command {[G_msg "pr_model"]} {} "pr_model" {} -command {execute i.pr_model}} - {command {[G_msg "pr_sites_aggregate"]} {} "pr_sites_aggregate" {} -command {execute i.pr_sites_aggregate}} - {command {[G_msg "pr_statistics"]} {} "pr_statistics" {} -command {execute i.pr_statistics}} - {command {[G_msg "pr_subsets"]} {} "pr_subsets" {} -command {execute i.pr_subsets}} - {command {[G_msg "pr_training"]} {} "pr_training" {} -command {execute i.pr_training}} - {command {[G_msg "pr_uxb"]} {} "pr_uxb" {} -command {execute i.pr_uxb}} - }} - {command {[G_msg "Clustering input for unsupervised classification"]} {} "i.cluster" {} -command {execute i.cluster }} + {command {[G_msg "Clustering input for unsupervised classification"]} {} "i.cluster: Clustering input for unsupervised classification" {} -command {execute i.cluster }} {separator} - {command {[G_msg "Maximum likelyhood classification (MLC)"]} {} "i.maxlik" {} -command {execute i.maxlik }} - {command {[G_msg "Sequential maximum a posteriory classification (SMAP)"]} {} "i.smap" {} -command {execute i.smap }} + {command {[G_msg "Maximum likelyhood classification (MLC)"]} {} "i.maxlik: Maximum likelyhood classification" {} -command {execute i.maxlik }} + {command {[G_msg "Sequential maximum a posteriory classification (SMAP)"]} {} "i.smap: Sequential maximum a posteriory classification" {} -command {execute i.smap }} {separator} - {command {[G_msg "Interactive input for supervised classification"]} {} "i.class" {} -command {term i.class }} - {command {[G_msg "Non-interactive input for supervised classification (MLC)"]} {} "i.gensig" {} -command {execute i.gensig }} - {command {[G_msg "Non-interactive input for supervised classification (SMAP)"]} {} "i.gensigset" {} -command {execute i.gensigset }} - {separator} - {command {[G_msg "Kappa classification accuracy assessment"]} {} "r.kappa" {} -command {execute r.kappa }} + {command {[G_msg "Interactive input for supervised classification"]} {} "i.class: Interactive input for supervised classification" {} -command {term i.class }} + {command {[G_msg "Input for supervised MLC"]} {} "i.gensig: Non-interactive input for supervised classification (MLC)" {} -command {execute i.gensig }} + {command {[G_msg "Input for supervised SMAP"]} {} "i.gensigset: Non-interactive input for supervised classification (SMAP)" {} -command {execute i.gensigset }} }} {cascad {[G_msg "Filter image"]} {} "" $tmenu { - {command {[G_msg "Zero edge crossing detection"]} {} "i.zc" {} -command {execute i.zc }} - {command {[G_msg "User defined matrix/convolving filter"]} {} "r.mfilter" {} -command {execute r.mfilter }} + {command {[G_msg "Edge detection"]} {} "i.zc: Zero edge crossing detection" {} -command {execute i.zc }} + {command {[G_msg "Matrix/convolving filter"]} {} "r.mfilter: User defined matrix/convolving filter" {} -command {execute r.mfilter }} }} - {command {[G_msg "Spectral response"]} {} "i.spectral" {} -command {execute i.spectral }} + {command {[G_msg "Spectral response"]} {} "i.spectral: Spectral response" {} -command {execute i.spectral }} {cascad {[G_msg "Transform image"]} {} "" $tmenu { - {command {[G_msg "Brovey pan sharpening"]} {} "i.fusion.brovey" {} -command {execute i.fusion.brovey }} + {command {[G_msg "Brovey sharpening"]} {} "i.fusion.brovey: Brovey transformation and pan sharpening" {} -command {execute i.fusion.brovey }} {separator} - {command {[G_msg "Canonical component"]} {} "i.cca" {} -command {execute i.cca }} - {command {[G_msg "Principal component"]} {} "i.pca" {} -command {execute i.pca }} - {command {[G_msg "Fast Fourier Transform"]} {} "i.fft" {} -command {execute i.fft }} - {command {[G_msg "Inverse Fast Fourier Transform"]} {} "i.ifft" {} -command {execute i.ifft }} + {command {[G_msg "Canonical correlation"]} {} "i.cca: Canonical correlation (discriminant analysis)" {} -command {execute i.cca }} + {command {[G_msg "Principal components"]} {} "i.pca: Principal components analysis" {} -command {execute i.pca }} + {command {[G_msg "Fast Fourier"]} {} "i.fft: Fast Fourier transform" {} -command {execute i.fft }} + {command {[G_msg "Inverse Fast Fourier"]} {} "i.ifft: Inverse fast Fourier transform" {} -command {execute i.ifft }} }} {separator} {cascad {[G_msg "Reports and statistics"]} {} "" $tmenu { - {command {[G_msg "Report basic file information"]} {} "r.info" {} -command {execute r.info }} - {command {[G_msg "Range of image values"]} {} "r.describe" {} -command {execute r.describe }} + {command {[G_msg "Bit pattern comparison"]} {} "r.bitpattern: Bit pattern comparison for ID of low quality pixels" {} -command {execute r.bitpattern }} + {command {[G_msg "Kappa analysis"]} {} "r.kappa: Kappa classification accuracy assessment" {} -command {execute r.kappa }} + {command {[G_msg "OIF for LandSat TM"]} {} "i.oif: Optimum index factor for LandSat TM" {} -command {execute i.oif }} }} - {cascad {[G_msg "Quality Assessment"]} {} "" $tmenu { - {command {[G_msg "Bit pattern comparison for ID of low quality pixels"]} {} "r.bitpattern" {} -command {execute r.bitpattern }} - {command {[G_msg "Optimum index factor for LandSat TM"]} {} "i.oif" {} -command {execute i.oif }} - }} } - {[G_msg "&Grid3D"]} all options $tmenu { + {[G_msg "&Volumes"]} all options $tmenu { {cascad {[G_msg "Develop grid3D volumes"]} {} "" $tmenu { - {command {[G_msg "Manage nulls for grid3D volume"]} {} "r3.null" {} -command {execute r3.null }} + {command {[G_msg "Manage nulls for grid3D volume"]} {} "r3.null: Manage nulls for grid3D volume" {} -command {execute r3.null }} {command {[G_msg "Manage timestamp for grid3D volume"]} {} "r3.timestamp" {} -command {execute r3.timestamp }} }} - {command {[G_msg "Create 3D mask for grid3D operations"]} {} "r3.mask" {} -command {execute r3.mask }} - {command {[G_msg "Create 2D raster cross section from grid3d volume"]} {} "r3.cross.rast" {} -command { execute r3.cross.rast }} - {command {[G_msg "Map calculator for grid3D operations"]} {} "r3.mapcalculator" {} -command {execute r3.mapcalculator }} - {command {[G_msg "Interpolate volume from vector points using splines"]} {} "v.vol.rst" {} -command {execute v.vol.rst }} + {command {[G_msg "3D MASK"]} {} "r3.mask: " {} -command {execute r3.mask }} + {command {[G_msg "3D Map calculator"]} {} "r3.mapcalculator: Map calculator for grid3D operations" {} -command {execute r3.mapcalculator }} + {command {[G_msg "Cross section from volume"]} {} "r3.cross.rast: Create 2D raster cross section from grid3D volume" {} -command { execute r3.cross.rast }} + {command {[G_msg "Interpolate volume from vector points"]} {} "v.vol.rst: Interpolate volume from vector points using splines" {} -command {execute v.vol.rst }} {cascad {[G_msg "Report and Statistics"]} {} "" $tmenu { - {command {[G_msg "Display information about grid3D volume"]} {} "r3.info" {} -command {execute r3.info }} + {command {[G_msg "Basic information"]} {} "r3.info: Display information about grid3D volume" {} -command {execute r3.info }} }} } {[G_msg "&Databases"]} all options $tmenu { + {cascad {[G_msg "Database information"]} {} "" $tmenu { + {command {[G_msg "Describe table"]} {} "db.describe: Describe table structure and attributes" {} -command {execute db.describe }} + {command {[G_msg "List columns"]} {} "db.columns: List columns for selected table" {} -command {execute db.columns }} + {command {[G_msg "List drivers"]} {} "db.drivers: List available database drivers" {} -command {execute db.drivers }} + {command {[G_msg "List tables"]} {} "db.tables: List tables in database" {} -command {execute db.tables }} + }} + {separator} {cascad {[G_msg "Manage database"]} {} "" $tmenu { - {command {[G_msg "Connect to database"]} {} "db.connect" {} -command {execute db.connect }} - {command {[G_msg "Login to database"]} {} "db.login" {} -command {execute db.login }} + {command {[G_msg "Connect to database"]} {} "db.connect: Connect to database" {} -command {execute db.connect }} + {command {[G_msg "Login to database"]} {} "db.login: Login to database" {} -command {execute db.login }} {separator} - {command {[G_msg "Create and add new attribute table to vector map"]} {} "v.db.addtable" {} -command {execute v.db.addtable }} - {command {[G_msg "Copy attribute table"]} {} "db.copy" {} -command {execute db.copy }} - {command {[G_msg "Remove existing attribute table for vector map"]} {} "v.db.droptable" {} -command {execute v.db.droptable }} + {command {[G_msg "Copy table"]} {} "db.copy: Copy attribute table" {} -command {execute db.copy }} + {command {[G_msg "New table"]} {} "v.db.addtable: Create and connect new attribute table to vector map" {} -command {execute v.db.addtable }} + {command {[G_msg "Remove table"]} {} "v.db.droptable: Remove existing attribute table for vector map" {} -command {execute v.db.droptable }} {separator} - {command {[G_msg "Add columns to table"]} {} "v.db.addcol" {} -command {execute v.db.addcol }} - {command {[G_msg "Change values in a column"]} {} "v.db.update" {} -command {execute v.db.update }} - {command {[G_msg "Rename a column"]} {} "v.db.renamecol" {} -command {execute v.db.renamecol }} + {command {[G_msg "Add columns"]} {} "v.db.addcol: Add columns to table" {} -command {execute v.db.addcol }} + {command {[G_msg "Change values"]} {} "v.db.update: Change values in a column" {} -command {execute v.db.update }} + {command {[G_msg "Rename a column"]} {} "v.db.renamecol: Rename a column" {} -command {execute v.db.renamecol }} {separator} - {command {[G_msg "Test database"]} {} "db.test" {} -command {execute db.test }} + {command {[G_msg "Test database"]} {} "db.test: Test database" {} -command {execute db.test }} }} - {cascad {[G_msg "Database information"]} {} "" $tmenu { - {command {[G_msg "Describe table"]} {} "db.describe" {} -command {execute db.describe }} - {command {[G_msg "List columns"]} {} "db.columns" {} -command {execute db.columns }} - {command {[G_msg "List drivers"]} {} "db.drivers" {} -command {execute db.drivers }} - {command {[G_msg "List tables"]} {} "db.tables" {} -command {execute db.tables }} - }} {separator} {cascad {[G_msg "Query"]} {} "" $tmenu { - {command {[G_msg "Query data in any table"]} {} "db.select" {} -command {execute db.select }} - {command {[G_msg "Query vector attribute data"]} {} "db.select" {} -command {execute v.db.select }} - {command {[G_msg "Execute SQL statement"]} {} "db.execute" {} -command {execute db.execute }} + {command {[G_msg "Query any table"]} {} "db.select: Query data in any table" {} -command {execute db.select }} + {command {[G_msg "Query vector attribute table"]} {} "v.db.select: Query vector attribute data" {} -command {execute v.db.select }} + {command {[G_msg "SQL statement"]} {} "db.execute: Execute SQL statement" {} -command {execute db.execute }} }} {cascad {[G_msg "Vector<->database connections"]} {} "" $tmenu { - {command {[G_msg "Reconnect vector map to attribute database"]} {} "v.db.reconnect.all" {} -command {execute v.db.reconnect.all }} - {command {[G_msg "Set database connection for vector attributes"]} {} "v.db.connect" {} -command {execute v.db.connect }} + {command {[G_msg "Reconnect vector to database"]} {} "v.db.reconnect.all: Reconnect vector map to attribute database" {} -command {execute v.db.reconnect.all }} + {command {[G_msg "Set vector - database connection"]} {} "v.db.connect: Set database connection for vector attributes" {} -command {execute v.db.connect }} }} - } + } {[G_msg "&Help"]} all options $tmenu { {command {[G_msg "GRASS help"]} {} "g.manual" {} -command { exec g.manual -i > $devnull & } } {command {[G_msg "GIS Manager &help"]} {} {[G_msg "GIS Manager help"]} {} -command { exec g.manual gis.m > $devnull & } } Modified: trunk/grassaddons/gipe/menudata.py =================================================================== --- trunk/grassaddons/gipe/menudata.py 2007-06-29 14:50:01 UTC (rev 881) +++ trunk/grassaddons/gipe/menudata.py 2007-06-29 16:13:32 UTC (rev 882) @@ -2,421 +2,309 @@ '''Data object that returns menu descriptions to be used in wxgui.py. Probably could be changed to XML or *.dtd file.''' def GetMenu(self): - return [( - ("Files", ( - ("Import", ( - ("Raster map", ( - ("Multiple formats using GDAL", "Import multiple formats using GDAL", "self.OnMenuCmd", "r.in.gdal"), - ("","","", ""), - ("Aggregate ASCII xyz", "Import aggregate ASCII xyz data", "self.OnMenuCmd", "r.in.xyz"), - ("ASCII grid", "Import ASCII GRID (includes GRASS ASCII)", "self.OnMenuCmd", "r.in.ascii"), - ("ASCII polygons and lines", "Import Polygons and lines from ASCII file", "self.OnMenuCmd", "r.in.poly"), - ("","","", ""), - ("Binary", "Import binary file (includes GTOPO30 format)", "self.OnMenuCmd", "r.in.bin"), - ("ESRI Arc/Info ASCII grid", "Import ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.in.arc"), - ("GRIDATB.FOR", "Import GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.in.gridatb"), - ("MAT-File (v.4)", "Import MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.in.mat"), - ("SPOT NDVI", "Import SPOT vegetation NDVI data sets", "self.OnMenuCmd", "r.in.spotvgt"), - ("SRTM HGT", "Import SRTM hgt files", "self.OnMenuCmd", "r.in.srtm"), - ("Terra ASTER HDF", "Import Terra ASTER HDF files", "self.OnMenuCmd", "r.in.aster"), - ("","","", ""), - ("WMS", "Import Web Mapping Server", "self.OnMenuCmd", "r.in.wms"), - )), - ("Vector map", ( - ("Multiple formats using OGR", "Import multiple formats using OGR", "self.OnMenuCmd", "v.in.ogr"), - ("","","", ""), - ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.in.ascii"), - ("Old GRASS vector", "Import old GRASS vector format", "self.OnMenuCmd", "v.convert"), - ("","","", ""), - ("DXF", "Import DXF file", "self.OnMenuCmd", "v.in.dxf"), - ("ESRI e00", "Import ESRI e00 file", "self.OnMenuCmd", "v.in.e00"), - ("Garmin GPS", "Import Garmin GPS Waypoints/Routes/Tracks", "self.OnMenuCmd", "v.in.garmin"), - ("GPSBabel GPS", "Import GPS Waypoints/Routes/Tracks using GPSBabel", "self.OnMenuCmd", "v.in.gpsbabel"), - ("GEOnet", "Import GEOnet Name server country files (US-NGA GNS)", "self.OnMenuCmd", "v.in.gns"), - ("Matlab and MapGen", "Import Matlab and MapGen files", "self.OnMenuCmd", "v.in.mapgen"), - )), - - ("Grid 3D", ( - ("ASCII 3D", "Import ASCII 3D file", "self.OnMenuCmd", "r3.in.ascii"), - ("Vis5D", "Import Vis5D file", "self.OnMenuCmd", "r3.in.v5d"), - )), - )), - ("Export", ( - ("Raster map", ( - ("Multiple formats using GDAL", "Export multiple formats using GDAL", "self.OnMenuCmd", "r.out.gdal"), - ("","","", ""), - ("ASCII grid", "Export ASCII grid (for GRASS, Surfer, Modflow, etc)", "self.OnMenuCmd", "r.out.ascii"), - ("ASCII x,y,z", "Export ASCII x,y,z values of cell centers", "self.OnMenuCmd", "r.out.xyz"), - ("","","", ""), - ("ESRI ASCII grid", "Export ESRI Arc/Info ASCII grid", "self.OnMenuCmd", "r.out.arc"), - ("GRIDATB.FOR", "Export GRIDATB.FOR map file (TOPMODEL)", "self.OnMenuCmd", "r.out.gridatb"), - ("MAT-File (v.4)", "Export MAT-File (v.4) array (Matlab or Octave)", "self.OnMenuCmd", "r.out.mat"), - ("","","", ""), - ("Binary", "Export binary file", "self.OnMenuCmd", "r.out.bin"), - ("","","", ""), - ("MPEG-1", "Export MPEG-1 animations", "self.OnMenuCmd", "r.out.mpeg"), - ("PNG", "Export PNG image (not georeferenced)", "self.OnMenuCmd", "r.out.png"), - ("PPM", "Export PPM image (24bit)", "self.OnMenuCmd", "r.out.ppm"), - ("POV-Ray", "Export POVray height-field", "self.OnMenuCmd", "r.out.pov"), - ("TIFF", "Export TIFF image (8/24bit)", "self.OnMenuCmd", "r.out.tiff"), - ("VRML", "Export VRML file", "self.OnMenuCmd", "r.out.vrml"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r.out.vtk"), - )), - ("Vector map", ( - ("Multiple formats using OGR", "Export multiple formats using OGR", "self.OnMenuCmd", "v.out.ogr"), - ("","","", ""), - ("ASCII points or GRASS ASCII vector", "Import ASCII points file or GRASS ASCII vector file", "self.OnMenuCmd", "v.out.ascii"), - - ("DXF", "Export DXF file", "self.OnMenuCmd", "v.out.dxf"), - ("POV-Ray", "Export POV-Ray format file", "self.OnMenuCmd", "v.out.pov"), - ("SVG", "Export SVG file", "self.OnMenuCmd", "v.out.svg"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "v.out.vtk"), - )), - - ("Grid 3D", ( - ("ASCII 3D", "Export ASCII 3D file", "self.OnMenuCmd", "r3.out.ascii"), - ("Vis5D", "Export Vis5D file", "self.OnMenuCmd", "r3.out.v5d"), - ("VTK", "Export VTK ASCII file", "self.OnMenuCmd", "r3.out.vtk"), - )), - )), + return [( + ("Files", ( + ("Import", "Import files", "self.runMenuCmd", "r.in.gdal"), + ("Export", "Export files", "self.runMenuCmd", "r.out.gdal"), + ("","","", ""), + ("E&xit", "Exit from wxgui.py", "self.onCloseWindow", "") + )), + ("Config", ( + ("Region", "Set region", "self.runMenuCmd", "g.region"), + ("","","", "") + )), + ("Raster", ( + ("Develop map", ( + ("Digitize raster", "Digitize raster", "self.runMenuCmd", "r.digit"), + ("","","", ""), + ("Compress/decompress raster file", "Compress/decompress raster file", "self.runMenuCmd", "r.compress"), + ("Manage boundary definition (WHICH COMMAND?)", "Manage boundary definition", "self.runMenuCmd", "r.region"), + ("Manage null values", "Manage null values", "self.runMenuCmd", "r.null"), + ("Manage timestamp for files", "Manage timestamp for files", "self.runMenuCmd", "r.timestamp"), + ("Quantization for floating-point maps", "Quantization for floating-point maps", "self.runMenuCmd", "r.quant"), + ("Resample (change resolution) using nearest neighbor method", "Resample (change resolution) using nearest neighbor method", "self.runMenuCmd", "r.resample"), + ("Resample (change resolution) using regularized spline tension", "Resample (change resolution) using regularized spline tension", "self.runMenuCmd", "r.resamp.rst"), + ("Support file creation and maintenance", "Support file creation and maintenance", "self.runMenuCmd", "r.support.sh"), + ("","","", ""), + ("Reproject raster from other location", "Reproject raster from other location", "self.runMenuCmd", "r.proj"), + ("Generate tiling for other projection", "Generate tiling for other projection", "self.runMenuCmd", "r.tileset"), + )), + ("Manage map colors", ( + ("Set colors to predefined color tables", "Set colors to predefined color tables", "self.runMenuCmd", "r.colors"), + ("Set colors using color rules", "Set colors using color rules", "self.runMenuCmd", "r.colors.rules"), + ("","","", ""), + ("Blend 2 color maps to produce 3 RGB files", "Blend 2 color maps to produce 3 RGB files", "self.runMenuCmd", "r.blend"), + ("Create color image from RGB files", "Create color image from RGB files", "self.runMenuCmd", "r.composite"), + ("Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.runMenuCmd", "r.his"), + )), + ("Query by coordinates", "Query by coordinates", "self.runMenuCmd", "r.what"), + ("","","", ""), + ("Create raster buffers", "Develop raster buffer", "self.runMenuCmd", "r.buffer"), + ("Create raster MASK", "Develop raster mask", "self.runMenuCmd", "r.mask"), + ("Locate closest points between areas in 2 raster maps", "r.distance", "self.runMenuCmd", "r.distance"), + ("Map calculator", "Map calculator", "self.runMenuCmd", "scripts/mapcalc_gparser.sh"), + ("Neighborhood analysis", ( + ("Moving window analysis of raster cells", "Moving window analysis of raster cells", "self.runMenuCmd", "r.neighbors"), + ("Analyze vector points in neighborhood of raster cells", "Analyze vector points in neighborhood of raster cells", "self.runMenuCmd", "v.neighbors"), + )), + ("Overlay maps", ( + ("Cross product", "Cross product", "self.runMenuCmd", "r.cross"), + ("Function of map series (time series)", "Function of map series (time series)", "self.runMenuCmd", "r.series"), + ("Patch maps", "Patch maps", "self.runMenuCmd", "r.patch"), + ("","","", ""), + ("Statistical calculations for cover map over base map", "Statistical calculations for cover map over base map", "self.runMenuCmd", "r.statistics"), + )), + ("Solar radiance and shadows", ( + ("Solar irradiance and daily irradiation", "Solar irradiance and daily irradiation", "self.runMenuCmd", "r.sun"), + ("Shadow map for sun position or date/time", "Shadow map for sun position or date/time", "self.runMenuCmd", "r.sunmask"), + )), + ("Terrain analysis", ( + ("Calculate cumulative movement costs between locales", "Calculate cumulative movement costs between locales", "self.runMenuCmd", "r.walk"), + ("cost surface", "cost surface", "self.runMenuCmd", "r.cost"), + ("Least cost route or flow", "Least cost route or flow", "self.runMenuCmd", "r.drain"), + ("Profile analysis", "Profile analysis", "self.runMenuCmd", "d.profile"), + ("Shaded relief map", "Shaded relief map", "self.runMenuCmd", "r.shaded.relief"), + ("Slope and aspect", "Slope and aspect", "self.runMenuCmd", "r.slope.aspect"), + ("Terrain parameters", "Terrain parameters", "self.runMenuCmd", "r.param.scale"), + ("Textural features", "Textural features", "self.runMenuCmd", "r.texture"), + ("Visibility/Line of sight", "Visibility/Line of sight", "self.runMenuCmd", "r.los"), + )), + ("Transform features", ( + ("Clump small areas (statistics calculated by r.volume)", "Clump small areas (statistics calculated by r.volume)", "self.runMenuCmd", "r.clump"), + ("Grow areas", "Grow areas", "self.runMenuCmd", "r.grow"), + ("Thin linear features", "Thin linear features", "self.runMenuCmd", "r.thin"), + )), + ("","","", ""), + ("Hydrologic modeling", ( + ("Carve stream channels into elevation map using vector streams map", "Carve stream channels into elevation map using vector streams map", "self.runMenuCmd", "r.carve"), + ("Depressionless elevation map and flowline map", "Depressionless elevation map and flowline map", "self.runMenuCmd", "r.fill.dir"), + ("Fill lake from seed point to specified level", "Fill lake from seed point to specified level", "self.runMenuCmd", "r.lake"), + ("Flow accumulation for massive grids (WHICH COMMAND?)", "Flow accumulation for massive grids", "self.runMenuCmd", "r.flow"), + ("Generate flow lines for raster map (WHICH COMMAND?)", "Generate flow lines for raster map", "self.runMenuCmd", "r.flow"), + ("SIMWE overland flow modeling (WHICH COMMAND?)", "SIMWE overland flow modeling", "self.runMenuCmd", "r.simwe"), + ("SIMWE sediment erosion, transport, deposition modeling (WHICH COMMAND?)", "SIMWE sediment erosion, transport, deposition modeling", "self.runMenuCmd", "r.simwe"), + ("Topographic index map", "Topographic index map", "self.runMenuCmd", "r.topidx"), + ("TOPMODEL simulation", "TOPMODEL simulation", "self.runMenuCmd", "r.topmodel"), + ("Watershed subbasins", "Watershed subbasins", "self.runMenuCmd", "r.basins.fill"), + ("Watershed analysis", "Watershed analysis", "self.runMenuCmd", "r.watershed"), + ("Watershed basin creation", "Watershed basin creation", "self.runMenuCmd", "r.water.outlet"), + )), + ("Landscape structure modeling", ( + ("Set up sampling and analysis framework", "Set up sampling and analysis framework", "self.runMenuCmd", "r.le.setup"), + ("","","", ""), + ("Analyze landscape characteristics", "Analyze landscape characteristics", "self.runMenuCmd", "r.le.pixel"), + ("Analyze landscape patch characteristics", "Analyze landscape patch characteristics", "self.runMenuCmd", "r.le.patch"), + ("Output landscape patch information", "Output landscape patch information", "self.runMenuCmd", "r.le.trace"), + )), + ("Wildfire modeling", ( + ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.runMenuCmd", "r.ros"), + ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.runMenuCmd", "r.spreadpath"), + ("Simulate anisotropic spread phenomena", "Simulate anisotropic spread phenomena", "self.runMenuCmd", "r.spread"), + )), + ("","","", ""), + ("Change category values and labels", ( + ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.runMenuCmd", "d.rast.edit"), + ("","","", ""), + ("Reclassify categories for areas of specified sizes", "Reclassify categories for areas of specified sizes", "self.runMenuCmd", "r.reclass.area"), + ("Reclassify categories using rules", "Reclassify categories using rules", "self.runMenuCmd", "r.reclass.rules"), + ("Reclassify categories using rules file", "Reclassify categories using rules file", "self.runMenuCmd", "r.reclass.file"), + ("","","", ""), + ("Recode categories using rules (create new map)", "Recode categories using rules (create new map)", "self.runMenuCmd", "r.recode.rules"), + ("Recode categories using rules file (create new map)", "Recode categories using rules file (create new map)", "self.runMenuCmd", "r.recode.file"), + ("","","", ""), + ("Rescale categories (create new map)", "Rescale categories (create new map)", "self.runMenuCmd", "r.rescale"), + ("Rescale categories with equalized histogram (create new map)", "Rescale categories with equalized histogram (create new map)", "self.runMenuCmd", "r.rescale.eq"), + )), + ("","","", ""), + ("Generate concentric circles around points", "Generate concentric circles around points", "self.runMenuCmd", "r.circle"), + ("Generate random raster cells", ( + ("Generate random cells", "Generate random cells", "self.runMenuCmd", "r.random.cells"), + ("Generate random cells and vector points from raster map", "Generate random cells and vector points from raster map", "self.runMenuCmd", "r.random"), + )), + ("Generate surfaces", ( + ("Generate density surface using moving Gaussian kernel", "Generate density surface using moving Gaussian kernel", "self.runMenuCmd", "v.kernel"), + ("Generate fractal surface", "Generate fractal surface", "self.runMenuCmd", "r.surf.fractal"), + ("Generate gaussian deviates surface", "Generate gaussian deviates surface", "self.runMenuCmd", "r.surf.gauss"), + ("Generate plane", "Generate plane", "self.runMenuCmd", "r.plane"), + ("Generate random deviates surface", "Generate random deviates surface", "self.runMenuCmd", "r.surf.random"), + ("Generate random surface with spatial dependence", "Generate random surface with spatial dependence", "self.runMenuCmd", "r.random.surface"), + )), + ("Generate vector contour lines", "Generate vector contour lines", "self.runMenuCmd", "r.contour"), + ("Interpolate surfaces", ( + ("Bilinear interpolation from raster points", "Bilinear interpolation from raster points", "self.runMenuCmd", "r.bilinear"), + ("Inverse distance weighted interpolation from raster points", "Inverse distance weighted interpolation from raster points", "self.runMenuCmd", "r.surf.idw"), + ("Interpolation from raster contour", "Interpolation from raster contour", "self.runMenuCmd", "r.surf.contour"), + ("","","", ""), + ("Inverse distance weighted interpolation from vector points", "Inverse distance weighted interpolation from vector points", "self.runMenuCmd", "v.surf.idw"), + ("Regularized spline tension interpolation from vector points or contours (WHICH COMMAND ?)", "Regularized spline tension interpolation from vector points or contours", "self.runMenuCmd", "v.surf.rst"), + ("","","", ""), + ("Fill NULL cells by interpolation using regularized spline tension", "Fill NULL cells by interpolation using regularized spline tension", "self.runMenuCmd", "r.fillnulls"), + )), + ("","","", ""), + ("Report and statistics", ( + ("Report basic file information", "Report basic file information", "self.runMenuCmd", "r.info"), + ("Report category labels and values", "Report category labels and values", "self.runMenuCmd", "r.cats"), + ("","","", ""), + ("General statistics", "General statistics", "self.runMenuCmd", "r.stats"), + ("Range of all category values", "Range of all category values", "self.runMenuCmd", "r.describe"), + ("Sum all cell category values", "Sum all cell category values", "self.runMenuCmd", "r.sum"), + ("Sum area by map and category", "Sum area by map and category", "self.runMenuCmd", "r.report"), + ("Summary statistics for clumped cells (work with r.clump)", "Summary statistics for clumped cells (work with r.clump)", "self.runMenuCmd", "r.volume"), + ("Total surface area corrected for topography", "Total surface area corrected for topography", "self.runMenuCmd", "r.surf.area"), + ("Univariate statistics", "Univariate statistics", "self.runMenuCmd", "r.univar"), + ("Univariate statistics (script version)", "Univariate statistics (script version)", "self.runMenuCmd", "r.univar.sh"), + ("","","", ""), + ("Sample values along transects", "Sample values along transects", "self.runMenuCmd", "r.profile"), + ("Sample values along transects (use azimuth, distance)", "Sample values along transects (use azimuth, distance)", "self.runMenuCmd", "r.transect"), + ("","","", ""), + ("Covariance/correlation", "Covariance/correlation", "self.runMenuCmd", "r.covar"), + ("Linear regression between 2 maps", "Linear regression between 2 maps", "self.runMenuCmd", "r.regression.line"), + ("Mutual category occurrences (coincidence)", "Mutual category occurrences (coincidence)", "self.runMenuCmd", "r.coin"), + )), + ("","","", "") + )), + ("Vector", ( + ("Develop map", ( + ("Digitize", "Digitize vector", "self.runMenuCmd", "v.digit"), + ("","","", ""), + ("Create/Rebuild topology", "Create/Rebuild topology", "self.runMenuCmd", "v.build"), + ("Clean vector files", "clean vector files", "self.runMenuCmd", "v.clean"), + ("","","", ""), + ("Break lines at intersections", "Break lines at intersections", "self.runMenuCmd", "v.topo.check"), + ("Build polylines from adjacent segments", "Build polylines from adjacent segments", "self.runMenuCmd", "v.build.polylines"), + ("Split polylines into segments", "Split polylines into segments", "self.runMenuCmd", "v.segment"), + ("Create lines parallel to existing lines", "Create lines parallel to existing lines", "self.runMenuCmd", "v.parallel"), + ("","","", ""), + ("Convert vector feature types", "Convert vector feature types", "self.runMenuCmd", "v.type"), + ("Convert 2D vector to 3D by sampling raster", "Convert 2D vector to 3D by sampling raster", "self.runMenuCmd", "v.drape"), + ("Extrude 2D vector into 3D vector", "Extrude 2D vector into 3D vector", "self.runMenuCmd", "v.extrude"), + ("","","", ""), + ("Create text label file for vector features", "Create text label file for vector features", "self.runMenuCmd", "v.label"), + ("","","", ""), + ("Reproject vector from other location", "Reproject vector from other location", "self.runMenuCmd", "v.proj"), + ("","","", "") + )), + ("","","", ""), + ("vector<->database connections", ( + ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.runMenuCmd", "v.external"), + ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.runMenuCmd", "v.db.connect"), + )), + ("Query by attributes", "Query by attributes", "self.runMenuCmd", "v.extract"), + ("Query by coordinate(s)", "Query by coordinate(s)", "self.runMenuCmd", "v.what"), + ("Query by map features", "Query by map features", "self.runMenuCmd", "v.select"), + ("","","", ""), + ("Create vector buffers", "Create vector buffers", "self.runMenuCmd", "v.buffer"), + ("Linear referencing for vectors", ( + ("Create linear reference system", "Create linear reference system", "self.runMenuCmd", "v.lrs.create"), + ("Create stationing from input lines, and linear reference system", "Create stationing from input lines, and linear reference system", "self.runMenuCmd", "v.lrs.label"), + ("Create points/segments from input lines, linear reference system and positions read from stdin", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.runMenuCmd", "v.lrs.segment"), + ("Find line id and real km+offset for given points in vector map using linear reference system", "Find line id and real km+offset for given points in vector map using linear reference system", "self.runMenuCmd", "v.lrs.where"), + )), + ("Neighborhood analysis", ( + ("Locate nearest feature to points or centroids", "Locate nearest feature to points or centroids", "self.runMenuCmd", "v.distance"), + ("Generate Thiessen polygons around points (Voronoi diagram)", "Generate Thiessen polygons around points (Voronoi diagram)", "self.runMenuCmd", "v.voronoi"), + ("Connect points to create Delaunay triangles", "Connect points to create Delaunay triangles", "self.runMenuCmd", "v.delaunay"), + )), + ("Network analysis", ( + ("Allocate subnets", "Allocate subnets", "self.runMenuCmd", "v.net.alloc"), + ("Network maintenance", "Network maintenance", "self.runMenuCmd", "v.net"), + ("Shortest route", "Shortest route", "self.runMenuCmd", "v.net.path"), + ("Shortest route (visualization only)", "Shortest route (visualization only)", "self.runMenuCmd", "d.path"), + ("Split net to bands between cost isolines", "Split net to bands between cost isolines", "self.runMenuCmd", "v.net.iso"), + ("Steiner tree", "Steiner tree", "self.runMenuCmd", "v.net.steiner"), + ("Traveling salesman analysis", "Traveling salesman analysis", "self.runMenuCmd", "v.net.salesman"), + )), + ("Overlay maps", ( + ("Overlay/combine 2 vector maps", "Overlay/combine 2 vector maps", "self.runMenuCmd", "v.overlay"), + ("Patch multiple maps (combine)", "Patch multiple maps (combine)", "self.runMenuCmd", "v.patch"), + )), + ("Generate area feature for extent of current region", "Generate area feature for extent of current region", "self.runMenuCmd", "v.in.region"), + ("Generate rectangular vector grid", "Generate rectangular vector grid", "self.runMenuCmd", "v.mkgrid"), + ("","","", ""), + ("Change attributes", ( + ("Attach/delete, or report categories", "Attach/delete, or report categories", "self.runMenuCmd", "v.category"), + ("Reclassify features using rules file", "Reclassify features using rules file", "self.runMenuCmd", "v.reclass"), + )), + ("","","", ""), + ("Work with vector points", ( + ("Generate points", ( + ("Generate points from database", "Generate points from database", "self.runMenuCmd", "v.in.db"), + ("Generate random points", "Generate random points", "self.runMenuCmd", "v.random"), + ("Random location perturbations of points", "Random location perturbations of points", "self.runMenuCmd", "v.perturb"), + )), + ("Generate areas from points", ( + ("Generate convex hull for point set", "Generate convex hull for point set", "self.runMenuCmd", "v.hull"), + ("Generate Delaunay triangles for point set", "Generate Delaunay triangles for point set", "self.runMenuCmd", "v.delaunay"), + ("Generate Voronoi diagram/Thiessen polygons for point set", "Generate Voronoi diagram/Thiessen polygons for point set", "self.runMenuCmd", "v.voronoi"), + )), + ("Sample raster maps", ( + ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.runMenuCmd", "v.rast.stats"), + ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.runMenuCmd", "v.what.rast"), + ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.runMenuCmd", "v.sample"), + )), + ("Partition points into test/training sets for k-fold cross validation", "Partition points into test/training sets for k-fold cross validation", "self.runMenuCmd", "v.kcv"), + ("Transfer attribute data from queried vector map to points", "Transfer attribute data from queried vector map to points", "self.runMenuCmd", "v.what.vect"), + )), + ("","","", ""), + ("Reports and statistics", ( + ("Basic information", "Basic information", "self.runMenuCmd", "v.info"), + ("Load vector attributes to database or create reports", "Load vector attributes to database or create reports", "self.runMenuCmd", "v.to.db"), + ("Report areas for vector attribute categories", "Report areas for vector attribute categories", "self.runMenuCmd", "v.report"), + ("Univariate statistics", "Univariate statistics", "self.runMenuCmd", "v.univar"), + ("","","", ""), + ("Test normality of point distribution", "Test normality of point distribution", "self.runMenuCmd", "v.normal"), + ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.runMenuCmd", "v.rast.stats"), + ("Indices of point counts in quadrats", "Indices of point counts in quadrats", "self.runMenuCmd", "v.qcount"), + )), + ("","","", "") + )), + ("Image", ( + ("Develop images and groups", ( + ("Create/edit imagery group", "Create/edit imagery group", "self.runMenuCmd", "i.group"), + ("Target imagery group", "Target imagery group", "self.runMenuCmd", "i.target"), + ("","","", ""), + ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.runMenuCmd", "i.image.mosaic"), + )), + ("Manage image colors", ( + ("Color balance and enhance color tables of multiband imagery for rgb display", "Color balance and enhance color tables of multiband imagery for rgb display", "self.runMenuCmd", "i.landsat.rgb"), + ("Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "Transform HIS (Hue/Intensity/Saturation) color image to RGB (Red/Green/Blue)", "self.runMenuCmd", "i.his.rgb"), + ("Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "Transform RGB (Red/Green/Blue) color image to HIS (Hue/Intensity/Saturation)", "self.runMenuCmd", "i.rgb.his"), + )), + ("Rectify and georeference image group", ( + ("Set ground control points (GCP's) from raster map or keyboard entry", "Set ground control points (GCP's) from raster map or keyboard entry", "self.runMenuCmd", "i.points"), + ("Set ground control points (GCP's) from vector map or keyboard entry", "Set ground control points (GCP's) from vector map or keyboard entry", "self.runMenuCmd", "i.vpoints"), + ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.runMenuCmd", "i.rectify"), + ("Ortho Photo rectification", "Ortho Photo rectification", "self.runMenuCmd", "i.ortho.photo"), + )), + ("","","", ""), + ("Classify image", ( + ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.runMenuCmd", "i.cluster"), + ("","","", ""), + ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.runMenuCmd", "i.maxlik"), + ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.runMenuCmd", "i.smap"), + ("","","", ""), + ("Interactive input for supervised classification", "Interactive input for supervised classification", "self.runMenuCmd", "i.class"), + ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.runMenuCmd", "i.gensig"), + ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.runMenuCmd", "i.gensigset"), + )), + ("Classify image (pr library)", ( + ("subsets", "pr_subsets", "self.RunMenuCmd", "i.pr_subsets"), + ("training", "pr_training", "self.RunMenuCmd", "i.pr_training"), + ("classify", "pr_classify", "self.RunMenuCmd", "i.pr_classify"), + ("","","", ""), + ("features", "pr_features", "self.RunMenuCmd", "i.pr_features"), + ("features_additional", "pr_features_additional", "self.RunMenuCmd", "i.pr_features_additional"), + ("features_extract", "pr_features_extract", "self.RunMenuCmd", "i.pr_features_extract"), + ("features_selection", "pr_features_selection", "self.RunMenuCmd", "i.pr_features_selection"), + ("","","", ""), + ("model", "pr_model", "self.RunMenuCmd", "i.pr_model"), + ("sites_aggregate", "pr_sites_aggregate", "self.RunMenuCmd", "i.pr_sites_aggregate"), + ("blob", "pr_blob", "self.RunMenuCmd", "i.pr_blob"), + ("uxb", "pr_uxb", "self.RunMenuCmd", "i.pr_uxb"), + ("","","", ""), + ("statistics", "pr_statistics", "self.RunMenuCmd", "i.pr_statistics"), + )), ("","","", ""), - ("Manage maps and volumes", ( - ("Copy", "Copy maps within mapsets or between mapsets", "self.OnMenuCmd", "g.copy"), - ("","","", ""), - ("List", "List maps by type", "self.OnMenuCmd", "list"), - ("List filtered", "List maps filtered by expressions and wildcards", "self.OnMenuCmd", "g.mlist"), - ("","","", ""), - ("Rename", "Rename maps", "self.OnMenuCmd", "g.rename"), - ("","","", ""), - ("Delete", "Delete maps", "self.OnMenuCmd", "g.remove"), - ("Delete filtered", "Delete maps using expressions and wildcards", "self.OnMenuCmd", "g.mremove"), - )), - ("Map type conversions", ( - ("Raster to vector", "Convert raster to vector map", "self.OnMenuCmd", "r.to.vect"), - ("Raster series to volume", "Convert raster map series to volume", "self.OnMenuCmd", "r.to.rast3"), - ("Raster 2.5D to volume", "Convert raster 2.5D map to volume", "self.OnMenuCmd", "r.to.rast3elev"), - ("","","", ""), - ("Vector to raster", "Convert vector to raster map", "self.OnMenuCmd", "v.to.rast"), - ("Vector to volume", "Convert vector 3D points to volume voxels", "self.OnMenuCmd", "v.to.rast3"), - ("Sites to vector", "Convert sites (GRASS 5) to vector map", "self.OnMenuCmd", "v.in.sites"), - ("","","", ""), - ("Volumes to raster series", "Convert raster to vector map", "self.OnMenuCmd", "r3.to.rast"), - )), - ("","","", ""), - ("Georectify (not functional)", "Georectify raster and vector maps", "self.OnGeorectify", ""), - ("","","", ""), - ("Bearing/distance to coordinates", "Convert between bearing/distance and coordinates", "self.OnMenuCmd", "m.cogo"), - ("","","", ""), - ("Postscript plot", "Create cartographic PostScript plot", "self.OnMenuCmd", "ps.map"), - ("","","", ""), - ("E&xit", "Exit from wxgui.py", "self.OnCloseWindow", ""), - )), - ("Config", ( - ("Region", ( - ("Display region", "Display region settings", "self.RunMenuCmd", "g.region -p"), - ("Set region", "Change region settings", "self.OnMenuCmd", "g.region"), - )), - ("GRASS working environment", ( - ("Mapset access (not functional)", "Set access to other mapsets in current location", "self.OnMapsets", ""), - ("Change working environment", "Change current working session to new mapset, location, or data directory", "self.OnMenuCmd", "g.mapset"), - ("User access", "Change access by other users to current mapset", "self.OnMenuCmd", "g.access"), - ("Show settings", "Show current GRASS environment settings", "self.RunMenuCmd", "g.gisenv "), - ("Change settings", "Change GRASS environment settings", "self.OnMenuCmd", "g.gisenv"), - ("Version", "Show current GRASS version", "self.RunMenuCmd", "g.version -c"), - )), - ("Manage projections", ( - ("Projections", "Show projection information and create projection files", "self.OnMenuCmd", "g.proj"), - ("Convert coordinates", "Convert coordinates from one projection to another", "self.OnMenuCmd", "m.proj"), - )), - ("Display font", "Set default font for GRASS displays", "self.DefaultFont", ""), - )), - ("Raster", ( - ("Develop map", ( - ("Digitize raster (not functional)", "Digitize raster", "self.OnRDigit", ""), - ("","","", ""), - ("Compress/decompress raster file", "Compress/decompress raster file", "self.OnMenuCmd", "r.compress"), - ("Manage boundary definition (WHICH COMMAND?)", "Manage boundary definition", "self.OnMenuCmd", "r.region"), - ("Manage null values", "Manage null values", "self.OnMenuCmd", "r.null"), - ("Manage timestamp for files", "Manage timestamp for files", "self.OnMenuCmd", "r.timestamp"), - ("Quantization for floating-point maps", "Quantization for floating-point maps", "self.OnMenuCmd", "r.quant"), - ("Resample (change resolution) using nearest neighbor method", "Resample (change resolution) using nearest neighbor method", "self.OnMenuCmd", "r.resample"), - ("Resample (change resolution) using regularized spline tension", "Resample (change resolution) using regularized spline tension", "self.OnMenuCmd", "r.resamp.rst"), - ("Support file creation and maintenance", "Support file creation and maintenance", "self.OnMenuCmd", "r.support.sh"), - ("","","", ""), - ("Reproject raster from other location", "Reproject raster from other location", "self.OnMenuCmd", "r.proj"), - ("Generate tiling for other projection", "Generate tiling for other projection", "self.OnMenuCmd", "r.tileset"), - )), - ("Manage map colors", ( - ("Set colors to predefined color tables", "Set colors to predefined color tables", "self.OnMenuCmd", "r.colors"), - ("Set colors using color rules", "Set colors using color rules", "self.OnMenuCmd", "r.colors.rules"), - ("","","", ""), - ("Blend 2 color maps to produce 3 RGB files", "Blend 2 color maps to produce 3 RGB files", "self.OnMenuCmd", "r.blend"), - ("Create color image from RGB files", "Create color image from RGB files", "self.OnMenuCmd", "r.composite"), - ("Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps", "self.OnMenuCmd", "r.his"), - )), - ("Query/Profile", ( - ("Query by coordinates", "Query by coordinates", "self.OnMenuCmd", "r.what"), - ("Profile", "Profile of transect", "self.DispProfile", ""), - )), - ("","","", ""), - ("Create raster MASK", "Develop raster mask", "self.OnMenuCmd", "r.mask"), - ("Create raster buffers", "Develop raster buffer", "self.OnMenuCmd", "r.buffer"), - ("Map calculator", "Map calculator", "self.OnMenuCmd", "scripts/mapcalc_gparser.sh"), - ("","","", ""), - ("Overlay maps", ( - ("Cross product", "Cross product", "self.OnMenuCmd", "r.cross"), - ("Function of map series (time series)", "Function of map series (time series)", "self.OnMenuCmd", "r.series"), - ("Patch maps", "Patch maps", "self.OnMenuCmd", "r.patch"), - ("","","", ""), - ("Statistical calculations for cover map over base map", "Statistical calculations for cover map over base map", "self.OnMenuCmd", "r.statistics"), - )), - ("Transform features", ( - ("Clump small areas (statistics calculated by r.volume)", "Clump small areas (statistics calculated by r.volume)", "self.OnMenuCmd", "r.clump"), - ("Grow areas", "Grow areas", "self.OnMenuCmd", "r.grow"), - ("Thin linear features", "Thin linear features", "self.OnMenuCmd", "r.thin"), - )), - ("Proximity/Neighborhood analysis", ( - ("Moving window analysis of raster cells", "Moving window analysis of raster cells", "self.OnMenuCmd", "r.neighbors"), - ("Analyze vector points in neighborhood of raster cells", "Analyze vector points in neighborhood of raster cells", "self.OnMenuCmd", "v.neighbors"), - ("","","", ""), - ("Locate closest points between areas in 2 raster maps", "r.distance", "self.OnMenuCmd", "r.distance"), - )), - ("","","", ""), - ("Modeling: Hydrologic", ( - ("Carve stream channels into elevation map using vector streams map", "Carve stream channels into elevation map using vector streams map", "self.OnMenuCmd", "r.carve"), - ("Depressionless elevation map and flowline map", "Depressionless elevation map and flowline map", "self.OnMenuCmd", "r.fill.dir"), - ("Fill lake from seed point to specified level", "Fill lake from seed point to specified level", "self.OnMenuCmd", "r.lake"), - ("Flow accumulation for massive grids (WHICH COMMAND?)", "Flow accumulation for massive grids", "self.OnMenuCmd", "r.flow"), - ("Generate flow lines for raster map (WHICH COMMAND?)", "Generate flow lines for raster map", "self.OnMenuCmd", "r.flow"), - ("SIMWE overland flow modeling (WHICH COMMAND?)", "SIMWE overland flow modeling", "self.OnMenuCmd", "r.simwe"), - ("SIMWE sediment erosion, transport, deposition modeling (WHICH COMMAND?)", "SIMWE sediment erosion, transport, deposition modeling", "self.OnMenuCmd", "r.simwe"), - ("Topographic index map", "Topographic index map", "self.OnMenuCmd", "r.topidx"), - ("TOPMODEL simulation", "TOPMODEL simulation", "self.OnMenuCmd", "r.topmodel"), - ("Watershed subbasins", "Watershed subbasins", "self.OnMenuCmd", "r.basins.fill"), - ("Watershed analysis", "Watershed analysis", "self.OnMenuCmd", "r.watershed"), - ("Watershed basin creation", "Watershed basin creation", "self.OnMenuCmd", "r.water.outlet"), - )), - ("Modeling: Landscape structure", ( - ("Set up sampling and analysis framework", "Set up sampling and analysis framework", "self.OnMenuCmd", "r.le.setup"), - ("","","", ""), - ("Analyze landscape characteristics", "Analyze landscape characteristics", "self.OnMenuCmd", "r.le.pixel"), - ("Analyze landscape patch characteristics", "Analyze landscape patch characteristics", "self.OnMenuCmd", "r.le.patch"), - ("Output landscape patch information", "Output landscape patch information", "self.OnMenuCmd", "r.le.trace"), - )), - ("Modeling: Landscape patch analysis", ( - ("Configure and create patch map for analysis", "Configure and create patch map for analysis", "self.RunMenuCmd", "r.li.setup"), - ("","","", ""), - ("Contrast weighted edge density index", "Calculate contrast weighted edge density index", "self.RunMenuCmd", "r.li.cwed"), - ("Calculate dominance's diversity index", "Calculate dominance's diversity index", "self.RunMenuCmd", "r.li.dominance"), - ("Edge density index using a 4 neighbour algorithm","Calculate edge density index using a 4 neighbour algorithm", "self.RunMenuCmd", "r.li.edgedensity"), - ("Mean patch size index using a 4 neighbour algorithm", "Calculate mean patch size index using a 4 neighbour algorithm", "self.RunMenuCmd", " r.li.mps"), - ("Coefficient of variation of patch area","Calculate coefficient of variation of patch area", "self.RunMenuCmd", "r.li.padcv"), - ("Range of patch area size", "Calculate range of patch area size", "self.RunMenuCmd", "r.li.padrange"), - ("Standard deviation of patch area","Calculate standard deviation of patch area", "self.RunMenuCmd", "r.li.padsd"), - ("Patch density index using a 4 neighbour algorithm","Calculate patch density index using a 4 neighbour algorithm", "self.RunMenuCmd", "r.li.patchdensity"), - ("Patch number index using a 4 neighbour algorithm", "Calculate patch number index using a 4 neighbour algorithm", "self.RunMenuCmd", "r.li.patchnum"), - ("Dominance's diversity index", "Calculate dominance's diversity index", "self.RunMenuCmd", "r.li.shannon"), - ("Shannon's diversity index", "Calculate Shannon's diversity index", "self.RunMenuCmd", "r.li.richness"), - ("Shape index", "Calculate shape index", "self.RunMenuCmd", "r.li.shape"), - ("Simpson's diversity index", "Calculate Simpson's diversity index", "self.RunMenuCmd", "r.li.simpson"), - )), - ("Modeling: Terrain and Solar", ( - ("Calculate cumulative movement costs between locales", "Calculate cumulative movement costs between locales", "self.OnMenuCmd", "r.walk"), - ("cost surface", "cost surface", "self.OnMenuCmd", "r.cost"), - ("Least cost route or flow", "Least cost route or flow", "self.OnMenuCmd", "r.drain"), - ("","","", ""), - ("Shaded relief map", "Shaded relief map", "self.OnMenuCmd", "r.shaded.relief"), - ("Slope and aspect", "Slope and aspect", "self.OnMenuCmd", "r.slope.aspect"), - ("Terrain parameters", "Terrain parameters", "self.OnMenuCmd", "r.param.scale"), - ("","","", ""), - ("Textural features", "Textural features", "self.OnMenuCmd", "r.texture"), - ("Visibility/Line of sight", "Visibility/Line of sight", "self.OnMenuCmd", "r.los"), - ("","","", ""), - ("Solar irradiance and daily irradiation", "Solar irradiance and daily irradiation", "self.OnMenuCmd", "r.sun"), - ("Shadow map for sun position or date/time", "Shadow map for sun position or date/time", "self.OnMenuCmd", "r.sunmask"), - )), - ("Modeling: Wildfire", ( - ("Generate rate of spread (ROS) maps", "Generate rate of spread (ROS) maps", "self.OnMenuCmd", "r.ros"), - ("Generate least-cost spread paths", "Generate least-cost spread paths", "self.OnMenuCmd", "r.spreadpath"), - ("Simulate anisotropic spread phenomena", "Simulate anisotropic spread phenomena", "self.OnMenuCmd", "r.spread"), - )), - ("","","", ""), - ("Change category values and labels", ( - ("Edit category values of individual cells for displayed raster map", "Edit category values of individual cells for displayed raster map", "self.OnMenuCmd", "d.rast.edit"), - ("","","", ""), - ("Reclassify categories for areas of specified sizes", "Reclassify categories for areas of specified sizes", "self.OnMenuCmd", "r.reclass.area"), - ("Reclassify categories using rules", "Reclassify categories using rules", "self.OnMenuCmd", "r.reclass.rules"), - ("Reclassify categories using rules file", "Reclassify categories using rules file", "self.OnMenuCmd", "r.reclass.file"), - ("","","", ""), - ("Recode categories using rules (create new map)", "Recode categories using rules (create new map)", "self.OnMenuCmd", "r.recode.rules"), - ("Recode categories using rules file (create new map)", "Recode categories using rules file (create new map)", "self.OnMenuCmd", "r.recode.file"), - ("","","", ""), - ("Rescale categories (create new map)", "Rescale categories (create new map)", "self.OnMenuCmd", "r.rescale"), - ("Rescale categories with equalized histogram (create new map)", "Rescale categories with equalized histogram (create new map)", "self.OnMenuCmd", "r.rescale.eq"), - )), - ("","","", ""), - ("Generate", ( - ("Concentric circles around points", "Generate concentric circles around points", "self.OnMenuCmd", "r.circle"), - ("Density surface using moving Gaussian kernel", "Generate density surface using moving Gaussian kernel", "self.OnMenuCmd", "v.kernel"), - ("Fractal surface", "Generate fractal surface", "self.OnMenuCmd", "r.surf.fractal"), - ("Gaussian deviates surface", "Generate gaussian deviates surface", "self.OnMenuCmd", "r.surf.gauss"), - ("Generate plane", "Generate plane", "self.OnMenuCmd", "r.plane"), - ("","","", ""), - ("Random cells", "Generate random cells", "self.OnMenuCmd", "r.random.cells"), - ("Random cells and vector points from raster map", "Generate random cells and vector points from raster map", "self.OnMenuCmd", "r.random"), - ("Random deviates surface", "Generate random deviates surface", "self.OnMenuCmd", "r.surf.random"), - ("Random surface with spatial dependence", "Generate random surface with spatial dependence", "self.OnMenuCmd", "r.random.surface"), - ("","","", ""), - ("Generate vector contour lines", "Generate vector contour lines", "self.OnMenuCmd", "r.contour"), - )), - ("Interpolate surfaces", ( - ("Bilinear interpolation from raster points", "Bilinear interpolation from raster points", "self.OnMenuCmd", "r.bilinear"), - ("Inverse distance weighted interpolation from raster points", "Inverse distance weighted interpolation from raster points", "self.OnMenuCmd", "r.surf.idw"), - ("Interpolation from raster contour", "Interpolation from raster contour", "self.OnMenuCmd", "r.surf.contour"), - ("","","", ""), - ("Inverse distance weighted interpolation from vector points", "Inverse distance weighted interpolation from vector points", "self.OnMenuCmd", "v.surf.idw"), - ("Regularized spline tension interpolation from vector points or contours (WHICH COMMAND ?)", "Regularized spline tension interpolation from vector points or contours", "self.OnMenuCmd", "v.surf.rst"), - ("","","", ""), - ("Fill NULL cells by interpolation using regularized spline tension", "Fill NULL cells by interpolation using regularized spline tension", "self.OnMenuCmd", "r.fillnulls"), - )), - ("","","", ""), - ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), - ("Report category labels and values", "Report category labels and values", "self.OnMenuCmd", "r.cats"), - ("","","", ""), - ("General statistics", "General statistics", "self.OnMenuCmd", "r.stats"), - ("Range of all category values", "Range of all category values", "self.OnMenuCmd", "r.describe"), - ("Sum all cell category values", "Sum all cell category values", "self.OnMenuCmd", "r.sum"), - ("Sum area by map and category", "Sum area by map and category", "self.OnMenuCmd", "r.report"), - ("Summary statistics for clumped cells (work with r.clump)", "Summary statistics for clumped cells (work with r.clump)", "self.OnMenuCmd", "r.volume"), - ("Total surface area corrected for topography", "Total surface area corrected for topography", "self.OnMenuCmd", "r.surf.area"), - ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "r.univar"), - ("Univariate statistics (script version)", "Univariate statistics (script version)", "self.OnMenuCmd", "r.univar.sh"), - ("","","", ""), - ("Sample values along transects", "Sample values along transects", "self.OnMenuCmd", "r.profile"), - ("Sample values along transects (use azimuth, distance)", "Sample values along transects (use azimuth, distance)", "self.OnMenuCmd", "r.transect"), - ("","","", ""), - ("Covariance/correlation", "Covariance/correlation", "self.OnMenuCmd", "r.covar"), - ("Linear regression between 2 maps", "Linear regression between 2 maps", "self.OnMenuCmd", "r.regression.line"), - ("Mutual category occurrences (coincidence)", "Mutual category occurrences (coincidence)", "self.OnMenuCmd", "r.coin"), - )), - ("","","", "") - )), - ("Vector", ( - ("Develop map", ( - ("Digitize", "Digitize vector", "self.OnMenuCmd", "v.digit"), - ("","","", ""), - ("Create/Rebuild topology", "Create/Rebuild topology", "self.OnMenuCmd", "v.build"), - ("Clean vector files", "clean vector files", "self.OnMenuCmd", "v.clean"), - ("","","", ""), - ("Break lines at intersections", "Break lines at intersections", "self.OnMenuCmd", "v.topo.check"), - ("Build polylines from adjacent segments", "Build polylines from adjacent segments", "self.OnMenuCmd", "v.build.polylines"), - ("Split polylines into segments", "Split polylines into segments", "self.OnMenuCmd", "v.segment"), - ("Create lines parallel to existing lines", "Create lines parallel to existing lines", "self.OnMenuCmd", "v.parallel"), - ("","","", ""), - ("Convert vector feature types", "Convert vector feature types", "self.OnMenuCmd", "v.type"), - ("Convert 2D vector to 3D by sampling raster", "Convert 2D vector to 3D by sampling raster", "self.OnMenuCmd", "v.drape"), - ("Extrude 2D vector into 3D vector", "Extrude 2D vector into 3D vector", "self.OnMenuCmd", "v.extrude"), - ("","","", ""), - ("Create text label file for vector features", "Create text label file for vector features", "self.OnMenuCmd", "v.label"), - ("","","", ""), - ("Reproject vector from other location", "Reproject vector from other location", "self.OnMenuCmd", "v.proj"), - ("","","", "") - )), - ("","","", ""), - ("vector<->database connections", ( - ("Create new vector as link to external OGR layer", "Create new vector as link to external OGR layer", "self.OnMenuCmd", "v.external"), - ("Set database connection for vector attributes", "Set database connection for vector attributes", "self.OnMenuCmd", "v.db.connect"), - )), - ("Query by attributes", "Query by attributes", "self.OnMenuCmd", "v.extract"), - ("Query by coordinate(s)", "Query by coordinate(s)", "self.OnMenuCmd", "v.what"), - ("Query by map features", "Query by map features", "self.OnMenuCmd", "v.select"), - ("","","", ""), - ("Create vector buffers", "Create vector buffers", "self.OnMenuCmd", "v.buffer"), - ("Linear referencing for vectors", ( - ("Create linear reference system", "Create linear reference system", "self.OnMenuCmd", "v.lrs.create"), - ("Create stationing from input lines, and linear reference system", "Create stationing from input lines, and linear reference system", "self.OnMenuCmd", "v.lrs.label"), - ("Create points/segments from input lines, linear reference system and positions read from stdin", "Create points/segments from input lines, linear reference system and positions read from stdin", "self.OnMenuCmd", "v.lrs.segment"), - ("Find line id and real km+offset for given points in vector map using linear reference system", "Find line id and real km+offset for given points in vector map using linear reference system", "self.OnMenuCmd", "v.lrs.where"), - )), - ("Neighborhood analysis", ( - ("Locate nearest feature to points or centroids", "Locate nearest feature to points or centroids", "self.OnMenuCmd", "v.distance"), - ("Generate Thiessen polygons around points (Voronoi diagram)", "Generate Thiessen polygons around points (Voronoi diagram)", "self.OnMenuCmd", "v.voronoi"), - ("Connect points to create Delaunay triangles", "Connect points to create Delaunay triangles", "self.OnMenuCmd", "v.delaunay"), - )), - ("Network analysis", ( - ("Allocate subnets", "Allocate subnets", "self.OnMenuCmd", "v.net.alloc"), - ("Network maintenance", "Network maintenance", "self.OnMenuCmd", "v.net"), - ("Shortest route", "Shortest route", "self.OnMenuCmd", "v.net.path"), - ("Shortest route (visualization only)", "Shortest route (visualization only)", "self.OnMenuCmd", "d.path"), - ("Split net to bands between cost isolines", "Split net to bands between cost isolines", "self.OnMenuCmd", "v.net.iso"), - ("Steiner tree", "Steiner tree", "self.OnMenuCmd", "v.net.steiner"), - ("Traveling salesman analysis", "Traveling salesman analysis", "self.OnMenuCmd", "v.net.salesman"), - )), - ("Overlay maps", ( - ("Overlay/combine 2 vector maps", "Overlay/combine 2 vector maps", "self.OnMenuCmd", "v.overlay"), - ("Patch multiple maps (combine)", "Patch multiple maps (combine)", "self.OnMenuCmd", "v.patch"), - )), - ("Generate area feature for extent of current region", "Generate area feature for extent of current region", "self.OnMenuCmd", "v.in.region"), - ("Generate rectangular vector grid", "Generate rectangular vector grid", "self.OnMenuCmd", "v.mkgrid"), - ("","","", ""), - ("Change attributes", ( - ("Attach/delete, or report categories", "Attach/delete, or report categories", "self.OnMenuCmd", "v.category"), - ("Reclassify features using rules file", "Reclassify features using rules file", "self.OnMenuCmd", "v.reclass"), - )), - ("","","", ""), - ("Work with vector points", ( - ("Generate points", ( - ("Generate points from database", "Generate points from database", "self.OnMenuCmd", "v.in.db"), - ("Generate random points", "Generate random points", "self.OnMenuCmd", "v.random"), - ("Random location perturbations of points", "Random location perturbations of points", "self.OnMenuCmd", "v.perturb"), - )), - ("Generate areas from points", ( - ("Generate convex hull for point set", "Generate convex hull for point set", "self.OnMenuCmd", "v.hull"), - ("Generate Delaunay triangles for point set", "Generate Delaunay triangles for point set", "self.OnMenuCmd", "v.delaunay"), - ("Generate Voronoi diagram/Thiessen polygons for point set", "Generate Voronoi diagram/Thiessen polygons for point set", "self.OnMenuCmd", "v.voronoi"), - )), - ("Sample raster maps", ( - ("Calculate statistics for raster map overlain by vector map", "Calculate statistics for raster map overlain by vector map", "self.OnMenuCmd", "v.rast.stats"), - ("Sample raster maps at point locations", "Sample raster maps at point locations", "self.OnMenuCmd", "v.what.rast"), - ("Sample raster neighborhood around points", "Sample raster neighborhood around points", "self.OnMenuCmd", "v.sample"), - )), - ("Partition points into test/training sets for k-fold cross validation", "Partition points into test/training sets for k-fold cross validation", "self.OnMenuCmd", "v.kcv"), - ("Transfer attribute data from queried vector map to points", "Transfer attribute data from queried vector map to points", "self.OnMenuCmd", "v.what.vect"), - )), - ("","","", ""), - ("Reports and statistics", ( - ("Basic information", "Basic information", "self.OnMenuCmd", "v.info"), - ("Load vector attributes to database or create reports", "Load vector attributes to database or create reports", "self.OnMenuCmd", "v.to.db"), - ("Report areas for vector attribute categories", "Report areas for vector attribute categories", "self.OnMenuCmd", "v.report"), - ("Univariate statistics", "Univariate statistics", "self.OnMenuCmd", "v.univar"), - ("","","", ""), - ("Test normality of point distribution", "Test normality of point distribution", "self.OnMenuCmd", "v.normal"), - ("Calculate stats for raster map underlying vector objects", "Calculate stats for raster map underlying vector objects", "self.OnMenuCmd", "v.rast.stats"), - ("Indices of point counts in quadrats", "Indices of point counts in quadrats", "self.OnMenuCmd", "v.qcount"), - )), - ("","","", "") - )), - ("Image", ( - ("Develop images and groups", ( - ("Create/edit imagery group", "Create/edit imagery group", "self.OnMenuCmd", "i.group"), - ("Target imagery group", "Target imagery group", "self.OnMenuCmd", "i.target"), - ("","","", ""), - ("Mosaic up to 4 adjacent images", "Mosaic up to 4 adjacent images", "self.OnMenuCmd", "i.image.mosaic"), - )), - ("Manage image colors", ( - ("Balance/enhance color tables for rgb display", "Balance/enhance color tables for rgb display", "self.OnMenuCmd", "i.landsat.rgb"), - ("Transform HIS to RGB", "Transform HIS to RGB", "self.OnMenuCmd", "i.his.rgb"), - ("Transform RGB to HIS", "Transform RGB to HIS", "self.OnMenuCmd", "i.rgb.his"), - )), - ("Rectify and georeference image group", ( - ("Set ground control points (GCP's) from raster map or keyboard entry", "Set ground control points (GCP's) from raster map or keyboard entry", "self.OnMenuCmd", "i.points"), - ("Set ground control points (GCP's) from vector map or keyboard entry", "Set ground control points (GCP's) from vector map or keyboard entry", "self.OnMenuCmd", "i.vpoints"), - ("","","", ""), - ("Affine and Polynomial rectification (rubber sheet)", "Affine and Polynomial rectification (rubber sheet)", "self.OnMenuCmd", "i.rectify"), - ("Ortho Photo rectification", "Ortho Photo rectification", "self.OnMenuCmd", "i.ortho.photo"), - )), - ("","","", ""), ("RS Pre-Processing (DN->Rad->Ref)", ( ("Landsat 7 ETM+", "Landsat 7 ETM+", "self.RunMenuCmd", "i.dn2ref.l7"), ("Landsat 7 ETM+ (from .met)", "Landsat 7 ETM+ (from .met)", "self.RunMenuCmd", "i.dn2full.l7"), @@ -471,116 +359,35 @@ ("Biomass growth", "Biomass growth", "self.RunMenuCmd", "i.biomass"), )), ("","","", ""), - ("Filter image", ( - ("Zero edge crossing detection", "Zero edge crossing detection", "self.OnMenuCmd", "i.zc"), - ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.OnMenuCmd", "r.mfilter"), - )), - ("Transform image", ( - ("Brovey pan sharpening", "Brovey pan sharpening", "self.OnMenuCmd", "i.fusion.brovey"), + ("Filter image", ( + ("Zero edge crossing detection", "Zero edge crossing detection", "self.runMenuCmd", "i.zc"), + ("User defined matrix/convolving filter", "User defined matrix/convolving filter", "self.runMenuCmd", "r.mfilter"), + )), + ("Spectral response", "Spectral response", "self.runMenuCmd", "i.spectral"), + ("Tasseled cap vegetation index", "Tasseled cap vegetation index", "self.runMenuCmd", "i.tasscap"), + ("Transform image", ( + ("Brovey transformation and pan sharpening", "Brovey transformation and pan sharpening", "self.runMenuCmd", "i.fusion.brovey"), ("","","", ""), - ("Canonical component", "Canonical component", "self.OnMenuCmd", "i.cca"), - ("Principal component", "Principal component", "self.OnMenuCmd", "i.pca"), - ("Fast Fourier Transform", "Fast Fourier Transform", "self.OnMenuCmd", "i.fft"), - ("Inverse Fast Fourier Transform", "Inverse Fast Fourier Transform", "self.OnMenuCmd", "i.ifft"), - )), - ("","","", ""), - ("Classify image (Standard)", ( - ("Clustering input for unsupervised classification", "Clustering input for unsupervised classification", "self.OnMenuCmd", "i.cluster"), - ("","","", ""), - ("Maximum likelihood Classification (MLC)", "Maximum likelihood Classification (MLC)", "self.OnMenuCmd", "i.maxlik"), - ("Sequential maximum a posteriori classification (SMAP)", "Sequential maximum a posteriori classification (SMAP)", "self.OnMenuCmd", "i.smap"), - ("","","", ""), - ("Interactive input for supervised classification", "Interactive input for supervised classification", "self.OnMenuCmd", "i.class"), - ("Non-interactive input for supervised classification (MLC)", "Non-interactive input for supervised classification (MLC)", "self.OnMenuCmd", "i.gensig"), - ("Non-interactive input for supervised classification (SMAP)", "Non-interactive input for supervised classification (SMAP)", "self.OnMenuCmd", "i.gensigset"), - ("","","", ""), - ("Kappa classification accuracy assessment", "Kappa classification accuracy assessment", "self.OnMenuCmd", "r.kappa"), - )), - ("Classify image (pr library)", ( - ("subsets", "pr_subsets", "self.RunMenuCmd", "i.pr_subsets"), - ("training", "pr_training", "self.RunMenuCmd", "i.pr_training"), - ("classify", "pr_classify", "self.RunMenuCmd", "i.pr_classify"), - ("","","", ""), - ("features", "pr_features", "self.RunMenuCmd", "i.pr_features"), - ("features_additional", "pr_features_additional", "self.RunMenuCmd", "i.pr_features_additional"), - ("features_extract", "pr_features_extract", "self.RunMenuCmd", "i.pr_features_extract"), - ("features_selection", "pr_features_selection", "self.RunMenuCmd", "i.pr_features_selection"), - ("","","", ""), - ("model", "pr_model", "self.RunMenuCmd", "i.pr_model"), - ("sites_aggregate", "pr_sites_aggregate", "self.RunMenuCmd", "i.pr_sites_aggregate"), - ("blob", "pr_blob", "self.RunMenuCmd", "i.pr_blob"), - ("uxb", "pr_uxb", "self.RunMenuCmd", "i.pr_uxb"), - ("","","", ""), - ("statistics", "pr_statistics", "self.RunMenuCmd", "i.pr_statistics"), - )), - ("","","", ""), - ("Quality Analysis", ( - ("Bit pattern comparison for ID of low quality pixels", "Bit pattern comparison for ID of low quality pixels", "self.OnMenuCmd", "r.bitpattern"), - ("Optimum index factor for LandSat TM", "Optimum index factor for LandSat TM", "self.OnMenuCmd", "i.oif"), - )), - ("Report and statistics", ( - ("Report basic file information", "Report basic file information", "self.OnMenuCmd", "r.info"), - ("Range of image values", "Range of image values", "self.OnMenuCmd", "r.describe"), - ("","","", ""), - ("Histogram image", "Histogram i