-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
83 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from typing import Dict, Literal | ||
from .objects import AddressProps | ||
|
||
|
||
def process_address( | ||
props: dict, | ||
style: Literal["US"] = "US", | ||
) -> Dict[str, str]: | ||
"""Convert Overture's address properties to OSM tags. | ||
Args: | ||
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. | ||
""" | ||
bad_tags = ["version", "theme", "type", "address_levels"] | ||
print(props) | ||
prop = AddressProps(**props) | ||
obj_dict = prop.model_dump(exclude_none=True, by_alias=True) | ||
if prop.address_levels: | ||
if style == "US": | ||
obj_dict["addr:state"] = prop.address_levels[0]["value"] | ||
|
||
for tag in bad_tags: | ||
obj_dict.pop(tag, None) | ||
|
||
return obj_dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters