Skip to content

Commit 5e0d27f

Browse files
Restore type on vector layers.
1 parent b294c7d commit 5e0d27f

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

packages/base/src/formbuilder/creationform.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ export class CreationForm extends React.Component<ICreationFormProps, any> {
186186
visible: true,
187187
name: actualName,
188188
};
189-
190189
this.jGISModel.addLayer(UUID.uuid4(), layerModel);
191190
}
192191
});

packages/base/src/tools.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,9 @@ export const loadFile = async (fileInfo: {
499499
model: IJupyterGISModel;
500500
}) => {
501501
const { filepath, type, model } = fileInfo;
502+
if (!filepath) {
503+
return;
504+
}
502505

503506
if (filepath.startsWith('http://') || filepath.startsWith('https://')) {
504507
switch (type) {

packages/schema/src/schema/project/layers/vectorLayer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
"type": "object",
33
"description": "VectorLayer",
44
"title": "IVectorLayer",
5-
"required": ["source"],
5+
"required": ["source", "type"],
66
"additionalProperties": false,
77
"properties": {
88
"source": {
99
"type": "string",
1010
"description": "The id of the source"
1111
},
12+
"type": {
13+
"type": "string",
14+
"enum": ["points", "polygons", "lines"],
15+
"default": "points",
16+
"description": "The type of vector layer"
17+
},
1218
"color": {
1319
"type": "object",
1420
"description": "The color of the the object"

python/jupytergis_lab/jupytergis_lab/notebook/gis_document.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ def add_geojson_layer(
245245
path: str | Path | None = None,
246246
data: Dict | None = None,
247247
name: str = "GeoJSON Layer",
248+
type: "points" | "polygons" | "lines" = "points",
248249
opacity: float = 1,
249250
logical_op: str | None = None,
250251
feature: str | None = None,
@@ -258,6 +259,7 @@ def add_geojson_layer(
258259
:param name: The name that will be used for the object in the document.
259260
:param path: The path to the JSON file or URL to embed into the jGIS file.
260261
:param data: The raw GeoJSON data to embed into the jGIS file.
262+
:param type: The type of the vector layer to create.
261263
:param opacity: The opacity, between 0 and 1.
262264
:param color_expr: The style expression used to style the layer, defaults to None
263265
"""
@@ -301,6 +303,7 @@ def add_geojson_layer(
301303
"visible": True,
302304
"parameters": {
303305
"source": source_id,
306+
"type": type,
304307
"color": color_expr,
305308
"opacity": opacity,
306309
},

python/jupytergis_qgis/jupytergis_qgis/qgis_loader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ def build_uri(parameters: dict[str, str], source_type: str) -> str | None:
783783
geometry_type = layer.get("parameters", {}).get("type")
784784
layer_params = layer.get("parameters", {})
785785

786-
if geometry_type == "circle":
786+
if geometry_type == "points":
787787
symbol = QgsMarkerSymbol()
788788
color_params = layer_params.get("color", {})
789789
opacity = layer_params.get("opacity", 1.0)
@@ -811,7 +811,7 @@ def build_uri(parameters: dict[str, str], source_type: str) -> str | None:
811811
symbology_state, geometry_type, color_params, symbol
812812
)
813813

814-
elif geometry_type == "line":
814+
elif geometry_type == "lines":
815815
symbol = QgsLineSymbol()
816816
symbol.setOutputUnit(Qgis.RenderUnit.Pixels)
817817
color_params = layer_params.get("color", {})
@@ -840,7 +840,7 @@ def build_uri(parameters: dict[str, str], source_type: str) -> str | None:
840840
symbology_state, geometry_type, color_params, symbol
841841
)
842842

843-
elif geometry_type == "fill":
843+
elif geometry_type == "polygons":
844844
symbol = QgsFillSymbol()
845845
symbol.setOutputUnit(Qgis.RenderUnit.Pixels)
846846
color_params = layer_params.get("color", {})

0 commit comments

Comments
 (0)