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
d1e738df
Commit
d1e738df
authored
Sep 16, 2014
by
Ian Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Added members for Ground Overlay tags.
* Implemented the altitude property and etree_element() functionality.
parent
90707b32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
3 deletions
+110
-3
fastkml/kml.py
fastkml/kml.py
+66
-0
fastkml/test_main.py
fastkml/test_main.py
+44
-3
No files found.
fastkml/kml.py
View file @
d1e738df
...
...
@@ -743,6 +743,72 @@ class GroundOverlay(_Overlay):
"""
__name__
=
'GroundOverlay'
_altitude
=
None
# Specifies the distance above the earth's surface, in meters, and is
# interpreted according to the altitude mode.
_altitudeMode
=
None
# Specifies how the <altitude> is interpreted. Possible values are:
# clampToGround -
# (default) Indicates to ignore the altitude specification and drape
# the overlay over the terrain.
# absolute -
# Sets the altitude of the overlay relative to sea level, regardless
# of the actual elevation of the terrain beneath the element. For
# example, if you set the altitude of an overlay to 10 meters with an
# absolute altitude mode, the overlay will appear to be at ground
# level if the terrain beneath is also 10 meters above sea level. If
# the terrain is 3 meters above sea level, the overlay will appear
# elevated above the terrain by 7 meters.
# - LatLonBox -
# Specifies where the top, bottom, right, and left sides of a bounding box
# for the ground overlay are aligned. Also, optionally the rotation of the
# overlay.
_north
=
None
# Specifies the latitude of the north edge of the bounding box, in decimal
# degrees from 0 to ±90.
_south
=
None
# Specifies the latitude of the south edge of the bounding box, in decimal
# degrees from 0 to ±90.
_east
=
None
# Specifies the longitude of the east edge of the bounding box, in decimal
# degrees from 0 to ±180. (For overlays that overlap the meridian of 180°
# longitude, values can extend beyond that range.)
_west
=
None
# Specifies the longitude of the west edge of the bounding box, in decimal
# degrees from 0 to ±180. (For overlays that overlap the meridian of 180°
# longitude, values can extend beyond that range.)
_rotation
=
None
# Specifies a rotation of the overlay about its center, in degrees. Values
# can be ±180. The default is 0 (north). Rotations are specified in a
# counterclockwise direction.
@
property
def
altitude
(
self
):
return
self
.
_altitude
@
altitude
.
setter
def
altitude
(
self
,
value
):
try
:
float
(
value
)
except
(
ValueError
,
TypeError
):
self
.
_altitude
=
None
else
:
self
.
_altitude
=
str
(
value
)
def
etree_element
(
self
):
element
=
super
(
GroundOverlay
,
self
).
etree_element
()
if
self
.
_altitude
:
altitude
=
etree
.
SubElement
(
element
,
"%saltitude"
%
self
.
ns
)
altitude
.
text
=
self
.
_altitude
return
element
class
Document
(
_Container
):
...
...
fastkml/test_main.py
View file @
d1e738df
...
...
@@ -22,7 +22,7 @@ from fastkml import styles
from
fastkml
import
base
from
fastkml
import
atom
from
fastkml
import
config
from
fastkml
import
gx
from
fastkml
import
gx
# NOQA
import
datetime
from
dateutil.tz
import
tzutc
,
tzoffset
...
...
@@ -93,8 +93,8 @@ class BaseClassesTestCase(unittest.TestCase):
def
test_Container
(
self
):
f
=
kml
.
_Container
(
name
=
'A Container'
)
# apparently you can add documents to containes
#d = kml.Document()
#self.assertRaises(TypeError, f.append, d)
#
d = kml.Document()
#
self.assertRaises(TypeError, f.append, d)
p
=
kml
.
Placemark
()
f
.
append
(
p
)
self
.
assertRaises
(
NotImplementedError
,
f
.
etree_element
)
...
...
@@ -2026,6 +2026,45 @@ class GroundOverlayTestCase(unittest.TestCase):
self
.
assertEqual
(
g
.
to_string
(
prettyprint
=
False
),
expected
)
def
test_altitude_from_int
(
self
):
g
=
kml
.
GroundOverlay
()
g
.
altitude
=
123
expected
=
(
'<kml:GroundOverlay xmlns:kml="http://www.opengis.net/kml/2.2">'
'<kml:visibility>1</kml:visibility>'
'<kml:altitude>123</kml:altitude>'
'</kml:GroundOverlay>'
)
self
.
assertEqual
(
g
.
to_string
(
prettyprint
=
False
),
expected
)
def
test_altitude_from_float
(
self
):
g
=
kml
.
GroundOverlay
()
g
.
altitude
=
123.4
expected
=
(
'<kml:GroundOverlay xmlns:kml="http://www.opengis.net/kml/2.2">'
'<kml:visibility>1</kml:visibility>'
'<kml:altitude>123.4</kml:altitude>'
'</kml:GroundOverlay>'
)
self
.
assertEqual
(
g
.
to_string
(
prettyprint
=
False
),
expected
)
def
test_altitude_from_string
(
self
):
g
=
kml
.
GroundOverlay
()
g
.
altitude
=
'123.4'
expected
=
(
'<kml:GroundOverlay xmlns:kml="http://www.opengis.net/kml/2.2">'
'<kml:visibility>1</kml:visibility>'
'<kml:altitude>123.4</kml:altitude>'
'</kml:GroundOverlay>'
)
self
.
assertEqual
(
g
.
to_string
(
prettyprint
=
False
),
expected
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
...
...
@@ -2039,6 +2078,8 @@ def test_suite():
suite
.
addTest
(
unittest
.
makeSuite
(
SetGeometryTestCase
))
suite
.
addTest
(
unittest
.
makeSuite
(
GetGeometryTestCase
))
suite
.
addTest
(
unittest
.
makeSuite
(
Force3DTestCase
))
suite
.
addTest
(
unittest
.
makeSuite
(
BaseOverlayTestCase
))
suite
.
addTest
(
unittest
.
makeSuite
(
GroundOverlayTestCase
))
return
suite
if
__name__
==
'__main__'
:
...
...
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