Skip to content

Commit

Permalink
#10193: Issue with WFS added via Query params (#10195) (#10296)
Browse files Browse the repository at this point in the history
* #10193: Issue with WFS added via Query params
- fix the issue behind not adding the wfs layer
- write the unit tests for this cahnge

* Update web/client/api/WFS.js

---------

Co-authored-by: Suren <dsuren1@gmail.com>
  • Loading branch information
mahmoudadel54 and dsuren1 committed May 10, 2024
1 parent a6766d1 commit dacfbc0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 8 additions & 4 deletions web/client/api/WFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,28 @@ export const getFeatureSimple = function(baseUrl, params) {
export const getCapabilitiesURL = (url, {version = "1.1.0"} = {}) => {
const parsed = urlUtil.parse(getDefaultUrl(url), true);
return urlUtil.format(assign({}, parsed, {
search: undefined, // this allows to merge parameters correctly
query: assign({
service: "WFS",
version,
...parsed.query,
service: "WFS",
request: "GetCapabilities"
}, parsed.query)
})
}));
};

export const getFeatureURL = (url, typeName, { version = "1.1.0", ...params } = {}) => {
const parsed = urlUtil.parse(getDefaultUrl(url), true);
return urlUtil.format(assign({}, parsed, {
search: undefined, // this allows to merge parameters correctly
query: assign({
service: "WFS",
typeName,
version,
...parsed.query,
service: "WFS",
request: "GetFeature",
...params
}, parsed.query)
})
}));
};
/**
Expand Down
12 changes: 12 additions & 0 deletions web/client/api/__tests__/WFS-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,16 @@ describe('Test WFS ogc API functions', () => {
expect(getFeatureURL(_url).split('?')[0]).toBe(_url[0]);
});

it('getFeatureURL if it includes getCapabilites request', () => {
const _url = 'http://gs-stable.geosolutionsgroup.com:443/geoserver3/wfs?service=WFS&version=1.1.0&request=GetCapabilities';
const featureURL = getFeatureURL(_url, "layerName");
expect(featureURL.includes("request=GetFeature")).toBeTruthy();
expect(featureURL.split('?')[1]).toEqual('typeName=layerName&version=1.1.0&service=WFS&request=GetFeature');
});

it('getFeatureURL if it includes normal getFeature request with version different than the default one', () => {
const _url = 'http://gs-stable.geosolutionsgroup.com:443/geoserver3/wfs?service=WFS&version=1.1.1&request=GetFeature';
const featureURL = getFeatureURL(_url, "layerName");
expect(featureURL.split('?')[1]).toEqual('typeName=layerName&version=1.1.1&service=WFS&request=GetFeature');
});
});

0 comments on commit dacfbc0

Please sign in to comment.