Skip to content

Commit

Permalink
fix(ogc-filter) Sync pushbutton filter with downloaded data (was not …
Browse files Browse the repository at this point in the history
…sync) (#548)

* ui(share-map) Included/Excluded text alignement

* fix(ogc-filter) push button were not visible if filters were not editable

* fix(ogc-filter) Sync pushbutton filter with downloaded data (was not sync)

* Update ogc-filter.ts
  • Loading branch information
pelord authored and mbarbeau committed Jan 20, 2020
1 parent 4fe60f1 commit e3dc8b7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
<mat-icon svgIcon="content-copy"></mat-icon>
{{ 'igo.context.shareMap.copy' | translate }}
</button>
</div>
<div *ngIf="!hasApi">
<br/>
<section class="mat-typography">
<h4>{{'igo.context.shareMap.included' | translate}}</h4>
Expand Down
10 changes: 7 additions & 3 deletions packages/geo/src/lib/download/shared/download.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ export class DownloadService {

let filterQueryString;
filterQueryString = new OgcFilterWriter()
.handleOgcFiltersAppliedValue(layer.dataSource.options, ogcFilters.geometryName);
.handleOgcFiltersAppliedValue(
layer.dataSource.options,
ogcFilters.geometryName,
layer.map.getExtent(),
new olProjection({ code: layer.map.projection }));
if (!filterQueryString) {
// Prevent getting all the features for empty filter
filterQueryString = new OgcFilterWriter().buildFilter(
Expand All @@ -67,10 +71,10 @@ export class DownloadService {
ogcFilters.geometryName
);
} else {
filterQueryString = 'filter=' + filterQueryString;
filterQueryString = 'filter=' + encodeURIComponent(filterQueryString);
}
window.open(
`${baseurl}&${encodeURIComponent(filterQueryString)}&${outputFormatDownload}`,
`${baseurl}&${filterQueryString}&${outputFormatDownload}`,
'_blank'
);
} else if (DSOptions.download) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<button *ngIf="header && options.ogcFilters && (options.ogcFilters.enabled
&& options.ogcFilters.editable)"
<button *ngIf="header && options.ogcFilters && options.ogcFilters.enabled"
mat-icon-button
collapsibleButton
tooltip-position="below"
Expand All @@ -11,8 +10,7 @@
</button>

<div #ogcFilter class="igo-layer-actions-container"
*ngIf="options.ogcFilters && (options.ogcFilters.enabled
&& options.ogcFilters.editable)">
*ngIf="options.ogcFilters && options.ogcFilters.enabled">
<igo-ogc-filterable-item
*ngIf="ogcFilterCollapse && options.ogcFilters.enabled"
igoListItem
Expand Down
18 changes: 15 additions & 3 deletions packages/geo/src/lib/filter/shared/ogc-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import olFormatWKT from 'ol/format/WKT';
import olFormatWFS from 'ol/format/WFS';
import olGeometry from 'ol/geom/Geometry';

import olProjection from 'ol/proj/Projection';

import { uuid, ObjectUtils } from '@igo2/utils';

import {
Expand Down Expand Up @@ -427,6 +429,9 @@ export class OgcFilterWriter {
}

private computeIgoPushButton(pushButtons: IgoPushButton): IgoPushButton {
if (pushButtons.groups.every(group => group.computedButtons !== undefined)) {
return pushButtons;
}
let pb: IgoPushButton;
if (pushButtons.groups && pushButtons.bundles) {
if (!pushButtons.bundles.every(bundle => bundle.id !== undefined)) {
Expand Down Expand Up @@ -457,7 +462,11 @@ export class OgcFilterWriter {
return pb;
}

public handleOgcFiltersAppliedValue(options: OgcFilterableDataSourceOptions, fieldNameGeometry: string) {
public handleOgcFiltersAppliedValue(
options: OgcFilterableDataSourceOptions,
fieldNameGeometry: string,
extent?: [number, number, number, number],
proj?: olProjection): string{
const ogcFilters = options.ogcFilters;
if (!ogcFilters) {
return;
Expand All @@ -481,15 +490,18 @@ export class OgcFilterWriter {
});
if (conditions.length >= 1) {
filterQueryStringPushButton = this.buildFilter(
conditions.length === 1 ? conditions[0] : { logical: 'And', filters: conditions }
conditions.length === 1 ? conditions[0] : { logical: 'And', filters: conditions },
extent,
proj,
ogcFilters.geometryName
);
}
}

if (ogcFilters.enabled && ogcFilters.filters) {
ogcFilters.geometryName = ogcFilters.geometryName || fieldNameGeometry;
const igoFilters = ogcFilters.filters;
filterQueryStringAdvancedFilters = this.buildFilter(igoFilters);
filterQueryStringAdvancedFilters = this.buildFilter(igoFilters, extent, proj, ogcFilters.geometryName);
}

let filterQueryString = ogcFilters.advancedOgcFilters ? filterQueryStringAdvancedFilters : filterQueryStringPushButton;
Expand Down

0 comments on commit e3dc8b7

Please sign in to comment.