Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: functional API for LOCATION_LISTS #60

Open
3 tasks
chrisdicaprio opened this issue Nov 27, 2024 · 0 comments
Open
3 tasks

Proposal: functional API for LOCATION_LISTS #60

chrisdicaprio opened this issue Nov 27, 2024 · 0 comments
Assignees
Labels

Comments

@chrisdicaprio
Copy link
Collaborator

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)
@chrisdicaprio chrisdicaprio self-assigned this Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant