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

2529-More corrections for add layer and the config API #2530

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
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,27 @@
"color": "rgba(0,0,255,0.5)",
"paternSize": 10,
"paternWidth": 2,
"fillStyle": "diagonalCross",
"stroke": {
"color": "rgba(128,0,0,1)",
"lineStyle": "dot"
}
}
},
{
"label": "Default",
"visible": true,
"values": ["Default"],
"settings": {
"type": "filledPolygon",
"color": "rgba(0,0,255,0.5)",
"paternSize": 10,
"paternWidth": 2,
"fillStyle": "diagonalCross",
"stroke": {
"color": "rgba(0,0,128,1)",
"lineStyle": "dot"
}
}
}
]
}
Expand Down Expand Up @@ -168,14 +183,18 @@
},
"style": {
"type": "simple",
"label": "LineString label",
"settings": {
"type": "lineString",
"stroke": {
"lineStyle": "shortDash-dot-dot",
"color": "rgba(128,0,0,1)"
"fields": ["LineString label"],
"info": [
{
"settings": {
"type": "lineString",
"stroke": {
"lineStyle": "shortDash-dot-dot",
"color": "rgba(128,0,0,1)"
}
}
}
}
]
}
},
{
Expand Down Expand Up @@ -215,14 +234,18 @@
}
},
"style": {
"styleType": "simple",
"label": "Icon point label",
"settings": {
"type": "iconSymbol",
"mimeType": "image/png",
"src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAcNJREFUKJFjYSATsCBz/v//z/Tp8+fwO/cf273/+FmckZHxn6iQwBMVJbldXJyc27Bq/P//v8jVm3cmtUxf7rX+3nN+ZEVJ+srhd+8/3KikIFfMyMj4Fa7x////zBeu3JjuXDM55Ou//xjOmnfxrsS+8t7Uze1FLAwMDClwjU+fv0irmLzYH5smGHjw/TdTz7yVIe/ef9wiJMi/gYWBgYHhxp2HXgeev2dFVtjhb8Pw7dtPhqbdp+FiCy894E+4cz+IgYEBovHDp88qyJpmxngwxIf5wfnImt+9f68Ed+rff3/ZkTVycnDA2dxcHMhSDH/+/WeHa+Tm5HzJwMCgCJMsW7SZgYmZkeHHj18M5RsPo2jk4eJ+DdcoKSZyQoeX0+LK5+8MDAwMDC9+/WWImbkeI4D85MUZJMWED8A1qirKVjUlBvgETVqugqEa5mQmRoacKO9zWurKPXCNfHx8389evha5Njd8bfPCLXIXPn1F0eQgLshQGut7XUREOJCRkfEfXCMDAwODsa7WmQOnT+t150VMevn6ne33bz+kGBgZ/3FzcTyUEBXZxcb4p0RbTek3TD1KWnUwNf3IwMAQj8u5yAAAupehfivnXOEAAAAASUVORK5CYII=",
"opacity": 0.5
}
"type": "simple",
"fields": ["Icon point label"],
"info": [
{
"settings": {
"type": "iconSymbol",
"mimeType": "image/png",
"src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAcNJREFUKJFjYSATsCBz/v//z/Tp8+fwO/cf273/+FmckZHxn6iQwBMVJbldXJyc27Bq/P//v8jVm3cmtUxf7rX+3nN+ZEVJ+srhd+8/3KikIFfMyMj4Fa7x////zBeu3JjuXDM55Ou//xjOmnfxrsS+8t7Uze1FLAwMDClwjU+fv0irmLzYH5smGHjw/TdTz7yVIe/ef9wiJMi/gYWBgYHhxp2HXgeev2dFVtjhb8Pw7dtPhqbdp+FiCy894E+4cz+IgYEBovHDp88qyJpmxngwxIf5wfnImt+9f68Ed+rff3/ZkTVycnDA2dxcHMhSDH/+/WeHa+Tm5HzJwMCgCJMsW7SZgYmZkeHHj18M5RsPo2jk4eJ+DdcoKSZyQoeX0+LK5+8MDAwMDC9+/WWImbkeI4D85MUZJMWED8A1qirKVjUlBvgETVqugqEa5mQmRoacKO9zWurKPXCNfHx8389evha5Njd8bfPCLXIXPn1F0eQgLshQGut7XUREOJCRkfEfXCMDAwODsa7WmQOnT+t150VMevn6ne33bz+kGBgZ/3FzcTyUEBXZxcb4p0RbTek3TD1KWnUwNf3IwMAQj8u5yAAAupehfivnXOEAAAAASUVORK5CYII=",
"opacity": 0.5
}
}
]
}
},
{
Expand Down Expand Up @@ -274,12 +297,16 @@
}
},
"style": {
"styleType": "simple",
"label": "Point label",
"settings": {
"type": "simpleSymbol",
"symbol": "star"
}
"type": "simple",
"fields": ["Point label"],
"info": [
{
"settings": {
"type": "simpleSymbol",
"symbol": "star"
}
}
]
}
},
{
Expand Down Expand Up @@ -336,12 +363,16 @@
}
},
"style": {
"styleType": "simple",
"label": "Point label",
"settings": {
"type": "simpleSymbol",
"symbol": "star"
}
"type": "simple",
"fields": ["Point label"],
"info": [
{
"settings": {
"type": "simpleSymbol",
"symbol": "star"
}
}
]
}
},
{
Expand Down Expand Up @@ -393,12 +424,16 @@
}
},
"style": {
"styleType": "simple",
"label": "Point label",
"settings": {
"type": "simpleSymbol",
"symbol": "star"
}
"type": "simple",
"fields": ["Point label"],
"info": [
{
"settings": {
"type": "simpleSymbol",
"symbol": "star"
}
}
]
}
},
{
Expand Down Expand Up @@ -450,12 +485,16 @@
}
},
"style": {
"styleType": "simple",
"label": "Point label",
"settings": {
"type": "simpleSymbol",
"symbol": "star"
}
"type": "simple",
"fields": ["Point label"],
"info": [
{
"settings": {
"type": "simpleSymbol",
"symbol": "star"
}
}
]
}
}
]
Expand All @@ -464,3 +503,4 @@
}
]
}

