-
Notifications
You must be signed in to change notification settings - Fork 42
Wmts support #386
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
base: master
Are you sure you want to change the base?
Wmts support #386
Changes from all commits
8ae5d21
27d9ef6
34028a2
857f19e
a5316ad
fccd7ee
99c208c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,6 +112,24 @@ Similar properties as Tiled WMS, with these exceptions: | |
| | interpolate | By default, linear interpolation is used when resampling. Set to false to use the nearest neighbor instead. | `"interpolate": false` | | ||
| | tileGridRef | Parameter is not used for `IMAGEWMS` | | | ||
|
|
||
| ## WMTS (tiled) | ||
|
|
||
| | Property | Meaning (from Openlayers [API docs](https://openlayers.org/en/latest/apidoc/module-ol_source_WMTS.html)) | Example | | ||
| |--------------------|:----------|---------| | ||
| | **type** | Indicator that the layer is a WMTS, use `WMTS` | `"type": "WMTS"` | | ||
| | **layer** | Layer name as advertised in the WMTS capabilities. | `"layer": "sgmc2"` | | ||
| | **url** | A URL for the service. For the RESTful request encoding, this is a URL template. For KVP encoding, it is normal URL. A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be used instead of defining each one separately in the `urls` option. | `"url": "https://mrdata.usgs.gov/mapcache/wmts"` | | ||
| | projection | The projection of the layer. Has to be defined in `projectionDefs` if not `EPSG:4326` or `EPSG:3857`. if not set the projection of the map is used | `"projection": "EPSG:3857"` | | ||
| | format | Image format. Only used when requestEncoding is 'KVP' | `"format": "image/png"` | | ||
| | transparent | Boolean value, whether the WMS layer should be queried with a transparent background | `"transparent": true` | | ||
| | tileGridRef | Identifier of the tile grid to use for this layer (has to be defined in `tileGridDefs`) The grid has to be correctly identified with `"type": "WMTS"` | `"tileGridRef": "usgs"` | | ||
| | crossOrigin | Provides support for CORS, defining how the layers source handles crossorigin requests. For more information and the supported values see [HTML attribute: crossorigin](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) | `"crossOrigin": "anonymous"` | | ||
| | cacheSize, interpolate, reprojectionErrorThreshold, tilePixelRatio, version, matrixSet, urls, wrapX, transition, zDirection | The module wraps ol/source/WMTS layer options: https://openlayers.org/en/latest/apidoc/module-ol_source_WMTS.html | `"cacheSize": 16` | | ||
| | optionsFromCapabilities | In WMTS layers options can be retrieved parsing the service capabilities document, the option is an object containing at least the following keys: `url`, `layer`, `matrixSet` or `projection` | `"optionsFromCapabilities": {"url": "https://idt2.regione.veneto.it/gwc/service/wmts?request=GetCapabilities", "layer": "rv:DTM_RV_5m_3003", "matrixSet": "EPSG:4326"}` | | ||
| | hoverAttribute | Attribute to be shown if a feature of the layer is hovered. Only has an effect if `hoverable` is set to `true`. | `"hoverAttribute": "name"` | | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| | hoverOverlay | ID of a custom map overlay to display when a feature of the layer is hovered. Only has an effect if `hoverable` is set to `true`. For more information on how to implement a map overlay see the [reusable components](reusable-components?id=map-overlay) section. | `"hoverOverlay": "my-custom-overlay"` | | ||
| | params | This allows to inject custom HTTP parameters to the GetMap request of the layer. | `"params": {"FEATUREID": 1}"` | | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like |
||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some fields supported by your code are not documented here, e.g. |
||
|
|
||
| ## XYZ | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| import { Image as ImageLayer, Tile as TileLayer } from 'ol/layer'; | ||
| import ImageWMS from 'ol/source/ImageWMS'; | ||
| import TileWmsSource from 'ol/source/TileWMS'; | ||
| import WMTS, { optionsFromCapabilities } from 'ol/source/WMTS.js'; | ||
| import WMTSCapabilities from 'ol/format/WMTSCapabilities.js'; | ||
| import OsmSource from 'ol/source/OSM'; | ||
| import VectorTileLayer from 'ol/layer/VectorTile' | ||
| import VectorTileSource from 'ol/source/VectorTile' | ||
|
|
@@ -65,6 +67,8 @@ export const LayerFactory = { | |
| return this.createTileWmsLayer(lConf); | ||
| } else if (lConf.type === 'IMAGEWMS') { | ||
| return this.createImageWmsLayer(lConf); | ||
| } else if (lConf.type === 'WMTS') { | ||
| return this.createTileWmtsLayer(lConf); | ||
| } else if (lConf.type === 'WFS') { | ||
| return this.createWfsLayer(lConf, olMap); | ||
| } else if (lConf.type === 'XYZ') { | ||
|
|
@@ -165,6 +169,74 @@ export const LayerFactory = { | |
| return layer; | ||
| }, | ||
|
|
||
| /** | ||
| * Returns an OpenLayers Tiled WMTS layer instance due to given config. | ||
| * | ||
| * @param {Object} lConf Layer config object | ||
| * @return {ol.layer.Tile} OL Tiled WMTS layer instance | ||
| */ | ||
| createTileWmtsLayer (lConf) { | ||
| // apply additional HTTP params | ||
|
|
||
| const WMTSlayer = new TileLayer({ | ||
| ...this.getCommonLayerOptions(lConf), | ||
| source: new TileWmsSource({ // fake source, will be replaced | ||
| url: '' | ||
| }) | ||
|
Comment on lines
+183
to
+185
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you just remove |
||
| }) | ||
|
|
||
| if (lConf.optionsFromCapabilities) { | ||
| const parser = new WMTSCapabilities(); | ||
|
|
||
| fetch(lConf.optionsFromCapabilities.url).then(function (response) { | ||
| return response.text(); | ||
| }).then(function (text) { | ||
| const capabilities = parser.read(text); | ||
| const options = optionsFromCapabilities(capabilities, { | ||
| layer: lConf.optionsFromCapabilities.layer, | ||
| matrixSet: lConf.optionsFromCapabilities.matrixSet, | ||
| projection: lConf.optionsFromCapabilities.projection, | ||
| requestEncoding: lConf.optionsFromCapabilities.requestEncoding, | ||
| style: lConf.optionsFromCapabilities.style, | ||
| format: lConf.optionsFromCapabilities.format, | ||
| crossOrigin: lConf.optionsFromCapabilities.crossOrigin | ||
|
Comment on lines
+196
to
+202
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I´m wondering from a structural point of view: Would it be sufficient to replace the |
||
| }) | ||
| const Source = new WMTS({ | ||
| ...options, | ||
| attributions: lConf.attributions, | ||
| hoverable: lConf.hoverable, | ||
| hoverAttribute: lConf.hoverAttribute, | ||
| hoverOverlay: lConf.hoverOverlay | ||
|
Comment on lines
+207
to
+209
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These attributes must be set on the |
||
| }) | ||
| WMTSlayer.setSource(Source) | ||
| }); | ||
| } else { | ||
| WMTSlayer.setSource(new WMTS({ | ||
| url: lConf.url, | ||
| tileGrid: lConf.tileGrid, | ||
| cacheSize: lConf.cacheSize, | ||
| interpolate: lConf.interpolate, | ||
| reprojectionErrorThreshold: lConf.reprojectionErrorThreshold, | ||
| projection: lConf.projection, | ||
| crossOrigin: lConf.crossOrigin, | ||
| layer: lConf.layer, | ||
| style: lConf.style, | ||
| tilePixelRatio: lConf.tilePixelRatio, | ||
| format: lConf.format, | ||
| version: lConf.version, | ||
| matrixSet: lConf.matrixSet, | ||
| urls: lConf.urls, | ||
| wrapX: lConf.wrapX, | ||
| transition: lConf.transition, | ||
| zDirection: lConf.zDirection, | ||
| hoverable: lConf.hoverable, | ||
| hoverAttribute: lConf.hoverAttribute, | ||
| hoverOverlay: lConf.hoverOverlay | ||
| })) | ||
| } | ||
| return WMTSlayer; | ||
| }, | ||
|
|
||
| /** | ||
| * Returns an OpenLayers WFS layer instance due to given config. | ||
| * | ||
|
|
||
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.
Could you be a bit more verbose regarding the documentation here and document fields 1 by 1?