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
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.
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
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.
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
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.
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
35class Categories(pydantic.BaseModel): 36 """Overture categories model.""" 37 38 main: str 39 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
42class Brand(pydantic.BaseModel): 43 """Overture brand model.""" 44 45 wikidata: Optional[str] 46 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
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.
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
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.
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
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.
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
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.
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