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

Richard Greenwood richard.greenwood at gmail.com
Sat May 25 08:03:20 PDT 2013


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.****
>
> ** **
>
> ** **
>
> *Gary Smart PhD* – Software Engineer – ISR Systems****
>
> *UTC AEROSPACE SYSTEMS*
>
> Malvern Hills Science Park, Geraldine Road, Malvern, WR14 3SZ****
>
> *Tel:* (+44) 1684 899783****
>
> gary.smart at utas.utc.com www.utcaerospacesystems.com****
>
> ** **
>
> CONFIDENTIALITY WARNING: This message may contain proprietary and/or
> privileged information of UTC Aerospace Systems and its affiliated
> companies. If you are not the intended recipient please 1) do not disclose,
> copy, distribute or use this message or its contents, 2) advise the sender
> by return e-mail, and 3) delete all copies (including all attachments) from
> your computer. Your co-operation is greatly appreciated.****
>
> ** **
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>


-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130525/eab04d7a/attachment.html>


More information about the Users mailing list