-
diff --git a/projects/geo/src/lib/map/shared/map.ts b/projects/geo/src/lib/map/shared/map.ts
index cbd583677c..3b0ac12727 100644
--- a/projects/geo/src/lib/map/shared/map.ts
+++ b/projects/geo/src/lib/map/shared/map.ts
@@ -115,25 +115,7 @@ export class IgoMap {
this.overlayMarkerStyle = this.setOverlayMarkerStyle();
this.overlayDataSource = new FeatureDataSource();
-
- const stroke = new olstyle.Stroke({
- color: [0, 161, 222, 1],
- width: 2
- });
-
- const fill = new olstyle.Fill({
- color: [0, 161, 222, 0.15]
- });
-
- this.overlayStyle = new olstyle.Style({
- stroke: stroke,
- fill: fill,
- image: new olstyle.Circle({
- radius: 5,
- stroke: stroke,
- fill: fill
- })
- });
+ this.overlayStyle = this.setOverlayDataSourceStyle();
const layer = new VectorLayer({
title: 'Overlay',
@@ -352,6 +334,12 @@ export class IgoMap {
this.overlayDataSource.ol.addFeature(feature);
}
+ getOverlayByID(id): olFeature {
+ if (this.overlayDataSource.ol.getFeatureById(id)) {
+ return this.overlayDataSource.ol.getFeatureById(id);
+ }
+ return;
+ }
removeOverlayByID(id) {
if (this.overlayDataSource.ol.getFeatureById(id)) {
@@ -455,6 +443,38 @@ export class IgoMap {
return listLegend;
}
+ setOverlayDataSourceStyle(
+ strokeRGBA: [number, number, number, number] = [0, 161, 222, 1],
+ strokeWidth: number = 2,
+ fillRGBA: [number, number, number, number] = [0, 161, 222, 0.15],
+ text?
+ ): olstyle.Style {
+ const stroke = new olstyle.Stroke({
+ color: strokeRGBA,
+ width: strokeWidth
+ });
+
+ const fill = new olstyle.Fill({
+ color: fillRGBA
+ });
+
+ return new olstyle.Style({
+ stroke: stroke,
+ fill: fill,
+ image: new olstyle.Circle({
+ radius: 5,
+ stroke: stroke,
+ fill: fill
+ }),
+ text: new olstyle.Text({
+ font: '12px Calibri,sans-serif',
+ text: text,
+ fill: new olstyle.Fill({ color: '#000' }),
+ stroke: new olstyle.Stroke({ color: '#fff', width: 3 })
+ })
+ });
+ }
+
setOverlayMarkerStyle(color = 'blue', text?): olstyle.Style {
let iconColor;
switch (color) {
diff --git a/projects/geo/src/lib/wkt/shared/wkt.service.ts b/projects/geo/src/lib/wkt/shared/wkt.service.ts
index b04423f78b..2d1985a61a 100644
--- a/projects/geo/src/lib/wkt/shared/wkt.service.ts
+++ b/projects/geo/src/lib/wkt/shared/wkt.service.ts
@@ -2,25 +2,44 @@ import { Injectable } from '@angular/core';
import * as olproj from 'ol/proj';
import olWKT from 'ol/format/WKT';
-import olPolygon from 'ol/geom/Polygon';
-
-import { MapService } from '../../map/shared/map.service';
@Injectable({
providedIn: 'root'
})
export class WktService {
- constructor(private mapService: MapService) {}
-
- public mapExtentToWKT(epsgTO = this.mapService.getMap().projection) {
- let extent = olproj.transformExtent(
- this.mapService.getMap().getExtent(),
- this.mapService.getMap().projection,
- epsgTO
- );
- extent = this.roundCoordinateArray(extent, epsgTO, 0);
- const wkt = new olWKT().writeGeometry(olPolygon.fromExtent(extent));
- return wkt;
+ constructor() {}
+
+ public wktToFeature(wkt, wktProj, featureProj = 'EPSG:3857') {
+ return new olWKT().readFeature(wkt, {
+ dataProjection: wktProj,
+ featureProjection: featureProj
+ });
+ }
+ public extentToWkt(epsgTO, extent, extentProj) {
+ let currentExtent = olproj.transformExtent(extent, extentProj, epsgTO);
+ currentExtent = this.roundCoordinateArray(currentExtent, epsgTO, 0);
+ const wktPoly = `POLYGON((
+ ${extent[0]} ${extent[1]},
+ ${extent[0]} ${extent[3]},
+ ${extent[2]} ${extent[3]},
+ ${extent[2]} ${extent[1]},
+ ${extent[0]} ${extent[1]}))`;
+ const wktLine = `LINESTRING(
+ ${extent[0]} ${extent[1]},
+ ${extent[0]} ${extent[3]},
+ ${extent[2]} ${extent[3]},
+ ${extent[2]} ${extent[1]},
+ ${extent[0]} ${extent[1]})`;
+ const wktMultiPoints = `MULTIPOINT(
+ ${extent[0]} ${extent[1]},
+ ${extent[0]} ${extent[3]},
+ ${extent[2]} ${extent[3]},
+ ${extent[2]} ${extent[1]})`;
+ return {
+ wktPoly: wktPoly,
+ wktLine: wktLine,
+ wktMultiPoints: wktMultiPoints
+ };
}
private roundCoordinateArray(coordinateArray, projection, decimal = 0) {
@@ -28,7 +47,7 @@ export class WktService {
const units = lproj.getUnits();
const olUnits = ['ft', 'm', 'us-ft'];
if (olUnits.indexOf(units) !== -1) {
- coordinateArray = this.roundArray(coordinateArray);
+ coordinateArray = this.roundArray(coordinateArray, decimal);
}
return coordinateArray;
}
@@ -42,7 +61,7 @@ export class WktService {
return array;
}
- public snrcWKT(snrc, epsgTO = 'EPSG:3857') {
+ public snrcToWkt(snrc, epsgTO = 'EPSG:3857') {
snrc = snrc.toLowerCase();
let wktPoly;
const ew = {
@@ -81,8 +100,8 @@ export class WktService {
['05', '06', '07', '08'],
['04', '03', '02', '01']
];
- const checkSNRC50k = /\d{2,3}[a-l][0,1][0-9]/gi;
- const checkSNRC250k = /\d{2,3}[a-l]/gi;
+ const checkSNRC50k = /\d{2,3}[a-p][0,1][0-9]/gi;
+ const checkSNRC250k = /\d{2,3}[a-p]/gi;
const checkSNRC1m = /\d{2,3}/gi;
let snrc1m = false;
@@ -106,8 +125,8 @@ export class WktService {
} else if (snrc250k) {
snrc += '01';
}
- if (/\d{2,3}[a-l][0,1][0-9]/gi.test(snrc)) {
- const regex_1m = /(?=[a-l])/gi;
+ if (/\d{2,3}[a-p][0,1][0-9]/gi.test(snrc)) {
+ const regex_1m = /(?=[a-p])/gi;
const ar1m = snrc.split(regex_1m);
const part1m = ar1m[0];
const part250k = ar1m[1][0];
@@ -214,8 +233,31 @@ export class WktService {
coord.ul.join(' ')
].join(',') +
'))';
+ const wktLine =
+ 'LINESTRING(' +
+ [
+ coord.ul.join(' '),
+ coord['ur'].join(' '),
+ coord['lr'].join(' '),
+ coord['ll'].join(' '),
+ coord.ul.join(' ')
+ ].join(',') +
+ ')';
- return wktPoly;
+ const wktMultiPoints =
+ 'MULTIPOINT(' +
+ [
+ coord.ul.join(' '),
+ coord['ur'].join(' '),
+ coord['lr'].join(' '),
+ coord['ll'].join(' ')
+ ].join(',') +
+ ')';
+ return {
+ wktPoly: wktPoly,
+ wktLine: wktLine,
+ wktMultiPoints: wktMultiPoints
+ };
}
}
}
diff --git a/projects/geo/src/locale/en.geo.json b/projects/geo/src/locale/en.geo.json
index aea0c94997..fbddb857b1 100644
--- a/projects/geo/src/locale/en.geo.json
+++ b/projects/geo/src/locale/en.geo.json
@@ -58,7 +58,9 @@
"Update this datasource with the active filter(s). To enable this button, the layer must be visible (or in the defined scale ranges) or you must modify the current filter.",
"layerFiltered": "This layer is currently filtered",
"layerFilterable": "This layer is filterable",
- "filterBy": "Filter by"
+ "filterBy": "Filter by",
+ "showFeatureExtent": "Show feature used as spatial extent",
+ "hideFeatureExtent": "Hide feature used as spatial extent "
},
"spatialSelector": {
"fixedExtent": "Fixed extent",
diff --git a/projects/geo/src/locale/fr.geo.json b/projects/geo/src/locale/fr.geo.json
index e01a0012ab..6a023a6b4a 100644
--- a/projects/geo/src/locale/fr.geo.json
+++ b/projects/geo/src/locale/fr.geo.json
@@ -58,7 +58,9 @@
"Mettre à jour la source de donnée avec les filtres actifs de la liste. Pour activer ce boutton, la couche doit etre visible (et dans les échelles permises) ou veillez modifier le présent filtre.",
"layerFiltered": "Cette couche d'information est présentement filtrée.",
"layerFilterable": "Cette couche d'information est filtrable",
- "filterBy": "Filtrer par"
+ "filterBy": "Filtrer par",
+ "showFeatureExtent": "Montrer l'empreinte des étendues",
+ "hideFeatureExtent": "Cacher l'empreinte des étendues"
},
"spatialSelector": {
"fixedExtent": "Étendue fixe",