|
@@ -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 {Subject} from 'rxjs';
|
|
|
import {catchError} from 'rxjs/operators';
|
|
import {catchError} from 'rxjs/operators';
|
|
|
|
|
|
|
|
import {HsConfig} from 'hslayers-ng';
|
|
import {HsConfig} from 'hslayers-ng';
|
|
@@ -12,7 +13,11 @@ export type Index = 'EVI' | 'RVI4S1';
|
|
|
export class CalculatorService {
|
|
export class CalculatorService {
|
|
|
availableDates: Array<string>;
|
|
availableDates: Array<string>;
|
|
|
availableProducts = ['EVI', 'RVI4S1'];
|
|
availableProducts = ['EVI', 'RVI4S1'];
|
|
|
|
|
+ dateRangeSelects: Subject<{date: string}> = new Subject();
|
|
|
|
|
+ dateCalendarSelects: Subject<{date: string}> = new Subject();
|
|
|
|
|
+ selectedDate;
|
|
|
selectedField;
|
|
selectedField;
|
|
|
|
|
+ //selectedProduct;
|
|
|
serviceBaseUrl = 'https://fieldcalc.lesprojekt.cz/';
|
|
serviceBaseUrl = 'https://fieldcalc.lesprojekt.cz/';
|
|
|
//TODO: temporary hard-coded hack
|
|
//TODO: temporary hard-coded hack
|
|
|
centroid = {type: 'Point', coordinates: [16.944, 49.228]};
|
|
centroid = {type: 'Point', coordinates: [16.944, 49.228]};
|
|
@@ -41,6 +46,9 @@ export class CalculatorService {
|
|
|
) {
|
|
) {
|
|
|
//TODO: temporary hard-coded hack
|
|
//TODO: temporary hard-coded hack
|
|
|
this.selectedField = this.centroid;
|
|
this.selectedField = this.centroid;
|
|
|
|
|
+ this.dateRangeSelects.subscribe(({date}) => {
|
|
|
|
|
+ this.selectedDate = date;
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
noFieldSelected(): boolean {
|
|
noFieldSelected(): boolean {
|
|
@@ -67,6 +75,10 @@ export class CalculatorService {
|
|
|
console.log('data received!');
|
|
console.log('data received!');
|
|
|
console.log(data);
|
|
console.log(data);
|
|
|
this.availableDates = data.dates;
|
|
this.availableDates = data.dates;
|
|
|
|
|
+ /* Any previously selected date must be cleaned up
|
|
|
|
|
+ * so it won't get sent to the API as a wrong param
|
|
|
|
|
+ */
|
|
|
|
|
+ this.selectedDate = undefined;
|
|
|
//TODO: temporary hard-coded hack
|
|
//TODO: temporary hard-coded hack
|
|
|
this.selectedField = this.field;
|
|
this.selectedField = this.field;
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
@@ -75,7 +87,7 @@ export class CalculatorService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async getZones({product, date}: {product: Index; date: string}) {
|
|
|
|
|
|
|
+ async getZones({product}: {product: Index}) {
|
|
|
try {
|
|
try {
|
|
|
const data = await this.httpClient
|
|
const data = await this.httpClient
|
|
|
.post(
|
|
.post(
|
|
@@ -84,7 +96,7 @@ export class CalculatorService {
|
|
|
'get_zones',
|
|
'get_zones',
|
|
|
{
|
|
{
|
|
|
product,
|
|
product,
|
|
|
- date,
|
|
|
|
|
|
|
+ date: this.selectedDate,
|
|
|
format: 'geojson',
|
|
format: 'geojson',
|
|
|
geometry: this.selectedField,
|
|
geometry: this.selectedField,
|
|
|
},
|
|
},
|