Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Hillshade layer to notebook api #304

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
10 changes: 0 additions & 10 deletions packages/schema/src/schema/rasterDemSource.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,10 @@
"type": "string",
"description": "The url to the tile provider"
},
"tileSize": {
"type": "number",
"description": " The tile size",
"default": 512
},
"attribution": {
"type": "string",
"description": "The attribution for the raster-dem source"
},
"encoding": {
Copy link
Member

Choose a reason for hiding this comment

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

Is it some outdated thing we used to have with maplibre?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea, that and tileSize were needed in MapLibre

"type": "string",
"enum": ["terrarium", "mapbox"],
"default": "mapbox"
},
"urlParameters": {
"type": "object",
"additionalProperties": {
Expand Down
38 changes: 38 additions & 0 deletions python/jupytergis_lab/jupytergis_lab/notebook/gis_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
IVectorTileSource,
IVideoSource,
IWebGlLayer,
IRasterDemSource,
LayerType,
SourceType,
)
Expand Down Expand Up @@ -414,6 +415,41 @@ def add_tiff_layer(

return self._add_layer(OBJECT_FACTORY.create_layer(layer, self))

def add_hillshade_layer(
self,
url: str,
name: str = "Hillshade Layer",
urlParameters: Dict = {},
attribution: str = "",
):
"""
Add a hillshade layer

:param str url: URL of the 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.
"""

source = {
"type": SourceType.RasterDemSource,
"name": f"{name} Source",
"parameters": {
"url": url,
"attribution": attribution,
"urlParameters": urlParameters,
},
}
source_id = self._add_source(OBJECT_FACTORY.create_source(source, self))

layer = {
"type": LayerType.HillshadeLayer,
"name": name,
"visible": True,
"parameters": {"source": source_id},
}

return self._add_layer(OBJECT_FACTORY.create_layer(layer, self))

def create_color_expr(
self,
color_stops: Dict,
Expand Down Expand Up @@ -655,6 +691,7 @@ class Config:
IImageSource,
IVideoSource,
IGeoTiffSource,
IRasterDemSource,
]
_parent = Optional[GISDocument]

Expand Down Expand Up @@ -740,3 +777,4 @@ def create_source(
OBJECT_FACTORY.register_factory(SourceType.ImageSource, IImageSource)
OBJECT_FACTORY.register_factory(SourceType.VideoSource, IVideoSource)
OBJECT_FACTORY.register_factory(SourceType.GeoTiffSource, IGeoTiffSource)
OBJECT_FACTORY.register_factory(SourceType.RasterDemSource, IRasterDemSource)
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
from ._schema.videoSource import IVideoSource # noqa
from ._schema.imageSource import IImageSource # noqa
from ._schema.geoTiffSource import IGeoTiffSource # noqa
from ._schema.rasterDemSource import IRasterDemSource # noqa
Loading