overturetoosm.objects

Pydantic models needed throughout the project.

  1"""Pydantic models needed throughout the project."""
  2
  3from typing import Dict, List, Optional
  4import pydantic
  5
  6
  7class Sources(pydantic.BaseModel):
  8    """Overture sources model."""
  9
 10    property: str
 11    dataset: str
 12    record_id: Optional[str] = None
 13    confidence: float = pydantic.Field(default=0.0)
 14
 15
 16class Names(pydantic.BaseModel):
 17    """Overture names model."""
 18
 19    primary: str
 20    common: Optional[Dict[str, str]]
 21    rules: Optional[List[Dict[str, str]]]
 22
 23
 24class Addresses(pydantic.BaseModel):
 25    """Overture addresses model."""
 26
 27    freeform: Optional[str]
 28    locality: Optional[str]
 29    postcode: Optional[str]
 30    region: Optional[str]
 31    country: Optional[str]
 32
 33
 34class Categories(pydantic.BaseModel):
 35    """Overture categories model."""
 36
 37    main: str
 38    alternate: Optional[List[str]]
 39
 40
 41class Brand(pydantic.BaseModel):
 42    """Overture brand model."""
 43
 44    wikidata: Optional[str]
 45    names: Names
 46
 47
 48class PlaceProps(pydantic.BaseModel):
 49    """Overture properties model.
 50
 51    Use this model directly if you want to manipulate the `place` properties yourself.
 52    """
 53
 54    id: str
 55    version: int
 56    update_time: str
 57    sources: List[Sources]
 58    names: Names
 59    brand: Optional[Brand] = None
 60    categories: Optional[Categories] = None
 61    confidence: float = pydantic.Field(ge=0.0, le=1.0)
 62    websites: Optional[List[str]] = None
 63    socials: Optional[List[str]] = None
 64    phones: Optional[List[str]] = None
 65    addresses: List[Addresses]
 66
 67
 68class ConfidenceError(Exception):
 69    """
 70    Confidence error exception.
 71
 72    This exception is raised when the confidence level of an item is below the
 73    user-defined level. It contains the original confidence level and the confidence
 74    level of the item.
 75
 76    Attributes:
 77        confidence_level (float): The set confidence level.
 78        confidence_item (float): The confidence of the item.
 79        message (str): The error message.
 80    """
 81
 82    def __init__(
 83        self,
 84        confidence_level: float,
 85        confidence_item: float,
 86        message: str = "Confidence in this item is too low.",
 87    ) -> None:
 88        """@private"""
 89        self.confidence_level = confidence_level
 90        self.confidence_item = confidence_item
 91        self.message = message
 92        super().__init__(message)
 93
 94    def __str__(self) -> str:
 95        """@private"""
 96        conf = f"confidence_level={self.confidence_level}, confidence_item={self.confidence_item}"
 97        return f"""{self.message} {conf}"""
 98
 99
100class UnmatchedError(Exception):
101    """
102    Unmatched category error.
103
104    This exception is raised when an item's Overture category does not have a
105    corresponding OSM definition. Edit
106    [the OSM Wiki page](https://wiki.openstreetmap.org/wiki/Overture_categories)
107    to add a definition to this category.
108
109    Attributes:
110        category (str): The Overture category that is unmatched.
111        message (str): The error message.
112    """
113
114    def __init__(
115        self,
116        category: str,
117        message: str = "Overture category is unmatched.",
118    ) -> None:
119        """@private"""
120        self.category = category
121        self.message = message
122        super().__init__(message)
123
124    def __str__(self) -> str:
125        """@private"""
126        return f"{self.message} {{category={self.category}}}"
127
128
129class BuildingProps(pydantic.BaseModel):
130    """Overture building properties.
131
132    Use this model directly if you want to manipulate the `building` properties yourself.
133    """
134
135    version: int
136    class_: str = pydantic.Field(alias="class")
137    subtype: str
138    sources: List[Sources]
139    height: Optional[float] = None
140    is_underground: Optional[bool] = None
141    num_floors: Optional[int] = None
142    num_floors_underground: Optional[int] = None
143    min_height: Optional[float] = None
144    min_floor: Optional[int] = None
145    facade_color: Optional[str] = None
146    facade_material: Optional[str] = None
147    roof_material: Optional[str] = None
148    roof_shape: Optional[str] = None
149    roof_direction: Optional[str] = None
150    roof_orientation: Optional[str] = None
151    roof_color: Optional[str] = None
152    roof_height: Optional[float] = None
class Sources(pydantic.main.BaseModel):
 8class Sources(pydantic.BaseModel):
 9    """Overture sources model."""
10
11    property: str
12    dataset: str
13    record_id: Optional[str] = None
14    confidence: float = pydantic.Field(default=0.0)

