Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Cabieces
otb
Commits
5a895bdd
Commit
5a895bdd
authored
4 years ago
by
Julien Osman
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Use GeomMetadataSupplier in ImageFileReader
parent
da215dfb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Modules/IO/ImageIO/include/otbImageFileReader.hxx
+46
-59
46 additions, 59 deletions
Modules/IO/ImageIO/include/otbImageFileReader.hxx
with
46 additions
and
59 deletions
Modules/IO/ImageIO/include/otbImageFileReader.hxx
+
46
−
59
View file @
5a895bdd
...
...
@@ -40,6 +40,7 @@
#include
"otbImageMetadata.h"
#include
"otbImageMetadataInterfaceFactory.h"
#include
"otbImageCommons.h"
#include
"otbGeomMetadataSupplier.h"
#include
"otbMacro.h"
...
...
@@ -443,13 +444,6 @@ void ImageFileReader<TOutputImage, ConvertPixelTraits>::GenerateOutputInformatio
otbLogMacro
(
Debug
,
<<
"No kwl metadata found in file "
<<
lFileNameOssimKeywordlist
);
}
}
MetadataSupplierInterface
*
mds
=
dynamic_cast
<
MetadataSupplierInterface
*>
(
m_ImageIO
.
GetPointer
());
if
(
mds
)
{
ImageMetadataInterfaceBase
::
Pointer
imi
=
ImageMetadataInterfaceFactory
::
CreateIMI
(
imd
,
mds
);
// update 'imd' with the parsed metadata
imd
=
imi
->
GetImageMetadata
();
}
}
// Don't add an empty ossim keyword list
...
...
@@ -457,45 +451,6 @@ void ImageFileReader<TOutputImage, ConvertPixelTraits>::GenerateOutputInformatio
{
itk
::
EncapsulateMetaData
<
ImageKeywordlist
>
(
dict
,
MetaDataKey
::
OSSIMKeywordlistKey
,
otb_kwl
);
}
/*else
{
//
// For image with world file, we have a non-null GeoTransform, an empty kwl, but no projection ref.
// Decision made here : if the keywordlist is empty, and the geotransform is not the identity,
// then assume the file is in WGS84
//
std::string projRef;
itk::ExposeMetaData(dict, MetaDataKey::ProjectionRefKey, projRef);
// Compute spacing for an identity geotransform at current resolution
unsigned int resolution = 0;
itk::ExposeMetaData<unsigned int>(dict,
MetaDataKey::ResolutionFactor,
resolution);
double idSpacing = 1.0;
if (resolution != 0)
idSpacing = 1.0 * std::pow((double)2.0, (double)resolution);
std::cout << "?" << std::endl;
std::cout << std::abs(origin[0] - 0.5 * spacing[0]) << std::endl;
std::cout << std::abs(origin[1] - 0.5 * spacing[1]) << std::endl;
std::cout << std::abs(spacing[0] - idSpacing) << std::endl;
std::cout << std::abs(spacing[1] - idSpacing) << std::endl;
const double epsilon = 1.0E-12;
if ( projRef.empty()
&& std::abs(origin[0] - 0.5 * spacing[0]) > epsilon
&& std::abs(origin[1] - 0.5 * spacing[1]) > epsilon
&& (std::abs(spacing[0] - idSpacing) > epsilon
&& std::abs(spacing[1] - idSpacing) > epsilon))
{
std::cout << "Force the projection ref" << std::endl;
std::string wgs84ProjRef =
"GEOGCS[\"GCS_WGS_1984\", DATUM[\"D_WGS_1984\", SPHEROID[\"WGS_1984\", 6378137, 298.257223563]],"
"PRIMEM[\"Greenwich\", 0], UNIT[\"Degree\", 0.017453292519943295]]";
itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey, wgs84ProjRef);
}
}*/
m_KeywordListUpToDate
=
true
;
}
...
...
@@ -507,21 +462,53 @@ void ImageFileReader<TOutputImage, ConvertPixelTraits>::GenerateOutputInformatio
// And add to new one
itk
::
EncapsulateMetaData
<
ImageKeywordlist
>
(
dict
,
MetaDataKey
::
OSSIMKeywordlistKey
,
otb_kwl
);
if
(
m_KeywordListUpToDate
)
{
// Read back from existing dictionary
if
(
img_common
!=
nullptr
)
{
imd
=
img_common
->
GetImageMetadata
();
}
}
if
(
m_FilenameHelper
->
GetSkipGeom
())
{
// Make sure the SensorGeometry is empty
imd
.
RemoveSensorGeometry
();
}
// if (m_KeywordListUpToDate)
// {
// // Read back from existing dictionary
// if (img_common != nullptr)
// {
// imd = img_common->GetImageMetadata();
// }
// }
// if (m_FilenameHelper->GetSkipGeom())
// {
// // Make sure the SensorGeometry is empty
// imd.RemoveSensorGeometry();
// }
}
// NEW METADATA FRAMEWORK
// This unique_ptr is used to keep the reference to the GeomMetadataSupplier (if any)
std
::
unique_ptr
<
MetadataSupplierInterface
>
unique_ptr_mds
;
// This pointer is used to receive the selected supplier
MetadataSupplierInterface
*
mds
;
std
::
string
DerivatedFileName
=
GetDerivedDatasetSourceFileName
(
m_FileName
);
std
::
string
extension
=
itksys
::
SystemTools
::
GetFilenameLastExtension
(
DerivatedFileName
);
std
::
string
attachedGeom
=
DerivatedFileName
.
substr
(
0
,
DerivatedFileName
.
size
()
-
extension
.
size
())
+
std
::
string
(
".geom"
);
// Case 1: external geom supplied through extended filename
if
(
!
m_FilenameHelper
->
GetSkipGeom
()
&&
m_FilenameHelper
->
ExtGEOMFileNameIsSet
())
{
unique_ptr_mds
=
std
::
make_unique
<
GeomMetadataSupplier
>
(
m_FilenameHelper
->
GetExtGEOMFileName
());
mds
=
unique_ptr_mds
.
get
();
}
// Case 2: attached geom (if present)
else
if
(
!
m_FilenameHelper
->
GetSkipGeom
()
&&
itksys
::
SystemTools
::
FileExists
(
attachedGeom
))
{
unique_ptr_mds
=
std
::
make_unique
<
GeomMetadataSupplier
>
(
attachedGeom
);
mds
=
unique_ptr_mds
.
get
();
}
// Case 3: tags in file
else
mds
=
dynamic_cast
<
MetadataSupplierInterface
*>
(
m_ImageIO
.
GetPointer
());
if
(
mds
)
{
ImageMetadataInterfaceBase
::
Pointer
imi
=
ImageMetadataInterfaceFactory
::
CreateIMI
(
imd
,
mds
);
// update 'imd' with the parsed metadata
imd
=
imi
->
GetImageMetadata
();
}
// If Skip ProjectionRef is activated, remove ProjRef from dict
if
(
m_FilenameHelper
->
GetSkipCarto
())
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment