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

Fix ogcFilters Push buttons #548

Merged
merged 5 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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