Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@ build:
pre_build:
- /bin/bash --login -c "micromamba run -n jupytergis-build jlpm install"
- /bin/bash --login -c "micromamba run -n jupytergis-build jlpm build"
- /bin/bash --login -c "micromamba run -n jupytergis-build jlpm build:packages"
- |-
/bin/bash --login -c "micromamba run -n jupytergis-docs \
python -m pip install \
$(ls ./python/jupytergis_core/dist/jupytergis*.whl) \
$(ls ./python/jupytergis_lab/dist/jupytergis*.whl) \
$(ls ./python/jupytergis_qgis/dist/jupytergis*.whl)"

build:
html:
- |-
/bin/bash --login -c "cd docs && micromamba run -n jupytergis-docs \
python -m sphinx -T -b html -d _build/doctrees -D language=en . \
python -m sphinx --fail-on-warning --keep-going --nitpicky --show-traceback --builder html --doctree-dir _build/doctrees --define language=en . \
$READTHEDOCS_OUTPUT/html"
2 changes: 1 addition & 1 deletion docs/user_guide/features/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Features

```{toctree}
:maxdepth:
:maxdepth: 2

extension.rst
collab.rst
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ extend-include = ["*.ipynb"]
select = [
# pycodestyle
"E",
# bugbear: Disallow mutable argument defaults
"B006",
]
ignore = ["E501", "E731"]
67 changes: 36 additions & 31 deletions python/jupytergis_lab/jupytergis_lab/notebook/gis_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class GISDocument(CommWidget):
"""
Create a new GISDocument object.

:param path: the path to the file that you would like to open.
If not provided, a new empty document will be created.
:param path: the path to the file that you would like to open. If not provided, a new empty document will be created.
"""

def __init__(
Expand Down Expand Up @@ -234,7 +233,7 @@ def add_geojson_layer(
logical_op: str | None = None,
feature: str | None = None,
operator: str | None = None,
value: Union[str, number, float] | None = None,
value: Union[str, int, float] | None = None,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching between typescript and python is a big oof on my brain 🤕

color_expr=None,
):
"""
Expand All @@ -244,7 +243,6 @@ def add_geojson_layer(
:param path: The path to the JSON file to embed into the jGIS file.
:param data: The raw GeoJSON data to embed into the jGIS file.
:param type: The type of the vector layer to create.
:param color: The color to apply to features.
:param opacity: The opacity, between 0 and 1.
:param color_expr: The style expression used to style the layer, defaults to None
"""
Expand Down Expand Up @@ -334,9 +332,9 @@ def add_image_layer(

def add_video_layer(
self,
urls: [],
urls: List,
name: str = "Image Layer",
coordinates: [] = [],
coordinates: Optional[List] = None,
opacity: float = 1,
):
"""
Expand All @@ -347,6 +345,8 @@ def add_video_layer(
:param coordinates: Corners of video specified in longitude, latitude pairs.
:param opacity: The opacity, between 0 and 1.
"""
if coordinates is None:
coordinates = []

if urls is None or coordinates is None:
raise ValueError("URLs and Coordinates are required")
Expand Down Expand Up @@ -383,14 +383,14 @@ def add_tiff_layer(
"""
Add a tiff layer

:param str url: URL of the tif
:param int min: Minimum pixel value to be displayed, defaults to letting the map display set the value
:param int max: Maximum pixel value to be displayed, defaults to letting the map display set the value
:param str name: The name that will be used for the object in the document, defaults to "Tiff Layer"
:param bool normalize: Select whether to normalize values between 0..1, if false than min/max have no effect, defaults to True
:param bool wrapX: Render tiles beyond the tile grid extent, defaults to False
:param float opacity: The opacity, between 0 and 1, defaults to 1.0
:param _type_ color_expr: The style expression used to style the layer, defaults to None
:param url: URL of the tif
:param min: Minimum pixel value to be displayed, defaults to letting the map display set the value
:param max: Maximum pixel value to be displayed, defaults to letting the map display set the value
:param name: The name that will be used for the object in the document, defaults to "Tiff Layer"
:param normalize: Select whether to normalize values between 0..1, if false than min/max have no effect, defaults to True
:param wrapX: Render tiles beyond the tile grid extent, defaults to False
:param opacity: The opacity, between 0 and 1, defaults to 1.0
:param color_expr: The style expression used to style the layer, defaults to None
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeating the types in the docstring is not necessary, the documentation generator will find the annotations in the function signature!

"""

source = {
Expand Down Expand Up @@ -421,7 +421,7 @@ def add_hillshade_layer(
self,
url: str,
name: str = "Hillshade Layer",
urlParameters: Dict = {},
urlParameters: Optional[Dict] = None,
attribution: str = "",
):
"""
Expand All @@ -431,6 +431,8 @@ def add_hillshade_layer(
:param str name: The name that will be used for the object in the document, defaults to "Hillshade Layer"
:param attribution: The attribution.
"""
if urlParameters is None:
urlParameters = {}

source = {
"type": SourceType.RasterDemSource,
Expand All @@ -454,14 +456,14 @@ def add_hillshade_layer(

def add_heatmap_layer(
self,
feature: string,
feature: str,
path: str | Path | None = None,
data: Dict | None = None,
name: str = "Heatmap Layer",
opacity: float = 1,
blur: number = 15,
radius: number = 8,
gradient: List[str] = ["#00f", "#0ff", "#0f0", "#ff0", "#f00"],
blur: int = 15,
radius: int = 8,
gradient: Optional[List[str]] = None,
):
"""
Add a Heatmap Layer to the document.
Expand Down Expand Up @@ -495,6 +497,9 @@ def add_heatmap_layer(
if data is not None:
parameters = {"data": data}

if gradient is None:
gradient = ["#00f", "#0ff", "#0f0", "#ff0", "#f00"]

source = {
"type": SourceType.GeoJSONSource,
"name": f"{name} Source",
Expand Down Expand Up @@ -609,16 +614,16 @@ def add_filter(
logical_op: str,
feature: str,
operator: str,
value: Union[str, number, float],
value: Union[str, int, float],
):
"""
Add a filter to a layer

:param str layer_id: The ID of the layer to filter
:param str logical_op: The logical combination to apply to filters. Must be "any" or "all"
:param str feature: The feature to be filtered on
:param str operator: The operator used to compare the feature and value
:param Union[str, number, float] value: The value to be filtered on
:param layer_id: The ID of the layer to filter
:param logical_op: The logical combination to apply to filters. Must be "any" or "all"
:param feature: The feature to be filtered on
:param operator: The operator used to compare the feature and value
:param value: The value to be filtered on
"""
layer = self._layers.get(layer_id)

Expand Down Expand Up @@ -655,16 +660,16 @@ def update_filter(
logical_op: str,
feature: str,
operator: str,
value: Union[str, number, float],
value: Union[str, int, float],
):
"""
Update a filter applied to a layer

:param str layer_id: The ID of the layer to filter
:param str logical_op: The logical combination to apply to filters. Must be "any" or "all"
:param str feature: The feature to update the value for
:param str operator: The operator used to compare the feature and value
:param Union[str, number, float] value: The new value to be filtered on
:param layer_id: The ID of the layer to filter
:param logical_op: The logical combination to apply to filters. Must be "any" or "all"
:param feature: The feature to update the value for
:param operator: The operator used to compare the feature and value
:param value: The new value to be filtered on
"""
layer = self._layers.get(layer_id)

Expand Down
9 changes: 5 additions & 4 deletions scripts/build_packages.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Build all JupyterGIS packages.

IMPORTANT: Requires dependencies in requirements-build.txt
"""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt we should decouple dependency install from building.


import subprocess
from pathlib import Path

Expand All @@ -8,8 +13,6 @@ def execute(cmd: str, cwd=None):

def build_packages():
root_path = Path(__file__).parents[1]
requirements_build_path = root_path / "requirements-build.txt"
install_build_deps = f"python -m pip install -r {requirements_build_path}"

python_package_prefix = "python"
python_packages = [
Expand All @@ -20,8 +23,6 @@ def build_packages():
"jupytergis_lite",
]

execute(install_build_deps)

for py_package in python_packages:
execute("hatch build", cwd=root_path / python_package_prefix / py_package)

Expand Down
Loading