As a users of the nzhsm-common library we access locations lists via the dict that defines them, e.g.:
locations=LOCATION_LISTS['NZ']['locations'],
def get_one_location_list(location_list_id):
ll = LOCATION_LISTS.get(location_list_id)
if ll:
return LocationList(location_list_id, ll['locations'])
raise IndexError("LocationList with id %s was not found." % location_list_id)
However, the use of a dict interface does not document the use of the lists, better to have a function(s). There are already 2 functions:
def get_location_list(
location_list_names: List[str], resolution: float = DEFAULT_RESOLUTION, sort_locations: bool = True
) -> Iterable[CodedLocation]:
"""
Get all coded locations within one or more lists.
def get_location_list_names() -> List[str]:
"""
Return a list of valid location lists.
A user may want:
- location list ids (e.g. "WLG", "CHC", etc)
- a location lists "id" (e.g. "HB", SRWG214")
- a location list "name"
- lat lon (floating point, at the resource's resolution) of locations in the list
CodedLocations from the list
Proposal:
A LocationList class with the following methods or properties (with get_ prefix if a method):
ids
name
id
coded_locations
coordinates (lat, lon): list of LatLon objects
Done when:
As a users of the
nzhsm-commonlibrary we access locations lists via the dict that defines them, e.g.:However, the use of a dict interface does not document the use of the lists, better to have a function(s). There are already 2 functions:
A user may want:
CodedLocationsfrom the listProposal:
A
LocationListclass with the following methods or properties (withget_prefix if a method):idsnameidcoded_locationscoordinates(lat, lon): list ofLatLonobjectsDone when:
LocaitonListshould have methods or propertiesLocationListclassget_location_listthat takes anidand returns aLocationListobject. This will replace the existing function (could be a class method)