aio_taginfo.api.v4.key.prevalent_values
/api/4/key/prevalent_values
endpoint.
1"""`/api/4/key/prevalent_values` endpoint.""" 2 3from aio_taginfo.api.v4 import ObjectType, Response 4from aio_taginfo.api.v4._internal import NonEmptyString, api_get_json, api_params 5 6from aiohttp import ClientSession 7from pydantic import Field 8from pydantic.dataclasses import dataclass 9 10 11__all__ = ( 12 "call", 13 "PrevalentValue", 14) 15 16 17@dataclass(kw_only=True, frozen=True) 18class PrevalentValue: 19 """ 20 One value of a given tag and the number of times it was used. 21 22 Attributes: 23 value: The tag value or ``None`` to count the sum of the counts for all values not listed 24 count: Number of objects with this tag value 25 fraction: Fraction of number of objects with this tag value compared to all objects 26 """ 27 28 value: str | None = Field(min_length=1, repr=True) 29 count: int = Field(ge=0, repr=True) 30 fraction: float = Field(ge=0.0, le=1.0, allow_inf_nan=False, repr=True) 31 32 33@dataclass(kw_only=True, frozen=True) 34class _Params: 35 key: NonEmptyString = Field(repr=True) 36 min_fraction: float = Field(ge=0.01, le=1.0, allow_inf_nan=False, repr=True) 37 filter: ObjectType = Field(repr=True) 38 39 40async def call( 41 key: str, 42 min_fraction: float = 0.01, 43 filter: ObjectType = ObjectType.ALL, # noqa: A002 44 session: ClientSession | None = None, 45) -> Response[list[PrevalentValue]]: 46 """ 47 Get most prevalent values used with a given key. 48 49 https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_prevalent_values 50 51 Args: 52 key: tag key 53 min_fraction: only return values which are used in at least this percent 54 of all objects with this key (defaults to 0.01) 55 filter: can be used to filter only values on tags used on nodes/ways/relations 56 session: request client session 57 58 Raises: 59 TaginfoError 60 """ 61 params = api_params(_Params, key=key, min_fraction=min_fraction, filter=filter) 62 return await api_get_json( 63 path="key/prevalent_values", 64 cls=Response[list[PrevalentValue]], 65 session=session, 66 params=params, 67 ) 68 69 70__docformat__ = "google"
async def
call( key: str, min_fraction: float = 0.01, filter: aio_taginfo.api.v4.ObjectType = <ObjectType.ALL: 'all'>, session: aiohttp.client.ClientSession | None = None) -> aio_taginfo.api.v4.Response[list[PrevalentValue]]:
41async def call( 42 key: str, 43 min_fraction: float = 0.01, 44 filter: ObjectType = ObjectType.ALL, # noqa: A002 45 session: ClientSession | None = None, 46) -> Response[list[PrevalentValue]]: 47 """ 48 Get most prevalent values used with a given key. 49 50 https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_prevalent_values 51 52 Args: 53 key: tag key 54 min_fraction: only return values which are used in at least this percent 55 of all objects with this key (defaults to 0.01) 56 filter: can be used to filter only values on tags used on nodes/ways/relations 57 session: request client session 58 59 Raises: 60 TaginfoError 61 """ 62 params = api_params(_Params, key=key, min_fraction=min_fraction, filter=filter) 63 return await api_get_json( 64 path="key/prevalent_values", 65 cls=Response[list[PrevalentValue]], 66 session=session, 67 params=params, 68 )
Get most prevalent values used with a given key.
https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_prevalent_values
Arguments:
- key: tag key
- min_fraction: only return values which are used in at least this percent of all objects with this key (defaults to 0.01)
- filter: can be used to filter only values on tags used on nodes/ways/relations
- session: request client session
Raises:
- TaginfoError
@dataclass(kw_only=True, frozen=True)
class
PrevalentValue:
18@dataclass(kw_only=True, frozen=True) 19class PrevalentValue: 20 """ 21 One value of a given tag and the number of times it was used. 22 23 Attributes: 24 value: The tag value or ``None`` to count the sum of the counts for all values not listed 25 count: Number of objects with this tag value 26 fraction: Fraction of number of objects with this tag value compared to all objects 27 """ 28 29 value: str | None = Field(min_length=1, repr=True) 30 count: int = Field(ge=0, repr=True) 31 fraction: float = Field(ge=0.0, le=1.0, allow_inf_nan=False, repr=True)
One value of a given tag and the number of times it was used.
Attributes:
- value: The tag value or
None
to count the sum of the counts for all values not listed - count: Number of objects with this tag value
- fraction: Fraction of number of objects with this tag value compared to all objects