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