Commit f552c80e authored by ncastejon's avatar ncastejon
Browse files

Add featureinfo for WMS - Add Multi* feature for WFS

parent d749479f
......@@ -1361,15 +1361,10 @@
"wgs84": "0.0.0"
}
},
"@mapbox/gl-matrix": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@mapbox/gl-matrix/-/gl-matrix-0.0.1.tgz",
"integrity": "sha1-5RJqq01kw2uBx6l9CuDd3eV3PSs="
},
"@mapbox/jsonlint-lines-primitives": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.1.tgz",
"integrity": "sha512-LGegvJq+ks4UFnEAvtAhygFRZxaNg2vw7PsvLOAXY8ziJLv5aFDSdHDEMJA/Q8PG5dNhMioUvo0kNqb7U5dPoQ=="
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.2.tgz",
"integrity": "sha1-zlblOfg1UrWNENZy6k1vya3HsjQ="
},
"@mapbox/mapbox-gl-supported": {
"version": "1.4.0",
......@@ -1382,9 +1377,9 @@
"integrity": "sha1-ioP5M1x4YO/6Lu7KJUMyqgru2PI="
},
"@mapbox/shelf-pack": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@mapbox/shelf-pack/-/shelf-pack-3.1.0.tgz",
"integrity": "sha1-Ht6pwL9nFbIXFxumBkbCAa9SD2o="
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@mapbox/shelf-pack/-/shelf-pack-3.2.0.tgz",
"integrity": "sha512-dyQxe6ukILV6qaEvxoKCIwhblgRjYp1ZGlClo4xvfbmxzFO5LYu7Tnrg2AZrRgN7VsSragsGcNjzUe9kCdKHYQ=="
},
"@mapbox/tiny-sdf": {
"version": "1.1.0",
......@@ -1405,9 +1400,9 @@
}
},
"@mapbox/whoots-js": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@mapbox/whoots-js/-/whoots-js-3.0.0.tgz",
"integrity": "sha1-wd5CkwgUJNo6wwwjr6hQrxAZu1Q="
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@mapbox/whoots-js/-/whoots-js-3.1.0.tgz",
"integrity": "sha512-Es6WcD0nO5l+2BOQS4uLfNPYQaNDfbot3X1XUoloz+x0mPDS3eeORZJl06HXjwBG1fOGwCRnzK88LMdxKRrd6Q=="
},
"@ngtools/webpack": {
"version": "6.0.8",
......@@ -2199,9 +2194,9 @@
}
},
"@types/geojson": {
"version": "7946.0.3",
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.3.tgz",
"integrity": "sha512-BYHiG1vQJ7T93uswzuXZ0OBPWqj5tsAPtaMDQADV8sn2InllXarwg9llr6uaW22q1QCwBZ81gVajOpYWzjesug=="
"version": "7946.0.4",
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.4.tgz",
"integrity": "sha512-MHmwBtCb7OCv1DSivz2UNJXPGU/1btAWRKlqJ2saEhVJkpkvqHMMaOpKg0v4sAbDWSQekHGvPVMM8nQ+Jen03Q=="
},
"@types/jasmine": {
"version": "2.8.8",
......@@ -2219,9 +2214,9 @@
}
},
"@types/mapbox-gl": {
"version": "0.45.0",
"resolved": "https://registry.npmjs.org/@types/mapbox-gl/-/mapbox-gl-0.45.0.tgz",
"integrity": "sha512-IFfjMrHsN6znvYxz/H122FldpI1LqJhPjP399B+2cjaiCBhzl98dEIIHtDXSZ1KvB7Ghmlqcmd9JkpMOjMebfg==",
"version": "0.47.2",
"resolved": "https://registry.npmjs.org/@types/mapbox-gl/-/mapbox-gl-0.47.2.tgz",
"integrity": "sha512-2RYTLUCPWkyh2RtzA8g7J5zybA12WbnKQnGLa+4Em2E6Sb0F/aQPl03nVxNX9URXu0+4fk+7ReGB8Pj07SPoEw==",
"requires": {
"@types/geojson": "*"
}
......@@ -6299,9 +6294,9 @@
}
},
"geojson-vt": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/geojson-vt/-/geojson-vt-3.1.2.tgz",
"integrity": "sha512-bydur0jq2KfvUzlDtXuY31cfHdIcwnmy0mTOn4b/sjM3cCj5BnJXaM73u5ZHyz93FqubZwMK7k2u1e6vnuEw4Q=="
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/geojson-vt/-/geojson-vt-3.2.0.tgz",
"integrity": "sha512-qk7sEv7dMfuGzflwClsgtO1fWPut/TqCInWEEUJc/Ofn4tmqBGznnPv3eUdxtwMkulMaAwSL3osHiyN03XJd/w=="
},
"get-caller-file": {
"version": "1.0.2",
......@@ -6359,6 +6354,11 @@
}
}
},
"gl-matrix": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/gl-matrix/-/gl-matrix-2.8.1.tgz",
"integrity": "sha512-0YCjVpE3pS5XWlN3J4X7AiAx65+nqAI54LndtVFnQZB6G/FVLkZH8y8V6R3cIoOQR4pUdfwQGd1iwyoXHJ4Qfw=="
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
......@@ -8441,9 +8441,9 @@
}
},
"kdbush": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/kdbush/-/kdbush-1.0.1.tgz",
"integrity": "sha1-PL0D6d6tnA9vZszblkUOXOzGQOA="
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/kdbush/-/kdbush-2.0.1.tgz",
"integrity": "sha512-9KqSdmWCkBIisFIGclT0FRagKhI7IVbMyUjsxCFG0Ly1Dg6whlxJ7b9lrq8ifk3X/fGeJzok1R75LQfZTfA5zQ=="
},
"killable": {
"version": "1.0.0",
......@@ -8988,13 +8988,12 @@
}
},
"mapbox-gl": {
"version": "0.45.0",
"resolved": "https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-0.45.0.tgz",
"integrity": "sha1-r3HMgk8NflHM1cUF6q5BG8CRDM0=",
"version": "0.47.0",
"resolved": "https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-0.47.0.tgz",
"integrity": "sha512-y1AlNYMAKaqEtaqni0zOMYj9gTc1gZ0lqLkxXK9iFg5+ZBITc5DL9AcrXhpEXNxUzXKFa7dZkSULyNaqXFQ8yQ==",
"requires": {
"@mapbox/gl-matrix": "^0.0.1",
"@mapbox/jsonlint-lines-primitives": "^2.0.1",
"@mapbox/mapbox-gl-supported": "^1.3.1",
"@mapbox/mapbox-gl-supported": "^1.4.0",
"@mapbox/point-geometry": "^0.1.0",
"@mapbox/shelf-pack": "^3.1.0",
"@mapbox/tiny-sdf": "^1.1.0",
......@@ -9005,7 +9004,8 @@
"csscolorparser": "~1.0.2",
"earcut": "^2.1.3",
"geojson-rewind": "^0.3.0",
"geojson-vt": "^3.1.0",
"geojson-vt": "^3.1.4",
"gl-matrix": "^2.6.1",
"gray-matter": "^3.0.8",
"grid-index": "^1.0.0",
"minimist": "0.0.8",
......@@ -9014,7 +9014,7 @@
"rw": "^1.3.3",
"shuffle-seed": "^1.1.6",
"sort-object": "^0.3.2",
"supercluster": "^2.3.0",
"supercluster": "^4.0.1",
"through2": "^2.0.3",
"tinyqueue": "^1.1.0",
"vt-pbf": "^3.0.1"
......@@ -10684,9 +10684,9 @@
}
},
"protocol-buffers-schema": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-2.2.0.tgz",
"integrity": "sha1-0pxs1z+2VZePtpiWkRgNuEQRn2E="
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.3.2.tgz",
"integrity": "sha512-Xdayp8sB/mU+sUV4G7ws8xtYMGdQnxbeIfLjyO9TZZRJdztBGhlmbI5x1qcY4TG5hBkIKGnc28i7nXxaugu88w=="
},
"protractor": {
"version": "5.3.2",
......@@ -11461,11 +11461,11 @@
"dev": true
},
"resolve-protobuf-schema": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/resolve-protobuf-schema/-/resolve-protobuf-schema-2.0.0.tgz",
"integrity": "sha1-5nsGKmfwLRG9aIbnDv2niEB+D7Q=",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz",
"integrity": "sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==",
"requires": {
"protocol-buffers-schema": "^2.0.2"
"protocol-buffers-schema": "^3.3.1"
}
},
"resolve-url": {
......@@ -11695,9 +11695,9 @@
}
},
"seedrandom": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.3.tgz",
"integrity": "sha1-JDhQTa0zkXMUv/GKxNeU8W1qrsw="
"version": "2.4.4",
"resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.4.tgz",
"integrity": "sha512-9A+PDmgm+2du77B5i0Ip2cxOqqHjgNxnBgglxLcX78A2D6c2rTo61z4jnVABpF4cKeDMDG+cmXXvdnqse2VqMA=="
},
"select-hose": {
"version": "2.0.0",
......@@ -12760,11 +12760,11 @@
}
},
"supercluster": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/supercluster/-/supercluster-2.3.0.tgz",
"integrity": "sha1-h6tWCBu+qaHXJN9TUe6ejDry9Is=",
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/supercluster/-/supercluster-4.1.1.tgz",
"integrity": "sha512-sF0FfUOPFp96DKzwWFLeQOEqqKu2PpcesxAFeFsknA/q7g7igVVn/p3NI2XHEghNSyDAqunKNKqAbqNO8+7NDQ==",
"requires": {
"kdbush": "^1.0.1"
"kdbush": "^2.0.1"
}
},
"supports-color": {
......
import { IMetadata } from '.';
import { IData } from './data.model';
export interface IElasticsearchHit {
'_id': string;
......@@ -6,6 +7,7 @@ export interface IElasticsearchHit {
'_score': number;
'_source': {
'metadata-fr': IMetadata;
'data-fr': IData;
};
'inner_hits': {
'data': {
......
import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { Metadata, IMetadataLink } from '../../geosource/models';
import { Metadata, IMetadataLink, IElasticsearchResponse } from '../../geosource/models';
import { Notification } from '../../core/models';
import * as mapboxgl from 'mapbox-gl';
import { map } from 'rxjs/operators';
import { map, catchError } from 'rxjs/operators';
import { ElasticsearchService } from '../../geosource/services/elasticsearch.service';
import { NotificationService } from '../../core/services';
import { errors } from '../../../i18n/error-messages/error-messages.fr';
......@@ -25,6 +25,7 @@ export class MapService {
minimap: Minimap;
private _mapSubject = new Subject<any>();
_errorService: any;
constructor(
private _http: HttpClient,
......@@ -82,24 +83,25 @@ export class MapService {
addLayers() {
// Check if the metadata has WFS (vector) data format. If not we use WMS format
const uriWFS = this.metadata.link.find((e) => { return e.protocol === 'OGC:WFS'; });
// const uriWFS = false;
if (uriWFS && this._datasetDetailService.datasetDataNumber < 2500) {
if (uriWFS && this._datasetDetailService.datasetDataNumber < 1000) {
const bounds = this.map.getBounds();
this.getWFSFeatures(
this.metadata,
2500).subscribe((geojson) => {
1000).subscribe((geojson) => {
this.addWFSLayer(geojson);
});
} else if (uriWFS && this._datasetDetailService.datasetDataNumber > 2500 &&
this._datasetDetailService.datasetDataNumber < 100000) {
} else if (uriWFS && this._datasetDetailService.datasetDataNumber > 1000 &&
this._datasetDetailService.datasetDataNumber < 50000) {
const bounds = this.map.getBounds();
this.getWFSFeatures(
this.metadata,
1000, bounds).subscribe((geojson) => {
500, bounds).subscribe((geojson) => {
this.addWFSLayer(geojson);
});
......@@ -222,7 +224,7 @@ export class MapService {
'fill-color': '#ff2d2d',
'fill-opacity': 0.4,
},
filter: ['==', '$type', 'Polygon'],
filter: ['match', ['geometry-type'], ['Polygon', 'MultiPolygon'], true, false],
});
// For 'LineString' feature, one layer is enough (no cluster)
......@@ -239,7 +241,7 @@ export class MapService {
'line-width': 3,
'line-opacity': 0.8,
},
filter: ['==', '$type', 'LineString'],
filter: ['match', ['geometry-type'], ['LineString', 'MultiLineString'], true, false],
});
if (!this.eventPopupAdded) {
......@@ -319,7 +321,19 @@ export class MapService {
const bounds = this.map.getBounds();
const bbox = '' + bounds.getSouthWest().lat + ',' + bounds.getSouthWest().lng
+ ',' + bounds.getNorthEast().lat + ',' + bounds.getNorthEast().lng;
const result = this.getFeatureInfo(uriWMS.name, bbox, e.point.x, e.point.y).subscribe((result) => {
const result = this.getFeatureInfo(e.lngLat.lng, e.lngLat.lat).subscribe((result) => {
if (result) {
let content = '<h4>Informations</h4>';
for (const property in result.properties) {
if (result.properties.hasOwnProperty(property)) {
content += '<b>' + property + '</b>: ' + result.properties[property] + '<br/>';
}
}
new mapboxgl.Popup()
.setLngLat(e.lngLat)
.setHTML(content)
.addTo(this.map);
}
});
});
}
......@@ -398,30 +412,94 @@ export class MapService {
featureCollection.features.push(e._source['data-fr']);
}
});
const newFeatures = [];
featureCollection.features.forEach((feature) => {
if (feature.geometry.type === 'MultiPoint') {
feature.geometry.coordinates.forEach((point) => {
const newFeature = Object.assign(feature);
newFeature.geometry.coordinates = point;
newFeature.geometry.type = 'Point';
newFeatures.push(newFeature);
});
} else {
newFeatures.push(feature);
}
});
featureCollection.features = newFeatures;
return featureCollection as GeoJSON.FeatureCollection;
}));
}
getFeatureInfo(layer, bbox, x, y) {
const url = 'https://download.data.grandlyon.com/wms/grandlyon?request=GetFeatureInfo' +
'&service=WMS' +
'&version=1.1.1' +
'&layers=' + layer +
'&srs=EPSG:3857' +
'&width=780' +
'&height=330' +
'&bbox=' + bbox +
'&query_layers=' + layer +
'&feature_count=1' +
'&x=' + x +
'&y=' + y;
return this._http.get(url).pipe(
map((xml) => {
// const parseString = require('xml2js').parseString;
// return parseString(xml, (err, result) => {
// return result;
// });
}));
getFeatureInfo(lng, lat) {
// CReate specific filter depending on geometry type
let filter = {};
if (this._datasetDetailService.datasetData[0].geometry.type === 'Point'
|| this._datasetDetailService.datasetData[0].geometry.type === 'LineString'
|| this._datasetDetailService.datasetData[0].geometry.type === 'MultiLineString'
|| this._datasetDetailService.datasetData[0].geometry.type === 'MultiPoint') {
filter = {
shape: {
coordinates: [lng, lat],
radius: '10m',
type: 'circle',
},
relation: 'intersects',
};
} else if (this._datasetDetailService.datasetData[0].geometry.type === 'Polygon'
|| this._datasetDetailService.datasetData[0].geometry.type === 'MultiPolygon') {
filter = {
shape: {
coordinates: [lng, lat],
type: 'point',
},
relation: 'contains',
};
}
// Set query string options
const requestOptions = {
body: {
size: 1,
query: {
bool: {
filter: {
bool: {
must: [
{
geo_shape: {
'data-fr.geometry': filter,
},
},
{
term: {
'metadata-fr.geonet:info.uuid.keyword': this.metadata.geonet.uuid,
},
},
],
},
},
},
},
},
};
console.log(JSON.stringify(requestOptions));
const url = environment.elasticsearchUrl.full + '/_search';
return this._http.request<IElasticsearchResponse>('POST', url, requestOptions).pipe(
map((e) => {
console.log(e.hits.hits);
let result = null;
if (e.hits && e.hits.hits) {
result = e.hits.hits[0]._source['data-fr'];
}
return result;
}),
catchError(
(err) => {
throw this._errorService.handleError(err, { message: errors.geosource.getDatasetList });
},
),
);
}
switchLayer(baseLayer) {
......
......@@ -11,7 +11,7 @@ export const environment = {
// ElasticSearch
elasticsearchUrl: {
full: servicesProxyUrl + '/elasticsearch2/test-all-in-one-index.full.v8',
full: servicesProxyUrl + '/elasticsearch2/test-all-in-one-index.full.v8.quadtree',
meta: servicesProxyUrl + '/elasticsearch/*.meta',
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment