aio_taginfo.api.v4.key.combinations

/api/4/key/combinations endpoint.

  1"""`/api/4/key/combinations` endpoint."""
  2
  3from enum import Enum
  4
  5from aio_taginfo.api.v4 import ObjectType, Response, SortOrder
  6from aio_taginfo.api.v4._internal import NonEmptyString, api_get_json, api_params
  7
  8from aiohttp import ClientSession
  9from pydantic import Field
 10from pydantic.dataclasses import dataclass
 11
 12
 13__all__ = (
 14    "call",
 15    "KeyCombination",
 16    "KeyCombinationSorting",
 17)
 18
 19
 20@dataclass(kw_only=True, frozen=True)
 21class KeyCombination:
 22    """
 23    Combination statistics for a given key with another.
 24
 25    Attributes:
 26        other_key: Other key.
 27        together_count: Number of objects that have both keys.
 28        to_fraction: Fraction of objects with this key that also have the other key.
 29        from_fraction: Fraction of objects with other key that also have this key.
 30    """
 31
 32    other_key: str = Field(min_length=1, repr=True)
 33    together_count: int = Field(ge=0, repr=True)
 34    to_fraction: float = Field(ge=0.0, le=1.0, allow_inf_nan=False, repr=True)
 35    from_fraction: float = Field(ge=0.0, le=1.0, allow_inf_nan=False, repr=True)
 36
 37
 38class KeyCombinationSorting(str, Enum):
 39    """Sort options for key combination."""
 40
 41    TOGETHER_COUNT = "together_count"
 42    OTHER_KEY = "other_key"
 43    FROM_FRACTION = "from_fraction"
 44
 45
 46@dataclass(kw_only=True, frozen=True)
 47class _Params:
 48    key: NonEmptyString = Field(repr=True)
 49    query: NonEmptyString | None = Field(repr=True)
 50    sortname: KeyCombinationSorting = Field(repr=True)
 51    sortorder: SortOrder = Field(repr=True)
 52    filter: ObjectType = Field(repr=True)
 53    page: int = Field(gt=0, repr=True)
 54    rp: int = Field(ge=0, repr=True)
 55
 56
 57async def call(
 58    key: str,
 59    query: str | None = None,
 60    sortname: KeyCombinationSorting = KeyCombinationSorting.TOGETHER_COUNT,
 61    sortorder: SortOrder = SortOrder.DESC,
 62    filter: ObjectType = ObjectType.ALL,  # noqa: A002
 63    page: int = 1,
 64    rp: int = 0,
 65    session: ClientSession | None = None,
 66) -> Response[list[KeyCombination]]:
 67    """
 68    Find keys that are used together with a given key.
 69
 70    https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_combinations
 71
 72    Args:
 73        key: tag key
 74        query: only show results where the ``other_key`` matches this query (substring match)
 75        sortname: what field to sort by
 76        sortorder: sort order
 77        filter: can be used to filter only values on tags used on nodes/ways/relations
 78        page: page number (starting at 1)
 79        rp: results per page
 80        session: request client session
 81
 82    Raises:
 83        TaginfoError
 84    """
 85    params = api_params(
 86        _Params,
 87        key=key,
 88        query=query,
 89        sortname=sortname,
 90        sortorder=sortorder,
 91        filter=filter,
 92        page=page,
 93        rp=rp,
 94    )
 95    return await api_get_json(
 96        path="key/combinations",
 97        cls=Response[list[KeyCombination]],
 98        session=session,
 99        params=params,
100    )
101
102
103__docformat__ = "google"
async def call( key: str, query: str | None = None, sortname: KeyCombinationSorting = <KeyCombinationSorting.TOGETHER_COUNT: 'together_count'>, sortorder: aio_taginfo.api.v4.SortOrder = <SortOrder.DESC: 'desc'>, filter: aio_taginfo.api.v4.ObjectType = <ObjectType.ALL: 'all'>, page: int = 1, rp: int = 0, session: aiohttp.client.ClientSession | None = None) -> aio_taginfo.api.v4.Response[list[KeyCombination]]:
 58async def call(
 59    key: str,
 60    query: str | None = None,
 61    sortname: KeyCombinationSorting = KeyCombinationSorting.TOGETHER_COUNT,
 62    sortorder: SortOrder = SortOrder.DESC,
 63    filter: ObjectType = ObjectType.ALL,  # noqa: A002
 64    page: int = 1,
 65    rp: int = 0,
 66    session: ClientSession | None = None,
 67) -> Response[list[KeyCombination]]:
 68    """
 69    Find keys that are used together with a given key.
 70
 71    https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_combinations
 72
 73    Args:
 74        key: tag key
 75        query: only show results where the ``other_key`` matches this query (substring match)
 76        sortname: what field to sort by
 77        sortorder: sort order
 78        filter: can be used to filter only values on tags used on nodes/ways/relations
 79        page: page number (starting at 1)
 80        rp: results per page
 81        session: request client session
 82
 83    Raises:
 84        TaginfoError
 85    """
 86    params = api_params(
 87        _Params,
 88        key=key,
 89        query=query,
 90        sortname=sortname,
 91        sortorder=sortorder,
 92        filter=filter,
 93        page=page,
 94        rp=rp,
 95    )
 96    return await api_get_json(
 97        path="key/combinations",
 98        cls=Response[list[KeyCombination]],
 99        session=session,
100        params=params,
101    )

