Skip to content

Proposal: functional API for LOCATION_LISTS #60

@chrisdicaprio

Description

@chrisdicaprio

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:

  • decision on if LocaitonList should have methods or properties
  • working LocationList class
  • a helper function get_location_list that takes an id and returns a LocationList object. This will replace the existing function (could be a class method)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions