test_v_in_lidar_basic.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. """
  2. Name: decimation_test
  3. Purpose: v.in.lidar decimation test
  4. Author: Vaclav Petras
  5. Copyright: (C) 2015 by Vaclav Petras and the GRASS Development Team
  6. Licence: This program is free software under the GNU General Public
  7. License (>=v2). Read the file COPYING that comes with GRASS
  8. for details.
  9. """
  10. import os
  11. from grass.gunittest.case import TestCase
  12. from grass.gunittest.main import test
  13. class BasicTest(TestCase):
  14. """Test case for watershed module
  15. This tests expects v.random and v.out.lidar to work properly.
  16. """
  17. # Setup variables to be used for outputs
  18. vector_points = 'vinlidar_basic_original'
  19. imported_points = 'vinlidar_basic_imported'
  20. las_file = 'vinlidar_basic_points.las'
  21. npoints = 300
  22. @classmethod
  23. def setUpClass(cls):
  24. """Ensures expected computational region and generated data"""
  25. cls.use_temp_region()
  26. cls.runModule('g.region', n=20, s=10, e=25, w=15, res=1)
  27. cls.runModule('v.random', flags='zb', output=cls.vector_points,
  28. npoints=cls.npoints, zmin=200, zmax=500, seed=100)
  29. cls.runModule('v.out.lidar', input=cls.vector_points,
  30. output=cls.las_file)
  31. @classmethod
  32. def tearDownClass(cls):
  33. """Remove the temporary region and generated data"""
  34. cls.runModule('g.remove', flags='f', type='vector',
  35. name=cls.vector_points)
  36. if os.path.isfile(cls.las_file):
  37. os.remove(cls.las_file)
  38. cls.del_temp_region()
  39. def tearDown(self):
  40. """Remove the outputs created by the import
  41. This is executed after each test run.
  42. """
  43. self.runModule('g.remove', flags='f', type='vector',
  44. name=self.imported_points)
  45. def test_output_identical(self):
  46. """Test to see if the standard outputs are created"""
  47. self.assertModule('v.in.lidar', input=self.las_file,
  48. output=self.imported_points, flags='bt')
  49. self.assertVectorExists(self.imported_points)
  50. self.assertVectorEqualsVector(
  51. actual=self.imported_points,
  52. reference=self.vector_points,
  53. digits=2, precision=.01)
  54. if __name__ == '__main__':
  55. test()