Skip to content

Restore type (polygon, line, point) on vector layers #847

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

Draft
wants to merge 1 commit 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
3 changes: 2 additions & 1 deletion packages/base/src/formbuilder/creationform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ export class CreationForm extends React.Component<ICreationFormProps, any> {
visible: true,
name: actualName,
};

console.log('sourceData:', this.props.sourceData);
console.log('layerData:', this.props.layerData);
this.jGISModel.addLayer(UUID.uuid4(), layerModel);
}
});
Expand Down
3 changes: 3 additions & 0 deletions packages/base/src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ export const loadFile = async (fileInfo: {
model: IJupyterGISModel;
}) => {
const { filepath, type, model } = fileInfo;
if (!filepath) {
return;
}

if (filepath.startsWith('http://') || filepath.startsWith('https://')) {
switch (type) {
Expand Down
8 changes: 7 additions & 1 deletion packages/schema/src/schema/project/layers/vectorLayer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
"type": "object",
"description": "VectorLayer",
"title": "IVectorLayer",
"required": ["source"],
"required": ["source", "type"],
"additionalProperties": false,
"properties": {
"source": {
"type": "string",
"description": "The id of the source"
},
"type": {
"type": "string",
"enum": ["points", "polygons", "lines"],
"default": "points",
"description": "The type of vector layer"
},
"color": {
"type": "object",
"description": "The color of the the object"
Expand Down
3 changes: 3 additions & 0 deletions python/jupytergis_lab/jupytergis_lab/notebook/gis_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def add_geojson_layer(
path: str | Path | None = None,
data: Dict | None = None,
name: str = "GeoJSON Layer",
type: "points" | "polygons" | "lines" = "points",
opacity: float = 1,
logical_op: str | None = None,
feature: str | None = None,
Expand All @@ -258,6 +259,7 @@ def add_geojson_layer(
:param name: The name that will be used for the object in the document.
:param path: The path to the JSON file or URL 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 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 @@ -301,6 +303,7 @@ def add_geojson_layer(
"visible": True,
"parameters": {
"source": source_id,
"type": type,
"color": color_expr,
"opacity": opacity,
},
Expand Down
6 changes: 3 additions & 3 deletions python/jupytergis_qgis/jupytergis_qgis/qgis_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ def build_uri(parameters: dict[str, str], source_type: str) -> str | None:
geometry_type = layer.get("parameters", {}).get("type")
layer_params = layer.get("parameters", {})

if geometry_type == "circle":
if geometry_type == "points":
symbol = QgsMarkerSymbol()
color_params = layer_params.get("color", {})
opacity = layer_params.get("opacity", 1.0)
Expand Down Expand Up @@ -811,7 +811,7 @@ def build_uri(parameters: dict[str, str], source_type: str) -> str | None:
symbology_state, geometry_type, color_params, symbol
)

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

elif geometry_type == "fill":
elif geometry_type == "polygons":
symbol = QgsFillSymbol()
symbol.setOutputUnit(Qgis.RenderUnit.Pixels)
color_params = layer_params.get("color", {})
Expand Down
Loading