Overture sources model.

property: str
dataset: str
record_id: Optional[str]
confidence: float
model_config = {}
model_fields = {'property': FieldInfo(annotation=str, required=True), 'dataset': FieldInfo(annotation=str, required=True), 'record_id': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'confidence': FieldInfo(annotation=float, required=False, default=0.0)}
model_computed_fields = {}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class Names(pydantic.main.BaseModel):
17class Names(pydantic.BaseModel):
18    """Overture names model."""
19
20    primary: str
21    common: Optional[Dict[str, str]]
22    rules: Optional[List[Dict[str, str]]]

Overture names model.

primary: str
common: Optional[Dict[str, str]]
rules: Optional[List[Dict[str, str]]]
model_config = {}
model_fields = {'primary': FieldInfo(annotation=str, required=True), 'common': FieldInfo(annotation=Union[Dict[str, str], NoneType], required=True), 'rules': FieldInfo(annotation=Union[List[Dict[str, str]], NoneType], required=True)}
model_computed_fields = {}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class Addresses(pydantic.main.BaseModel):
25class Addresses(pydantic.BaseModel):
26    """Overture addresses model."""
27
28    freeform: Optional[str]
29    locality: Optional[str]
30    postcode: Optional[str]
31    region: Optional[str]
32    country: Optional[str]

Overture addresses model.

freeform: Optional[str]
locality: Optional[str]
postcode: Optional[str]
region: Optional[str]
country: Optional[str]
model_config = {}
model_fields = {'freeform': FieldInfo(annotation=Union[str, NoneType], required=True), 'locality': FieldInfo(annotation=Union[str, NoneType], required=True), 'postcode': FieldInfo(annotation=Union[str, NoneType], required=True), 'region': FieldInfo(annotation=Union[str, NoneType], required=True), 'country': FieldInfo(annotation=Union[str, NoneType], required=True)}
model_computed_fields = {}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class Categories(pydantic.main.BaseModel):
35class Categories(pydantic.BaseModel):
36    """Overture categories model."""
37
38    main: str
39    alternate: Optional[List[str]]

Overture categories model.

main: str
alternate: Optional[List[str]]
model_config = {}
model_fields = {'main': FieldInfo(annotation=str, required=True), 'alternate': FieldInfo(annotation=Union[List[str], NoneType], required=True)}
model_computed_fields = {}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class Brand(pydantic.main.BaseModel):
42class Brand(pydantic.BaseModel):
43    """Overture brand model."""
44
45    wikidata: Optional[str]
46    names: Names

Overture brand model.

wikidata: Optional[str]
names: Names
model_config = {}
model_fields = {'wikidata': FieldInfo(annotation=Union[str, NoneType], required=True), 'names': FieldInfo(annotation=Names, required=True)}
model_computed_fields = {}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class PlaceProps(pydantic.main.BaseModel):
49class PlaceProps(pydantic.BaseModel):
50    """Overture properties model.
51
52    Use this model directly if you want to manipulate the `place` properties yourself.
53    """
54
55    id: str
56    version: int
57    update_time: str
58    sources: List[Sources]
59    names: Names
60    brand: Optional[Brand] = None
61    categories: Optional[Categories] = None
62    confidence: float = pydantic.Field(ge=0.0, le=1.0)
63    websites: Optional[List[str]] = None
64    socials: Optional[List[str]] = None
65    phones: Optional[List[str]] = None
66    addresses: List[Addresses]

Overture properties model.

Use this model directly if you want to manipulate the place properties yourself.

id: str
version: int
update_time: str
sources: List[Sources]
names: Names
brand: Optional[Brand]
categories: Optional[Categories]
confidence: float
websites: Optional[List[str]]
socials: Optional[List[str]]
phones: Optional[List[str]]
addresses: List[Addresses]
model_config = {}
model_fields = {'id': FieldInfo(annotation=str, required=True), 'version': FieldInfo(annotation=int, required=True), 'update_time': FieldInfo(annotation=str, required=True), 'sources': FieldInfo(annotation=List[Sources], required=True), 'names': FieldInfo(annotation=Names, required=True), 'brand': FieldInfo(annotation=Union[Brand, NoneType], required=False, default=None), 'categories': FieldInfo(annotation=Union[Categories, NoneType], required=False, default=None), 'confidence': FieldInfo(annotation=float, required=True, metadata=[Ge(ge=0.0), Le(le=1.0)]), 'websites': FieldInfo(annotation=Union[List[str], NoneType], required=False, default=None), 'socials': FieldInfo(annotation=Union[List[str], NoneType], required=False, default=None), 'phones': FieldInfo(annotation=Union[List[str], NoneType], required=False, default=None), 'addresses': FieldInfo(annotation=List[Addresses], required=True)}
model_computed_fields = {}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class ConfidenceError(builtins.Exception):
69class ConfidenceError(Exception):
70    """
71    Confidence error exception.
72
73    This exception is raised when the confidence level of an item is below the
74    user-defined level. It contains the original confidence level and the confidence
75    level of the item.
76
77    Attributes:
78        confidence_level (float): The set confidence level.
79        confidence_item (float): The confidence of the item.
80        message (str): The error message.
81    """
82
83    def __init__(
84        self,
85        confidence_level: float,
86        confidence_item: float,
87        message: str = "Confidence in this item is too low.",
88    ) -> None:
89        """@private"""
90        self.confidence_level = confidence_level
91        self.confidence_item = confidence_item
92        self.message = message
93        super().__init__(message)
94
95    def __str__(self) -> str:
96        """@private"""
97        conf = f"confidence_level={self.confidence_level}, confidence_item={self.confidence_item}"
98        return f"""{self.message} {conf}"""

