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
0a985294
Commit
0a985294
authored
16 years ago
by
Emmanuel Christophe
Browse files
Options
Downloads
Patches
Plain Diff
ENH: adding accessor
parent
0ddb263b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Code/IO/otbImageKeywordlist.h
+3
-0
3 additions, 0 deletions
Code/IO/otbImageKeywordlist.h
Code/IO/otbVectorDataKeywordlist.cxx
+59
-12
59 additions, 12 deletions
Code/IO/otbVectorDataKeywordlist.cxx
Code/IO/otbVectorDataKeywordlist.h
+33
-1
33 additions, 1 deletion
Code/IO/otbVectorDataKeywordlist.h
with
95 additions
and
13 deletions
Code/IO/otbImageKeywordlist.h
+
3
−
0
View file @
0a985294
...
@@ -44,6 +44,9 @@ public:
...
@@ -44,6 +44,9 @@ public:
/** Standard class typedefs. */
/** Standard class typedefs. */
typedef
ImageKeywordlist
Self
;
typedef
ImageKeywordlist
Self
;
virtual
const
char
*
GetNameOfClass
()
const
{
return
"ImageKeywordlist"
;}
typedef
std
::
map
<
ossimString
,
ossimString
>
KeywordlistMap
;
typedef
std
::
map
<
ossimString
,
ossimString
>
KeywordlistMap
;
void
SetKeywordlist
(
const
ossimKeywordlist
&
kwl
)
void
SetKeywordlist
(
const
ossimKeywordlist
&
kwl
)
...
...
This diff is collapsed.
Click to expand it.
Code/IO/otbVectorDataKeywordlist.cxx
+
59
−
12
View file @
0a985294
...
@@ -42,8 +42,9 @@ VectorDataKeywordlist
...
@@ -42,8 +42,9 @@ VectorDataKeywordlist
}
}
}
}
void
VectorDataKeywordlist
::
void
AddField
(
OGRFieldDefn
*
fieldDefn
,
OGRField
*
field
)
VectorDataKeywordlist
::
AddField
(
OGRFieldDefn
*
fieldDefn
,
OGRField
*
field
)
{
{
FieldType
newField
;
FieldType
newField
;
newField
.
first
=
fieldDefn
;
newField
.
first
=
fieldDefn
;
...
@@ -55,9 +56,55 @@ void VectorDataKeywordlist::
...
@@ -55,9 +56,55 @@ void VectorDataKeywordlist::
m_FieldList
.
push_back
(
CopyOgrField
(
newField
));
m_FieldList
.
push_back
(
CopyOgrField
(
newField
));
};
};
std
::
string
VectorDataKeywordlist
::
GetFieldAsString
(
std
::
string
key
)
const
{
for
(
unsigned
int
i
=
0
;
i
<
m_FieldList
.
size
();
++
i
)
{
if
(
key
.
compare
(
m_FieldList
[
i
].
first
->
GetNameRef
())
==
0
)
{
return
m_FieldList
[
i
].
second
.
String
;
}
}
return
""
;
}
bool
VectorDataKeywordlist
::
HasField
(
std
::
string
key
)
const
{
for
(
unsigned
int
i
=
0
;
i
<
m_FieldList
.
size
();
++
i
)
{
if
(
key
.
compare
(
m_FieldList
[
i
].
first
->
GetNameRef
())
==
0
)
{
return
true
;
}
}
return
false
;
}
VectorDataKeywordlist
::
FieldType
VectorDataKeywordlist
::
GetNthField
(
unsigned
int
index
)
const
{
if
(
index
>
m_FieldList
.
size
())
{
itkExceptionMacro
(
<<
" Accessing out-of-range metadata "
);
}
return
m_FieldList
[
index
];
}
unsigned
int
VectorDataKeywordlist
::
GetNumberOfFields
()
const
{
return
m_FieldList
.
size
();
}
void
void
VectorDataKeywordlist
::
VectorDataKeywordlist
operator
=
(
const
Self
&
p
)
::
operator
=
(
const
Self
&
p
)
{
{
for
(
unsigned
int
i
=
0
;
i
<
p
.
m_FieldList
.
size
();
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
p
.
m_FieldList
.
size
();
++
i
)
{
{
...
@@ -66,15 +113,15 @@ VectorDataKeywordlist::
...
@@ -66,15 +113,15 @@ VectorDataKeywordlist::
}
}
void
void
VectorDataKeywordlist
::
VectorDataKeywordlist
Print
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
::
Print
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
{
{
this
->
PrintSelf
(
os
,
indent
.
GetNextIndent
());
this
->
PrintSelf
(
os
,
indent
.
GetNextIndent
());
}
}
void
void
VectorDataKeywordlist
::
VectorDataKeywordlist
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
::
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
{
{
os
<<
indent
<<
" VectorData Keyword list: "
;
os
<<
indent
<<
" VectorData Keyword list: "
;
os
<<
indent
<<
" - Size: "
<<
m_FieldList
.
size
()
<<
std
::
endl
;
os
<<
indent
<<
" - Size: "
<<
m_FieldList
.
size
()
<<
std
::
endl
;
...
@@ -85,8 +132,8 @@ VectorDataKeywordlist::
...
@@ -85,8 +132,8 @@ VectorDataKeywordlist::
}
}
std
::
string
std
::
string
VectorDataKeywordlist
::
VectorDataKeywordlist
PrintField
(
FieldType
field
)
const
::
PrintField
(
FieldType
field
)
const
{
{
std
::
stringstream
output
;
std
::
stringstream
output
;
output
<<
std
::
setprecision
(
15
);
output
<<
std
::
setprecision
(
15
);
...
@@ -165,8 +212,8 @@ VectorDataKeywordlist::
...
@@ -165,8 +212,8 @@ VectorDataKeywordlist::
VectorDataKeywordlist
::
FieldType
VectorDataKeywordlist
::
FieldType
VectorDataKeywordlist
::
VectorDataKeywordlist
CopyOgrField
(
FieldType
field
)
::
CopyOgrField
(
FieldType
field
)
{
{
FieldType
outField
;
FieldType
outField
;
outField
.
first
=
new
OGRFieldDefn
(
field
.
first
);
outField
.
first
=
new
OGRFieldDefn
(
field
.
first
);
...
...
This diff is collapsed.
Click to expand it.
Code/IO/otbVectorDataKeywordlist.h
+
33
−
1
View file @
0a985294
...
@@ -33,7 +33,7 @@ namespace otb
...
@@ -33,7 +33,7 @@ namespace otb
* a vector object. This information is retrieved from the input file (a
* a vector object. This information is retrieved from the input file (a
* shapefile for example) and propagated along the pipeline with the object.
* shapefile for example) and propagated along the pipeline with the object.
*
*
* This is the equivalent of the otb
Ossim
Keywordlist class but for OGR information.
* This is the equivalent of the otb
Image
Keywordlist class but for OGR information.
*
*
* \todo add the accessor to enable modifying/updating the data.
* \todo add the accessor to enable modifying/updating the data.
*
*
...
@@ -48,12 +48,44 @@ class VectorDataKeywordlist
...
@@ -48,12 +48,44 @@ class VectorDataKeywordlist
typedef
std
::
pair
<
OGRFieldDefn
*
,
OGRField
>
FieldType
;
typedef
std
::
pair
<
OGRFieldDefn
*
,
OGRField
>
FieldType
;
typedef
std
::
vector
<
FieldType
>
FieldListType
;
typedef
std
::
vector
<
FieldType
>
FieldListType
;
virtual
const
char
*
GetNameOfClass
()
const
{
return
"VectorDataKeywordlist"
;}
void
AddField
(
OGRFieldDefn
*
fieldDefn
,
OGRField
*
field
);
void
AddField
(
OGRFieldDefn
*
fieldDefn
,
OGRField
*
field
);
/**
* Returns the value associated with a field name.
* \param key The name of the field.
* \return The value of the field. A default value is retuned if the key was not found.
*/
std
::
string
GetFieldAsString
(
std
::
string
key
)
const
;
/**
* \return True if the node contains the field named after the given key.
* \param key The name of the field.
*/
bool
HasField
(
std
::
string
key
)
const
;
/**
* \return the nth field of the node as a std::pair of (key,value).
* \param index the index of the field to return.
*/
FieldType
GetNthField
(
unsigned
int
index
)
const
;
/**
* \return the number of fields in the node.
*/
unsigned
int
GetNumberOfFields
()
const
;
/**
* Print the keyword list
*/
virtual
void
Print
(
std
::
ostream
&
os
,
itk
::
Indent
indent
=
0
)
const
;
virtual
void
Print
(
std
::
ostream
&
os
,
itk
::
Indent
indent
=
0
)
const
;
/** Constructor */
VectorDataKeywordlist
();
VectorDataKeywordlist
();
/** Destructor */
virtual
~
VectorDataKeywordlist
();
virtual
~
VectorDataKeywordlist
();
/** Constructor by copy (deep copy)*/
/** Constructor by copy (deep copy)*/
...
...
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