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
David Youssefi
otb
Commits
bf6d0c20
Commit
bf6d0c20
authored
13 years ago
by
Emmanuel Christophe
Browse files
Options
Downloads
Patches
Plain Diff
STYLE: fix indentation
parent
8af3dae0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Utils/otbDEMConvert.cxx
+78
-79
78 additions, 79 deletions
Utils/otbDEMConvert.cxx
with
78 additions
and
79 deletions
Utils/otbDEMConvert.cxx
+
78
−
79
View file @
bf6d0c20
...
...
@@ -42,7 +42,6 @@
namespace
otb
{
template
<
typename
TPixelType
>
int
generic_convert_to_tif
(
otb
::
ApplicationOptionsResult
*
parseResult
,
std
::
string
tempFilename
)
{
...
...
@@ -101,119 +100,119 @@ int DEMConvert::Execute(otb::ApplicationOptionsResult* parseResult)
std
::
string
componentTypeInfo
(
reader
->
GetImageIO
()
->
GetComponentTypeInfo
().
name
());
if
(
componentTypeInfo
==
typeid
(
unsigned
char
).
name
())
{
generic_convert_to_tif
<
unsigned
char
>
(
parseResult
,
tempFilename
);
generic_convert_to_tif
<
unsigned
char
>
(
parseResult
,
tempFilename
);
}
else
if
(
componentTypeInfo
==
typeid
(
char
).
name
())
{
generic_convert_to_tif
<
char
>
(
parseResult
,
tempFilename
);
generic_convert_to_tif
<
char
>
(
parseResult
,
tempFilename
);
}
else
if
(
componentTypeInfo
==
typeid
(
unsigned
short
).
name
())
{
generic_convert_to_tif
<
unsigned
short
>
(
parseResult
,
tempFilename
);
generic_convert_to_tif
<
unsigned
short
>
(
parseResult
,
tempFilename
);
}
else
if
(
componentTypeInfo
==
typeid
(
short
).
name
())
{
generic_convert_to_tif
<
short
>
(
parseResult
,
tempFilename
);
generic_convert_to_tif
<
short
>
(
parseResult
,
tempFilename
);
}
else
if
(
componentTypeInfo
==
typeid
(
unsigned
int
).
name
())
{
generic_convert_to_tif
<
unsigned
int
>
(
parseResult
,
tempFilename
);
generic_convert_to_tif
<
unsigned
int
>
(
parseResult
,
tempFilename
);
}
else
if
(
componentTypeInfo
==
typeid
(
int
).
name
())
{
generic_convert_to_tif
<
int
>
(
parseResult
,
tempFilename
);
generic_convert_to_tif
<
int
>
(
parseResult
,
tempFilename
);
}
else
if
(
componentTypeInfo
==
typeid
(
unsigned
long
).
name
())
{
generic_convert_to_tif
<
unsigned
long
>
(
parseResult
,
tempFilename
);
generic_convert_to_tif
<
unsigned
long
>
(
parseResult
,
tempFilename
);
}
else
if
(
componentTypeInfo
==
typeid
(
long
).
name
())
{
generic_convert_to_tif
<
long
>
(
parseResult
,
tempFilename
);
generic_convert_to_tif
<
long
>
(
parseResult
,
tempFilename
);
}
else
if
(
componentTypeInfo
==
typeid
(
float
).
name
())
{
generic_convert_to_tif
<
float
>
(
parseResult
,
tempFilename
);
generic_convert_to_tif
<
float
>
(
parseResult
,
tempFilename
);
}
else
if
(
componentTypeInfo
==
typeid
(
double
).
name
())
{
generic_convert_to_tif
<
double
>
(
parseResult
,
tempFilename
);
generic_convert_to_tif
<
double
>
(
parseResult
,
tempFilename
);
}
else
{
itkExceptionMacro
(
"This appication doesn't support image pixel type "
<<
componentTypeInfo
);
return
EXIT_FAILURE
;
itkExceptionMacro
(
"This appication doesn't support image pixel type "
<<
componentTypeInfo
);
return
EXIT_FAILURE
;
}
// Keyword list to initialize image writers with.
ossimKeywordlist
kwl
;
const
char
*
PREFIX
=
"imagewriter."
;
// Define the output file type
const
ossimString
output_type
(
"general_raster_bsq_envi"
);
kwl
.
add
(
PREFIX
,
ossimKeywordNames
::
TYPE_KW
,
output_type
.
c_str
(),
true
);
ossimKeywordlist
kwl
;
const
char
*
PREFIX
=
"imagewriter."
;
// Define the output file type
const
ossimString
output_type
(
"general_raster_bsq_envi"
);
kwl
.
add
(
PREFIX
,
ossimKeywordNames
::
TYPE_KW
,
output_type
.
c_str
(),
true
);
// Get an image handler for the input file.
ossimRefPtr
<
ossimImageHandler
>
ih
=
ossimImageHandlerRegistry
::
instance
()
->
open
(
ossimString
(
tempFilename
));
// Get an image handler for the input file.
ossimRefPtr
<
ossimImageHandler
>
ih
=
ossimImageHandlerRegistry
::
instance
()
->
open
(
ossimString
(
tempFilename
));
// Initialize the
if
(
ih
->
getErrorStatus
()
==
ossimErrorCodes
::
OSSIM_ERROR
)
{
itkExceptionMacro
(
"Error reading image: "
<<
input_file
<<
"Exiting application..."
);
return
EXIT_FAILURE
;
}
// Initialize the
if
(
ih
->
getErrorStatus
()
==
ossimErrorCodes
::
OSSIM_ERROR
)
{
itkExceptionMacro
(
"Error reading image: "
<<
input_file
<<
"Exiting application..."
);
return
EXIT_FAILURE
;
}
ih
->
initialize
();
ih
->
initialize
();
ossimRefPtr
<
ossimImageSource
>
source
=
ih
.
get
();
ossimRefPtr
<
ossimBandSelector
>
bs
=
0
;
ossimRefPtr
<
ossimImageSource
>
source
=
ih
.
get
();
ossimRefPtr
<
ossimBandSelector
>
bs
=
0
;
// Get the image rectangle for the rrLevel selected.
ossimIrect
output_rect
;
output_rect
=
source
->
getBoundingRect
(
0
);
// Get the image rectangle for the rrLevel selected.
ossimIrect
output_rect
;
output_rect
=
source
->
getBoundingRect
(
0
);
ossimRefPtr
<
ossimImageFileWriter
>
writer
=
ossimImageWriterFactoryRegistry
::
instance
()
->
createWriter
(
kwl
,
PREFIX
);
ossimRefPtr
<
ossimImageFileWriter
>
writer
=
ossimImageWriterFactoryRegistry
::
instance
()
->
createWriter
(
kwl
,
PREFIX
);
writer
->
connectMyInputTo
(
0
,
source
.
get
());
writer
->
open
(
ossimFilename
(
parseResult
->
GetParameterString
(
"OutputPath"
))
+
".ras"
);
writer
->
connectMyInputTo
(
0
,
source
.
get
());
writer
->
open
(
ossimFilename
(
parseResult
->
GetParameterString
(
"OutputPath"
))
+
".ras"
);
// Add a listener to get percent complete.
ossimStdOutProgress
prog
(
0
,
true
);
writer
->
addListener
(
&
prog
);
if
(
writer
->
getErrorStatus
()
==
ossimErrorCodes
::
OSSIM_OK
)
{
if
(
(
ih
->
getOutputScalarType
()
!=
OSSIM_UCHAR
)
&&
(
PTR_CAST
(
ossimJpegWriter
,
writer
.
get
())
)
)
// Add a listener to get percent complete.
ossimStdOutProgress
prog
(
0
,
true
);
writer
->
addListener
(
&
prog
);
if
(
writer
->
getErrorStatus
()
==
ossimErrorCodes
::
OSSIM_OK
)
{
if
(
(
ih
->
getOutputScalarType
()
!=
OSSIM_UCHAR
)
&&
(
PTR_CAST
(
ossimJpegWriter
,
writer
.
get
())
)
)
{
writer
->
setScaleToEightBitFlag
(
true
);
writer
->
setScaleToEightBitFlag
(
true
);
}
ossimRefPtr
<
ossimCacheTileSource
>
cache
=
new
ossimCacheTileSource
;
ossimIpt
tileWidthHeight
(
ih
->
getImageTileWidth
(),
ih
->
getImageTileHeight
());
// only use the cache if its stripped
if
(
static_cast
<
ossim_uint32
>
(
tileWidthHeight
.
x
)
==
ih
->
getBoundingRect
().
width
())
ossimRefPtr
<
ossimCacheTileSource
>
cache
=
new
ossimCacheTileSource
;
ossimIpt
tileWidthHeight
(
ih
->
getImageTileWidth
(),
ih
->
getImageTileHeight
());
// only use the cache if its stripped
if
(
static_cast
<
ossim_uint32
>
(
tileWidthHeight
.
x
)
==
ih
->
getBoundingRect
().
width
())
{
cache
->
connectMyInputTo
(
0
,
source
.
get
());
cache
->
setTileSize
(
tileWidthHeight
);
writer
->
connectMyInputTo
(
0
,
cache
.
get
());
cache
->
connectMyInputTo
(
0
,
source
.
get
());
cache
->
setTileSize
(
tileWidthHeight
);
writer
->
connectMyInputTo
(
0
,
cache
.
get
());
}
else
else
{
writer
->
connectMyInputTo
(
0
,
source
.
get
());
writer
->
connectMyInputTo
(
0
,
source
.
get
());
}
writer
->
initialize
();
writer
->
setAreaOfInterest
(
output_rect
);
// Set the output rectangle.
writer
->
initialize
();
writer
->
setAreaOfInterest
(
output_rect
);
// Set the output rectangle.
try
try
{
writer
->
execute
();
writer
->
execute
();
}
catch
(
std
::
exception
&
e
)
catch
(
std
::
exception
&
e
)
{
std
::
cerr
<<
"std::exception thrown:"
<<
std
::
endl
;
std
::
cerr
<<
e
.
what
()
<<
std
::
endl
;
...
...
@@ -221,24 +220,24 @@ int DEMConvert::Execute(otb::ApplicationOptionsResult* parseResult)
return
EXIT_FAILURE
;
}
}
else
{
itkExceptionMacro
(
"Error detected in the image writer..."
);
return
EXIT_FAILURE
;
}
if
(
parseResult
->
IsOptionPresent
(
"KeepTif"
)
==
false
)
{
bool
resRemove
=
itksys
::
SystemTools
::
RemoveFile
(
tempFilename
.
c_str
());
if
(
resRemove
==
false
)
{
std
::
cout
<<
"Enable to erase the output temporary file "
<<
tempFilename
<<
"."
<<
std
::
endl
;
}
}
return
EXIT_SUCCESS
;
}
else
{
itkExceptionMacro
(
"Error detected in the image writer..."
);
return
EXIT_FAILURE
;
}
if
(
parseResult
->
IsOptionPresent
(
"KeepTif"
)
==
false
)
{
bool
resRemove
=
itksys
::
SystemTools
::
RemoveFile
(
tempFilename
.
c_str
());
if
(
resRemove
==
false
)
{
std
::
cout
<<
"Enable to erase the output temporary file "
<<
tempFilename
<<
"."
<<
std
::
endl
;
}
}
return
EXIT_SUCCESS
;
}
...
...
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