import { Injectable } from '@angular/core' ; import { Store } from '@ngrx/store' ; import Feature from 'ol/Feature' ; import Circle from 'ol/geom/Circle' ; import LineString from 'ol/geom/LineString' ; import Point from 'ol/geom/Point' ; import Polygon from 'ol/geom/Polygon' ; import VectorLayer from 'ol/layer/Vector' ; import Map from 'ol/Map' ; import VectorSource from 'ol/source/Vector' ; import { Observable } from 'rxjs' ; import { MangolLayer } from './classes/Layer' ; import { MangolConfig } from './interfaces/config.interface' ; import { MangolControllersFullScreenDictionary , MangolControllersPositionDictionary , MangolControllersRotationDictionary , MangolControllersZoomDictionary } from './interfaces/config-map-controllers.interface' ; import { PrintDictionary } from './interfaces/config-toolbar.interface' ; import { CursorMode } from './interfaces/cursor-mode' ; import * as ConfigActions from './store/config/config.actions' ; import * as fromConfig from './store/config/config.reducers' ; import * as ControllersActions from './store/controllers/controllers.actions' ; import * as fromControllers from './store/controllers/controllers.reducers' ; import * as CursorActions from './store/cursor/cursor.actions' ; import * as fromCursor from './store/cursor/cursor.reducers' ; import * as FeatureinfoActions from './store/featureinfo/featureinfo.actions' ; import * as fromFeatureinfo from './store/featureinfo/featureinfo.reducers' ; import { FeatureinfoDictionary } from './store/featureinfo/featureinfo.reducers' ; import * as LayersActions from './store/layers/layers.actions' ; import * as fromLayers from './store/layers/layers.reducers' ; import * as LayertreeActions from './store/layertree/layertree.actions' ; import * as fromLayertree from './store/layertree/layertree.reducers' ; import { LayertreeDictionary } from './store/layertree/layertree.reducers' ; import * as MangolActions from './store/mangol.actions' ; import * as fromMangol from './store/mangol.reducers' ; import * as MapActions from './store/map/map.actions' ; import * as fromMap from './store/map/map.reducers' ; import * as MeasureActions from './store/measure/measure.actions' ; import * as fromMeasure from './store/measure/measure.reducers' ; import { MeasureDictionary , MeasureMode } from './store/measure/measure.reducers' ; import * as PrintActions from './store/print/print.actions' ; import { PrintLayout , PrintSize } from './store/print/print.reducers' ; import * as fromPrint from './store/print/print.reducers' ; import * as SidebarActions from './store/sidebar/sidebar.actions' ; import * as fromSidebar from './store/sidebar/sidebar.reducers' ; @ Injectable ( { providedIn : 'root' } ) export class MangolService { configState$ : Observable < fromConfig . State > ; mapState$ : Observable < fromMap . State > ; sidebarState$ : Observable < fromSidebar . State > ; controllersState$ : Observable < fromControllers . State > ; cursorState$ : Observable < fromCursor . State > ; featureinfoState$ : Observable < fromFeatureinfo . State > ; layersState$ : Observable < fromLayers . State > ; layertreeState$ : Observable < fromLayertree . State > ; measureState$ : Observable < fromMeasure . State > ; printState$ : Observable < fromPrint . State > ; constructor ( private store ) { this . configState$ = this . store . select ( ( state ) => state . config ) ; this . mapState$ = this . store . select ( ( state ) => state . map ) ; this . sidebarState$ = this . store . select ( ( state ) => state . sidebar ) ; this . controllersState$ = this . store . select ( ( state ) => state . controllers ) ; this . cursorState$ = this . store . select ( ( state ) => state . cursor ) ; this . featureinfoState$ = this . store . select ( ( state ) => state . featureinfo ) ; this . layersState$ = this . store . select ( ( state ) => state . layers ) ; this . layertreeState$ = this . store . select ( ( state ) => state . layertree ) ; this . measureState$ = this . store . select ( ( state ) => state . measure ) ; this . printState$ = this . store . select ( ( state ) => state . print ) ; } /**
     * Resets the Mangol State
     */ resetMangolState ( ) { this . store . dispatch ( new MangolActions . ClearState ( ) ) ; } setConfig ( config ) { this . store . dispatch ( new ConfigActions . SetConfig ( config ) ) ; } setMap ( map ) { this . store . dispatch ( new MapActions . SetMap ( map ) ) ; } toggleSidebar ( ) { this . store . dispatch ( new SidebarActions . Toggle ( ) ) ; } setHasSidebar ( hasSidebar ) { this . store . dispatch ( new SidebarActions . SetHasSidebar ( hasSidebar ) ) ; } setSidebarMode ( mode ) { this . store . dispatch ( new SidebarActions . SetMode ( mode ) ) ; } setSidebarCollapsible ( collapsible ) { this . store . dispatch ( new SidebarActions . SetCollapsible ( collapsible ) ) ; } setSidebarOpened ( opened ) { this . store . dispatch ( new SidebarActions . SetOpened ( opened ) ) ; } setSidebarTitle ( title ) { this . store . dispatch ( new SidebarActions . SetTitle ( title ) ) ; } setSidebarSelectedModule ( module ) { this . store . dispatch ( new SidebarActions . SetSelectedModule ( module ) ) ; } resetControllers ( ) { this . store . dispatch ( new ControllersActions . Reset ( ) ) ; } setControllersShowZoom ( show ) { this . store . dispatch ( new ControllersActions . SetShowZoom ( show ) ) ; } setControllersZoomDictionary ( dictionary ) { this . store . dispatch ( new ControllersActions . SetZoomDictionary ( dictionary ) ) ; } setControllersShowTooltip ( show ) { this . store . dispatch ( new ControllersActions . SetShowTooltip ( show ) ) ; } setControllersShowPosition ( show ) { this . store . dispatch ( new ControllersActions . SetShowPosition ( show ) ) ; } setControllersPositionPrecision ( precision ) { this . store . dispatch ( new ControllersActions . SetPositionPrecision ( precision ) ) ; } setControllersPositionCoordinates ( coordinates ) { this . store . dispatch ( new ControllersActions . SetPositionCoordinates ( coordinates ) ) ; } setControllersPositionDictionary ( dictionary ) { this . store . dispatch ( new ControllersActions . SetPositionDictionary ( dictionary ) ) ; } setControllersShowRotation ( show ) { this . store . dispatch ( new ControllersActions . SetShowRotation ( show ) ) ; } setControllersRotationDictionary ( dictionary ) { this . store . dispatch ( new ControllersActions . SetRotationDictionary ( dictionary ) ) ; } setControllersShowRotationTooltip ( show ) { this . store . dispatch ( new ControllersActions . SetShowRotationTooltip ( show ) ) ; } setControllersRotationValue ( value ) { this . store . dispatch ( new ControllersActions . SetRotationValue ( value ) ) ; } setControllersShowFullscreen ( show ) { this . store . dispatch ( new ControllersActions . SetShowFullscreen ( show ) ) ; } setControllersShowFullscreenTooltip ( show ) { this . store . dispatch ( new ControllersActions . SetShowFullscreenTooltip ( show ) ) ; } setControllersFullscreenDictionary ( dictionary ) { this . store . dispatch ( new ControllersActions . SetFullscreenDictionary ( dictionary ) ) ; } resetCursorMode ( ) { this . store . dispatch ( new CursorActions . ResetMode ( ) ) ; } setCursorMode ( mode ) { this . store . dispatch ( new CursorActions . SetMode ( mode ) ) ; } setCursorVisible ( visible ) { this . store . dispatch ( new CursorActions . SetVisible ( visible ) ) ; } setCursorLayer ( layer ) { this . store . dispatch ( new CursorActions . SetLayer ( layer ) ) ; } featureinfoSetHasFeatureinfo ( hasFeatureinfo ) { this . store . dispatch ( new FeatureinfoActions . HasFeatureinfo ( hasFeatureinfo ) ) ; } featureinfoSetDisabled ( disabled ) { this . store . dispatch ( new FeatureinfoActions . SetDisabled ( disabled ) ) ; } featureinfoSetTitle ( title ) { this . store . dispatch ( new FeatureinfoActions . SetTitle ( title ) ) ; } featureinfoSetMaxFeatures ( maxFeatures ) { this . store . dispatch ( new FeatureinfoActions . SetMaxFeatures ( maxFeatures ) ) ; } featureinfoSetLayers ( layers ) { this . store . dispatch ( new FeatureinfoActions . SetLayers ( layers ) ) ; } featureinfoSetSelectedLayer ( layer ) { this . store . dispatch ( new FeatureinfoActions . SetSelectedLayer ( layer ) ) ; } featureinfoSetResultsLayer ( layer ) { this . store . dispatch ( new FeatureinfoActions . SetResultsLayer ( layer ) ) ; } featureinfoSetResultsItems ( features ) { this . store . dispatch ( new FeatureinfoActions . SetResultsItems ( features ) ) ; } featureinfoSetDictionary ( dictionary ) { this . store . dispatch ( new FeatureinfoActions . SetDictionary ( dictionary ) ) ; } featureinfoSetHoverColor ( color ) { this . store . dispatch ( new FeatureinfoActions . SetHoverColor ( color ) ) ; } /**
     * LAYERS state functions
     */ layersSetLayers ( layers ) { this . store . dispatch ( new LayersActions . SetLayers ( layers ) ) ; } layersSetMeasureLayer ( layer ) { this . store . dispatch ( new LayersActions . SetMeasureLayer ( layer ) ) ; } /**
     * LAYERTREE state functions
     */ layertreeSetHasLayertree ( hasLayertree ) { this . store . dispatch ( new LayertreeActions . HasLayertree ( hasLayertree ) ) ; } layertreeSetDisabled ( disabled ) { this . store . dispatch ( new LayertreeActions . SetDisabled ( disabled ) ) ; } layertreeSetTitle ( title ) { this . store . dispatch ( new LayertreeActions . SetTitle ( title ) ) ; } layertreeSetDictionary ( dictionary ) { this . store . dispatch ( new LayertreeActions . SetDictionary ( dictionary ) ) ; } layertreeShowLayergroupBadges ( showBadges ) { this . store . dispatch ( new LayertreeActions . ShowLayergroupBadges ( showBadges ) ) ; } /**
     * MEASURE state functions
     */ measureSetHasMeasure ( hasMeasure ) { this . store . dispatch ( new MeasureActions . HasMeasure ( hasMeasure ) ) ; } measureSetDisabled ( disabled ) { this . store . dispatch ( new MeasureActions . SetDisabled ( disabled ) ) ; } measureSetTitle ( title ) { this . store . dispatch ( new MeasureActions . SetTitle ( title ) ) ; } measureSetDictionary ( dictionary ) { this . store . dispatch ( new MeasureActions . SetDictionary ( dictionary ) ) ; } measureSetMode ( mode ) { this . store . dispatch ( new MeasureActions . SetMode ( mode ) ) ; } /**
     * PRINT state functions
     */ printSetHasPrint ( hasPrint ) { this . store . dispatch ( new PrintActions . HasPrint ( hasPrint ) ) ; } printSetDisabled ( disabled ) { this . store . dispatch ( new PrintActions . SetDisabled ( disabled ) ) ; } printSetTitle ( title ) { this . store . dispatch ( new PrintActions . SetTitle ( title ) ) ; } printSetResolutions ( resolutions ) { this . store . dispatch ( new PrintActions . SetResolutions ( resolutions ) ) ; } printSetLayouts ( layouts ) { this . store . dispatch ( new PrintActions . SetLayouts ( layouts ) ) ; } printSetSizes ( sizes ) { this . store . dispatch ( new PrintActions . SetSizes ( sizes ) ) ; } printSetDictionary ( dictionary ) { this . store . dispatch ( new PrintActions . SetDictionary ( dictionary ) ) ; } printSetSelectedLayout ( layout ) { this . store . dispatch ( new PrintActions . SetSelectedLayout ( layout ) ) ; } printSetSelectedResolution ( resolution ) { this . store . dispatch ( new PrintActions . SetSelectedResolution ( resolution ) ) ; } printSetSelectedSize ( size ) { this . store . dispatch ( new PrintActions . SetSelectedSize ( size ) ) ; } }