Skip to content

Commit

Permalink
fix(ogc-filter): Fix for Angular 6 and adjustements for minilib (#186)
Browse files Browse the repository at this point in the history
* refactor(map) a more customizable way to add overlay

* feat(wkt service) refactor and adding ways to return wkt objects

* fix(ogc-fillter interface and class) refactor interfaces and operators

* refactor(ogc-filter) bing map to ogcfilter.

* (feat) feature color used as a extent (0000 vs gray) and autorefresh

* fix(download-service) with right properties

* feat(ogc-filter) Autorefresh toggle feature extent and bind map

* refactor(wfs) interface for outputFormatDownload

* ui(ogc-filter) updating demo with proper params.

* fix(ogc-filter) Moving to angular 6 and selectionChange on select

* i18n(ogc-filter) translation for feature extent.

* feat(ogc-filter-form) AutoRefresh on change, feature extent overlay

* refactor(*) sourcefields

* refactor(wms-datasource)managing sourcefield for wms

* refactor(ogc-filter) isOgcFilterable/filtersAreEditable enabled/editable

* fix(wfs) not using filters when filters are disabled.

* refactor(ogc-filter) ogcFilters: {enabled: true,editable: true,...}

* fix(wfs) default value for ogcfilters

* ui(ogc-filter) cleaner example

* ui(ogc-filter) refresh button removed due to autorefresh on change.

* feat(ogc-filter) refactor and defining a cleaner way for refresh events

* refactor(*)move wfs-service usage from ogc-filter.service to datasources

* fix(wkt-service) Wrong regex. Was excluding some SNRC

* feat(datasource) providing data wfs-service to datasources

* fix(download-service) Adjustement on interface and services params.

* feat(wms wfs)  wfs for wms source and common interfaces on wms and wfs

* fix(filterable-datasource) Let filterable layer apply active filters.

* refactor(ogc-fliter) adjustements for wms with linked wfs

* fix(ogc-filter) active filter geometry footprint on init

* refactor(ogc-filter) various interfaces

* fix(ogc-filter) fixing wrong conflict resolution.

* fic(ogc-filter-button) Fix button integration

* fix(ogc-filter-button) fix button integration into layer-list

* fix(ogc-filter-button) download button shown.

* ui(ogc-filter) hide spatial extent button if no geometry active.

* fix(ogc-filter-button) fix button integration into layer-list

* Update layer.component.ts

* Update ogc-filter.component.ts

* lint code

* Update map.ts

* remove inused import

* fix position buttons layer
  • Loading branch information
pelord authored and mbarbeau committed Oct 16, 2018
1 parent dd92fc8 commit cb77a93
Show file tree
Hide file tree
Showing 39 changed files with 929 additions and 496 deletions.
1 change: 1 addition & 0 deletions demo/src/app/geo/layer/layer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
floatLabel="never">

<ng-template #igoLayerItemToolbar let-layer="layer">
<igo-ogc-filter-button [map]="map" [layer]="layer"></igo-ogc-filter-button>
<igo-metadata-button [layer]="layer"></igo-metadata-button>
<igo-download-button [layer]="layer"></igo-download-button>
</ng-template>
Expand Down
39 changes: 39 additions & 0 deletions demo/src/app/geo/layer/layer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
LayerService,
WMSDataSourceOptions,
LayerOptions,
WFSDataSourceOptions,
OgcFilterableDataSourceOptions,
MetadataLayerOptions
} from '@igo2/geo';

Expand Down Expand Up @@ -47,6 +49,43 @@ export class AppLayerComponent {
);
});

interface WFSoptions
extends WFSDataSourceOptions,
OgcFilterableDataSourceOptions {}

const wfsDatasource: WFSoptions = {
type: 'wfs',
url: 'https://geoegl.msp.gouv.qc.ca/igo2/api/ws/igo_gouvouvert.fcgi',
params: {
featureTypes: 'vg_observation_v_autre_wmst',
fieldNameGeometry: 'geometry',
maxFeatures: 10000,
version: '2.0.0',
outputFormat: 'geojson_utf8',
outputFormatDownload: 'shp'
},
ogcFilters: {
enabled: true,
editable: true,
filters: {
operator: 'PropertyIsEqualTo',
propertyName: 'code_municipalite',
expression: '10043'
}
}
};

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

this.layerService
.createAsyncLayer({
sourceOptions: {
Expand Down
2 changes: 2 additions & 0 deletions demo/src/app/geo/layer/layer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IgoPanelModule } from '@igo2/common';
import {
IgoMapModule,
IgoLayerModule,
IgoFilterModule,
IgoMetadataModule,
IgoDownloadModule
} from '@igo2/geo';
Expand All @@ -26,6 +27,7 @@ import { AppLayerRoutingModule } from './layer-routing.module';
IgoPanelModule,
IgoMapModule,
IgoLayerModule,
IgoFilterModule,
IgoMetadataModule,
IgoDownloadModule
],
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/geo/ogc-filter/ogc-filter.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</igo-map-browser>

<igo-panel title="Layers">
<igo-ogc-filterable-list [layers]="map.layers">
<igo-ogc-filterable-list [map]="map" [layers]="map.layers">

</igo-ogc-filterable-list>
</igo-panel>
Expand Down
92 changes: 85 additions & 7 deletions demo/src/app/geo/ogc-filter/ogc-filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import {
IgoMap,
DataSourceService,
LayerService,
WMSDataSourceOptions,
WFSDataSourceOptions,
OgcFilterableDataSourceOptions
WFSDataSourceOptionsParams,
OgcFilterableDataSourceOptions,
AnyBaseOgcFilterOptions
} from '@igo2/geo';

@Component({
Expand Down Expand Up @@ -58,15 +61,43 @@ export class AppOgcFilterComponent {
fieldNameGeometry: 'geometry',
maxFeatures: 10000,
version: '2.0.0',
outputFormat: 'geojson'
outputFormat: 'geojson',
outputFormatDownload: 'SHP' // based on service capabilities
},
isOgcFilterable: true,
sourceFields: [
{ name: 'code_municipalite', alias: '# de la municipalitée' },
{ name: 'date_observation' },
{ name: 'urgence', values: ['immédiate', 'inconnue'] }
],
ogcFilters: {
filtersAreEditable: true,
enabled: true,
editable: true,
filters: {
operator: 'PropertyIsEqualTo',
propertyName: 'code_municipalite',
expression: '10043'
logical: 'Or',
filters: [
{
operator: 'PropertyIsEqualTo',
propertyName: 'code_municipalite',
expression: '10043'
},
{
operator: 'Intersects',
geometryName: 'the_geom',
wkt_geometry: `MULTIPOLYGON(((
-8379441.158019895 5844447.897707146,
-8379441.158019895 5936172.331649357,
-8134842.66750733 5936172.331649357,
-8134842.66750733 5844447.897707146,
-8379441.158019895 5844447.897707146
), (
-8015003 5942074,
-8015003 5780349,
-7792364 5780349,
-7792364 5942074,
-8015003 5942074
)))`
}
] as AnyBaseOgcFilterOptions[]
}
}
};
Expand All @@ -81,5 +112,52 @@ export class AppOgcFilterComponent {
})
);
});

interface WMSoptions
extends WMSDataSourceOptions,
OgcFilterableDataSourceOptions {}

const datasourceWms: WMSoptions = {
type: 'wms',
url: '/geoserver/wms',
urlWfs: '/geoserver/wfs',
params: {
layers: 'water_areas',
version: '1.3.0'
},
ogcFilters: {
enabled: true,
editable: true,
filters: {
operator: 'PropertyIsEqualTo',
propertyName: 'waterway',
expression: 'riverbank'
}
},
sourceFields: [
{ name: 'waterway', alias: 'Chemin d eau' },
{ name: 'osm_id' },
{ name: 'landuse', values: ['yes', 'no'] }
],
paramsWFS: {
featureTypes: 'water_areas',
fieldNameGeometry: 'the_geom',
maxFeatures: 10000,
version: '1.1.0',
outputFormat: 'application/json',
outputFormatDownload: 'application/vnd.google-earth.kml+xml'
} as WFSDataSourceOptionsParams
};

this.dataSourceService
.createAsyncDataSource(datasourceWms)
.subscribe(dataSource => {
this.map.addLayer(
this.layerService.createLayer({
title: 'Geoserver water_areas',
source: dataSource
})
);
});
}
}
1 change: 1 addition & 0 deletions projects/core/src/lib/request/error.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class ErrorInterceptor implements HttpInterceptor {
const translate = this.injector.get(LanguageService).translate;
const message = translate.instant('igo.core.errors.uncaught.message');
const title = translate.instant('igo.core.errors.uncaught.title');
this.httpError.error.caught = true;
this.messageService.error(message, title);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HttpClientModule } from '@angular/common/http';

