-
Notifications
You must be signed in to change notification settings - Fork 33
Add WMS DescribeLayer operation support #137
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <DescribeLayerResponse xmlns="http://www.opengis.net/sld" | ||
| xmlns:ows="http://www.opengis.net/ows" | ||
| xmlns:se="http://www.opengis.net/se" | ||
| xmlns:wcs="http://schemas.opengis.net/wcs" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns:imagery="http://www.geodata-service.org/imagery" xsi:schemaLocation="http://www.opengis.net/sld DescribeLayer.xsd"> | ||
| <Version>1.1.0</Version> | ||
| <LayerDescription> | ||
| <owsType>wcs</owsType> | ||
| <se:OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="https://www.geodata-service.org/ows/wcs"/> | ||
| <TypeName> | ||
| <se:CoverageTypeName>imagery:ortho_coverage</se:CoverageTypeName> | ||
| </TypeName> | ||
| </LayerDescription> | ||
| </DescribeLayerResponse> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <DescribeLayerResponse xmlns="http://www.opengis.net/sld" | ||
| xmlns:ows="http://www.opengis.net/ows" | ||
| xmlns:se="http://www.opengis.net/se" | ||
| xmlns:wfs="http://schemas.opengis.net/wfs" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns:geodata="http://www.example.com/geodata" xsi:schemaLocation="http://www.opengis.net/sld DescribeLayer.xsd"> | ||
| <Version>1.1.0</Version> | ||
| <LayerDescription> | ||
| <owsType>wfs</owsType> | ||
| <se:OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="https://www.example.com/geoserver/wfs"/> | ||
| <TypeName> | ||
| <se:FeatureTypeName>geodata:geography_vector</se:FeatureTypeName> | ||
| </TypeName> | ||
| </LayerDescription> | ||
| </DescribeLayerResponse> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { parseDescribeLayerResponse } from './describelayer.js'; | ||
| // @ts-expect-error ts-migrate(7016) | ||
| import describeLayerWfs from '../../fixtures/wms/describelayer-wfs.xml'; | ||
| // @ts-expect-error ts-migrate(7016) | ||
| import describeLayerWcs from '../../fixtures/wms/describelayer-wcs.xml'; | ||
| import { parseXmlString } from '../shared/xml-utils.js'; | ||
|
|
||
| describe('WMS DescribeLayer', () => { | ||
| describe('parseDescribeLayerResponse', () => { | ||
| it('parses a vector layer description (owsType WFS)', () => { | ||
| const doc = parseXmlString(describeLayerWfs); | ||
| const result = parseDescribeLayerResponse( | ||
| doc, | ||
| 'geodata:geography_vector' | ||
| ); | ||
| expect(result).toEqual({ | ||
| layerName: 'geodata:geography_vector', | ||
| owsType: 'wfs', | ||
| owsUrl: 'https://www.example.com/geoserver/wfs', | ||
| typeName: 'geodata:geography_vector', | ||
| }); | ||
| }); | ||
|
|
||
| it('parses a raster layer description (owsType WCS)', () => { | ||
| const doc = parseXmlString(describeLayerWcs); | ||
| const result = parseDescribeLayerResponse(doc, 'imagery:ortho_coverage'); | ||
| expect(result).toEqual({ | ||
| layerName: 'imagery:ortho_coverage', | ||
| owsType: 'wcs', | ||
| owsUrl: 'https://www.geodata-service.org/ows/wcs', | ||
| typeName: 'imagery:ortho_coverage', | ||
| }); | ||
| }); | ||
|
|
||
| it('returns null when the response contains no layer description', () => { | ||
| const emptyResponse = `<?xml version="1.0" encoding="UTF-8"?> | ||
| <DescribeLayerResponse xmlns="http://www.opengis.net/sld"> | ||
| <Version>1.1.0</Version> | ||
| </DescribeLayerResponse>`; | ||
| const doc = parseXmlString(emptyResponse); | ||
| const result = parseDescribeLayerResponse(doc, 'nonexistent:layer'); | ||
| expect(result).toBeNull(); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { XmlDocument } from '@rgrove/parse-xml'; | ||
| import { | ||
| findChildElement, | ||
| getElementAttribute, | ||
| getElementText, | ||
| getRootElement, | ||
| } from '../shared/xml-utils.js'; | ||
| import { WmsLayerDescription } from './model.js'; | ||
|
|
||
| /** | ||
| * Parses a WMS DescribeLayer response document and returns the description | ||
| * for the requested layer. | ||
| * @param describeLayerDoc The parsed XML document from a DescribeLayer response | ||
| * @param layerName The layer name to look for in the response | ||
| * @return The layer description, or null if the layer was not found in the response | ||
| */ | ||
| export function parseDescribeLayerResponse( | ||
| describeLayerDoc: XmlDocument, | ||
| layerName: string | ||
| ): WmsLayerDescription | null { | ||
| const root = getRootElement(describeLayerDoc); | ||
| const match = findChildElement(root, 'LayerDescription'); | ||
| if (!match) return null; | ||
|
|
||
| const owsType = getElementText( | ||
| findChildElement(match, 'owsType') | ||
| ) as WmsLayerDescription['owsType']; | ||
| const onlineResource = findChildElement(match, 'OnlineResource'); | ||
| const owsUrl = getElementAttribute(onlineResource, 'xlink:href'); | ||
|
|
||
| const typeNameEl = findChildElement(match, 'TypeName'); | ||
| const typeName = | ||
| getElementText(findChildElement(typeNameEl, 'FeatureTypeName')) || | ||
| getElementText(findChildElement(typeNameEl, 'CoverageTypeName')); | ||
|
|
||
| return { | ||
| layerName, | ||
| owsType, | ||
| owsUrl, | ||
| ...(typeName ? { typeName } : {}), | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a SLD_VERSION=1.1.0 param here