import_locations(self,
marker_file)
|
|
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 Python's 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")}
>>> marker_file = open("trigpoints")
>>> markers = Trigpoints(marker_file)
>>> for key, value in sorted(markers.items()):
... print("%s - %s" % (key, value))
500936 - Broom Farm (52°03'57"N, 000°16'53"W alt 37m)
501097 - Bygrave (52°00'38"N, 000°10'24"W alt 97m)
505392 - Sish Lane (51°54'39"N, 000°11'11"W alt 136m)
>>> marker_file.seek(0)
>>> markers = Trigpoints(marker_file.readlines())
>>> markers = Trigpoints(open("southern_trigpoints"))
>>> print(markers[1])
FakeLand (48°07'23"S, 000°07'23"W alt 12m)
>>> markers = Trigpoints(open("broken_trigpoints"))
>>> for key, value in sorted(markers.items()):
... print("%s - %s" % (key, value))
500968 - Brown Hill Nm See The Heights (53°38'23"N, 001°39'34"W)
501414 - Cheriton Hill Nm See Paddlesworth (51°06'03"N, 001°08'33"E)
- Parameters:
marker_file (file , list or str ) - Trigpoint marker data to read
- Returns:
dict
- Named locations with Trigpoint objects
- Raises:
ValueError - Invalid value for marker_file
- Overrides:
point.KeyedPoints.import_locations
|