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

Share arcgis #587

Merged
merged 4 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion docs/config_json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ Exemples
"composite": [
{
"id": "tq_swtq",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq",
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"regFilters": ["zpegt"],
"groupImpose": {"id": "zpegt", "title": "zpegt"}
},
Expand Down
205 changes: 97 additions & 108 deletions src/app/pages/portal/portal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,15 @@ import {
CapabilitiesService,
sourceCanSearch,
sourceCanReverseSearch,
generateWMSIdFromSourceOptions,
generateWMTSIdFromSourceOptions,
WMSDataSourceOptions,
WMTSDataSourceOptions,
FEATURE,
ImportService,
handleFileImportError,
handleFileImportSuccess,
featureFromOl,
QueryService,
WfsWorkspace,
FeatureWorkspace
FeatureWorkspace,
generateIdFromSourceOptions
} from '@igo2/geo';

import {
Expand All @@ -88,6 +85,7 @@ import { HttpClient } from '@angular/common/http';
import { WelcomeWindowComponent } from './welcome-window/welcome-window.component';
import { WelcomeWindowService } from './welcome-window/welcome-window.service';
import { MatPaginator } from '@angular/material/paginator';
import { ObjectUtils } from '@igo2/utils';

@Component({
selector: 'app-portal',
Expand Down Expand Up @@ -980,72 +978,81 @@ export class PortalComponent implements OnInit, OnDestroy {
}

private readLayersQueryParams(params: Params) {
this.readLayersQueryParamsWMS(params);
this.readLayersQueryParamsWMTS(params);
this.readLayersQueryParamsByType(params, 'wms');
this.readLayersQueryParamsByType(params, 'wmts');
this.readLayersQueryParamsByType(params, 'arcgisrest');
this.readLayersQueryParamsByType(params, 'imagearcgisrest');
this.readLayersQueryParamsByType(params, 'tilearcgisrest');
this.readVectorQueryParams(params);
}

private readLayersQueryParamsWMS(params: Params) {
if ((params['layers'] || params['wmsLayers']) && params['wmsUrl']) {
const nameParamLayers = params['wmsLayers'] ? 'wmsLayers' : 'layers'; // for maintain compatibility
const layersByService = params[nameParamLayers].split('),(');
const urls = params['wmsUrl'].split(',');
let cnt = 0;
urls.forEach((url) => {
const currentLayersByService = this.extractLayersByService(
layersByService[cnt]
);
currentLayersByService.forEach((layer) => {
const layerFromUrl = layer.split(':igoz');
const layerOptions = {
url: url,
params: { LAYERS: layerFromUrl[0] }
};
const id = generateWMSIdFromSourceOptions(
layerOptions as WMSDataSourceOptions
);
const visibility = this.computeLayerVisibilityFromUrl(params, id);
this.addWmsLayerByName(
url,
layerFromUrl[0],
visibility,
parseInt(layerFromUrl[1] || 1000, 10)
);
});
cnt += 1;
});
private readLayersQueryParamsByType(params: Params, type) {
let nameParamLayersKey;
let urlsKey;
switch (type) {
case 'wms':
if ((params['layers'] || params['wmsLayers']) && params['wmsUrl']) {
urlsKey = 'wmsUrl';
nameParamLayersKey = params['wmsLayers'] ? 'wmsLayers' : 'layers'; // for maintain compatibility
}
break;
case 'wmts':
if (params['wmtsLayers'] && params['wmtsUrl']) {
urlsKey = 'wmtsUrl';
nameParamLayersKey = 'wmtsLayers';
}
break;
case 'arcgisrest':
if (params['arcgisLayers'] && params['arcgisUrl']) {
urlsKey = 'arcgisUrl';
nameParamLayersKey = 'arcgisLayers';
}
break;
case 'imagearcgisrest':
if (params['iarcgisLayers'] && params['iarcgisUrl']) {
urlsKey = 'iarcgisUrl';
nameParamLayersKey = 'iarcgisLayers';
}
break;
case 'tilearcgisrest':
if (params['tarcgisLayers'] && params['tarcgisUrl']) {
urlsKey = 'tarcgisUrl';
nameParamLayersKey = 'tarcgisLayers';
}
break;
}
}

private readLayersQueryParamsWMTS(params: Params) {
if (params['wmtsLayers'] && params['wmtsUrl']) {
const layersByService = params['wmtsLayers'].split('),(');
const urls = params['wmtsUrl'].split(',');
let cnt = 0;
urls.forEach((url) => {
const currentLayersByService = this.extractLayersByService(
layersByService[cnt]
);
currentLayersByService.forEach((layer) => {
const layerFromUrl = layer.split(':igoz');
const layerOptions = {
url: url,
layer: layerFromUrl[0]
};
const id = generateWMTSIdFromSourceOptions(
layerOptions as WMTSDataSourceOptions
);
const visibility = this.computeLayerVisibilityFromUrl(params, id);
this.addWmtsLayerByName(
url,
layerFromUrl[0],
visibility,
parseInt(layerFromUrl[1] || 1000, 10)
);
if (!nameParamLayersKey || !urlsKey) {
return;
}
const layersByService = params[nameParamLayersKey].split('),(');
const urls = params[urlsKey].split(',');
console.log(urls, layersByService);

let cnt = 0;
urls.forEach((url) => {
const currentLayersByService = this.extractLayersByService(
layersByService[cnt]
);
currentLayersByService.forEach((layer) => {
const layerFromUrl = layer.split(':igoz');
const layerOptions = ObjectUtils.removeUndefined({
type,
url: url,
layer: layerFromUrl[0],
params: type === 'wms' ? { LAYERS: layerFromUrl[0] } : undefined
});
cnt += 1;
const id = generateIdFromSourceOptions(layerOptions);
const visibility = this.computeLayerVisibilityFromUrl(params, id);
this.addLayerFromURL(
url,
layerFromUrl[0],
type,
visibility,
parseInt(layerFromUrl[1] || 1000, 10)
);
});
}
cnt += 1;
});
}

private readVectorQueryParams(params: Params) {
Expand Down Expand Up @@ -1096,61 +1103,43 @@ export class PortalComponent implements OnInit, OnDestroy {
: outLayersByService;
return outLayersByService.split(',');
}

private addWmsLayerByName(
private addLayerFromURL(
url: string,
name: string,
type: 'wms' | 'wmts' | 'arcgisrest'| 'imagearcgisrest' | 'tilearcgisrest',
visibility: boolean = true,
zIndex: number = 100000
) {
if (!this.contextLoaded) {
return;
}
this.addedLayers$$.push(
this.layerService
.createAsyncLayer({
zIndex: zIndex,
visible: visibility,
sourceOptions: {
optionsFromCapabilities: true,
optionsFromApi: true,
type: 'wms',
url: url,
params: {
layers: name
}
}
})
.subscribe((l) => {
this.map.addLayer(l);
})
);
}

private addWmtsLayerByName(
url: string,
name: string,
visibility: boolean = true,
zIndex: number = 100000
) {
if (!this.contextLoaded) {
return;
const commonSourceOptions = {
optionsFromCapabilities: true,
optionsFromApi: true,
crossOrigin: true,
type,
url
};
const arcgisClause = (type === 'arcgisrest' || type === 'imagearcgisrest' || type === 'tilearcgisrest');
let sourceOptions = {
version: type === 'wmts' ? '1.0.0' : undefined,
queryable: arcgisClause ? true : false,
queryFormat: arcgisClause ? 'esrijson' : undefined,
layer: name
};
if (type === 'wms') {
sourceOptions = { params: {LAYERS: name}} as any;
}

sourceOptions = ObjectUtils.removeUndefined(Object.assign({}, sourceOptions, commonSourceOptions));

this.addedLayers$$.push(
this.layerService
.createAsyncLayer({
zIndex: zIndex,
visible: visibility,
sourceOptions: {
optionsFromCapabilities: true,
type: 'wmts',
url: url,
crossOrigin: true,
// matrixSet: 'GoogleMapsCompatibleExt2:epsg:3857',
version: '1.0.0',
layer: name
}
} as any)
sourceOptions
})
.subscribe((l) => {
this.map.addLayer(l);
})
Expand Down Expand Up @@ -1189,10 +1178,10 @@ export class PortalComponent implements OnInit, OnDestroy {
// After, managing named layer by id (context.json OR id from datasource)
visiblelayers = visibleOnLayersParams.split(',');
invisiblelayers = visibleOffLayersParams.split(',');
if (visiblelayers.indexOf(currentLayerid) > -1) {
if (visiblelayers.indexOf(currentLayerid) > -1 || visiblelayers.indexOf(currentLayerid.toString()) > -1) {
visible = true;
}
if (invisiblelayers.indexOf(currentLayerid) > -1) {
if (invisiblelayers.indexOf(currentLayerid) > -1 || invisiblelayers.indexOf(currentLayerid.toString()) > -1) {
visible = false;
}
return visible;
Expand Down
10 changes: 5 additions & 5 deletions src/contexts/layerSync.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
"sourceOptions": {
"queryable": true,
"type": "wms",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq",
"urlWfs": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq",
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"urlWfs": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"params": {
"layers": "radars_photos"
},
Expand Down Expand Up @@ -99,8 +99,8 @@
"sourceOptions": {
"queryable": true,
"type": "wms",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq",
"urlWfs": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq",
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"urlWfs": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"params": {
"layers": "radars_photos"
},
Expand Down Expand Up @@ -239,7 +239,7 @@
"version": "2.0.0"
},
"type": "wfs",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq"
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq"
}
}
],
Expand Down
4 changes: 2 additions & 2 deletions src/contexts/ogcFilters.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"title": "Filterable WMS layers with predefined filters (buttons)",
"sourceOptions": {
"type": "wms",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq",
"urlWfs": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq",
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"urlWfs": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"queryable": true,
"params": {
"layers": "radars_photos"
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/testExport.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": "2.0.0"
},
"type": "wfs",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq"
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq"
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/contexts/variousFormats.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"queryable": true,
"queryTitle": "nomcartrou",
"type": "mvt",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq?mode=tile&tilemode=gmap&tile={x}+{y}+{z}&layers=lieuhabite&map.imagetype=mvt"
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq?mode=tile&tilemode=gmap&tile={x}+{y}+{z}&layers=lieuhabite&map.imagetype=mvt"
}
},
{
Expand Down Expand Up @@ -62,7 +62,7 @@
"sourceOptions": {
"queryable": true,
"queryTitle": "identificationDesTravaux",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq?service=WFS&request=GetFeature&version=1.1.0&typename=chantiers_mtmdet&outputFormat=geojson",
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq?service=WFS&request=GetFeature&version=1.1.0&typename=chantiers_mtmdet&outputFormat=geojson",
"type": "cluster",
"distance": 50
}
Expand Down Expand Up @@ -113,7 +113,7 @@
"id": "vector2",
"sourceOptions": {
"type": "vector",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq?service=WFS&request=GetFeature&version=1.1.0&typename=aeroport_piste&outputFormat=geojson",
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq?service=WFS&request=GetFeature&version=1.1.0&typename=aeroport_piste&outputFormat=geojson",
"queryable": true,
"queryFormat": "geojson",
"queryTitle": "desclocal"
Expand Down
10 changes: 5 additions & 5 deletions src/contexts/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"queryable": true,
"queryTitle": "nometablis",
"type": "wms",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq",
"urlWfs": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq",
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"urlWfs": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"params": {
"layers": "etablissement_mtq"
},
Expand All @@ -40,7 +40,7 @@
"sourceOptions": {
"queryable": true,
"queryTitle": "nomnavcana",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq?service=WFS&request=GetFeature&version=1.1.0&typename=aeroport_piste&outputFormat=geojson",
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq?service=WFS&request=GetFeature&version=1.1.0&typename=aeroport_piste&outputFormat=geojson",
"type": "vector"
}
},
Expand All @@ -50,7 +50,7 @@
"sourceOptions": {
"queryable": true,
"queryTitle": "identificationDesTravaux",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq?service=WFS&request=GetFeature&version=1.1.0&typename=chantiers_mtmdet&outputFormat=geojson",
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq?service=WFS&request=GetFeature&version=1.1.0&typename=chantiers_mtmdet&outputFormat=geojson",
"type": "cluster",
"distance": 50
}
Expand All @@ -60,7 +60,7 @@
"visible": true,
"sourceOptions": {
"type": "wfs",
"url": "https://geoegl.msp.gouv.qc.ca/apis/ws/swtq",
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"queryable": true,
"queryTitle": "desclocal",
"params": {
Expand Down
Loading