[GRASS-SVN] r52782 - grass/trunk/vector/v.transform
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 20 08:32:39 PDT 2012
Author: mmetz
Date: 2012-08-20 08:32:38 -0700 (Mon, 20 Aug 2012)
New Revision: 52782
Modified:
grass/trunk/vector/v.transform/main.c
Log:
v.transform fix for #1615
Modified: grass/trunk/vector/v.transform/main.c
===================================================================
--- grass/trunk/vector/v.transform/main.c 2012-08-20 15:26:09 UTC (rev 52781)
+++ grass/trunk/vector/v.transform/main.c 2012-08-20 15:32:38 UTC (rev 52782)
@@ -59,7 +59,7 @@
/* columns */
unsigned int i;
- int idx;
+ int idx, out3d;
char **tokens;
char *columns_name[7]; /* xshift, yshift, zshift, xscale, yscale, zscale, zrot */
@@ -181,6 +181,8 @@
Vect_check_input_output_name(vold->answer, vnew->answer, G_FATAL_EXIT);
+ out3d = WITHOUT_Z;
+
if (!table->answer && columns->answer) {
G_fatal_error(_("Table name is not defined. Please use '%s' parameter."),
table->key);
@@ -191,40 +193,6 @@
"Otherwise the table is overwritten."));
}
- /* open vector maps */
- Vect_open_old2(&Old, vold->answer, "", field->answer);
- Vect_open_new(&New, vnew->answer, Vect_is_3d(&Old) || tozero_flag->answer ||
- strcmp(zshift->answer, "0.0") || strcmp(zscale->answer, "1.0") ||
- strcmp(zrot->answer, "0.0") ? WITH_Z : WITHOUT_Z);
-
- /* copy and set header */
- Vect_copy_head_data(&Old, &New);
-
- Vect_hist_copy(&Old, &New);
- Vect_hist_command(&New);
-
- sprintf(date, "%s", G_date());
- sscanf(date, "%*s%s%d%*s%d", mon, &day, &yr);
- sprintf(date, "%s %d %d", mon, day, yr);
- Vect_set_date(&New, date);
-
- Vect_set_person(&New, G_whoami());
-
- sprintf(buf, "transformed from %s", vold->answer);
- Vect_set_map_name(&New, buf);
-
- Vect_set_scale(&New, 1);
- Vect_set_zone(&New, 0);
- Vect_set_thresh(&New, 0.0);
-
- Vect_get_map_box(&Old, &box);
-
- /* z to zero */
- if (tozero_flag->answer)
- ztozero = 0 - box.B;
- else
- ztozero = 0;
-
/* tokenize columns names */
for (i = 0; i <= IDX_ZROT; i++) {
columns_name[i] = NULL;
@@ -273,6 +241,46 @@
trans_params[IDX_ZSCALE] = atof(zscale->answer);
trans_params[IDX_ZROT] = atof(zrot->answer);
+ /* open vector maps */
+ Vect_open_old2(&Old, vold->answer, "", field->answer);
+
+ /* should output be 3D ?
+ * note that z-scale and ztozero have no effect with input 2D */
+ if (Vect_is_3d(&Old) || trans_params[IDX_ZSHIFT] != 0. ||
+ columns_name[IDX_ZSHIFT])
+ out3d = WITH_Z;
+
+ Vect_open_new(&New, vnew->answer, out3d);
+
+ /* copy and set header */
+ Vect_copy_head_data(&Old, &New);
+
+ Vect_hist_copy(&Old, &New);
+ Vect_hist_command(&New);
+
+ sprintf(date, "%s", G_date());
+ sscanf(date, "%*s%s%d%*s%d", mon, &day, &yr);
+ sprintf(date, "%s %d %d", mon, day, yr);
+ Vect_set_date(&New, date);
+
+ Vect_set_person(&New, G_whoami());
+
+ sprintf(buf, "transformed from %s", vold->answer);
+ Vect_set_map_name(&New, buf);
+
+ Vect_set_scale(&New, 1);
+ Vect_set_zone(&New, 0);
+ Vect_set_thresh(&New, 0.0);
+
+ Vect_get_map_box(&Old, &box);
+
+ /* z to zero */
+ if (tozero_flag->answer)
+ ztozero = 0 - box.B;
+ else
+ ztozero = 0;
+
+ /* do the transformation */
G_important_message(_("Tranforming features..."));
transform_digit_file(&Old, &New,
ztozero, swap_flag->answer, trans_params,
More information about the grass-commit
mailing list