overturetoosm.addresses
Convert Overture's addresses
features to OSM tags.
1"""Convert Overture's `addresses` features to OSM tags.""" 2 3from typing import Dict 4from .objects import AddressProps 5 6 7def process_address( 8 props: dict, 9 style: str = "US", 10) -> Dict[str, str]: 11 """Convert Overture's address properties to OSM tags. 12 13 Args: 14 props (dict): The feature properties from the Overture GeoJSON. 15 style (str, optional): How to handle the `address_levels` field. Open 16 a pull request or issue to add support for other regions. Defaults to "US". 17 18 Returns: 19 Dict[str, str]: The reshaped and converted properties in OSM's flat str:str schema. 20 """ 21 bad_tags = ["version", "theme", "type", "address_levels"] 22 prop = AddressProps(**props) 23 24 obj_dict = prop.model_dump(exclude_none=True, by_alias=True) 25 26 if obj_dict["address_levels"] and len(obj_dict["address_levels"]) > 0: 27 if style == "US": 28 obj_dict["addr:state"] = str(obj_dict["address_levels"][0]["value"]) 29 30 for tag in bad_tags: 31 obj_dict.pop(tag, None) 32 33 return obj_dict
def
process_address(props: dict, style: str = 'US') -> Dict[str, str]:
8def process_address( 9 props: dict, 10 style: str = "US", 11) -> Dict[str, str]: 12 """Convert Overture's address properties to OSM tags. 13 14 Args: 15 props (dict): The feature properties from the Overture GeoJSON. 16 style (str, optional): How to handle the `address_levels` field. Open 17 a pull request or issue to add support for other regions. Defaults to "US". 18 19 Returns: 20 Dict[str, str]: The reshaped and converted properties in OSM's flat str:str schema. 21 """ 22 bad_tags = ["version", "theme", "type", "address_levels"] 23 prop = AddressProps(**props) 24 25 obj_dict = prop.model_dump(exclude_none=True, by_alias=True) 26 27 if obj_dict["address_levels"] and len(obj_dict["address_levels"]) > 0: 28 if style == "US": 29 obj_dict["addr:state"] = str(obj_dict["address_levels"][0]["value"]) 30 31 for tag in bad_tags: 32 obj_dict.pop(tag, None) 33 34 return obj_dict
Convert Overture's address properties to OSM tags.
Arguments:
- props (dict): The feature properties from the Overture GeoJSON.
- style (str, optional): How to handle the
address_levels
field. Open a pull request or issue to add support for other regions. Defaults to "US".
Returns:
Dict[str, str]: The reshaped and converted properties in OSM's flat str:str schema.