Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fastkml
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Aurélien Vermylen
fastkml
Commits
0f882d7b
Commit
0f882d7b
authored
Jul 31, 2014
by
Jason Helland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle case where Document booleans (visibility,isopen) are 'true' or 'false' when
parsing from string
parent
272c6d25
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
fastkml/kml.py
fastkml/kml.py
+8
-2
fastkml/test_main.py
fastkml/test_main.py
+24
-0
No files found.
fastkml/kml.py
View file @
0f882d7b
...
...
@@ -493,10 +493,16 @@ class _Feature(_BaseObject):
self
.
description
=
description
.
text
visibility
=
element
.
find
(
'%svisibility'
%
self
.
ns
)
if
visibility
is
not
None
:
self
.
visibility
=
int
(
visibility
.
text
)
if
visibility
.
text
in
[
'1'
,
'true'
]:
self
.
visibility
=
1
else
:
self
.
visibility
=
0
isopen
=
element
.
find
(
'%sopen'
%
self
.
ns
)
if
isopen
is
not
None
:
self
.
isopen
=
int
(
isopen
.
text
)
if
isopen
.
text
in
[
'1'
,
'true'
]:
self
.
isopen
=
1
else
:
self
.
isopen
=
0
styles
=
element
.
findall
(
'%sStyle'
%
self
.
ns
)
for
style
in
styles
:
s
=
Style
(
self
.
ns
)
...
...
fastkml/test_main.py
View file @
0f882d7b
...
...
@@ -362,6 +362,30 @@ class KmlFromStringTestCase(unittest.TestCase):
k2
.
from_string
(
k
.
to_string
())
self
.
assertEqual
(
k
.
to_string
(),
k2
.
to_string
())
def
test_document_booleans
(
self
):
doc
=
"""<kml xmlns="http://www.opengis.net/kml/2.2">
<Document targetId="someTargetId">
<name>Document.kml</name>
<visibility>true</visibility>
<open>1</open>
</Document>
</kml>"""
k
=
kml
.
KML
()
k
.
from_string
(
doc
)
self
.
assertEqual
(
list
(
k
.
features
())[
0
].
visibility
,
1
)
self
.
assertEqual
(
list
(
k
.
features
())[
0
].
isopen
,
1
)
doc
=
"""<kml xmlns="http://www.opengis.net/kml/2.2">
<Document targetId="someTargetId">
<name>Document.kml</name>
<visibility>0</visibility>
<open>false</open>
</Document>
</kml>"""
k
=
kml
.
KML
()
k
.
from_string
(
doc
)
self
.
assertEqual
(
list
(
k
.
features
())[
0
].
visibility
,
0
)
self
.
assertEqual
(
list
(
k
.
features
())[
0
].
isopen
,
0
)
def
test_folders
(
self
):
doc
=
"""<kml xmlns="http://www.opengis.net/kml/2.2">
<Folder>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment