[GRASS-SVN] r31659 - grass/trunk/raster/r.in.xyz
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jun 9 16:53:35 EDT 2008
Author: neteler
Date: 2008-06-09 16:53:35 -0400 (Mon, 09 Jun 2008)
New Revision: 31659
Modified:
grass/trunk/raster/r.in.xyz/local_proto.h
grass/trunk/raster/r.in.xyz/main.c
Log:
added zscale parameter
Modified: grass/trunk/raster/r.in.xyz/local_proto.h
===================================================================
--- grass/trunk/raster/r.in.xyz/local_proto.h 2008-06-09 07:49:12 UTC (rev 31658)
+++ grass/trunk/raster/r.in.xyz/local_proto.h 2008-06-09 20:53:35 UTC (rev 31659)
@@ -38,7 +38,7 @@
#define METHOD_TRIMMEAN 13
/* main.c */
-int scan_bounds(FILE*, int, int, int, char*, int, int);
+int scan_bounds(FILE*, int, int, int, char*, int, int, double);
/* support.c */
int blank_array(void *, int, int, RASTER_MAP_TYPE, int);
Modified: grass/trunk/raster/r.in.xyz/main.c
===================================================================
--- grass/trunk/raster/r.in.xyz/main.c 2008-06-09 07:49:12 UTC (rev 31658)
+++ grass/trunk/raster/r.in.xyz/main.c 2008-06-09 20:53:35 UTC (rev 31659)
@@ -126,6 +126,7 @@
double min = 0.0/0.0; /* init as nan */
double max = 0.0/0.0; /* init as nan */
+ double zscale = 1.0;
size_t offset, n_offset;
int n = 0;
double sum = 0.;
@@ -140,7 +141,7 @@
struct GModule *module;
struct Option *input_opt, *output_opt, *delim_opt, *percent_opt, *type_opt;
- struct Option *method_opt, *xcol_opt, *ycol_opt, *zcol_opt, *zrange_opt;
+ struct Option *method_opt, *xcol_opt, *ycol_opt, *zcol_opt, *zrange_opt, *zscale_opt;
struct Option *trim_opt, *pth_opt;
struct Flag *scan_flag, *shell_style, *skipline;
@@ -211,6 +212,14 @@
zrange_opt->key_desc = "min,max";
zrange_opt->description = _("Filter range for z data (min,max)");
+ zscale_opt = G_define_option();
+ zscale_opt->key = "zscale";
+ zscale_opt->type = TYPE_DOUBLE;
+ zscale_opt->required = NO;
+ zscale_opt->answer = "1.0";
+ zscale_opt->key_desc = "zscale";
+ zscale_opt->description = _("Scale to apply to z data");
+
percent_opt = G_define_option();
percent_opt->key = "percent";
percent_opt->type = TYPE_INTEGER;
@@ -274,6 +283,7 @@
max_col = (zcol > max_col) ? zcol : max_col;
percent = atoi(percent_opt->answer);
+ zscale = atof(zscale_opt->answer);
/* parse zrange */
do_zfilter = FALSE;
@@ -453,7 +463,7 @@
if( zrange_opt->answer )
G_warning(_("zrange will not be taken into account during scan"));
- scan_bounds(in_fp, xcol, ycol, zcol, fs, shell_style->answer, skipline->answer);
+ scan_bounds(in_fp, xcol, ycol, zcol, fs, shell_style->answer, skipline->answer, zscale);
if(!from_stdin)
fclose(in_fp);
@@ -597,6 +607,8 @@
}
if( 1 != sscanf(tokens[zcol-1], "%lf", &z) )
G_fatal_error(_("Bad z-coordinate line %d column %d. <%s>"), line, zcol, tokens[zcol-1]);
+
+ z=z/zscale;
if(zrange_opt->answer) {
if (z < zrange_min || z > zrange_max) {
G_free_tokens(tokens);
@@ -1011,7 +1023,7 @@
-int scan_bounds(FILE* fp, int xcol, int ycol, int zcol, char *fs, int shell_style, int skipline)
+int scan_bounds(FILE* fp, int xcol, int ycol, int zcol, char *fs, int shell_style, int skipline, double zscale)
{
int line, first, max_col;
char buff[BUFFSIZE];
@@ -1105,10 +1117,10 @@
fprintf(stderr,_("Range: min max\n"));
fprintf(stdout,"x: %11f %11f\n", min_x, max_x);
fprintf(stdout,"y: %11f %11f\n", min_y, max_y);
- fprintf(stdout,"z: %11f %11f\n", min_z, max_z);
+ fprintf(stdout,"z: %11f %11f\n", min_z/zscale, max_z/zscale);
} else
fprintf(stdout,"n=%f s=%f e=%f w=%f b=%f t=%f\n",
- max_y, min_y, max_x, min_x, min_z, max_z);
+ max_y, min_y, max_x, min_x, min_z/zscale, max_z/zscale);
G_debug(1, "Processed %d lines.", line);
G_debug(1, "region template: g.region n=%f s=%f e=%f w=%f",
More information about the grass-commit
mailing list