Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(imported vector): allow to store vector data and layer in indexeddb #1204

Merged
merged 82 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
f51f7c0
fix(demo): unable to add layers from the catalog
pelord Feb 21, 2023
95b1cba
refactor(*):unifying styles in a single directory
pelord Feb 28, 2023
f69bd04
refactor(*):unifying styles in a single directory
pelord Feb 28, 2023
4d928a4
refactor(style-modal): move to style directory
pelord Feb 28, 2023
0c5872f
wip
pelord Mar 1, 2023
b68c05b
fix(context): crash on context export with vector data (https://githu…
pelord Mar 1, 2023
f981045
Merge remote-tracking branch 'origin/exportContext_bug_localLayer_v2'…
pelord Mar 1, 2023
b204d99
refactor(import-style): random style based on attributes
pelord Mar 1, 2023
fcfa8ee
BREAKING CHANGE(style): Various style interface moved into igoStyle p…
pelord Mar 1, 2023
fc6cf79
wip
pelord Mar 1, 2023
e4d0249
wip
pelord Mar 2, 2023
0251237
wip
pelord Mar 2, 2023
f204a55
wip
pelord Mar 2, 2023
d0fd496
refactor(style-modal): renaming style-modal to style-modal-drawing
pelord Mar 3, 2023
9047e6a
feat(style): methods to change imported vector layer style (base styl…
pelord Mar 3, 2023
24c242d
Merge tag '1.14.2' into style
pelord Mar 15, 2023
c21585b
wip merge conflict resolution
pelord Mar 15, 2023
3ca31b0
Merge remote-tracking branch 'origin/next' into style
pelord Mar 15, 2023
5c0773b
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 16, 2023
c4510a3
feat(confirm-dialog): now support translations
pelord Mar 17, 2023
f97b911
feat(*): allow to store imported data to indexed db
pelord Mar 17, 2023
be738e9
Merge branch 'cd' into idbImport
pelord Mar 17, 2023
3356952
Merge remote-tracking branch 'origin/cd' into idbImport
pelord Mar 17, 2023
8d25631
wip
pelord Mar 17, 2023
4a575e8
feat(indexeddb): adding a store to save layers
pelord Mar 17, 2023
e97e560
Merge remote-tracking branch 'origin/layerData' into idbImport
pelord Mar 17, 2023
1d311f6
wip
pelord Mar 22, 2023
9fb466d
feat(imported vector): allow to store vector data and layer in indexeddb
pelord Mar 22, 2023
7354ae0
Merge remote-tracking branch 'origin/style' into idbImport
pelord Mar 22, 2023
eb571b7
wip
pelord Mar 22, 2023
4ba4bd6
lint
pelord Mar 22, 2023
c57aa65
feat(import): add a config allowToStoreLayer to control layer storage
pelord Mar 22, 2023
7c8023b
wip
pelord Mar 22, 2023
d4764e1
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 22, 2023
f37c07a
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 22, 2023
e7c6775
wip
pelord Mar 22, 2023
843ba38
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 22, 2023
f8c7e8c
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 22, 2023
44aaccc
wip
pelord Mar 23, 2023
eb07842
fix(longpress): prevent multitouch event emissioon
pelord Mar 23, 2023
d0e61d4
Merge remote-tracking branch 'origin/lp' into idbImport
pelord Mar 23, 2023
2a24c9e
feat(geolocation): code refactor + better handling view zom/move when…
pelord Mar 24, 2023
d7e1c36
wip
pelord Mar 24, 2023
7cae1be
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 24, 2023
cc9c115
feat(geolocation): added feature to show movement direction
CASSI01 Mar 24, 2023
e370e49
Merge branch 'gf' of https://github.com/infra-geo-ouverte/igo2-lib in…
CASSI01 Mar 24, 2023
ebe8ef7
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 24, 2023
2347041
wip
pelord Mar 24, 2023
7404cd5
Merge remote-tracking branch 'origin/gf' into idbImport
pelord Mar 24, 2023
debb795
lint
pelord Mar 24, 2023
3e6daf2
wip
pelord Mar 24, 2023
77e928a
Merge remote-tracking branch 'origin/gf' into idbImport
pelord Mar 24, 2023
9574398
feat(geolocation): changed orientation symbol style and now checks sp…
CASSI01 Mar 24, 2023
feb51ff
Merge remote-tracking branch 'origin/gf' into idbImport
pelord Mar 25, 2023
d32ab4e
feat(workspace):add option to index or not content
pelord Mar 27, 2023
a281877
wip
pelord Mar 27, 2023
ee46cd3
Merge remote-tracking branch 'origin/gf' into idbImport
pelord Mar 27, 2023
8e88143
wip
pelord Mar 27, 2023
c3e71e1
Merge remote-tracking branch 'origin/gf' into idbImport
pelord Mar 27, 2023
45f31be
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 27, 2023
2b53649
Merge remote-tracking branch 'origin/wsf' into idbImport
pelord Mar 27, 2023
bd2ca6b
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 27, 2023
2936b46
lint
pelord Mar 27, 2023
294da62
fix(map): set resolution to 0 was impossible
pelord Mar 28, 2023
e61ef4b
BREAKING CHANGE(OFFLINE): major refactor and some properties moved
pelord Mar 28, 2023
b79bb69
wip
pelord Mar 28, 2023
bf079df
Merge remote-tracking branch 'origin/nc' into idbImport
pelord Mar 28, 2023
b8b74b8
wip
pelord Mar 28, 2023
43aab38
Merge remote-tracking branch 'origin/nc' into idbImport
pelord Mar 28, 2023
9c5f60b
wip
pelord Mar 28, 2023
7267111
Merge remote-tracking branch 'origin/nc' into idbImport
pelord Mar 28, 2023
d31e725
wip
pelord Mar 28, 2023
777c52f
Merge remote-tracking branch 'origin/nc' into idbImport
pelord Mar 28, 2023
684be10
wip
pelord Mar 28, 2023
0424178
feat(geolocation): fixed condition to change arrow orientation
CASSI01 Mar 29, 2023
652dc09
feat(geolocation): fixed possibly undefined speed in orientation check
CASSI01 Mar 29, 2023
904463b
Merge remote-tracking branch 'origin/gf' into idbImport
pelord Mar 29, 2023
bf7666d
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 30, 2023
dc5f7c4
Merge remote-tracking branch 'origin/next' into gf
pelord Mar 30, 2023
14917f9
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 30, 2023
b6c0292
Merge remote-tracking branch 'origin/gf' into idbImport
pelord Mar 31, 2023
2f27c08
Merge remote-tracking branch 'origin/next' into idbImport
pelord Mar 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,482 changes: 1,690 additions & 1,792 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,7 @@ export class LayerContextDirective implements OnInit, OnDestroy {
layersAndIndex$
.pipe(buffer(layersAndIndex$.pipe(debounceTime(500))))
.subscribe((layers: Layer[]) => {
layers = layers
.filter((layer: Layer) => layer !== undefined)
.map((layer) => {
layer.visible = this.computeLayerVisibilityFromUrl(layer);
layer.zIndex = layer.zIndex;

return layer;
});

this.contextLayers.concat(layers);
this.map.addLayers(layers);
this.handleAddLayers(layers);

if (context.extraFeatures) {
context.extraFeatures.forEach((featureCollection) => {
Expand Down Expand Up @@ -137,6 +127,23 @@ export class LayerContextDirective implements OnInit, OnDestroy {
});
}
});

this.layerService.createAsyncIdbLayers(context.uri).pipe(debounceTime(500))
.subscribe((layers: Layer[]) => this.handleAddLayers(layers));

}

private handleAddLayers(layers: Layer[]) {
layers = layers
.filter((layer: Layer) => layer !== undefined)
.map((layer) => {
layer.visible = this.computeLayerVisibilityFromUrl(layer);
layer.zIndex = layer.zIndex;

return layer;
});
this.contextLayers.concat(layers);
this.map.addLayers(layers);
}

private computeLayerVisibilityFromUrl(layer: Layer): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
import { StyleService } from '../../style/style-service/style.service';
import { StyleListService } from '../../style/style-list/style-list.service';
import { skipWhile } from 'rxjs/operators';
import { EntityRecord, Workspace } from '@igo2/common';
import { ConfirmDialogService, EntityRecord, Workspace } from '@igo2/common';
import type { WorkspaceStore } from '@igo2/common';
import { WfsWorkspace } from '../../workspace/shared/wfs-workspace';
import { EditionWorkspace } from '../../workspace/shared/edition-workspace';
Expand All @@ -56,6 +56,7 @@ import { computeProjectionsConstraints } from '../../map';
import olVectorSource from 'ol/source/Vector';
import olClusterSource from 'ol/source/Cluster';
import type { default as OlGeometry } from 'ol/geom/Geometry';
import { LayerService } from '../../layer/shared/layer.service';
import { ImportExportServiceOptions } from '../shared/import.interface';

@Component({
Expand Down Expand Up @@ -107,6 +108,8 @@ export class ImportExportComponent implements OnDestroy, OnInit {

@Input() map: IgoMap;

@Input() contextUri: string;

private _projectionsLimitations: ProjectionsLimitationsOptions = {};
@Input()
set projectionsLimitations(value: ProjectionsLimitationsOptions) {
Expand Down Expand Up @@ -165,7 +168,9 @@ export class ImportExportComponent implements OnDestroy, OnInit {
private config: ConfigService,
private cdRef: ChangeDetectorRef,
private storageService: StorageService,
private downloadService: DownloadService
private downloadService: DownloadService,
private layerService: LayerService,
private confirmDialogService: ConfirmDialogService
) {
this.loadConfig();
this.buildForm();
Expand Down Expand Up @@ -743,6 +748,7 @@ export class ImportExportComponent implements OnDestroy, OnInit {

private onFileImportSuccess(file: File, features: Feature[]) {
const importExportOptions = this.config.getConfig('importExport') as ImportExportServiceOptions;
const confirmDialogService = importExportOptions?.allowToStoreLayer ? this.confirmDialogService : undefined;
const importWithStyle =importExportOptions?.importWithStyle || this.config.getConfig('importWithStyle');
if (this.config.getConfig('importWithStyle')) {
console.warn(`
Expand All @@ -758,14 +764,20 @@ export class ImportExportComponent implements OnDestroy, OnInit {
file,
features,
this.map,
this.messageService
this.contextUri,
this.messageService,
this.layerService,
confirmDialogService
);
} else {
handleFileImportSuccess(
file,
features,
this.map,
this.contextUri,
this.messageService,
this.layerService,
confirmDialogService,
this.styleListService,
this.styleService
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Directive, HostListener, EventEmitter, OnInit, OnDestroy } from '@angular/core';
import { Directive, HostListener, EventEmitter, OnInit, OnDestroy, Input } from '@angular/core';

import { BehaviorSubject, Subscription } from 'rxjs';

import { MessageService, ConfigService } from '@igo2/core';
import { DragAndDropDirective } from '@igo2/common';
import { ConfirmDialogService, DragAndDropDirective } from '@igo2/common';

import { Feature } from '../../feature/shared/feature.interfaces';
import { IgoMap } from '../../map/shared/map';
Expand All @@ -13,6 +13,7 @@ import { handleFileImportSuccess, handleFileImportError } from '../shared/import
import { StyleService } from '../../style/style-service/style.service';
import { StyleListService } from '../../style/style-list/style-list.service';
import { concatMap, first, skipWhile } from 'rxjs/operators';
import { LayerService } from '../../layer/shared/layer.service';
import { ImportExportServiceOptions } from './import.interface';

@Directive({
Expand All @@ -30,13 +31,17 @@ export class DropGeoFileDirective extends DragAndDropDirective implements OnInit
return this.component.map;
}

@Input() contextUri: string;

constructor(
private component: MapBrowserComponent,
private importService: ImportService,
private styleListService: StyleListService,
private styleService: StyleService,
private config: ConfigService,
private messageService: MessageService
private messageService: MessageService,
private layerService: LayerService,
private confirmDialogService: ConfirmDialogService
) {
super();
}
Expand Down Expand Up @@ -140,11 +145,19 @@ export class DropGeoFileDirective extends DragAndDropDirective implements OnInit
This legacy conversion will be deleted in 2024.
`);
}
const confirmDialogService = importExportOptions?.allowToStoreLayer ? this.confirmDialogService : undefined;
if (!importWithStyle) {
handleFileImportSuccess(file, features, this.map, this.messageService);
handleFileImportSuccess(
file,
features,
this.map,
this.contextUri,
this.messageService,
this.layerService,
confirmDialogService);
} else {
handleFileImportSuccess(file, features, this.map, this.messageService,
this.styleListService, this.styleService);
handleFileImportSuccess(file, features, this.map, this.contextUri, this.messageService,
this.layerService, confirmDialogService, this.styleListService, this.styleService);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export interface ImportExportServiceOptions {
forceNaming?: boolean;
formats?: ExportFormat[];
configFileToGeoDBService?: string;
allowToStoreLayer?: boolean;
importWithStyle?: boolean;
}
72 changes: 52 additions & 20 deletions packages/geo/src/lib/import-export/shared/import.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,25 @@ import { ClusterDataSource } from '../../datasource/shared/datasources/cluster-d
import { ClusterDataSourceOptions } from '../../datasource/shared/datasources/cluster-datasource.interface';
import { uuid } from '@igo2/utils';
import { featureRandomStyle, featureRandomStyleFunction } from '../../style/shared/feature/feature-style';
import { LayerService } from '../../layer/shared/layer.service';
import { ConfirmDialogService } from '@igo2/common';
import { first, of } from 'rxjs';

export function addLayerAndFeaturesToMap(
features: Feature[],
map: IgoMap,
layerTitle: string
contextUri: string,
layerTitle: string,
layerService: LayerService,
storeToIdb: boolean = false
): VectorLayer {
const olFeatures = features.map((feature: Feature) =>
featureToOl(feature, map.projection)
);

const id = uuid();
const sourceOptions: FeatureDataSourceOptions & QueryableDataSourceOptions = {
id,
type: 'vector',
queryable: true
};
Expand All @@ -45,14 +53,16 @@ export function addLayerAndFeaturesToMap(
randomStyle = featureRandomStyle();
editable = true;
}
const layer = new VectorLayer({
const layer = layerService.createLayer({
id,
title: layerTitle,
workspace: { enabled: true, searchIndexEnabled: true },
isIgoInternalLayer: true,
source,
igoStyle: { editable },
idbInfo: { firstLoad: true, storeToIdb, contextUri: contextUri || '*' },
style: randomStyle
});
}) as VectorLayer;
layer.setExtent(computeOlFeaturesExtent(map, olFeatures));
map.addLayer(layer);
moveToOlFeatures(map, olFeatures);
Expand Down Expand Up @@ -182,11 +192,18 @@ export function addLayerAndFeaturesStyledToMap(
return layer;
}

function padTo2Digits(num) {
return num.toString().padStart(2, '0');
}

export function handleFileImportSuccess(
file: File,
features: Feature[],
map: IgoMap,
contextUri: string,
messageService: MessageService,
layerService: LayerService,
confirmDialogService?: ConfirmDialogService,
styleListService?: StyleListService,
styleService?: StyleService
) {
Expand All @@ -195,24 +212,39 @@ export function handleFileImportSuccess(
return;
}

const layerTitle = computeLayerTitleFromFile(file);
let layerTitle = computeLayerTitleFromFile(file);

if (!styleListService) {
addLayerAndFeaturesToMap(features, map, layerTitle);
} else {
addLayerAndFeaturesStyledToMap(
features,
map,
layerTitle,
styleListService,
styleService
);
}
messageService.success(
'igo.geo.dropGeoFile.success.text',
'igo.geo.dropGeoFile.success.title',
undefined,
{ value: layerTitle });
const obs$ = confirmDialogService ? confirmDialogService.open('igo.geo.import.promptStoreToIdb') : of(false);

obs$.pipe(first()).subscribe((confirm) => {
const d = new Date();
const dformat =
[d.getFullYear(),
padTo2Digits(d.getMonth() + 1),
padTo2Digits(d.getDate()), ].join('/') +
' ' +
[padTo2Digits(d.getHours()),padTo2Digits(d.getMinutes())].join(':');


layerTitle = confirm ? `${layerTitle} (${dformat})` : layerTitle;
if (!styleListService) {
addLayerAndFeaturesToMap(features, map, contextUri, layerTitle, layerService, confirm);
} else {
addLayerAndFeaturesStyledToMap(
features,
map,
layerTitle,
styleListService,
styleService
);
}

messageService.success(
'igo.geo.dropGeoFile.success.text',
'igo.geo.dropGeoFile.success.title',
undefined,
{ value: layerTitle });
});
}

export function handleFileImportError(
Expand Down
Loading