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
39e4bf40
Commit
39e4bf40
authored
14 years ago
by
Mickael Savinaud
Browse files
Options
Downloads
Patches
Plain Diff
ADD: test in cmake configuration to detect if GDAL can read HDF4_EOS file
parent
86347198
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMake/ImportGdal.cmake
+16
-0
16 additions, 0 deletions
CMake/ImportGdal.cmake
CMake/TestHDF4Open.cxx
+120
-0
120 additions, 0 deletions
CMake/TestHDF4Open.cxx
with
136 additions
and
0 deletions
CMake/ImportGdal.cmake
+
16
−
0
View file @
39e4bf40
...
...
@@ -178,6 +178,22 @@ IF(OTB_USE_EXTERNAL_GDAL)
"embeds its own libgeotiff and is compiled with --with-hide-internal-symbols=yes.
\n
"
"You might consider building GDAL yourself without using --with-hide-internal-symbols"
)
ENDIF
(
NOT CHECK_XTIFFOPEN_SYMBOL
)
# This test is known to fail with gdal build with some versions of hdf library
#${OTB_DATA_ROOT}/Input/MOD09Q1G_EVI.A2006233.h07v03.005.2008338190308.hdf -> Test KO
#${OTB_DATA_ROOT}/Input/GSSTF_NCEP.2b.2008.12.31.he5 -> Test OK
IF
(
OTB_DATA_ROOT
)
SET
(
CMAKE_REQUIRED_INCLUDES
${
GEOTIFF_INCLUDE_DIRS
}
;
${
TIFF_INCLUDE_DIRS
}
)
SET
(
CMAKE_REQUIRED_LIBRARIES
"
${
GDAL_LIBRARY
}
;
${
GEOTIFF_LIBRARY
}
;
${
TIFF_LIBRARY
}
"
)
CHECK_CXX_SOURCE_RUNS_ARGS
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/CMake/TestHDF4Open.cxx
${
OTB_DATA_ROOT
}
/Input/MOD09Q1G_EVI.A2006233.h07v03.005.2008338190308.hdf
CHECK_HDF4OPEN_SYMBOL
)
IF
(
NOT CHECK_HDF4OPEN_SYMBOL
)
MESSAGE
(
WARNING
"CHECK_HDF4OPEN_SYMBOL test failed : your platform exhibits a problem to read HDF4 files. So the HDF tests will be deactivated"
)
ENDIF
(
NOT CHECK_HDF4OPEN_SYMBOL
)
ENDIF
(
OTB_DATA_ROOT
)
ELSE
(
OTB_USE_EXTERNAL_GDAL
)
...
...
This diff is collapsed.
Click to expand it.
CMake/TestHDF4Open.cxx
0 → 100644
+
120
−
0
View file @
39e4bf40
/*
* TestHDF4Open.cxx
*
* Created on: 14 févr. 2011
* Author: Mickael Savinaud
*/
#include
<iostream>
#include
<string>
#include
<gdal_priv.h>
#include
<cpl_port.h>
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
2
)
{
std
::
cerr
<<
"Usage : "
<<
argv
[
0
]
<<
" <HDF4_filename> <ID number of the dataset>"
<<
std
::
endl
;
return
1
;
}
// Open File
GDALDataset
*
poDataset
;
GDALDataset
*
poDatasetSubDS
;
GDALAllRegister
();
poDataset
=
(
GDALDataset
*
)
GDALOpen
(
argv
[
1
],
GA_ReadOnly
);
if
(
poDataset
==
NULL
)
{
return
1
;
}
std
::
cout
<<
"HDF4 File : "
<<
argv
[
1
]
<<
std
::
endl
;
char
**
metadata
=
poDataset
->
GetMetadata
(
""
);
// Retrieve Attributes
char
**
metadataSDS
=
poDataset
->
GetMetadata
(
"SUBDATASETS"
);
// Retrieving child objects
int
selectedDSNameID
=
2
;
std
::
cout
<<
"ID of the subdataset : "
<<
selectedDSNameID
<<
std
::
endl
;
std
::
string
subDatasetName
(
metadataSDS
[
2
*
(
selectedDSNameID
-
1
)
]);
// +1 for i_DESC
size_t
found
=
subDatasetName
.
find
(
"="
);
if
(
found
==
std
::
string
::
npos
)
{
return
1
;
}
else
{
subDatasetName
.
erase
(
subDatasetName
.
begin
(),
subDatasetName
.
begin
()
+
found
+
1
);
std
::
cout
<<
"Name the subdataset : "
<<
subDatasetName
<<
std
::
endl
;
}
poDatasetSubDS
=
(
GDALDataset
*
)
GDALOpen
(
subDatasetName
.
c_str
(),
GA_ReadOnly
);
if
(
poDatasetSubDS
==
NULL
)
{
return
1
;
}
std
::
cout
<<
"Subdataset in the HDF4 file is open "
<<
std
::
endl
;
char
**
metadataSubDS
=
poDatasetSubDS
->
GetMetadata
(
""
);
// Retrieve Attributes
std
::
cout
<<
"Metadata[0] in SubDS : "
<<
metadataSubDS
[
0
]
<<
std
::
endl
;
int
xSize
=
poDatasetSubDS
->
GetRasterXSize
();
int
ySize
=
poDatasetSubDS
->
GetRasterYSize
();
int
nbBand
=
poDatasetSubDS
->
GetRasterCount
();
std
::
cout
<<
"xSize = "
<<
xSize
<<
", ySize = "
<<
ySize
<<
", nbBand = "
<<
nbBand
<<
std
::
endl
;
GDALRasterBand
*
rb
=
poDatasetSubDS
->
GetRasterBand
(
1
);
GDALDataType
pxlType
=
rb
->
GetRasterDataType
();
std
::
cout
<<
"Type GDAL = "
<<
GDALGetDataTypeName
(
pxlType
)
<<
std
::
endl
;
int
xSizeROI
=
xSize
;
int
ySizeROI
=
ySize
;
if
(
pxlType
==
GDT_Byte
)
{
std
::
cout
<<
"byte case : "
<<
sizeof
(
unsigned
char
)
<<
std
::
endl
;
typedef
unsigned
char
UCHAR
;
UCHAR
*
buffer
=
new
UCHAR
[
xSizeROI
*
ySizeROI
];
rb
->
RasterIO
(
GF_Read
,
0
,
0
,
xSizeROI
,
ySizeROI
,
buffer
,
xSizeROI
,
ySizeROI
,
pxlType
,
0
,
0
);
if
(
CPLGetLastErrorNo
()
>
0
)
{
return
1
;
}
std
::
cout
<<
"value = "
<<
static_cast
<
UCHAR
>
(
*
(
buffer
))
<<
std
::
endl
;
delete
[]
buffer
;
}
else
if
(
pxlType
==
GDT_Int16
)
{
std
::
cout
<<
"Int16 case : "
<<
sizeof
(
short
int
)
<<
std
::
endl
;
typedef
short
int
SHORT
;
SHORT
*
buffer
=
new
SHORT
[
xSizeROI
*
ySizeROI
];
rb
->
RasterIO
(
GF_Read
,
0
,
0
,
xSizeROI
,
ySizeROI
,
buffer
,
xSizeROI
,
ySizeROI
,
pxlType
,
0
,
0
);
if
(
CPLGetLastErrorNo
()
>
0
)
{
return
1
;
}
std
::
cout
<<
"value = "
<<
static_cast
<
SHORT
>
(
*
(
buffer
))
<<
std
::
endl
;
delete
[]
buffer
;
}
else
if
(
pxlType
==
GDT_Float32
)
{
std
::
cout
<<
"float case : "
<<
sizeof
(
float
)
<<
std
::
endl
;
float
*
buffer
=
new
float
[
xSizeROI
*
ySizeROI
];
rb
->
RasterIO
(
GF_Read
,
0
,
0
,
xSizeROI
,
ySizeROI
,
buffer
,
xSizeROI
,
ySizeROI
,
pxlType
,
0
,
0
);
if
(
CPLGetLastErrorNo
()
>
0
)
{
return
1
;
}
std
::
cout
<<
"value = "
<<
static_cast
<
float
>
(
*
(
buffer
))
<<
std
::
endl
;
delete
[]
buffer
;
}
GDALClose
(
poDatasetSubDS
);
GDALClose
(
poDataset
);
return
0
;
}
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