edist.NumberedPoints

Module edist :: Class NumberedPoints |
[hide private]
[frames] | no frames]

# Class NumberedPoints

          object --+
                   |
                list --+
                       |
    upoints.point.Points --+
                           |
                          NumberedPoints

Class for representing a group of NumberedPoint objects

Since: 2008-01-08

Instance Methods | [hide private]
new list |
__init__(self, locations=None, format=`'``dd``'`, unistr=True, verbose=True, config_locations=None, units=`'``km``'`) Initialise a new NumberedPoints object |
`str` |
__repr__(self) Self-documenting string representation |
import_locations(self, locations, config_locations) Import locations from arguments |
display(self, locator) Pretty print locations |
`list` of `float` |
distance(self) Calculate distances between locations |
`list` of `float` |
bearing(self, mode, string) Calculate bearing/final bearing between locations |
`list` of Point objects within specified range |
range(self, distance) Test whether locations are within a given range of the first |
destination(self, options, locator) Calculate destination locations for given distance and bearings |
`list` of 2 `tuple` of `datetime.datetime` |
sun_events(self, mode) Calculate sunrise/sunset times for locations |
flight_plan(self, speed, time) Output the flight plan corresponding to the given locations |
Inherited from `upoints.point.Points`: `final_bearing`, `forward`, `inverse`, `midpoint`, `sunrise`, `sunset`, `to_grid_locator` Inherited from `list`: `__add__`, `__contains__`, `__delitem__`, `__delslice__`, `__eq__`, `__ge__`, `__getattribute__`, `__getitem__`, `__getslice__`, `__gt__`, `__hash__`, `__iadd__`, `__imul__`, `__iter__`, `__le__`, `__len__`, `__lt__`, `__mul__`, `__ne__`, `__new__`, `__reversed__`, `__rmul__`, `__setitem__`, `__setslice__`, `append`, `count`, `extend`, `index`, `insert`, `pop`, `remove`, `reverse`, `sort` Inherited from `object`: `__delattr__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__str__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, locations=None, format=`'``dd``'`, unistr=True, verbose=True, config_locations=None, units=`'``km``'`) (Constructor) |
Initialise a new NumberedPoints object Parameters: `locations` (`list` of `str` objects) - Location identifiers `format` (`str`) - Coordinate formatting system to use `unistr` (`bool`) - Whether to output Unicode results `verbose` (`bool`) - Whether to generate verbose output `config_locations` (`dict`) - Locations imported from user's config file `units` (`str`) - Unit type to be used for distances Returns: new list Overrides: object.__init__

### __repr__(self) (Representation operator) |
Self-documenting string representation
    >>> locations = ["0;0"] * 4
    >>> NumberedPoints(locations)
    NumberedPoints([NumberedPoint(0.0, 0.0, 1, 'metric'),
                    NumberedPoint(0.0, 0.0, 2, 'metric'),
                    NumberedPoint(0.0, 0.0, 3, 'metric'),
                    NumberedPoint(0.0, 0.0, 4, 'metric')],
                   'dd', True, True, None, 'km')
Returns: `str` String to recreate NumberedPoints object Overrides: object.__repr__

### import_locations(self, locations, config_locations) |
Import locations from arguments
    >>> NumberedPoints(["0;0", "Home", "0;0"],
    ...                config_locations={"Home": (52.015, -0.221)})
    NumberedPoints([NumberedPoint(0.0, 0.0, 1, 'metric'),
                    NumberedPoint(52.015, -0.221, 'Home', 'metric'),
                    NumberedPoint(0.0, 0.0, 3, 'metric')],
                   'dd', True, True, {'Home': (52.015000000000001, -0.221)},
                   'km')
Parameters: `locations` (`list` of `str`) - Location identifiers `config_locations` (`dict`) - Locations imported from user's config file Overrides: upoints.point.Points.import_locations

### display(self, locator) |
Pretty print locations
    >>> locations = NumberedPoints(["Home", "52.168;0.040"],
    ...                            config_locations={"Home": (52.015, -0.221)})
    >>> locations.display(None)
    Location Home is N52.015°; W000.221°
    Location 2 is N52.168°; E000.040°
    >>> locations.format = "locator"
    >>> locations.display("extsquare")
    Location Home is IO92va33
    Location 2 is JO02ae40
    >>> locations.verbose = False
    >>> locations.display("extsquare")
    IO92va33
    JO02ae40
Parameters: `locator` (`str`) - Accuracy of Maidenhead locator output

### distance(self) |
Calculate distances between locations
    >>> locations = NumberedPoints(["52.015;-0.221", "52.168;0.040"])
    >>> locations.distance()
    Location 1 to 2 is 24 kilometres
    >>> locations = NumberedPoints(["52.015;-0.221", "52.168;0.040"], units="sm")
    >>> locations.distance()
    Location 1 to 2 is 15 miles
    >>> locations = NumberedPoints(["52.015;-0.221", "52.168;0.040"], units="nm")
    >>> locations.verbose = False
    >>> locations.distance()
    13.2989574317
    >>> locations = NumberedPoints(["52.015;-0.221", "52.168;0.040",
    ...                             "51.420;-1.500"])
    >>> locations.distance()
    Location 1 to 2 is 24 kilometres
    Location 2 to 3 is 134 kilometres
    Total distance is 159 kilometres
Parameters: `method` - Method used to calculate distance Returns: `list` of `float` Distance between points in series Overrides: upoints.point.Points.distance

### bearing(self, mode, string) |
Calculate bearing/final bearing between locations
    >>> locations = NumberedPoints(["52.015;-0.221", "52.168;0.040"])
    >>> locations.bearing("bearing", False)
    Location 1 to 2 is 46°
    >>> locations.bearing("bearing", True)
    Location 1 to 2 is North-east
    >>> locations.bearing("final_bearing", False)
    Final bearing from location 1 to 2 is 46°
    >>> locations.bearing("final_bearing", True)
    Final bearing from location 1 to 2 is North-east
    >>> locations.verbose = False
    >>> locations.bearing("bearing", True)
    North-east
    >>> locations.verbose = False
    >>> locations.bearing("final_bearing", True)
    North-east
Parameters: `mode` (`str`) - Type of bearing to calculate `string` (`bool`) - Use named directions Returns: `list` of `float` Bearing between points in series Overrides: upoints.point.Points.bearing

### range(self, distance) |
Test whether locations are within a given range of the first
    >>> locations = NumberedPoints(["52.015;-0.221", "52.168;0.040"])
    >>> locations.range(20)
    Location 2 is not within 20 kilometres of location 1
    >>> locations.range(30)
    Location 2 is within 30 kilometres of location 1
    >>> locations.verbose = False
    >>> locations.range(30)
    True
Parameters: `distance` (`float`) - Distance to test location is within Returns: `list` of Point objects within specified range Overrides: upoints.point.Points.range

### destination(self, options, locator) |
Calculate destination locations for given distance and bearings
    >>> locations = NumberedPoints(["52.015;-0.221", "52.168;0.040"])
    >>> locations.destination((42, 240), False)
    Destination from location 1 is N51.825°; W000.751°
    Destination from location 2 is N51.978°; W000.491°
    >>> locations.format = "locator"
    >>> locations.destination((42, 240), "subsquare")
    Destination from location 1 is IO91ot
    Destination from location 2 is IO91sx
    >>> locations.verbose = False
    >>> locations.destination((42, 240), "extsquare")
    IO91ot97
    IO91sx14
Parameters: `options` (`tuple`) - Distance and bearing `locator` (`str`) - Accuracy of Maidenhead locator output Overrides: upoints.point.Points.destination

### sun_events(self, mode) |
Calculate sunrise/sunset times for locations
    >>> locations = NumberedPoints(["52.015;-0.221", "52.168;0.040"])
    >>> locations.sun_events("sunrise") # doctest: +ELLIPSIS
    Sunrise at ... in location 1
    Sunrise at ... in location 2
    >>> locations.sun_events("sunset") # doctest: +ELLIPSIS
    Sunset at ... in location 1
    Sunset at ... in location 2
Parameters: `mode` (`str`) - Sun event to display Returns: `list` of 2 `tuple` of `datetime.datetime` The time for the sunrise and sunset events for each point Overrides: upoints.point.Points.sun_events

### flight_plan(self, speed, time) |
Output the flight plan corresponding to the given locations TODO: Description
    >>> locations = NumberedPoints(["52.015;-0.221", "52.168;0.040",
    ...                             "52.249;0.130", "52.494;0.654"])
    >>> locations.flight_plan(0, "h")
    WAYPOINT,BEARING[°],DISTANCE[km],ELAPSED_TIME[h],LATITUDE[d.dd],LONGITUDE[d.dd]
    1,,,,52.015000,-0.221000
    2,46,24.6,,52.168000,0.040000
    3,34,10.9,,52.249000,0.130000
    4,52,44.8,,52.494000,0.654000
    -- OVERALL --#,,80.3,,,
    -- DIRECT --#,47,79.9,,,
    >>> locations = NumberedPoints(["52.015;-0.221", "52.168;0.040",
    ...                             "52.249;0.130", "52.494;0.654"],
    ...                            units="nm")
    >>> locations.flight_plan(20, "m")
    WAYPOINT,BEARING[°],DISTANCE[nm],ELAPSED_TIME[m],LATITUDE[d.dd],LONGITUDE[d.dd]
    1,,,,52.015000,-0.221000
    2,46,13.3,0.7,52.168000,0.040000
    3,34,5.9,0.3,52.249000,0.130000
    4,52,24.2,1.2,52.494000,0.654000
    -- OVERALL --,,43.4,2.2,,
    -- DIRECT --,47,43.1,2.2,,
Parameters: `speed` (`float`) - Speed to use for elapsed time calculation `time` (`str`) - Time unit to use for output