Skip to content

Commit

Permalink
Merge pull request #41 from infra-geo-ouverte/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
drekss authored Jun 4, 2020
2 parents d309ca3 + e308859 commit 83102ba
Show file tree
Hide file tree
Showing 46 changed files with 506 additions and 146 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## [1.3.1](https://github.com/infra-geo-ouverte/igo2-lib/compare/1.3.0...1.3.1) (2020-06-01)


### Bug Fixes

* **context:** limit length title context ([88de4ee](https://github.com/infra-geo-ouverte/igo2-lib/commit/88de4ee4c836ef61a85386cf0a2c4060650129be))
* **context:** reset z-index ([64c2861](https://github.com/infra-geo-ouverte/igo2-lib/commit/64c2861738681baa32900a382ad260de32d40990))
* **datasource:** optionsFromApi disabled by default in context ([23abbe8](https://github.com/infra-geo-ouverte/igo2-lib/commit/23abbe81ea9baadab6ef9a8db88f4cbe6fa9437f))
* **getCapabilites:** nonexistent layer results in an untitled layer ([07bd348](https://github.com/infra-geo-ouverte/igo2-lib/commit/07bd34830fd86e79ffb544b1946c0033be6a022f))
* **getCapabilities:** slow request results in an unfilled list ([762f33f](https://github.com/infra-geo-ouverte/igo2-lib/commit/762f33f740a720928c50c83e356db4f3839d5a5b))
* **layer-list:** sort alpha with upper cases and accent ([#647](https://github.com/infra-geo-ouverte/igo2-lib/issues/647)) ([f244e69](https://github.com/infra-geo-ouverte/igo2-lib/commit/f244e69ee99e662f269dd21ea1bb443818fa5660))
* **layer-list / export:** Fix 1.3 release ([#654](https://github.com/infra-geo-ouverte/igo2-lib/issues/654)) ([ff28783](https://github.com/infra-geo-ouverte/igo2-lib/commit/ff2878339eccf2486cd7f936ef6a688e9824da37))
* **map:** improve zIndex management ([6657c4a](https://github.com/infra-geo-ouverte/igo2-lib/commit/6657c4a5cccf676e512cf837a0dfea67244b2113))
* **optionsApi:** remove default url ([b3eaf3b](https://github.com/infra-geo-ouverte/igo2-lib/commit/b3eaf3bc5611ba9030bbd08137c891c60e280724))
* **query:** catch GML3 error ([4c9c4fe](https://github.com/infra-geo-ouverte/igo2-lib/commit/4c9c4fecd9f284c119a3da70db22959b864194b0))
* **spatial-filter:** fix polygon/line layer display ([#655](https://github.com/infra-geo-ouverte/igo2-lib/issues/655)) ([9588672](https://github.com/infra-geo-ouverte/igo2-lib/commit/95886722f06d13cadba1a5b45c1a861721c61c87))


### Features

* **export:** GPX export properties in comment by default ([8687d53](https://github.com/infra-geo-ouverte/igo2-lib/commit/8687d53ab585a48f762b9d908d9a4e3f65bb4c95))



# [1.3.0](https://github.com/infra-geo-ouverte/igo2-lib/compare/1.2.0...1.3.0) (2020-05-11)


Expand Down
37 changes: 37 additions & 0 deletions demo/src/app/geo/layer/layer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,43 @@ export class AppLayerComponent {
this.map.addLayer(this.layerService.createLayer(layer));
});

const wfsDatasourceCustomEPSG: WFSoptions = {
type: 'wfs',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi',
params: {
featureTypes: 'vg_observation_v_autre_wmst',
fieldNameGeometry: 'geometry',
maxFeatures: 10000,
version: '2.0.0',
outputFormat: 'geojson_utf8',
srsName: 'EPSG:32198',
outputFormatDownload: 'shp'
},
ogcFilters: {
enabled: true,
editable: true,
filters: {
operator: 'PropertyIsEqualTo',
propertyName: 'code_municipalite',
expression: '12072'
}
},
formatOptions: {
dataProjection: 'EPSG:32198'
}
};

this.dataSourceService
.createAsyncDataSource(wfsDatasourceCustomEPSG)
.subscribe(dataSource => {
const layer: LayerOptions = {
title: 'WFS (Custom EPSG)',
visible: true,
source: dataSource
};
this.map.addLayer(this.layerService.createLayer(layer));
});

this.layerService
.createAsyncLayer({
sourceOptions: {
Expand Down
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo/demo",
"version": "1.3.0",
"version": "1.3.1",
"description": "IGO Library",
"author": "MSP",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/auth",
"version": "1.3.0",
"version": "1.3.1",
"description": "IGO Library",
"author": "MSP",
"keywords": ["igo"],
Expand All @@ -24,8 +24,8 @@
"@angular/core": "^7.2.6",
"@angular/forms": "^7.2.6",
"@angular/material": "^7.3.3",
"@igo2/core": "^1.3.0",
"@igo2/utils": "^1.3.0",
"@igo2/core": "^1.3.1",
"@igo2/utils": "^1.3.1",
"rxjs": "^6.4.0"
}
}
6 changes: 3 additions & 3 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/common",
"version": "1.3.0",
"version": "1.3.1",
"description": "IGO Library",
"author": "MSP",
"keywords": ["igo"],
Expand All @@ -17,8 +17,8 @@
"@angular/common": "^7.2.6",
"@angular/core": "^7.2.6",
"@angular/material": "^7.3.3",
"@igo2/core": "^1.3.0",
"@igo2/utils": "^1.3.0",
"@igo2/core": "^1.3.1",
"@igo2/utils": "^1.3.1",
"scroll-into-view-if-needed": "^2.2.20",
"typy": "^2.0.1"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<mat-list-item *ngIf="!action.checkbox"
matTooltipClass="actionbarItemTooltip"
matTooltipShowDelay="500"
[matTooltip]="withTooltip ? (tooltip | translate) : ''"
[matTooltip]="withTooltip ? ((tooltip$ | async) || title | translate) : ''"
[ngClass]="ngClass$ | async"
(click)="onClick()">
<button *ngIf="withIcon"
mat-list-avatar
mat-icon-button
[color]="color"
[disabled]="disabled$ | async">
<mat-icon *ngIf="withIcon" svgIcon="{{icon}}"></mat-icon>
<mat-icon *ngIf="withIcon" svgIcon="{{icon$ | async}}"></mat-icon>
</button>
<h4 *ngIf="withTitle" matLine>{{title | translate}}</h4>
</mat-list-item>

<mat-list-item class="item-checkbox" *ngIf="action.checkbox"
matTooltipClass="actionbarItemTooltip"
matTooltipShowDelay="500"
[matTooltip]="withTooltip ? (tooltip | translate) : ''"
[matTooltip]="withTooltip ? ((tooltip$ | async) || title | translate) : ''"
[ngClass]="ngClass$ | async">
<mat-checkbox *ngIf="withTitle"
(change)="action.handler()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
OnDestroy
} from '@angular/core';

import { BehaviorSubject, Subscription } from 'rxjs';
import { BehaviorSubject, Subscription, isObservable } from 'rxjs';

import { Action } from '../shared/action.interfaces';

Expand All @@ -25,6 +25,10 @@ export class ActionbarItemComponent implements OnInit, OnDestroy {

readonly disabled$: BehaviorSubject<boolean> = new BehaviorSubject(false);

readonly icon$: BehaviorSubject<string> = new BehaviorSubject(undefined);

readonly tooltip$: BehaviorSubject<string> = new BehaviorSubject(undefined);

readonly noDisplay$: BehaviorSubject<boolean> = new BehaviorSubject(false);

readonly ngClass$: BehaviorSubject<{[key: string]: boolean}> = new BehaviorSubject({});
Expand All @@ -35,6 +39,10 @@ export class ActionbarItemComponent implements OnInit, OnDestroy {

private availability$$: Subscription;

private icon$$: Subscription;

private tooltip$$: Subscription;

private noDisplay$$: Subscription;

private display$$: Subscription;
Expand Down Expand Up @@ -88,16 +96,6 @@ export class ActionbarItemComponent implements OnInit, OnDestroy {
*/
get title(): string { return this.action.title; }

/**
* @internal
*/
get tooltip(): string { return this.action.tooltip || this.title; }

/**
* @internal
*/
get icon(): string { return this.action.icon; }

constructor() {}

ngOnInit() {
Expand All @@ -108,6 +106,20 @@ export class ActionbarItemComponent implements OnInit, OnDestroy {
.subscribe((ngClass: {[key: string]: boolean}) => this.updateNgClass(ngClass));
}

if (isObservable(this.action.icon)) {
this.icon$$ = this.action.icon
.subscribe((icon: string) => this.updateIcon(icon));
} else {
this.updateIcon(this.action.icon);
}

if (isObservable(this.action.tooltip)) {
this.tooltip$$ = this.action.tooltip
.subscribe((tooltip: string) => this.updateTooltip(tooltip));
} else {
this.updateTooltip(this.action.tooltip);
}

if (this.action.availability !== undefined) {
this.availability$$ = this.action.availability(...args)
.subscribe((available: boolean) => this.disabled = !available);
Expand Down Expand Up @@ -141,6 +153,16 @@ export class ActionbarItemComponent implements OnInit, OnDestroy {
this.display$$ = undefined;
}

if (this.icon$$ !== undefined) {
this.icon$$.unsubscribe();
this.icon$$ = undefined;
}

if (this.tooltip$$ !== undefined) {
this.tooltip$$.unsubscribe();
this.tooltip$$ = undefined;
}

this.disabled$$.unsubscribe();
this.noDisplay$$.unsubscribe();
}
Expand All @@ -160,4 +182,12 @@ export class ActionbarItemComponent implements OnInit, OnDestroy {
private updateNgClass(ngClass: {[key: string]: boolean}) {
this.ngClass$.next(Object.assign({}, this.ngClass$.value, ngClass));
}

private updateTooltip(tooltip: string) {
this.tooltip$.next(tooltip);
}

private updateIcon(icon: string) {
this.icon$.next(icon);
}
}
4 changes: 2 additions & 2 deletions packages/common/src/lib/action/shared/action.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export interface Action {
id: string;
handler: ActionHandler;
title?: string;
icon?: string;
tooltip?: string;
icon?: string | Observable<string>;
tooltip?: string | Observable<string>;
args?: any[];
checkbox?: boolean;
checkCondition?: boolean;
Expand Down
12 changes: 6 additions & 6 deletions packages/context/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/context",
"version": "1.3.0",
"version": "1.3.1",
"description": "IGO Library",
"author": "MSP",
"keywords": ["igo"],
Expand All @@ -19,11 +19,11 @@
"@angular/core": "^7.2.6",
"@angular/forms": "^7.2.6",
"@angular/material": "^7.3.3",
"@igo2/auth": "^1.3.0",
"@igo2/common": "^1.3.0",
"@igo2/core": "^1.3.0",
"@igo2/utils": "^1.3.0",
"@igo2/geo": "^1.3.0",
"@igo2/auth": "^1.3.1",
"@igo2/common": "^1.3.1",
"@igo2/core": "^1.3.1",
"@igo2/utils": "^1.3.1",
"@igo2/geo": "^1.3.1",
"ol": "^5.3.0",
"rxjs": "^6.4.0"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Directive, OnInit, OnDestroy, Optional, Input } from '@angular/core';

import { Subscription, of, zip } from 'rxjs';
import { withLatestFrom, skip, filter } from 'rxjs/operators';
import { Subscription, merge } from 'rxjs';
import { skip, buffer, debounceTime, filter } from 'rxjs/operators';

import { RouteService } from '@igo2/core';
import {
Expand All @@ -19,7 +19,6 @@ import { DetailedContext } from './context.interface';
selector: '[igoLayerContext]'
})
export class LayerContextDirective implements OnInit, OnDestroy {

private context$$: Subscription;
private queryParams: any;

Expand Down Expand Up @@ -50,10 +49,11 @@ export class LayerContextDirective implements OnInit, OnDestroy {
this.route.options.contextKey
) {
const queryParams$$ = this.route.queryParams
.pipe(skip(1))
.subscribe(params => {
this.queryParams = params;
queryParams$$.unsubscribe();
if ( Object.keys(params).length > 0 ) {
this.queryParams = params;
queryParams$$.unsubscribe();
}
});
}
}
Expand All @@ -63,38 +63,37 @@ export class LayerContextDirective implements OnInit, OnDestroy {
}

private handleContextChange(context: DetailedContext) {
if (context.layers === undefined) { return; }
if (context.layers === undefined) {
return;
}
if (this.removeLayersOnContextChange === true) {
this.map.removeAllLayers();
} else {
this.map.removeLayers(this.contextLayers);
}
this.contextLayers = [];

const layersAndIndex$ = zip(...context.layers.map((layerOptions: LayerOptions, index: number) => {
return this.layerService.createAsyncLayer(layerOptions).pipe(
withLatestFrom(of(index))
);
}));

layersAndIndex$.subscribe((layersAndIndex: [Layer, number][]) => {
const layers = layersAndIndex
.reduce((acc: Layer[], bunch: [Layer, number]) => {
const [layer, index] = bunch;
// A layer may be undefined when it's badly configured
if (layer !== undefined) {
const layersAndIndex$ = merge(
...context.layers.map((layerOptions: LayerOptions, index: number) => {
return this.layerService.createAsyncLayer(layerOptions);
})
);

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 || index + 1; // Map indexes start at 1
}
layer.zIndex = layer.zIndex;

acc[index] = layer;
return acc;
}, new Array(layersAndIndex.length))
.filter((layer: Layer) => layer !== undefined);
return layer;
});

this.contextLayers = layers;
this.map.addLayers(layers);
});
this.contextLayers.concat(layers);
this.map.addLayers(layers);
});
}

private computeLayerVisibilityFromUrl(layer: Layer): boolean {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/core",
"version": "1.3.0",
"version": "1.3.1",
"description": "IGO Library",
"author": "MSP",
"keywords": ["igo"],
Expand All @@ -21,7 +21,7 @@
"@angular/common": "^7.2.6",
"@angular/core": "^7.2.6",
"@angular/cdk": "^7.3.3",
"@igo2/utils": "^1.3.0",
"@igo2/utils": "^1.3.1",
"rxjs": "^6.4.0"
}
}
Loading

0 comments on commit 83102ba

Please sign in to comment.