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
e0b744e6
Commit
e0b744e6
authored
Aug 23, 2014
by
Ian Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for address
parent
f959be0b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
5 deletions
+49
-5
docs/HISTORY.txt
docs/HISTORY.txt
+1
-0
fastkml/kml.py
fastkml/kml.py
+22
-2
fastkml/test_main.py
fastkml/test_main.py
+26
-3
No files found.
docs/HISTORY.txt
View file @
e0b744e6
...
@@ -6,6 +6,7 @@ Changelog
...
@@ -6,6 +6,7 @@ Changelog
-----------------
-----------------
- back to development
- back to development
- Add support for address
0.7 (2014/08/01)
0.7 (2014/08/01)
----------------
----------------
...
...
fastkml/kml.py
View file @
e0b744e6
...
@@ -199,7 +199,7 @@ class _Feature(_BaseObject):
...
@@ -199,7 +199,7 @@ class _Feature(_BaseObject):
_atom_link
=
None
_atom_link
=
None
# Specifies the URL of the website containing this KML or KMZ file.
# Specifies the URL of the website containing this KML or KMZ file.
# TODO
address = None
_
address
=
None
# A string value representing an unstructured address written as a
# A string value representing an unstructured address written as a
# standard street, city, state address, and/or as a postal code.
# standard street, city, state address, and/or as a postal code.
# You can use the <address> tag to specify the location of a point
# You can use the <address> tag to specify the location of a point
...
@@ -441,6 +441,20 @@ class _Feature(_BaseObject):
...
@@ -441,6 +441,20 @@ class _Feature(_BaseObject):
"Snippet must be dict of {'text':t, 'maxLines':i} or string"
"Snippet must be dict of {'text':t, 'maxLines':i} or string"
)
)
@
property
def
address
(
self
):
if
self
.
_address
:
return
self
.
_address
@
address
.
setter
def
address
(
self
,
address
):
if
isinstance
(
address
,
basestring
):
self
.
_address
=
address
elif
address
is
None
:
self
.
_address
=
None
else
:
raise
ValueError
def
etree_element
(
self
):
def
etree_element
(
self
):
element
=
super
(
_Feature
,
self
).
etree_element
()
element
=
super
(
_Feature
,
self
).
etree_element
()
if
self
.
name
:
if
self
.
name
:
...
@@ -481,6 +495,9 @@ class _Feature(_BaseObject):
...
@@ -481,6 +495,9 @@ class _Feature(_BaseObject):
element
.
append
(
self
.
_atom_author
.
etree_element
())
element
.
append
(
self
.
_atom_author
.
etree_element
())
if
self
.
extended_data
is
not
None
:
if
self
.
extended_data
is
not
None
:
element
.
append
(
self
.
extended_data
.
etree_element
())
element
.
append
(
self
.
extended_data
.
etree_element
())
if
self
.
_address
is
not
None
:
address
=
etree
.
SubElement
(
element
,
'%saddress'
%
self
.
ns
)
address
.
text
=
self
.
_address
return
element
return
element
def
from_element
(
self
,
element
):
def
from_element
(
self
,
element
):
...
@@ -553,6 +570,9 @@ class _Feature(_BaseObject):
...
@@ -553,6 +570,9 @@ class _Feature(_BaseObject):
# logger.warn(
# logger.warn(
# 'arbitrary or typed extended data is not yet supported'
# 'arbitrary or typed extended data is not yet supported'
# )
# )
address
=
element
.
find
(
'%saddress'
%
self
.
ns
)
if
address
is
not
None
:
self
.
address
=
address
.
text
class
_Container
(
_Feature
):
class
_Container
(
_Feature
):
...
@@ -769,7 +789,7 @@ class _TimePrimitive(_BaseObject):
...
@@ -769,7 +789,7 @@ class _TimePrimitive(_BaseObject):
RESOLUTIONS
=
[
'gYear'
,
'gYearMonth'
,
'date'
,
'dateTime'
]
RESOLUTIONS
=
[
'gYear'
,
'gYearMonth'
,
'date'
,
'dateTime'
]
def
get_resolution
(
self
,
dt
,
resolution
):
def
get_resolution
(
self
,
dt
,
resolution
=
None
):
if
resolution
:
if
resolution
:
if
resolution
not
in
self
.
RESOLUTIONS
:
if
resolution
not
in
self
.
RESOLUTIONS
:
raise
ValueError
raise
ValueError
...
...
fastkml/test_main.py
View file @
e0b744e6
...
@@ -73,7 +73,7 @@ class BaseClassesTestCase(unittest.TestCase):
...
@@ -73,7 +73,7 @@ class BaseClassesTestCase(unittest.TestCase):
self
.
assertEqual
(
f
.
isopen
,
0
)
self
.
assertEqual
(
f
.
isopen
,
0
)
self
.
assertEqual
(
f
.
_atom_author
,
None
)
self
.
assertEqual
(
f
.
_atom_author
,
None
)
self
.
assertEqual
(
f
.
_atom_link
,
None
)
self
.
assertEqual
(
f
.
_atom_link
,
None
)
#
self.assertEqual(f.address, None)
self
.
assertEqual
(
f
.
address
,
None
)
# self.assertEqual(f.phoneNumber, None)
# self.assertEqual(f.phoneNumber, None)
self
.
assertEqual
(
f
.
_snippet
,
None
)
self
.
assertEqual
(
f
.
_snippet
,
None
)
self
.
assertEqual
(
f
.
description
,
None
)
self
.
assertEqual
(
f
.
description
,
None
)
...
@@ -326,6 +326,13 @@ class BuildKmlTestCase(unittest.TestCase):
...
@@ -326,6 +326,13 @@ class BuildKmlTestCase(unittest.TestCase):
self
.
assertEqual
(
d
.
to_string
(),
d2
.
to_string
())
self
.
assertEqual
(
d
.
to_string
(),
d2
.
to_string
())
d
.
link
=
None
d
.
link
=
None
def
test_address
(
self
):
address
=
'1600 Amphitheatre Parkway, Mountain View, CA 94043, USA'
d
=
kml
.
Document
()
d
.
address
=
address
self
.
assertTrue
(
address
in
str
(
d
.
to_string
()))
self
.
assertTrue
(
'address>'
in
str
(
d
.
to_string
()))
class
KmlFromStringTestCase
(
unittest
.
TestCase
):
class
KmlFromStringTestCase
(
unittest
.
TestCase
):
def
test_document
(
self
):
def
test_document
(
self
):
...
@@ -811,6 +818,22 @@ class KmlFromStringTestCase(unittest.TestCase):
...
@@ -811,6 +818,22 @@ class KmlFromStringTestCase(unittest.TestCase):
doc
=
kml
.
KML
()
doc
=
kml
.
KML
()
self
.
assertRaises
(
TypeError
,
doc
.
from_string
,
'<xml></xml>'
)
self
.
assertRaises
(
TypeError
,
doc
.
from_string
,
'<xml></xml>'
)
def
test_address
(
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:address>3901 Holly Dr, San Jose, CA 95060</kml:address>
</kml:Document>
"""
)
doc2
=
kml
.
Document
()
doc2
.
from_string
(
doc
.
to_string
())
self
.
assertEqual
(
doc
.
to_string
(),
doc2
.
to_string
())
class
StyleTestCase
(
unittest
.
TestCase
):
class
StyleTestCase
(
unittest
.
TestCase
):
def
test_styleurl
(
self
):
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