-
Notifications
You must be signed in to change notification settings - Fork 18
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
Implement schemas #4
Comments
About our file format, I'm thinking we could do the following: {
"layers": {
"1234-1234-1": {"type": "TileLayer", "name": "My Layer 1", "value": {"url": "https://...jpg"}},
"1234-1234-2": {"type": "VectorLayer", "name": "My Layer 2", "value": {"source": "5678-5678-1", "styling": {"stroke": "red"}}}
},
"dataSources": {
"5678-5678-1": {"type": "VectorSource", "value": {[GEOJSON-format]}}
},
"layerGroups": {
"group1": {"layers": ["1234-1234-1", "..."], "visible": false},
"group2": {"layers": ["1234-1234-1", "..."]},
}
} |
Looks good. |
Right, we should probably indeed have UUIDs for groups too 👍🏽
Indeed it may be better to have data sources outside of the format. An updated version of the above: {
"layers": {
"1234-1234-1": {"type": "TileLayer", "name": "My Layer 1", "value": {"url": "https://...jpg"}},
"1234-1234-2": {"type": "VectorLayer", "name": "My Layer 2", "value": {"source": "5678-5678-1", "styling": {"stroke": "red"}}}
},
"dataSources": {
"5678-5678-1": {"type": "GeoJSONFile", "url": "./path/to/local.json"}
},
"layerGroups": {
"9876-9876-1": {"name": "group1", "layers": ["1234-1234-1", "..."], "visible": false},
"9876-9876-2": {"name": "group2", "layers": ["1234-1234-1", "..."]},
}
} |
Yes, it looks good. |
We should look into SpatiaLite. |
If we go closer to the maplibre design, our format could look like the following: {
"layers": {
"1234-1234-1": {"type": "raster", "name": "My Layer 1", "source": "5678-5678-2"},
"1234-1234-2": {"type": "line", "name": "My Layer 2", "source": "5678-5678-1", "styling": {"stroke": "red"}}
},
"sources": {
"5678-5678-1": {"type": "geojson", "url": "./path/to/local.json"},
"5678-5678-2": {"type": "raster", "url": "https://...jpg"},
},
"layerGroups": {
"9876-9876-1": {"name": "group1", "layers": ["1234-1234-1", "..."], "visible": false},
"9876-9876-2": {"name": "group2", "layers": ["1234-1234-1", "..."]},
}
} |
After discussion with @martinRenou, the groups may be the reference for the display. If we go in that direction, we should probably set the {
"layers": {
"1234-1234-1": {"type": "raster", "name": "My Layer 1", "source": "5678-5678-2"},
"1234-1234-2": {"type": "line", "name": "My Layer 2", "source": "5678-5678-1", "styling": {"stroke": "red"}}
},
"sources": {
"5678-5678-1": {"type": "geojson", "url": "./path/to/local.json"},
"5678-5678-2": {"type": "raster", "url": "https://...jpg"},
},
"layerGroups": [
{"name": "group1", "layers": ["1234-1234-1", "..."], "visible": false},
{"name": "group2", "layers": ["1234-1234-1", "..."]},
]
} What do you think ? |
I'm not sure about that. This means that each time a layer is added, it is also added as a single layer group?
Maybe we could keep the |
Yes, every layer should be in a group. Otherwise we would have to make distinction between the individual layers and the grouped ones.
That works too, I don't have a strong opinion on that. |
But let's say a user creates a layer group with just one layer. We now have two layer groups with the same layer, and we need to make a distinction that one is an implicit layer group, and the other is an explicit layer group. I'm not sure it is better. |
We can make this transparent to the user so that the user does not know it's a group with one layer. If the user creates a group with one layer it will mostly be a no-op. It's really just for convenience for us on the display, so we just need to loop over the layer groups to meet every layer. |
It's like in the QGIS data structure, you have access to the layer tree which contains all layers, which is the equivalent to our list of layer groups. |
What do you mean by "no-op"? It's a valid group, for instance a user could mark the layer as not visible in this group, or with a special transparency value.
I think that if we go that road we would need a layer group attribute that would flag this group as implicit, e.g. |
How about this instead:
|
If I understand correctly, we would lost the |
Yeah I think the z-index is just implicit with the tree/groups structure |
I don't quite understand the notion of layer tree. |
What don't you understand? |
Looks great, we assume that if the entry is a string it is an individual layer, otherwise it is a group. And the layer tree is a list in this schema.
The idea is to be able to hide or perform other action on a group of layers. |
So in a layer tree a node can be a layer or a layer group, and a layer group has layers that can again be layer groups? |
To allow creating groups. We can think about a scenario using a map and some layers in background, and have several groups displaying data that are not meant to be displayed together. Using groups, you can easily switch between the different data you want to display. |
QGIS and felt both have the ability to group layers, I'm not sure how felt is structuring its data this but QGIS has a tree of layers in memory and saved into the file. In felt you can create groups to control visibility or other visual parameters to a set of layers, and to structure a bit more your file: Screencast.from.2024-06-21.11-23-50.mp4A flat list of layers can quickly be unreadable if you have many layers, so being able to group them sounds like a basic feature to me |
I know groups are useful, what I mean is that groups should just consist of a flat list of layers, but not a possibly nested list of layers and groups. |
Having nested groups would be useful to users too, and it would not bring to much complication for us. So why not do it? |
What's the use case, and how do you display nested groups? |
It looks like felt does not support nested groups, but QGIS does:
Well:
I'd expect that reading through the tree would give us a natural z-index? |
I think that's an important point, if we want to support QGIS files |
OK, makes sense. If the UUIDs in the layer tree can be layers or layer groups, let's make sure we don't end up with recursion 😄 |
Yeah.. We need to make sure the GUI never creates such broken file, but we cannot stop people from manually editing the file and making mistakes. Proper error handling is all we can do. |
I'm trying to build the nested schema but this creates an expected object. IIUC we have:
The tree and group calls each others. So I added the "layerTree": {
"$ref": "#/definitions/jGISLayerTree"
}, and in the definitions, I added: "jGISLayerGroup": {
"title": "IJGISLayerGroup",
"type": "object",
"additionalProperties": false,
"required": ["name", "layers"],
"properties": {
"name": {
"type": "string"
},
"layers": {
"$ref": "#/definitions/jGISLayerTree"
},
"visible": {
"type": "boolean"
},
"parameters": {
"type": "object"
}
}
},
"jGISLayerTree": {
"title": "IJGISLayerTree",
"type": "array",
"default": [],
"items": {
"oneOf": [
{"type": "string"},
{
"type": "object",
"$ref": "#/definitions/jGISLayerGroup"
}
]
}
} When building it, I have an additional export type IJGISLayerTree = (string | IJGISLayerGroup)[];
export interface IJGISLayerGroup {
name: string;
layers: IJGISLayerTree;
visible?: boolean;
parameters?: {
[k: string]: any;
};
}
export interface IJGISLayerGroup1 {
name: string;
layers: IJGISLayerTree;
visible?: boolean;
parameters?: {
[k: string]: any;
};
} Don't know how to properly declare it. |
Maybe there should only be |
Looks good, thanks |
Closing as the basic schemas have been implemented, we can iterate |
We need to implement some schemas to get started.
A good starting point may be to implement schemas for TileLayer / GeoJSON layer.
The text was updated successfully, but these errors were encountered: