Commit 794b6710 authored by Manuel Grizonnet's avatar Manuel Grizonnet

Merge branch 'develop' into missing_packages_superbuild_documentation

parents 4418ff7f 61c61e24
......@@ -158,20 +158,28 @@ OTB, through the use of the OSSIM library --
sensors either through a physical or an analytical approach. This is
transparent for the user, since the geometrical model for a given
image is instantiated using the information stored in its meta-data. The
search for a sensor model is not straightforward. It is done in 3 steps :
search for a sensor model is not straightforward. It is done in several steps :
\begin{enumerate}
\item Load an external \code{.geom} file specified through extended filenames
(if present)
\item Load the \code{.geom} file attached with the input image (if present).
They share the same name, without extension.
\item Search in the OSSIM plugin factory for a suitable model
(\code{ossimplugins::ossimPluginProjectionFactory}). For instance, this
factory contains Pl\'eiades and TerraSar sensor models.
\item If no model was found, search in the OSSIM projection factory
(\code{ossimProjectionFactoryRegistry}). For instance this factory contains
Spot5, Landsat and Quickbird sensor models.
\item If still no model was found, search for a valid sensor model defined
in an external \code{.geom} file. If no model is found, check if there are
any RPC tags embedded within the image (GDAL is used to detect those RPC
tags). When the tags are present, an \code{ossimRpcModel} is created.
\item If no model was found, search any RPC tags in the input image. When the
tags are present, an \code{ossimRpcModel} is created.
\item If still no model was found, search for a valid sensor model in other
files attached to the current dataset. For instance, with a Sentinel-1 SAFE XML
product, it will inspect underlying \code{.tiff} files. With a VRT dataset, it
will inspect the files referenced by the VRT.
\end{enumerate}
Note that the \code{.geom} metadata file can store any sensor model recognized
by OSSIM.
\subsection{Using Sensor Models}
\label{sec:UsingSensorModels}
......
......@@ -429,6 +429,9 @@ public:
* conversion)*/
void DoMapBuffer(void* buffer, size_t numberOfPixels, std::vector<unsigned int>& bandList);
/** Returns a const ref to the list of attached files*/
itkGetConstReferenceMacro(AttachedFileNames, std::vector<std::string> );
protected:
ImageIOBase();
~ImageIOBase() override;
......@@ -550,6 +553,9 @@ protected:
unsigned int numberOfActualSplits,
const itk::ImageIORegion &pasteRegion) const;
/** List of files part of the same dataset as the input filename */
std::vector<std::string> m_AttachedFileNames;
private:
ImageIOBase(const Self&) = delete;
void operator=(const Self&) = delete;
......
......@@ -435,7 +435,7 @@ void GDALImageIO::InternalReadImageInformation()
// supported gdal format using the m_DatasetNumber value
// HDF4_SDS:UNKNOWN:"myfile.hdf":2
// and make m_Dataset point to it.
if (m_Dataset->GetDataSet()->GetRasterCount() == 0)
if (m_Dataset->GetDataSet()->GetRasterCount() == 0 || m_DatasetNumber > 0)
{
// this happen in the case of a hdf file with SUBDATASETS
// Note: we assume that the datasets are in order
......@@ -659,6 +659,24 @@ void GDALImageIO::InternalReadImageInformation()
}
}
// get list of other files part of the same dataset
char** datasetFileList = dataset->GetFileList();
m_AttachedFileNames.clear();
if (datasetFileList != nullptr)
{
char** currentFile = datasetFileList;
while (*currentFile != nullptr)
{
if (m_FileName.compare(*currentFile) != 0)
{
m_AttachedFileNames.emplace_back(*currentFile);
otbLogMacro(Debug,<<"Found attached file : "<< *currentFile);
}
currentFile++;
}
CSLDestroy(datasetFileList);
}
/*----------------------------------------------------------------------*/
/*-------------------------- METADATA ----------------------------------*/
/*----------------------------------------------------------------------*/
......
......@@ -433,7 +433,20 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
}
else
{
otbLogMacro(Info,<< "No kwl metadata found in file "<<lFileNameOssimKeywordlist);
// Try attached files
for (const std::string& path : m_ImageIO->GetAttachedFileNames())
{
otb_kwl = ReadGeometryFromImage(path,!m_FilenameHelper->GetSkipRpcTag());
if(!otb_kwl.Empty())
{
otbLogMacro(Info,<< "Loading kwl metadata in attached file "<<path);
break;
}
}
if (otb_kwl.Empty())
{
otbLogMacro(Info,<< "No kwl metadata found in file "<<lFileNameOssimKeywordlist);
}
}
}
......
......@@ -75,6 +75,7 @@ otbCompareWritingComplexImage.cxx
otbImageFileReaderOptBandTest.cxx
otbImageFileWriterOptBandTest.cxx
otbMultiImageFileWriterTest.cxx
otbWriteGeomFile.cxx
)
add_executable(otbImageIOTestDriver ${OTBImageIOTests})
......@@ -1357,3 +1358,12 @@ otb_add_test(NAME ioTvMultiImageFileWriter_DiffSize
${TEMP}/ioTvMultiImageFileWriter_DiffSize1.tif
${TEMP}/ioTvMultiImageFileWriter_DiffSize2.tif
25)
otb_add_test(NAME ioTvCompoundMetadataReaderTest
COMMAND otbImageIOTestDriver
--compare-ascii ${EPSILON_9}
${INPUTDATA}/QB_Toulouse_SensorModel_labelImage.geom
${TEMP}/ioTvCompoundMetadataReaderTest.geom
otbWriteGeomFile
${INPUTDATA}/QB_Toulouse_combo.vrt
${TEMP}/ioTvCompoundMetadataReaderTest.tif)
......@@ -152,4 +152,5 @@ void RegisterTests()
REGISTER_TEST(otbImageFileReaderOptBandTest);
REGISTER_TEST(otbImageFileWriterOptBandTest);
REGISTER_TEST(otbMultiImageFileWriterTest);
REGISTER_TEST(otbWriteGeomFile);
}
/*
* Copyright (C) 2005-2017 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.
*/
#include "otbVectorImage.h"
#include "itkMacro.h"
#include <iostream>
#include "otbImageFileReader.h"
int otbWriteGeomFile(int itkNotUsed(argc), char* argv[])
{
// Verify the number of parameters in the command line
std::string inputFilename(argv[1]);
std::string outputFilename(argv[2]);
typedef double InputPixelType;
const unsigned int Dimension = 2;
typedef otb::VectorImage<InputPixelType, Dimension> InputImageType;
typedef otb::ImageFileReader<InputImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputFilename);
reader->UpdateOutputInformation();
otb::ImageKeywordlist otb_kwl;
itk::MetaDataDictionary &dict = reader->GetOutput()->GetMetaDataDictionary();
itk::ExposeMetaData<otb::ImageKeywordlist>(dict, otb::MetaDataKey::OSSIMKeywordlistKey, otb_kwl);
if (otb_kwl.Empty())
{
return EXIT_FAILURE;
}
otb::WriteGeometry(otb_kwl, outputFilename);
return EXIT_SUCCESS;
}
......@@ -33,8 +33,10 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wcast-align"
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wheader-guard"
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wheader-guard"
#endif
#endif
#include <shark/Models/Classifier.h>
#include "otb_shark.h"
......
......@@ -30,6 +30,9 @@
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wsign-compare"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wheader-guard"
#endif
#endif
#include "otb_shark.h"
#include "shark/Data/Dataset.h"
......
......@@ -68,7 +68,7 @@ public:
}
// Reimplement the SetActive method
void SetActive( const bool value ) override
void SetActive( bool value ) override
{
Superclass::SetActive( value );
m_StringParam->SetActive( value );
......
......@@ -83,7 +83,7 @@ public:
}
// Reimplement the SetActive method
void SetActive( const bool value ) override
void SetActive( bool value ) override
{
Superclass::SetActive( value );
m_UnsignedIntParam->SetActive( value );
......
Markdown is supported
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