import { CapabilitiesService } from './capabilities.service';
import { DataSourceService } from './datasource.service';
import { WFSService } from './wfs.service';
import { WFSService } from './datasources/wfs.service';

describe('DataSourceService', () => {
beforeEach(() => {
Expand Down
19 changes: 15 additions & 4 deletions projects/geo/src/lib/datasource/shared/datasource.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
XYZDataSourceOptions,
WFSDataSource,
WFSDataSourceOptions,
WFSService,
WMTSDataSource,
WMTSDataSourceOptions,
WMSDataSource,
Expand All @@ -33,7 +34,10 @@ import {
export class DataSourceService {
public datasources$ = new BehaviorSubject<DataSource[]>([]);

constructor(private capabilitiesService: CapabilitiesService) {}
constructor(
private capabilitiesService: CapabilitiesService,
private wfsDataSourceService: WFSService
) {}

createAsyncDataSource(context: AnyDataSourceOptions): Observable<DataSource> {
if (!context.type) {
Expand Down Expand Up @@ -104,7 +108,9 @@ export class DataSourceService {
private createWFSDataSource(
context: WFSDataSourceOptions
): Observable<WFSDataSource> {
return new Observable(d => d.next(new WFSDataSource(context)));
return new Observable(d =>
d.next(new WFSDataSource(context, this.wfsDataSourceService))
);
}

private createWMSDataSource(
Expand All @@ -114,11 +120,16 @@ export class DataSourceService {
return this.capabilitiesService
.getWMSOptions(context)
.pipe(
map((options: WMSDataSourceOptions) => new WMSDataSource(options))
map(
(options: WMSDataSourceOptions) =>
new WMSDataSource(options, this.wfsDataSourceService)
)
);
}

return new Observable(d => d.next(new WMSDataSource(context)));
return new Observable(d =>
d.next(new WMSDataSource(context, this.wfsDataSourceService))
);
}

private createWMTSDataSource(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export abstract class DataService {
abstract getData(): string;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import olSource from 'ol/source/Source';

import { DataSource } from './datasource';
import { DownloadOptions } from '../../../download/shared/download.interface';

export interface DataSourceOptions {
type?:
Expand All @@ -21,6 +22,8 @@ export interface DataSourceOptions {
// view?: ol.olx.layer.ImageOptions;
// displayField?: string;
ol?: olSource;
sourceFields?: SourceFieldsOptionsParams[];
download?: DownloadOptions;
}

export interface DataSourceLegendOptions {
Expand All @@ -31,3 +34,9 @@ export interface DataSourceLegendOptions {
style?: { [key: string]: string | number };
title?: string;
}

export interface SourceFieldsOptionsParams {
name: any;
alias?: any;
values?: any;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {
DataSourceLegendOptions
} from './datasource.interface';

// import { DataService } from './data.service';
import { DataService } from './data.service';

export abstract class DataSource {
public id: string;
public ol: olSource;

constructor(
public options: DataSourceOptions = {} // protected dataSourceService?: DataService
public options: DataSourceOptions = {},
protected dataService?: DataService
) {
this.options = options;
this.id = this.generateId();
Expand Down
2 changes: 2 additions & 0 deletions projects/geo/src/lib/datasource/shared/datasources/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './data.service';
export * from './datasource';
export * from './datasource.interface';
export * from './feature-datasource';
Expand All @@ -8,6 +9,7 @@ export * from './xyz-datasource';
export * from './xyz-datasource.interface';
export * from './wfs-datasource';
export * from './wfs-datasource.interface';
export * from './wfs.service';
export * from './wms-datasource';
export * from './wms-datasource.interface';
export * from './wmts-datasource';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@ export interface WFSDataSourceOptions
extends DataSourceOptions,
FeatureDataSourceOptions {
// type?: 'wfs';
params: WFSDataSourceOptionsParams;
params: WFSDataSourceOptionsParams; // Used by user
paramsWFS?: WFSDataSourceOptionsParams; // Used by code
urlWfs?: string; // Used by code
}

export interface WFSDataSourceOptionsParams {
version?: string;
featureTypes: string;
fieldNameGeometry: string;
maxFeatures?: Number;
outputFormat?: string;
outputFormat: string;
outputFormatDownload?: string;
srsname?: string;
xmlFilter?: string;
wfsCapabilities?: WFSCapabilitiesParams;
}

export interface WFSCapabilitiesParams {
xmlBody?: string;
GetPropertyValue?: boolean;
}
Loading

0 comments on commit cb77a93

Please sign in to comment.