[OpenLayers-Users] EPSG:4326 WMS map aspect ratio

Smart, Gary Gary.Smart at utas.utc.com
Thu May 30 08:52:39 PDT 2013


Thanks for the response.  However, I am not in control of the WMS maps
supplied.  I certainly cannot insist that the customer re-projects his
entire WMS contents.

I am looking for a way to make the client (openLayers) adjust the
projection (to its native spherical Mercator) prior to display?  

Incidentally, WorldWind has no problem displaying maps from the very
same WMS and displaying a square OS grid.

 

From: Richard Greenwood [mailto:richard.greenwood at gmail.com] 
Sent: 25 May 2013 16:03
To: Smart, Gary
Cc: OpenLayers
Subject: [External] Re: [OpenLayers-Users] EPSG:4326 WMS map aspect
ratio

 

I would suggest that you use an appropriate map projection for your area
of interest. That's what projections are for. Ideally you project all
your data and save it in that projection, although it is possible to
reproject on the server, or on the client.

Rich

 

On Wed, May 22, 2013 at 7:59 AM, Smart, Gary <Gary.Smart at utas.utc.com>
wrote:

I really would like to display the contents of my local WMS in a form
which the users are used to (i.e. square OS grids, rather than the
'squashed' appearance which comes from mapping the EPSG:4326 onto a
flat-Earth projection in high latitudes).  I have found numerous
examples of' how to resolve this problem', but none seem to have any
effect on the distortion OR they result in no map being displayed at
all.  I cannot connect directly to map servers on the web (spherical
Mercator), because my system is an isolated network and the maps are
supplied by the customer.

 

Salient extracts from the js code follow:

        var map, options = { 
                             projection: new
OpenLayers.Projection('EPSG:4326'), 
                             //displayProjection: new
OpenLayers.Projection('EPSG:3574'),
                             //units: 'm',
                             //maxResolution: 156543.0339,
                             //maxExtent: new
OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508)
                             zoom: 14
                           };
        map = new OpenLayers.Map('map', options);

 

        var my50kLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS", 

 
"http://expdev2/cgi-bin/wms?", 

                                                   {

                                                     layers:
'UK_ASRP_1to50000',

                                                     format:
'image/png',

                                                     //transparent:
'true',

                                                    continuousWorld:
true,

                                                     attribution: "OS
1:50K",

                                                   }); 

        map.addLayers([my50kLayer]);

 

As the code exists above, the displayed map works fine (apart from the
squished grid rectangles).  Having adapted the 'measure example' from
the OpenLayers examples page, I can measure from the map, and if the
geodesic selection is made, the measurements are clearly correct (1Km
across both dimensions of the OS grid).  With geodesic selection not
clicked, the measurement across the map is approximately 1.5Km.  So the
transforms and projections are clearly in sync.  But how do I stretch
the maps in the 'y' direction so they appear equant (not squished
vertically)?

 

Adding the displayProjection seems to do nothing.  Using any of the
other options with my WMS, results in a blank map.

 

I have also plagiarised the polar-projections example from the
OpenLayers example site, and replace the buttons with the following
projections:

var projectionOptions = 

    {

        'EPSG:4326':

        {

            projection: new OpenLayers.Projection('EPSG:4326')

        },

        'EPSG:3857':

        {

            projection: new OpenLayers.Projection('EPSG:3857'),

            maxExtent: new OpenLayers.Bounds(-5505054, -5505054,
5505054, 5505054),

            maxResolution: 5505054 / 128,

            numZoomLevels: 18

        }

    }; // end projectionOptions array

 

And I have applied the projections as per the example code (i.e.
setProjection function was copied and is being called).  However,
pressing EPSG:3857 button results in a blank map, and pressing EPSG:4326
after that, also results in a blank map (albeit with a white pair of
tiles in the middle)!

 

Can anyone tell me whether it is possible to display a square grid for
OS maps coming from an EPSG:4326 WMS?

Thank you.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130530/6b5bfb05/attachment-0001.html>


More information about the Users mailing list