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
a0c716a0
Commit
a0c716a0
authored
Aug 23, 2014
by
Ian Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for phoneNumber
parent
e0b744e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
2 deletions
+45
-2
docs/HISTORY.txt
docs/HISTORY.txt
+1
-1
fastkml/kml.py
fastkml/kml.py
+21
-1
fastkml/test_main.py
fastkml/test_main.py
+23
-0
No files found.
docs/HISTORY.txt
View file @
a0c716a0
...
...
@@ -6,7 +6,7 @@ Changelog
-----------------
- back to development
- Add support for address
- Add support for address
and phoneNumber
0.7 (2014/08/01)
----------------
...
...
fastkml/kml.py
View file @
a0c716a0
...
...
@@ -205,7 +205,7 @@ class _Feature(_BaseObject):
# You can use the <address> tag to specify the location of a point
# instead of using latitude and longitude coordinates.
# TODO
phoneNumber = None
_
phoneNumber
=
None
# A string value representing a telephone number.
# This element is used by Google Maps Mobile only.
...
...
@@ -455,6 +455,20 @@ class _Feature(_BaseObject):
else
:
raise
ValueError
@
property
def
phoneNumber
(
self
):
if
self
.
_phoneNumber
:
return
self
.
_phoneNumber
@
phoneNumber
.
setter
def
phoneNumber
(
self
,
phoneNumber
):
if
isinstance
(
phoneNumber
,
basestring
):
self
.
_phoneNumber
=
phoneNumber
elif
phoneNumber
is
None
:
self
.
_phoneNumber
=
None
else
:
raise
ValueError
def
etree_element
(
self
):
element
=
super
(
_Feature
,
self
).
etree_element
()
if
self
.
name
:
...
...
@@ -498,6 +512,9 @@ class _Feature(_BaseObject):
if
self
.
_address
is
not
None
:
address
=
etree
.
SubElement
(
element
,
'%saddress'
%
self
.
ns
)
address
.
text
=
self
.
_address
if
self
.
_phoneNumber
is
not
None
:
phoneNumber
=
etree
.
SubElement
(
element
,
'%sphoneNumber'
%
self
.
ns
)
phoneNumber
.
text
=
self
.
_phoneNumber
return
element
def
from_element
(
self
,
element
):
...
...
@@ -573,6 +590,9 @@ class _Feature(_BaseObject):
address
=
element
.
find
(
'%saddress'
%
self
.
ns
)
if
address
is
not
None
:
self
.
address
=
address
.
text
phoneNumber
=
element
.
find
(
'%sphoneNumber'
%
self
.
ns
)
if
phoneNumber
is
not
None
:
self
.
phoneNumber
=
phoneNumber
.
text
class
_Container
(
_Feature
):
...
...
fastkml/test_main.py
View file @
a0c716a0
...
...
@@ -333,6 +333,13 @@ class BuildKmlTestCase(unittest.TestCase):
self
.
assertTrue
(
address
in
str
(
d
.
to_string
()))
self
.
assertTrue
(
'address>'
in
str
(
d
.
to_string
()))
def
test_phone_number
(
self
):
phone
=
'+1 234 567 8901'
d
=
kml
.
Document
()
d
.
phoneNumber
=
phone
self
.
assertTrue
(
phone
in
str
(
d
.
to_string
()))
self
.
assertTrue
(
'phoneNumber>'
in
str
(
d
.
to_string
()))
class
KmlFromStringTestCase
(
unittest
.
TestCase
):
def
test_document
(
self
):
...
...
@@ -834,6 +841,22 @@ class KmlFromStringTestCase(unittest.TestCase):
doc2
.
from_string
(
doc
.
to_string
())
self
.
assertEqual
(
doc
.
to_string
(),
doc2
.
to_string
())
def
test_phone_number
(
self
):
doc
=
kml
.
Document
()
doc
.
from_string
(
"""
<kml:Document xmlns:kml="http://www.opengis.net/kml/2.2" id="pm-id">
<kml:name>pm-name</kml:name>
<kml:description>pm-description</kml:description>
<kml:visibility>1</kml:visibility>
<kml:phoneNumber>+1 234 567 8901</kml:phoneNumber>
</kml:Document>
"""
)
doc2
=
kml
.
Document
()
doc2
.
from_string
(
doc
.
to_string
())
self
.
assertEqual
(
doc
.
to_string
(),
doc2
.
to_string
())
class
StyleTestCase
(
unittest
.
TestCase
):
def
test_styleurl
(
self
):
...
...
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