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
5441ae1a
Commit
5441ae1a
authored
13 years ago
by
Mickael Savinaud
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add a new projRef with the test about GDALImageIOWriteMetadata
parent
a64a3c47
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
Testing/Code/IO/otbGDALImageIOTestWriteMetadata.cxx
+56
-9
56 additions, 9 deletions
Testing/Code/IO/otbGDALImageIOTestWriteMetadata.cxx
with
56 additions
and
9 deletions
Testing/Code/IO/otbGDALImageIOTestWriteMetadata.cxx
+
56
−
9
View file @
5441ae1a
...
...
@@ -167,6 +167,7 @@ int otbGDALImageIOTestWriteMetadata(int argc, char * argv[])
options
.
push_back
(
"-setGCP"
);
testWriteMetadata
(
filenameTIFF
,
filenameHDR
,
options
,
file
);
file
<<
"=================================================="
<<
std
::
endl
;
//////////
// ProjRef, NoGCP, No GeoTransfo_ID
options
.
clear
();
...
...
@@ -197,6 +198,38 @@ int otbGDALImageIOTestWriteMetadata(int argc, char * argv[])
options
.
push_back
(
"-setGCP"
);
testWriteMetadata
(
filenameTIFF
,
filenameHDR
,
options
,
file
);
file
<<
"=================================================="
<<
std
::
endl
;
//////////
// ProjRefUTM, NoGCP, No GeoTransfo_ID
options
.
clear
();
options
.
push_back
(
"-setProjectionRef_UTM"
);
testWriteMetadata
(
filenameTIFF
,
filenameHDR
,
options
,
file
);
// ProjRefUTM, NoGCP, GeoTransfo_ID
options
.
push_back
(
"-setGeoTransform_ID"
);
testWriteMetadata
(
filenameTIFF
,
filenameHDR
,
options
,
file
);
// ProjRefUTM, GCP, GeoTransfo_ID
options
.
push_back
(
"-setGCP"
);
testWriteMetadata
(
filenameTIFF
,
filenameHDR
,
options
,
file
);
// ProjRefUTM, NoGCP, GeoTransfo
options
.
clear
();
options
.
push_back
(
"-setProjectionRef_UTM"
);
options
.
push_back
(
"-setGeoTransform"
);
testWriteMetadata
(
filenameTIFF
,
filenameHDR
,
options
,
file
);
// ProjRefUTM, GCP, GeoTransfo
options
.
push_back
(
"-setGCP"
);
testWriteMetadata
(
filenameTIFF
,
filenameHDR
,
options
,
file
);
// ProjRefUTM, GCP, No GeoTransfo
options
.
clear
();
options
.
push_back
(
"-setProjectionRef_UTM"
);
options
.
push_back
(
"-setGCP"
);
testWriteMetadata
(
filenameTIFF
,
filenameHDR
,
options
,
file
);
file
.
close
();
return
EXIT_SUCCESS
;
}
...
...
@@ -391,6 +424,7 @@ bool writeReadDatasetMetadata(std::string filename, std::vector<std::string> opt
// Set parameters
bool
setGCP
=
false
;
bool
setProjectionRef
=
false
;
bool
setProjectionRef_UTM
=
false
;
bool
setGeoTransform_ID
=
false
;
bool
setGeoTransform
=
false
;
...
...
@@ -413,8 +447,13 @@ bool writeReadDatasetMetadata(std::string filename, std::vector<std::string> opt
{
setProjectionRef
=
true
;
}
if
(
opt
.
compare
(
"-setProjectionRef_UTM"
)
==
0
)
{
setProjectionRef_UTM
=
true
;
}
}
// Check the driver used
GDALDriver
*
poDriver
;
char
**
papszMetadata
;
...
...
@@ -447,10 +486,10 @@ bool writeReadDatasetMetadata(std::string filename, std::vector<std::string> opt
poDstDS
=
poDriver
->
Create
(
filename
.
c_str
(),
128
,
128
,
1
,
GDT_Byte
,
papszOptions
);
OGRSpatialReference
oSRS
;
char
*
pszSRS_WKT
=
NULL
;
oSRS
.
SetWellKnownGeogCS
(
"WGS84"
);
oSRS
.
exportToWkt
(
&
pszSRS_WKT
);
OGRSpatialReference
oSRS
_GCP
;
char
*
pszSRS_WKT
_GCP
=
NULL
;
oSRS
_GCP
.
SetWellKnownGeogCS
(
"WGS84"
);
oSRS
_GCP
.
exportToWkt
(
&
pszSRS_WKT
_GCP
);
// Set GCP
if
(
setGCP
)
...
...
@@ -468,7 +507,7 @@ bool writeReadDatasetMetadata(std::string filename, std::vector<std::string> opt
gdalGcps
[
0
].
dfGCPY
=
43.6544262050905
;
gdalGcps
[
0
].
dfGCPZ
=
0
;
poDstDS
->
SetGCPs
(
gcpCount
,
gdalGcps
,
pszSRS_WKT
);
poDstDS
->
SetGCPs
(
gcpCount
,
gdalGcps
,
pszSRS_WKT
_GCP
);
delete
[]
gdalGcps
;
...
...
@@ -477,10 +516,17 @@ bool writeReadDatasetMetadata(std::string filename, std::vector<std::string> opt
}
// Set ProjectionRef
if
(
setProjectionRef
)
OGRSpatialReference
oSRS_ProjRef
;
char
*
pszSRS_WKT_ProjRef
=
NULL
;
if
(
setProjectionRef
||
setProjectionRef_UTM
)
{
//infoDatasetCreate->m_ProjRef = static_cast<std::string>(pszSRS_WKT);
poDstDS
->
SetProjection
(
pszSRS_WKT
);
oSRS_ProjRef
.
SetWellKnownGeogCS
(
"WGS84"
);
if
(
setProjectionRef_UTM
)
{
oSRS_ProjRef
.
SetUTM
(
31
,
TRUE
);
}
oSRS_ProjRef
.
exportToWkt
(
&
pszSRS_WKT_ProjRef
);
poDstDS
->
SetProjection
(
pszSRS_WKT_ProjRef
);
}
// Set GeoTransform
...
...
@@ -531,7 +577,8 @@ bool writeReadDatasetMetadata(std::string filename, std::vector<std::string> opt
// Once we're done, close properly the dataset
GDALClose
(
(
GDALDatasetH
)
poDstDS
);
CPLFree
(
pszSRS_WKT
);
CPLFree
(
pszSRS_WKT_GCP
);
CPLFree
(
pszSRS_WKT_ProjRef
);
//**************
// Open File
...
...
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