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

Duplicated WMS params lowercase vs uppercase #519

Merged
merged 6 commits into from
Nov 26, 2019
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
28 changes: 14 additions & 14 deletions demo/src/app/geo/layer/layer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export class AppLayerComponent {
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi',
optionsFromCapabilities: true,
params: {
layers: 'MELS_CS_ANGLO_S',
version: '1.3.0'
LAYERS: 'MELS_CS_ANGLO_S',
VERSION: '1.3.0'
}
}
})
Expand All @@ -110,8 +110,8 @@ export class AppLayerComponent {
type: 'wms',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/swtq',
params: {
layers: 'bgr_v_sous_route_res_sup_act',
version: '1.3.0'
LAYERS: 'bgr_v_sous_route_res_sup_act',
VERSION: '1.3.0'
}
}
})
Expand All @@ -126,8 +126,8 @@ export class AppLayerComponent {
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/swtq',
optionsFromCapabilities: true,
params: {
layers: 'lieuhabite',
version: '1.3.0'
LAYERS: 'lieuhabite',
VERSION: '1.3.0'
}
}
})
Expand All @@ -142,8 +142,8 @@ export class AppLayerComponent {
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/mffpecofor.fcgi',
optionsFromCapabilities: true,
params: {
layers: 'sh_dis_eco',
version: '1.3.0'
LAYERS: 'sh_dis_eco',
VERSION: '1.3.0'
}
}
})
Expand All @@ -167,8 +167,8 @@ export class AppLayerComponent {
url: 'https://demo.geo-solutions.it/geoserver/ows',
optionsFromCapabilities: true,
params: {
layers: 'nurc:Arc_Sample', // , test:Linea_costa
version: '1.3.0'
LAYERS: 'nurc:Arc_Sample', // , test:Linea_costa
VERSION: '1.3.0'
}
}
})
Expand All @@ -182,8 +182,8 @@ export class AppLayerComponent {
type: 'wms',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/swtq',
params: {
layers: 'evenements',
version: '1.3.0'
LAYERS: 'evenements',
VERSION: '1.3.0'
}
}
})
Expand All @@ -194,8 +194,8 @@ export class AppLayerComponent {
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi',
refreshIntervalSec: 15,
params: {
layers: 'vg_observation_v_inondation_embacle_wmst',
version: '1.3.0'
LAYERS: 'vg_observation_v_inondation_embacle_wmst',
VERSION: '1.3.0'
}
};

