|
@@ -3,14 +3,9 @@ import {Injectable} from '@angular/core';
|
|
|
import {Subject} from 'rxjs';
|
|
import {Subject} from 'rxjs';
|
|
|
import {catchError} from 'rxjs/operators';
|
|
import {catchError} from 'rxjs/operators';
|
|
|
|
|
|
|
|
-import {GeoJSON} from 'ol/format';
|
|
|
|
|
-import {Geometry} from 'ol/geom';
|
|
|
|
|
-import {Vector as VectorSource} from 'ol/source';
|
|
|
|
|
-import {getCenter} from 'ol/extent';
|
|
|
|
|
-import {transform} from 'ol/proj';
|
|
|
|
|
-
|
|
|
|
|
import {HsConfig} from 'hslayers-ng';
|
|
import {HsConfig} from 'hslayers-ng';
|
|
|
|
|
|
|
|
|
|
+import {FieldService} from './field.service';
|
|
|
import {ZonesService} from './zones.service';
|
|
import {ZonesService} from './zones.service';
|
|
|
|
|
|
|
|
export type Index = 'EVI' | 'RVI4S1';
|
|
export type Index = 'EVI' | 'RVI4S1';
|
|
@@ -21,56 +16,23 @@ export class CalculatorService {
|
|
|
availableProducts = ['EVI', 'RVI4S1'];
|
|
availableProducts = ['EVI', 'RVI4S1'];
|
|
|
dateRangeSelects: Subject<{date: string}> = new Subject();
|
|
dateRangeSelects: Subject<{date: string}> = new Subject();
|
|
|
dateCalendarSelects: Subject<{date: string}> = new Subject();
|
|
dateCalendarSelects: Subject<{date: string}> = new Subject();
|
|
|
- field: VectorSource<Geometry>;
|
|
|
|
|
selectedDate;
|
|
selectedDate;
|
|
|
- selectedField;
|
|
|
|
|
//selectedProduct;
|
|
//selectedProduct;
|
|
|
serviceBaseUrl = 'https://fieldcalc.lesprojekt.cz/';
|
|
serviceBaseUrl = 'https://fieldcalc.lesprojekt.cz/';
|
|
|
- //TODO: temporarry hard-coded hack
|
|
|
|
|
- fieldGeoJSON = {
|
|
|
|
|
- type: 'Polygon',
|
|
|
|
|
- coordinates: [
|
|
|
|
|
- [
|
|
|
|
|
- [17.008032903697003, 49.259378350222214],
|
|
|
|
|
- [17.012346093160815, 49.26055145480218],
|
|
|
|
|
- [17.01341275235608, 49.25661998865008],
|
|
|
|
|
- [17.01578237120672, 49.251834177355896],
|
|
|
|
|
- [17.01243531034079, 49.24966645404407],
|
|
|
|
|
- [17.009126895621744, 49.24897297823598],
|
|
|
|
|
- [17.003117114964958, 49.253454830509305],
|
|
|
|
|
- [17.008032903697003, 49.259378350222214],
|
|
|
|
|
- ],
|
|
|
|
|
- ],
|
|
|
|
|
- };
|
|
|
|
|
- //[[[17.01403296191603, 49.24858329768389], [17.014029303734432, 49.24849340104692], [17.01389198448605, 49.2484957958039], [17.013754665219444, 49.24849819039773], [17.013751007554088, 49.248408293744056], [17.013613688518262, 49.24841068816722], [17.013476369464207, 49.24841308242727], [17.013469055184203, 49.248233289084894], [17.01333173660994, 49.24823568316671], [17.01319441801745, 49.24823807708539], [17.013183448228144, 49.24796838701452], [17.013320766073623, 49.24796599311847], [17.01331710926463, 49.247876096432506], [17.013729061944726, 49.24786891378824], [17.01373271950072, 49.24795881045155], [17.0138700372733, 49.24795641590298], [17.013873695096525, 49.24804631255717], [17.014285649051903, 49.24803912791008], [17.014281990481678, 49.247949231278554], [17.014419308181342, 49.247946836077475], [17.014422967000566, 49.24803673270145], [17.015246874309636, 49.24802235802403], [17.015384192130647, 49.24801996167353], [17.01540249521542, 49.24846944450495], [17.01526517614939, 49.248471840893245], [17.01526151574496, 49.24838194432262], [17.015124196909692, 49.24838434054022], [17.015127857065117, 49.248474237118394], [17.01457858054565, 49.248483820387705], [17.014582239723282, 49.248573716994485], [17.01403296191603, 49.24858329768389]]]};
|
|
|
|
|
private _datesLoading: boolean;
|
|
private _datesLoading: boolean;
|
|
|
private _zonesLoading: boolean;
|
|
private _zonesLoading: boolean;
|
|
|
|
|
|
|
|
constructor(
|
|
constructor(
|
|
|
|
|
+ private fieldService: FieldService,
|
|
|
private hsConfig: HsConfig,
|
|
private hsConfig: HsConfig,
|
|
|
private httpClient: HttpClient,
|
|
private httpClient: HttpClient,
|
|
|
private zonesService: ZonesService
|
|
private zonesService: ZonesService
|
|
|
) {
|
|
) {
|
|
|
- //TODO: temporary hard-coded hack
|
|
|
|
|
- this.field = new VectorSource({
|
|
|
|
|
- features: [
|
|
|
|
|
- new GeoJSON().readFeature(this.fieldGeoJSON, {
|
|
|
|
|
- dataProjection: 'EPSG:4326',
|
|
|
|
|
- featureProjection: 'EPSG:5514',
|
|
|
|
|
- }),
|
|
|
|
|
- ],
|
|
|
|
|
- });
|
|
|
|
|
- //TODO: temporary hard-coded hack
|
|
|
|
|
- this.selectedField = this.field;
|
|
|
|
|
this.dateRangeSelects.subscribe(({date}) => {
|
|
this.dateRangeSelects.subscribe(({date}) => {
|
|
|
this.selectedDate = date;
|
|
this.selectedDate = date;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- noFieldSelected(): boolean {
|
|
|
|
|
- return this.selectedField === undefined;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
noDates(): boolean {
|
|
noDates(): boolean {
|
|
|
return this.availableDates === undefined;
|
|
return this.availableDates === undefined;
|
|
|
}
|
|
}
|
|
@@ -81,8 +43,6 @@ export class CalculatorService {
|
|
|
async getDates({product}: {product: Index}) {
|
|
async getDates({product}: {product: Index}) {
|
|
|
this.availableDates = undefined;
|
|
this.availableDates = undefined;
|
|
|
this._datesLoading = true;
|
|
this._datesLoading = true;
|
|
|
- //TODO: temporary hard-coded hack
|
|
|
|
|
- this.selectedField = this.field;
|
|
|
|
|
try {
|
|
try {
|
|
|
const data = await this.httpClient
|
|
const data = await this.httpClient
|
|
|
.get<{dates: string[]}>(
|
|
.get<{dates: string[]}>(
|
|
@@ -92,7 +52,7 @@ export class CalculatorService {
|
|
|
'product=' +
|
|
'product=' +
|
|
|
product +
|
|
product +
|
|
|
'¢roid=' +
|
|
'¢roid=' +
|
|
|
- JSON.stringify(this.getCentroidOfField(this.selectedField))
|
|
|
|
|
|
|
+ JSON.stringify(this.fieldService.getSelectedFieldCentroid())
|
|
|
)
|
|
)
|
|
|
.toPromise();
|
|
.toPromise();
|
|
|
this._datesLoading = false;
|
|
this._datesLoading = false;
|
|
@@ -110,17 +70,6 @@ export class CalculatorService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- getCentroidOfField(field) {
|
|
|
|
|
- return {
|
|
|
|
|
- type: 'Point',
|
|
|
|
|
- coordinates: transform(
|
|
|
|
|
- getCenter(field.getExtent()),
|
|
|
|
|
- 'EPSG:5514',
|
|
|
|
|
- 'EPSG:4326'
|
|
|
|
|
- ),
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
get datesLoading() {
|
|
get datesLoading() {
|
|
|
return this._datesLoading;
|
|
return this._datesLoading;
|
|
|
}
|
|
}
|
|
@@ -134,8 +83,6 @@ export class CalculatorService {
|
|
|
*/
|
|
*/
|
|
|
async getZones({product}: {product: Index}) {
|
|
async getZones({product}: {product: Index}) {
|
|
|
this._zonesLoading = true;
|
|
this._zonesLoading = true;
|
|
|
- //TODO: temporary hard-coded hack
|
|
|
|
|
- this.selectedField = this.fieldGeoJSON;
|
|
|
|
|
try {
|
|
try {
|
|
|
const data = await this.httpClient
|
|
const data = await this.httpClient
|
|
|
.post(
|
|
.post(
|
|
@@ -146,7 +93,7 @@ export class CalculatorService {
|
|
|
product,
|
|
product,
|
|
|
date: this.selectedDate,
|
|
date: this.selectedDate,
|
|
|
format: 'geojson',
|
|
format: 'geojson',
|
|
|
- geometry: this.selectedField,
|
|
|
|
|
|
|
+ geometry: this.fieldService.selectedField,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
headers: {
|
|
headers: {
|