Confidence error exception.

This exception is raised when the confidence level of an item is below the user-defined level. It contains the original confidence level and the confidence level of the item.

Attributes:
  • confidence_level (float): The set confidence level.
  • confidence_item (float): The confidence of the item.
  • message (str): The error message.
confidence_level
confidence_item
message
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class UnmatchedError(builtins.Exception):
101class UnmatchedError(Exception):
102    """
103    Unmatched category error.
104
105    This exception is raised when an item's Overture category does not have a
106    corresponding OSM definition. Edit
107    [the OSM Wiki page](https://wiki.openstreetmap.org/wiki/Overture_categories)
108    to add a definition to this category.
109
110    Attributes:
111        category (str): The Overture category that is unmatched.
112        message (str): The error message.
113    """
114
115    def __init__(
116        self,
117        category: str,
118        message: str = "Overture category is unmatched.",
119    ) -> None:
120        """@private"""
121        self.category = category
122        self.message = message
123        super().__init__(message)
124
125    def __str__(self) -> str:
126        """@private"""
127        return f"{self.message} {{category={self.category}}}"

Unmatched category error.

This exception is raised when an item's Overture category does not have a corresponding OSM definition. Edit the OSM Wiki page to add a definition to this category.

Attributes:
  • category (str): The Overture category that is unmatched.
  • message (str): The error message.
category
message
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class BuildingProps(pydantic.main.BaseModel):
130class BuildingProps(pydantic.BaseModel):
131    """Overture building properties.
132
133    Use this model directly if you want to manipulate the `building` properties yourself.
134    """
135
136    version: int
137    class_: str = pydantic.Field(alias="class")
138    subtype: str
139    sources: List[Sources]
140    height: Optional[float] = None
141    is_underground: Optional[bool] = None
142    num_floors: Optional[int] = None
143    num_floors_underground: Optional[int] = None
144    min_height: Optional[float] = None
145    min_floor: Optional[int] = None
146    facade_color: Optional[str] = None
147    facade_material: Optional[str] = None
148    roof_material: Optional[str] = None
149    roof_shape: Optional[str] = None
150    roof_direction: Optional[str] = None
151    roof_orientation: Optional[str] = None
152    roof_color: Optional[str] = None
153    roof_height: Optional[float] = None

Overture building properties.

Use this model directly if you want to manipulate the building properties yourself.

version: int
class_: str
subtype: str
sources: List[Sources]
height: Optional[float]
is_underground: Optional[bool]
num_floors: Optional[int]
num_floors_underground: Optional[int]
min_height: Optional[float]
min_floor: Optional[int]
facade_color: Optional[str]
facade_material: Optional[str]
roof_material: Optional[str]
roof_shape: Optional[str]
roof_direction: Optional[str]
roof_orientation: Optional[str]
roof_color: Optional[str]
roof_height: Optional[float]
model_config = {}
model_fields = {'version': FieldInfo(annotation=int, required=True), 'class_': FieldInfo(annotation=str, required=True, alias='class', alias_priority=2), 'subtype': FieldInfo(annotation=str, required=True), 'sources': FieldInfo(annotation=List[Sources], required=True), 'height': FieldInfo(annotation=Union[float, NoneType], required=False, default=None), 'is_underground': FieldInfo(annotation=Union[bool, NoneType], required=False, default=None), 'num_floors': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'num_floors_underground': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'min_height': FieldInfo(annotation=Union[float, NoneType], required=False, default=None), 'min_floor': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'facade_color': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'facade_material': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'roof_material': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'roof_shape': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'roof_direction': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'roof_orientation': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'roof_color': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'roof_height': FieldInfo(annotation=Union[float, NoneType], required=False, default=None)}
model_computed_fields = {}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs