Skip to content

Commit

Permalink
move isValidResponse to WMSUtils adding docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 committed Dec 3, 2024
1 parent 453a5f7 commit a574965
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion web/client/components/map/openlayers/plugins/WMSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import TileWMS from 'ol/source/TileWMS';
import VectorTileSource from 'ol/source/VectorTile';
import VectorTileLayer from 'ol/layer/VectorTile';

import { isVectorFormat, isValidResponse } from '../../../../utils/VectorTileUtils';
import { isVectorFormat } from '../../../../utils/VectorTileUtils';
import { isValidResponse } from '../../../../utils/WMSUtils';
import { OL_VECTOR_FORMATS, applyStyle } from '../../../../utils/openlayers/VectorTileUtils';

import { proxySource, getWMSURLs, wmsToOpenlayersOptions, toOLAttributions, generateTileGrid } from '../../../../utils/openlayers/WMSUtils';
Expand Down
13 changes: 13 additions & 0 deletions web/client/utils/WMSUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ export const isValidGetMapFormat = (format) => {
export const isValidGetFeatureInfoFormat = (format) => {
return getDefaultSupportedGetFeatureInfoFormats().includes(format);
};

/**
* Validate GetMap response from WMS ImageWMS.
* "OGC protocol returns status = 200 with Exception in body,
* this function checks if the exception is contained in the response".
* https://docs.geoserver.org/main/en/user/services/wms/reference.html#exceptions
* @param {object} response
* @return {boolean}
*/
export const isValidResponse = (response) => {
return response?.status === 200 && response?.data && response?.data?.type !== "text/xml";
};

/**
* Parses layer info from capabilities object
* @param {object} capabilities capabilities section of the layer as an object from xml2js parsing of the WMS capabilities
Expand Down

0 comments on commit a574965

Please sign in to comment.