Leaflet map with WMS and custom projection
Asked Answered
E

0

8

I have implemented a map using Leaflet and tiles from a WMS-service. They offer a list of projections, where of one is usable in standard Leaflet EPSG:4326.

However, the map looks a bit distorted, and I recon one of the other projections would be better. The supplier of the maps uses EPSG:32624, but I cannot seem to get that projection right.

This is the complete list: EPSG:32624, EPSG:32619, EPSG:32620, EPSG:32621, EPSG:32622, EPSG:32623, EPSG:32624, EPSG:32625, EPSG:32626, EPSG:32627, EPSG:4326, EPSG:3413, EPSG:3575

I have a fiddle here: http://jsfiddle.net/uyrv2j7f/2/

There are two maps, top one is using desired projection, but not really working. Bottom one is using a working, but distorted projection.

I'm quite sure, that I need to edit the configuration of the crs. But to what? Where to find the info?

I have found the first part here: http://spatialreference.org/ref/epsg/wgs-84-utm-zone-24n/ - the rest I have nicked for examples using other projections.

var crs = new L.Proj.CRS('EPSG:32624',
    '+proj=utm +zone=24 +ellps=WGS84 +datum=WGS84 +units=m +no_defs', {
    resolutions: [
        2116.670900008467, 
        1058.3354500042335, 
        529.1677250021168, 
        264.5838625010584, 
        132.2919312505292, 
        66.1459656252646, 
        26.458386250105836, 
        13.229193125052918, 
        6.614596562526459, 
        2.6458386250105836, 
        1.3229193125052918, 
        0.6614596562526459, 
        0.33072982812632296, 
        0.21166709000084669
    ],
    transformation: new L.Transformation(1, -500, -1, 7017000)
});

Hope someone can help me out.

Alternatively: Leaflet works like a charm for me normally and is preferred library for the case. BUT should someone bee able to Help med out using different library, then I'd be very interested.....

UPDATE: tinproject gave some pointers, I went looking, and this version is closer to the wanted result: http://jsbin.com/rehoxu/5/edit?html,css,js,output

I'd still like inputs on how to really define the variables for the custom-projections though...

Erastianism answered 26/6, 2015 at 10:33 Comment(4)
I think that both maps are really working. I thought that you are expecting a whole world in the first one but projected UTM zones are only 6 degrees wide. As you can see on your spatialreference.org the WGS84 Bounds of UTM zone 24N are: -42.0000, 0.0000, -36.0000, 84.0000, so your maker lies outside that bounds.Hali
Thanks for looking at my question :-) Well... The bottom map shows the right area, Greenland, but too wide in the top, and narrow in the bottom. Probably because normal projections are better for non-polar areas. The top SHOULD show the exact same, just not distorted, as projection should be more suited. BUT I cannot seem to configure it just right..... (look for reference: upload.wikimedia.org/wikipedia/commons/9/98/…)Erastianism
As I want to say in my original comment it's that the projection choosed isn't valid for your needs as the projection only comprise a part of Greenland, you have to look for a suitable one. On the map you show for reference says that this it's a Lambert conformal conic projection, I don't know if there is an EPSG code for that projection, but surely contains all the information to define the Proj tansformation.Hali
Thanks very much for you inputs. I have researched a bit, and though I have not found the perfect solution, I did manage to find examples using other arctic projections. They used code to generate the variables needed which I don't know how to find my self....I was able to snatch bits and pieces to create a much improved map : jsbin.com/rehoxu/5/edit?html,css,js,outputErastianism

© 2022 - 2024 — McMap. All rights reserved.