|
|
@@ -0,0 +1,74 @@
|
|
|
+import {HttpClient} from '@angular/common/http';
|
|
|
+import {Injectable} from '@angular/core';
|
|
|
+
|
|
|
+import {GML} from 'ol/format';
|
|
|
+import {Vector as VectorSource} from 'ol/source';
|
|
|
+import {bbox as bboxStrategy} from 'ol/loadingstrategy';
|
|
|
+
|
|
|
+@Injectable({providedIn: 'root'})
|
|
|
+export class IrrigationHistoryService {
|
|
|
+ reservoirWfsSource;
|
|
|
+ epsgCode: string;
|
|
|
+ timeStamp: string;
|
|
|
+
|
|
|
+ constructor(private httpClient: HttpClient) {
|
|
|
+ this.epsgCode = '3857';
|
|
|
+ this.timeStamp = '2022-05-20T03:00:00Z';
|
|
|
+ this.reservoirWfsSource = this.createReservoirWfsSource();
|
|
|
+ }
|
|
|
+
|
|
|
+ getForecast() {
|
|
|
+ const crossOrigin = !window.location.hostname.includes('gis.atapex.sk');
|
|
|
+ const proxyPath = window.location.hostname.includes('localhost')
|
|
|
+ ? 'http://localhost:8085/'
|
|
|
+ : '/proxy/';
|
|
|
+ return this.httpClient.get(
|
|
|
+ (crossOrigin ? proxyPath : '') +
|
|
|
+ 'https://www.gis.atapex.sk/agrihub_forecast/'
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ private createReservoirWfsSource() {
|
|
|
+ return new VectorSource({
|
|
|
+ format: new GML(/*{
|
|
|
+ dataProjection: 'EPSG:3857',
|
|
|
+ }*/),
|
|
|
+ url: (extent) => {
|
|
|
+ const timeStampEnd = '2022-05-20T04:00:05.603Z';
|
|
|
+ const crossOrigin = !window.location.hostname.includes('gis.atapex.sk');
|
|
|
+ const proxyPath = window.location.hostname.includes('localhost')
|
|
|
+ ? 'http://localhost:8085/'
|
|
|
+ : '/proxy/';
|
|
|
+ return (
|
|
|
+ (crossOrigin ? proxyPath : '') +
|
|
|
+ 'https://www.gis.atapex.sk/geoserver/agrihub/wfs' +
|
|
|
+ '?service=WFS' +
|
|
|
+ '&VERSION=1.1.0' +
|
|
|
+ '&REQUEST=GetFeature' +
|
|
|
+ '&TYPENAME=agrihub:water_surface' +
|
|
|
+ '&COUNT=100' +
|
|
|
+ //'&outputformat=geojson' +
|
|
|
+ `&SRSNAME=EPSG:${this.epsgCode}` +
|
|
|
+ //`&BBOX=${extent.join(',')},EPSG:${epsgCode}` +
|
|
|
+ `&FILTER=
|
|
|
+ <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
|
|
|
+ <ogc:And>
|
|
|
+ <ogc:PropertyIsGreaterThan>
|
|
|
+ <ogc:PropertyName>agrihub:datetime</ogc:PropertyName>
|
|
|
+ <ogc:Literal>${this.timeStamp}</ogc:Literal>
|
|
|
+ </ogc:PropertyIsGreaterThan>
|
|
|
+ <ogc:PropertyIsLessThan>
|
|
|
+ <ogc:PropertyName>agrihub:datetime</ogc:PropertyName>
|
|
|
+ <ogc:Literal>${timeStampEnd}</ogc:Literal>
|
|
|
+ </ogc:PropertyIsLessThan>
|
|
|
+ </ogc:And>
|
|
|
+ </ogc:Filter>`
|
|
|
+ );
|
|
|
+ //%3Cgml:Box%3E%3Cgml:coordinates%3E${
|
|
|
+ //extent.join(',')
|
|
|
+ //}%3C/gml:coordinates%3E%3C/gml:Box%3E%3C/ogc:Filter%3E`;
|
|
|
+ },
|
|
|
+ strategy: bboxStrategy,
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|