From 160eb10aba99bd05cb3312aabb7df0e93b084bd9 Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Tue, 5 Oct 2021 13:46:10 +0200 Subject: [PATCH] Refactoring types --- custom-webpack.config.js | 6 ++-- package-lock.json | 6 ++++ package.json | 1 + .../src/fm-map/actions/map.actions.ts | 16 +++++---- .../file-drop-target.component.ts | 4 +-- .../gps-location/gps-location.component.ts | 4 +-- .../aol/item-layers/item-layers.component.ts | 34 ++++++++++--------- .../item-vector-source.component.ts | 30 ++++++++-------- .../layer-vector-image.component.ts | 9 ++--- .../feature-list-container.component.ts | 7 ++-- .../feature-list-croppingscheme.component.ts | 3 +- ...eature-list-feature-container.component.ts | 3 +- ...eature-list-feature-cropfield.component.ts | 5 +-- .../feature-list-feature.component.ts | 3 +- .../feature-list/feature-list.component.ts | 11 +++--- .../feature-thumbnail.component.ts | 2 +- .../if-zoom-to-show.directive.ts | 7 ++-- .../fm-map/components/map/map.component.ts | 11 +++--- .../zoom-to-show-alert.component.ts | 7 ++-- .../src/fm-map/effects/map.effects.ts | 10 +++--- .../src/fm-map/models/item.layer.ts | 5 +-- .../src/fm-map/models/style.cache.ts | 6 ++-- .../src/fm-map/reducers/map.reducer.ts | 5 +-- projects/common-map/tsconfig.lib.json | 3 +- projects/common-map3d/tsconfig.lib.json | 3 +- projects/common-map3d/tsconfig.lib.prod.json | 3 -- projects/common/src/fm/common.module.ts | 4 ++- projects/common/tsconfig.lib.json | 3 +- projects/common/tsconfig.lib.prod.json | 3 +- src/tsconfig.app.json | 5 +-- tsconfig.json | 1 + 31 files changed, 118 insertions(+), 102 deletions(-) diff --git a/custom-webpack.config.js b/custom-webpack.config.js index 70173ee..46c8f29 100644 --- a/custom-webpack.config.js +++ b/custom-webpack.config.js @@ -1,5 +1,6 @@ module.exports = { - node: { + resolve: { + fallback: { // Resolve node module use of fs fs: "empty", Buffer: false, @@ -7,4 +8,5 @@ module.exports = { https: "empty", zlib: "empty" } - }; \ No newline at end of file + } +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1d77af1..6c3e6c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4289,6 +4289,12 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", "dev": true }, + "@types/arcgis-rest-api": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/@types/arcgis-rest-api/-/arcgis-rest-api-10.4.5.tgz", + "integrity": "sha512-MhpTj3aaURIFhK6pBRF50yCHW5TpbeuC1E81juovfNesSOshsQnCzludhpBhIr2pNzplTBlfzrT7RKiLZ5F3Tw==", + "dev": true + }, "@types/color-name": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", diff --git a/package.json b/package.json index eea2449..7d89318 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "@angular/cli": "^12.2.8", "@angular/compiler-cli": "~12.2.8", "@angular/language-service": "~12.2.8", + "@types/arcgis-rest-api": "^10.4.5", "@types/jasmine": "~2.8.8", "@types/jasminewd2": "^2.0.9", "@types/node": "^12.20.15", diff --git a/projects/common-map/src/fm-map/actions/map.actions.ts b/projects/common-map/src/fm-map/actions/map.actions.ts index ec89de0..888fe54 100644 --- a/projects/common-map/src/fm-map/actions/map.actions.ts +++ b/projects/common-map/src/fm-map/actions/map.actions.ts @@ -5,7 +5,9 @@ import { IItemLayer } from '../models/item.layer'; import { ILayervalue } from '../models/layer.value'; import { IQueryState } from '@farmmaps/common'; import { IItem } from '@farmmaps/common'; -import { Feature,Style } from 'ol'; +import { Feature } from 'ol'; +import { Style } from 'ol/style'; +import { Geometry } from 'ol/geom'; import { IPeriodState } from '../models/period.state'; export const SETSTATE = '[Map] SetState'; @@ -103,13 +105,13 @@ export class StartSearch implements Action { export class StartSearchSuccess implements Action { readonly type = STARTSEARCHSUCCESS; - constructor(public features: Array, public query:IQueryState) { } + constructor(public features: Array>, public query:IQueryState) { } } export class SelectFeature implements Action { readonly type = SELECTFEATURE; - constructor(public feature:Feature) { } + constructor(public feature:Feature) { } } export class SelectItem implements Action { @@ -151,13 +153,13 @@ export class SelectTemporal implements Action { export class AddFeatureSuccess implements Action { readonly type = ADDFEATURESUCCESS; - constructor(public feature: Feature) { } + constructor(public feature: Feature) { } } export class UpdateFeatureSuccess implements Action { readonly type = UPDATEFEATURESUCCESS; - constructor(public feature: Feature) { } + constructor(public feature: Feature) { } } export class ExpandSearch implements Action { @@ -271,7 +273,7 @@ export class DoQuery implements Action { export class SetStyle implements Action { readonly type = SETSTYLE; - constructor(public itemType:string,public style: Style | (Feature)) { } + constructor(public itemType:string,public style: Style | (Feature)) { } } export class ShowLayerSwitcher implements Action { @@ -287,7 +289,7 @@ export class SetReplaceUrl implements Action { export class SetFeatures implements Action { readonly type = SETFEATURES; - constructor(public features: Array) { } + constructor(public features: Array>) { } } export class SetLayerValuesLocation implements Action { diff --git a/projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts b/projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts index ab9273a..643a445 100644 --- a/projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts +++ b/projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts @@ -4,7 +4,7 @@ import { MapComponent } from 'ngx-openlayers'; import * as proj from 'ol/proj'; import {Point,Geometry} from 'ol/geom'; import { GeoJSON } from 'ol/format'; -import { Feature } from 'ol'; +import { Feature} from 'ol'; export interface IDroppedFile { files: any, @@ -21,7 +21,7 @@ export class FileDropTargetComponent implements OnInit, OnDestroy { element: Element; @Output() onFileDropped = new EventEmitter(); @Input() parentCode: string; - @Input() features: Array; + @Input() features: Array>; constructor(private map: MapComponent) { } diff --git a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts b/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts index 1b42a0d..4230817 100644 --- a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts +++ b/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, Input, ViewChild, ElementRef, OnChanges, SimpleChanges ,Host} from '@angular/core'; import { MapComponent } from 'ngx-openlayers'; -import Overlay from 'ol/Overlay'; +import Overlay from 'ol/Overlay'; import { fromLonLat, toLonLat } from 'ol/proj'; @@ -52,7 +52,7 @@ export class GpsLocation implements OnInit,OnChanges{ this.rotate = "rotate(" + Math.round(this.heading) + " 500 500)"; this.locTolerancePixels = this.locationTolerance; this.map.instance.addOverlay(this.instance); - this.map.instance.getView().on('change:resolution', (evt) => { + this.map.instance.getView().on('change:resolution', (evt:any) => { this.resolution = evt.target.get('resolution'); this.recalcLocationTolerance(); }); diff --git a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts b/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts index 49265fd..da4d683 100644 --- a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts +++ b/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts @@ -10,12 +10,14 @@ import * as proj from 'ol/proj'; import * as loadingstrategy from 'ol/loadingstrategy'; import * as style from 'ol/style'; import {Tile,Layer,Image} from 'ol/layer'; -import {XYZ,ImageStatic,OSM,BingMaps,TileWMS,TileArcGISRest,TileJSON} from 'ol/source'; +import {XYZ,ImageStatic,OSM,BingMaps,TileWMS,TileArcGISRest,TileJSON,Source} from 'ol/source'; import {Vector as VectorSource} from 'ol/source'; import { Vector as VectorLayer } from 'ol/layer'; import VectorTileSource from 'ol/source/VectorTile'; import VectorTileLayer from 'ol/layer/VectorTile'; import {GeoJSON,MVT} from 'ol/format'; +import { Geometry } from 'ol/geom'; +import TileSource from 'ol/source/Tile'; @Component({ selector: 'fm-map-item-layers', @@ -34,7 +36,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange private initialized:boolean = false; private mapEventHandlerInstalled = false; private selectedFeatures = {}; - private selectionLayer:Layer = null; + private selectionLayer:Layer = null; constructor(private itemService: ItemService, private map: MapComponent, public appConfig: AppConfig) { super(map); @@ -119,9 +121,9 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange return this.styleCache[key]; } - createGeotiffLayer(item:IItem,itemLayer:IItemLayer):Layer { + createGeotiffLayer(item:IItem,itemLayer:IItemLayer):Layer { var layerIndex = -1; - var layer: Layer = null; + var layer: Layer = null; layerIndex = itemLayer.layerIndex != -1 ? itemLayer.layerIndex : item.data.layers[0].index; let source = new XYZ({ maxZoom: 19, minZoom: 1, url: `${this._apiEndPoint}/api/v1/items/${item.code}/tiles/${layerIndex}/{z}/{x}/{y}.png?v=${Date.parse(item.updated)}` }); layer = new Tile({ source: source }); @@ -142,9 +144,9 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange return layer; } - createShapeLayer(item:IItem,itemLayer:IItemLayer):Layer { + createShapeLayer(item:IItem,itemLayer:IItemLayer):Layer { var layerIndex = -1; - var layer: Layer = null; + var layer: Layer = null; layerIndex = itemLayer.layerIndex != -1 ? itemLayer.layerIndex : item.data.layers[0].index; var data = item.data; var l:ILayer = (data && data.layers && data.layers.length > 0) ? data.layers[layerIndex] : null; @@ -177,7 +179,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange let source = new VectorSource({ strategy: loadingstrategy.bbox, loader: function (extent: Extent, resolution: number, projection: Projection) { - var source = this as VectorSource; + var source = this as VectorSource; __this.itemService.getItemFeatures(item.code, extent, projection.getCode(), layerIndex).subscribe(function (data) { var features = format.readFeatures(data); for (let f of features) { @@ -230,16 +232,16 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange return layer; } - createSelectionLayer(itemLayer:IItemLayer):Layer { + createSelectionLayer(itemLayer:IItemLayer):Layer { var layerIndex = -1; - var layer: Layer = null; + var layer: Layer = null; layerIndex = itemLayer.layerIndex != -1 ? itemLayer.layerIndex : itemLayer.item.data.layers[0].index; var data = itemLayer.item.data; var l:ILayer = (data && data.layers && data.layers.length > 0) ? data.layers[layerIndex] : null; if (l && l.rendering && l.rendering.renderoutputType == "VectorTiles") { return new VectorTileLayer({ renderMode: 'vector', - source: itemLayer.layer.getSource(), + source: (itemLayer.layer as VectorTileLayer).getSource(), style: (feature) => { if (feature.getId() in this.selectedFeatures) { @@ -260,9 +262,9 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange return null; } - createExternalLayer(item:IItem,itemLayer:IItemLayer):Layer { + createExternalLayer(item:IItem,itemLayer:IItemLayer):Layer { let data = item.data as ILayerData; - var layer: Layer = null; + var layer: Layer = null; switch (data.interfaceType) { case 'OSM': { let source = new OSM(); @@ -312,8 +314,8 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange return layer; } - createLayer(itemLayer: IItemLayer): Layer { - var layer: Layer = null; + createLayer(itemLayer: IItemLayer): Layer { + var layer: Layer = null; var layerIndex = -1; if (itemLayer.item.itemType == 'vnd.farmmaps.itemtype.geotiff.processed') { layer = this.createGeotiffLayer(itemLayer.item,itemLayer); @@ -360,7 +362,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange } } - addOrUpdateOlLayer(itemLayer:IItemLayer,index:number):Layer { + addOrUpdateOlLayer(itemLayer:IItemLayer,index:number):Layer { if(!itemLayer) return null; var olLayers = this.instance.getLayers(); var layer = itemLayer.layer; @@ -385,7 +387,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange } updateLayers(itemLayers: IItemLayer[]) { - let newLayers: IItemLayer[] = []; + let newLayers: Layer[] = []; if (itemLayers) { itemLayers.forEach((itemLayer, index) => { if(itemLayer.item.itemType == 'vnd.farmmaps.itemtype.temporal') { diff --git a/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts b/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts index 233d7bc..5d60072 100644 --- a/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts +++ b/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts @@ -3,14 +3,14 @@ import { LayerVectorComponent, SourceVectorComponent, MapComponent } from 'ngx-o import { ItemService,ItemTypeService,IItem, IItemType } from '@farmmaps/common'; import { Feature } from 'ol'; -import { Point } from 'ol/geom'; +import { Point,Geometry } from 'ol/geom'; import { MapBrowserEvent } from 'ol'; import * as style from 'ol/style'; import * as color from 'ol/color'; import * as loadingstrategy from 'ol/loadingstrategy'; import * as condition from 'ol/events/condition'; import * as extent from 'ol/extent'; -import {Vector,Cluster} from 'ol/source'; +import {Vector,Cluster,Source} from 'ol/source'; import {Layer} from 'ol/layer'; import {GeoJSON} from 'ol/format'; import {Select} from 'ol/interaction'; @@ -25,17 +25,17 @@ import {FeatureIconService} from '../../../services/feature-icon.service'; ] }) export class ItemVectorSourceComponent extends SourceVectorComponent implements OnInit, OnChanges { - instance: Vector; + instance: Vector; private _format: GeoJSON; private _select: Select; private _hoverSelect: Select; private _iconScale: number = 0.05; - @Input() features: Array; - @Input() selectedFeature: Feature; + @Input() features: Array>; + @Input() selectedFeature: Feature; @Input() selectedItem: IItem; @Input() styles:IStyles; - @Output() onFeatureSelected: EventEmitter = new EventEmitter(); - @Output() onFeatureHover: EventEmitter = new EventEmitter(); + @Output() onFeatureSelected: EventEmitter> = new EventEmitter>(); + @Output() onFeatureHover: EventEmitter> = new EventEmitter>(); private stylesCache:IStyles = {}; constructor(@Host() private layer: LayerVectorComponent, private itemService: ItemService, private map: MapComponent, private itemTypeService: ItemTypeService,private featureIconService$:FeatureIconService) { @@ -43,7 +43,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements this._format = new GeoJSON(); } - geometry(feature: Feature) { + geometry(feature: Feature) { let view = this.map.instance.getView(); let resolution = view.getResolution(); var geometry = feature.getGeometry(); @@ -55,9 +55,9 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements return geometry; } - getSelectedStyle(feature:Feature):style.Style { + getSelectedStyle(feature:Feature):style.Style { let key = feature.get('itemType')+"_selected"; - let evaluatedStyle =null; + let evaluatedStyle: style.Style | (Feature) =undefined; var styleEntry = this.stylesCache[key]; if(styleEntry) { if(typeof styleEntry === 'function') { @@ -71,7 +71,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements if(evaluatedStyle ) { evaluatedStyle.setGeometry((feature) => this.geometry(feature)); } - return evaluatedStyle + return evaluatedStyle as style.Style } ngOnInit() { @@ -80,17 +80,17 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements this._select = new Select({ style:null, hitTolerance: 10, - layers: [this.layer.instance as Layer] + layers: [this.layer.instance as Layer] }); this._hoverSelect = new Select({ - style: (feature) => { + style: (feature:Feature) => { return this.getSelectedStyle(feature); }, hitTolerance: 10, condition: (e: MapBrowserEvent) => { return e.type == 'pointermove'; }, - layers: [this.layer.instance as Layer] + layers: [this.layer.instance as Layer] }); this.map.instance.addInteraction(this._select); this.map.instance.addInteraction(this._hoverSelect); @@ -132,7 +132,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements fill: new style.Fill({ color: fillColor }), - geometry:(feature) => this.geometry(feature) + geometry:(feature:Feature) => this.geometry(feature) }); } else { key = 'file'; diff --git a/projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts b/projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts index 2fc6306..05293d7 100644 --- a/projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts +++ b/projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts @@ -1,8 +1,5 @@ -import { Component, OnDestroy, OnInit, Input, Optional, OnChanges, SimpleChanges } from '@angular/core'; -import { Vector } from 'ol/layer'; -import { Style } from 'ol/style'; -import { StyleFunction } from 'ol/style/Style'; -import { LayerVectorComponent, LayerGroupComponent, MapComponent } from 'ngx-openlayers'; +import { Component, OnDestroy, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core'; +import { LayerVectorComponent, MapComponent } from 'ngx-openlayers'; import { RenderType } from 'ol/layer/Vector'; @Component({ @@ -12,7 +9,7 @@ import { RenderType } from 'ol/layer/Vector'; `, }) export class LayerVectorImageComponent extends LayerVectorComponent implements OnInit, OnDestroy, OnChanges { - public source: Vector; + //public source: Vector; @Input() renderMode: RenderType | string = "image"; diff --git a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts b/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts index 8dbd03b..7713926 100644 --- a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts +++ b/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts @@ -1,5 +1,6 @@ import { Component, Input, OnInit, ComponentFactoryResolver, ViewChild, SimpleChanges, ComponentFactory, Inject} from '@angular/core'; import { Feature } from 'ol'; +import { Geometry} from 'ol/geom'; import { FeatureListComponent,AbstractFeatureListComponent } from '../feature-list/feature-list.component'; import { WidgetHostDirective } from '../widget-host/widget-host.directive'; import {IQueryState,PackageService } from '@farmmaps/common'; @@ -20,10 +21,10 @@ export class FeatureListContainerComponent { this.featureLists = [...this.featureLists].reverse(); } - @Input() features: Array + @Input() features: Array> @Input() queryState: IQueryState; - @Input() selectedFeature: Feature; - @Input() clickedFeature:Observable; + @Input() selectedFeature: Feature; + @Input() clickedFeature:Observable>; @ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective; componentRef:any; diff --git a/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.ts b/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.ts index 9e359c3..dd9d4d5 100644 --- a/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.ts +++ b/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.ts @@ -9,6 +9,7 @@ import * as mapActions from '../../actions/map.actions'; import { tassign } from 'tassign'; import { Router } from '@angular/router'; import { Feature } from 'ol'; +import { Geometry} from 'ol/geom'; @ForItemType("vnd.farmmaps.itemtype.croppingscheme") @Injectable() @@ -23,7 +24,7 @@ export class FeatureListCroppingschemeComponent extends AbstractFeatureListCompo super(store, itemTypeService, location); } - getAction(feature:Feature):Action { + getAction(feature:Feature):Action { var queryState = tassign(mapReducers.initialState.queryState, { parentCode: feature.get('code'), itemType: "vnd.farmmaps.itemtype.cropfield" }); return new mapActions.DoQuery(queryState); } diff --git a/projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts b/projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts index 56edfd5..b9d933a 100644 --- a/projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts +++ b/projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts @@ -1,5 +1,6 @@ import { Component, Input, OnInit, ComponentFactoryResolver, ViewChild, SimpleChanges, ComponentFactory, Inject, Type} from '@angular/core'; import { Feature } from 'ol'; +import { Geometry } from 'ol/geom'; import { AbstractFeatureListFeatureComponent,FeatureListFeatureComponent } from '../feature-list-feature/feature-list-feature.component'; import { WidgetHostDirective } from '../widget-host/widget-host.directive'; @@ -18,7 +19,7 @@ export class FeatureListFeatureContainerComponent { this.featureLists = [...this.featureLists].reverse(); } - @Input() feature: Feature; + @Input() feature: Feature; @ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective; diff --git a/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.ts b/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.ts index b6c4e38..45b6077 100644 --- a/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.ts +++ b/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.ts @@ -1,5 +1,6 @@ import { Component, Injectable,ViewChild,AfterViewInit} from '@angular/core'; import { Feature } from 'ol'; +import { Geometry } from 'ol/geom'; import { Store } from '@ngrx/store'; import * as mapReducers from '../../reducers/map.reducer'; import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common'; @@ -23,11 +24,11 @@ export class FeatureListFeatureCropfieldComponent extends AbstractFeatureListFea super(store, itemTypeService,config); } - areaInHa(feature:Feature):number { + areaInHa(feature:Feature):number { if(!feature) return 0; // get area from faeture if 0 calculate from polygon let a = feature.get('area'); if(a) return a; - return getArea(feature.getGeometry(),{projectio:"EPSG:3857"}) / 10000; + return getArea(feature.getGeometry(),{projection:"EPSG:3857"}) / 10000; } } diff --git a/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.ts b/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.ts index 8a37cdb..bfde907 100644 --- a/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.ts +++ b/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.ts @@ -1,5 +1,6 @@ import { Component, Input, Injectable,Directive} from '@angular/core'; import { Feature } from 'ol'; +import { Geometry } from 'ol/geom'; import { Store } from '@ngrx/store'; import * as mapReducers from '../../reducers/map.reducer'; import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common'; @@ -9,7 +10,7 @@ import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common'; @Injectable() @Directive() export abstract class AbstractFeatureListFeatureComponent { - @Input() feature: Feature + @Input() feature: Feature constructor(public store: Store, public itemTypeService: ItemTypeService,public config:AppConfig) { } diff --git a/projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts b/projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts index 241de46..097e0d0 100644 --- a/projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts +++ b/projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts @@ -1,6 +1,7 @@ import { Component, Input, Injectable,Directive,SimpleChanges } from '@angular/core'; import { Location } from '@angular/common'; import { Feature } from 'ol'; +import { Geometry} from 'ol/geom'; import { Store,Action} from '@ngrx/store'; import * as mapReducers from '../../reducers/map.reducer'; import { commonReducers,ItemTypeService, IItem, Item } from '@farmmaps/common'; @@ -14,20 +15,20 @@ import { IQueryState } from '@farmmaps/common'; @Injectable() @Directive() export abstract class AbstractFeatureListComponent { - @Input() features: Array; + @Input() features: Array>; @Input() queryState: IQueryState; - @Input() selectedFeature: Feature; + @Input() selectedFeature: Feature; constructor(public store: Store, public itemTypeService: ItemTypeService, private location: Location) { } - handleFeatureClick(feature:Feature) { + handleFeatureClick(feature:Feature) { if(feature) { let action = this.getAction(feature); this.store.dispatch(action); } } - getAction(feature:Feature):Action { + getAction(feature:Feature):Action { var newQuery: any = tassign(mapReducers.initialState.queryState); newQuery.parentCode = feature.get('parentCode'); newQuery.itemCode = feature.get('code'); @@ -48,7 +49,7 @@ export abstract class AbstractFeatureListComponent { this.location.back(); } - isFeatureSelected(feature:Feature):boolean { + isFeatureSelected(feature:Feature):boolean { if(!this.selectedFeature) return false; return feature.getId() == this.selectedFeature.getId(); } diff --git a/projects/common-map/src/fm-map/components/feature-thumbnail/feature-thumbnail.component.ts b/projects/common-map/src/fm-map/components/feature-thumbnail/feature-thumbnail.component.ts index ec01356..d5e61a5 100644 --- a/projects/common-map/src/fm-map/components/feature-thumbnail/feature-thumbnail.component.ts +++ b/projects/common-map/src/fm-map/components/feature-thumbnail/feature-thumbnail.component.ts @@ -16,7 +16,7 @@ export class GeometryThumbnailComponent implements OnInit { @ViewChild('canvas') canvas; @ViewChild('container') container; - @Input('feature') feature:Feature; + @Input('feature') feature:Feature; ngOnInit(): void { } diff --git a/projects/common-map/src/fm-map/components/if-zoom-to-show/if-zoom-to-show.directive.ts b/projects/common-map/src/fm-map/components/if-zoom-to-show/if-zoom-to-show.directive.ts index b2b8b4e..15172c6 100644 --- a/projects/common-map/src/fm-map/components/if-zoom-to-show/if-zoom-to-show.directive.ts +++ b/projects/common-map/src/fm-map/components/if-zoom-to-show/if-zoom-to-show.directive.ts @@ -1,5 +1,6 @@ import { Directive, ViewContainerRef,TemplateRef,OnInit,Input, OnChanges } from '@angular/core'; -import { layer } from 'ol'; +import { Layer } from 'ol/layer'; +import { Source } from 'ol/source'; import { MapComponent } from 'ngx-openlayers'; @Directive({ @@ -7,7 +8,7 @@ import { MapComponent } from 'ngx-openlayers'; }) export class ifZoomToShowDirective implements OnInit { @Input() - set fmMapIfZoomToShow(layer:layer) { + set fmMapIfZoomToShow(layer:Layer) { this.layer$=layer; this.checkZoom(); } @@ -24,7 +25,7 @@ export class ifZoomToShowDirective implements OnInit { this.checkZoom(); } - private layer$:layer; + private layer$:Layer; private thenTemplate$:TemplateRef; private elseTemplate$:TemplateRef; private showView = false; diff --git a/projects/common-map/src/fm-map/components/map/map.component.ts b/projects/common-map/src/fm-map/components/map/map.component.ts index 4745d0e..f3723bc 100644 --- a/projects/common-map/src/fm-map/components/map/map.component.ts +++ b/projects/common-map/src/fm-map/components/map/map.component.ts @@ -29,6 +29,7 @@ import {commonReducers} from '@farmmaps/common'; import {commonActions} from '@farmmaps/common'; import {Feature} from 'ol'; +import {Geometry} from 'ol/geom'; import {Extent,createEmpty,extend } from 'ol/extent'; import {transform} from 'ol/proj'; import { tassign } from 'tassign'; @@ -46,7 +47,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { public openedModalName$: Observable = this.store.select(commonReducers.selectOpenedModalName); public itemTypes$: Observable<{ [id: string]: IItemType }>; public mapState$: Observable = this.store.select(mapReducers.selectGetMapState); - public features$: Observable> = this.store.select(mapReducers.selectGetFeatures); + public features$: Observable>> = this.store.select(mapReducers.selectGetFeatures); public overlayLayers$: Observable> = this.store.select(mapReducers.selectGetOverlayLayers); public selectedOverlayLayer$: Observable = this.store.select(mapReducers.selectGetSelectedOverlayLayer); public selectedItemLayer$: Observable = this.store.select(mapReducers.selectGetSelectedItemLayer); @@ -63,8 +64,8 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { public parentCode$: Observable =this.store.select(mapReducers.selectGetParentCode); public panelVisible$: Observable = this.store.select(mapReducers.selectGetPanelVisible); public panelCollapsed$: Observable = this.store.select(mapReducers.selectGetPanelCollapsed); - public selectedFeature$: Observable = this.store.select(mapReducers.selectGetSelectedFeature); - public clickedFeature: Subject = new Subject(); + public selectedFeature$: Observable> = this.store.select(mapReducers.selectGetSelectedFeature); + public clickedFeature: Subject> = new Subject>(); public selectedItem$: Observable = this.store.select(mapReducers.selectGetSelectedItem); public parentItem$: Observable =this.store.select(mapReducers.selectGetParentItem); public queryState$: Observable = this.store.select(mapReducers.selectGetQueryState); @@ -163,11 +164,11 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { this.uploadService.addFiles(droppedFile.files, droppedFile.event, { parentCode:droppedFile.parentCode, geometry:droppedFile.geometry }); } - handleFeatureClick(feature: Feature) { + handleFeatureClick(feature: Feature) { this.clickedFeature.next(feature); } - handleFeatureHover(feature: Feature) { + handleFeatureHover(feature: Feature) { this.store.dispatch(new mapActions.SelectFeature(feature)); } diff --git a/projects/common-map/src/fm-map/components/zoom-to-show-alert/zoom-to-show-alert.component.ts b/projects/common-map/src/fm-map/components/zoom-to-show-alert/zoom-to-show-alert.component.ts index 954ad5d..6df314e 100644 --- a/projects/common-map/src/fm-map/components/zoom-to-show-alert/zoom-to-show-alert.component.ts +++ b/projects/common-map/src/fm-map/components/zoom-to-show-alert/zoom-to-show-alert.component.ts @@ -1,14 +1,15 @@ import { Component, Input } from '@angular/core'; -import { layer } from 'ol'; +import { Layer } from 'ol/layer'; +import { Source } from 'ol/source'; @Component({ selector: 'fm-map-zoom-to-show-alert', template: '
 Zoom in to show layer
' }) export class ZoomToShowAlert { - public layer$: layer; + public layer$: Layer; @Input() - set layer(layer:layer) { + set layer(layer:Layer) { this.layer$ = layer; } } diff --git a/projects/common-map/src/fm-map/effects/map.effects.ts b/projects/common-map/src/fm-map/effects/map.effects.ts index ff2290f..a7d02cc 100644 --- a/projects/common-map/src/fm-map/effects/map.effects.ts +++ b/projects/common-map/src/fm-map/effects/map.effects.ts @@ -11,7 +11,7 @@ import { withLatestFrom, switchMap, map, catchError, mergeMap } from 'rxjs/opera import {GeoJSON,WKT} from 'ol/format'; import {Feature} from 'ol'; import { getCenter,createEmpty,extend } from 'ol/extent'; -import {Point} from 'ol/geom' +import {Point,Geometry} from 'ol/geom' import * as mapActions from '../actions/map.actions'; @@ -50,7 +50,7 @@ export class MapEffects { private _wktFormat: WKT; private overrideSelectedItemLayer: boolean = false; - private updateFeatureGeometry(feature:Feature, updateEvent:commonActions.DeviceUpdateEvent): Feature { + private updateFeatureGeometry(feature:Feature, updateEvent:commonActions.DeviceUpdateEvent): Feature { let newFeature = feature.clone(); var f = this._wktFormat.readFeature(updateEvent.attributes["geometry"],{ dataProjection: 'EPSG:4326', @@ -153,7 +153,7 @@ export class MapEffects { if (!action.query.bboxFilter) { if (extent) { for (let f of action.features) { - extend(extent, (f as Feature).getGeometry().getExtent()); + extend(extent, (f as Feature).getGeometry().getExtent()); } if(action.features && action.features.length >0) { actions.push(new mapActions.SetExtent(extent)); @@ -169,7 +169,7 @@ export class MapEffects { let extent = createEmpty(); if (extent) { for (let f of action.features) { - extend(extent, (f as Feature).getGeometry().getExtent()); + extend(extent, (f as Feature).getGeometry().getExtent()); } if(action.features.length>0) return of(new mapActions.SetExtent(extent)); } @@ -256,7 +256,7 @@ export class MapEffects { withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)), mergeMap(([action, features]) => { let deviceUpdateEventAction = action as commonActions.DeviceUpdateEvent; - var feature: Feature = null; + var feature: Feature = null; for (let f of features) { if (f.getId() == deviceUpdateEventAction.itemCode) { feature = f; diff --git a/projects/common-map/src/fm-map/models/item.layer.ts b/projects/common-map/src/fm-map/models/item.layer.ts index ede7354..3840ff9 100644 --- a/projects/common-map/src/fm-map/models/item.layer.ts +++ b/projects/common-map/src/fm-map/models/item.layer.ts @@ -1,9 +1,10 @@ import { IItem,IListItem } from '@farmmaps/common'; import {Layer} from 'ol/layer'; +import { Source } from 'ol/source'; export interface IItemLayer { item: IItem, - layer: Layer, + layer: Layer, visible: boolean, legendVisible:boolean, projection: string, @@ -13,7 +14,7 @@ export interface IItemLayer { export class ItemLayer implements IItemLayer { public item: IItem; - public layer: Layer = null; + public layer: Layer = null; public visible: boolean = true; public legendVisible: boolean = false; public projection: string; diff --git a/projects/common-map/src/fm-map/models/style.cache.ts b/projects/common-map/src/fm-map/models/style.cache.ts index 667760b..e464d15 100644 --- a/projects/common-map/src/fm-map/models/style.cache.ts +++ b/projects/common-map/src/fm-map/models/style.cache.ts @@ -1,5 +1,7 @@ -import {Style,Feature} from 'ol'; +import {Feature} from 'ol'; +import { Style } from 'ol/style'; +import {Geometry } from 'ol/geom'; export interface IStyles{ - [id: string]: Style | (Feature); + [id: string]: Style | (Feature); }; \ No newline at end of file diff --git a/projects/common-map/src/fm-map/reducers/map.reducer.ts b/projects/common-map/src/fm-map/reducers/map.reducer.ts index 86253e1..c23aed0 100644 --- a/projects/common-map/src/fm-map/reducers/map.reducer.ts +++ b/projects/common-map/src/fm-map/reducers/map.reducer.ts @@ -11,6 +11,7 @@ import {commonActions} from '@farmmaps/common'; import { createSelector, createFeatureSelector } from '@ngrx/store'; import {Feature} from 'ol'; +import {Geometry} from 'ol/geom'; import { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store'; @@ -45,10 +46,10 @@ export interface State { queryState: IQueryState, query:IQuery, parentCode: string, - features: Array, + features: Array>, panelVisible: boolean, panelCollapsed: boolean, - selectedFeature: Feature, + selectedFeature: Feature, selectedItem:IItem, parentItem:IItem, clearEnabled: boolean, diff --git a/projects/common-map/tsconfig.lib.json b/projects/common-map/tsconfig.lib.json index 250ae7a..a78ed73 100644 --- a/projects/common-map/tsconfig.lib.json +++ b/projects/common-map/tsconfig.lib.json @@ -22,8 +22,7 @@ "strictMetadataEmit": true, "fullTemplateTypeCheck": true, "strictInjectionParameters": true, - "enableResourceInlining": true, - "enableIvy": false + "enableResourceInlining": true }, "exclude": [ "src/test.ts", diff --git a/projects/common-map3d/tsconfig.lib.json b/projects/common-map3d/tsconfig.lib.json index 250ae7a..a78ed73 100644 --- a/projects/common-map3d/tsconfig.lib.json +++ b/projects/common-map3d/tsconfig.lib.json @@ -22,8 +22,7 @@ "strictMetadataEmit": true, "fullTemplateTypeCheck": true, "strictInjectionParameters": true, - "enableResourceInlining": true, - "enableIvy": false + "enableResourceInlining": true }, "exclude": [ "src/test.ts", diff --git a/projects/common-map3d/tsconfig.lib.prod.json b/projects/common-map3d/tsconfig.lib.prod.json index 5615c27..fb40dbb 100644 --- a/projects/common-map3d/tsconfig.lib.prod.json +++ b/projects/common-map3d/tsconfig.lib.prod.json @@ -3,8 +3,5 @@ "extends": "./tsconfig.lib.json", "compilerOptions": { "declarationMap": false - }, - "angularCompilerOptions": { - "enableIvy": false } } diff --git a/projects/common/src/fm/common.module.ts b/projects/common/src/fm/common.module.ts index 82379b5..eaae409 100644 --- a/projects/common/src/fm/common.module.ts +++ b/projects/common/src/fm/common.module.ts @@ -110,7 +110,9 @@ export { IGradientstop, BackButtonComponent, AvatarComponent, - EditImageModalComponent + EditImageModalComponent, + GradientComponent, + GradientSelectComponent }; @NgModule({ diff --git a/projects/common/tsconfig.lib.json b/projects/common/tsconfig.lib.json index 7a13f38..1416e7f 100644 --- a/projects/common/tsconfig.lib.json +++ b/projects/common/tsconfig.lib.json @@ -30,8 +30,7 @@ "strictMetadataEmit": true, "fullTemplateTypeCheck": true, "strictInjectionParameters": true, - "enableResourceInlining": true, - "enableIvy": false + "enableResourceInlining": true }, "exclude": [ "src/test.ts", diff --git a/projects/common/tsconfig.lib.prod.json b/projects/common/tsconfig.lib.prod.json index 2f184f1..cfe6512 100644 --- a/projects/common/tsconfig.lib.prod.json +++ b/projects/common/tsconfig.lib.prod.json @@ -30,8 +30,7 @@ "strictMetadataEmit": true, "fullTemplateTypeCheck": true, "strictInjectionParameters": true, - "enableResourceInlining": true, - "enableIvy": false + "enableResourceInlining": true }, "exclude": [ "src/test.ts", diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json index f17d500..f3a1b80 100644 --- a/src/tsconfig.app.json +++ b/src/tsconfig.app.json @@ -10,8 +10,5 @@ ], "include": [ "src/**/*.d.ts" - ], - "angularCompilerOptions": { - "enableIvy": false - } + ] } diff --git a/tsconfig.json b/tsconfig.json index 26caf36..0677ae0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,7 @@ "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "importHelpers": true, + "skipLibCheck": true, "target": "es2015", "typeRoots": [ "node_modules/@types"