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

Add new gmf.source.Swisstopo #333

Merged
merged 1 commit into from Nov 24, 2015
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions contribs/gmf/exports/source/swisstoposource.js
@@ -0,0 +1,4 @@
goog.require('gmf.source.Swisstopo');


goog.exportSymbol('gmf.source.Swisstopo', gmf.source.Swisstopo);
31 changes: 31 additions & 0 deletions contribs/gmf/externs/gmfx.js
Expand Up @@ -105,6 +105,37 @@ gmfx.source.AsitVDOptions;
gmfx.source.AsitVDOptions.prototype.layer;


/**
* @typedef {{
* layer: string,
* format: (string|undefined),
* timestamp: string
* }}
*/
gmfx.source.SwisstopoOptions;


/**
* Layer name.
* @type {string}
*/
gmfx.source.SwisstopoOptions.prototype.layer;


/**
* Image format. Default is `png`.
* @type {string}
*/
gmfx.source.SwisstopoOptions.prototype.format;


/**
* The `Time` dimension of the source.
* @type {string}
*/
gmfx.source.SwisstopoOptions.prototype.timestamp;


/**
* Configuration object for the locationchooser component.
* @typedef {{
Expand Down
71 changes: 71 additions & 0 deletions contribs/gmf/src/source/swisstoposource.js
@@ -0,0 +1,71 @@
goog.provide('gmf.source.Swisstopo');

goog.require('ol.Attribution');
goog.require('ol.source.WMTS');
goog.require('ol.tilegrid.WMTS');


/**
* @const {!Array.<number>}
* @private
*/
gmf.source.SwisstopoResolutions_ = [
4000, 3750, 3500, 3250, 3000, 2750, 2500, 2250, 2000, 1750, 1500, 1250,
1000, 750, 650, 500, 250, 100, 50, 20, 10, 5, 2.5, 2, 1.5, 1, 0.5
];


/**
* @const {ol.tilegrid.WMTS}
* @private
*/
gmf.source.SwisstopoTileGrid_ = new ol.tilegrid.WMTS({
extent: [420000, 30000, 900000, 350000],
resolutions: gmf.source.SwisstopoResolutions_,
matrixIds: gmf.source.SwisstopoResolutions_.map(function(value, index) {
return String(index);
})
});



/**
* Layer source for the Swisstopo tile server.
* WARNING: This tile server is not publicly available: you have to be
* registered by Swisstopo to use the service.
* @see https://api3.geo.admin.ch/services/sdiservices.html#wmts
*
* @constructor
* @extends {ol.source.WMTS}
* @param {gmfx.source.SwisstopoOptions} options WMTS options.
*/
gmf.source.Swisstopo = function(options) {

var format = options.format ? options.format : 'png';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're declaring the format variable but not using it afterwards.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


goog.base(this, {
attributions: [gmf.source.Swisstopo.ATTRIBUTION_],
url: 'https://wmts{5-9}.geo.admin.ch/1.0.0/{Layer}/default/{Time}' +
'/21781/{TileMatrix}/{TileRow}/{TileCol}.' + format,
dimensions: {
'Time': options.timestamp
},
projection: 'EPSG:21781',
requestEncoding: 'REST',
layer: options.layer,
style: 'default',
matrixSet: '21781',
format: 'image/' + format,
tileGrid: gmf.source.SwisstopoTileGrid_
});
};
goog.inherits(gmf.source.Swisstopo, ol.source.WMTS);


/**
* @const {ol.Attribution}
* @private
*/
gmf.source.Swisstopo.ATTRIBUTION_ = new ol.Attribution({
html: '&copy; <a href="http://www.swisstopo.admin.ch">swisstopo</a>'
});