Package upoints :: Module kml :: Class Placemark
[hide private]
[frames] | no frames]

Class Placemark

      object --+        
               |        
     point.Point --+    
                   |    
trigpoints.Trigpoint --+
                       |
                      Placemark

Class for representing a Placemark element from KML data files

Since: 0.6.0

Instance Methods [hide private]
 
__init__(self, latitude, longitude, altitude=None, name=None, description=None)
Initialise a new Placemark object
str
__str__(self, mode='dms')
Pretty printed location string
ET.Element
tokml(self, kml_version='2.2', human_namespace=False)
Generate a KML Placemark element subtree

Inherited from point.Point: __dict__, __eq__, __hash__, __ne__, __repr__, __unicode__, bearing, destination, distance, final_bearing, forward, inverse, midpoint, sun_events, sunrise, sunset, to_grid_locator

Inherited from point.Point (private): _set_location

Inherited from object: __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__

Instance Variables [hide private]
  altitude
Location's altitude
  latitude
Location's latitude
  longitude
Locations's longitude

Inherited from trigpoints.Trigpoint: identity, name

Inherited from point.Point: rad_latitude, rad_longitude, timezone, units

Properties [hide private]
  description

Inherited from object: __class__

Method Details [hide private]

__init__(self, latitude, longitude, altitude=None, name=None, description=None)
(Constructor)

 

Initialise a new Placemark object

>>> Placemark(52, 0, 4)
Placemark(52.0, 0.0, 4.0, None, None)
>>> Placemark(52, 0, None)
Placemark(52.0, 0.0, None, None, None)
>>> Placemark(52, 0, None, "name", "desc")
Placemark(52.0, 0.0, None, 'name', 'desc')
Parameters:
  • latitude (float or coercible to float) - Placemarks's latitude
  • longitude (float or coercible to float) - Placemark's longitude
  • altitude (float or coercible to float) - Placemark's altitude
  • name (str) - Name for placemark
  • description (str) - Placemark's description
Raises:
  • ValueError - Unknown value for angle
  • ValueError - Unknown value for units
  • ValueError - Invalid value for latitude or longitude
Overrides: object.__init__

__str__(self, mode='dms')
(Informal representation operator)

 

Pretty printed location string

>>> print(Placemark(52, 0, 4))
52°00'00"N, 000°00'00"E alt 4m
>>> print(Placemark(52, 0, None))
52°00'00"N, 000°00'00"E
>>> print(Placemark(52, 0, None, "name", "desc"))
name (52°00'00"N, 000°00'00"E) [desc]
>>> print(Placemark(52, 0, 42, "name", "desc"))
name (52°00'00"N, 000°00'00"E alt 42m) [desc]
Parameters:
  • mode (str) - Coordinate formatting system to use
Returns: str
Human readable string representation of Placemark object
Raises:
  • ValueError - Unknown value for mode
Overrides: object.__str__

tokml(self, kml_version='2.2', human_namespace=False)

 

Generate a KML Placemark element subtree

>>> ET.tostring(Placemark(52, 0, 4).tokml())
'<ns0:Placemark xmlns:ns0="http://earth.google.com/kml/2.2"><ns0:Point><ns0:coordinates>0.0,52.0,4</ns0:coordinates></ns0:Point></ns0:Placemark>'
>>> ET.tostring(Placemark(52, 0, 4, "Cambridge").tokml())
'<ns0:Placemark id="Cambridge" xmlns:ns0="http://earth.google.com/kml/2.2"><ns0:name>Cambridge</ns0:name><ns0:Point><ns0:coordinates>0.0,52.0,4</ns0:coordinates></ns0:Point></ns0:Placemark>'
>>> ET.tostring(Placemark(52, 0, 4).tokml(kml_version="2.0"))
'<ns0:Placemark xmlns:ns0="http://earth.google.com/kml/2.0"><ns0:Point><ns0:coordinates>0.0,52.0,4</ns0:coordinates></ns0:Point></ns0:Placemark>'
>>> ET.tostring(Placemark(52, 0, 4, "Cambridge", "in the UK").tokml())
'<ns0:Placemark id="Cambridge" xmlns:ns0="http://earth.google.com/kml/2.2"><ns0:name>Cambridge</ns0:name><ns0:description>in the UK</ns0:description><ns0:Point><ns0:coordinates>0.0,52.0,4</ns0:coordinates></ns0:Point></ns0:Placemark>'
Parameters:
  • kml_version (str) - KML version to generate
  • human_namespace (bool) - Whether to generate output using human readable namespace prefixes
Returns: ET.Element
KML Placemark element