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
1086bc20
There was an error fetching the commit references. Please try again later.
Commit
1086bc20
authored
13 years ago
by
Mickael Savinaud
Browse files
Options
Downloads
Patches
Plain Diff
WIP: add tests about vectordata extract + proj
parent
a251461a
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
Testing/Code/Projections/CMakeLists.txt
+37
-6
37 additions, 6 deletions
Testing/Code/Projections/CMakeLists.txt
Testing/Code/Projections/otbVectorDataIntoImageProjectionFilterTest.cxx
+70
-46
70 additions, 46 deletions
...rojections/otbVectorDataIntoImageProjectionFilterTest.cxx
with
107 additions
and
52 deletions
Testing/Code/Projections/CMakeLists.txt
+
37
−
6
View file @
1086bc20
...
...
@@ -932,15 +932,46 @@ ADD_TEST(prTvVectorDataProjectionFilterFromMapToImage ${PROJECTIONS_TESTS3}
${
TEMP
}
/prTvVectorDataProjectionFilterFromMapToImage.kml
)
ADD_TEST
(
prTvVectorDataIntoImageProjectionFilter
${
PROJECTIONS_TESTS3
}
#--compare-ascii ${NOTOL}
#${BASELINE_FILES}/prTvVectorDataProjectionFilterFromMapToImage.kml
#${TEMP}/prTvVectorDataProjectionFilterFromMapToImage.kml
# extract from image QB and MidiPyrenees vectordata
ADD_TEST
(
prTvVectorData_ProjRef_ProjIntoImage_WithProjRef_Extract_Filter0
${
PROJECTIONS_TESTS3
}
otbVectorDataIntoImageProjectionFilterTest
${
INPUTDATA
}
/Classification/QB_1_ortho.tif
${
INPUTDATA
}
/Classification/VectorData_QB1.shp
${
INPUTDATA
}
/QB_extract_512x512.tif
${
LARGEINPUT
}
/VECTOR/MidiPyrenees/roads.shp
${
INPUTDATA
}
/DEM/srtm_directory
${
TEMP
}
/prTvVectorDataProjRefProjIntoImageWithProjRef10.shp
${
TEMP
}
/prTvVectorDataProjRefProjIntoImageWithProjRef10.txt
0
)
ADD_TEST
(
prTvVectorData_ProjRef_ProjIntoImage_WithProjRef_ExtractLeftUp_Filter0
${
PROJECTIONS_TESTS3
}
otbVectorDataIntoImageProjectionFilterTest
${
INPUTDATA
}
/QB_extract_leftup_256x2048.tif
${
LARGEINPUT
}
/VECTOR/MidiPyrenees/roads.shp
${
INPUTDATA
}
/DEM/srtm_directory
${
TEMP
}
/prTvVectorDataProjRefProjIntoImageWithProjRef20.shp
${
TEMP
}
/prTvVectorDataProjRefProjIntoImageWithProjRef20.txt
0
)
ADD_TEST
(
prTvVectorData_ProjRef_ProjIntoImage_WithProjRef_Extract_Filter1
${
PROJECTIONS_TESTS3
}
otbVectorDataIntoImageProjectionFilterTest
${
INPUTDATA
}
/QB_extract_512x512.tif
${
LARGEINPUT
}
/VECTOR/MidiPyrenees/roads.shp
${
INPUTDATA
}
/DEM/srtm_directory
${
TEMP
}
/prTvVectorDataProjRefProjIntoImageWithProjRef11.shp
${
TEMP
}
/prTvVectorDataProjRefProjIntoImageWithProjRef11.txt
1
)
ADD_TEST
(
prTvVectorData_ProjRef_ProjIntoImage_WithProjRef_ExtractLeftUp_Filter1
${
PROJECTIONS_TESTS3
}
otbVectorDataIntoImageProjectionFilterTest
${
INPUTDATA
}
/QB_extract_leftup_256x2048.tif
${
LARGEINPUT
}
/VECTOR/MidiPyrenees/roads.shp
${
INPUTDATA
}
/DEM/srtm_directory
${
TEMP
}
/prTvVectorDataProjRefProjIntoImageWithProjRef21.shp
${
TEMP
}
/prTvVectorDataProjRefProjIntoImageWithProjRef21.txt
1
)
ADD_TEST
(
prTuGeocentricTransformNew
${
PROJECTIONS_TESTS3
}
otbGeocentricTransformNew
)
...
...
This diff is collapsed.
Click to expand it.
Testing/Code/Projections/otbVectorDataIntoImageProjectionFilterTest.cxx
+
70
−
46
View file @
1086bc20
...
...
@@ -15,6 +15,8 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include
<fstream>
#include
"itkExceptionObject.h"
#include
"otbMacro.h"
...
...
@@ -23,61 +25,70 @@
#include
"otbImageFileReader.h"
#include
"otbVectorData.h"
#include
"otbVectorDataFileReader.h"
#include
"otbVectorDataFileWriter.h"
#include
"otbVectorDataIntoImageProjectionFilter.h"
int
otbVectorDataIntoImageProjectionFilterTest
(
int
argc
,
char
*
argv
[])
{
typedef
float
PixelType
;
typedef
otb
::
VectorImage
<
PixelType
,
2
>
VectorImageType
;
typedef
otb
::
Image
<
PixelType
,
2
>
ImageType
;
typedef
otb
::
VectorImage
<
PixelType
,
2
>
VectorImageType
;
typedef
otb
::
Image
<
PixelType
,
2
>
ImageType
;
typedef
otb
::
ImageFileReader
<
VectorImageType
>
ReaderType
;
// Vector Data
typedef
otb
::
VectorData
<>
VectorDataType
;
typedef
otb
::
VectorDataFileReader
<
VectorDataType
>
VectorDataReaderType
;
typedef
otb
::
VectorDataFileWriter
<
VectorDataType
>
VectorDataWriterType
;
//
typedef
otb
::
VectorDataIntoImageProjectionFilter
<
VectorDataType
,
VectorImageType
>
VectorDataReProjFilter
;
typedef
otb
::
VectorDataIntoImageProjectionFilter
<
VectorDataType
,
VectorImageType
>
VectorDataReProjFilter
;
typedef
itk
::
PreOrderTreeIterator
<
VectorDataType
::
DataTreeType
>
TreeIteratorType
;
std
::
string
imageInputFilename
=
argv
[
1
];
std
::
string
vectorDataInputFilename
=
argv
[
2
];
std
::
string
demDirectory
=
argv
[
3
];
std
::
string
vectorDataOutputFilename
=
argv
[
4
];
std
::
string
txtOutputFilename
=
argv
[
5
];
std
::
cout
<<
imageInputFilename
<<
"
\n
"
<<
vectorDataInputFilename
<<
"
\n
"
<<
demDirectory
<<
"
\n
"
<<
vectorDataOutputFilename
<<
"
\n
"
<<
txtOutputFilename
<<
std
::
endl
;
// Read the image
ReaderType
::
Pointer
reader
=
ReaderType
::
New
();
reader
->
SetFileName
(
argv
[
1
]
);
reader
->
SetFileName
(
imageInputFilename
);
reader
->
UpdateOutputInformation
();
std
::
cout
<<
"Processing image: "
<<
reader
->
GetFileName
()
<<
std
::
endl
;
// read the Vector Data
VectorDataReaderType
::
Pointer
vdReader
=
VectorDataReaderType
::
New
();
vdReader
->
SetFileName
(
argv
[
2
]
);
vdReader
->
SetFileName
(
vectorDataInputFilename
);
vdReader
->
Update
();
std
::
cout
<<
"Processing vectorData: "
<<
vdReader
->
GetFileName
()
<<
std
::
endl
;
std
::
cout
<<
"Set input data to read data DONE"
<<
std
::
endl
;
std
::
ofstream
file
;
file
.
open
(
txtOutputFilename
.
c_str
());
file
<<
"--- IMAGE INPUT ---"
<<
std
::
endl
;
file
<<
"Spacing of the input image: "
<<
reader
->
GetOutput
()
->
GetSpacing
()
<<
std
::
endl
;
file
<<
"Origin of the input image: "
<<
reader
->
GetOutput
()
->
GetOrigin
()
<<
std
::
endl
;
file
<<
"Size of the input image: "
<<
reader
->
GetOutput
()
->
GetLargestPossibleRegion
()
<<
std
::
endl
;
file
<<
"ProjRef of the input image: "
<<
reader
->
GetOutput
()
->
GetProjectionRef
()
<<
std
::
endl
;
VectorDataReProjFilter
::
Pointer
vdReProjFilter
=
VectorDataReProjFilter
::
New
();
//----------
// Display input
std
::
cout
<<
"--- TEST INPUT ---"
<<
std
::
endl
;
TreeIteratorType
itVectorInput
(
vdReader
->
GetOutput
()
->
GetDataTree
());
itVectorInput
.
GoToBegin
();
while
(
!
itVectorInput
.
IsAtEnd
())
{
if
(
itVectorInput
.
Get
()
->
IsPolygonFeature
())
{
std
::
cout
<<
"----------
\n
"
<<
itVectorInput
.
Get
()
->
GetNodeTypeAsString
()
<<
std
::
endl
;
std
::
cout
<<
"List of vertices: "
<<
": "
<<
std
::
endl
;
for
(
unsigned
int
itPoints
=
0
;
itPoints
<
itVectorInput
.
Get
()
->
GetPolygonExteriorRing
()
->
GetVertexList
()
->
Size
();
itPoints
++
)
{
std
::
cout
<<
"vertex["
<<
itPoints
<<
"]: "
<<
itVectorInput
.
Get
()
->
GetPolygonExteriorRing
()
->
GetVertexList
()
->
GetElement
(
itPoints
)
<<
std
::
endl
;
}
std
::
cout
<<
"Polygon region: "
<<
itVectorInput
.
Get
()
->
GetPolygonExteriorRing
()
->
GetBoundingRegion
()
<<
std
::
endl
;
}
++
itVectorInput
;
}
file
<<
"
\n
--- VECTOR DATA INPUT ---"
<<
std
::
endl
;
file
<<
"ProjRef of the input vector data: "
<<
vdReader
->
GetOutput
()
->
GetProjectionRef
()
<<
std
::
endl
;
file
<<
"Origin of the input vector data: "
<<
vdReader
->
GetOutput
()
->
GetOrigin
()
<<
std
::
endl
;
file
<<
"Spacing of the input vector data: "
<<
vdReader
->
GetOutput
()
->
GetSpacing
()
<<
std
::
endl
;
//----------
// Set input of the filter
...
...
@@ -85,31 +96,44 @@ int otbVectorDataIntoImageProjectionFilterTest(int argc, char * argv[])
vdReProjFilter
->
SetInputVectorData
(
vdReader
->
GetOutput
());
vdReProjFilter
->
SetUseOutputSpacingAndOriginFromImage
(
true
);
vdReProjFilter
->
SetDEMDirectory
(
demDirectory
);
std
::
string
stateOutput
=
""
;
if
(
atoi
(
argv
[
6
])
==
1
)
{
stateOutput
=
"true"
;
vdReProjFilter
->
SetUseOutputSpacingAndOriginFromImage
(
true
);
}
else
{
stateOutput
=
"false"
;
vdReProjFilter
->
SetUseOutputSpacingAndOriginFromImage
(
false
);
}
std
::
cout
<<
"Set input data for the filter DONE ("
<<
stateOutput
<<
")"
<<
std
::
endl
;
//----------
// UPDATE
vdReProjFilter
->
Update
();
// WRITE
//vdReProjFilter->Update();
VectorDataWriterType
::
Pointer
vdwriter
=
VectorDataWriterType
::
New
();
vdwriter
->
SetFileName
(
vectorDataOutputFilename
);
vdwriter
->
SetInput
(
vdReProjFilter
->
GetOutput
());
vdwriter
->
Update
();
std
::
cout
<<
"Update"
<<
std
::
endl
;
//----------
// check output
std
::
cout
<<
"--- TEST OUTPUT ---"
<<
std
::
endl
;
TreeIteratorType
itVector
(
vdReProjFilter
->
GetOutput
()
->
GetDataTree
());
itVector
.
GoToBegin
();
while
(
!
itVector
.
IsAtEnd
())
{
if
(
itVector
.
Get
()
->
IsPolygonFeature
())
{
std
::
cout
<<
"----------
\n
"
<<
itVector
.
Get
()
->
GetNodeTypeAsString
()
<<
std
::
endl
;
std
::
cout
<<
"List of vertices: "
<<
": "
<<
std
::
endl
;
for
(
unsigned
int
itPoints
=
0
;
itPoints
<
itVector
.
Get
()
->
GetPolygonExteriorRing
()
->
GetVertexList
()
->
Size
();
itPoints
++
)
{
std
::
cout
<<
"vertex["
<<
itPoints
<<
"]: "
<<
itVector
.
Get
()
->
GetPolygonExteriorRing
()
->
GetVertexList
()
->
GetElement
(
itPoints
)
<<
std
::
endl
;
}
std
::
cout
<<
"Polygon region: "
<<
itVector
.
Get
()
->
GetPolygonExteriorRing
()
->
GetBoundingRegion
()
<<
std
::
endl
;
}
++
itVector
;
}
file
<<
"
\n
--- VECTRODATA OUTPUT ---"
<<
std
::
endl
;
file
<<
"ProjRef of the output vector data: "
<<
vdReProjFilter
->
GetOutput
()
->
GetProjectionRef
()
<<
std
::
endl
;
file
<<
"Origin of the output vector data: "
<<
vdReProjFilter
->
GetOutput
()
->
GetOrigin
()
<<
std
::
endl
;
file
<<
"Spacing of the output vector data: "
<<
vdReProjFilter
->
GetOutput
()
->
GetSpacing
()
<<
std
::
endl
;
file
.
close
();
std
::
cout
<<
"END"
<<
std
::
endl
;
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