Skip to content
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

Closed
ErikNixdorf opened this issue Jul 31, 2020 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@ErikNixdorf
Copy link

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):

  • Operating System: Windows
  • GRASS GIS version 7.8.2
@ErikNixdorf ErikNixdorf added the bug Something isn't working label Jul 31, 2020
@neteler neteler changed the title v.out.vtk: Replace Geometry Output datatype "float" by "double"[Bug] [Bug] v.out.vtk: Replace Geometry Output datatype "float" by "double" Aug 9, 2020
@BadAssassin
Copy link
Contributor

BadAssassin commented Sep 1, 2020

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++) {

@ErikNixdorf
Copy link
Author

to me, it looks good. However, I am a bit wondering why you dont just replace floatby double in any case. But as I said, the case-sensitive solution provided above is good, too

@BadAssassin
Copy link
Contributor

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.

ninsbl pushed a commit to ninsbl/grass that referenced this issue Oct 26, 2022
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>
ninsbl pushed a commit to ninsbl/grass that referenced this issue Feb 17, 2023
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>
marisn pushed a commit to marisn/grass that referenced this issue Jun 2, 2023
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>
neteler pushed a commit to nilason/grass that referenced this issue Nov 7, 2023
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants