Package upoints :: Module xearth :: Class Xearths
[hide private]
[frames] | no frames]

Class Xearths

   object --+        
            |        
         dict --+    
                |    
point.KeyedPoints --+
                    |
                   Xearths

Class for representing a group of Xearth objects

Since: 0.5.1

Instance Methods [hide private]
new empty dictionary

__init__(self, marker_file=None)
Initialise a new Xearths object
str
__str__(self)
Xearth objects rendered for use with Xearth/Xplanet
dict
import_locations(self, marker_file)
Parse Xearth data files

Inherited from point.KeyedPoints: __repr__, bearing, destination, distance, final_bearing, forward, inverse, midpoint, range, sun_events, sunrise, sunset, to_grid_locator

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __hash__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __setitem__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, marker_file=None)
(Constructor)

 
Initialise a new Xearths object
Parameters:
  • points - Point objects to wrap
  • parse - Whether to attempt import of points
  • units - Unit type to be used for distances when parsing string locations
Returns:
new empty dictionary

Overrides: object.__init__

__str__(self)
(Informal representation operator)

 

Xearth objects rendered for use with Xearth/Xplanet

>>> markers = Xearths(open("xearth"))
>>> print(markers)
52.015000 -0.221000 "Home"
52.633300 -2.500000 "Telford"
Returns: str
Xearth/Xplanet marker file formatted output
Overrides: object.__str__

import_locations(self, marker_file)

 

Parse Xearth data files

import_locations() returns a dictionary with keys containing the xearth name, and values consisting of a Xearth object and a string containing any comment found in the marker file.

It expects Xearth marker files in the following format:

# Comment

52.015     -0.221 "Home"          # James Rowe's home
52.6333    -2.5   "Telford"

Any empty line or line starting with a '#' is ignored. All data lines are whitespace-normalised, so actual layout should have no effect. The above file processed by import_locations() will return the following dict object:

{'Home': point.Point(52.015, -0.221, "James Rowe's home"),
 'Telford': point.Point(52.6333, -2.5, None)}
>>> markers = Xearths(open("xearth"))
>>> for key, value in sorted(markers.items()):
...     print("%s - %s" % (key, value))
Home - James Rowe's home (N52.015°; W000.221°)
Telford - N52.633°; W002.500°
Parameters:
  • marker_file (file, list or str) - Xearth marker data to read
Returns: dict
Named locations with optional comments
Overrides: point.KeyedPoints.import_locations

Note: This function also handles the extended xplanet marker files whose points can optionally contain added xplanet specific keywords for defining colours and fonts.