[GRASS-SVN] r36502 - grass/trunk/vector/v.surf.idw
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Mar 28 10:15:39 EDT 2009
Author: martinl
Date: 2009-03-28 10:15:39 -0400 (Sat, 28 Mar 2009)
New Revision: 36502
Modified:
grass/trunk/vector/v.surf.idw/main.c
grass/trunk/vector/v.surf.idw/proto.h
grass/trunk/vector/v.surf.idw/read_sites.c
Log:
v.surf.idw: flag 'z' introduced
Modified: grass/trunk/vector/v.surf.idw/main.c
===================================================================
--- grass/trunk/vector/v.surf.idw/main.c 2009-03-28 13:35:22 UTC (rev 36501)
+++ grass/trunk/vector/v.surf.idw/main.c 2009-03-28 14:15:39 UTC (rev 36502)
@@ -42,12 +42,11 @@
struct Point *noidxpoints = NULL;
struct list_Point *list;
static struct Cell_head window;
-static struct Flag *noindex;
void calculate_distances(int, int, double, double, int *);
void calculate_distances_noindex(double, double);
/* read_sites.c */
-void read_sites(char *, int, char *);
+void read_sites(char *, int, char *, int);
int main(int argc, char *argv[])
{
@@ -68,6 +67,10 @@
{
struct Option *input, *npoints, *output, *dfield, *col;
} parm;
+ struct
+ {
+ struct Flag *noindex, *withz;
+ } flag;
struct cell_list
{
int row, column;
@@ -98,24 +101,25 @@
parm.npoints->answer = "12";
parm.dfield = G_define_standard_option(G_OPT_V_FIELD);
- parm.dfield->description =
- _("If set to 0, z coordinates are used (3D vector only)");
parm.dfield->answer = "1";
parm.col = G_define_option();
parm.col->key = "column";
parm.col->type = TYPE_STRING;
parm.col->required = NO;
- parm.col->label = _("Attribute table column with values to interpolate");
- parm.col->description = _("Required if layer > 0");
+ parm.col->description = _("Attribute table column with values to interpolate");
- noindex = G_define_flag();
- noindex->key = 'n';
- noindex->label = _("Don't index points by raster cell");
- noindex->description = _("Slower but uses"
+ flag.noindex = G_define_flag();
+ flag.noindex->key = 'n';
+ flag.noindex->label = _("Don't index points by raster cell");
+ flag.noindex->description = _("Slower but uses"
" less memory and includes points from outside region"
" in the interpolation");
+ flag.withz = G_define_flag();
+ flag.withz->key = 'z';
+ flag.withz->description = _("Use z coordinates for approximation");
+
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
@@ -126,7 +130,7 @@
sscanf(parm.dfield->answer, "%d", &field);
- if (field > 0 && !parm.col->answer)
+ if (!flag.withz->answer && !parm.col->answer)
G_fatal_error(_("No attribute column specified"));
list =
@@ -137,7 +141,7 @@
/* get the window, dimension arrays */
G_get_window(&window);
- if (!noindex->answer) {
+ if (!flag.noindex->answer) {
npoints_currcell = (long **)G_malloc(window.rows * sizeof(long *));
points =
(struct Point ***)G_malloc(window.rows * sizeof(struct Point **));
@@ -158,13 +162,14 @@
}
/* read the elevation points from the input sites file */
- read_sites(parm.input->answer, field, parm.col->answer);
+ read_sites(parm.input->answer, flag.withz->answer ? 0 : field,
+ parm.col->answer, flag.noindex->answer);
if (npoints == 0)
G_fatal_error(_("No data points found"));
nsearch = npoints < search_points ? npoints : search_points;
- if (!noindex->answer) {
+ if (!flag.noindex->answer) {
/* Arbitrary point to switch between searching algorithms. Could do
* with refinement PK */
if ((window.rows * window.cols) / npoints > 400) {
@@ -270,7 +275,7 @@
/* If current cell contains more than nsearch points just average
* all the points in this cell and don't look in any others */
- if (!(noindex->answer) && npoints_currcell[row][col] >= nsearch) {
+ if (!(flag.noindex->answer) && npoints_currcell[row][col] >= nsearch) {
sum1 = 0.0;
for (i = 0; i < npoints_currcell[row][col]; i++)
sum1 += points[row][col][i].z;
@@ -278,7 +283,7 @@
interp_value = sum1 / npoints_currcell[row][col];
}
else {
- if (noindex->answer)
+ if (flag.noindex->answer)
calculate_distances_noindex(north, east);
else {
pointsfound = 0;
@@ -396,19 +401,19 @@
G_command_history(&history);
G_write_history(parm.output->answer, &history);
- G_done_msg("");
+ G_done_msg(" ");
exit(EXIT_SUCCESS);
}
-void newpoint(double z, double east, double north)
+void newpoint(double z, double east, double north, int noindex)
{
int row, column;
row = (int)((window.north - north) / window.ns_res);
column = (int)((east - window.west) / window.ew_res);
- if (!noindex->answer) {
+ if (!noindex) {
if (row < 0 || row >= window.rows || column < 0 ||
column >= window.cols) ;
else { /* Ignore sites outside current region as can't be indexed */
Modified: grass/trunk/vector/v.surf.idw/proto.h
===================================================================
--- grass/trunk/vector/v.surf.idw/proto.h 2009-03-28 13:35:22 UTC (rev 36501)
+++ grass/trunk/vector/v.surf.idw/proto.h 2009-03-28 14:15:39 UTC (rev 36502)
@@ -1 +1 @@
-void newpoint(double, double, double);
+void newpoint(double, double, double, int);
Modified: grass/trunk/vector/v.surf.idw/read_sites.c
===================================================================
--- grass/trunk/vector/v.surf.idw/read_sites.c 2009-03-28 13:35:22 UTC (rev 36501)
+++ grass/trunk/vector/v.surf.idw/read_sites.c 2009-03-28 14:15:39 UTC (rev 36502)
@@ -13,7 +13,7 @@
* mccauley
*/
-void read_sites(char *name, int field, char *col)
+void read_sites(char *name, int field, char *col, int noindex)
{
extern long npoints;
int nrec, ctype = 0, type;
@@ -90,7 +90,7 @@
else
dval = Points->z[0];
- newpoint(dval, Points->x[0], Points->y[0]);
+ newpoint(dval, Points->x[0], Points->y[0], noindex);
}
if (field > 0)
More information about the grass-commit
mailing list