Skip to content

Commit

Permalink
Improve add_overture method (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs authored Nov 10, 2024
1 parent 845aa10 commit 59c100e
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 36 deletions.
38 changes: 27 additions & 11 deletions docs/maplibre/overture.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
" center=[-74.0095, 40.7046], zoom=16, pitch=60, bearing=-17, style=\"positron\"\n",
")\n",
"m.add_basemap(\"Esri.WorldImagery\", visible=False)\n",
"m.add_overture_3d_buildings(release=\"2024-07-22\", template=\"simple\")\n",
"m.add_overture_3d_buildings(release=\"2024-10-23\", template=\"simple\")\n",
"m.add_layer_control()\n",
"m"
]
Expand Down Expand Up @@ -84,24 +84,40 @@
"outputs": [],
"source": [
"m = leafmap.Map(center=[-74.0095, 40.7046], zoom=16)\n",
"m.add_basemap(\"OpenStreetMap.Mapnik\")\n",
"m.add_basemap(\"Esri.WorldImagery\", visible=False)\n",
"m.add_overture_data(theme=\"buildings\", opacity=0.8)\n",
"m.add_layer_control()\n",
"m"
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"id": "8",
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(center=[-74.0095, 40.7046], zoom=16)\n",
"m.add_basemap(\"OpenStreetMap.Mapnik\")\n",
"m.add_basemap(\"Esri.WorldImagery\", visible=False)\n",
"m.add_overture_buildings(type=\"line\", line_color=\"#ff0000\", line_width=2, opacity=0.8)\n",
"m.add_layer_control()\n",
"m"
]
},
{
"cell_type": "markdown",
"id": "9",
"metadata": {},
"source": [
"## Transportation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"id": "10",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -114,7 +130,7 @@
},
{
"cell_type": "markdown",
"id": "10",
"id": "11",
"metadata": {},
"source": [
"## Places"
Expand All @@ -123,7 +139,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "11",
"id": "12",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -136,7 +152,7 @@
},
{
"cell_type": "markdown",
"id": "12",
"id": "13",
"metadata": {},
"source": [
"## Addresses"
Expand All @@ -145,7 +161,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "13",
"id": "14",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -158,7 +174,7 @@
},
{
"cell_type": "markdown",
"id": "14",
"id": "15",
"metadata": {},
"source": [
"## Base"
Expand All @@ -167,7 +183,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "15",
"id": "16",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -180,7 +196,7 @@
},
{
"cell_type": "markdown",
"id": "16",
"id": "17",
"metadata": {},
"source": [
"## Divisions"
Expand All @@ -189,7 +205,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "17",
"id": "18",
"metadata": {},
"outputs": [],
"source": [
Expand Down
21 changes: 21 additions & 0 deletions leafmap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13573,6 +13573,27 @@ def replace_hyphens_in_keys(d: Union[Dict, List, Any]) -> Union[Dict, List, Any]
return d


def replace_underscores_in_keys(d: Union[Dict, List, Any]) -> Union[Dict, List, Any]:
"""
Recursively replaces underscores with hyphens in dictionary keys.
Args:
d (Union[Dict, List, Any]): The input dictionary, list or any other data type.
Returns:
Union[Dict, List, Any]: The modified dictionary or list with keys having underscores replaced with hyphens,
or the original input if it's not a dictionary or list.
"""
if isinstance(d, dict):
return {
k.replace("_", "-"): replace_underscores_in_keys(v) for k, v in d.items()
}
elif isinstance(d, list):
return [replace_underscores_in_keys(i) for i in d]
else:
return d


def geojson_bounds(geojson: dict) -> Optional[list]:
"""
Calculate the bounds of a GeoJSON object.
Expand Down
Loading

0 comments on commit 59c100e

Please sign in to comment.