Skip to content

Commit

Permalink
feat(demo): new page for OSDP integration
Browse files Browse the repository at this point in the history
Closes #2675
Closes #2676

Also fixes rendering issue with multiple style types
  • Loading branch information
DamonU2 committed Jan 8, 2025
1 parent fe3c72f commit f6bf918
Show file tree
Hide file tree
Showing 7 changed files with 369 additions and 139 deletions.
267 changes: 138 additions & 129 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
"labeled": true
},
"listOfGeoviewLayerConfig": [
{
"geoviewLayerId": "472ef86d-7f7c-423b-a7d2-b6f92b79fd6d",
"geoviewLayerType": "geoCore"
},
{
"geoviewLayerId": "historical-flood",
"geoviewLayerName": "Historical Flood Events (HFE)",
Expand Down Expand Up @@ -85,7 +81,7 @@
],
"opacity": 1,
"rotation": 0,
"src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAcdJREFUKJFjYSATsCBz/v//z/Tt++fwZ6/v2X359lGckZHxHx+34BNJMZVdnOyc27Bq/P//v8iDZzcm7Tg+yev915v8yIokhMzCn768v1FKTKGYkZHxK1zj////me8+vjx99YHikP///2I468W7UxJLd11NjXTtZ2FgYEiBa3zz4WnaluO9/tg0wcCff1+Zdp+aFfLpy/stfDyCG1gYGBgYnry46/Xtx2NWZIW6CmEMP39/Y7j1dAvC5vdn+J+8uh3EwMAA0fjl+0cVZE1mGqkMzmYRDAwMDAxr9zKgaP785Z0Skh//siNrZGPhgLPZWblRnPz3/z92uEZ2Ns6XDAwMijDJo9dmMTAyMjH8/vOD4fKDlSgaOdm5X8M1CvJKnGBl4bf4/ecjAwMDA8P/fz8ZDl+eiBFAAtyqDIK84gfgGiWElKrs9TJ99pzrUMFQDQWMjMwMNnpx5+Sl1HvgGvn4+L7ffnA50tmwbO3hK7Plfv1+j6KJi0OawV4v+bogr2ggIyPjP7hGBgYGBlUF3TNX7x3QczMtnvTh82vb37+/STEwMv7jYOV+KMArtusbN1OJrKTab5h6lLSqreTwkYGBIR6Xc5EBAG+8pa3DWR79AAAAAElFTkSuQmCC",
"src": "iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABw0lEQVQ4jWNhoBJgGRoG/f//n+nry8fhzy4ft/v2/pU4IxPDPx5RmSfSBva7OPiFthFl0P///0UeHNk86fSCFq/vH97wI8vxSsiFPzl3cKO0oV0xIyPjV5wG/f//n/nOgXXTj00tC2H4/x/D1s8vHkns70hNdSidxsLAwJCC06BXN8+mnZnX5I/NEBj49/cP06l5LSGfnt3ZwielsgGrQc8vHfX69e0zK7KYlL4tw5+f3xhe3TgLF/vy6hH/k7NHgxgYGLAb9P39GxVkvqKNL4NtwQQGBgYGhh01YSiGfX37RAmn1/7//cuOIsnBjZUN9SKqWmQOGzfvSwYGBkUY/86+1QyMTEwMf35+Z3h24RCKQRy8gq9xGsQvpXiCmZXd4u/vnxAX/vvLcGvXMgZ0wMEvzMAnrXIAp0EqGtZVn7zjfa5smIUSViiAkZFByyf5nIKVZw9OgxhlZb/f3bUmUss3ee3NnUvl/v76gWIGGxcvg5ZP0nUuOelARkbGfzgNYmBgYFB2CzlzZtVMPYPwgkmfXz60/fP9mxQDI8M/Vi6+h7wS8ru+S/4uUTbx/Y2uD2teMwlL/8jAwBCP03tYwOArRgCKzaW6FXcnxAAAAABJRU5ErkJggg==",
"type": "iconSymbol"
}
},
Expand Down Expand Up @@ -249,6 +245,26 @@
"type": "iconSymbol"
}
},
{
"visible": false,
"label": "Regulated, Yearly, Low",
"values": [
"Regulated",
"Yearly",
"Low"
],
"settings": {
"mimeType": "image/png",
"offset": [
0,
0
],
"opacity": 1,
"rotation": 0,
"src": "iVBORw0KGgoAAAANSUhEUgAAABQAAAATCAYAAACQjC21AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABTklEQVQ4jWNhoDJgGTADV4Vq84StvvqFKgYuDFYx/P7vWz0DA0MAVQxkZPjb95+B0WFBkKJdwrr7hygycHGwcsA/hv8OEIMZuxkYGMzJNnBmmjHrv7fvu5CcarYoRDE0bs391WQZyP72fQ4DA4Mqstj//4xtM9OMN6TPOvubJAPnhMoIMf5jqMUipcLx9l06AwPDFJIMZP3P2sDAwCCIXZaxbq6f+sLkTTc/E2Xg4lBF9X//GDNwWcbAwCDKzPqnnIGBoYYoA//9Y+xhYGBgxWMgAyPD/8LFQfJTY9c9fI7XwAUhSs4M/xl88BkGBVz/GFiaGBgYUnEa2NDAwMR4maGXCMOgzvyfuChQvi9u/cPrWA1UvKKYxMDAoE+0gQwMzP+YmDsZGBj8MAxcFarN8/3f92YSDIM4koHBFzlLwg2EliSSpBqIDgauPCQWAAAl/F2MVoc3hAAAAABJRU5ErkJggg==",
"type": "iconSymbol"
}
},
{
"visible": true,
"label": "Regulated, Yearly, Normal",
Expand Down Expand Up @@ -293,6 +309,10 @@
"layerFilter": "Total_CSO_Volume > 5000000"
}
]
},
{
"geoviewLayerId": "472ef86d-7f7c-423b-a7d2-b6f92b79fd6d",
"geoviewLayerType": "geoCore"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion packages/geoview-core/public/templates/config-sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ <h4 id="HLCONF1">Sanbox Map</h4>
<script>
// Utility functions ========================================================================================================

// Tab selection function. This function is called when you clickmon a tab to select and display its content.
// Tab selection function. This function is called when you click on a tab to select and display its content.
function openTab(evt, tabName) {
var i, tabContent, tabLinks;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>OSDP Integration - Canadian Geospatial Platform Viewer</title>
<link rel="shortcut icon" href="./favicon.ico" />
<meta name="msapplication-TileColor" content="#da532c" />
<meta name="msapplication-config" content="./img/browserconfig.xml" />
<meta name="theme-color" content="#ffffff" />
<meta name="msapplication-TileColor" content="#da532c" />
<meta name="theme-color" content="#ffffff" />
<link href="https://fonts.googleapis.com/css?family=Roboto|Montserrat:200,300,400,900|Merriweather" rel="stylesheet" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel="stylesheet" href="css/style.css" />
</head>

<body>
<div class="header-table">
<table>
<tbody>
<tr>
<td><img class="header-logo" alt="logo" src="./img/Logo.png" /></td>
<td class="header-title">
<h1><strong>OSDP Integration</strong></h1>
</td>
</tr>
<tr>
<td><a href="./demos.html">Main</a><br /></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td><p>Demonstration of Open Science Data Portal Integration</p></td>
</tr>
</tbody>
</table>
</div>

<div class="map-title-holder">
<h4 id="HMap1">OSDP Integration</h4>
</div>


<div id="mapSection">
<div
id="Map1"
class="geoview-map"
data-lang="en"
data-config-url="./configs/OSDP/osdp-empty.json"
></div>
</div>

<div>
<p>"Delete map div" will delete the div containing the map (if it exists). "Create map div" will create a div for the map (if it does not exist).
"Refresh map" will recreate the map (creating the div if it does not exist) according to the most recent config. "Update State" will update the config to the current map state.</p>
<button id="deleteMap" style="margin: 10px">Delete map div</button>
<button id="createMap" style="margin: 10px">Create map div</button>
<button id="refreshMap" style="margin: 10px">Refresh map</button>
<button id="updateState" style="margin: 10px">Update State</button>
</div>

<div class="selector">
<textarea id="layerUuids" cols="40" rows="5" placeholder="Enter UUIDs"></textarea>
<br>
<button id="addLayers" style="margin: 10px">Add Layers</button>
</div>

<script src="codedoc.js"></script>
<script>
// Empty map config
let mapConfig = {
"map": {
"interaction": "dynamic",
"viewSettings": {
"projection": 3857
},
"basemapOptions": {
"basemapId": "transport",
"shaded": false,
"labeled": true
},
"listOfGeoviewLayerConfig": []
},
"components": ["overview-map"],
"navBar": ["zoom", "fullscreen", "home", "location", "basemap-select"],
"appBar": {
"tabs": {
"core": ["geolocator", "export"]
}
},
"footerBar": {
"tabs": {
"core": ["legend", "layers", "details", "data-table", "time-slider", "geochart"]
}
},
"corePackages": [],
"theme": "geo.ca"
};

function createMapDiv() {
if (!document.getElementById('Map1')) {
const newDiv = document.createElement('div');
const id = document.createAttribute('id');
id.value = 'Map1';
newDiv.setAttributeNode(id);
document.getElementById('mapSection').appendChild(newDiv);
}
}

/** OSDP function
* Removes a map if it exists.
*
* @param map The map id.
* @returns Promise<void>
*/
function removeMap(map) {
return new Promise(resolve => {
if (this.cgpv.api.maps[map]) {
this.isRemoving = true;
this.cgpv.api.maps[map].remove(false)
.then(() => {
this.isRemoving = false;
resolve();
});
} else {
resolve();
}
});
}

/** OSDP function
* Adds layers to the map.
*
* @param layers Array of layers.
*/
function addLayers(layers) {
layers.forEach((layer) => {
this.cgpv.api.maps.Map1.layer.addGeoviewLayerByGeoCoreUUID(layer);
});
}

// Delete Button============================================================================================================
const deleteMapButton = document.getElementById('deleteMap');

// add an event listener when a button is clicked
deleteMapButton.addEventListener('click', function () {
// Delete map div
document.getElementById('Map1').remove();
});

// Create Button============================================================================================================
const createMapButton = document.getElementById('createMap');

// add an event listener when a button is clicked
createMapButton.addEventListener('click', createMapDiv);

// Refresh Button============================================================================================================
const refreshMapButton = document.getElementById('refreshMap');

// add an event listener when a button is clicked
refreshMapButton.addEventListener('click', function () {
createMapDiv();
return new Promise (resolve => {
removeMap('Map1')
.then(() => {
cgpv.api.createMapFromConfig('Map1', JSON.stringify(mapConfig), 800)
.then(() => {
resolve();
});
});
});
});

// Update Button============================================================================================================
const updateMapButton = document.getElementById('updateState');

// add an event listener when a button is clicked
updateMapButton.addEventListener('click', function () {
mapConfig = cgpv.api.maps.Map1.createMapConfigFromMapState();
});

// Add Layers Button============================================================================================================
const addLayersButton = document.getElementById('addLayers');

// add an event listener when a button is clicked
addLayersButton.addEventListener('click', function () {
let layerUuids = document.getElementById('layerUuids').value;
if (layerUuids.length = 1 && !layerUuids[0]) layerUuids = 'ccc75c12-5acc-4a6a-959f-ef6f621147b9';
const uuidList = layerUuids.split('\n').join(',').split(',');
if (document.getElementById('Map1')) addLayers(uuidList);
});

// initialize cgpv and api events, a callback is optional, used if calling api's after the rendering is ready
cgpv.init();
</script>
</body>
</html>
1 change: 1 addition & 0 deletions packages/geoview-core/public/templates/demos/demos.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ <h2 class="index-header-title"><strong>Canadian Geospatial Platform (CGP) - GeoV
<h4>Canada's Spatial Data Infrastructure</h4>
<a href="./demo-cgdi.html">Water Starter Kit</a>
<h4>Open Science Data Portal</h4>
<a href="./demo-osdp-integration.html">Geoview Integration</a><br />
<a href="./demo-osdp-air.html">Air Quality</a><br />
<a href="./demo-osdp-biodiversity.html">Biodiversity</a><br />
<a href="./demo-osdp-climate.html">Climate</a><br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class AllFeatureInfoLayerSet extends AbstractLayerSet {
* @param {QueryType} queryType - The query's type to perform
* @returns {Promise<TypeAllFeatureInfoResultSet | void>} A promise which will hold the result of the query
*/
// TODO: (futur development) The queryType is a door opened to allow the triggering using a bounding box or a polygon.
// TODO: (future development) The queryType is a door opened to allow the triggering using a bounding box or a polygon.
async queryLayer(layerPath: string, queryType: QueryType = 'all'): Promise<TypeAllFeatureInfoResultSet | void> {
// FIXME: Watch out for code reentrancy between queries!
// FIX.MECONT: Consider using a LIFO pattern, per layer path, as the race condition resolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1584,9 +1584,9 @@ export async function getFeatureCanvas(
if (featureStyle) {
if (geometryType === 'Point') {
if (
(styleSettings.type === 'simple' && styleSettings.info[0].settings.type === 'simpleSymbol') ||
(styleSettings.type === 'uniqueValue' && styleSettings.info[0].settings.type === 'simpleSymbol') ||
(styleSettings.type === 'classBreaks' && isSimpleSymbolVectorConfig(styleSettings.info[0].settings))
(styleSettings.type === 'simple' && !(featureStyle.getImage() instanceof Icon)) ||
(styleSettings.type === 'uniqueValue' && !(featureStyle.getImage() instanceof Icon)) ||
(styleSettings.type === 'classBreaks' && !(featureStyle.getImage() instanceof Icon))
) {
canvas = createPointCanvas(featureStyle);
} else {
Expand Down

0 comments on commit f6bf918

Please sign in to comment.