Implement device update event
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
This commit is contained in:
parent
2e0b090fb7
commit
615872992f
12
package-lock.json
generated
12
package-lock.json
generated
@ -1943,9 +1943,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@farmmaps/common": {
|
"@farmmaps/common": {
|
||||||
"version": "0.0.1-prerelease.83",
|
"version": "0.0.1-prerelease.90",
|
||||||
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common/-/common-0.0.1-prerelease.83.tgz",
|
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common/-/common-0.0.1-prerelease.90.tgz",
|
||||||
"integrity": "sha512-JQryEA79ELg9hFYBYBIyEQD0bv5oHTX6Uch2nRaOlLhaiXbo6g/F4UYdRnLGTo7nzIPD1wcLcZQorfSMOhYPyQ==",
|
"integrity": "sha512-uSB9cJ06aJtfftQ/Yw6qR+LeeOAP1ly6JGxW6ubr/9hEqub38w+BPsQQYD5Sxn/oLjknRwhzEMZKYWTINF4zXw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"angular-oauth2-oidc": "^8.0.2",
|
"angular-oauth2-oidc": "^8.0.2",
|
||||||
"ngx-uploadx": "^3.3.2",
|
"ngx-uploadx": "^3.3.2",
|
||||||
@ -1953,9 +1953,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@farmmaps/common-map": {
|
"@farmmaps/common-map": {
|
||||||
"version": "0.0.1-prerelease.83",
|
"version": "0.0.1-prerelease.90",
|
||||||
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common-map/-/common-map-0.0.1-prerelease.83.tgz",
|
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common-map/-/common-map-0.0.1-prerelease.90.tgz",
|
||||||
"integrity": "sha512-tILDqqj+ucSipvxJws3tLlZ4ytewqfmZzTmS07O0YhTFqx7+4WzkW8kL8S8vx3t3rB/ZPoAMa9u+w6G2WQ6nCw==",
|
"integrity": "sha512-z1q8cHFNrrAQx8n8dXW2cn9d3wxG9oruPSoNgUrgz+YYJkxeDr0kd3SqloftPJrVxES0iIiqguweo0SRyBGVYA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"ngx-openlayers": "1.0.0-next.13",
|
"ngx-openlayers": "1.0.0-next.13",
|
||||||
"ol": "^6.0.0",
|
"ol": "^6.0.0",
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
"@angular/platform-browser-dynamic": "~8.2.14",
|
"@angular/platform-browser-dynamic": "~8.2.14",
|
||||||
"@angular/router": "~8.2.14",
|
"@angular/router": "~8.2.14",
|
||||||
"@aspnet/signalr": "^1.1.4",
|
"@aspnet/signalr": "^1.1.4",
|
||||||
"@farmmaps/common": ">=0.0.1-prerelease.83 <0.0.1",
|
"@farmmaps/common": ">=0.0.1-prerelease.90 <0.0.1",
|
||||||
"@farmmaps/common-map": ">=0.0.1-prerelease.83 <0.0.1",
|
"@farmmaps/common-map": ">=0.0.1-prerelease.90 <0.0.1",
|
||||||
"@ng-bootstrap/ng-bootstrap": "^4.2.1",
|
"@ng-bootstrap/ng-bootstrap": "^4.2.1",
|
||||||
"@ngrx/effects": "^8.2.0",
|
"@ngrx/effects": "^8.2.0",
|
||||||
"@ngrx/router-store": "^8.2.0",
|
"@ngrx/router-store": "^8.2.0",
|
||||||
|
@ -15,6 +15,6 @@
|
|||||||
"@ngrx/router-store": "^8.2",
|
"@ngrx/router-store": "^8.2",
|
||||||
"@ngrx/store": "^8.2",
|
"@ngrx/store": "^8.2",
|
||||||
"tassign": "^1.0.0",
|
"tassign": "^1.0.0",
|
||||||
"@farmmaps/common": ">=0.0.1-prerelease.82 <0.0.1"
|
"@farmmaps/common": ">=0.0.1-prerelease.90 <0.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { Effect, Actions,ofType } from '@ngrx/effects';
|
|||||||
import { Observable , of } from 'rxjs';
|
import { Observable , of } from 'rxjs';
|
||||||
import { withLatestFrom, switchMap, map, catchError, mergeMap, delay} from 'rxjs/operators';
|
import { withLatestFrom, switchMap, map, catchError, mergeMap, delay} from 'rxjs/operators';
|
||||||
|
|
||||||
import {GeoJSON} from 'ol/format';
|
import {GeoJSON,WKT} from 'ol/format';
|
||||||
import {Feature} from 'ol';
|
import {Feature} from 'ol';
|
||||||
import { getCenter, Extent, createEmpty, extend} from 'ol/extent';
|
import { getCenter, Extent, createEmpty, extend} from 'ol/extent';
|
||||||
import {Point} from 'ol/geom'
|
import {Point} from 'ol/geom'
|
||||||
@ -25,10 +25,15 @@ import { tassign } from 'tassign';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MapEffects {
|
export class MapEffects {
|
||||||
private _format: GeoJSON;
|
private _geojsonFormat: GeoJSON;
|
||||||
|
private _wktFormat: WKT;
|
||||||
|
|
||||||
private toPointFeature(feature: any): Feature {
|
private toPointFeature(updateEvent:commonActions.DeviceUpdateEvent): Feature {
|
||||||
var f = this._format.readFeature(feature);
|
var f = this._wktFormat.readFeature(updateEvent.attributes["geometry"],{
|
||||||
|
dataProjection: 'EPSG:4326',
|
||||||
|
featureProjection: 'EPSG:3857'
|
||||||
|
});
|
||||||
|
f.setId(updateEvent.itemCode);
|
||||||
var centroid = getCenter(f.getGeometry().getExtent());
|
var centroid = getCenter(f.getGeometry().getExtent());
|
||||||
f.setGeometry(new Point(centroid));
|
f.setGeometry(new Point(centroid));
|
||||||
return f;
|
return f;
|
||||||
@ -83,7 +88,7 @@ export class MapEffects {
|
|||||||
f.id = f.properties["code"];
|
f.id = f.properties["code"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return of(new mapActions.StartSearchSuccess(this._format.readFeatures(features), action.queryState));
|
return of(new mapActions.StartSearchSuccess(this._geojsonFormat.readFeatures(features), action.queryState));
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
catchError(error => of(new commonActions.Fail(error))));
|
catchError(error => of(new commonActions.Fail(error))));
|
||||||
@ -135,7 +140,11 @@ export class MapEffects {
|
|||||||
ofType(mapActions.SELECTITEMSUCCESS),
|
ofType(mapActions.SELECTITEMSUCCESS),
|
||||||
switchMap((action:mapActions.SelectItemSuccess) => {
|
switchMap((action:mapActions.SelectItemSuccess) => {
|
||||||
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
||||||
map((feature: IItem) => new mapActions.AddFeatureSuccess(this._format.readFeature(feature) )),
|
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))));
|
catchError(error => of(new commonActions.Fail(error))));
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
@ -163,21 +172,19 @@ export class MapEffects {
|
|||||||
|
|
||||||
@Effect()
|
@Effect()
|
||||||
featureUpdate$: Observable<Action> = this.actions$.pipe(
|
featureUpdate$: Observable<Action> = this.actions$.pipe(
|
||||||
ofType(commonActions.ITEMCHANGEDEVENT),
|
ofType(commonActions.DEVICEUPDATEEVENT),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)),
|
||||||
mergeMap(([action, features]) => {
|
mergeMap(([action, features]) => {
|
||||||
let itemChangedAction = action as commonActions.ItemChangedEvent;
|
let deviceUpdateEventAction = action as commonActions.DeviceUpdateEvent;
|
||||||
var feature: Feature = null;
|
var feature: Feature = null;
|
||||||
for (let f of features) {
|
for (let f of features) {
|
||||||
if (f.get("code") == itemChangedAction.itemCode) {
|
if (f.getId() == deviceUpdateEventAction.itemCode) {
|
||||||
feature = f;
|
feature = f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (feature) {
|
if (feature) {
|
||||||
return this.itemService$.getFeature(itemChangedAction.itemCode, "EPSG:3857").pipe(
|
return of(new mapActions.UpdateFeatureSuccess(this.toPointFeature(deviceUpdateEventAction)));
|
||||||
map((feature: any) => new mapActions.UpdateFeatureSuccess(this.toPointFeature(feature))),
|
|
||||||
catchError(error => of(new commonActions.Fail(error))));
|
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@ -225,6 +232,7 @@ export class MapEffects {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService) {
|
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService) {
|
||||||
this._format = new GeoJSON();
|
this._geojsonFormat = new GeoJSON();
|
||||||
|
this._wktFormat = new WKT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,372 +1,372 @@
|
|||||||
import { tassign } from 'tassign';
|
import { tassign } from 'tassign';
|
||||||
import { IItem,Item } from '@farmmaps/common';
|
import { IItem,Item } from '@farmmaps/common';
|
||||||
import { IItemLayer,ItemLayer} from '../models/item.layer';
|
import { IItemLayer,ItemLayer} from '../models/item.layer';
|
||||||
import { IMapState} from '../models/map.state';
|
import { IMapState} from '../models/map.state';
|
||||||
import { IQueryState} from '../models/query.state';
|
import { IQueryState} from '../models/query.state';
|
||||||
import { IPeriodState} from '../models/period.state';
|
import { IPeriodState} from '../models/period.state';
|
||||||
import * as mapActions from '../actions/map.actions';
|
import * as mapActions from '../actions/map.actions';
|
||||||
import {commonActions} from '@farmmaps/common';
|
import {commonActions} from '@farmmaps/common';
|
||||||
import { createSelector, createFeatureSelector } from '@ngrx/store';
|
import { createSelector, createFeatureSelector } from '@ngrx/store';
|
||||||
|
|
||||||
import {Feature} from 'ol';
|
import {Feature} from 'ol';
|
||||||
|
|
||||||
import { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';
|
import { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';
|
||||||
|
|
||||||
import { MODULE_NAME } from '../module-name';
|
import { MODULE_NAME } from '../module-name';
|
||||||
|
|
||||||
const startDate:Date = new Date(new Date(Date.now()).getFullYear(), new Date(Date.now()).getMonth() - 3, 1);
|
const startDate:Date = new Date(new Date(Date.now()).getFullYear(), new Date(Date.now()).getMonth() - 3, 1);
|
||||||
const endDate:Date = new Date(Date.now());
|
const endDate:Date = new Date(Date.now());
|
||||||
|
|
||||||
export const initialQueryState: IQueryState = {
|
export const initialQueryState: IQueryState = {
|
||||||
itemCode: null,
|
itemCode: null,
|
||||||
parentCode: null,
|
parentCode: null,
|
||||||
level: 1,
|
level: 1,
|
||||||
itemType: null,
|
itemType: null,
|
||||||
bboxFilter: false,
|
bboxFilter: false,
|
||||||
query: null,
|
query: null,
|
||||||
tags: null,
|
tags: null,
|
||||||
endDate: null,
|
endDate: null,
|
||||||
startDate: null,
|
startDate: null,
|
||||||
bbox: []
|
bbox: []
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
period:IPeriodState,
|
period:IPeriodState,
|
||||||
mapState: IMapState,
|
mapState: IMapState,
|
||||||
viewExtent: number[],
|
viewExtent: number[],
|
||||||
queryState: IQueryState,
|
queryState: IQueryState,
|
||||||
query:IQueryState,
|
query:IQueryState,
|
||||||
parentCode: string,
|
parentCode: string,
|
||||||
features: Array<Feature>,
|
features: Array<Feature>,
|
||||||
panelVisible: boolean,
|
panelVisible: boolean,
|
||||||
panelCollapsed: boolean,
|
panelCollapsed: boolean,
|
||||||
selectedFeature: Feature,
|
selectedFeature: Feature,
|
||||||
selectedItem:IItem,
|
selectedItem:IItem,
|
||||||
clearEnabled: boolean,
|
clearEnabled: boolean,
|
||||||
searchCollapsed: boolean,
|
searchCollapsed: boolean,
|
||||||
searchMinified: boolean,
|
searchMinified: boolean,
|
||||||
menuVisible: boolean,
|
menuVisible: boolean,
|
||||||
extent: number[],
|
extent: number[],
|
||||||
baseLayers: Array<IItemLayer>
|
baseLayers: Array<IItemLayer>
|
||||||
overlayLayers: Array<IItemLayer>,
|
overlayLayers: Array<IItemLayer>,
|
||||||
selectedItemLayer: IItemLayer,
|
selectedItemLayer: IItemLayer,
|
||||||
projection: string,
|
projection: string,
|
||||||
selectedBaseLayer: IItemLayer,
|
selectedBaseLayer: IItemLayer,
|
||||||
selectedOverlayLayer: IItemLayer
|
selectedOverlayLayer: IItemLayer
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initialState: State = {
|
export const initialState: State = {
|
||||||
period: {
|
period: {
|
||||||
startDate: startDate,
|
startDate: startDate,
|
||||||
endDate: endDate
|
endDate: endDate
|
||||||
},
|
},
|
||||||
mapState: {
|
mapState: {
|
||||||
zoom: 8,
|
zoom: 8,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
xCenter: 5.377554,
|
xCenter: 5.377554,
|
||||||
yCenter: 52.162422,
|
yCenter: 52.162422,
|
||||||
baseLayerCode: ""
|
baseLayerCode: ""
|
||||||
},
|
},
|
||||||
viewExtent:[],
|
viewExtent:[],
|
||||||
queryState: tassign(initialQueryState),
|
queryState: tassign(initialQueryState),
|
||||||
query: tassign(initialQueryState),
|
query: tassign(initialQueryState),
|
||||||
parentCode: null,
|
parentCode: null,
|
||||||
features: [],
|
features: [],
|
||||||
panelVisible: false,
|
panelVisible: false,
|
||||||
panelCollapsed: false,
|
panelCollapsed: false,
|
||||||
selectedFeature: null,
|
selectedFeature: null,
|
||||||
selectedItem: null,
|
selectedItem: null,
|
||||||
clearEnabled: false,
|
clearEnabled: false,
|
||||||
searchCollapsed: true,
|
searchCollapsed: true,
|
||||||
searchMinified:false,
|
searchMinified:false,
|
||||||
menuVisible: true,
|
menuVisible: true,
|
||||||
extent: null,
|
extent: null,
|
||||||
baseLayers: [],
|
baseLayers: [],
|
||||||
overlayLayers: [],
|
overlayLayers: [],
|
||||||
projection: "EPSG:3857",
|
projection: "EPSG:3857",
|
||||||
selectedBaseLayer: null,
|
selectedBaseLayer: null,
|
||||||
selectedOverlayLayer: null,
|
selectedOverlayLayer: null,
|
||||||
selectedItemLayer: null
|
selectedItemLayer: null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
|
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ROUTER_NAVIGATION: {
|
case ROUTER_NAVIGATION: {
|
||||||
let a = action as RouterNavigationAction;
|
let a = action as RouterNavigationAction;
|
||||||
return tassign(state);
|
return tassign(state);
|
||||||
}
|
}
|
||||||
case mapActions.SETMAPSTATE: {
|
case mapActions.SETMAPSTATE: {
|
||||||
let a = action as mapActions.SetMapState;
|
let a = action as mapActions.SetMapState;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
mapState: a.mapState
|
mapState: a.mapState
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SETQUERYSTATE: {
|
case mapActions.SETQUERYSTATE: {
|
||||||
let a = action as mapActions.SetQueryState;
|
let a = action as mapActions.SetQueryState;
|
||||||
return tassign(state, { queryState: tassign(a.queryState )});
|
return tassign(state, { queryState: tassign(a.queryState )});
|
||||||
}
|
}
|
||||||
case mapActions.SETSTATE: {
|
case mapActions.SETSTATE: {
|
||||||
let a = action as mapActions.SetState;
|
let a = action as mapActions.SetState;
|
||||||
return tassign(state, { mapState: tassign(a.mapState), queryState: tassign(a.queryState)});
|
return tassign(state, { mapState: tassign(a.mapState), queryState: tassign(a.queryState)});
|
||||||
}
|
}
|
||||||
case mapActions.SETVIEWEXTENT: {
|
case mapActions.SETVIEWEXTENT: {
|
||||||
let a = action as mapActions.SetViewExtent;
|
let a = action as mapActions.SetViewExtent;
|
||||||
return tassign(state, { viewExtent: a.extent });
|
return tassign(state, { viewExtent: a.extent });
|
||||||
}
|
}
|
||||||
case mapActions.SETPARENT: {
|
case mapActions.SETPARENT: {
|
||||||
let a = action as mapActions.SetParent;
|
let a = action as mapActions.SetParent;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
parentCode : a.parentCode
|
parentCode : a.parentCode
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.STARTSEARCHSUCCESS: {
|
case mapActions.STARTSEARCHSUCCESS: {
|
||||||
let a = action as mapActions.StartSearchSuccess;
|
let a = action as mapActions.StartSearchSuccess;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
panelVisible: true,
|
panelVisible: true,
|
||||||
clearEnabled: true,
|
clearEnabled: true,
|
||||||
searchMinified: true,
|
searchMinified: true,
|
||||||
features: a.features
|
features: a.features
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SELECTFEATURE: {
|
case mapActions.SELECTFEATURE: {
|
||||||
let a = action as mapActions.SelectFeature;
|
let a = action as mapActions.SelectFeature;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
selectedFeature: state.selectedItem?state.selectedFeature: a.feature
|
selectedFeature: state.selectedItem?state.selectedFeature: a.feature
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SELECTITEM: {
|
case mapActions.SELECTITEM: {
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
selectedItem: null,
|
selectedItem: null,
|
||||||
searchMinified:false,
|
searchMinified:false,
|
||||||
selectedItemLayer: null,
|
selectedItemLayer: null,
|
||||||
features:[]
|
features:[]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SELECTITEMSUCCESS: {
|
case mapActions.SELECTITEMSUCCESS: {
|
||||||
let a = action as mapActions.SelectItemSuccess;
|
let a = action as mapActions.SelectItemSuccess;
|
||||||
var itemLayer = null;
|
var itemLayer = null;
|
||||||
if (a.item && "vnd.farmmaps.itemtype.layer,vnd.farmmaps.itemtype.shape.processed,vnd.farmmaps.itemtype.geotiff.processed".indexOf(a.item.itemType) >=0 ) {
|
if (a.item && "vnd.farmmaps.itemtype.layer,vnd.farmmaps.itemtype.shape.processed,vnd.farmmaps.itemtype.geotiff.processed".indexOf(a.item.itemType) >=0 ) {
|
||||||
itemLayer = new ItemLayer(a.item);
|
itemLayer = new ItemLayer(a.item);
|
||||||
}
|
}
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
selectedItem: a.item,
|
selectedItem: a.item,
|
||||||
selectedItemLayer: itemLayer,
|
selectedItemLayer: itemLayer,
|
||||||
panelVisible: a.item != null,
|
panelVisible: a.item != null,
|
||||||
clearEnabled: a.item != null,
|
clearEnabled: a.item != null,
|
||||||
searchCollapsed: false,
|
searchCollapsed: false,
|
||||||
searchMinified: true,
|
searchMinified: true,
|
||||||
queryState: tassign(state.queryState, {itemCode:a.item ? a.item.code:null})
|
queryState: tassign(state.queryState, {itemCode:a.item ? a.item.code:null})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.STARTSEARCH: {
|
case mapActions.STARTSEARCH: {
|
||||||
let a = action as mapActions.StartSearch;
|
let a = action as mapActions.StartSearch;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
selectedItem: null,
|
selectedItem: null,
|
||||||
selectedItemLayer:null,
|
selectedItemLayer:null,
|
||||||
queryState: tassign(a.queryState),
|
queryState: tassign(a.queryState),
|
||||||
searchCollapsed: false,
|
searchCollapsed: false,
|
||||||
searchMinified: true,
|
searchMinified: true,
|
||||||
menuVisible:false
|
menuVisible:false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.DOQUERY: {
|
case mapActions.DOQUERY: {
|
||||||
let a = action as mapActions.DoQuery;
|
let a = action as mapActions.DoQuery;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
query: tassign(a.query, { bbox: a.query.bboxFilter ? state.viewExtent : [] })});
|
query: tassign(a.query, { bbox: a.query.bboxFilter ? state.viewExtent : [] })});
|
||||||
}
|
}
|
||||||
case mapActions.ADDFEATURESUCCESS: {
|
case mapActions.ADDFEATURESUCCESS: {
|
||||||
let a = action as mapActions.AddFeatureSuccess;
|
let a = action as mapActions.AddFeatureSuccess;
|
||||||
let features = state.features.slice();
|
let features = state.features.slice();
|
||||||
features.push(a.feature);
|
features.push(a.feature);
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
panelVisible: true,
|
panelVisible: true,
|
||||||
selectedFeature: a.feature,
|
selectedFeature: a.feature,
|
||||||
menuVisible: false,
|
menuVisible: false,
|
||||||
extent: a.feature.getGeometry().getExtent(),
|
extent: a.feature.getGeometry().getExtent(),
|
||||||
searchCollapsed: false,
|
searchCollapsed: false,
|
||||||
clearEnabled:true,
|
clearEnabled:true,
|
||||||
features:features
|
features:features
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.UPDATEFEATURESUCCESS: {
|
case mapActions.UPDATEFEATURESUCCESS: {
|
||||||
let a = action as mapActions.UpdateFeatureSuccess;
|
let a = action as mapActions.UpdateFeatureSuccess;
|
||||||
let features: any[] = [];
|
let features: any[] = [];
|
||||||
var index = -1;
|
var index = -1;
|
||||||
for (var i = 0; i < state.features.length; i++) {
|
for (var i = 0; i < state.features.length; i++) {
|
||||||
if (state.features[i].get("code") == a.feature.get("code")) {
|
if (state.features[i].getId() == a.feature.getId()) {
|
||||||
features.push(a.feature);
|
features.push(a.feature);
|
||||||
} else {
|
} else {
|
||||||
features.push(state.features[i]);
|
features.push(state.features[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tassign(state, { features: features });
|
return tassign(state, { features: features });
|
||||||
}
|
}
|
||||||
case mapActions.EXPANDSEARCH: {
|
case mapActions.EXPANDSEARCH: {
|
||||||
return tassign(state, { searchCollapsed: false });
|
return tassign(state, { searchCollapsed: false });
|
||||||
}
|
}
|
||||||
case mapActions.COLLAPSESEARCH: {
|
case mapActions.COLLAPSESEARCH: {
|
||||||
return tassign(state, { searchCollapsed: state.panelVisible ? false: true});
|
return tassign(state, { searchCollapsed: state.panelVisible ? false: true});
|
||||||
}
|
}
|
||||||
case mapActions.TOGGLEMENU: {
|
case mapActions.TOGGLEMENU: {
|
||||||
return tassign(state, { menuVisible: !state.menuVisible });
|
return tassign(state, { menuVisible: !state.menuVisible });
|
||||||
}
|
}
|
||||||
case mapActions.SETEXTENT: {
|
case mapActions.SETEXTENT: {
|
||||||
let a = action as mapActions.SetExtent;
|
let a = action as mapActions.SetExtent;
|
||||||
return tassign(state, { extent: a.extent });
|
return tassign(state, { extent: a.extent });
|
||||||
}
|
}
|
||||||
case mapActions.ADDLAYER: {
|
case mapActions.ADDLAYER: {
|
||||||
let a = action as mapActions.AddLayer;
|
let a = action as mapActions.AddLayer;
|
||||||
let itemLayers = state.overlayLayers.slice(0);
|
let itemLayers = state.overlayLayers.slice(0);
|
||||||
let itemLayer = new ItemLayer(a.item);
|
let itemLayer = new ItemLayer(a.item);
|
||||||
itemLayer.layerIndex = a.layerIndex == -1 ? 0 : a.layerIndex;
|
itemLayer.layerIndex = a.layerIndex == -1 ? 0 : a.layerIndex;
|
||||||
itemLayers.push(itemLayer);
|
itemLayers.push(itemLayer);
|
||||||
return tassign(state, { overlayLayers: itemLayers, selectedOverlayLayer: itemLayer });
|
return tassign(state, { overlayLayers: itemLayers, selectedOverlayLayer: itemLayer });
|
||||||
}
|
}
|
||||||
case mapActions.REMOVELAYER: {
|
case mapActions.REMOVELAYER: {
|
||||||
let a = action as mapActions.RemoveLayer;
|
let a = action as mapActions.RemoveLayer;
|
||||||
let newLayers = state.overlayLayers.slice(0);
|
let newLayers = state.overlayLayers.slice(0);
|
||||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
let i = state.overlayLayers.indexOf(a.itemLayer);
|
||||||
var selectedOverlayLayer: IItemLayer = null;
|
var selectedOverlayLayer: IItemLayer = null;
|
||||||
if (i>0 && state.overlayLayers.length > 1)
|
if (i>0 && state.overlayLayers.length > 1)
|
||||||
selectedOverlayLayer = state.overlayLayers[i - 1];
|
selectedOverlayLayer = state.overlayLayers[i - 1];
|
||||||
else if (i == 0 && state.overlayLayers.length > 1)
|
else if (i == 0 && state.overlayLayers.length > 1)
|
||||||
selectedOverlayLayer = state.overlayLayers[i + 1];
|
selectedOverlayLayer = state.overlayLayers[i + 1];
|
||||||
newLayers.splice(i, 1);
|
newLayers.splice(i, 1);
|
||||||
return tassign(state, { overlayLayers: newLayers, selectedOverlayLayer: selectedOverlayLayer });
|
return tassign(state, { overlayLayers: newLayers, selectedOverlayLayer: selectedOverlayLayer });
|
||||||
}
|
}
|
||||||
case mapActions.SETVISIBILITY: {
|
case mapActions.SETVISIBILITY: {
|
||||||
let a = action as mapActions.SetVisibility;
|
let a = action as mapActions.SetVisibility;
|
||||||
let newLayers = state.overlayLayers.slice(0);
|
let newLayers = state.overlayLayers.slice(0);
|
||||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
let i = state.overlayLayers.indexOf(a.itemLayer);
|
||||||
newLayers[i].visible = a.visibility;
|
newLayers[i].visible = a.visibility;
|
||||||
return tassign(state, { overlayLayers: newLayers });
|
return tassign(state, { overlayLayers: newLayers });
|
||||||
}
|
}
|
||||||
case mapActions.SETOPACITY: {
|
case mapActions.SETOPACITY: {
|
||||||
let a = action as mapActions.SetOpacity;
|
let a = action as mapActions.SetOpacity;
|
||||||
let newLayers = state.overlayLayers.slice(0);
|
let newLayers = state.overlayLayers.slice(0);
|
||||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
let i = state.overlayLayers.indexOf(a.itemLayer);
|
||||||
newLayers[i].opacity = a.opacity;
|
newLayers[i].opacity = a.opacity;
|
||||||
return tassign(state, { overlayLayers: newLayers });
|
return tassign(state, { overlayLayers: newLayers });
|
||||||
}
|
}
|
||||||
case mapActions.SETLAYERINDEX: {
|
case mapActions.SETLAYERINDEX: {
|
||||||
let a = action as mapActions.SetLayerIndex;
|
let a = action as mapActions.SetLayerIndex;
|
||||||
if (a.itemLayer == null) {
|
if (a.itemLayer == null) {
|
||||||
var newItemlayer = new ItemLayer(state.selectedItemLayer.item);
|
var newItemlayer = new ItemLayer(state.selectedItemLayer.item);
|
||||||
newItemlayer.layerIndex = a.layerIndex;
|
newItemlayer.layerIndex = a.layerIndex;
|
||||||
return tassign(state, { selectedItemLayer: newItemlayer})
|
return tassign(state, { selectedItemLayer: newItemlayer})
|
||||||
} else {
|
} else {
|
||||||
let newLayers = state.overlayLayers.slice(0);
|
let newLayers = state.overlayLayers.slice(0);
|
||||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
let i = state.overlayLayers.indexOf(a.itemLayer);
|
||||||
newLayers[i].layerIndex = a.layerIndex;
|
newLayers[i].layerIndex = a.layerIndex;
|
||||||
return tassign(state, { overlayLayers: newLayers });
|
return tassign(state, { overlayLayers: newLayers });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case mapActions.LOADBASELAYERSSUCCESS: {
|
case mapActions.LOADBASELAYERSSUCCESS: {
|
||||||
let a =action as mapActions.LoadBaseLayersSuccess;
|
let a =action as mapActions.LoadBaseLayersSuccess;
|
||||||
let baseLayers:ItemLayer[] = [];
|
let baseLayers:ItemLayer[] = [];
|
||||||
for (let item of a.items) {
|
for (let item of a.items) {
|
||||||
var l = new ItemLayer(item);
|
var l = new ItemLayer(item);
|
||||||
l.visible = false;
|
l.visible = false;
|
||||||
baseLayers.push(l);
|
baseLayers.push(l);
|
||||||
}
|
}
|
||||||
var selectedBaseLayer: IItemLayer = null;
|
var selectedBaseLayer: IItemLayer = null;
|
||||||
var mapState = tassign(state.mapState);
|
var mapState = tassign(state.mapState);
|
||||||
console.debug(`Base layerload: ${mapState.baseLayerCode}`)
|
console.debug(`Base layerload: ${mapState.baseLayerCode}`)
|
||||||
if (baseLayers.length > 0 && mapState.baseLayerCode != "") {
|
if (baseLayers.length > 0 && mapState.baseLayerCode != "") {
|
||||||
selectedBaseLayer = baseLayers.filter(layer => layer.item.code === mapState.baseLayerCode)[0];
|
selectedBaseLayer = baseLayers.filter(layer => layer.item.code === mapState.baseLayerCode)[0];
|
||||||
selectedBaseLayer.visible = true;
|
selectedBaseLayer.visible = true;
|
||||||
} else if (baseLayers.length > 0) {
|
} else if (baseLayers.length > 0) {
|
||||||
selectedBaseLayer = baseLayers[0];
|
selectedBaseLayer = baseLayers[0];
|
||||||
selectedBaseLayer.visible = true;
|
selectedBaseLayer.visible = true;
|
||||||
mapState.baseLayerCode = selectedBaseLayer.item.code;
|
mapState.baseLayerCode = selectedBaseLayer.item.code;
|
||||||
}
|
}
|
||||||
return tassign(state, { mapState:mapState, baseLayers: baseLayers, selectedBaseLayer: selectedBaseLayer });
|
return tassign(state, { mapState:mapState, baseLayers: baseLayers, selectedBaseLayer: selectedBaseLayer });
|
||||||
}
|
}
|
||||||
case mapActions.SELECTBASELAYER: {
|
case mapActions.SELECTBASELAYER: {
|
||||||
let a = action as mapActions.SelectBaseLayer;
|
let a = action as mapActions.SelectBaseLayer;
|
||||||
let baseLayers = state.baseLayers.slice(0);
|
let baseLayers = state.baseLayers.slice(0);
|
||||||
baseLayers.forEach((l) => l.visible = false);
|
baseLayers.forEach((l) => l.visible = false);
|
||||||
let i = state.baseLayers.indexOf(a.itemLayer);
|
let i = state.baseLayers.indexOf(a.itemLayer);
|
||||||
baseLayers[i].visible = true;
|
baseLayers[i].visible = true;
|
||||||
var mapState = tassign(state.mapState);
|
var mapState = tassign(state.mapState);
|
||||||
mapState.baseLayerCode = a.itemLayer.item.code;
|
mapState.baseLayerCode = a.itemLayer.item.code;
|
||||||
return tassign(state, {mapState:mapState, baseLayers:baseLayers,selectedBaseLayer:a.itemLayer });
|
return tassign(state, {mapState:mapState, baseLayers:baseLayers,selectedBaseLayer:a.itemLayer });
|
||||||
}
|
}
|
||||||
case mapActions.SELECTOVERLAYLAYER: {
|
case mapActions.SELECTOVERLAYLAYER: {
|
||||||
let a = action as mapActions.SelectOverlayLayer;
|
let a = action as mapActions.SelectOverlayLayer;
|
||||||
return tassign(state, { selectedOverlayLayer: a.itemLayer });
|
return tassign(state, { selectedOverlayLayer: a.itemLayer });
|
||||||
}
|
}
|
||||||
case commonActions.ESCAPE: {
|
case commonActions.ESCAPE: {
|
||||||
let a = action as commonActions.Escape;
|
let a = action as commonActions.Escape;
|
||||||
let newQueryState = tassign(state.queryState, { query: null, tags: null, itemCode: null, parentCode: null, itemType: null });
|
let newQueryState = tassign(state.queryState, { query: null, tags: null, itemCode: null, parentCode: null, itemType: null });
|
||||||
if (a.escapeKey) {
|
if (a.escapeKey) {
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
panelVisible: false,
|
panelVisible: false,
|
||||||
panelCollapsed:false,
|
panelCollapsed:false,
|
||||||
selectedItem: null,
|
selectedItem: null,
|
||||||
selectedItemLayer: null,
|
selectedItemLayer: null,
|
||||||
selectedFeature: null,
|
selectedFeature: null,
|
||||||
queryState: newQueryState,
|
queryState: newQueryState,
|
||||||
clearEnabled: false,
|
clearEnabled: false,
|
||||||
searchCollapsed: true,
|
searchCollapsed: true,
|
||||||
searchMinified: false,
|
searchMinified: false,
|
||||||
menuVisible:false,
|
menuVisible:false,
|
||||||
features: [],
|
features: [],
|
||||||
query:initialState.query
|
query:initialState.query
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return tassign(state, {});
|
return tassign(state, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getMapState = (state: State) => state.mapState;
|
export const getMapState = (state: State) => state.mapState;
|
||||||
export const getParentCode = (state: State) => state.parentCode;
|
export const getParentCode = (state: State) => state.parentCode;
|
||||||
export const getFeatures = (state: State) => state.features;
|
export const getFeatures = (state: State) => state.features;
|
||||||
export const getPanelVisible = (state: State) => state.panelVisible;
|
export const getPanelVisible = (state: State) => state.panelVisible;
|
||||||
export const getPanelCollapsed = (state: State) => state.panelCollapsed;
|
export const getPanelCollapsed = (state: State) => state.panelCollapsed;
|
||||||
export const getSelectedFeature = (state: State) => state.selectedFeature;
|
export const getSelectedFeature = (state: State) => state.selectedFeature;
|
||||||
export const getSelectedItem = (state: State) => state.selectedItem;
|
export const getSelectedItem = (state: State) => state.selectedItem;
|
||||||
export const getQueryState = (state: State) => state.queryState;
|
export const getQueryState = (state: State) => state.queryState;
|
||||||
export const getClearEnabled = (state: State) => state.clearEnabled;
|
export const getClearEnabled = (state: State) => state.clearEnabled;
|
||||||
export const getSearchCollapsed = (state: State) => state.searchCollapsed;
|
export const getSearchCollapsed = (state: State) => state.searchCollapsed;
|
||||||
export const getSearchMinified = (state: State) => state.searchMinified;
|
export const getSearchMinified = (state: State) => state.searchMinified;
|
||||||
export const getMenuVisible = (state: State) => state.menuVisible;
|
export const getMenuVisible = (state: State) => state.menuVisible;
|
||||||
export const getExtent = (state: State) => state.extent;
|
export const getExtent = (state: State) => state.extent;
|
||||||
export const getOverlayLayers = (state: State) => state.overlayLayers;
|
export const getOverlayLayers = (state: State) => state.overlayLayers;
|
||||||
export const getBaseLayers = (state: State) => state.baseLayers;
|
export const getBaseLayers = (state: State) => state.baseLayers;
|
||||||
export const getProjection = (state: State) => state.projection;
|
export const getProjection = (state: State) => state.projection;
|
||||||
export const getSelectedBaseLayer = (state: State) => state.selectedBaseLayer;
|
export const getSelectedBaseLayer = (state: State) => state.selectedBaseLayer;
|
||||||
export const getSelectedOverlayLayer = (state: State) => state.selectedOverlayLayer;
|
export const getSelectedOverlayLayer = (state: State) => state.selectedOverlayLayer;
|
||||||
export const getQuery = (state: State) => state.query;
|
export const getQuery = (state: State) => state.query;
|
||||||
export const getSelectedItemLayer = (state: State) => state.selectedItemLayer;
|
export const getSelectedItemLayer = (state: State) => state.selectedItemLayer;
|
||||||
export const getPeriod = (state:State) => state.period;
|
export const getPeriod = (state:State) => state.period;
|
||||||
|
|
||||||
export const selectMapState = createFeatureSelector<State>(MODULE_NAME);
|
export const selectMapState = createFeatureSelector<State>(MODULE_NAME);
|
||||||
export const selectGetMapState= createSelector(selectMapState, getMapState);
|
export const selectGetMapState= createSelector(selectMapState, getMapState);
|
||||||
export const selectGetParentCode = createSelector(selectMapState, getParentCode);
|
export const selectGetParentCode = createSelector(selectMapState, getParentCode);
|
||||||
export const selectGetFeatures = createSelector(selectMapState, getFeatures);
|
export const selectGetFeatures = createSelector(selectMapState, getFeatures);
|
||||||
export const selectGetPanelVisible = createSelector(selectMapState, getPanelVisible);
|
export const selectGetPanelVisible = createSelector(selectMapState, getPanelVisible);
|
||||||
export const selectGetPanelCollapsed = createSelector(selectMapState, getPanelCollapsed);
|
export const selectGetPanelCollapsed = createSelector(selectMapState, getPanelCollapsed);
|
||||||
export const selectGetSelectedFeature = createSelector(selectMapState, getSelectedFeature);
|
export const selectGetSelectedFeature = createSelector(selectMapState, getSelectedFeature);
|
||||||
export const selectGetSelectedItem = createSelector(selectMapState, getSelectedItem);
|
export const selectGetSelectedItem = createSelector(selectMapState, getSelectedItem);
|
||||||
export const selectGetQueryState = createSelector(selectMapState, getQueryState);
|
export const selectGetQueryState = createSelector(selectMapState, getQueryState);
|
||||||
export const selectGetClearEnabled = createSelector(selectMapState, getClearEnabled);
|
export const selectGetClearEnabled = createSelector(selectMapState, getClearEnabled);
|
||||||
export const selectGetSearchCollapsed = createSelector(selectMapState, getSearchCollapsed);
|
export const selectGetSearchCollapsed = createSelector(selectMapState, getSearchCollapsed);
|
||||||
export const selectGetSearchMinified = createSelector(selectMapState, getSearchMinified);
|
export const selectGetSearchMinified = createSelector(selectMapState, getSearchMinified);
|
||||||
export const selectGetMenuVisible = createSelector(selectMapState, getMenuVisible);
|
export const selectGetMenuVisible = createSelector(selectMapState, getMenuVisible);
|
||||||
export const selectGetExtent = createSelector(selectMapState, getExtent);
|
export const selectGetExtent = createSelector(selectMapState, getExtent);
|
||||||
export const selectGetOverlayLayers = createSelector(selectMapState, getOverlayLayers);
|
export const selectGetOverlayLayers = createSelector(selectMapState, getOverlayLayers);
|
||||||
export const selectGetBaseLayers = createSelector(selectMapState, getBaseLayers);
|
export const selectGetBaseLayers = createSelector(selectMapState, getBaseLayers);
|
||||||
export const selectGetProjection = createSelector(selectMapState, getProjection);
|
export const selectGetProjection = createSelector(selectMapState, getProjection);
|
||||||
export const selectGetSelectedBaseLayer = createSelector(selectMapState, getSelectedBaseLayer);
|
export const selectGetSelectedBaseLayer = createSelector(selectMapState, getSelectedBaseLayer);
|
||||||
export const selectGetSelectedOverlayLayer = createSelector(selectMapState, getSelectedOverlayLayer);
|
export const selectGetSelectedOverlayLayer = createSelector(selectMapState, getSelectedOverlayLayer);
|
||||||
export const selectGetQuery = createSelector(selectMapState, getQuery);
|
export const selectGetQuery = createSelector(selectMapState, getQuery);
|
||||||
export const selectGetSelectedItemLayer = createSelector(selectMapState, getSelectedItemLayer);
|
export const selectGetSelectedItemLayer = createSelector(selectMapState, getSelectedItemLayer);
|
||||||
export const selectGetPeriod = createSelector(selectMapState, getPeriod);
|
export const selectGetPeriod = createSelector(selectMapState, getPeriod);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user