2020-02-20 20:20:50 +00:00
|
|
|
import { Injectable } from '@angular/core';
|
2021-07-27 06:51:56 +00:00
|
|
|
import { ActivatedRoute } from '@angular/router';
|
2019-11-25 14:31:42 +00:00
|
|
|
|
|
|
|
import { Store, Action } from '@ngrx/store';
|
|
|
|
import { Effect, Actions,ofType } from '@ngrx/effects';
|
|
|
|
|
2021-03-05 16:19:30 +00:00
|
|
|
import { EMPTY, Observable , of,merge} from 'rxjs';
|
|
|
|
import { withLatestFrom, switchMap, map, catchError, mergeMap,tap } from 'rxjs/operators';
|
2019-11-25 14:31:42 +00:00
|
|
|
|
2019-12-11 09:29:47 +00:00
|
|
|
import {GeoJSON,WKT} from 'ol/format';
|
2019-11-25 14:31:42 +00:00
|
|
|
import {Feature} from 'ol';
|
2020-04-21 11:22:54 +00:00
|
|
|
import { getCenter,createEmpty,extend } from 'ol/extent';
|
2019-11-25 14:31:42 +00:00
|
|
|
import {Point} from 'ol/geom'
|
|
|
|
|
|
|
|
|
|
|
|
import * as mapActions from '../actions/map.actions';
|
|
|
|
import * as mapReducers from '../reducers/map.reducer';
|
|
|
|
import {commonReducers} from '@farmmaps/common';
|
|
|
|
|
|
|
|
import {commonActions} from '@farmmaps/common';
|
|
|
|
|
2020-02-12 19:38:14 +00:00
|
|
|
import { IItem } from '@farmmaps/common';
|
2019-11-25 14:31:42 +00:00
|
|
|
import { FolderService, ItemService } from '@farmmaps/common';
|
|
|
|
import { tassign } from 'tassign';
|
|
|
|
|
2020-02-12 19:38:14 +00:00
|
|
|
import {FeatureIconService} from '../services/feature-icon.service';
|
|
|
|
|
|
|
|
import * as style from 'ol/style';
|
|
|
|
|
2020-04-22 10:34:07 +00:00
|
|
|
import { ItemTypeService,IQueryState } from '@farmmaps/common';
|
2021-03-06 13:06:31 +00:00
|
|
|
import { TemporalItemLayer } from '../models/item.layer'
|
2020-03-22 19:08:53 +00:00
|
|
|
|
2020-02-12 19:38:14 +00:00
|
|
|
|
2019-11-25 14:31:42 +00:00
|
|
|
@Injectable()
|
|
|
|
export class MapEffects {
|
2019-12-11 09:29:47 +00:00
|
|
|
private _geojsonFormat: GeoJSON;
|
|
|
|
private _wktFormat: WKT;
|
2021-07-27 06:51:56 +00:00
|
|
|
public _overrideSelectedItemLayer: boolean = false;
|
|
|
|
public _overrideOverlayLayers: boolean = false;
|
2019-12-11 09:29:47 +00:00
|
|
|
|
|
|
|
private toPointFeature(updateEvent:commonActions.DeviceUpdateEvent): Feature {
|
|
|
|
var f = this._wktFormat.readFeature(updateEvent.attributes["geometry"],{
|
|
|
|
dataProjection: 'EPSG:4326',
|
|
|
|
featureProjection: 'EPSG:3857'
|
|
|
|
});
|
|
|
|
f.setId(updateEvent.itemCode);
|
2019-11-25 14:31:42 +00:00
|
|
|
var centroid = getCenter(f.getGeometry().getExtent());
|
|
|
|
f.setGeometry(new Point(centroid));
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
init$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.INIT),
|
|
|
|
withLatestFrom(this.store$.select(commonReducers.selectGetRootItems)),
|
|
|
|
switchMap(([action, rootItems]) => {
|
2020-02-12 19:38:14 +00:00
|
|
|
let actions=[];
|
2019-11-25 14:31:42 +00:00
|
|
|
for (let rootItem of rootItems) {
|
2020-02-12 19:38:14 +00:00
|
|
|
if (rootItem.itemType == "UPLOADS_FOLDER") actions.push(new mapActions.SetParent(rootItem.code));
|
2019-11-25 14:31:42 +00:00
|
|
|
}
|
2020-02-12 19:38:14 +00:00
|
|
|
// initialize default feature styles
|
|
|
|
actions.push(new mapActions.SetStyle('file',new style.Style({
|
|
|
|
image: new style.Icon({
|
|
|
|
anchor: [0.5, 1],
|
|
|
|
scale: 0.05,
|
2021-01-24 08:09:43 +00:00
|
|
|
src: this.featureIconService$.getIconImageDataUrl("fal fa-file")
|
2020-07-15 21:15:31 +00:00
|
|
|
}),
|
2020-02-12 19:38:14 +00:00
|
|
|
stroke: new style.Stroke({
|
|
|
|
color: 'red',
|
|
|
|
width: 1
|
2021-01-26 08:12:37 +00:00
|
|
|
}),
|
|
|
|
fill: new style.Fill({
|
|
|
|
color: 'rgba(0, 0, 0,0)'
|
2020-02-12 19:38:14 +00:00
|
|
|
})
|
|
|
|
})));
|
|
|
|
actions.push(new mapActions.SetStyle('selected',new style.Style({
|
|
|
|
image: new style.Icon({
|
|
|
|
anchor: [0.5, 1],
|
|
|
|
scale: 0.08,
|
|
|
|
src: this.featureIconService$.getIconImageDataUrl(null)
|
|
|
|
}),
|
|
|
|
stroke: new style.Stroke({
|
|
|
|
color: 'red',
|
|
|
|
width: 3
|
2021-01-26 08:12:37 +00:00
|
|
|
}),
|
|
|
|
fill: new style.Fill({
|
|
|
|
color: 'rgba(0, 0, 0, 0)'
|
2020-02-12 19:38:14 +00:00
|
|
|
})
|
2020-07-15 21:15:31 +00:00
|
|
|
})));
|
2020-02-12 19:38:14 +00:00
|
|
|
|
|
|
|
return actions;
|
2019-11-25 14:31:42 +00:00
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
initBaseLayers$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.INIT),
|
|
|
|
withLatestFrom(this.store$.select(mapReducers.selectGetProjection)),
|
|
|
|
map(([action, projection]) => new mapActions.LoadBaseLayers(projection)));
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
loadBaseLayers$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.LOADBASELAYERS),
|
|
|
|
switchMap((action: mapActions.LoadBaseLayers) => {
|
|
|
|
return this.itemService$.getItemList("vnd.farmmaps.itemtype.layer", { "isBaseLayer": true }).pipe(
|
|
|
|
map((items: IItem[]) => new mapActions.LoadBaseLayersSuccess(items)),
|
|
|
|
catchError(error => of(new commonActions.Fail(error))));
|
|
|
|
}));
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
startSearch$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.STARTSEARCH),
|
2020-10-28 12:31:12 +00:00
|
|
|
switchMap((action) => {
|
2020-04-22 06:59:04 +00:00
|
|
|
let a = action as mapActions.StartSearch;
|
|
|
|
var startDate = a.queryState.startDate;
|
2020-07-15 21:15:31 +00:00
|
|
|
var endDate = a.queryState.endDate;
|
2019-11-25 14:31:42 +00:00
|
|
|
var newAction:Observable<Action>;
|
2020-04-22 06:59:04 +00:00
|
|
|
if (a.queryState.itemCode || a.queryState.parentCode || a.queryState.itemType || a.queryState.query || a.queryState.tags) {
|
2021-03-16 20:30:20 +00:00
|
|
|
newAction= this.itemService$.getFeatures(a.queryState.bbox, "EPSG:3857", a.queryState.query, a.queryState.tags, startDate, endDate, a.queryState.itemType, a.queryState.parentCode, null, a.queryState.level).pipe(
|
2019-11-25 14:31:42 +00:00
|
|
|
switchMap((features: any) => {
|
|
|
|
for (let f of features.features) {
|
|
|
|
if (f.properties && f.properties["code"]) {
|
|
|
|
f.id = f.properties["code"];
|
|
|
|
}
|
|
|
|
}
|
2020-10-28 12:31:12 +00:00
|
|
|
return of(new mapActions.StartSearchSuccess(this._geojsonFormat.readFeatures(features), a.queryState));
|
2019-11-25 14:31:42 +00:00
|
|
|
}
|
|
|
|
),
|
|
|
|
catchError(error => of(new commonActions.Fail(error))));
|
|
|
|
} else {
|
2020-04-17 11:26:50 +00:00
|
|
|
return [];
|
2020-07-15 21:15:31 +00:00
|
|
|
}
|
2019-11-25 14:31:42 +00:00
|
|
|
return newAction;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
@Effect()
|
2020-04-21 11:22:54 +00:00
|
|
|
zoomToExtent$: Observable<Action> = this.actions$.pipe(
|
2019-11-25 14:31:42 +00:00
|
|
|
ofType(mapActions.STARTSEARCHSUCCESS),
|
|
|
|
mergeMap((action: mapActions.StartSearchSuccess) => {
|
2020-04-21 11:22:54 +00:00
|
|
|
let actions =[];
|
|
|
|
actions.push(new commonActions.SetMenuVisible(false));
|
|
|
|
let extent = createEmpty();
|
2021-07-27 06:51:56 +00:00
|
|
|
if (!action.query.bboxFilter && !this._overrideSelectedItemLayer) {
|
2020-04-21 11:22:54 +00:00
|
|
|
if (extent) {
|
|
|
|
for (let f of action.features) {
|
|
|
|
extend(extent, (f as Feature).getGeometry().getExtent());
|
|
|
|
}
|
2020-09-29 12:56:23 +00:00
|
|
|
if(action.features && action.features.length >0) {
|
|
|
|
actions.push(new mapActions.SetExtent(extent));
|
|
|
|
}
|
2020-07-15 21:15:31 +00:00
|
|
|
}
|
2020-04-21 11:22:54 +00:00
|
|
|
}
|
|
|
|
return actions;
|
|
|
|
}));
|
|
|
|
|
2020-12-11 12:35:51 +00:00
|
|
|
@Effect()
|
|
|
|
zoomToExtent2$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.SETFEATURES),
|
2021-04-19 06:43:20 +00:00
|
|
|
switchMap((action: mapActions.SetFeatures) => {
|
2020-12-11 12:35:51 +00:00
|
|
|
let extent = createEmpty();
|
2021-04-19 06:43:20 +00:00
|
|
|
if (extent) {
|
|
|
|
for (let f of action.features) {
|
|
|
|
extend(extent, (f as Feature).getGeometry().getExtent());
|
|
|
|
}
|
|
|
|
if(action.features.length>0) return of(new mapActions.SetExtent(extent));
|
|
|
|
}
|
|
|
|
return EMPTY;
|
2020-12-11 12:35:51 +00:00
|
|
|
}));
|
|
|
|
|
2020-04-21 11:22:54 +00:00
|
|
|
@Effect()
|
|
|
|
hideMenu$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.STARTSEARCHSUCCESS),
|
|
|
|
mergeMap((action: mapActions.StartSearchSuccess) => {
|
|
|
|
return of(new commonActions.SetMenuVisible(false));
|
2019-11-25 14:31:42 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
selectItem$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.SELECTITEM),
|
|
|
|
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
2020-10-28 12:31:12 +00:00
|
|
|
switchMap(([action, selectedItem]) => {
|
2019-11-25 14:31:42 +00:00
|
|
|
let a = action as mapActions.SelectItem;
|
|
|
|
let itemCode = selectedItem ? selectedItem.code : "";
|
2020-10-28 12:31:12 +00:00
|
|
|
if (a.itemCode != itemCode) {
|
2019-11-25 14:31:42 +00:00
|
|
|
return this.itemService$.getItem(a.itemCode).pipe(
|
2020-07-15 21:15:31 +00:00
|
|
|
switchMap(child => {
|
|
|
|
return this.itemService$.getItem(child.parentCode)
|
|
|
|
.pipe(map(parent => {
|
|
|
|
return {child, parent};
|
2020-08-01 07:44:32 +00:00
|
|
|
}),catchError(() => { let parent:IItem = null;return of({child,parent})})
|
2020-07-15 21:15:31 +00:00
|
|
|
);
|
|
|
|
}),
|
|
|
|
map(data => new mapActions.SelectItemSuccess(data.child, data.parent)),
|
2019-11-25 14:31:42 +00:00
|
|
|
catchError(error => of(new commonActions.Fail(error))))
|
|
|
|
} else {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
2020-12-16 17:04:39 +00:00
|
|
|
@Effect()
|
|
|
|
selectItemSuccessSetLayer$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.SELECTITEMSUCCESS),
|
|
|
|
map((action:mapActions.SelectItemSuccess) =>
|
|
|
|
new mapActions.SetSelectedItemLayer(action.item)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2019-11-25 14:31:42 +00:00
|
|
|
@Effect()
|
|
|
|
selectItemSuccess$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.SELECTITEMSUCCESS),
|
|
|
|
switchMap((action:mapActions.SelectItemSuccess) => {
|
2021-07-27 07:16:58 +00:00
|
|
|
if(!this._overrideSelectedItemLayer) {
|
|
|
|
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
|
|
|
map((feature: any) => {
|
|
|
|
let f = this._geojsonFormat.readFeature(feature);
|
|
|
|
f.setId(action.item.code);
|
|
|
|
return new mapActions.AddFeatureSuccess(f );
|
|
|
|
}),
|
|
|
|
catchError(error => of(new commonActions.Fail(error))));
|
|
|
|
} else {
|
|
|
|
return EMPTY;
|
|
|
|
}
|
2019-11-25 14:31:42 +00:00
|
|
|
}
|
|
|
|
));
|
|
|
|
|
2020-02-27 16:59:00 +00:00
|
|
|
@Effect()
|
|
|
|
selectItemSuccessTemporal$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.SELECTITEMSUCCESS),
|
|
|
|
switchMap((action:mapActions.SelectItemSuccess) => {
|
|
|
|
if(action.item.itemType == "vnd.farmmaps.itemtype.temporal") {
|
|
|
|
return this.itemService$.getChildItemList(action.item.code,null).pipe(
|
2020-03-03 09:21:24 +00:00
|
|
|
map(items => new mapActions.SelectTemporalItemsSuccess(
|
2020-07-15 21:15:31 +00:00
|
|
|
items.sort((a, b) =>
|
2020-07-07 07:24:45 +00:00
|
|
|
-(Date.parse(b.dataDate) - Date.parse(a.dataDate))
|
2020-03-03 09:21:24 +00:00
|
|
|
)
|
|
|
|
)),
|
2020-02-27 16:59:00 +00:00
|
|
|
catchError(error => of(new commonActions.Fail(error))));
|
|
|
|
} else {
|
|
|
|
return [];
|
2020-07-15 21:15:31 +00:00
|
|
|
}
|
2020-02-27 16:59:00 +00:00
|
|
|
}
|
|
|
|
));
|
|
|
|
|
2019-11-25 14:31:42 +00:00
|
|
|
@Effect()
|
|
|
|
uploadedItemClick$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(commonActions.UPLOADEDFILECLICK),
|
|
|
|
switchMap((action: commonActions.UploadedFileClick) => of(new mapActions.DoQuery(tassign(mapReducers.initialState.query, {itemCode:action.itemCode})))
|
|
|
|
));
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
featureUpdate$: Observable<Action> = this.actions$.pipe(
|
2019-12-11 09:29:47 +00:00
|
|
|
ofType(commonActions.DEVICEUPDATEEVENT),
|
2019-11-25 14:31:42 +00:00
|
|
|
withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)),
|
|
|
|
mergeMap(([action, features]) => {
|
2019-12-11 09:29:47 +00:00
|
|
|
let deviceUpdateEventAction = action as commonActions.DeviceUpdateEvent;
|
2019-11-25 14:31:42 +00:00
|
|
|
var feature: Feature = null;
|
|
|
|
for (let f of features) {
|
2019-12-11 09:29:47 +00:00
|
|
|
if (f.getId() == deviceUpdateEventAction.itemCode) {
|
2019-11-25 14:31:42 +00:00
|
|
|
feature = f;
|
|
|
|
break;
|
|
|
|
}
|
2020-07-15 21:15:31 +00:00
|
|
|
}
|
2019-11-25 14:31:42 +00:00
|
|
|
if (feature) {
|
2020-07-15 21:15:31 +00:00
|
|
|
return of(new mapActions.UpdateFeatureSuccess(this.toPointFeature(deviceUpdateEventAction)));
|
2019-11-25 14:31:42 +00:00
|
|
|
} else {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
itemUpdate$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(commonActions.ITEMCHANGEDEVENT),
|
|
|
|
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
|
|
|
mergeMap(([action, selectedItem]) => {
|
2020-07-15 21:15:31 +00:00
|
|
|
let itemChangedAction = action as commonActions.ItemChangedEvent;
|
2019-11-25 14:31:42 +00:00
|
|
|
if (selectedItem && selectedItem.code == itemChangedAction.itemCode) {
|
|
|
|
return this.itemService$.getItem(itemChangedAction.itemCode).pipe(
|
2020-07-15 21:15:31 +00:00
|
|
|
switchMap(child => {
|
|
|
|
return this.itemService$.getItem(child.parentCode)
|
|
|
|
.pipe(map(parent => {
|
|
|
|
return {child, parent};
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
map(data => new mapActions.SelectItemSuccess(data.child, data.parent)),
|
2019-11-25 14:31:42 +00:00
|
|
|
catchError(error => of(new commonActions.Fail(error))));
|
|
|
|
} else {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2020-04-21 10:31:20 +00:00
|
|
|
getActionFromQueryState(queryState:IQueryState, inSearch:boolean):Observable<Action>|[] {
|
2020-04-22 07:25:10 +00:00
|
|
|
if(!inSearch && (queryState.itemType || queryState.parentCode || queryState.itemCode || queryState.query || queryState.tags)) {
|
2020-07-15 21:15:31 +00:00
|
|
|
var newAction:Action;
|
|
|
|
if (queryState.itemCode && queryState.itemCode != "") {
|
|
|
|
newAction= new mapActions.SelectItem(queryState.itemCode);
|
2020-04-21 10:31:20 +00:00
|
|
|
} else {
|
|
|
|
newAction= new mapActions.StartSearch(queryState);
|
|
|
|
}
|
2020-10-28 12:31:12 +00:00
|
|
|
|
2020-04-21 10:31:20 +00:00
|
|
|
} else {
|
2020-10-28 12:31:12 +00:00
|
|
|
newAction = new mapActions.Clear();
|
2020-04-21 10:31:20 +00:00
|
|
|
}
|
2020-10-28 12:31:12 +00:00
|
|
|
return of(newAction);
|
2020-07-15 21:15:31 +00:00
|
|
|
}
|
2020-04-21 10:31:20 +00:00
|
|
|
|
2021-03-05 16:19:30 +00:00
|
|
|
@Effect()
|
|
|
|
getLayerValue$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.GETLAYERVALUE),
|
2021-03-05 17:41:09 +00:00
|
|
|
mergeMap((action:mapActions.GetLayerValue) => {
|
2021-03-05 16:19:30 +00:00
|
|
|
var l = action.itemLayer.item.data["layers"][action.itemLayer.layerIndex];
|
|
|
|
var scale = l.scale?l.scale:1;
|
|
|
|
return this.itemService$.getLayerValue(action.itemLayer.item.code,action.itemLayer.layerIndex,action.x,action.y).pipe(
|
2021-03-05 17:41:09 +00:00
|
|
|
mergeMap((v: number) => {
|
2021-03-05 16:19:30 +00:00
|
|
|
let a=[];
|
2021-03-05 18:03:50 +00:00
|
|
|
if(v !== null) {
|
2021-03-05 17:41:09 +00:00
|
|
|
if(l.renderer && l.renderer.colorMap && l.renderer.colorMap.colormapType == "manual") {
|
|
|
|
l.renderer.colorMap.entries.forEach((e) => {
|
|
|
|
if(e.value == v) {
|
|
|
|
v=e.label;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
a.push(new mapActions.GetLayerValueSuccess({date:action.itemLayer.item.dataDate,value:v,layerName:l.name,quantity:"",unit:l.unit}));
|
|
|
|
} else {
|
|
|
|
a.push(new mapActions.GetLayerValueSuccess({date:action.itemLayer.item.dataDate,value:v*scale,layerName:l.name,quantity:l.quantity,unit:l.unit}));
|
|
|
|
}
|
|
|
|
}
|
2021-03-05 16:19:30 +00:00
|
|
|
return a;
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
updateLayerValuesOnLayerAddedOrRemoved$: Observable<Action> = this.actions$.pipe(
|
2021-03-06 13:06:31 +00:00
|
|
|
ofType(mapActions.ADDLAYER,mapActions.REMOVELAYER,mapActions.SELECTITEM,mapActions.NEXTTEMPORAL,mapActions.PREVIOUSTEMPORAL,mapActions.TOGGLELAYERVALUESENABLED),
|
2021-03-05 16:19:30 +00:00
|
|
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesX)),
|
|
|
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesY)),
|
|
|
|
map(([[action,x],y]) => new mapActions.SetLayerValuesLocation(x,y))
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
getLayerValues$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.SETLAYERVALUESLOCATION),
|
|
|
|
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItemLayer)),
|
|
|
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesEnabled)),
|
|
|
|
withLatestFrom(this.store$.select(mapReducers.selectGetOverlayLayers)),
|
2021-03-05 17:41:09 +00:00
|
|
|
mergeMap(([[[action, selected], enabled],overlayLayers]) => {
|
2021-03-05 16:19:30 +00:00
|
|
|
let layers = [];
|
2021-03-06 13:06:31 +00:00
|
|
|
if(selected) {
|
2021-03-06 13:29:01 +00:00
|
|
|
if(selected && (selected as TemporalItemLayer).selectedItemLayer ) {
|
2021-03-06 13:06:31 +00:00
|
|
|
selected=(selected as TemporalItemLayer).selectedItemLayer;
|
|
|
|
}
|
|
|
|
layers.push(selected);
|
|
|
|
}
|
2021-03-05 16:19:30 +00:00
|
|
|
overlayLayers.forEach((ol) => {
|
|
|
|
if(ol!=selected) layers.push(ol);
|
|
|
|
});
|
|
|
|
let a = action as mapActions.SetLayerValuesLocation;
|
|
|
|
let actions = [];
|
|
|
|
if(enabled) {
|
|
|
|
layers.forEach((ol) => {
|
|
|
|
if("vnd.farmmaps.itemtype.shape.processed,vnd.farmmaps.itemtype.geotiff.processed".indexOf(ol.item.itemType)>=0) {
|
|
|
|
actions.push(new mapActions.GetLayerValue(ol,a.x,a.y));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return actions;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2019-11-25 14:31:42 +00:00
|
|
|
@Effect()
|
|
|
|
setState$: Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(mapActions.SETSTATE),
|
2020-04-17 11:26:50 +00:00
|
|
|
withLatestFrom(this.store$.select(mapReducers.selectGetInSearch)),
|
|
|
|
switchMap(([action,inSearch]) => {
|
2020-04-21 10:31:20 +00:00
|
|
|
let a = action as mapActions.SetState;
|
|
|
|
return this.getActionFromQueryState(a.queryState,inSearch);
|
2019-11-25 14:31:42 +00:00
|
|
|
}));
|
|
|
|
|
2020-10-28 12:31:12 +00:00
|
|
|
@Effect()
|
|
|
|
escape$:Observable<Action> = this.actions$.pipe(
|
|
|
|
ofType(commonActions.ESCAPE),
|
|
|
|
switchMap((action) => {
|
|
|
|
let a = action as commonActions.Escape;
|
|
|
|
if(a.escapeKey) {
|
|
|
|
return of(new mapActions.Clear());
|
|
|
|
} else {
|
|
|
|
return EMPTY;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2021-07-27 06:51:56 +00:00
|
|
|
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService,private featureIconService$:FeatureIconService,private itemTypeService$:ItemTypeService, private route: ActivatedRoute) {
|
2019-12-11 09:29:47 +00:00
|
|
|
this._geojsonFormat = new GeoJSON();
|
|
|
|
this._wktFormat = new WKT();
|
2021-07-27 06:51:56 +00:00
|
|
|
if(route && route.snapshot && route.snapshot.data && route.snapshot.data["fm-map-map"]) {
|
|
|
|
let params = route.snapshot.data["fm-map-map"];
|
|
|
|
this._overrideSelectedItemLayer = params["overrideSelectedItemlayer"] ? params["overrideSelectedItemlayer"] : false;
|
|
|
|
this._overrideOverlayLayers = params["overrideOverlayLayers"] ? params["overrideOverlayLayers"] : false;
|
|
|
|
}
|
|
|
|
}
|
2019-11-25 14:31:42 +00:00
|
|
|
}
|