[GRASS-SVN] r67313 - in grass/trunk/vector/v.out.lidar: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 21 17:31:02 PST 2015


Author: wenzeslaus
Date: 2015-12-21 17:31:02 -0800 (Mon, 21 Dec 2015)
New Revision: 67313

Added:
   grass/trunk/vector/v.out.lidar/testsuite/
   grass/trunk/vector/v.out.lidar/testsuite/test_v_out_lidar.py
Modified:
   grass/trunk/vector/v.out.lidar/main.c
   grass/trunk/vector/v.out.lidar/v.out.lidar.html
Log:
v.out.lidar: scale the data with .01, add basic tests

Modified: grass/trunk/vector/v.out.lidar/main.c
===================================================================
--- grass/trunk/vector/v.out.lidar/main.c	2015-12-22 01:27:47 UTC (rev 67312)
+++ grass/trunk/vector/v.out.lidar/main.c	2015-12-22 01:31:02 UTC (rev 67313)
@@ -471,6 +471,7 @@
     struct Option *grass_rgb_column_opt;
     struct Option *red_column_opt, *green_column_opt, *blue_column_opt;
     struct Option *where_opt;
+    struct Option *las_xyscale_opt, *las_zscale_opt;
     struct Flag *region_flag, *no_color_table_flag;
     struct Map_info vinput;
 
@@ -600,6 +601,26 @@
     blue_column_opt->required = NO;
     blue_column_opt->guisection = _("Columns");
 
+    las_xyscale_opt = G_define_option();
+    las_xyscale_opt->key = "las_xyscale";
+    las_xyscale_opt->type = TYPE_DOUBLE;
+    las_xyscale_opt->required = YES;
+    las_xyscale_opt->answer = "0.01";
+    las_xyscale_opt->label = _("Internal scale to apply to X and Y values");
+    las_xyscale_opt->description = _("This scale does not change"
+        " the values itself but only how precisely they are stored,"
+        " for example 0.01 will preserve two decimal places");
+
+    las_zscale_opt = G_define_option();
+    las_zscale_opt->key = "las_zscale";
+    las_zscale_opt->type = TYPE_DOUBLE;
+    las_zscale_opt->required = YES;
+    las_zscale_opt->answer = "0.01";
+    las_zscale_opt->label = _("Internal scale to apply to z values");
+    las_zscale_opt->description = _("This scale does not change"
+        " the values itself but only how precisely they are stored,"
+        " for example 0.01 will preserve two decimal places");
+
     region_flag = G_define_flag();
     region_flag->key = 'r';
     region_flag->guisection = _("Selection");
@@ -682,6 +703,8 @@
 
     LASSRS_SetWKT(las_srs, current_wkt);
     LASHeader_SetSRS(las_header, las_srs);
+    LASHeader_SetScale(las_header, atof(las_xyscale_opt->answer),
+        atof(las_xyscale_opt->answer), atof(las_zscale_opt->answer));
     /* TODO: support append mode */
     int write_mode = 1;
 

Added: grass/trunk/vector/v.out.lidar/testsuite/test_v_out_lidar.py
===================================================================
--- grass/trunk/vector/v.out.lidar/testsuite/test_v_out_lidar.py	                        (rev 0)
+++ grass/trunk/vector/v.out.lidar/testsuite/test_v_out_lidar.py	2015-12-22 01:31:02 UTC (rev 67313)
@@ -0,0 +1,76 @@
+"""
+Name:      test_v_out_lidar
+Purpose:   v.out.lidar export test
+
+Author:    Vaclav Petras
+Copyright: (C) 2015 by Vaclav Petras and the GRASS Development Team
+Licence:   This program is free software under the GNU General Public
+           License (>=v2). Read the file COPYING that comes with GRASS
+           for details.
+"""
+
+import os
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+
+class BasicTest(TestCase):
+    """Test case for watershed module
+
+    This tests expects v.random to work properly.
+    """
+
+    # Setup variables to be used for outputs
+    vector_points = 'v_out_lidar_original'
+    imported_points = 'v_out_lidar_imported'
+    las_file = 'v_out_lidar_points.las'
+
+    @classmethod
+    def setUpClass(cls):
+        """Ensures expected computational region and generated data"""
+        cls.use_temp_region()
+        cls.runModule('g.region', n=20, s=10, e=25, w=15, res=1)
+        cls.runModule('v.random', flags='zb', output=cls.vector_points,
+            npoints=300, zmin=200, zmax=500, seed=100)
+
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the temporary region and generated data"""
+        cls.runModule('g.remove', flags='f', type='vector',
+            name=cls.vector_points)
+        cls.del_temp_region()
+
+    def tearDown(self):
+        """Remove the outputs created by the export
+
+        This is executed after each test run.
+        """
+        if os.path.isfile(self.las_file):
+            os.remove(self.las_file)
+        self.runModule('g.remove', flags='f', type='vector',
+            name=self.imported_points)
+
+    def test_module_runs_output_created(self):
+        """Test to see if the standard outputs are created"""
+        self.assertModule('v.out.lidar', input=self.vector_points,
+            output=self.las_file)
+        self.assertFileExists(self.las_file)
+
+    def test_output_identical(self):
+        """Test to see if the standard outputs are created
+
+        This test depends on v.in.lidar working properly.
+        """
+        self.assertModule('v.out.lidar', input=self.vector_points,
+            output=self.las_file)
+        self.assertModule('v.in.lidar', input=self.las_file,
+            output=self.imported_points, flags='bt')
+        self.assertVectorExists(self.imported_points)
+        self.assertVectorEqualsVector(
+            actual=self.imported_points,
+            reference=self.vector_points,
+            digits=2, precision=.01)
+
+
+if __name__ == '__main__':
+    test()

Modified: grass/trunk/vector/v.out.lidar/v.out.lidar.html
===================================================================
--- grass/trunk/vector/v.out.lidar/v.out.lidar.html	2015-12-22 01:27:47 UTC (rev 67312)
+++ grass/trunk/vector/v.out.lidar/v.out.lidar.html	2015-12-22 01:31:02 UTC (rev 67313)
@@ -9,7 +9,14 @@
 The <b>where</b> option limits the export by attributes (applied only
 when the columns are used for export).
 
+<p>
+LAS format stores the coordinates as integers rounding the decimal places.
+Before that a scale is applied to preserve a certain number of decimal
+places. This scale can be set using <b>las_xyscale</b> and <b>las_xscale</b>
+options. For example, the scale value 0.01 will preserve two decimal
+places while the value 1.0 will preserve none.
 
+
 <h2>NOTES</h2>
 
 The typical file extensions for the LAS format are .las and .laz (compressed).



More information about the grass-commit mailing list