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
Antoine Belvire
otb
Commits
f583c992
Commit
f583c992
authored
13 years ago
by
Guillaume Pasero
Browse files
Options
Downloads
Patches
Plain Diff
ENH: adapt application ObtainUTMZoneFromGeoPoint to new framework
parent
abfac2e9
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/otbObtainUTMZoneFromGeoPoint.cxx
+63
-74
63 additions, 74 deletions
Applications/Projections/otbObtainUTMZoneFromGeoPoint.cxx
with
63 additions
and
74 deletions
Applications/Projections/otbObtainUTMZoneFromGeoPoint.cxx
+
63
−
74
View file @
f583c992
...
...
@@ -15,95 +15,84 @@
PURPOSE, See the above copyright notices for more information.
=========================================================================*/
#include
"otbWrapperApplication.h"
#include
"otbWrapperApplicationFactory.h"
#include
<iostream>
#include
<fstream>
#include
"otbCommandLineArgumentParser.h"
#include
"otbMapProjections.h"
#include
"otbImage.h"
#include
"itkExceptionObject.h"
#include
"itkMacro.h"
#include
"otbUtils.h"
int
main
(
int
argc
,
char
*
argv
[])
namespace
otb
{
namespace
Wrapper
{
try
class
ObtainUTMZoneFromGeoPoint
:
public
Application
{
public:
/** Standard class typedefs. */
typedef
ObtainUTMZoneFromGeoPoint
Self
;
typedef
Application
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Standard macro */
itkNewMacro
(
Self
);
itkTypeMacro
(
ObtainUTMZoneFromGeoPoint
,
otb
::
Application
);
private:
ObtainUTMZoneFromGeoPoint
()
{
// Parse command line parameters
typedef
otb
::
CommandLineArgumentParser
ParserType
;
ParserType
::
Pointer
parser
=
ParserType
::
New
();
SetName
(
"ObtainUTMZoneFromGeoPoint"
);
SetDescription
(
"UTM zone determination from a geographic point."
);
// Documentation
SetDocName
(
"Obtain UTM Zone From Geo Point Application"
);
SetDocLongDescription
(
"UTM zone determination from a geographic point."
);
SetDocLimitations
(
"None"
);
SetDocAuthors
(
"OTB-Team"
);
SetDocSeeAlso
(
" "
);
parser
->
SetProgramDescription
(
"UTM zone determination from a geographic point"
);
parser
->
AddOption
(
"--Latitude"
,
"Latitude value of desired point"
,
"-lat"
);
parser
->
AddOption
(
"--Longitude"
,
"Longitude value of desired point"
,
"-lon"
);
AddDocTag
(
Tags
::
Coordinates
);
}
typedef
otb
::
CommandLineArgumentParseResult
ParserResultType
;
ParserResultType
::
Pointer
parseResult
=
ParserResultType
::
New
();
virtual
~
ObtainUTMZoneFromGeoPoint
()
{
}
try
void
DoCreateParameters
()
{
parser
->
ParseCommandLine
(
argc
,
argv
,
parseResult
);
AddParameter
(
ParameterType_Float
,
"lat"
,
"Latitude"
);
SetParameterDescription
(
"lat"
,
"Latitude value of desired point."
);
AddParameter
(
ParameterType_Float
,
"lon"
,
"Longitude"
);
SetParameterDescription
(
"lon"
,
"Longitude value of desired point."
);
AddParameter
(
ParameterType_Int
,
"utm"
,
"UTMZone"
);
SetParameterDescription
(
"utm"
,
"UTM Zone"
);
MandatoryOff
(
"utm"
);
SetParameterRole
(
"utm"
,
Role_Output
);
SetExampleComment
(
"Obtain a UTM Zone"
,
0
);
SetDocExampleParameterValue
(
"lat"
,
"10.0"
);
SetDocExampleParameterValue
(
"lon"
,
"124.0"
);
}
catch
(
itk
::
ExceptionObject
&
err
)
void
DoUpdateParameters
()
{
std
::
string
descriptionException
=
err
.
GetDescription
();
if
(
descriptionException
.
find
(
"ParseCommandLine(): Help Parser"
)
!=
std
::
string
::
npos
)
{
std
::
cout
<<
"WARNING : output file pixels are converted in 'unsigned char'"
<<
std
::
endl
;
return
EXIT_SUCCESS
;
}
if
(
descriptionException
.
find
(
"ParseCommandLine(): Version Parser"
)
!=
std
::
string
::
npos
)
{
return
EXIT_SUCCESS
;
}
return
EXIT_FAILURE
;
// Nothing to do
}
// Code
double
lon
=
parseResult
->
GetParameterDouble
(
"--Longitude"
);
double
lat
=
parseResult
->
GetParameterDouble
(
"--Latitude"
);
int
utmZone
=
otb
::
Utils
::
GetZoneFromGeoPoint
(
lon
,
lat
);
if
(
!
parseResult
->
IsOptionPresent
(
"--OTBTesting"
))
void
DoExecute
()
{
std
::
cout
<<
"Geographic Point (Lat, Lon) : ("
<<
lat
<<
","
<<
lon
<<
")"
<<
std
::
endl
;
std
::
cout
<<
"UTM Corresponding Zone : ==> "
<<
utmZone
<<
" <=="
<<
std
::
endl
;
int
utmZone
=
otb
::
Utils
::
GetZoneFromGeoPoint
(
GetParameterFloat
(
"lon"
),
GetParameterFloat
(
"lat"
));
SetParameterInt
(
"utm"
,
utmZone
);
}
else
{
std
::
string
outputTestFileName
=
parseResult
->
GetParameterString
(
"--OTBTesting"
,
0
);
};
std
::
ofstream
outputTestFile
;
outputTestFile
.
open
(
outputTestFileName
.
c_str
());
outputTestFile
<<
"Geographic Point (Lat, Lon) : ("
<<
lat
<<
","
<<
lon
<<
")"
<<
std
::
endl
;
outputTestFile
<<
"UTM Corresponding Zone : ==> "
<<
utmZone
<<
" <=="
<<
std
::
endl
;
outputTestFile
.
close
();
}
}
catch
(
itk
::
ExceptionObject
&
err
)
{
std
::
cout
<<
"Exception itk::ExceptionObject raised !"
<<
std
::
endl
;
std
::
cout
<<
err
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
catch
(
std
::
bad_alloc
&
err
)
{
std
::
cout
<<
"Exception bad_alloc : "
<<
(
char
*
)
err
.
what
()
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
catch
(
...
)
{
std
::
cout
<<
"Unknown exception raised !"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
return
EXIT_SUCCESS
;
}
}
OTB_APPLICATION_EXPORT
(
otb
::
Wrapper
::
ObtainUTMZoneFromGeoPoint
)
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