18 changes: 7 additions & 11 deletions packages/geoview-core/public/templates/layers/geojson.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h4 id="HLYR1">1. Many GeoJSON Layers</h4>
'projection': 3978
},
'basemapOptions': {
'basemapId': 'imagery',
'basemapId': 'transport',
'shaded': false,
'labeled': false
},
Expand All @@ -77,13 +77,11 @@ <h4 id="HLYR1">1. Many GeoJSON Layers</h4>
'listOfLayerEntryConfig': [
{
'layerId': 'polygons.json',
'layerName': { 'en': 'Polygons' },
'layerFilter': 'creationDate >= date \'2020/02/15\''
'layerName': { 'en': 'Polygons' }
},
{
'layerId': 'lines.json',
'layerName': { 'en': 'Lines' },
'layerFilter': 'creationDate >= date \'2020-05-28T12:00:00-05:00\''
'layerName': { 'en': 'Lines' }
},
{
'entryType': 'group',
Expand All @@ -93,13 +91,11 @@ <h4 id="HLYR1">1. Many GeoJSON Layers</h4>
{
'layerId': 'icon_points.json',
'layerName': { 'en': 'Icons' },
'initialSettings': { 'states': {'visible' : false} },
'layerFilter': 'creationDate >= date \'2020-01-14T12:00:01-05:00\''
'initialSettings': { 'states': {'visible' : false} }
},
{
'layerId': 'points.json',
'layerName': { 'en': 'Points' },
'layerFilter': 'creationDate >= date \'2019-02-15T22:00:00Z\''
'layerName': { 'en': 'Points' }
}
]
}
Expand All @@ -112,7 +108,7 @@ <h4 id="HLYR1">1. Many GeoJSON Layers</h4>
'corePackages': [],
'theme': 'geo.ca'
}"></div>
<button type="button" class="collapsible">Visibility and filters</button>
<button type="button" class="collapsible active">Visibility and filters</button>
<pre id="layer1-buttons-pre" class="panel"></pre>
<button class="collapsible">Get Legend</button>
<pre id="LegendsId1-table-pre" class="panel">
Expand Down Expand Up @@ -246,7 +242,7 @@ <h4 id="HLYR1">1. Many GeoJSON Layers</h4>
window.addEventListener('load', () => {
createCodeSnippet();
createConfigSnippet();
});
});
</script>
</body>

