|
@@ -1,5 +1,6 @@
|
|
|
import {HttpClient} from '@angular/common/http';
|
|
import {HttpClient} from '@angular/common/http';
|
|
|
import {Injectable} from '@angular/core';
|
|
import {Injectable} from '@angular/core';
|
|
|
|
|
+import {NgbCalendar, NgbDateStruct} from '@ng-bootstrap/ng-bootstrap';
|
|
|
import {Subject} from 'rxjs';
|
|
import {Subject} from 'rxjs';
|
|
|
import {catchError} from 'rxjs/operators';
|
|
import {catchError} from 'rxjs/operators';
|
|
|
|
|
|
|
@@ -15,11 +16,11 @@ import {FieldService} from './field.service';
|
|
|
import {ZonesService} from './zones.service';
|
|
import {ZonesService} from './zones.service';
|
|
|
import {imageWmsTLayer, imageWmsTSource} from './image-wms-t-layer';
|
|
import {imageWmsTLayer, imageWmsTSource} from './image-wms-t-layer';
|
|
|
|
|
|
|
|
-export type Index = 'EVI' | 'RVI4S1';
|
|
|
|
|
|
|
+export type Index = 'EVI' | 'NDVI';
|
|
|
|
|
|
|
|
@Injectable({providedIn: 'root'})
|
|
@Injectable({providedIn: 'root'})
|
|
|
export class CalculatorService {
|
|
export class CalculatorService {
|
|
|
- AVAILABLE_PRODUCTS = ['EVI', 'RVI4S1'] as const;
|
|
|
|
|
|
|
+ AVAILABLE_PRODUCTS = ['EVI', 'NDVI'] as const;
|
|
|
BLUR_MIN_VALUE = 0 as const;
|
|
BLUR_MIN_VALUE = 0 as const;
|
|
|
BLUR_MAX_VALUE = 5 as const;
|
|
BLUR_MAX_VALUE = 5 as const;
|
|
|
MIN_LPIS_VISIBLE_ZOOM = 15 as const;
|
|
MIN_LPIS_VISIBLE_ZOOM = 15 as const;
|
|
@@ -31,7 +32,9 @@ export class CalculatorService {
|
|
|
lpisLoading = false;
|
|
lpisLoading = false;
|
|
|
quantileCount = 4;
|
|
quantileCount = 4;
|
|
|
selectedDate: string;
|
|
selectedDate: string;
|
|
|
|
|
+ selectedDateCalendar: NgbDateStruct;
|
|
|
viewChanges: Subject<any> = new Subject();
|
|
viewChanges: Subject<any> = new Subject();
|
|
|
|
|
+ lastError = '';
|
|
|
//selectedProduct;
|
|
//selectedProduct;
|
|
|
private _datesLoading: boolean;
|
|
private _datesLoading: boolean;
|
|
|
private _zonesLoading: boolean;
|
|
private _zonesLoading: boolean;
|
|
@@ -44,7 +47,8 @@ export class CalculatorService {
|
|
|
private hsMapService: HsMapService,
|
|
private hsMapService: HsMapService,
|
|
|
private hsToastService: HsToastService,
|
|
private hsToastService: HsToastService,
|
|
|
private httpClient: HttpClient,
|
|
private httpClient: HttpClient,
|
|
|
- private zonesService: ZonesService
|
|
|
|
|
|
|
+ private zonesService: ZonesService,
|
|
|
|
|
+ private calendar: NgbCalendar
|
|
|
) {
|
|
) {
|
|
|
this.dateRangeSelects.subscribe(({date}) => {
|
|
this.dateRangeSelects.subscribe(({date}) => {
|
|
|
this.selectedDate = date;
|
|
this.selectedDate = date;
|
|
@@ -57,7 +61,7 @@ export class CalculatorService {
|
|
|
this.selectedDate = undefined;
|
|
this.selectedDate = undefined;
|
|
|
});
|
|
});
|
|
|
this.hsEventBus.olMapLoads.subscribe((map) => {
|
|
this.hsEventBus.olMapLoads.subscribe((map) => {
|
|
|
- map.getView().on('change:resolution', (evt) => {
|
|
|
|
|
|
|
+ map.map.getView().on('change:resolution', (evt) => {
|
|
|
this.viewChanges.next(evt.target);
|
|
this.viewChanges.next(evt.target);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
@@ -72,11 +76,12 @@ export class CalculatorService {
|
|
|
*/
|
|
*/
|
|
|
async getDates({product}: {product: Index}) {
|
|
async getDates({product}: {product: Index}) {
|
|
|
this.availableDates = undefined;
|
|
this.availableDates = undefined;
|
|
|
|
|
+ this.selectedDateCalendar = null;
|
|
|
this._datesLoading = true;
|
|
this._datesLoading = true;
|
|
|
try {
|
|
try {
|
|
|
const data = await this.httpClient
|
|
const data = await this.httpClient
|
|
|
.get<{dates: string[]}>(
|
|
.get<{dates: string[]}>(
|
|
|
- (this.proxyEnabled() ? this.hsConfig.proxyPrefix : '') +
|
|
|
|
|
|
|
+ (this.proxyEnabled() ? this.hsConfig.apps.default.proxyPrefix : '') +
|
|
|
this.SERVICE_BASE_URL +
|
|
this.SERVICE_BASE_URL +
|
|
|
'get_dates?' +
|
|
'get_dates?' +
|
|
|
'product=' +
|
|
'product=' +
|
|
@@ -124,11 +129,12 @@ export class CalculatorService {
|
|
|
* Call 'get_zones' API method
|
|
* Call 'get_zones' API method
|
|
|
*/
|
|
*/
|
|
|
async getZones({product}: {product: Index}) {
|
|
async getZones({product}: {product: Index}) {
|
|
|
|
|
+ this.lastError = '';
|
|
|
this._zonesLoading = true;
|
|
this._zonesLoading = true;
|
|
|
try {
|
|
try {
|
|
|
const data = await this.httpClient
|
|
const data = await this.httpClient
|
|
|
.post(
|
|
.post(
|
|
|
- (this.proxyEnabled() ? this.hsConfig.proxyPrefix : '') +
|
|
|
|
|
|
|
+ (this.proxyEnabled() ? this.hsConfig.apps.default.proxyPrefix : '') +
|
|
|
this.SERVICE_BASE_URL +
|
|
this.SERVICE_BASE_URL +
|
|
|
'get_zones',
|
|
'get_zones',
|
|
|
{
|
|
{
|
|
@@ -149,23 +155,28 @@ export class CalculatorService {
|
|
|
.toPromise();
|
|
.toPromise();
|
|
|
console.log('data received!', data);
|
|
console.log('data received!', data);
|
|
|
this._zonesLoading = false;
|
|
this._zonesLoading = false;
|
|
|
- this.zonesService.updateZones(data, {quantileCount: this.quantileCount});
|
|
|
|
|
|
|
+ await this.zonesService.updateZones(data, {
|
|
|
|
|
+ quantileCount: this.quantileCount,
|
|
|
|
|
+ });
|
|
|
this.updateImageBackground(this.selectedDate);
|
|
this.updateImageBackground(this.selectedDate);
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
|
|
+ const errLoadingZones =
|
|
|
|
|
+ this.hsLanguageService.getTranslationIgnoreNonExisting(
|
|
|
|
|
+ 'CALCULATOR',
|
|
|
|
|
+ 'errorLoadingZones'
|
|
|
|
|
+ );
|
|
|
this._zonesLoading = false;
|
|
this._zonesLoading = false;
|
|
|
this.hsToastService.createToastPopupMessage(
|
|
this.hsToastService.createToastPopupMessage(
|
|
|
this.hsLanguageService.getTranslationIgnoreNonExisting(
|
|
this.hsLanguageService.getTranslationIgnoreNonExisting(
|
|
|
'CALCULATOR',
|
|
'CALCULATOR',
|
|
|
'errorLoading'
|
|
'errorLoading'
|
|
|
),
|
|
),
|
|
|
- this.hsLanguageService.getTranslationIgnoreNonExisting(
|
|
|
|
|
- 'CALCULATOR',
|
|
|
|
|
- 'errorLoadingZones'
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ errLoadingZones,
|
|
|
{
|
|
{
|
|
|
toastStyleClasses: 'bg-warning text-dark',
|
|
toastStyleClasses: 'bg-warning text-dark',
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
+ this.lastError = errLoadingZones;
|
|
|
console.error('Somethin fucked up!');
|
|
console.error('Somethin fucked up!');
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
}
|
|
}
|
|
@@ -182,6 +193,9 @@ export class CalculatorService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private proxyEnabled(): boolean {
|
|
private proxyEnabled(): boolean {
|
|
|
- return this.hsConfig.useProxy === undefined || this.hsConfig.useProxy;
|
|
|
|
|
|
|
+ return (
|
|
|
|
|
+ this.hsConfig.apps.default.useProxy === undefined ||
|
|
|
|
|
+ this.hsConfig.apps.default.useProxy
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|