AW-4860
This commit is contained in:
parent
3c7adf012f
commit
f2e265391c
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "farmmaps-lib-app",
|
"name": "farmmaps-lib-app",
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<li class="border-top pt-1 pb-1 value" *ngFor="let layerValue of layers">
|
<li class="border-top pt-1 pb-1 value" *ngFor="let layerValue of layers">
|
||||||
<div>{{layerValue.layerName}}</div>
|
<div>{{layerValue.layerName}}</div>
|
||||||
<div>{{layerValue.date|date}}</div>
|
<div>{{layerValue.date|date}}</div>
|
||||||
<div><span *ngIf="layerValue.quantity"><span class="me-1">{{layerValue.quantity}}</span> </span><span class="me-1 font-weight-bold">{{layerValue.value}}</span><span>{{layerValue.unit}}</span></div>
|
<div><span *ngIf="layerValue.quantity"><span class="me-1">{{layerValue.quantity}}</span> </span><span class="me-1 font-weight-bold">{{getScaledValue(layerValue)}}</span><span>{{layerValue.unit}}</span></div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ng-template #no_data>
|
<ng-template #no_data>
|
||||||
@ -15,4 +15,4 @@
|
|||||||
</ng-template>
|
</ng-template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>>
|
</div>
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import { Component, OnInit,Input,ViewChild,ElementRef,AfterViewInit } from '@angular/core';
|
import { Component, OnInit, Input, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
|
||||||
import {IItemLayer} from '../../../models/item.layer';
|
import { IItemLayer } from '../../../models/item.layer';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import * as mapReducers from '../../../reducers/map.reducer';
|
import * as mapReducers from '../../../reducers/map.reducer';
|
||||||
import * as mapActions from '../../../actions/map.actions';
|
import * as mapActions from '../../../actions/map.actions';
|
||||||
import { MapComponent } from 'ngx-openlayers';
|
import { MapComponent } from 'ngx-openlayers';
|
||||||
import { ILayervalue } from '../../../models/layer.value';
|
import { ILayervalue } from '../../../models/layer.value';
|
||||||
import { Observable,interval,Subject } from 'rxjs';
|
import { Observable, interval, Subject } from 'rxjs';
|
||||||
import { debounce, throttle } from 'rxjs/operators';
|
import { debounce, throttle } from 'rxjs/operators';
|
||||||
import { toLonLat } from 'ol/proj';
|
import { toLonLat } from 'ol/proj';
|
||||||
import { toStringHDMS } from 'ol/coordinate';
|
import { toStringHDMS } from 'ol/coordinate';
|
||||||
import { ClipboardService } from 'ngx-clipboard'
|
import { ClipboardService } from 'ngx-clipboard'
|
||||||
import {GeoJSON,WKT} from 'ol/format';
|
import { GeoJSON, WKT } from 'ol/format';
|
||||||
import { Point } from 'ol/geom';
|
import { Point } from 'ol/geom';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -18,19 +18,19 @@ import { Point } from 'ol/geom';
|
|||||||
templateUrl: './layer-values.component.html',
|
templateUrl: './layer-values.component.html',
|
||||||
styleUrls: ['./layer-values.component.scss']
|
styleUrls: ['./layer-values.component.scss']
|
||||||
})
|
})
|
||||||
export class LayerValuesComponent implements OnInit,AfterViewInit {
|
export class LayerValuesComponent implements OnInit, AfterViewInit {
|
||||||
|
|
||||||
@ViewChild('layerValues') containerRef:ElementRef;
|
@ViewChild('layerValues') containerRef: ElementRef;
|
||||||
offsetX$ =0;
|
offsetX$ = 0;
|
||||||
offsetY$ =0;
|
offsetY$ = 0;
|
||||||
lonlat$="";
|
lonlat$ = "";
|
||||||
wkt$= "";
|
wkt$ = "";
|
||||||
layerValues$:Observable<Array<ILayervalue>> = this.store.select(mapReducers.selectGetLayerValues);
|
layerValues$: Observable<Array<ILayervalue>> = this.store.select(mapReducers.selectGetLayerValues);
|
||||||
enabled$:Observable<boolean> = this.store.select(mapReducers.selectGetLayerValuesEnabled);
|
enabled$: Observable<boolean> = this.store.select(mapReducers.selectGetLayerValuesEnabled);
|
||||||
wktFormat$:WKT;
|
wktFormat$: WKT;
|
||||||
|
|
||||||
constructor( private store: Store<mapReducers.State>,private map: MapComponent,private clipboardService$:ClipboardService) {
|
constructor(private store: Store<mapReducers.State>, private map: MapComponent, private clipboardService$: ClipboardService) {
|
||||||
this.wktFormat$=new WKT();
|
this.wktFormat$ = new WKT();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@ -39,24 +39,32 @@ export class LayerValuesComponent implements OnInit,AfterViewInit {
|
|||||||
|
|
||||||
moveEndSubject = new Subject<any>();
|
moveEndSubject = new Subject<any>();
|
||||||
|
|
||||||
ngAfterViewInit():void {
|
ngAfterViewInit(): void {
|
||||||
this.offsetY$ = this.containerRef.nativeElement.offsetTop;
|
this.offsetY$ = this.containerRef.nativeElement.offsetTop;
|
||||||
this.offsetX$ = this.containerRef.nativeElement.offsetLeft;
|
this.offsetX$ = this.containerRef.nativeElement.offsetLeft;
|
||||||
this.map.instance.on('moveend', () => {
|
this.map.instance.on('moveend', () => {
|
||||||
this.moveEndSubject.next({});
|
this.moveEndSubject.next({});
|
||||||
});
|
});
|
||||||
this.moveEndSubject.pipe(throttle(ev => interval(100))).subscribe(() => this.updateValuesLocation());
|
this.moveEndSubject.pipe(throttle(ev => interval(100))).subscribe(() => this.updateValuesLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateValuesLocation() {
|
updateValuesLocation() {
|
||||||
const xy = this.map.instance.getCoordinateFromPixel([this.offsetX$,this.offsetY$])
|
const xy = this.map.instance.getCoordinateFromPixel([this.offsetX$, this.offsetY$])
|
||||||
const lonlat = toLonLat(xy);
|
const lonlat = toLonLat(xy);
|
||||||
this.wkt$ = this.wktFormat$.writeGeometry(new Point(lonlat))
|
this.wkt$ = this.wktFormat$.writeGeometry(new Point(lonlat))
|
||||||
this.lonlat$ = toStringHDMS(lonlat);
|
this.lonlat$ = toStringHDMS(lonlat);
|
||||||
this.store.dispatch(new mapActions.SetLayerValuesLocation(xy[0],xy[1]));
|
this.store.dispatch(new mapActions.SetLayerValuesLocation(xy[0], xy[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
copyToClipboard() {
|
copyToClipboard() {
|
||||||
this.clipboardService$.copy(this.wkt$);
|
this.clipboardService$.copy(this.wkt$);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getScaledValue(layerValue: ILayervalue): number {
|
||||||
|
let v = layerValue.value;
|
||||||
|
if (layerValue.scale && layerValue.scale != 0) {
|
||||||
|
v = layerValue.scale * layerValue.value;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { Store, Action,createFeatureSelector } from '@ngrx/store';
|
import { Store, Action, createFeatureSelector } from '@ngrx/store';
|
||||||
import { ROUTER_NAVIGATED, RouterReducerState } from '@ngrx/router-store';
|
import { ROUTER_NAVIGATED, RouterReducerState } from '@ngrx/router-store';
|
||||||
import * as fromRouter from '@ngrx/router-store';
|
import * as fromRouter from '@ngrx/router-store';
|
||||||
import { createEffect, Actions,ofType } from '@ngrx/effects';
|
import { createEffect, Actions, ofType } from '@ngrx/effects';
|
||||||
|
|
||||||
import { EMPTY, Observable , of} from 'rxjs';
|
import { EMPTY, Observable, of } from 'rxjs';
|
||||||
import { withLatestFrom, switchMap, map, catchError, mergeMap } from 'rxjs/operators';
|
import { withLatestFrom, switchMap, map, catchError, mergeMap } from 'rxjs/operators';
|
||||||
|
|
||||||
import {GeoJSON,WKT} from 'ol/format';
|
import { GeoJSON, WKT } from 'ol/format';
|
||||||
import {Feature} from 'ol';
|
import { Feature } from 'ol';
|
||||||
import { getCenter,createEmpty,extend } from 'ol/extent';
|
import { getCenter, createEmpty, extend } from 'ol/extent';
|
||||||
import {Point,Geometry} from 'ol/geom'
|
import { Point, Geometry } from 'ol/geom'
|
||||||
|
|
||||||
|
|
||||||
import * as mapActions from '../actions/map.actions';
|
import * as mapActions from '../actions/map.actions';
|
||||||
import * as mapReducers from '../reducers/map.reducer';
|
import * as mapReducers from '../reducers/map.reducer';
|
||||||
import {commonReducers} from '@farmmaps/common';
|
import { commonReducers } from '@farmmaps/common';
|
||||||
|
|
||||||
import {commonActions} from '@farmmaps/common';
|
import { commonActions } from '@farmmaps/common';
|
||||||
|
|
||||||
import { IItem } from '@farmmaps/common';
|
import { IItem } from '@farmmaps/common';
|
||||||
import { FolderService, ItemService } from '@farmmaps/common';
|
import { FolderService, ItemService } from '@farmmaps/common';
|
||||||
import { tassign } from 'tassign';
|
import { tassign } from 'tassign';
|
||||||
|
|
||||||
import {FeatureIconService} from '../services/feature-icon.service';
|
import { FeatureIconService } from '../services/feature-icon.service';
|
||||||
|
|
||||||
import * as style from 'ol/style';
|
import * as style from 'ol/style';
|
||||||
|
|
||||||
import { ItemTypeService,IQueryState } from '@farmmaps/common';
|
import { ItemTypeService, IQueryState } from '@farmmaps/common';
|
||||||
import { TemporalItemLayer } from '../models/item.layer'
|
import { TemporalItemLayer } from '../models/item.layer'
|
||||||
|
|
||||||
export const getRouterState = createFeatureSelector<RouterReducerState>('router');
|
export const getRouterState = createFeatureSelector<RouterReducerState>('router');
|
||||||
@ -50,9 +50,9 @@ export class MapEffects {
|
|||||||
private _wktFormat: WKT;
|
private _wktFormat: WKT;
|
||||||
private overrideSelectedItemLayer = false;
|
private overrideSelectedItemLayer = false;
|
||||||
|
|
||||||
private updateFeatureGeometry(feature:Feature<Geometry>, updateEvent:commonActions.DeviceUpdateEvent): Feature<Geometry> {
|
private updateFeatureGeometry(feature: Feature<Geometry>, updateEvent: commonActions.DeviceUpdateEvent): Feature<Geometry> {
|
||||||
const newFeature = feature.clone();
|
const newFeature = feature.clone();
|
||||||
const f = this._wktFormat.readFeature(updateEvent.attributes["geometry"],{
|
const f = this._wktFormat.readFeature(updateEvent.attributes["geometry"], {
|
||||||
dataProjection: 'EPSG:4326',
|
dataProjection: 'EPSG:4326',
|
||||||
featureProjection: 'EPSG:3857'
|
featureProjection: 'EPSG:3857'
|
||||||
});
|
});
|
||||||
@ -62,19 +62,19 @@ export class MapEffects {
|
|||||||
return newFeature;
|
return newFeature;
|
||||||
}
|
}
|
||||||
|
|
||||||
init$ = createEffect(() => this.actions$.pipe(
|
init$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.INIT),
|
ofType(mapActions.INIT),
|
||||||
withLatestFrom(this.store$.select(commonReducers.selectGetRootItems)),
|
withLatestFrom(this.store$.select(commonReducers.selectGetRootItems)),
|
||||||
switchMap(([action, rootItems]) => {
|
switchMap(([action, rootItems]) => {
|
||||||
const actions=[];
|
const actions = [];
|
||||||
for (const rootItem of rootItems) {
|
for (const rootItem of rootItems) {
|
||||||
if (rootItem.itemType == "UPLOADS_FOLDER") actions.push(new mapActions.SetParent(rootItem.code));
|
if (rootItem.itemType == "UPLOADS_FOLDER") actions.push(new mapActions.SetParent(rootItem.code));
|
||||||
}
|
}
|
||||||
// initialize default feature styles
|
// initialize default feature styles
|
||||||
actions.push(new mapActions.SetStyle('file',new style.Style({
|
actions.push(new mapActions.SetStyle('file', new style.Style({
|
||||||
image: new style.Icon({
|
image: new style.Icon({
|
||||||
anchor: [0.5, 1],
|
anchor: [0.5, 1],
|
||||||
scale: 0.05,
|
scale: 0.05,
|
||||||
src: this.featureIconService$.getIconImageDataUrl("fal fa-file")
|
src: this.featureIconService$.getIconImageDataUrl("fal fa-file")
|
||||||
}),
|
}),
|
||||||
stroke: new style.Stroke({
|
stroke: new style.Stroke({
|
||||||
@ -85,7 +85,7 @@ export class MapEffects {
|
|||||||
color: 'rgba(0, 0, 0,0)'
|
color: 'rgba(0, 0, 0,0)'
|
||||||
})
|
})
|
||||||
})));
|
})));
|
||||||
actions.push(new mapActions.SetStyle('selected',new style.Style({
|
actions.push(new mapActions.SetStyle('selected', new style.Style({
|
||||||
image: new style.Icon({
|
image: new style.Icon({
|
||||||
anchor: [0.5, 1],
|
anchor: [0.5, 1],
|
||||||
scale: 0.08,
|
scale: 0.08,
|
||||||
@ -104,13 +104,13 @@ export class MapEffects {
|
|||||||
}
|
}
|
||||||
)));
|
)));
|
||||||
|
|
||||||
initBaseLayers$ = createEffect(() => this.actions$.pipe(
|
initBaseLayers$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.INIT),
|
ofType(mapActions.INIT),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetProjection)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetProjection)),
|
||||||
map(([action, projection]) => new mapActions.LoadBaseLayers(projection)))
|
map(([action, projection]) => new mapActions.LoadBaseLayers(projection)))
|
||||||
);
|
);
|
||||||
|
|
||||||
loadBaseLayers$ = createEffect(() => this.actions$.pipe(
|
loadBaseLayers$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.LOADBASELAYERS),
|
ofType(mapActions.LOADBASELAYERS),
|
||||||
switchMap((action: mapActions.LoadBaseLayers) => {
|
switchMap((action: mapActions.LoadBaseLayers) => {
|
||||||
return this.itemService$.getItemList("vnd.farmmaps.itemtype.layer", { "isBaseLayer": true }).pipe(
|
return this.itemService$.getItemList("vnd.farmmaps.itemtype.layer", { "isBaseLayer": true }).pipe(
|
||||||
@ -118,15 +118,15 @@ export class MapEffects {
|
|||||||
catchError(error => of(new commonActions.Fail(error))));
|
catchError(error => of(new commonActions.Fail(error))));
|
||||||
})));
|
})));
|
||||||
|
|
||||||
startSearch$ = createEffect(() => this.actions$.pipe(
|
startSearch$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.STARTSEARCH),
|
ofType(mapActions.STARTSEARCH),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
const a = action as mapActions.StartSearch;
|
const a = action as mapActions.StartSearch;
|
||||||
const startDate = a.queryState.startDate;
|
const startDate = a.queryState.startDate;
|
||||||
const endDate = a.queryState.endDate;
|
const endDate = a.queryState.endDate;
|
||||||
let newAction:Observable<Action>;
|
let newAction: Observable<Action>;
|
||||||
if (a.queryState.itemCode || a.queryState.parentCode || a.queryState.itemType || a.queryState.query || a.queryState.tags) {
|
if (a.queryState.itemCode || a.queryState.parentCode || a.queryState.itemType || a.queryState.query || a.queryState.tags) {
|
||||||
newAction= this.itemService$.getFeatures(a.queryState.bbox, "EPSG:3857", a.queryState.query, a.queryState.tags, startDate, endDate, a.queryState.itemType, a.queryState.parentCode, a.queryState.dataFilter, a.queryState.level).pipe(
|
newAction = this.itemService$.getFeatures(a.queryState.bbox, "EPSG:3857", a.queryState.query, a.queryState.tags, startDate, endDate, a.queryState.itemType, a.queryState.parentCode, a.queryState.dataFilter, a.queryState.level).pipe(
|
||||||
switchMap((features: any) => {
|
switchMap((features: any) => {
|
||||||
for (const f of features.features) {
|
for (const f of features.features) {
|
||||||
if (f.properties && f.properties["code"]) {
|
if (f.properties && f.properties["code"]) {
|
||||||
@ -144,18 +144,18 @@ export class MapEffects {
|
|||||||
})));
|
})));
|
||||||
|
|
||||||
|
|
||||||
zoomToExtent$ = createEffect(() => this.actions$.pipe(
|
zoomToExtent$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.STARTSEARCHSUCCESS),
|
ofType(mapActions.STARTSEARCHSUCCESS),
|
||||||
mergeMap((action: mapActions.StartSearchSuccess) => {
|
mergeMap((action: mapActions.StartSearchSuccess) => {
|
||||||
const actions =[];
|
const actions = [];
|
||||||
actions.push(new commonActions.SetMenuVisible(false));
|
actions.push(new commonActions.SetMenuVisible(false));
|
||||||
const extent = createEmpty();
|
const extent = createEmpty();
|
||||||
if (!action.query.bboxFilter) {
|
if (!action.query.bboxFilter) {
|
||||||
if (extent) {
|
if (extent) {
|
||||||
for (const f of action.features) {
|
for (const f of action.features) {
|
||||||
extend(extent, (f as Feature<Geometry>).getGeometry().getExtent());
|
extend(extent, (f as Feature<Geometry>).getGeometry().getExtent());
|
||||||
}
|
}
|
||||||
if(action.features && action.features.length >0) {
|
if (action.features && action.features.length > 0) {
|
||||||
actions.push(new mapActions.SetExtent(extent));
|
actions.push(new mapActions.SetExtent(extent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,64 +163,64 @@ export class MapEffects {
|
|||||||
return actions;
|
return actions;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
zoomToExtent2$ = createEffect(() => this.actions$.pipe(
|
zoomToExtent2$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.SETFEATURES),
|
ofType(mapActions.SETFEATURES),
|
||||||
switchMap((action: mapActions.SetFeatures) => {
|
switchMap((action: mapActions.SetFeatures) => {
|
||||||
const extent = createEmpty();
|
const extent = createEmpty();
|
||||||
if (extent) {
|
if (extent) {
|
||||||
for (const f of action.features) {
|
for (const f of action.features) {
|
||||||
extend(extent, (f as Feature<Geometry>).getGeometry().getExtent());
|
extend(extent, (f as Feature<Geometry>).getGeometry().getExtent());
|
||||||
}
|
|
||||||
if(action.features.length>0) return of(new mapActions.SetExtent(extent));
|
|
||||||
}
|
}
|
||||||
return EMPTY;
|
if (action.features.length > 0) return of(new mapActions.SetExtent(extent));
|
||||||
})));
|
}
|
||||||
|
return EMPTY;
|
||||||
|
})));
|
||||||
|
|
||||||
hideMenu$ = createEffect(() => this.actions$.pipe(
|
hideMenu$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.STARTSEARCHSUCCESS),
|
ofType(mapActions.STARTSEARCHSUCCESS),
|
||||||
mergeMap((action: mapActions.StartSearchSuccess) => {
|
mergeMap((action: mapActions.StartSearchSuccess) => {
|
||||||
return of(new commonActions.SetMenuVisible(false));
|
return of(new commonActions.SetMenuVisible(false));
|
||||||
})));
|
})));
|
||||||
|
|
||||||
selectItem$ = createEffect(() => this.actions$.pipe(
|
selectItem$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.SELECTITEM),
|
ofType(mapActions.SELECTITEM),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
||||||
switchMap(([action, selectedItem]) => {
|
switchMap(([action, selectedItem]) => {
|
||||||
const a = action as mapActions.SelectItem;
|
const a = action as mapActions.SelectItem;
|
||||||
const itemCode = selectedItem ? selectedItem.code : "";
|
const itemCode = selectedItem ? selectedItem.code : "";
|
||||||
if (a.itemCode != itemCode) {
|
if (a.itemCode != itemCode) {
|
||||||
return this.itemService$.getItem(a.itemCode).pipe(
|
return this.itemService$.getItem(a.itemCode).pipe(
|
||||||
switchMap(child => {
|
switchMap(child => {
|
||||||
return this.itemService$.getItem(child.parentCode)
|
return this.itemService$.getItem(child.parentCode)
|
||||||
.pipe(map(parent => {
|
.pipe(map(parent => {
|
||||||
return {child, parent};
|
return { child, parent };
|
||||||
}),catchError(() => { const parent:IItem = null;return of({child,parent})})
|
}), catchError(() => { const parent: IItem = null; return of({ child, parent }) })
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
map(data => new mapActions.SelectItemSuccess(data.child, data.parent)),
|
map(data => new mapActions.SelectItemSuccess(data.child, data.parent)),
|
||||||
catchError(error => of(new commonActions.Fail(error))))
|
catchError(error => of(new commonActions.Fail(error))))
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)));
|
)));
|
||||||
|
|
||||||
selectItemSuccessSetLayer$ = createEffect(() => this.actions$.pipe(
|
selectItemSuccessSetLayer$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.SELECTITEMSUCCESS),
|
|
||||||
map((action:mapActions.SelectItemSuccess) =>
|
|
||||||
new mapActions.SetSelectedItemLayer(action.item)
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
selectItemSuccess$ = createEffect(() => this.actions$.pipe(
|
|
||||||
ofType(mapActions.SELECTITEMSUCCESS),
|
ofType(mapActions.SELECTITEMSUCCESS),
|
||||||
switchMap((action:mapActions.SelectItemSuccess) => {
|
map((action: mapActions.SelectItemSuccess) =>
|
||||||
if(!this.overrideSelectedItemLayer) {
|
new mapActions.SetSelectedItemLayer(action.item)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
selectItemSuccess$ = createEffect(() => this.actions$.pipe(
|
||||||
|
ofType(mapActions.SELECTITEMSUCCESS),
|
||||||
|
switchMap((action: mapActions.SelectItemSuccess) => {
|
||||||
|
if (!this.overrideSelectedItemLayer) {
|
||||||
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
||||||
map((feature: any) => {
|
map((feature: any) => {
|
||||||
const f = this._geojsonFormat.readFeature(feature);
|
const f = this._geojsonFormat.readFeature(feature);
|
||||||
f.setId(action.item.code);
|
f.setId(action.item.code);
|
||||||
return new mapActions.AddFeatureSuccess(f );
|
return new mapActions.AddFeatureSuccess(f);
|
||||||
}),
|
}),
|
||||||
catchError(error => of(new commonActions.Fail(error))));
|
catchError(error => of(new commonActions.Fail(error))));
|
||||||
} else {
|
} else {
|
||||||
@ -229,29 +229,29 @@ export class MapEffects {
|
|||||||
}
|
}
|
||||||
)));
|
)));
|
||||||
|
|
||||||
selectItemSuccessTemporal$ = createEffect(() => this.actions$.pipe(
|
selectItemSuccessTemporal$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.SELECTITEMSUCCESS),
|
ofType(mapActions.SELECTITEMSUCCESS),
|
||||||
switchMap((action:mapActions.SelectItemSuccess) => {
|
switchMap((action: mapActions.SelectItemSuccess) => {
|
||||||
if(action.item.itemType == "vnd.farmmaps.itemtype.temporal") {
|
if (action.item.itemType == "vnd.farmmaps.itemtype.temporal") {
|
||||||
return this.itemService$.getChildItemList(action.item.code,null).pipe(
|
return this.itemService$.getChildItemList(action.item.code, null).pipe(
|
||||||
map(items => new mapActions.SelectTemporalItemsSuccess(
|
map(items => new mapActions.SelectTemporalItemsSuccess(
|
||||||
items.sort((a, b) =>
|
items.sort((a, b) =>
|
||||||
-(Date.parse(b.dataDate) - Date.parse(a.dataDate))
|
-(Date.parse(b.dataDate) - Date.parse(a.dataDate))
|
||||||
)
|
)
|
||||||
)),
|
)),
|
||||||
catchError(error => of(new commonActions.Fail(error))));
|
catchError(error => of(new commonActions.Fail(error))));
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)));
|
}
|
||||||
|
|
||||||
uploadedItemClick$ = createEffect(() => this.actions$.pipe(
|
|
||||||
ofType(commonActions.UPLOADEDFILECLICK),
|
|
||||||
switchMap((action: commonActions.UploadedFileClick) => of(new mapActions.DoQuery(tassign(mapReducers.initialState.query.querystate, {itemCode:action.itemCode})))
|
|
||||||
)));
|
)));
|
||||||
|
|
||||||
featureUpdate$ = createEffect(() => this.actions$.pipe(
|
uploadedItemClick$ = createEffect(() => this.actions$.pipe(
|
||||||
|
ofType(commonActions.UPLOADEDFILECLICK),
|
||||||
|
switchMap((action: commonActions.UploadedFileClick) => of(new mapActions.DoQuery(tassign(mapReducers.initialState.query.querystate, { itemCode: action.itemCode })))
|
||||||
|
)));
|
||||||
|
|
||||||
|
featureUpdate$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(commonActions.DEVICEUPDATEEVENT),
|
ofType(commonActions.DEVICEUPDATEEVENT),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)),
|
||||||
mergeMap(([action, features]) => {
|
mergeMap(([action, features]) => {
|
||||||
@ -264,13 +264,13 @@ export class MapEffects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (feature) {
|
if (feature) {
|
||||||
return of(new mapActions.UpdateFeatureSuccess(this.updateFeatureGeometry(feature,deviceUpdateEventAction)));
|
return of(new mapActions.UpdateFeatureSuccess(this.updateFeatureGeometry(feature, deviceUpdateEventAction)));
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
itemUpdate$ = createEffect(() => this.actions$.pipe(
|
itemUpdate$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(commonActions.ITEMCHANGEDEVENT),
|
ofType(commonActions.ITEMCHANGEDEVENT),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
||||||
mergeMap(([action, selectedItem]) => {
|
mergeMap(([action, selectedItem]) => {
|
||||||
@ -280,8 +280,8 @@ export class MapEffects {
|
|||||||
switchMap(child => {
|
switchMap(child => {
|
||||||
return this.itemService$.getItem(child.parentCode)
|
return this.itemService$.getItem(child.parentCode)
|
||||||
.pipe(map(parent => {
|
.pipe(map(parent => {
|
||||||
return {child, parent};
|
return { child, parent };
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
map(data => new mapActions.SelectItemSuccess(data.child, data.parent)),
|
map(data => new mapActions.SelectItemSuccess(data.child, data.parent)),
|
||||||
@ -291,13 +291,13 @@ export class MapEffects {
|
|||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
getActionFromQueryState(queryState:IQueryState, inSearch:boolean):Observable<Action>|[] {
|
getActionFromQueryState(queryState: IQueryState, inSearch: boolean): Observable<Action> | [] {
|
||||||
if(!inSearch && (queryState.itemType || queryState.parentCode || queryState.itemCode || queryState.query || queryState.tags)) {
|
if (!inSearch && (queryState.itemType || queryState.parentCode || queryState.itemCode || queryState.query || queryState.tags)) {
|
||||||
var newAction:Action;
|
var newAction: Action;
|
||||||
if (queryState.itemCode && queryState.itemCode != "") {
|
if (queryState.itemCode && queryState.itemCode != "") {
|
||||||
newAction= new mapActions.SelectItem(queryState.itemCode);
|
newAction = new mapActions.SelectItem(queryState.itemCode);
|
||||||
} else {
|
} else {
|
||||||
newAction= new mapActions.StartSearch(queryState);
|
newAction = new mapActions.StartSearch(queryState);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -306,104 +306,104 @@ export class MapEffects {
|
|||||||
return of(newAction);
|
return of(newAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLayerValue$ = createEffect(() => this.actions$.pipe(
|
getLayerValue$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.GETLAYERVALUE),
|
ofType(mapActions.GETLAYERVALUE),
|
||||||
mergeMap((action:mapActions.GetLayerValue) => {
|
mergeMap((action: mapActions.GetLayerValue) => {
|
||||||
const l = action.itemLayer.item.data["layers"][action.itemLayer.layerIndex];
|
const l = action.itemLayer.item.data["layers"][action.itemLayer.layerIndex];
|
||||||
const scale = l.scale?l.scale:1;
|
const scale = l.scale ? l.scale : 1;
|
||||||
return this.itemService$.getLayerValue(action.itemLayer.item.code,action.itemLayer.layerIndex,action.x,action.y).pipe(
|
return this.itemService$.getLayerValue(action.itemLayer.item.code, action.itemLayer.layerIndex, action.x, action.y).pipe(
|
||||||
mergeMap((v: number) => {
|
mergeMap((v: number) => {
|
||||||
const a=[];
|
const a = [];
|
||||||
if(v !== null) {
|
if (v !== null) {
|
||||||
if(l.renderer && l.renderer.colorMap && l.renderer.colorMap.colormapType == "manual") {
|
if (l.renderer && l.renderer.colorMap && l.renderer.colorMap.colormapType == "manual") {
|
||||||
l.renderer.colorMap.entries.forEach((e) => {
|
l.renderer.colorMap.entries.forEach((e) => {
|
||||||
if(e.value == v && e.label) {
|
if (e.value == v && e.label) {
|
||||||
v=e.label;
|
v = e.label;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
a.push(new mapActions.GetLayerValueSuccess({date:action.itemLayer.item.dataDate,value:v,layerName:l.name,quantity:"",unit:l.unit}));
|
a.push(new mapActions.GetLayerValueSuccess({ date: action.itemLayer.item.dataDate, value: v, layerName: l.name, quantity: "", unit: l.unit, scale: l.scale }));
|
||||||
} else {
|
} else {
|
||||||
a.push(new mapActions.GetLayerValueSuccess({date:action.itemLayer.item.dataDate,value:v*scale,layerName:l.name,quantity:l.quantity,unit:l.unit}));
|
a.push(new mapActions.GetLayerValueSuccess({ date: action.itemLayer.item.dataDate, value: v * scale, layerName: l.name, quantity: l.quantity, unit: l.unit, scale: l.scale }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
)));
|
)));
|
||||||
|
|
||||||
updateLayerValuesOnLayerAddedOrRemoved$ = createEffect(() => this.actions$.pipe(
|
updateLayerValuesOnLayerAddedOrRemoved$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.ADDLAYER,mapActions.REMOVELAYER,mapActions.SELECTITEMSUCCESS,mapActions.SELECTTEMPORALITEMSSUCCESS, mapActions.NEXTTEMPORAL,mapActions.PREVIOUSTEMPORAL,mapActions.TOGGLELAYERVALUESENABLED,mapActions.SETLAYERINDEX,mapActions.SETSELECTEDITEMLAYER),
|
ofType(mapActions.ADDLAYER, mapActions.REMOVELAYER, mapActions.SELECTITEMSUCCESS, mapActions.SELECTTEMPORALITEMSSUCCESS, mapActions.NEXTTEMPORAL, mapActions.PREVIOUSTEMPORAL, mapActions.TOGGLELAYERVALUESENABLED, mapActions.SETLAYERINDEX, mapActions.SETSELECTEDITEMLAYER),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesX)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesX)),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesY)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesY)),
|
||||||
map(([[action,x],y]) => new mapActions.SetLayerValuesLocation(x,y))
|
map(([[action, x], y]) => new mapActions.SetLayerValuesLocation(x, y))
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
getLayerValues$ = createEffect(() => this.actions$.pipe(
|
getLayerValues$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.SETLAYERVALUESLOCATION),
|
ofType(mapActions.SETLAYERVALUESLOCATION),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItemLayer)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItemLayer)),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesEnabled)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesEnabled)),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetOverlayLayers)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetOverlayLayers)),
|
||||||
mergeMap(([[[action, selected], enabled],overlayLayers]) => {
|
mergeMap(([[[action, selected], enabled], overlayLayers]) => {
|
||||||
const layers = [];
|
const layers = [];
|
||||||
if(selected) {
|
if (selected) {
|
||||||
if(selected && (selected as TemporalItemLayer).selectedItemLayer ) {
|
if (selected && (selected as TemporalItemLayer).selectedItemLayer) {
|
||||||
selected=(selected as TemporalItemLayer).selectedItemLayer;
|
selected = (selected as TemporalItemLayer).selectedItemLayer;
|
||||||
}
|
}
|
||||||
layers.push(selected);
|
layers.push(selected);
|
||||||
}
|
}
|
||||||
overlayLayers.forEach((ol) => {
|
overlayLayers.forEach((ol) => {
|
||||||
if(ol!=selected) layers.push(ol);
|
if (ol != selected) layers.push(ol);
|
||||||
});
|
});
|
||||||
const a = action as mapActions.SetLayerValuesLocation;
|
const a = action as mapActions.SetLayerValuesLocation;
|
||||||
const actions = [];
|
const actions = [];
|
||||||
if(enabled) {
|
if (enabled) {
|
||||||
layers.forEach((ol) => {
|
layers.forEach((ol) => {
|
||||||
if("vnd.farmmaps.itemtype.shape.processed,vnd.farmmaps.itemtype.geotiff.processed".indexOf(ol.item.itemType)>=0) {
|
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));
|
actions.push(new mapActions.GetLayerValue(ol, a.x, a.y));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return actions;
|
return actions;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
|
||||||
setState$ = createEffect(() => this.actions$.pipe(
|
setState$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.SETSTATE),
|
ofType(mapActions.SETSTATE),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetInSearch)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetInSearch)),
|
||||||
switchMap(([action,inSearch]) => {
|
switchMap(([action, inSearch]) => {
|
||||||
const a = action as mapActions.SetState;
|
const a = action as mapActions.SetState;
|
||||||
return this.getActionFromQueryState(a.queryState,inSearch);
|
return this.getActionFromQueryState(a.queryState, inSearch);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
escape$ = createEffect(() => this.actions$.pipe(
|
escape$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(commonActions.ESCAPE),
|
ofType(commonActions.ESCAPE),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
const a = action as commonActions.Escape;
|
const a = action as commonActions.Escape;
|
||||||
if(a.escapeKey) {
|
if (a.escapeKey) {
|
||||||
return of(new mapActions.Clear());
|
return of(new mapActions.Clear());
|
||||||
} else {
|
} else {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
setOverride$ = createEffect(() => this.actions$.pipe(
|
setOverride$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(ROUTER_NAVIGATED),
|
ofType(ROUTER_NAVIGATED),
|
||||||
switchMap(() => this.store$.select(selectRouteData as any)),
|
switchMap(() => this.store$.select(selectRouteData as any)),
|
||||||
switchMap((data: any) => {
|
switchMap((data: any) => {
|
||||||
if(data && data["fm-map-map"]) {
|
if (data && data["fm-map-map"]) {
|
||||||
const params = data["fm-map-map"];
|
const params = data["fm-map-map"];
|
||||||
this.overrideSelectedItemLayer = params["overrideSelectedItemlayer"] ? params["overrideSelectedItemlayer"] : false;
|
this.overrideSelectedItemLayer = params["overrideSelectedItemlayer"] ? params["overrideSelectedItemlayer"] : false;
|
||||||
} else {
|
} else {
|
||||||
this.overrideSelectedItemLayer = false;
|
this.overrideSelectedItemLayer = false;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
})
|
})
|
||||||
));
|
));
|
||||||
|
|
||||||
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService,private featureIconService$:FeatureIconService,private itemTypeService$:ItemTypeService) {
|
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService, private featureIconService$: FeatureIconService, private itemTypeService$: ItemTypeService) {
|
||||||
this._geojsonFormat = new GeoJSON();
|
this._geojsonFormat = new GeoJSON();
|
||||||
this._wktFormat = new WKT();
|
this._wktFormat = new WKT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
export interface ILayervalue {
|
export interface ILayervalue {
|
||||||
date:string;
|
date: string;
|
||||||
layerName:string;
|
layerName: string;
|
||||||
unit:string;
|
unit: string;
|
||||||
quantity:string;
|
quantity: string;
|
||||||
value:number;
|
value: number;
|
||||||
|
scale: number;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user