openlayers 3: combine osm with swisstopo

488 views
Skip to first unread message

jan.gl...@gmail.com

unread,
Jan 6, 2016, 7:22:41 AM1/6/16
to GeoAdmin API
I'd like to integrate swisstopp "ch.swisstopo.pixelkarte-farbe" in my existing webapp based on openlayers 3. I look though a some examples but I have still some problems.

Based on this page ( http://api3.geo.admin.ch/services/sdiservices.html#other-projections ) there is also the projection EPSG:3857 which I need for osm and other maps. here ( http://wmts10.geo.admin.ch/EPSG/3857/1.0.0/WMTSCapabilities.xml ) I found all specs for "ch.swisstopo.pixelkarte-farbe" so I wrote this:

new ol.layer.Tile({
visible: true,
source: new ol.source.WMTS(({
layer: 'ch.swisstopo.pixelkarte-farbe',
crossOrigin: 'anonymous',
                projection: ol.proj.get('EPSG:3857'),
tileGrid: new ol.tilegrid.WMTS({
origin: [420000, 350000],
resolutions: [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, 0.25, 0.1],
matrixIds: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]
}),
requestEncoding: 'REST'
        }))
})


but this is not working, the url of the tiles are wrong (Col and Row). I think the origin is wrong, am I right? or what else?
can someone help me with a tip?

thanks a lot
jan

Marc Monnerat

unread,
Jan 6, 2016, 7:51:42 AM1/6/16
to geoadmin-api
Hello Jan,

I think you were pretty close, only your tileGrid definition was wrong. You have to use settings for EPSG:3857, not EPSG:21781 as you were. The resolution in the pseudo-mercator follow a regular power of two pattern...

I did correct your example: http://codepen.io/procrastinatio/pen/eJvVgP

More example: https://www.procrastinatio.org/mercator/ (maybe not all up to date)

Gruss

Marc

--
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.



--
-- ἡ φύσις οὐδὲν ποιεῖ ἅλματα.

jan.gl...@gmail.com

unread,
Jan 6, 2016, 9:02:41 AM1/6/16
to GeoAdmin API
wow, thanks for your fast response and solution! j

jan.gl...@gmail.com

unread,
Jun 7, 2016, 4:54:32 PM6/7/16
to GeoAdmin API
in the new release is a new map available: ch.swisstopo.landeskarte-farbe-10

if I change my layer name to this, it's not working. is this map not available for EPSG:3857?

will this map be a part of ch.swisstopo.pixelkarte-farbe (zoomlevel)?


Am Mittwoch, 6. Januar 2016 13:51:42 UTC+1 schrieb Marc Monnerat:

Marc Monnerat

unread,
Jun 8, 2016, 3:45:20 AM6/8/16
to geoadmin-api
Hello,

No, the new  ch.swisstopo.landeskarte-farbe-10 is a layer of it's own and is available in all projection through WMTS. So sum up, you have:

ch.swisstopo.pixelkarte-farbe-p25.noscale, the scanned national map at scale 1:25'000, available at all scale. Same for all other scales.
- ch.swisstopo.pixelkarte-farbe, a mixed of all national map (scale ranging from 1:25'000 to 1:1'000'000). In map.geo.admin.ch, it is combined with the ch.swisstopo.landeskarte-farbe-10.
- ch.swisstopo.landeskarte-farbe-10, also available at all zoom level.


I did update the example: http://codepen.io/procrastinatio/details/wWKYmV/ with the new LK10.

The full list of all available layers is always in the GetCapabilities:


You may also want to try using this WMTS GetCapabilities document to configure a layer. On way to do it: http://codepen.io/procrastinatio/pen/vKBjNz

Yes, I know parsing this huge XML document is highly inefficient, but it is the only official way to find the layer list, available timestamps. You may also try to use map.geo.admin.ch's layersConfig, which is JSON, but this is a file maded for geo.admin.ch, so subject to changes. But it has basically all informations you need.

I hope it is a bit clearer.

Regards,


Marc

jan.gl...@gmail.com

unread,
Jun 8, 2016, 6:06:02 PM6/8/16
to GeoAdmin API
thanks for this. I didn't get that ch.swisstopo.landeskarte-farbe-10 hast an .png output instead of .jpg
 
- ch.swisstopo.pixelkarte-farbe, a mixed of all national map (scale ranging from 1:25'000 to 1:1'000'000). In map.geo.admin.ch, it is combined with the ch.swisstopo.landeskarte-farbe-10.
do you have any tips or an example how to combine this two layers as in map.geo.admin.ch

Marc Monnerat

unread,
Jun 9, 2016, 8:17:59 AM6/9/16
to geoadmin-api
Hello Jan,

For each OL3 layer you may define a minResolution and a maxResolution. So choose them wiesely, and you will only display one of the two layers. But a better way to do it, is to define an ol.layer.Group where you add your layers, which what is done in map.geo.admin.ch. So if you change the group's opacity, all layers will change.

Regards,


Marc

--
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.

jan.gl...@gmail.com

unread,
Jun 12, 2016, 5:55:09 PM6/12/16
to GeoAdmin API
perfect, I could solve this now in my app

Marc Monnerat

unread,
Jun 14, 2016, 3:35:05 AM6/14/16
to geoadmin-api
Nice.
Reply all
Reply to author
Forward
0 new messages