Commit 6f83fe52 authored by Julien Osman's avatar Julien Osman
Browse files

Merge branch '2262_Update_application_GetImageProjection' into 'release-8.0'

Use new metadata framework in Application::GetImageProjection

See merge request !900
parents 3d29ed97 012a75de
Pipeline #10042 passed with stages
in 82 minutes and 2 seconds
......@@ -20,7 +20,8 @@ Describe any changes made to existing applications, or new applications that hav
<!---
##### Tests
Describe the testing strategy for new features.
Describe the testing strategy for new features.
- [ ] validated through ... unitary test
-->
<!---
......
Test Bug2262.py
PROJCS["WGS 84 / UTM zone 31N",
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",3],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AXIS["Easting",EAST],
AXIS["Northing",NORTH],
AUTHORITY["EPSG","32631"]]
\ No newline at end of file
......@@ -1633,14 +1633,7 @@ unsigned int Application::GetImageNbBands(const std::string& key, unsigned int i
std::string Application::GetImageProjection(const std::string& key, unsigned int idx)
{
std::string proj;
const itk::MetaDataDictionary& dict = this->GetParameterImageBase(key, idx)->GetMetaDataDictionary();
if (!dict.HasKey(MetaDataKey::ProjectionRefKey))
return std::string("");
itk::ExposeMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey, proj);
return proj;
return this->GetImageMetadata(key, idx).GetProjectedGeometry();
}
unsigned long Application::PropagateRequestedRegion(const std::string& key, ImageBaseType::RegionType region, unsigned int idx)
......
# -*- coding: utf-8 -*-
#
# Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
Originally reported on gitlab as bug #2262:
https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues/2262
"""
def test(otbApplication, argv):
bandmath1 = otbApplication.Registry.CreateApplication("BandMath")
bandmath1.SetParameterStringList("il", [argv[1]])
bandmath1.SetParameterString("exp", "im1b1")
bandmath1.Execute()
bandmath2 = otbApplication.Registry.CreateApplication("BandMath")
bandmath2.ImportImage("il", bandmath1.ExportImage("out"))
bandmath2.SetParameterString("exp", "im1b1+1")
bandmath2.Execute()
with open(argv[2], 'w') as outfile:
outfile.write("Test Bug2262.py\n")
outfile.write(bandmath2.GetImageProjection("out"))
......@@ -84,8 +84,19 @@ add_test( NAME pyTvBug1899
Bug1899
${OTB_DATA_ROOT}/Input/veryverySmallFSATSW.tif
${TEMP}/pyTvBug1899Output.tif
)
)
add_test( NAME pyTvBug2262
COMMAND ${TEST_DRIVER}
--compare-ascii ${NOTOL}
${BASELINE_FILES}/pyTvBug2262Output.txt
${TEMP}/pyTvBug2262Output.txt
Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
Bug2262
${OTB_DATA_ROOT}/Input/Capitole_Rasterization.tif
${TEMP}/pyTvBug2262Output.txt
)
add_test( NAME pyTvBandMathOutXML
COMMAND ${TEST_DRIVER} Execute
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment