diff --git a/tests/danesfield/data/metrics-template-config.txt b/tests/danesfield/data/metrics-template-config.txt new file mode 100644 index 000000000..2e4be6220 --- /dev/null +++ b/tests/danesfield/data/metrics-template-config.txt @@ -0,0 +1,32 @@ +# Template based on: +# https://github.com/pubgeo/core3d-metrics/blob/a586a44/aoi-example/aoi-example.config +# +# Modifications: +# - CLSMatchValue + +[INPUT.REF] +DSMFilename = $ref_prefix-DSM.tif +DTMFilename = $ref_prefix-DTM.tif +CLSFilename = $ref_prefix-CLS.tif +NDXFilename = $ref_prefix-NDX.tif +MTLFilename = $ref_prefix-MTL.tif +#CLSMatchValue = [[6],[17],[6,17],[256]] +CLSMatchValue = 6 + +[INPUT.TEST] +DSMFilename = $test_dsm +CLSFilename = $test_cls +MTLFilename = $test_mtl +DTMFilename = $test_dtm + +[OPTIONS] +QuantizeHeight = false + +[PLOTS] +ShowPlots = false +SavePlots = true + +[MATERIALS.REF] +MaterialIndices = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14 +MaterialNames = Unclassified,Asphalt,Concrete/Stone,Glass,Tree,Non-tree vegetation,Metal,Ceramic,Soil,Solar panel,Water,Polymer,Unscored,Indeterminate,Indeterminate asphalt/concrete +MaterialIndicesToIgnore = 0,12,13 diff --git a/tests/danesfield/metrics/test_metrics_config.py b/tests/danesfield/metrics/test_metrics_config.py new file mode 100644 index 000000000..4c9be5cfd --- /dev/null +++ b/tests/danesfield/metrics/test_metrics_config.py @@ -0,0 +1,32 @@ +############################################################################### +# Copyright Kitware Inc. and Contributors +# Distributed under the Apache License, 2.0 (apache.org/licenses/LICENSE-2.0) +# See accompanying Copyright.txt and LICENSE files for details +############################################################################### +from danesfield.metrics.config import _current_path, get_filename, get_template, populate_template +from os.path import dirname, join + +data_dir = join(dirname(dirname(__file__)), 'data') + + +def test__current_path(): + danesfield_root = dirname(dirname(dirname(data_dir))) + assert _current_path() == join(danesfield_root, 'danesfield', 'metrics') + + +def test_get_filename(): + file1 = 'test_dsm.tif' + file2 = 'test_cls.tif' + assert get_filename(file1, file2) == 'test_dsm__test_cls.config' + + +def test_get_template(): + with open(join(data_dir, 'metrics-template-config.txt'), 'r') as f: + contents = f.read() + assert get_template() == contents + + +def test_populate_template(): + template = '$ref_prefix $test_dsm $test_cls $test_mtl $test_dtm' + populated = populate_template(template, 'prefix', 'dsm', 'cls', 'mtl', 'dtm') + assert populated == 'prefix dsm cls mtl dtm'