Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NORMLIM_sigma0
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
s1-tiling
NORMLIM_sigma0
Commits
f40179bb
Commit
f40179bb
authored
2 years ago
by
Luc Hermitte
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Inject `nodata` automatically in image metadata
parent
a50cc19d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Resolve "Automatically inject NODATA metadata in generated images"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/otbExtractNormalVector.cxx
+4
-6
4 additions, 6 deletions
app/otbExtractNormalVector.cxx
app/otbSARComputeLocalIncidenceAngle.cxx
+5
-2
5 additions, 2 deletions
app/otbSARComputeLocalIncidenceAngle.cxx
include/otbApplicationWithNoData.h
+94
-0
94 additions, 0 deletions
include/otbApplicationWithNoData.h
with
103 additions
and
8 deletions
app/otbExtractNormalVector.cxx
+
4
−
6
View file @
f40179bb
...
...
@@ -23,7 +23,7 @@
#include
"otbRepack.h"
#include
"otbPositionHelpers.h"
#include
"otb
Wrapper
Application.h"
#include
"otbApplication
WithNoData
.h"
#include
"otbWrapperApplicationFactory.h"
#include
"otbFunctorImageFilter.h"
#include
"otbDEMHandler.h"
...
...
@@ -184,7 +184,7 @@ namespace Wrapper
* \ingroup App???
* \ingroup SARCalibrationExtended
*/
class
ExtractNormalVector
:
public
Application
class
ExtractNormalVector
:
public
Application
WithNoData
{
public:
/** Standard class typedefs. */
...
...
@@ -226,10 +226,7 @@ private:
AddParameter
(
ParameterType_OutputImage
,
"out"
,
"Image of normal vectors"
);
SetParameterDescription
(
"out"
,
"Image of normal vectors"
);
AddParameter
(
ParameterType_Float
,
"nodata"
,
"NoData value"
);
SetParameterDescription
(
"nodata"
,
"DEM empty cells are filled with this value (optional -32768 by default)"
);
SetDefaultParameterFloat
(
"nodata"
,
-
32768
);
MandatoryOff
(
"nodata"
);
DoInit_NoData
();
AddRAMParameter
();
...
...
@@ -249,6 +246,7 @@ private:
auto
const
nodata
=
GetParameterFloat
(
"nodata"
);
// std::cout << "nodata => " << nodata << std::endl;
AddNodataInMetadata
(
nodata
);
auto
const
spacing
=
inputImage
->
GetSignedSpacing
();
FloatType
const
x_spacing
=
spacing
[
0
];
...
...
This diff is collapsed.
Click to expand it.
app/otbSARComputeLocalIncidenceAngle.cxx
+
5
−
2
View file @
f40179bb
...
...
@@ -19,7 +19,7 @@
*/
#include
"otbSARComputeLocalIncidenceAngle.h"
#include
"otb
Wrapper
Application.h"
#include
"otbApplication
WithNoData
.h"
#include
"otbWrapperApplicationFactory.h"
// #define DOUBLES_EVERYWHERE
...
...
@@ -47,7 +47,7 @@ namespace Wrapper
* \ingroup App???
* \ingroup SARCalibrationExtended
*/
class
SARComputeLocalIncidenceAngle
:
public
Application
class
SARComputeLocalIncidenceAngle
:
public
Application
WithNoData
{
public:
/** Standard class typedefs. */
...
...
@@ -109,6 +109,7 @@ private:
#endif
SetParameterDescription
(
k_out_sin
,
"Output image with abs(sin LIA)"
);
DoInit_NoData
();
AddParameter
(
ParameterType_Float
,
"nodata"
,
"NoData value"
);
SetParameterDescription
(
"nodata"
,
"DEM empty cells are filled with this value (optional -32768 by default)"
);
SetDefaultParameterFloat
(
"nodata"
,
-
32768
);
...
...
@@ -139,6 +140,8 @@ private:
// filter->ShallComputeLIASign(true);
auto
const
nodata
=
GetParameterFloat
(
"nodata"
);
AddNodataInMetadata
(
nodata
,
k_out_lia
);
AddNodataInMetadata
(
nodata
,
k_out_sin
);
filter
->
SetNoData
(
nodata
);
SetParameterOutputImage
(
k_out_sin
,
filter
->
GetSinOutputImage
());
...
...
This diff is collapsed.
Click to expand it.
include/otbApplicationWithNoData.h
0 → 100644
+
94
−
0
View file @
f40179bb
/*
* 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.
*/
#ifndef otbApplicationWithNoData_h
#define otbApplicationWithNoData_h
#include
"otbWrapperApplication.h"
namespace
otb
{
namespace
Wrapper
{
/** Helper parent class for application that need to inject `&nodata=` in
* metadata.
*
* This class provides two services:
* - `DoInit_NoData()` meant to be called from `DoInit()` specialisation.
* - `AddNodataInMetadata()` meant to be called from `DoExecute()`
* specialisation.
*
* \author Luc Hermitte
* \copyright CS Group
* \ingroup App???
* \ingroup SARCalibrationExtended
*/
class
ApplicationWithNoData
:
public
Application
{
protected:
/**
* Registers a `-nodata` parameter.
*/
void
DoInit_NoData
()
{
AddParameter
(
ParameterType_Float
,
"nodata"
,
"NoData value"
);
SetParameterDescription
(
"nodata"
,
"DEM empty cells are filled with this value (optional -32768 by default)"
);
SetDefaultParameterFloat
(
"nodata"
,
-
32768
);
MandatoryOff
(
"nodata"
);
}
/**
* Appends `&nodata={value}` at the end of the extended filename to force
* nodata to be added in metadata.
*/
template
<
typename
FloatType
>
void
AddNodataInMetadata
(
FloatType
nodata
,
std
::
string
const
&
out_param
=
"out"
)
{
std
::
string
origin_FileName
=
GetParameterString
(
out_param
);
std
::
ostringstream
oss
;
oss
<<
origin_FileName
;
// Check if FileName is extended (with the ? caracter)
// If not extended then override the FileName
auto
const
extension_start
=
origin_FileName
.
find
(
'?'
);
if
(
extension_start
==
std
::
string
::
npos
&&
!
origin_FileName
.
empty
())
oss
<<
'?'
;
else
{
auto
const
nodata_start
=
origin_FileName
.
find
(
"&nodata="
);
if
(
nodata_start
>
extension_start
)
{
// Let's trust the end-user. Even if the value doesn't match
otbLogMacro
(
Warning
,
<<
"Trusting the nodata value required in extended filename. User specified "
<<
nodata
<<
" value won't be propagated in image metadata"
);
return
;
}
}
oss
<<
"&nodata="
<<
nodata
;
// Set the new FileName with extended options
SetParameterString
(
out_param
,
oss
.
str
());
}
};
}
//end namespace Wrapper
}
//end namespace otb
#endif // otbApplicationWithNoData_h
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