Skip to content

Commit

Permalink
Added typing (#494)
Browse files Browse the repository at this point in the history
* first init

* added typing for map

* added colormaps

* working on common

* fix spell error

* added deck

* working on folium

* worked on folium map

* fixed common

* added heremap

* added kepler

* added osm

* updated pc

* changed Tuple to tuple

* added plotlymap

* working on stack

* updated osm.py and req

* updated stac

* updated all py files

* removed stac_io type hint

* tuple to Tuple

* tuple to Tuple

* fixed typos

* updated bokehmap to Sequency

* updated stac and plotlymap

* updated plotlymap

* access_token - None

* updated with black

* removed kml

* updated basemap and stac

* updated bokeh

* updated notebook

* Update mkdocs.yml

added "notebooks/38_plotly.ipynb", in execute_ignore

* updated req

* updated mkdocs

* removed geemap

* made collection as Optional

* added None to Collection

* Fix bokeh error

* Fix bokehmap typing

* Pin pyymal version

* Fix pyymal error

* Skip notebook 71

* Fix button width error

* Fix basemap notebook error

* Improve typing

* Improve typing

---------

Co-authored-by: Qiusheng Wu <[email protected]>
  • Loading branch information
krishnaglodha and giswqs authored Aug 9, 2023
1 parent e896f9b commit 1dc8e24
Show file tree
Hide file tree
Showing 19 changed files with 1,145 additions and 926 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
gdalinfo --version
- name: Install dependencies
run: |
pip install --no-cache-dir Cython
pip install --no-cache-dir Cython PyYAML==6.0.1
pip install -r requirements.txt -r requirements_dev.txt
pip install .
- name: Discover typos with codespell
Expand Down
61 changes: 0 additions & 61 deletions docs/notebooks/02_using_basemaps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -167,67 +167,6 @@
"m.add_legend(builtin_legend=\"NWI\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Add a layer from [xyzservices](https://github.com/geopandas/xyzservices) provider object"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import xyzservices.providers as xyz"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"basemap = xyz.HEREv3.basicMap\n",
"basemap"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pass the api key to the xyzservices provider object or set it as an environment variable."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"basemap['apiKey'] = os.environ[\"HEREMAPS_API_KEY\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Add the xyzservices provider object as a layer to the map."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_basemap(basemap)\n",
"m"
]
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/38_plotly.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"metadata": {},
"outputs": [],
"source": [
"# leafmap.fix_widget_error()"
"leafmap.fix_widget_error()"
]
},
{
Expand Down
61 changes: 0 additions & 61 deletions examples/notebooks/02_using_basemaps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -167,67 +167,6 @@
"m.add_legend(builtin_legend=\"NWI\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Add a layer from [xyzservices](https://github.com/geopandas/xyzservices) provider object"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import xyzservices.providers as xyz"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"basemap = xyz.HEREv3.basicMap\n",
"basemap"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pass the api key to the xyzservices provider object or set it as an environment variable."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"basemap['apiKey'] = os.environ[\"HEREMAPS_API_KEY\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Add the xyzservices provider object as a layer to the map."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_basemap(basemap)\n",
"m"
]
}
],
"metadata": {
Expand Down
19 changes: 10 additions & 9 deletions leafmap/basemaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import ipyleaflet
import xyzservices.providers as xyz
from .common import check_package, planet_tiles
from typing import Dict, Optional, List

# from box import Box

Expand Down Expand Up @@ -228,7 +229,7 @@ def _unpack_sub_parameters(var, param):
return temp


def get_xyz_dict(free_only=True, france=False):
def get_xyz_dict(free_only: bool = True, france: bool = False) -> Dict:
"""Returns a dictionary of xyz services.
Args:
Expand Down Expand Up @@ -279,7 +280,7 @@ def get_xyz_dict(free_only=True, france=False):
return xyz_dict


def xyz_to_leaflet():
def xyz_to_leaflet() -> Dict:
"""Convert xyz tile services to ipyleaflet tile layers.
Returns:
Expand All @@ -306,7 +307,7 @@ def xyz_to_leaflet():
return leaflet_dict


def xyz_to_pydeck():
def xyz_to_pydeck() -> Dict:
"""Convert xyz tile services to pydeck custom tile layers.
Returns:
Expand Down Expand Up @@ -345,7 +346,7 @@ def xyz_to_pydeck():
return pydeck_dict


def xyz_to_folium():
def xyz_to_folium() -> Dict:
"""Convert xyz tile services to folium tile layers.
Returns:
Expand Down Expand Up @@ -409,7 +410,7 @@ def xyz_to_folium():
return folium_dict


def xyz_to_heremap():
def xyz_to_heremap() -> Dict:
"""Convert xyz tile services to hermap tile layers.
Returns:
Expand Down Expand Up @@ -510,7 +511,7 @@ def xyz_to_heremap():
return heremap_dict


def xyz_to_plotly():
def xyz_to_plotly() -> Dict:
"""Convert xyz tile services to plotly tile layers.
Returns:
Expand Down Expand Up @@ -546,7 +547,7 @@ def xyz_to_plotly():
return plotly_dict


def xyz_to_bokeh():
def xyz_to_bokeh() -> Dict:
"""Convert xyz tile services to bokeh tile layers.
Returns:
Expand Down Expand Up @@ -600,13 +601,13 @@ def search_qms(keywords, limit=10):
return services["results"][:limit]


def get_qms(service_id):
def get_qms(service_id: str) -> Dict:
QMS_API = "https://qms.nextgis.com/api/v1/geoservices"
service_details = requests.get(f"{QMS_API}/{service_id}")
return service_details.json()


def qms_to_leafmap(service_id):
def qms_to_leafmap(service_id: str) -> Dict:
service_details = get_qms(service_id)
name = service_details["name"]
url = service_details["url"]
Expand Down
Loading

0 comments on commit 1dc8e24

Please sign in to comment.