-
Notifications
You must be signed in to change notification settings - Fork 1
locations_by_name
Alex Jung edited this page Dec 21, 2024
·
1 revision
Find localities by name or unique id.
Name | Type | Required | Description |
---|---|---|---|
name | str | required | Name or id ID of locality to search for |
filters | list[LocationFilter] | optional | The localition search may be limited by certain types of objects using this parameter. Default value is []
|
limit | int | optional | Max size of returned list. Default value is 30
|
Type | Description |
---|---|
list[Location] | List of locations found py provided name sorted by match quality |
- Search all localities contain name
Plärrer
from apyefa import EfaClient, Location, LocationFilter
async with EfaClient("https://efa.vgn.de/vgnExt_oeffi/") as client:
locations: list[Location] = await client.locations_by_name("Plärrer")
print(f"Found {len(locations)} location(s)")
print(location[0].id)
print(location[0].name)
print(location[0].loc_type)
# OUTPUT:
# Found 20 location(s)
# de:09574:7132
# Hersbruck, Plärrer
# <LocationType.STOP: 'stop'>
- Search for POIs and Addresses with name
Plärrer
async with EfaClient("https://efa.vgn.de/vgnExt_oeffi/") as client:
locations: list[Location] = await client.locations_by_name("Plärrer", filters=[LocationFilter.ADDRESSES, LocationFilter.POIS])
print(f"Found {len(locations)} location(s)")
print(location[0].id)
print(location[0].name)
print(location[0].loc_type)
# OUTPUT:
# Found 4 location(s)
# poiID:1000029001:9564000:-1:N-PLärrer:Nürnberg:N-PLärrer:ANY:POI:4431934:680416:NAV4:vgn
# Nürnberg, N-PLärrer
# <LocationType.POI: 'poi'>
- Search by
stop id
async with EfaClient("https://efa.vgn.de/vgnExt_oeffi/") as client:
locations: list[Location] = await client.locations_by_name("de:09564:704")
print(f"Found {len(locations)} location(s)")
print(location[0].id)
print(location[0].name)
print(location[0].loc_type)
# OUTPUT:
# Found 1 location(s)
# de:09564:704
# Nürnberg, N-PLärrer
# <LocationType.STOP: 'stop'>