how to use wmts service with EPSG 21781 to show pixelkarte-farbe

452 views
Skip to first unread message

Alex

unread,
Feb 26, 2015, 10:58:20 AM2/26/15
to geoadm...@googlegroups.com
Hi

There is a nice example in the docs showing how to use the wmts service to present a pixelkarte-farbe in ol3 in EPSG:3857 (http://api3.geo.admin.ch/examples/ol3_mercator.html).
This works well in my code and on codepen: http://codepen.io/barbalex/pen/bNKpaq

I have tried unsucessfully to use EPSG:21781 though. This is the code (well, one of many versions I tried): http://codepen.io/barbalex/pen/dPKMjb

I have struggled to understand what is different when using EPSG:21781 instead of EPSG:3857:
Thanks for help!
Alex

Loïc Gasser

unread,
Feb 27, 2015, 3:10:51 AM2/27/15
to geoadm...@googlegroups.com

Hello Alex,

So first of all I think you are probably aware of that, but in order to use this layer, you need to register here http://www.swisstopo.admin.ch/internet/swisstopo/en/home/products/services/web_services/webaccess.html .

I believe that you are trying to use a pure ol3 implentation using our WMTS service, otherwise you could cut right through complexity using our API. http://api3.geo.admin.ch/examples/geoadmin_mapoverlay.html

If your goal is to use only ol3, here is an external example and explanations, that will be soon part of our doc. (You need to define the tile grid and wmts source, and include the proj4js definition of 21781 epsg code.)
http://procrastinatio.org/2015/02/21/lv95-lv03-comparison/

Concerning your question regarding projections.
When creating our tiles the default proj is 2178 and we use the wmts addresses {1-4}.
All the other projections are using the wmts address {10}, because they are reprojected tiles on the fly.

So if you don't really care about ptojection in your app, you should use the default one.

I hope that this is helpful to you.

Good luck with all that!

Kind Regards,
Loïc Gasser

Swisstopo

--
You received this message because you are subscribed to the Google Groups "GeoAdmin API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexander Gabriel

unread,
Feb 27, 2015, 5:27:52 AM2/27/15
to geoadm...@googlegroups.com
yep, I am aware of registering. Will do it before launching the app

yep, I'm using pure ol3. There's two reasons for this:
  1. the app and also the mapping part will be used (partly) offline, using locally stored base maps. The geo-admin-api WMTS will only be used when online
  2. I want to minimize dependencies and most of all: having to rush updates when the geo-admin-api is updated
I'll try your suggestions, thanks a lot for helping!

--
You received this message because you are subscribed to a topic in the Google Groups "GeoAdmin API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geoadmin-api/EVVK7qfOheU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to geoadmin-api...@googlegroups.com.

Alexander Gabriel

unread,
Feb 27, 2015, 8:48:34 AM2/27/15
to geoadm...@googlegroups.com
works!

thanks
Alex

Marc Monnerat

unread,
Mar 2, 2015, 10:46:40 AM3/2/15
to geoadmin-api
Hello Alex,

I'll try to clarify further some of your questions. 


1/ There are hundreds of projections, covering deferent goals. In Switzerland we use a projection called  *LV03* (German), *MN03" (French), *Swiss grid* (Garmin) or "EPSG:21781" (from EPSG). This projection is 100 years old and fits Switzerland best. Global system use different projection, and most, if not all, global web mapping application as Google Map, OpenStreetMap, Bing Map or Yandex Map, use *EPSG:3857* also know as *Web-Mercator*, *Google Projection*, *Pseudo-Mercator projection* or even *EPSG:9009l3* and so one. If you want to mix multiple projections in one application, you have to reproject your sources. In Web-application it is only possible with vector layer. In Desktop application like QGis or ESRI ARcMap, you may also reproject raster layer like the WTMS tile.

2/ Correct timestamp.
Some geo.admin.ch layers a updated from time to time, like the pixelkarte. To reflect this change, we also update the *timestamp*. So at the time of writing, we have for *ch.swisstopo.pixelkarte-farbe*, the following *timestamps*: 20151231,20140520,20140106,20130903,20130213,20120809,20111206,20111027,20110401.
For other layer, like the *ch.swisstopo.lubis-luftbilder_schwarzweiss*, which is the metadata for aerial images, you will find every year between now and 1926. So there is no *right* or *wrong* *timestamps*.

3/ ResourceUrl
The ResouceUrl is a template you need to build the correct WMT GetTile request. You'll find this information in the corresponding WMTS GetCapabilities, for instance http://wmts10.geo.admin.ch/1.0.0/WMTSCapabilities.EPSG.3857.xml for the Pseudo-Mercator projection.

Desktop GIS application like Qgis and ESRI ArcMap may use this document directly to configure and display layers. If you have to build manually the getTileRequest as in most JS library, please pay attention to the following points:

- We have two sets of hosts (backends): wmts{0-5} for native tiles (=EPSG:21781) and wmts{10-14} for non-native tiles (all other projections). This is not optimal, but otherwise we should have to parse every GetTile request in order to redirect it on the right backend, what would kill our caching proxy!
- You have to find a valid *timestamp* (Time) value, which is different for every layer. This information is found in the WMTS GetCapabilities. *Older* timestamp are never erased.
- The {TileMatrixSet}, which is the number of zoom level ({TileMatrix}) we have for one layer, is defined in the GetCapabilities, but not used in the RessourceUrl. It is always the EPSG projection code, i.e. '21781', '3857',...
- The {TileCol} and {TileRow} order is interverted between the native and non-native tiles!

It is a bit unfortunate, but to configure a layer in a Web-application, you have to use the WMTS GetCapabilities document, which most Web Mappings library are unable to parse.

For native tiles (EPSG:21781), the RessourceURl is:

For all other projection is like this:

The only parameter with the same value/meaning accrross all projections being *{Time}*.

4/ EPSG code in ol3
Yes, in pure OL3, only EPSG:4326 and EPSG:3857 are defined. If you want to use other projection, you have to add it manually. In api3.geo.admin.ch/loader.js we have added both EPSG:21781 and EPGS:2056.

For instance, the definition for 'EPSG:21751' is:

proj4.defs("EPSG:21781","+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs");

You could get it from: for http://epsg.io/21781

A lots of informations, but I hope it helps to make the whole a bit clearer.

Marc

Alexander Gabriel

unread,
Mar 2, 2015, 3:13:57 PM3/2/15
to geoadm...@googlegroups.com

Yes, very helpful

I grabbed your handy wmtsSource-function (thanks Loic for the link) and copied the timestamp from the WMTS GetCapabilities document.

It works nicely now.

Thanks for your great help!

Alex

Reply all
Reply to author
Forward
0 new messages