Reprojection is not working from “EPSG:3857” to “EPSG:21781”

155 views
Skip to first unread message

Vamsi Krishna Marri

unread,
Aug 24, 2016, 11:43:41 AM8/24/16
to GeoAdmin API
Hi,

I am currently using GeoAdmin API and am trying to add an extra layer with a reprojection of “EPSG:3857” on top of a layer created with “ch.swisstopo.pixelkarte-farbe” which is  originally with a projection of “EPSG:21781”. Here is an example code for the reprojection.

<!doctype html>
<html lang="en">


<head>
   
<style>
       
.map {
            height
: 400px;
            width
: 100%;
       
}
   
</style>
   
<title>GeoAdmin API example</title>
</head>


<body>
   
<h2>My first GeoAdmin map</h2>
   
<script src="http://api3.geo.admin.ch/loader.js?lang=en" type="text/javascript"></script>
   
<div id="map" class="map"></div>
   
<script type="text/javascript">
       
var layer = ga.layer.create('ch.swisstopo.pixelkarte-farbe');
       
var map = new ga.Map({
            target
: 'map',
            layers
: [layer],
            view
: new ol.View({
                resolution
: 200,
                center
: [670000, 160000]
           
})
       
});
       
var newLayer = new ol.layer.Tile({
            source
: new ol.source.XYZ({
                projection
: 'EPSG:3857',
                crossOrigin
: '',
                attributions
: [
                   
new ol.Attribution({
                        html
: '<a target="new" href="http://www.swisstopo.admin.ch/' +
                           
'internet/swisstopo/en/home.html">swisstopo</a>'
                   
})
               
],
                url
: 'http://wmts20.geo.admin.ch/1.0.0/ch.swisstopo.pixelkarte-farbe/default/current/3857/{z}/{x}/{y}.jpeg'
           
})
       
});
        map
.addLayer(newLayer);
   
</script>
</body>


</html>

If I try the same reprojection with the Openlayers 3.0, I am able to show everything correctly. Here is an example where a wide range of projections are overlaid on top of different projections.


Could someone help with this.

Thanks,
Vamsi.

Marc Monnerat

unread,
Aug 25, 2016, 11:20:18 AM8/25/16
to geoadmin-api
Hello Vamsi,

I am not sure what you want to do. Do you want to use the GeoAdmin API and display layers from other sources (OSM for instance) or do the opposite, display swisstopo layers in other projections ? The latter, as your code suggest it,  is easy, as we provide our layers in WMTS for other projection (see http://api3.geo.admin.ch/services/sdiservices.html#other-projections). But the view's projection is EPSG:21781 in Geoadmin API. No way to change. An example would be:


The former is a bit trickier, but since the few last version of OL3, it is possible to reproject tiles in the client, as you mentionned in the link you provide.Here is a quci and dirty example (adapted from OL3 example)


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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



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

Vamsi Krishna Marri

unread,
Aug 25, 2016, 12:32:51 PM8/25/16
to GeoAdmin API

Hello Marc,

Thank you very much for the reply.

I actually want to do the former thing. I have some tiles in EPSG:3857 and I want to display them on swisstopo layers.

In the example you are using the OL3 API not the GeoAdmin API. I guess GeoAdmin API does not support this functionality yet. May I know when can I expect this functionality with GeoAdmin API?

Thanks,
Vamsi.

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

Marc Monnerat

unread,
Aug 26, 2016, 5:32:47 AM8/26/16
to geoadmin-api
Hello Vamsi,

The raster reprojection was added in OL 3.11.0 (https://github.com/openlayers/ol3/releases/tag/v3.11.0) in November 2015. Unfortunately, the version of the GeoAdmin API is older than that. We should update it or you may rather use "pure" OL3 for your project.

Regards,

Marc

To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Vamsi Krishna Marri

unread,
Aug 30, 2016, 5:07:21 AM8/30/16
to GeoAdmin API
Hello Marc,

On the other hand, could you please tell me a way to convert the "EPSG:3857" tiles into "EPSG:21781" at the server side

Thanks,
Vamsi.

Marc Monnerat

unread,
Aug 30, 2016, 9:09:16 AM8/30/16
to geoadmin-api
Hello Vamsi,

If you want to convert a WMTS service from one projection to another, Mapproxy (https://mapproxy.org/) is one solution (at least, this is what we are using).

As reprojecting WMTS tiles with "dimensions" (a timestamp i our case) is not so well supported by MapProxy, here is an example of a configuration files (note, it is the oether way round, from EPSG:21781 to EPSG:3857):



Regards,


Marc



To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Vamsi Krishna Marri

unread,
Aug 31, 2016, 6:23:27 AM8/31/16
to GeoAdmin API
Hello Marc,

Thanks for the solution. I will try this and let you know if I find any problem.

Best regard,
Vamsi.
Reply all
Reply to author
Forward
0 new messages