forked from OSGeo/grass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v.in.ogr: testsuite added (OSGeo#2292)
This PR adds a small testsuite for 2D and 3D vector point data.
- Loading branch information
Showing
7 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
# This script requires the GRASS GIS 7 North Caroline location | ||
|
||
export GRASS_OVERWRITE=1 | ||
|
||
# 2D output | ||
g.region vector=firestations@PERMANENT | ||
v.out.ogr input=firestations@PERMANENT output=firestations.gpkg format=GPKG | ||
|
||
# 3D output | ||
v.out.ogr input=precip_30ynormals_3d@PERMANENT output=precip_30ynormals_3d.shp lco="SHPT=POINTZ" format=ESRI_Shapefile |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PROJCS["NAD_1983_HARN_StatePlane_North_Carolina_FIPS_3200",GEOGCS["GCS_North_American_1983_HARN",DATUM["D_North_American_1983_HARN",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",609601.22],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-79.0],PARAMETER["Standard_Parallel_1",36.1666666666667],PARAMETER["Standard_Parallel_2",34.3333333333333],PARAMETER["Latitude_Of_Origin",33.75],UNIT["Meter",1.0]] |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
"""Test of v.in.ogr | ||
@author Markus Neteler | ||
""" | ||
from grass.gunittest.case import TestCase | ||
from grass.gunittest.gmodules import SimpleModule | ||
|
||
|
||
class TestOgrImport(TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
"""Use temporary region settings""" | ||
cls.use_temp_region() | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
"""!Remove the temporary region""" | ||
cls.del_temp_region() | ||
|
||
def tearDown(self): | ||
self.runModule( | ||
"g.remove", type="vector", flags="f", pattern="test_ogr_import_map*" | ||
) | ||
|
||
def test_1(self): | ||
|
||
self.assertModule( | ||
"v.in.ogr", | ||
"Import GeoPackage Format", | ||
input="data/firestations.gpkg", | ||
output="test_ogr_import_map", | ||
) | ||
|
||
self.runModule("g.region", vector="test_ogr_import_map") | ||
|
||
# Output of v.univar | ||
univar_string = """n=71 | ||
nmissing=0 | ||
nnull=0 | ||
min=0 | ||
max=4 | ||
range=4 | ||
sum=21 | ||
mean=0.295775 | ||
mean_abs=0.295775 | ||
population_stddev=0.719827 | ||
population_variance=0.518151 | ||
population_coeff_variation=2.4337 | ||
sample_stddev=0.724951 | ||
sample_variance=0.525553 | ||
kurtosis=8.86174 | ||
skewness=2.82871""" | ||
|
||
self.assertVectorFitsUnivar( | ||
map="test_ogr_import_map", | ||
reference=univar_string, | ||
column="WATER_RESC", | ||
precision=1e-8, | ||
) | ||
|
||
def test_2(self): | ||
|
||
self.assertModule( | ||
"v.in.ogr", | ||
"Import 3D SHAPE Format", | ||
input="data/precip_30ynormals_3d.shp", | ||
output="test_ogr_import_map", | ||
) | ||
|
||
self.runModule("g.region", vector="test_ogr_import_map") | ||
|
||
# Output of v.info | ||
univar_string = """n=136 | ||
nmissing=0 | ||
nnull=0 | ||
min=2.4384 | ||
max=1615.44 | ||
range=1613 | ||
sum=40827.7 | ||
mean=300.203 | ||
mean_abs=300.203 | ||
population_stddev=320.783 | ||
population_variance=102902 | ||
population_coeff_variation=1.06855 | ||
sample_stddev=321.969 | ||
sample_variance=103664 | ||
kurtosis=1.98052 | ||
skewness=1.45954""" | ||
|
||
self.assertVectorFitsUnivar( | ||
map="test_ogr_import_map", | ||
reference=univar_string, | ||
column="elev", | ||
precision=1e-8, | ||
) | ||
|
||
|
||
# class TestOgrImportFails(TestCase): | ||
# def test_error_handling_1(self): | ||
# # Wrong type | ||
# self.assertModuleFail( | ||
# "v.in.ogr", | ||
# input="data/firestations.gpkg", | ||
# type="kernel", | ||
# output="test_ogr_import_map", | ||
# ) | ||
|
||
|
||
if __name__ == "__main__": | ||
from grass.gunittest.main import test | ||
|
||
test() |