Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
otb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
273
Issues
273
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main Repositories
otb
Commits
de239598
Commit
de239598
authored
Nov 08, 2013
by
Julien Malik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: automatically adapt opt.gridspacing in ortho appli for WGS84 output
parent
b473642c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
9 deletions
+60
-9
Applications/Projections/otbOrthoRectification.cxx
Applications/Projections/otbOrthoRectification.cxx
+60
-9
No files found.
Applications/Projections/otbOrthoRectification.cxx
View file @
de239598
...
...
@@ -32,6 +32,8 @@
// Elevation handler
#include "otbWrapperElevationParametersHandler.h"
#include "otbGeographicalDistance.h"
#include "otbMacro.h"
namespace
otb
...
...
@@ -54,6 +56,8 @@ enum
Mode_OrthoFit
};
const
float
DefaultGridSpacingMeter
=
4.0
;
namespace
Wrapper
{
...
...
@@ -215,7 +219,7 @@ private:
// Deformation Field Spacing
AddParameter
(
ParameterType_Float
,
"opt.gridspacing"
,
"Resampling grid spacing"
);
SetDefaultParameterFloat
(
"opt.gridspacing"
,
4.0
);
SetDefaultParameterFloat
(
"opt.gridspacing"
,
DefaultGridSpacingMeter
);
SetParameterDescription
(
"opt.gridspacing"
,
"Resampling is done according to a coordinate mapping deformation grid, "
"whose pixel size is set by this parameter, and "
...
...
@@ -539,8 +543,53 @@ private:
}
}
break
;
}
}
}
// switch (GetParameterInt("outputs.mode") )
if
(
!
HasUserValue
(
"opt.gridspacing"
))
{
// Update opt.gridspacing
// In case output coordinate system is WG84,
if
(
m_OutputProjectionRef
==
otb
::
GeoInformationConversion
::
ToWKT
(
4326
))
{
// How much is 4 meters in degrees ?
typedef
itk
::
Point
<
float
,
2
>
FloatPointType
;
FloatPointType
point1
,
point2
;
typedef
otb
::
GeographicalDistance
<
FloatPointType
>
GeographicalDistanceType
;
GeographicalDistanceType
::
Pointer
geoDistanceCalculator
=
GeographicalDistanceType
::
New
();
// center
point1
[
0
]
=
GetParameterFloat
(
"outputs.ulx"
)
+
GetParameterFloat
(
"outputs.spacingx"
)
*
GetParameterInt
(
"outputs.sizex"
)
/
2
;
point1
[
1
]
=
GetParameterFloat
(
"outputs.uly"
)
+
GetParameterFloat
(
"outputs.spacingy"
)
*
GetParameterInt
(
"outputs.sizey"
)
/
2
;
// center + [1,0]
point2
[
0
]
=
point1
[
0
]
+
GetParameterFloat
(
"outputs.spacingx"
);
point2
[
1
]
=
point1
[
1
];
double
xgroundspacing
=
geoDistanceCalculator
->
Evaluate
(
point1
,
point2
);
otbAppLogINFO
(
"Output X ground spacing in meter = "
<<
xgroundspacing
);
// center + [0,1]
point2
[
0
]
=
point1
[
0
];
point2
[
1
]
=
point1
[
1
]
+
GetParameterFloat
(
"outputs.spacingy"
);
double
ygroundspacing
=
geoDistanceCalculator
->
Evaluate
(
point1
,
point2
);
otbAppLogINFO
(
"Output Y ground spacing in meter = "
<<
ygroundspacing
);
double
xgridspacing
=
DefaultGridSpacingMeter
*
GetParameterFloat
(
"outputs.spacingx"
)
/
xgroundspacing
;
double
ygridspacing
=
DefaultGridSpacingMeter
*
GetParameterFloat
(
"outputs.spacingy"
)
/
ygroundspacing
;
otbAppLogINFO
(
<<
DefaultGridSpacingMeter
<<
" meters in X direction correspond roughly to "
<<
xgridspacing
<<
" degrees"
);
otbAppLogINFO
(
<<
DefaultGridSpacingMeter
<<
" meters in Y direction correspond roughly to "
<<
ygridspacing
<<
" degrees"
);
// Use the smallest spacing (more precise grid)
double
optimalSpacing
=
std
::
min
(
vcl_abs
(
xgridspacing
),
vcl_abs
(
ygridspacing
)
);
otbAppLogINFO
(
"Setting grid spacing to "
<<
optimalSpacing
);
SetParameterFloat
(
"opt.gridspacing"
,
optimalSpacing
);
}
}
// if (!HasUserValue("opt.gridspacing"))
}
// if (HasValue("io.in"))
}
void
DoExecute
()
...
...
@@ -651,23 +700,25 @@ private:
GetParameterInt
(
"outputs.sizex"
)
*
GetParameterFloat
(
"outputs.spacingx"
)
/
GetParameterFloat
(
"opt.gridspacing"
)
));
deformationGridSize
[
1
]
=
static_cast
<
ResampleFilterType
::
SizeType
::
SizeValueType
>
(
vcl_abs
(
GetParameterInt
(
"outputs.sizey"
)
*
GetParameterFloat
(
"outputs.spacingy"
)
/
GetParameterFloat
(
"opt.gridspacing"
)
));
otbAppLogINFO
(
"Using a deformation grid
with a size of
"
<<
deformationGridSize
);
otbAppLogINFO
(
"Using a deformation grid
of size
"
<<
deformationGridSize
);
if
(
deformationGridSize
[
0
]
*
deformationGridSize
[
1
]
==
0
)
{
otbAppLogFATAL
(
"Deformation grid degenerated (size of 0). "
"You shall set opt.gridspacing appropriately. opt.gridspacing is homogenous to outputs.spacing parameters"
);
"You shall set opt.gridspacing appropriately. "
"opt.gridspacing units are the same as outputs.spacing units"
);
}
if
(
vcl_abs
(
GetParameterFloat
(
"opt.gridspacing"
))
<
vcl_abs
(
GetParameterFloat
(
"outputs.spacingx"
))
||
vcl_abs
(
GetParameterFloat
(
"opt.gridspacing"
))
<
vcl_abs
(
GetParameterFloat
(
"outputs.spacingy"
))
)
{
otbAppLogWARNING
(
"Resolution of deformation grid should not be better than "
"resolution of output image. Computation time will be slow, and precision of output won't be better. "
"You shall set opt.gridspacing appropriately."
);
otbAppLogWARNING
(
"Spacing of deformation grid should be at least equal to "
"spacing of output image. Otherwise, computation time will be slow, "
"and precision of output will not be better. "
"You shall set opt.gridspacing appropriately. "
"opt.gridspacing units are the same as outputs.spacing units"
);
}
//otb::GeoInformationConversion::ToWKT(4326)
m_ResampleFilter
->
SetDeformationFieldSpacing
(
gridSpacing
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment