-
-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] v.out.vtk: Replace Geometry Output datatype "float" by "double" #864
Comments
Does this patch address the issue? I am not terribly familiar with VTK file format. diff --git a/vector/v.out.vtk/main.c b/vector/v.out.vtk/main.c
index ebad7cbf1..5c5974201 100644
--- a/vector/v.out.vtk/main.c
+++ b/vector/v.out.vtk/main.c
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
dp_opt->type = TYPE_INTEGER;
dp_opt->required = NO;
dp_opt->description =
- _("Number of significant digits (floating point only)");
+ _("Number of significant digits");
scale = G_define_option();
scale->key = "zscale";
@@ -152,8 +152,8 @@ int main(int argc, char *argv[])
if (dp_opt->answer) {
if (sscanf(dp_opt->answer, "%d", &dp) != 1)
G_fatal_error(_("Failed to interpret 'dp' parameter as an integer"));
- if (dp > 8 || dp < 0)
- G_fatal_error(_("dp has to be from 0 to 8"));
+ if (dp > 16 || dp < 0)
+ G_fatal_error(_("dp has to be from 0 to 16"));
}
else {
dp = 8; /*This value is taken from the lib settings in G_feature_easting */
diff --git a/vector/v.out.vtk/writeVTK.c b/vector/v.out.vtk/writeVTK.c
index 8b8ba60eb..66cd5e66a 100644
--- a/vector/v.out.vtk/writeVTK.c
+++ b/vector/v.out.vtk/writeVTK.c
@@ -199,7 +199,10 @@ int write_vtk_points(FILE * ascii, struct Map_info *Map, VTKInfo * info,
/*Write the coordinates into the vtk ascii file */
/************************************************/
- fprintf(ascii, "POINTS %i float\n", info->maxnumpoints);
+ if (dp > 8)
+ fprintf(ascii, "POINTS %i double\n", info->maxnumpoints);
+ else
+ fprintf(ascii, "POINTS %i float\n", info->maxnumpoints);
/*For every available vector type */
for (k = 0; k < typenum; k++) { |
to me, it looks good. However, I am a bit wondering why you dont just replace |
Like I said... I'm not terribly familiar with the VTK file usage, so I don't know if there is a specific need for float, so I included it just in case. I will submit a pull request. |
Geometric information in the VTK Polydata dataset output of the v.out.vtk function are now saved as datatype double instead of float which is more suitable considering the amount of digits in geographic coordinates. The 'POINTS n dataType' line now uses double dataType (float, double, int and more is allowed). Fixes OSGeo#864. Actual code change written by Brad ReDacted. Co-authored-by: Brad ReDacted <brad.redacted@outlook.com>
Geometric information in the VTK Polydata dataset output of the v.out.vtk function are now saved as datatype double instead of float which is more suitable considering the amount of digits in geographic coordinates. The 'POINTS n dataType' line now uses double dataType (float, double, int and more is allowed). Fixes OSGeo#864. Actual code change written by Brad ReDacted. Co-authored-by: Brad ReDacted <brad.redacted@outlook.com>
Geometric information in the VTK Polydata dataset output of the v.out.vtk function are now saved as datatype double instead of float which is more suitable considering the amount of digits in geographic coordinates. The 'POINTS n dataType' line now uses double dataType (float, double, int and more is allowed). Fixes OSGeo#864. Actual code change written by Brad ReDacted. Co-authored-by: Brad ReDacted <brad.redacted@outlook.com>
Geometric information in the VTK Polydata dataset output of the v.out.vtk function are now saved as datatype double instead of float which is more suitable considering the amount of digits in geographic coordinates. The 'POINTS n dataType' line now uses double dataType (float, double, int and more is allowed). Fixes OSGeo#864. Actual code change written by Brad ReDacted. Co-authored-by: Brad ReDacted <brad.redacted@outlook.com>
Describe the bug
Geometric information in the VTK Polydata dataset output of the v.out.vtk function are saved as datatype "float". However, considering the amount of digits in geographic coordinates, reading these vtk files with other vtk readers (e.g. ParaView) can result in a lack of precision
Expected behavior
Replace standard output format "float" by "double" for the geometry fields in order to overcome this problem
System description (please complete the following information):
The text was updated successfully, but these errors were encountered: