Skip to content

Commit

Permalink
Merge branch 'feature/layer-group-from-msp' of https://github.com/inf…
Browse files Browse the repository at this point in the history
…ra-geo-ouverte/igo2-lib into feature/layer-group-from-msp
  • Loading branch information
pelord committed Nov 7, 2024
2 parents 366767b + e6cadaa commit fda185f
Show file tree
Hide file tree
Showing 63 changed files with 202 additions and 280 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
TreeFlatNode
} from './tree-drag-drop.interface';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface TreeDropEvent<T = any> {
node: TreeFlatNode<T>;
ref: TreeFlatNode<T>;
Expand Down Expand Up @@ -79,11 +80,11 @@ export class TreeDragDropDirective implements AfterContentInit, OnDestroy {
// eslint-disable-next-line @angular-eslint/no-output-on-prefix
@Output() onDropError = new EventEmitter<DropPermission>();

@HostListener('dragover', ['$event']) hostDragOver(event: any): void {
@HostListener('dragover', ['$event']) hostDragOver(event: Event): void {
event.preventDefault();
}

@HostListener('drop', ['$event']) hostDrop(event: any): void {
@HostListener('drop', ['$event']) hostDrop(event: DragEvent): void {
this.drop(event);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/locale/en.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dragDrop": {
"cannot": {
"dropInsideItself": "Unable to move the item inside itself",
"maxLevel": "The maximum hierarchical level is {{value}}"
"maxLevel": "The maximum hierarchical level is reached ({{value}})"
}
},
"selectValueDialog": {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/locale/fr.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dragDrop": {
"cannot": {
"dropInsideItself": "Impossible de bouger l'item à l'intérieur de lui même",
"maxLevel": "Le maximum de niveau hiérarchique est de {{value}}"
"maxLevel": "Le maximum de niveau hiérarchique est atteint ({{value}})"
}
},
"selectValueDialog": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import {
FormsModule,
ReactiveFormsModule,
Expand All @@ -21,8 +21,8 @@ import { IgoLanguageModule } from '@igo2/core/language';
import { MessageService } from '@igo2/core/message';
import { type AnyLayer, type IgoMap, VectorLayer } from '@igo2/geo';

import { BehaviorSubject, Subscription } from 'rxjs';
import { filter, take } from 'rxjs/operators';
import { BehaviorSubject } from 'rxjs';
import { take } from 'rxjs/operators';

import { DetailedContext } from '../../context-manager/shared/context.interface';
import { ContextService } from '../../context-manager/shared/context.service';
Expand Down Expand Up @@ -57,21 +57,19 @@ import {
IgoLanguageModule
]
})
export class ContextImportExportComponent implements OnInit, OnDestroy {
export class ContextImportExportComponent implements OnInit {
public form: UntypedFormGroup;
public layers: VectorLayer[];
public inputProj = 'EPSG:4326';
public loading$ = new BehaviorSubject(false);
public forceNaming = false;
public layerList: AnyLayer[];
public userControlledLayerList: AnyLayer[];
public userControlledLayerList: readonly AnyLayer[];
public res: DetailedContext;
private clientSideFileSizeMax: number;
public fileSizeMb: number;
public activeImportExport = 'import';

private layers$$: Subscription;

@Input() map: IgoMap;

constructor(
Expand All @@ -92,12 +90,9 @@ export class ContextImportExportComponent implements OnInit, OnDestroy {
this.clientSideFileSizeMax =
(configFileSizeMb ? configFileSizeMb : 30) * Math.pow(1024, 2);
this.fileSizeMb = this.clientSideFileSizeMax / Math.pow(1024, 2);
this.layers$$ = this.map.layerController.layers$
.pipe(filter((layers) => !!layers))
.subscribe((layers) => {
this.layerList = layers;
this.userControlledLayerList = layers;
});

this.layerList = this.map.layerController.all;
this.userControlledLayerList = this.map.layerController.treeLayers;
}

importFiles(files: File[]) {
Expand Down Expand Up @@ -180,8 +175,4 @@ export class ContextImportExportComponent implements OnInit, OnDestroy {
onImportExportChange(event) {
this.activeImportExport = event.value;
}

ngOnDestroy(): void {
this.layers$$.unsubscribe();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function addImportedFeaturesToMap(
visible: extraFeatures.visible,
opacity: extraFeatures.opacity
});
map.addLayer(layer);
map.layerController.add(layer);

return layer;
}
Expand Down Expand Up @@ -268,7 +268,7 @@ export function addImportedFeaturesStyledToMap(
opacity: extraFeatures.opacity,
visible: extraFeatures.visible
});
map.addLayer(layer);
map.layerController.add(layer);

return layer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LanguageService } from '@igo2/core/language';
import { Message, MessageService } from '@igo2/core/message';
import { RouteService } from '@igo2/core/route';
import { StorageService } from '@igo2/core/storage';
import type { AnyLayer, Layer, MapBase } from '@igo2/geo';
import type { AnyLayer, IgoMap, Layer } from '@igo2/geo';
import { ExportService, isLayerGroup } from '@igo2/geo';
import { ObjectUtils, uuid } from '@igo2/utils';

Expand Down Expand Up @@ -434,7 +434,7 @@ export class ContextService {
this.editedContext$.next(context);
}

getContextFromMap(igoMap: MapBase, empty?: boolean): DetailedContext {
getContextFromMap(igoMap: IgoMap, empty?: boolean): DetailedContext {
const view = igoMap.ol.getView();
const proj = view.getProjection().getCode();
const center = new olPoint(view.getCenter()).transform(proj, 'EPSG:4326');
Expand Down Expand Up @@ -480,7 +480,7 @@ export class ContextService {
}

getContextFromLayers(
igoMap: MapBase,
igoMap: IgoMap,
layers: AnyLayer[],
name: string,
keepCurrentView?: boolean
Expand Down Expand Up @@ -633,7 +633,7 @@ export class ContextService {
}
}

getContextLayers(map: MapBase) {
getContextLayers(map: IgoMap) {
return map.layerController.treeLayers;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class LayerContextDirective implements OnInit, OnDestroy {
if (this.removeLayersOnContextChange === true) {
this.map.layerController.reset();
} else {
this.map.removeLayer(...this.contextLayers);
this.map.layerController.remove(...this.contextLayers);
}
this.contextLayers = [];
this.layerService.unavailableLayers = [];
Expand Down Expand Up @@ -139,7 +139,7 @@ export class LayerContextDirective implements OnInit, OnDestroy {

const layersSorted = sortLayersByZindex(layersFiltrered, 'asc');
this.contextLayers.concat(layersSorted);
this.map.addLayer(...layersSorted);
this.map.layerController.add(...layersSorted);
}

private computeLayerVisibilityFromUrl(layer: AnyLayer): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class CatalogBrowserLayerComponent implements OnInit, OnDestroy {

isVisible() {
if (this.layer?.id) {
const layer = this.map.layerController.getBySourceId(this.layer?.id);
const layer = this.map.layerController.getById(this.layer?.id);
this.isVisible$.next(layer?.displayed);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class CatalogBrowserComponent implements OnInit, OnDestroy {
this.map.layersAddedByClick$.next(layers);
}
this.store.state.updateMany(catalogLayers, { added: true });
this.map.addLayer(...layers.filter(Boolean));
this.map.layerController.add(...layers.filter(Boolean));
});
}

Expand All @@ -209,14 +209,16 @@ export class CatalogBrowserComponent implements OnInit, OnDestroy {
layers.forEach((layer: CatalogItemLayer) => {
this.store.state.update(layer, { added: false });
if (layer.options.baseLayer === true) {
const currLayer = this.map.getLayerById(String(layer.options.id));
const currLayer = this.map.layerController.getById(
String(layer.options.id)
);
if (currLayer !== undefined) {
this.map.removeLayer(currLayer);
this.map.layerController.remove(currLayer);
}
} else {
const currLayer = this.map.layerController.getBySourceId(layer.id);
const currLayer = this.map.layerController.getById(layer.id);
if (currLayer !== undefined) {
this.map.removeLayer(currLayer);
this.map.layerController.remove(currLayer);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import {
TimeFilterStyle,
TimeFilterType
} from '../../filter/shared/time-filter.enum';
import type {
ItemStyleOptions,
LegendOptions
} from '../../layer/shared/layers/legend.interface';
import { MapService } from '../../map/shared/map.service';
import { getResolutionFromScale } from '../../map/shared/map.utils';
import {
Expand All @@ -34,9 +38,6 @@ import { TileArcGISRestDataSourceOptions } from './datasources/tilearcgisrest-da
import { WMSDataSourceOptions } from './datasources/wms-datasource.interface';
import { WMTSDataSourceOptions } from './datasources/wmts-datasource.interface';

type ItemStyleOptions = any;
type LegendOptions = any;

@Injectable({
providedIn: 'root'
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OgcFiltersOptions } from '../../../filter';
import { FeatureDataSourceOptions } from './feature-datasource.interface';
import type { OgcFiltersOptions } from '../../../filter';
import type { FeatureDataSourceOptions } from './feature-datasource.interface';

export interface WFSDataSourceOptions extends FeatureDataSourceOptions {
// type?: 'wfs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ServerType } from 'ol/source/wms';

import { OgcFiltersOptions } from '../../../filter';
import { TimeFilterOptions } from '../../../filter/shared/time-filter.interface';
import { DataSourceOptions } from './datasource.interface';
import { WFSDataSourceOptionsParams } from './wfs-datasource.interface';
import type { OgcFiltersOptions } from '../../../filter';
import type { TimeFilterOptions } from '../../../filter/shared/time-filter.interface';
import type { DataSourceOptions } from './datasource.interface';
import type { WFSDataSourceOptionsParams } from './wfs-datasource.interface';

export interface WMSDataSourceOptions extends DataSourceOptions {
// type?: 'wms';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';

import {
AnyDataSourceOptions,
ArcGISRestDataSourceOptions,
ArcGISRestImageDataSourceOptions,
TileArcGISRestDataSourceOptions,
Expand Down Expand Up @@ -125,21 +124,4 @@ export class OptionsApiService extends OptionsService {
)
);
}

private handleSourceOptions<T extends AnyDataSourceOptions>(res: {
sourceOptions: T;
layerOptions: Record<string, string>;
}): T {
if (!res || !res.sourceOptions) {
return {} as T;
}
if (res.layerOptions) {
res.sourceOptions._layerOptionsFromSource = res.layerOptions;
} else {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { sourceOptions, layerOptions, ...restOptions } = res;
res.sourceOptions._layerOptionsFromSource = restOptions;
}
return res.sourceOptions;
}
}
4 changes: 2 additions & 2 deletions packages/geo/src/lib/feature/shared/feature-store.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function tryBindStoreLayer(
): VectorLayer {
if (store.layer !== undefined) {
if (!store.map.layerController.getById(store.layer.id)) {
store.map.addLayer(store.layer);
store.map.layerController.add(store.layer);
}
return store.layer;
}
Expand All @@ -27,7 +27,7 @@ export function tryBindStoreLayer(
});
store.bindLayer(layer);
if (!store.map.layerController.getById(store.layer.id)) {
store.map.addLayer(store.layer);
store.map.layerController.add(store.layer);
}

return layer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,6 @@ export class FeatureStoreSelectionStrategy extends EntityStoreStrategy {
*/
private removeOverlayLayer() {
this.overlayStore.source.ol.clear();
this.map.removeLayer(this.overlayStore.layer);
this.map.layerController.remove(this.overlayStore.layer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class TimeFilterFormComponent implements OnInit {
public startListYears: string[] = [];
public endListYears: string[] = [];

public interval: any;
public interval: number;
public playIcon = 'play-circle';
public resetIcon = 'replay';

Expand Down Expand Up @@ -383,7 +383,7 @@ export class TimeFilterFormComponent implements OnInit {
this.stopFilter();
} else {
this.playIcon = 'pause_circle';
this.interval = setInterval(
this.interval = window.setInterval(
(that) => {
let newMinDateNumber;
const maxDateNumber = new Date(that.max);
Expand Down
1 change: 1 addition & 0 deletions packages/geo/src/lib/geometry/shared/controls/modify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export class ModifyControl {
return;
}

this.deactivateModifyInteraction();
this.deactivateModifyInteraction();
this.olModifyInteraction = undefined;
}
Expand Down
Loading

0 comments on commit fda185f

Please sign in to comment.