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
e990cbc2
Commit
e990cbc2
authored
16 years ago
by
Emmanuel Christophe
Browse files
Options
Downloads
Patches
Plain Diff
DOC: TileMapImageIO
parent
335f2b2d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Examples/IO/TileMapImageIOExample.cxx
+90
-3
90 additions, 3 deletions
Examples/IO/TileMapImageIOExample.cxx
with
90 additions
and
3 deletions
Examples/IO/TileMapImageIOExample.cxx
+
90
−
3
View file @
e990cbc2
...
...
@@ -25,6 +25,15 @@
// ${GeneratedFolder} 1.4835345 43.55968261 12
// Software Guide : EndCommandLineArgs
// Software Guide : BeginLatex
//
// First, we need to include several headers. There will be a bit of
// manual work going on here.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
#include
"itkRGBPixel.h"
#include
"otbImage.h"
#include
"otbImageFileReader.h"
...
...
@@ -33,6 +42,7 @@
#include
"otbExtractROI.h"
#include
"otbImageFileWriter.h"
#include
"ossim/projection/ossimTileMapModel.h"
// Software Guide : EndCodeSnippet
int
main
(
int
argc
,
char
*
argv
[]
)
{
...
...
@@ -47,14 +57,40 @@ int main( int argc, char* argv[] )
}
// Software Guide : BeginLatex
//
// We retrieve the input parameters:
// \begin{itemize}
// \item the input filename is a simple text file specifying the access
// modality to open street map data;
// \item the output file is the image where you want to save the result;
// \item the cache directory is necessary to keep the data retrieved from
// the internet. It can also be reused to minimize network access;
// \item longitude of the center of the scene;
// \item latitude of the center of the scene;
// \item depth which is inversely related to the resolution: when you increase
// the depth by one, you divide the resolution by two.
// \end{itemize}
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
char
*
inputFilename
=
argv
[
1
];
char
*
outputFilename
=
argv
[
2
];
char
*
cacheDirectory
=
argv
[
3
];
double
lon
=
atof
(
argv
[
4
]);
double
lat
=
atof
(
argv
[
5
]);
int
depth
=
atoi
(
argv
[
6
]);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We now instanciate the reader. As some parameters need to be given to the
// IO which is an \doxygen{otb}{TileMapImageIO}, we need to manually create it also:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
itk
::
RGBPixel
<
unsigned
char
>
RGBPixelType
;
typedef
otb
::
Image
<
RGBPixelType
,
2
>
ImageType
;
typedef
otb
::
ImageFileReader
<
ImageType
>
ReaderType
;
...
...
@@ -67,7 +103,22 @@ int main( int argc, char* argv[] )
readerTile
->
SetImageIO
(
tileIO
);
readerTile
->
SetFileName
(
inputFilename
);
readerTile
->
UpdateOutputInformation
();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Now, we potentially have an image of several Peta-bytes covering the whole world
// in the reader
// that's why we don't want to do an update before extracting a specific
// area.
//
// The coordinates are refered with an origin at the north pole and the
// change date meridian in Mercator projection. So we need to translate the latitude
// and the longitude in this funny coordinate system:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
otb
::
InverseSensorModel
<
double
>
ModelType
;
ModelType
::
Pointer
model
=
ModelType
::
New
();
...
...
@@ -79,6 +130,7 @@ int main( int argc, char* argv[] )
return
1
;
}
typedef
itk
::
Point
<
double
,
2
>
PointType
;
PointType
lonLatPoint
;
lonLatPoint
[
0
]
=
lon
;
...
...
@@ -86,7 +138,16 @@ int main( int argc, char* argv[] )
PointType
tilePoint
;
tilePoint
=
model
->
TransformPoint
(
lonLatPoint
);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// This enable us to use the \doxygen{otb}{ExtractROI} to retrieve only
// the area of interest and to avoid crashing our memory-limited computer.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
long
int
startX
=
static_cast
<
long
int
>
(
tilePoint
[
0
]);
long
int
startY
=
static_cast
<
long
int
>
(
tilePoint
[
1
]);
long
int
sizeX
=
500
;
...
...
@@ -103,14 +164,40 @@ int main( int argc, char* argv[] )
extractROIOsmFilter
->
SetSizeY
(
sizeY
);
extractROIOsmFilter
->
SetInput
(
readerTile
->
GetOutput
());
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Finally, we just plug this to the writer to save our nice map of
// the area:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
otb
::
ImageFileWriter
<
ImageType
>
WriterType
;
WriterType
::
Pointer
writer
=
WriterType
::
New
();
writer
->
SetFileName
(
outputFilename
);
writer
->
SetInput
(
extractROIOsmFilter
->
GetOutput
());
writer
->
Update
();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Figure~\ref{fig:TILEMAPIMAGEIOEXAMPLE} shows the output images created from
// open street map data.
//
//
// \begin{figure}
// \center
// \includegraphics[width=0.70\textwidth]{openStreetMap.eps}
// \itkcaption[Open street map]{Map created from open street map at depth 12 near Toulouse}
// \label{fig:TILEMAPIMAGEIOEXAMPLE}
// \end{figure}
//
// If your street is missing, go and improve the map.
//
// Software Guide : EndLatex
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