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
17 changes: 13 additions & 4 deletions python/jupytergis_lab/jupytergis_lab/notebook/gis_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
IHillshadeLayer,
IImageLayer,
IImageSource,
IRasterDemSource,
IRasterLayer,
IRasterSource,
IVectorLayer,
IVectorTileLayer,
IVectorTileSource,
IVideoSource,
IWebGlLayer,
IRasterDemSource,
LayerType,
SourceType,
)
Expand All @@ -48,7 +48,7 @@ class GISDocument(CommWidget):

def __init__(
self,
path: Optional[str] = None,
path: Optional[str | Path] = None,
latitude: Optional[float] = None,
longitude: Optional[float] = None,
zoom: Optional[float] = None,
Expand All @@ -57,6 +57,9 @@ def __init__(
pitch: Optional[float] = None,
projection: Optional[str] = None,
):
if isinstance(path, Path):
path = str(path)

comm_metadata = GISDocument._path_to_comm(path)

ydoc = Doc()
Expand Down Expand Up @@ -102,10 +105,13 @@ def layer_tree(self) -> List[str | Dict]:
"""
return self._layerTree.to_py()

def export_to_qgis(self, path: str) -> bool:
def export_to_qgis(self, path: str | Path) -> bool:
# Lazy import, jupytergis_qgis of qgis may not be installed
from jupytergis_qgis.qgis_loader import export_project_to_qgis

if isinstance(path, Path):
path = str(path)

virtual_file = {
"layers": self._layers.to_py(),
"sources": self._sources.to_py(),
Expand Down Expand Up @@ -227,7 +233,7 @@ def add_vectortile_layer(

def add_geojson_layer(
self,
path: str | None = None,
path: str | Path | None = None,
data: Dict | None = None,
name: str = "GeoJSON Layer",
type: "circle" | "fill" | "line" = "line",
Expand All @@ -249,6 +255,9 @@ def add_geojson_layer(
:param opacity: The opacity, between 0 and 1.
:param color_expr: The style expression used to style the layer, defaults to None
"""
if isinstance(path, Path):
path = str(path)

if path is None and data is None:
raise ValueError("Cannot create a GeoJSON layer without data")

Expand Down
5 changes: 4 additions & 1 deletion python/jupytergis_lab/jupytergis_lab/notebook/y_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@


class YDocConnector(Widget):
def __init__(self, path: Optional[str], **kwargs) -> None:
def __init__(self, path: Optional[str | Path], **kwargs) -> None:
self.path = None
self._format = None
self._contentType = None

if isinstance(path, Path):
path = str(path)

if path is not None:
self.path = path
try:
Expand Down
Loading