Expand Down
58 changes: 28 additions & 30 deletions packages/geoview-core/public/templates/layers/layerlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,37 +351,35 @@ const createTableOfFilter = (mapId) => {
mapButtonsDiv.appendChild(br);
}
}
if (geoviewLayer.getLayerFilter(layerPath)) {
const layerFilterText = document.createElement('p');
layerFilterText.innerText = `Extra filter: `;
mapButtonsDiv.appendChild(layerFilterText);
const layerFilterInput = document.createElement('input');
layerFilterInput.id = `filter-input-${mapId}-${geoviewLayer.getGeoviewLayerId()}`;
layerFilterInput.style.width = '50%';
layerFilterText.appendChild(layerFilterInput);
layerFilterInput.value = geoviewLayer.getLayerFilter(layerPath) || '';
const layerFilterButton = document.createElement('button');
layerFilterButton.addEventListener('click', (e) => {
const checkbox = document.getElementById(`checkbox-${mapId}-${geoviewLayer.getGeoviewLayerId()}`);
geoviewLayer.applyViewFilter(layerPath, layerFilterInput.value, checkbox.value !== 'true');
});
layerFilterButton.innerText = 'Apply';
layerFilterText.style.width = 'max-content';
layerFilterText.appendChild(layerFilterButton);
const layerFilterText = document.createElement('p');
layerFilterText.innerText = `Extra filter: `;
mapButtonsDiv.appendChild(layerFilterText);
const layerFilterInput = document.createElement('input');
layerFilterInput.id = `filter-input-${mapId}-${geoviewLayer.getGeoviewLayerId()}`;
layerFilterInput.style.width = '50%';
layerFilterText.appendChild(layerFilterInput);
layerFilterInput.value = geoviewLayer.getLayerFilter(layerPath) || '';
const layerFilterButton = document.createElement('button');
layerFilterButton.addEventListener('click', (e) => {
const checkbox = document.getElementById(`checkbox-${mapId}-${geoviewLayer.getGeoviewLayerId()}`);
geoviewLayer.applyViewFilter(layerPath, layerFilterInput.value, checkbox.value !== 'true');
});
layerFilterButton.innerText = 'Apply';
layerFilterText.style.width = 'max-content';
layerFilterText.appendChild(layerFilterButton);

const checkboxInput = document.createElement('input');
checkboxInput.type = 'checkbox';
checkboxInput.value = 'false';
checkboxInput.id = `checkbox-${mapId}-${geoviewLayer.getGeoviewLayerId()}`;
checkboxInput.addEventListener('click', (e) => {
checkboxInput.value = checkboxInput.value === 'true' ? 'false' : 'true';
geoviewLayer.applyViewFilter(layerPath, layerFilterInput.value, checkboxInput.value !== 'true');
});
mapButtonsDiv.appendChild(checkboxInput);
const checkboxText = document.createElement('label');
checkboxText.innerText = `apply only the extra filter`;
mapButtonsDiv.appendChild(checkboxText);
}
const checkboxInput = document.createElement('input');
checkboxInput.type = 'checkbox';
checkboxInput.value = 'false';
checkboxInput.id = `checkbox-${mapId}-${geoviewLayer.getGeoviewLayerId()}`;
checkboxInput.addEventListener('click', (e) => {
checkboxInput.value = checkboxInput.value === 'true' ? 'false' : 'true';
geoviewLayer.applyViewFilter(layerPath, layerFilterInput.value, checkboxInput.value !== 'true');
});
mapButtonsDiv.appendChild(checkboxInput);
const checkboxText = document.createElement('label');
checkboxText.innerText = `apply only the extra filter`;
mapButtonsDiv.appendChild(checkboxText);
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ export abstract class AbstractGeoviewEsriLayerConfig extends AbstractGeoviewLaye
};
// #endregion PRIVATE

// =================
// #region PROTECTED
// ==============
// #region STATIC
/**
* Converts an esri geometry type string to a TypeStyleGeometry.
* @param {string} esriGeometryType - The esri geometry type to convert
* @returns {TypeStyleGeometry} The corresponding TypeStyleGeometry
* @protected @static
* @static
*/
protected static convertEsriGeometryTypeToOLGeometryType(esriGeometryType: string): TypeStyleGeometry {
static convertEsriGeometryTypeToOLGeometryType(esriGeometryType: string): TypeStyleGeometry {
switch (esriGeometryType) {
case 'esriGeometryPoint':
case 'esriGeometryMultipoint':
Expand All @@ -260,7 +260,7 @@ export abstract class AbstractGeoviewEsriLayerConfig extends AbstractGeoviewLaye
throw new Error(`Unsupported geometry type: ${esriGeometryType}`);
}
}
// #endregion PROTECTED
// #endregion STATIC
// #endregion METHODS
// #endregion CLASS HEADER
}
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ export abstract class AbstractGeoviewLayerConfig {
if (layerTreeFilter !== undefined) {
// When the filter is an empty array, we create the layer tree for all the metadata in the service metadata.
if (layerTreeFilter.length === 0) {
this.setMetadataLayerTree(this.processListOfLayerEntryConfig(this.createLayerTreeFromServiceMetadata()));
const layerTree = this.processListOfLayerEntryConfig(this.createLayerTreeFromServiceMetadata());
await this.fetchListOfLayerMetadata(layerTree);
this.setMetadataLayerTree(layerTree);
} else {
// When the filter contains one or many layer identifiers, we create the layer tree using only the specified layers.
// If the filter contains several layer identifiers, we create a group layer, as the root of the tree must contain
Expand Down Expand Up @@ -312,7 +314,7 @@ export abstract class AbstractGeoviewLayerConfig {
/**
* A recursive method to process the listOfLayerEntryConfig. The goal is to process each valid sublayer, searching the service's
* metadata to verify the layer's existence and whether it is a layer group, in order to determine the node's final structure.
* If it is a layer group, it will be created.
* If the metadata indicate the node is a layer group, it will be created by the createLayerEntryNode.
*
* @param {EntryConfigBaseClass[]} listOfLayerEntryConfig the list of sublayers to process.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ export class WmsLayerConfig extends AbstractGeoviewLayerConfig {
const response = await fetch(metadataUrl);
const capabilitiesString = await response.text();
this.setServiceMetadata(parser.read(capabilitiesString));
if (this.getServiceMetadata()) {
// GV: If this.getServiceMetadata() returns {}, we need to verify if the object is empty to conclude there is no metadata.
if (Object.keys(this.getServiceMetadata()).length) {
this.#processMetadataInheritance();
this.metadataAccessPath = this.getServiceMetadata().Capability.Request.GetMap.DCPType[0].HTTP.Get.OnlineResource as string;
} else throw new GeoviewLayerConfigError('Unable to read the metadata, value returned is empty.');
Expand Down
Loading
Loading