Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedHamouGisaia committed Dec 12, 2024
1 parent 64644f2 commit 46303b7
Show file tree
Hide file tree
Showing 46 changed files with 913 additions and 495 deletions.
19 changes: 19 additions & 0 deletions projects/arlas-map/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to Gisaïa under one or more contributor
* license agreements. See the NOTICE.txt file distributed with
* this work for additional information regarding copyright
* ownership. Gisaïa licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

Expand Down
40 changes: 29 additions & 11 deletions projects/arlas-map/src/lib/arlas-map-logic.service.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
/*
* Licensed to Gisaïa under one or more contributor
* license agreements. See the NOTICE.txt file distributed with
* this work for additional information regarding copyright
* ownership. Gisaïa licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { Injectable } from '@angular/core';
import { ArlasMapService } from './map/service/arlas-map.service';
import { FeatureCollection } from '@turf/helpers';
import { AbstractArlasMapGL } from './map/AbstractArlasMapGL';
import { ArlasMapSource } from './map/model/sources';
import { VisualisationSetConfig } from './map/model/visualisationsets';
import { ARLAS_ID, ExternalEvent, FILLSTROKE_LAYER_PREFIX, MapLayers, SCROLLABLE_ARLAS_ID } from './map/model/layers';
import { ExternalEvent, MapLayers } from './map/model/layers';
import { ElementIdentifier } from 'arlas-web-components';


@Injectable({
providedIn: 'root'
})
export abstract class ArlasMapFunctionalService {
export abstract class MapLogicService {
/** IMPORTANT NOTE: All the attributes/params that are typed with "any", will have the right type in the implementation. */
public dataSources: any[] = [];
public abstract layersMap: Map<string, any>;
Expand All @@ -28,7 +47,7 @@ export abstract class ArlasMapFunctionalService {
public declareArlasDataSources(dataSourcesIds: Set<string>, data: FeatureCollection<GeoJSON.Geometry>, map: AbstractArlasMapGL) {
if (dataSourcesIds) {
dataSourcesIds.forEach(sourceId => {
const source = this.mapService.createGeojsonSource(data)
const source = this.mapService.createGeojsonSource(data);
this.dataSources.push(source);
/** For an implementation that doesn't add a source to map
* --- for instance Openalayers, adds the source to layer ---
Expand All @@ -41,7 +60,7 @@ export abstract class ArlasMapFunctionalService {

public declareLabelSources(labelSourceId: string, data: FeatureCollection<GeoJSON.Geometry>, map: AbstractArlasMapGL) {
if (labelSourceId) {
const source = this.mapService.createGeojsonSource(data)
const source = this.mapService.createGeojsonSource(data);
this.mapService.setSource(labelSourceId, source, map);
}
}
Expand Down Expand Up @@ -129,7 +148,7 @@ export abstract class ArlasMapFunctionalService {
if (!!visualisation.layers && visualisation.enabled) {
for (let j = visualisation.layers.length - 1; j >= 0; j--) {
const l = visualisation.layers[j];
this.mapService.moveArlasDataLayer(map, l, this.layersMap)
this.mapService.moveArlasDataLayer(map, l, this.layersMap);
}
}
}
Expand All @@ -143,7 +162,8 @@ export abstract class ArlasMapFunctionalService {
}


public filterLayersOnEvent(mapLayers: MapLayers<any>, map: AbstractArlasMapGL, visibilityCondition: boolean, visibilityFilter: Array<any>, visibilityEvent: ExternalEvent,
public filterLayersOnEvent(mapLayers: MapLayers<any>, map: AbstractArlasMapGL,
visibilityCondition: boolean, visibilityFilter: Array<any>, visibilityEvent: ExternalEvent,
collection?: string): void {
if (mapLayers && mapLayers.externalEventLayers) {
mapLayers.externalEventLayers.filter(layer => layer.on === visibilityEvent).forEach(layer => {
Expand Down Expand Up @@ -193,7 +213,8 @@ export abstract class ArlasMapFunctionalService {
}
}

public highlightFeature(mapLayers: MapLayers<any>, map: AbstractArlasMapGL, featureToHightLight: { isleaving: boolean; elementidentifier: ElementIdentifier; }) {
public highlightFeature(mapLayers: MapLayers<any>, map: AbstractArlasMapGL,
featureToHightLight: { isleaving: boolean; elementidentifier: ElementIdentifier; }) {
if (featureToHightLight && featureToHightLight.elementidentifier) {
const ids: Array<number | string> = [featureToHightLight.elementidentifier.idValue];
if (!isNaN(+featureToHightLight.elementidentifier.idValue)) {
Expand Down Expand Up @@ -290,7 +311,4 @@ export abstract class ArlasMapFunctionalService {
public abstract updateMapStyle(map: AbstractArlasMapGL, l: any, ids: Array<string | number>, sourceName: string): void;

public abstract getVisibleIdsFilter(map: AbstractArlasMapGL, layer: any, ids: Array<string | number>);



}
}
4 changes: 2 additions & 2 deletions projects/arlas-map/src/lib/arlas-map.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<div cdkDragHandle class="map__visu-layer-drag">
<mat-icon>drag_indicator</mat-icon>
</div>
<arlas-legend [collection]="l | getCollection: mapFunctionalService.layersMap " [enabled]="visu.enabled"
[layer]="l | getValue: mapFunctionalService.layersMap " [zoom]="map?.zoom"
<arlas-legend [collection]="l | getCollection: mapLogicService.layersMap " [enabled]="visu.enabled"
[layer]="l | getValue: mapLogicService.layersMap " [zoom]="map?.zoom"
(visibilityStatus)="emitLegendVisibility(visu.name, l, $event)" [legendUpdater]="legendUpdater"
[visibilityUpdater]="visibilityUpdater"
(downloadSourceEmitter)="downloadLayerSource($event)"></arlas-legend>
Expand Down
75 changes: 48 additions & 27 deletions projects/arlas-map/src/lib/arlas-map.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
/*
* Licensed to Gisaïa under one or more contributor
* license agreements. See the NOTICE.txt file distributed with
* this work for additional information regarding copyright
* ownership. Gisaïa licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { Component, EventEmitter, HostListener, Input, OnInit, Output, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { marker } from '@biesbjerg/ngx-translate-extract-marker';
import { Feature, FeatureCollection, Geometry, Polygon, polygon } from '@turf/helpers';
import { BasemapStyle } from './basemaps/basemap.config';
import { ArlasMapOffset, AbstractArlasMapGL, ElementIdentifier, MapConfig, ZOOM_IN, ZOOM_OUT, RESET_BEARING, CROSS_LAYER_PREFIX } from './map/AbstractArlasMapGL';
import {
ArlasMapOffset, AbstractArlasMapGL, ElementIdentifier, MapConfig,
ZOOM_IN, ZOOM_OUT, RESET_BEARING, CROSS_LAYER_PREFIX
} from './map/AbstractArlasMapGL';
import { IconConfig, ControlPosition, DrawControlsOption } from './map/model/controls';
import { AoiDimensions, BboxDrawCommand } from './draw/draw.models';
import { LegendData } from './legend/legend.config';
Expand All @@ -19,7 +41,7 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { TranslateService } from '@ngx-translate/core';
import { ArlasBasemaps } from './basemaps/basemaps.model';
import { ArlasMapService } from './map/service/arlas-map.service';
import * as styles from './draw/themes/default-theme'
import * as styles from './draw/themes/default-theme';
import limitVertexDirectSelectMode from './draw/modes/LimitVertexDirectSelectMode';
import validGeomDrawPolygonMode from './draw/modes/ValidGeomDrawPolygonMode';
import { circleMode } from './draw/modes/circles/circle.mode';
Expand All @@ -35,7 +57,7 @@ import { ARLAS_VSET } from './map/model/layers';
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
import { OnMoveResult } from './map/model/map';
import { MapMouseEvent } from './map/model/events';
import { ArlasMapFunctionalService } from './arlas-map-logic.service';
import { MapLogicService } from './arlas-map-logic.service';
import { latLngToWKT } from './map/tools';

@Component({
Expand Down Expand Up @@ -184,7 +206,8 @@ export class ArlasMapComponent implements OnInit {
/** @description Margin applied to the map extent. Data will be fetched in all this extent. */
@Input() public margePanForLoad: number;

/** @description Margin applied to the map extent. Before loading data, the components checks first if there are features already loaded in this extent. */
/** @description Margin applied to the map extent. Before loading data,

Check failure on line 209 in projects/arlas-map/src/lib/arlas-map.component.ts

View workflow job for this annotation

GitHub Actions / Lint, Build, Test & Documentation

Trailing spaces not allowed
* the components checks first if there are features already loaded in this extent. */
@Input() public margePanForTest: number;

/** @description A callback run before the Map makes a request for an external URL/ */
Expand Down Expand Up @@ -242,6 +265,7 @@ export class ArlasMapComponent implements OnInit {
/** @description Subject of [collection, [field, legendData]] map. The map subscribes to it to keep */
/** the legend updated with the data displayed on the map. */
@Input() public legendUpdater: Subject<Map<string, Map<string, LegendData>>> = new Subject();

/** @description Subject of [layerId, boolean] map. The map subscribes to it to keep */
/** the legend updated with the visibility of the layer.*/
@Input() public visibilityUpdater: Subject<Map<string, boolean>> = new Subject();
Expand All @@ -256,9 +280,6 @@ export class ArlasMapComponent implements OnInit {

/** ANGULAR OUTPUTS */


/** @description Subject of [layerId, boolean] map. The map subscribes to it to keep */
/** the legend updated with the visibility of the layer.*/declareArlasDataSources
/** @description Emits true after the map is loaded and all sources & layers are added. */
@Output() public onMapLoaded: Subject<boolean> = new Subject<boolean>();

Expand Down Expand Up @@ -306,7 +327,7 @@ export class ArlasMapComponent implements OnInit {
public constructor(private http: HttpClient, private drawService: MapboxAoiDrawService,
private basemapService: BasemapService, private _snackBar: MatSnackBar, private translate: TranslateService,
protected mapService: ArlasMapService,
protected mapFunctionalService: ArlasMapFunctionalService) {
protected mapLogicService: MapLogicService) {
this.aoiEditSubscription = this.drawService.editAoi$.subscribe(ae => this.onAoiEdit.emit(ae));
this.drawBboxSubscription = this.drawService.drawBbox$.subscribe({
next: (bboxDC: BboxDrawCommand) => {
Expand Down Expand Up @@ -368,7 +389,7 @@ export class ArlasMapComponent implements OnInit {
this.drawService.addFeatures(this.drawData, /** deleteOld */ true);
}
this.drawSelectionChanged = false;
this.mapFunctionalService.updateLabelSources(this.map.POLYGON_LABEL_SOURCE, this.polygonlabeldata, this.map);
this.mapLogicService.updateLabelSources(this.map.POLYGON_LABEL_SOURCE, this.polygonlabeldata, this.map);
}
if (changes['boundsToFit'] !== undefined) {
const newBoundsToFit = changes['boundsToFit'].currentValue;
Expand Down Expand Up @@ -555,18 +576,18 @@ export class ArlasMapComponent implements OnInit {
this.basemapService.declareProtomapProtocol(this.map);
this.basemapService.addProtomapBasemap(this.map);
this.addIcons();
this.mapFunctionalService.declareArlasDataSources(this.dataSources, this.emptyData, this.map);
this.mapFunctionalService.declareBasemapSources(this.mapSources, this.map);
this.mapFunctionalService.declareLabelSources('', this.polygonlabeldata, this.map);
this.mapFunctionalService.addArlasDataLayers(this.visualisationSetsConfig, this.mapLayers, this.map);
this.mapLogicService.declareArlasDataSources(this.dataSources, this.emptyData, this.map);
this.mapLogicService.declareBasemapSources(this.mapSources, this.map);
this.mapLogicService.declareLabelSources('', this.polygonlabeldata, this.map);
this.mapLogicService.addArlasDataLayers(this.visualisationSetsConfig, this.mapLayers, this.map);
this.bindLayerEvents();
});

this.mapService.onMapEvent('load', this.map, () => {
this.draw.changeMode('static');
if (this.mapLayers !== null) {
this.visibilityUpdater.subscribe(visibilityStatus => {
this.mapFunctionalService.updateVisibility(visibilityStatus, this.visualisationSetsConfig, this.map);
this.mapLogicService.updateVisibility(visibilityStatus, this.visualisationSetsConfig, this.map);
});
}
this.canvas = this.map.getCanvasContainer();
Expand Down Expand Up @@ -767,7 +788,7 @@ export class ArlasMapComponent implements OnInit {
this.onMapLoaded.next(true);
});

this.map.onMoveEnd(this.mapFunctionalService.visualisationsSets).subscribe((moveResult => {
this.map.onMoveEnd(this.mapLogicService.visualisationsSets).subscribe((moveResult => {
this.onMove.next(moveResult);
}));

Expand Down Expand Up @@ -862,7 +883,7 @@ export class ArlasMapComponent implements OnInit {

/** Sets the layers order according to the order of `visualisationSetsConfig` list*/
public reorderLayers() {
this.mapFunctionalService.reorderLayers(this.visualisationSetsConfig, this.map);
this.mapLogicService.reorderLayers(this.visualisationSetsConfig, this.map);
}

/** ------------------------------------------------------- VISUAL SEPERATOR - DRAWING ----------------------------------------- */
Expand All @@ -884,7 +905,7 @@ export class ArlasMapComponent implements OnInit {

private mousemove = (e) => {
// Capture the ongoing xy coordinates
this.current = this.mapService.getPointFromScreen(e, this.canvas)
this.current = this.mapService.getPointFromScreen(e, this.canvas);
// Append the box element if it doesnt exist
if (this.box === undefined) {
this.box = document.createElement('div');
Expand Down Expand Up @@ -941,10 +962,10 @@ export class ArlasMapComponent implements OnInit {

/**
* Emits the newly drawn bbox. It completes the drawBbox event emitted by the drawService.
* @param east
* @param south
* @param west
* @param north
* @param east
* @param south
* @param west
* @param north
*/
protected drawBbox(east, south, west, north) {
const coordinates = [[
Expand Down Expand Up @@ -1120,7 +1141,7 @@ export class ArlasMapComponent implements OnInit {
}

public emitVisualisations(visualisationName: string) {
const layers = this.mapFunctionalService.updateLayoutVisibility(visualisationName, this.visualisationSetsConfig, this.map);
const layers = this.mapLogicService.updateLayoutVisibility(visualisationName, this.visualisationSetsConfig, this.map);
this.visualisations.emit(layers);
this.reorderLayers();
}
Expand All @@ -1144,9 +1165,9 @@ export class ArlasMapComponent implements OnInit {

/** puts the layers list in the new order after dropping */
public dropLayer(event: CdkDragDrop<string[]>, visuName: string) {
const layers = Array.from(this.mapFunctionalService.findVisualisationSetLayer(visuName, this.visualisationSetsConfig));
const layers = Array.from(this.mapLogicService.findVisualisationSetLayer(visuName, this.visualisationSetsConfig));
moveItemInArray(layers, event.previousIndex, event.currentIndex);
this.mapFunctionalService.setVisualisationSetLayers(visuName, layers, this.visualisationSetsConfig);
this.mapLogicService.setVisualisationSetLayers(visuName, layers, this.visualisationSetsConfig);
this.reorderLayers();
}

Expand All @@ -1168,7 +1189,7 @@ export class ArlasMapComponent implements OnInit {
}

public selectFeaturesByCollection(features: Array<ElementIdentifier>, collection: string) {
this.mapFunctionalService.selectFeaturesByCollection(this.mapLayers, this.map, features, collection);
this.mapLogicService.selectFeaturesByCollection(this.mapLayers, this.map, features, collection);
}

public hideBasemapSwitcher() {
Expand All @@ -1187,11 +1208,11 @@ export class ArlasMapComponent implements OnInit {
}

private highlightFeature(featureToHightLight: { isleaving: boolean; elementidentifier: ElementIdentifier; }) {
this.mapFunctionalService.highlightFeature(this.mapLayers, this.map, featureToHightLight);
this.mapLogicService.highlightFeature(this.mapLayers, this.map, featureToHightLight);
}

private selectFeatures(elementToSelect: Array<ElementIdentifier>) {
this.mapFunctionalService.selectFeatures(this.mapLayers, this.map, elementToSelect);
this.mapLogicService.selectFeatures(this.mapLayers, this.map, elementToSelect);
}

}
21 changes: 19 additions & 2 deletions projects/arlas-map/src/lib/arlas-map.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
/*
* Licensed to Gisaïa under one or more contributor
* license agreements. See the NOTICE.txt file distributed with
* this work for additional information regarding copyright
* ownership. Gisaïa licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { NgModule } from '@angular/core';
import { ArlasMapComponent } from './arlas-map.component';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { TranslateModule } from '@ngx-translate/core';
import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';
import { BasemapComponent } from './basemaps/basemap.component';
import { CoordinatesComponent } from './coordinates/coordinates.component';
import { MapboxAoiDrawService } from './draw/draw.service';
import { LayerIconComponent } from './legend/legend-icon/layer-icon.component';
import { LegendComponent } from './legend/legend.component';
Expand Down
21 changes: 20 additions & 1 deletion projects/arlas-map/src/lib/arlas-map.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to Gisaïa under one or more contributor
* license agreements. See the NOTICE.txt file distributed with
* this work for additional information regarding copyright
* ownership. Gisaïa licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({ name: 'getCollection' })
Expand All @@ -11,4 +30,4 @@ export class GetCollectionPipe implements PipeTransform {
}
return collection;
}
}
}
Loading

0 comments on commit 46303b7

Please sign in to comment.