Expand Down
8 changes: 4 additions & 4 deletions demo/src/app/geo/ogc-filter/ogc-filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export class AppOgcFilterComponent {
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/swtq',
urlWfs: 'https://geoegl.msp.gouv.qc.ca/apis/ws/swtq',
params: {
layers: 'radars_photos',
version: '1.3.0'
LAYERS: 'radars_photos',
VERSION: '1.3.0'
},
ogcFilters: {
enabled: true,
Expand Down Expand Up @@ -296,8 +296,8 @@ export class AppOgcFilterComponent {
// url: '/geoserver/wms',
// urlWfs: '/geoserver/wfs',
// params: {
// layers: 'water_areas',
// version: '1.3.0'
// LAYERS: 'water_areas',
// VERSION: '1.3.0'
// },
// ogcFilters: {
// enabled: true,
Expand Down
12 changes: 6 additions & 6 deletions demo/src/app/geo/print/print.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class AppPrintComponent {
type: 'wms',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi',
params: {
layers: 'MELS_CS_ANGLO_S',
version: '1.3.0'
LAYERS: 'MELS_CS_ANGLO_S',
VERSION: '1.3.0'
},
crossOrigin: 'anonymous'
}
Expand All @@ -62,8 +62,8 @@ export class AppPrintComponent {
type: 'wms',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi',
params: {
layers: 'vg_observation_v_inondation_embacle_wmst',
version: '1.3.0'
LAYERS: 'vg_observation_v_inondation_embacle_wmst',
VERSION: '1.3.0'
},
crossOrigin: 'anonymous'
}
Expand All @@ -77,8 +77,8 @@ export class AppPrintComponent {
// type: 'wms',
// url: 'http://geo.weather.gc.ca/geomet/?lang=fr',
// params: {
// layers: 'RADAR_1KM_RDBR',
// version: '1.3.0'
// LAYERS: 'RADAR_1KM_RDBR',
// VERSION: '1.3.0'
// },
// crossOrigin: 'anonymous'
// }
Expand Down
4 changes: 2 additions & 2 deletions demo/src/app/geo/time-filter/time-filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export class AppTimeFilterComponent {
type: 'wms',
url: 'https://geoegl.msp.gouv.qc.ca/ws/igo_gouvouvert.fcgi',
params: {
layers: 'vg_observation_v_inondation_embacle_wmst',
version: '1.3.0'
LAYERS: 'vg_observation_v_inondation_embacle_wmst',
VERSION: '1.3.0'
},
timeFilterable: true,
timeFilter: {
Expand Down
4 changes: 2 additions & 2 deletions demo/src/app/geo/workspace/workspace.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export class AppWorkspaceComponent implements OnInit {
// url: 'https://ahocevar.com/geoserver/wms',
// urlWfs: 'https://ahocevar.com/geoserver/wfs',
// params: {
// layers: 'water_areas',
// version: '1.3.0'
// LAYERS: 'water_areas',
// VERSION: '1.3.0'
// },
// paramsWFS: {
// featureTypes: 'water_areas',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class ShareMapService {
)) {
if (contextLayersID.indexOf(layer.id) === -1) {
const wmsUrl = (layer.dataSource.options as any).url;
const addedLayer = (layer.dataSource.options as any).params.layers;
const addedLayer = (layer.dataSource.options as any).params.LAYERS;
const addedLayerPosition = `${addedLayer}:igoz${layer.zIndex}`;

if (
Expand Down
12 changes: 7 additions & 5 deletions packages/geo/src/lib/catalog/shared/catalog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
CapabilitiesService,
WMSDataSourceOptions,
WMTSDataSourceOptions,
generateIdFromSourceOptions
generateIdFromSourceOptions,
WMSDataSourceOptionsParams
} from '../../datasource';
import {
LayerOptions,
Expand Down Expand Up @@ -225,10 +226,11 @@ export class CatalogService {
: undefined;

const params = Object.assign({}, catalogQueryParams, {
layers: layer.Name,
feature_count: catalog.count,
version: catalog.version || '1.3.0'
});
LAYERS: layer.Name,
FEATURE_COUNT: catalog.count,
VERSION: catalog.version || '1.3.0'
} as WMSDataSourceOptionsParams
);
const baseSourceOptions = {
type: 'wms',
url: catalog.url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class CapabilitiesService {
baseOptions: WMSDataSourceOptions
): Observable<WMSDataSourceOptions> {
const url = baseOptions.url;
const version = (baseOptions.params as any).version;
const version = (baseOptions.params as any).VERSION;

return this.getCapabilities('wms', url, version).pipe(
map((capabilities: any) => {
Expand Down Expand Up @@ -151,7 +151,7 @@ export class CapabilitiesService {
baseOptions: WMSDataSourceOptions,
capabilities: any
): WMSDataSourceOptions {
const layers = (baseOptions.params as any).layers;
const layers = (baseOptions.params as any).LAYERS;
const layer = this.findDataSourceInCapabilities(
capabilities.Capability.Layer,
layers
Expand Down
5 changes: 4 additions & 1 deletion packages/geo/src/lib/datasource/shared/datasource.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
ClusterDataSource,
ClusterDataSourceOptions
} from './datasources';
import { ObjectUtils } from '@igo2/utils';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -62,7 +63,9 @@ export class DataSourceService {
dataSource = this.createWFSDataSource(context as WFSDataSourceOptions);
break;
case 'wms':
dataSource = this.createWMSDataSource(context as WMSDataSourceOptions);
const wmsContext = context as WMSDataSourceOptions
ObjectUtils.removeDuplicateCaseInsensitive(wmsContext.params)
dataSource = this.createWMSDataSource(wmsContext);
break;
case 'wmts':
dataSource = this.createWMTSDataSource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ export interface WMSDataSourceOptions extends DataSourceOptions {
}

export interface WMSDataSourceOptionsParams {
layers: string;
version?: string;
time?: string;
LAYERS: string;
VERSION?: string;
TIME?: string;
FEATURE_COUNT?: number;
FILTER?: string;
INFO_FORMAT?: string;
DPI?: number;
MAP_RESOLUTION?: number;
FORMAT_OPTIONS?: string;
}

export interface WMSLayerOptionsFromCapabilities {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,9 @@ export class WMSDataSource extends DataSource {
protected wfsService: WFSService
) {
super(options);
// Important: To use wms versions smaller than 1.3.0, SRS
// needs to be supplied in the source "params"

// We need to do this to override the default version
// of openlayers which is uppercase
const sourceParams: any = options.params;
if (sourceParams && sourceParams.version) {
sourceParams.VERSION = sourceParams.version;
}

if (sourceParams && sourceParams.VERSION) {
if (sourceParams.version !== '1.3.0') {
if (!sourceParams.SRS && !sourceParams.srs) {
throw new Error(
`You must set a SRS (or srs) param for your WMS
(layer = ` +
sourceParams.layers +
`) because your want to use a WMS version under 1.3.0
Ex: "srs": "EPSG:3857" `
);
}
}
}

if (sourceParams && sourceParams.styles) {
sourceParams.STYLES = sourceParams.styles;
delete sourceParams.styles;
}

if (sourceParams && sourceParams.INFO_FORMAT) {
sourceParams.info_format = sourceParams.INFO_FORMAT;
}

const dpi = sourceParams.dpi || 96;
const dpi = sourceParams.DPI || 96;
sourceParams.DPI = dpi;
sourceParams.MAP_RESOLUTION = dpi;
sourceParams.FORMAT_OPTIONS = 'dpi:' + dpi;
Expand Down Expand Up @@ -130,14 +99,14 @@ export class WMSDataSource extends DataSource {
}

if (
sourceParams.layers.split(',').length > 1 &&
sourceParams.LAYERS.split(',').length > 1 &&
initOgcFilters &&
initOgcFilters.enabled
) {
console.log('*******************************');
console.log(
'BE CAREFULL, YOUR WMS LAYERS (' +
sourceParams.layers +
sourceParams.LAYERS +
') MUST SHARE THE SAME FIELDS TO ALLOW ogcFilters TO WORK !! '
);
console.log('*******************************');
Expand All @@ -151,7 +120,7 @@ export class WMSDataSource extends DataSource {
options,
fieldNameGeometry
);
this.ol.updateParams({ filter: filterQueryString });
sourceParams.FILTER = filterQueryString;
}

refresh() {
Expand All @@ -178,8 +147,8 @@ export class WMSDataSource extends DataSource {
const sourceParams = this.params;

let layers = [];
if (sourceParams.layers !== undefined) {
layers = sourceParams.layers.split(',');
if (sourceParams.LAYERS !== undefined) {
layers = sourceParams.LAYERS.split(',');
}

const baseUrl = this.options.url.replace(/\?$/, '');
Expand All @@ -188,7 +157,7 @@ export class WMSDataSource extends DataSource {
'SERVICE=wms',
'FORMAT=image/png',
'SLD_VERSION=1.1.0',
`VERSION=${sourceParams.version || '1.3.0'}`
`VERSION=${sourceParams.VERSION || '1.3.0'}`
];
if (style !== undefined) {
params.push(`STYLE=${style}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/src/lib/datasource/utils/id-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function generateIdFromSourceOptions(options: DataSourceOptions): string
* @returns A md5 hash of the the url and layers
*/
export function generateWMSIdFromSourceOptions(options: WMSDataSourceOptions) {
const layers = options.params.layers;
const layers = options.params.LAYERS;
const url = options.url.charAt(0) === '/' ? window.location.origin + options.url : options.url;
const chain = 'wms' + url + layers;
return Md5.hashStr(chain) as string;
Expand Down
4 changes: 2 additions & 2 deletions packages/geo/src/lib/filter/shared/ogc-filter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export class OGCFilterService {
constructor() {}

public filterByOgc(wmsDatasource: WMSDataSource, filterString: string) {
const appliedFilter = new OgcFilterWriter().formatProcessedOgcFilter(filterString, wmsDatasource.options.params.layers);
wmsDatasource.ol.updateParams({ filter: appliedFilter });
const appliedFilter = new OgcFilterWriter().formatProcessedOgcFilter(filterString, wmsDatasource.options.params.LAYERS);
wmsDatasource.ol.updateParams({ FILTER: appliedFilter });
}

public setOgcWFSFiltersOptions(wfsDatasource: OgcFilterableDataSource) {
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/src/lib/filter/shared/ogc-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ export class OgcFilterWriter {

let filterQueryString = ogcFilters.advancedOgcFilters ? filterQueryStringAdvancedFilters : filterQueryStringPushButton;
if (options.type === 'wms') {
filterQueryString = this.formatProcessedOgcFilter(filterQueryString, (options as any).params.layers);
filterQueryString = this.formatProcessedOgcFilter(filterQueryString, (options as any).params.LAYERS);
}
if (options.type === 'wfs') {
filterQueryString = this.formatProcessedOgcFilter(filterQueryString, (options as any).params.featureTypes);
Expand Down
4 changes: 2 additions & 2 deletions packages/geo/src/lib/filter/shared/time-filter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class TimeFilterService {
time = newdateform;
}

const params = { time };
const params = { TIME: time };
datasource.ol.updateParams(params);
}

Expand Down Expand Up @@ -78,7 +78,7 @@ export class TimeFilterService {
time = year;
}

const params = { time };
const params = { TIME: time };
datasource.ol.updateParams(params);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h4 (click)="toggleLegendOnClick()" [ngStyle]="{'cursor': filtersCollapsed ? 'de
<igo-time-filter-form
[layer]= "layer"
[options]="datasource.options.timeFilter"
[currentValue]="datasource.options.params.time"
[currentValue]="datasource.options.params.TIME"
(change)="handleDateChange($event)"
(yearChange)="handleYearChange($event)">
</igo-time-filter-form>
Expand Down
Loading