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
Container Registry
Model registry
Operate
Environments
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
Main Repositories
otb
Commits
ac35381a
Commit
ac35381a
authored
13 years ago
by
Guillaume Pasero
Browse files
Options
Downloads
Patches
Plain Diff
ENH: adapt application ImageEnvelope to new framework
parent
6153e6a4
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
Applications/Projections/otbImageEnvelope.cxx
+90
-41
90 additions, 41 deletions
Applications/Projections/otbImageEnvelope.cxx
with
90 additions
and
41 deletions
Applications/Projections/otbImageEnvelope.cxx
+
90
−
41
View file @
ac35381a
...
...
@@ -15,63 +15,112 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include
"otbWrapperApplication.h"
#include
"otbWrapperApplicationFactory.h"
#include
"otbImage.h"
#include
"otbImageToEnvelopeVectorDataFilter.h"
#include
"otbVectorData.h"
#include
"otbImageFileReader.h"
#include
"otbVectorDataFileWriter.h"
#include
"otbCommandLineArgumentParser.h"
typedef
unsigned
short
PixelType
;
typedef
otb
::
Image
<
PixelType
,
2
>
ImageType
;
typedef
otb
::
ImageFileReader
<
ImageType
>
ReaderType
;
typedef
otb
::
VectorData
<>
VectorDataType
;
typedef
otb
::
VectorDataFileWriter
<
VectorDataType
>
WriterType
;
typedef
otb
::
ImageToEnvelopeVectorDataFilter
<
ImageType
,
VectorDataType
>
FilterType
;
namespace
otb
{
namespace
Wrapper
{
int
main
(
int
argc
,
char
*
argv
[])
class
ImageEnvelope
:
public
Application
{
public:
/** Standard class typedefs. */
typedef
ImageEnvelope
Self
;
typedef
Application
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
// Parse command line parameters
typedef
otb
::
CommandLineArgumentParser
ParserType
;
ParserType
::
Pointer
parser
=
ParserType
::
New
();
/** Standard macro */
itkNewMacro
(
Self
);
parser
->
SetProgramDescription
(
"Write a vector file containing a polygon corresponding to the image envelope."
);
parser
->
AddInputImage
();
parser
->
AddOption
(
"--OutputVectorData"
,
"Vector Data file containg the envelope"
,
"-out"
,
1
,
true
);
itkTypeMacro
(
ImageEnvelope
,
otb
::
Application
);
typedef
otb
::
CommandLineArgumentParseResult
ParserResultType
;
ParserResultType
::
Pointer
parseResult
=
ParserResultType
::
New
();
/** Filters typedef */
typedef
otb
::
ImageToEnvelopeVectorDataFilter
<
FloatVectorImageType
,
VectorDataType
>
EnvelopeFilterType
;
try
private:
ImageEnvelope
()
{
parser
->
ParseCommandLine
(
argc
,
argv
,
parseResult
);
SetName
(
"ImageEnvelope"
);
SetDescription
(
"Extracts an image envelope."
);
// Documentation
SetDocName
(
"Image Envelope Application"
);
SetDocLongDescription
(
"Build a vector data containing the polygon of the image envelope."
);
SetDocLimitations
(
"None"
);
SetDocAuthors
(
"OTB-Team"
);
SetDocSeeAlso
(
" "
);
SetDocCLExample
(
"otbApplicationLauncherCommandLine ImageEnvelope ${OTB-BIN}/bin "
"--in ${OTB-Data}/Input/sensor_stereo_left.tif --out envelope.shp"
);
AddDocTag
(
Tags
::
Geometry
);
}
catch
(
itk
::
ExceptionObject
&
err
)
virtual
~
ImageEnvelope
()
{
std
::
string
descriptionException
=
err
.
GetDescription
();
if
(
descriptionException
.
find
(
"ParseCommandLine(): Help Parser"
)
!=
std
::
string
::
npos
)
}
void
DoCreateParameters
()
{
AddParameter
(
ParameterType_InputImage
,
"in"
,
"Input Image"
);
SetParameterDescription
(
"in"
,
"Input image."
);
AddParameter
(
ParameterType_OutputVectorData
,
"out"
,
"Output Vector Data"
);
SetParameterDescription
(
"out"
,
"Vector data file containing the envelope"
);
AddParameter
(
ParameterType_Float
,
"ae"
,
"AverageElevation"
);
SetParameterDescription
(
"ae"
,
"If no DEM is used, provide the height value (default is 0 meters)"
);
SetDefaultParameterFloat
(
"ae"
,
0.0
);
MandatoryOff
(
"ae"
);
AddParameter
(
ParameterType_String
,
"dem"
,
"DEMDirectory"
);
SetParameterDescription
(
"dem"
,
"Use DEM tiles to derive height values (AverageElevation option is ignored in this case)"
);
MandatoryOff
(
"dem"
);
AddParameter
(
ParameterType_String
,
"proj"
,
"Projection"
);
SetParameterDescription
(
"proj"
,
"Projection to be used to compute the envelope (default is WGS84)"
);
MandatoryOff
(
"proj"
);
}
void
DoUpdateParameters
()
{
// Nothing to be done
}
void
DoExecute
()
{
FloatVectorImageType
::
Pointer
input
=
GetParameterImage
(
"in"
);
m_Envelope
=
EnvelopeFilterType
::
New
();
m_Envelope
->
SetInput
(
input
);
if
(
HasValue
(
"dem"
))
{
return
EXIT_SUCCESS
;
m_Envelope
->
SetDEMDirectory
(
GetParameterString
(
"dem"
))
;
}
if
(
descriptionException
.
find
(
"ParseCommandLine(): Version Parser"
)
!=
std
::
string
::
npos
)
else
{
return
EXIT_SUCCESS
;
m_Envelope
->
SetAverageElevation
(
GetParameterFloat
(
"ae"
))
;
}
return
EXIT_FAILURE
;
}
if
(
HasValue
(
"proj"
))
{
m_Envelope
->
SetOutputProjectionRef
(
GetParameterString
(
"proj"
));
}
SetParameterOutputVectorData
(
"out"
,
m_Envelope
->
GetOutput
());
}
ReaderType
::
Pointer
reader
=
ReaderType
::
New
();
reader
->
SetFileName
(
parseResult
->
GetInputImage
());
FilterType
::
Pointer
filter
=
FilterType
::
New
();
filter
->
SetInput
(
reader
->
GetOutput
());
WriterType
::
Pointer
writer
=
WriterType
::
New
();
writer
->
SetInput
(
filter
->
GetOutput
());
writer
->
SetFileName
(
parseResult
->
GetParameterString
(
"--OutputVectorData"
));
writer
->
Update
();
EnvelopeFilterType
::
Pointer
m_Envelope
;
return
EXIT_SUCCESS
;
};
}
}
OTB_APPLICATION_EXPORT
(
otb
::
Wrapper
::
ImageEnvelope
)
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