trigpoints

trigpoints - Imports trigpoint marker files.

New in version 0.2.0.

class upoints.trigpoints.Trigpoint(latitude, longitude, altitude, name=None, identity=None)[source]

Bases: upoints.point.Point

Class for representing a location from a trigpoint marker file.

Warning

Although this class stores and presents the representation of altitude it doesn’t take it in to account when making calculations. For example, consider a point at the base of Mount Everest and a point at the peak of Mount Everest the actual distance travelled between the two would be considerably larger than the reported value calculated at ground level.

New in version 0.2.0.

Initialise a new Trigpoint object.

Parameters:
  • latitude (float) – Location’s latitude
  • longitude (float) – Location’s longitude
  • altitude (float) – Location’s altitude
  • name (str) – Name for location
  • identity (int) – Database identifier, if known
class upoints.trigpoints.Trigpoints(marker_file=None)[source]

Bases: upoints.point.KeyedPoints

Class for representing a group of Trigpoint objects.

New in version 0.5.1.

Initialise a new Trigpoints object.

import_locations(marker_file)[source]

Import trigpoint database files.

import_locations() returns a dictionary with keys containing the trigpoint identifier, and values that are Trigpoint objects.

It expects trigpoint marker files in the format provided at alltrigs-wgs84.txt, which is the following format:

H  SOFTWARE NAME & VERSION
I  GPSU 4.04,
S SymbolSet=0
...
W,500936,N52.066035,W000.281449,    37.0,Broom Farm
W,501097,N52.010585,W000.173443,    97.0,Bygrave
W,505392,N51.910886,W000.186462,   136.0,Sish Lane

Any line not consisting of 6 comma separated fields will be ignored. The reader uses the csv module, so alternative whitespace formatting should have no effect. The above file processed by import_locations() will return the following dict object:

{500936: point.Point(52.066035, -0.281449, 37.0, "Broom Farm"),
 501097: point.Point(52.010585, -0.173443, 97.0, "Bygrave"),
 505392: point.Point(51.910886, -0.186462, 136.0, "Sish Lane")}
Parameters:marker_file (file, list or str) – Trigpoint marker data to read
Return type:dict
Returns:Named locations with Trigpoint objects
Raises ValueError:
 Invalid value for marker_file