Skip to content

Commit

Permalink
Merge pull request #4175 from 3liz/backport-4150-to-release_3_7
Browse files Browse the repository at this point in the history
[Backport release_3_7] [Feature] Add QMS Bing Maps
  • Loading branch information
Gustry authored Feb 7, 2024
2 parents d55b03f + d336dc4 commit cdf7f72
Show file tree
Hide file tree
Showing 7 changed files with 1,548 additions and 2 deletions.
44 changes: 42 additions & 2 deletions assets/src/modules/config/BaseLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,29 @@ const defaultCompleteBaseLayersCfg = {

};

/**
* The QuickMapServices external layers object configuration
* It will be used to define base layers config based on the type of external layer
* @constant
* @type {object}
* @see https://plugins.qgis.org/plugins/quick_map_services/
* @private
*/
const QMSExternalLayer = {
"qms-bing-roads": {
"type": "bing",
"title": "Bing Streets",
"imagerySet": "RoadOnDemand",
"key": "",
},
"qms-bing-satellite": {
"type": "bing",
"title": "Bing Satellite",
"imagerySet": "Aerial",
"key": "",
},
}

/**
* Class representing a base layers config
* @class
Expand Down Expand Up @@ -787,8 +810,25 @@ export class BaseLayersConfig {
} else if ( layerTreeItem.layerConfig.externalWmsToggle ){
// The layer config has external access parameters
if (layerTreeItem.layerConfig.externalAccess.hasOwnProperty('type')) {
// layer could be converted to XYZ or WMTS background layers
extendedCfg[layerTreeItem.name] = structuredClone(layerTreeItem.layerConfig.externalAccess);
// search for QuickMapSevice plugin layers.
// The layers identification is based on the url property of the externalAccess object
const externalUrl = layerTreeItem.layerConfig.externalAccess.url;
if (externalUrl && externalUrl.includes('virtualearth.net') && options["bingKey"]) {
// Bing maps
// detect if the url is for roads or satellite
if (externalUrl.includes('dynamic')) {
// roads
extendedCfg[layerTreeItem.name] = structuredClone(QMSExternalLayer["qms-bing-roads"])
} else {
// fallback on satellite map
extendedCfg[layerTreeItem.name] = structuredClone(QMSExternalLayer["qms-bing-satellite"])
}
// add the apikey to the configuration
Object.assign(extendedCfg[layerTreeItem.name],{key:options["bingKey"]})
} else {
// layer could be converted to XYZ or WMTS background layers
extendedCfg[layerTreeItem.name] = structuredClone(layerTreeItem.layerConfig.externalAccess);
}
} else {
extendedCfg[layerTreeItem.name] = Object.assign(
structuredClone(layerTreeItem.layerConfig.externalAccess),
Expand Down
27 changes: 27 additions & 0 deletions tests/end2end/playwright/bing-basemap.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test, expect } from '@playwright/test';

test.describe('Bing Maps baselayers', () => {
test('Check Bing external services initialization', async ({ page }) => {
const url = '/index.php/view/map/?repository=testsrepository&project=bing_basemap';
let bingRoadsInitRequestPromise = page.waitForRequest(/RoadOnDemand/);
let bingSatelliteInitRequestPromise = page.waitForRequest(/Aerial/);
await page.goto(url);

const allResponses = await Promise.all([bingRoadsInitRequestPromise,bingSatelliteInitRequestPromise])

let getBingRoadsInitRequest = allResponses[0];
let getBingSatelliteInitRequest = allResponses[1];

let getBingRoadsInitResponse = await getBingRoadsInitRequest.response();
let getBingRoadsInitResponseJson = await getBingRoadsInitResponse?.json();

expect((getBingRoadsInitResponseJson.statusCode)).toBe(200);
expect((getBingRoadsInitResponseJson.authenticationResultCode)).toBe("ValidCredentials");

let getBingsatelliteInitResponse = await getBingSatelliteInitRequest.response();
let getBingsatelliteInitResponseJson = await getBingsatelliteInitResponse?.json();

expect((getBingsatelliteInitResponseJson.statusCode)).toBe(200);
expect((getBingsatelliteInitResponseJson.authenticationResultCode)).toBe("ValidCredentials");
})
})
304 changes: 304 additions & 0 deletions tests/js-units/data/bing_basemap-capabilities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,304 @@
{
"version": "1.3.0",
"Service": {
"Name": "WMS",
"Title": "bing_basemap",
"KeywordList": [
"infoMapAccessService"
],
"OnlineResource": "http://localhost:8130/index.php/lizmap/service?repository=testsrepository&project=bing_basemap",
"Fees": "conditions unknown",
"AccessConstraints": "None",
"MaxWidth": 3000,
"MaxHeight": 3000
},
"Capability": {
"Request": {
"GetCapabilities": {
"Format": [
"text/xml"
],
"DCPType": [
{
"HTTP": {
"Get": {
"OnlineResource": "http://localhost:8130/index.php/lizmap/service?repository=testsrepository&project=bing_basemap&"
}
}
}
]
},
"GetMap": {
"Format": [
"image/jpeg",
"image/png",
"image/png; mode=16bit",
"image/png; mode=8bit",
"image/png; mode=1bit",
"application/dxf"
],
"DCPType": [
{
"HTTP": {
"Get": {
"OnlineResource": "http://localhost:8130/index.php/lizmap/service?repository=testsrepository&project=bing_basemap&"
}
}
}
]
},
"GetFeatureInfo": {
"Format": [
"text/plain",
"text/html",
"text/xml",
"application/vnd.ogc.gml",
"application/vnd.ogc.gml/3.1.1",
"application/json",
"application/geo+json"
],
"DCPType": [
{
"HTTP": {
"Get": {
"OnlineResource": "http://localhost:8130/index.php/lizmap/service?repository=testsrepository&project=bing_basemap&"
}
}
}
]
}
},
"Exception": [
"XML"
],
"Layer": {
"Name": "bing_basemap",
"Title": "bing_basemap",
"KeywordList": [
"infoMapAccessService"
],
"CRS": [
"CRS:84",
"EPSG:3857",
"EPSG:4326"
],
"EX_GeographicBoundingBox": [
3.579083,
43.486976,
4.19827,
43.754206
],
"BoundingBox": [
{
"crs": "EPSG:4326",
"extent": [
43.486976,
3.579083,
43.754206,
4.19827
],
"res": [
null,
null
]
},
{
"crs": "EPSG:3857",
"extent": [
398421.768,
5386390.876,
467349.175,
5427483.423
],
"res": [
null,
null
]
}
],
"Layer": [
{
"Name": "baselayers",
"Title": "baselayers",
"CRS": [
"CRS:84",
"EPSG:3857",
"EPSG:4326",
"CRS:84",
"EPSG:3857",
"EPSG:4326"
],
"EX_GeographicBoundingBox": [
-180,
-85.051129,
180,
85.05113
],
"BoundingBox": [
{
"crs": "EPSG:4326",
"extent": [
-85.051129,
-180,
85.05113,
180
],
"res": [
null,
null
]
},
{
"crs": "EPSG:3857",
"extent": [
-20037508.343,
-20037508.627,
20037508.343,
20037508.627
],
"res": [
null,
null
]
}
],
"Layer": [
{
"Name": "bing_roads",
"Title": "bing roads",
"CRS": [
"CRS:84",
"EPSG:3857",
"EPSG:4326",
"CRS:84",
"EPSG:3857",
"EPSG:4326"
],
"EX_GeographicBoundingBox": [
-180,
-85.051129,
180,
85.051129
],
"BoundingBox": [
{
"crs": "EPSG:4326",
"extent": [
-85.051129,
-180,
85.051129,
180
],
"res": [
null,
null
]
},
{
"crs": "EPSG:3857",
"extent": [
-20037508.343,
-20037508.343,
20037508.343,
20037508.343
],
"res": [
null,
null
]
}
],
"Style": [
{
"Name": "default",
"Title": "default",
"LegendURL": [
{
"Format": "image/png",
"OnlineResource": "http://localhost:8130/index.php/lizmap/service?repository=testsrepository&project=bing_basemap&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&LAYER=bing_roads&FORMAT=image/png&STYLE=default&SLD_VERSION=1.1.0",
"size": [
null,
null
]
}
]
}
],
"queryable": true,
"opaque": false,
"noSubsets": false
},
{
"Name": "bing_aerial",
"Title": "bing aerial",
"CRS": [
"CRS:84",
"EPSG:3857",
"EPSG:4326",
"CRS:84",
"EPSG:3857",
"EPSG:4326"
],
"EX_GeographicBoundingBox": [
-180,
-85.051129,
180,
85.051129
],
"BoundingBox": [
{
"crs": "EPSG:4326",
"extent": [
-85.051129,
-180,
85.051129,
180
],
"res": [
null,
null
]
},
{
"crs": "EPSG:3857",
"extent": [
-20037508.343,
-20037508.343,
20037508.343,
20037508.343
],
"res": [
null,
null
]
}
],
"Style": [
{
"Name": "default",
"Title": "default",
"LegendURL": [
{
"Format": "image/png",
"OnlineResource": "http://localhost:8130/index.php/lizmap/service?repository=testsrepository&project=bing_basemap&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&LAYER=bing_aerial&FORMAT=image/png&STYLE=default&SLD_VERSION=1.1.0",
"size": [
null,
null
]
}
]
}
],
"queryable": true,
"opaque": false,
"noSubsets": false
}
],
"queryable": true,
"opaque": false,
"noSubsets": false
}
]
}
}
}
Loading

0 comments on commit cdf7f72

Please sign in to comment.