Find keys that are used together with a given key.

https://taginfo.openstreetmap.org/taginfo/apidoc#api_4_key_combinations

Arguments:
  • key: tag key
  • query: only show results where the other_key matches this query (substring match)
  • sortname: what field to sort by
  • sortorder: sort order
  • filter: can be used to filter only values on tags used on nodes/ways/relations
  • page: page number (starting at 1)
  • rp: results per page
  • session: request client session
Raises:
  • TaginfoError
@dataclass(kw_only=True, frozen=True)
class KeyCombination:
21@dataclass(kw_only=True, frozen=True)
22class KeyCombination:
23    """
24    Combination statistics for a given key with another.
25
26    Attributes:
27        other_key: Other key.
28        together_count: Number of objects that have both keys.
29        to_fraction: Fraction of objects with this key that also have the other key.
30        from_fraction: Fraction of objects with other key that also have this key.
31    """
32
33    other_key: str = Field(min_length=1, repr=True)
34    together_count: int = Field(ge=0, repr=True)
35    to_fraction: float = Field(ge=0.0, le=1.0, allow_inf_nan=False, repr=True)
36    from_fraction: float = Field(ge=0.0, le=1.0, allow_inf_nan=False, repr=True)

Combination statistics for a given key with another.

Attributes:
  • other_key: Other key.
  • together_count: Number of objects that have both keys.
  • to_fraction: Fraction of objects with this key that also have the other key.
  • from_fraction: Fraction of objects with other key that also have this key.
KeyCombination(*args: Any, **kwargs: Any)
139    def __init__(__dataclass_self__: PydanticDataclass, *args: Any, **kwargs: Any) -> None:
140        __tracebackhide__ = True
141        s = __dataclass_self__
142        s.__pydantic_validator__.validate_python(ArgsKwargs(args, kwargs), self_instance=s)
other_key: str = FieldInfo(annotation=str, required=True, metadata=[MinLen(min_length=1)])
together_count: int = FieldInfo(annotation=int, required=True, metadata=[Ge(ge=0)])
to_fraction: float = FieldInfo(annotation=float, required=True, metadata=[Ge(ge=0.0), Le(le=1.0), _PydanticGeneralMetadata(allow_inf_nan=False)])
from_fraction: float = FieldInfo(annotation=float, required=True, metadata=[Ge(ge=0.0), Le(le=1.0), _PydanticGeneralMetadata(allow_inf_nan=False)])
class KeyCombinationSorting(builtins.str, enum.Enum):
39class KeyCombinationSorting(str, Enum):
40    """Sort options for key combination."""
41
42    TOGETHER_COUNT = "together_count"
43    OTHER_KEY = "other_key"
44    FROM_FRACTION = "from_fraction"

Sort options for key combination.

TOGETHER_COUNT = <KeyCombinationSorting.TOGETHER_COUNT: 'together_count'>
OTHER_KEY = <KeyCombinationSorting.OTHER_KEY: 'other_key'>
FROM_FRACTION = <KeyCombinationSorting.FROM_FRACTION: 'from_fraction'>
Inherited Members
enum.Enum
name
value
builtins.str
encode
replace
split
rsplit
join
capitalize
casefold
title
center
count
expandtabs
find
partition
index
ljust
lower
lstrip
rfind
rindex
rjust
rstrip
rpartition
splitlines
strip
swapcase
translate
upper
startswith
endswith
removeprefix
removesuffix
isascii
islower
isupper
istitle
isspace
isdecimal
isdigit
isnumeric
isalpha
isalnum
isidentifier
isprintable
zfill
format
format_map
maketrans