Skip to content

Commit

Permalink
fix(lint): lint and fix excludeAttribute undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed Nov 5, 2019
1 parent 1373909 commit 0acacd2
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 67 deletions.
56 changes: 23 additions & 33 deletions demo/src/app/geo/feature/feature.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
styleUrls: ['./feature.component.scss']
})
export class AppFeatureComponent implements OnInit, OnDestroy {

public map = new IgoMap({
controls: {
attribution: {
Expand Down Expand Up @@ -52,7 +51,7 @@ export class AppFeatureComponent implements OnInit, OnDestroy {
]
};

public store = new FeatureStore([], {map: this.map});
public store = new FeatureStore([], { map: this.map });

constructor(
private languageService: LanguageService,
Expand Down Expand Up @@ -90,11 +89,7 @@ export class AppFeatureComponent implements OnInit, OnDestroy {
type: 'Feature',
geometry: {
type: 'LineString',
coordinates: [
[-72, 47.8],
[-73.5, 47.4],
[-72.4, 48.6]
]
coordinates: [[-72, 47.8], [-73.5, 47.4], [-72.4, 48.6]]
},
projection: 'EPSG:4326',
properties: {
Expand All @@ -108,11 +103,7 @@ export class AppFeatureComponent implements OnInit, OnDestroy {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [[
[-71, 46.8],
[-73, 47],
[-71.2, 46.6]
]]
coordinates: [[[-71, 46.8], [-73, 47], [-71.2, 46.6]]]
},
projection: 'EPSG:4326',
properties: {
Expand All @@ -123,22 +114,22 @@ export class AppFeatureComponent implements OnInit, OnDestroy {
}
]);

this.layerService.createAsyncLayer(
{
title: "MVT test",
visible: true,
sourceOptions: {
type: "mvt",
url: "https://ahocevar.com/geoserver/gwc/service/tms/1.0.0/ne:ne_10m_admin_0_countries@EPSG:900913@pbf/{z}/{x}/{-y}.pbf",
queryable: true
},
mapboxStyle: {
url: "assets/mapboxStyleExample-vectortile.json",
source: "ahocevar"
}
}
)
.subscribe(l => this.map.addLayer(l));
this.layerService
.createAsyncLayer({
title: 'MVT test',
visible: true,
sourceOptions: {
type: 'mvt',
url:
'https://ahocevar.com/geoserver/gwc/service/tms/1.0.0/ne:ne_10m_admin_0_countries@EPSG:900913@pbf/{z}/{x}/{-y}.pbf',
queryable: true
},
mapboxStyle: {
url: 'assets/mapboxStyleExample-vectortile.json',
source: 'ahocevar'
}
})
.subscribe(l => this.map.addLayer(l));

this.dataSourceService
.createAsyncDataSource({
Expand All @@ -148,13 +139,13 @@ export class AppFeatureComponent implements OnInit, OnDestroy {
const layer = this.layerService.createLayer({
title: 'Vector Layer',
source: dataSource,
animation:{
animation: {
duration: 2000
},
mapboxStyle: {
url: "assets/mapboxStyleExample-feature.json",
source: "source_nameX"
}
url: 'assets/mapboxStyleExample-feature.json',
source: 'source_nameX'
}
}) as VectorLayer;
this.map.addLayer(layer);
this.store.bindLayer(layer);
Expand All @@ -166,5 +157,4 @@ export class AppFeatureComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.store.destroy();
}

}
22 changes: 15 additions & 7 deletions packages/geo/src/lib/feature/shared/feature.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ import { FormGroup } from '@angular/forms';

import { GeoJsonGeometryTypes } from 'geojson';

import { EntityKey, EntityStoreOptions, EntityStoreStrategyOptions } from '@igo2/common';
import {
EntityKey,
EntityStoreOptions,
EntityStoreStrategyOptions
} from '@igo2/common';

import { VectorLayer } from '../../layer';
import { IgoMap } from '../../map';
import { FeatureMotion } from './feature.enums';
import OlFeature from 'ol/Feature';

export interface Feature<P = {[key: string]: any}> {
export interface Feature<P = { [key: string]: any }> {
type: string;
projection?: string;
geometry?: FeatureGeometry;
Expand All @@ -25,7 +29,7 @@ export interface FeatureMeta {
mapTitle?: string;
sourceTitle?: string;
order?: number;
alias?: {[key: string]: string};
alias?: { [key: string]: string };
revision?: number;
excludeAttribute?: Array<string>;
excludeAttributeOffline?: Array<string>;
Expand All @@ -41,7 +45,8 @@ export interface FeatureStoreOptions extends EntityStoreOptions {
layer?: VectorLayer;
}

export interface FeatureStoreStrategyOptions extends EntityStoreStrategyOptions {
export interface FeatureStoreStrategyOptions
extends EntityStoreStrategyOptions {
// When the store moves features into view, the view extent, which is also the features extent,
// is scaled by those factors, effectively resulting in a decentered view or a more zoomed in/out view.
// These factors are applied to the top, right, bottom and left directions, in that order.
Expand All @@ -52,14 +57,17 @@ export interface FeatureStoreStrategyOptions extends EntityStoreStrategyOptions
areaRatio?: number;
}

export interface FeatureStoreLoadingStrategyOptions extends FeatureStoreStrategyOptions {
export interface FeatureStoreLoadingStrategyOptions
extends FeatureStoreStrategyOptions {
getFeatureId?: (Feature) => EntityKey;
motion?: FeatureMotion;
}

export interface FeatureStoreLoadingLayerStrategyOptions extends FeatureStoreStrategyOptions {}
export interface FeatureStoreLoadingLayerStrategyOptions
extends FeatureStoreStrategyOptions {}

export interface FeatureStoreSelectionStrategyOptions extends FeatureStoreStrategyOptions {
export interface FeatureStoreSelectionStrategyOptions
extends FeatureStoreStrategyOptions {
map: IgoMap;
getFeatureId?: (Feature) => EntityKey;
motion?: FeatureMotion;
Expand Down
6 changes: 4 additions & 2 deletions packages/geo/src/lib/feature/shared/feature.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ export function featureFromOl(

if (olLayer) {
title = olLayer.get('title');
exclude = olLayer.get('sourceOptions').excludeAttribute;
excludeOffline = olLayer.get('sourceOptions').excludeAttributeOffline;
if (olLayer.get('sourceOptions')) {
exclude = olLayer.get('sourceOptions').excludeAttribute;
excludeOffline = olLayer.get('sourceOptions').excludeAttributeOffline;
}
} else {
title = olFeature.get('_title');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class OgcFilterableItemComponent implements OnInit {
@Input() map: IgoMap;

@Input() header: boolean = true;

get refreshFunc() {
return this.refreshFilters.bind(this);
}
Expand All @@ -57,14 +57,12 @@ export class OgcFilterableItemComponent implements OnInit {

ngOnInit() {
const ogcFilters = this.datasource.options.ogcFilters;
if (
ogcFilters.pushButtons &&
ogcFilters.pushButtons.length > 0) {
if (ogcFilters.advancedOgcFilters === undefined) {
ogcFilters.advancedOgcFilters = false;
}
this.hasPushButton = true;
if (ogcFilters.pushButtons && ogcFilters.pushButtons.length > 0) {
if (ogcFilters.advancedOgcFilters === undefined) {
ogcFilters.advancedOgcFilters = false;
}
this.hasPushButton = true;
}

switch (this.datasource.options.type) {
case 'wms':
Expand All @@ -83,9 +81,7 @@ export class OgcFilterableItemComponent implements OnInit {
JSON.stringify(ogcFilters.interfaceOgcFilters)
);
if (
ogcFilters.interfaceOgcFilters.filter(
f => f.wkt_geometry
).length >= 1
ogcFilters.interfaceOgcFilters.filter(f => f.wkt_geometry).length >= 1
) {
this.hasActiveSpatialFilter = true;
}
Expand All @@ -99,7 +95,8 @@ export class OgcFilterableItemComponent implements OnInit {

addFilterToSequence() {
this.filtersCollapsed = false;
const interfaceOgcFilters: OgcInterfaceFilterOptions[] = this.datasource.options.ogcFilters.interfaceOgcFilters;
const interfaceOgcFilters: OgcInterfaceFilterOptions[] = this.datasource
.options.ogcFilters.interfaceOgcFilters;
const arr = interfaceOgcFilters || [];
const lastLevel = arr.length === 0 ? 0 : arr[arr.length - 1].level;
let firstFieldName = '';
Expand Down Expand Up @@ -219,7 +216,10 @@ export class OgcFilterableItemComponent implements OnInit {
}

public addFilterDisabled(): boolean {
return (!this.datasource.options.sourceFields || this.datasource.options.sourceFields.length === 0);
return (
!this.datasource.options.sourceFields ||
this.datasource.options.sourceFields.length === 0
);
}

private changeOgcFiltersAdvancedOgcFilters(value: boolean) {
Expand Down
15 changes: 8 additions & 7 deletions packages/geo/src/lib/layer/shared/layer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class LayerService {
if (source === undefined) {
return undefined;
}
return this.createLayer( Object.assign(layerOptions, {source}));
return this.createLayer(Object.assign(layerOptions, { source }));
})
);
}
Expand Down Expand Up @@ -169,7 +169,7 @@ export class LayerService {
style
});

if(!olLayer) {
if (!olLayer) {
olLayer = new VectorLayer(layerOptionsOl);
}

Expand Down Expand Up @@ -203,18 +203,20 @@ export class LayerService {
style
});

if(!olLayer) {
if (!olLayer) {
olLayer = new VectorTileLayer(layerOptionsOl);
}

this.applyMapboxStyle(olLayer, layerOptionsOl);
return olLayer;
}

private applyMapboxStyle (layer: Layer, layerOptions: VectorTileLayerOptions ) {
private applyMapboxStyle(layer: Layer, layerOptions: VectorTileLayerOptions) {
if (layerOptions.mapboxStyle) {
const mapboxglStyle = this.getMapboxGlStyle(layerOptions.mapboxStyle.url).subscribe(res => {
stylefunction(layer.ol, res, layerOptions.mapboxStyle.source);
const mapboxglStyle = this.getMapboxGlStyle(
layerOptions.mapboxStyle.url
).subscribe(res => {
stylefunction(layer.ol, res, layerOptions.mapboxStyle.source);
});
}
}
Expand All @@ -228,5 +230,4 @@ export class LayerService {
})
);
}

}
9 changes: 6 additions & 3 deletions packages/geo/src/lib/layer/shared/layers/vector-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ export class VectorLayer extends Layer {
const opacity = easeOut(1 - elapsedRatio);
const newColor = ColorAsArray(this.options.animation.color || 'red');
newColor[3] = opacity;
let style = this.ol.getStyleFunction().call(this, feature).find(style=> {
return style.getImage();
});
let style = this.ol
.getStyleFunction()
.call(this, feature)
.find(style2 => {
return style2.getImage();
});
if (!style) {
style = this.ol.getStyleFunction().call(this, feature)[0];
}
Expand Down
5 changes: 3 additions & 2 deletions packages/geo/src/lib/query/shared/query.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,9 @@ export class QueryService {

let exclude;
if (layer.options.sourceOptions.type === 'wms') {
const sourceOptions = (layer.options.sourceOptions as WMSDataSourceOptions);
exclude = sourceOptions.excludeAttribute;
const sourceOptions = layer.options
.sourceOptions as WMSDataSourceOptions;
exclude = sourceOptions ? sourceOptions.excludeAttribute : undefined;
}

let title = this.getQueryTitle(feature, layer);
Expand Down

0 comments on commit 0acacd2

Please sign in to comment.