AW: [OpenLayers-Users] OpenLayers/Leaflet+MapServer (WMS) -coordinate-problem

Arnd Wippermann arnd.wippermann at web.de
Thu Sep 8 13:32:22 EDT 2011


Hi,

As you want to display your WMS on OSM layer, you have to use the projection
EPSG:900913 in OpenLayers. Then OpenLayers build the requeststring with the
coordinates in this projection. In a normal case MapServer would transform
the requested data from EPSG:4326 (if your layer is in that projection) to
EPSG:900913 and send them back and in OpenLayers they will displayed in
correct manner. 

As I understood, you grab the requeststring to parse it by yourself and then
do some action. In this case you have to do the transformation by yourself.

Arnd

-----Ursprüngliche Nachricht-----
Von: biff21 at gmx.de [mailto:biff21 at gmx.de] 
Gesendet: Mittwoch, 7. September 2011 16:59
An: Arnd Wippermann
Betreff: AW: [OpenLayers-Users] OpenLayers/Leaflet+MapServer (WMS)
-coordinate-problem

Hi,

I tried your suggestions but no success.

### My OL-Code:

var options = {
controls:[], //create map without controls -> add them later
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
numZoomLevels: 18,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508.34)
};
var map = new OpenLayers.Map('map', options);

var layer = new OpenLayers.Layer.OSM();
map.addLayer(layer);

var wetterpool_wms_layer = new OpenLayers.Layer.WMS("Wetterpool
Wetterdaten", "http://www.wetterpool.de/!test/OpenlayersWMS/mapserver.php",
{ layers: 'basic',format: 'image/png' }, { singleTile: true, ratio: 1,
opacity: 0.5, transitionEffect: 'resize' } );
wetterpool_wms_layer.addOptions({isBaseLayer: false});
map.addLayer(wetterpool_wms_layer);

map.addControl(new OpenLayers.Control.PanZoomBar()); map.addControl(new
OpenLayers.Control.MouseToolbar());
map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false}));
map.addControl(new OpenLayers.Control.Permalink()); map.addControl(new
OpenLayers.Control.Permalink('permalink'));
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.OverviewMap());
map.addControl(new OpenLayers.Control.KeyboardDefaults());

map.zoomToMaxExtent();

### MY WMS-Code

<?php

foreach($_REQUEST AS $key => $value)
{
	$string .= $key.'->'.$value."\n";
}
// Send me an email with url-params and quit mail('xxx','WMS',$string);exit;

?>

#######################################################

Problem is that the coordinates from OpenLayers still are in wrong format.
It wouldn't be a problem if setExtent would accept different formats of
coordinates. It's realy strange that a mapfile accepts coordinats like
-29156140.063875 and setExtent needs decimals like 50.3453°

More ideas?

Thank you!

Regards,
Guido

-------- Original-Nachricht --------
> Datum: Tue, 6 Sep 2011 22:30:48 +0200
> Von: "Arnd Wippermann" <arnd.wippermann at web.de>
> An: biff21 at gmx.de
> CC: users at openlayers.org
> Betreff: AW: [OpenLayers-Users] OpenLayers/Leaflet+MapServer (WMS) 
> -coordinate-problem

> Hi,
> 
> Most likely you have initialized your map without map options.
> 
> map = new OpenLayers.Map("map");
> 
> Then the map projection is EPSG:4326 by default, also the OSM layer
> (baselayer) is displayed with projection EPSG:900913.
> 
> It seems, that the querystring by OpenLayers takes the projection from 
> the map and the coordinates from the baselayer.
> 
> To be sure about projections it is always the best way to initialize 
> the map with options like
> 
> var options = {
>     controls:[], //create map without controls -> add them later
>     projection: new OpenLayers.Projection("EPSG:900913"),
>     displayProjection: new OpenLayers.Projection("EPSG:4326"),
>     units: "m",
>     numZoomLevels: 18,
>     maxResolution: 156543.0339,
>     maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
>                                      20037508, 20037508.34) }; var map 
> = new OpenLayers.Map('map', options);
>  
> Regards,
> Arnd
> 
> -----Ursprüngliche Nachricht-----
> Von: openlayers-users-bounces at lists.osgeo.org
> [mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von 
> biff21 at gmx.de
> Gesendet: Dienstag, 6. September 2011 12:21
> An: openlayers-users at lists.osgeo.org
> Betreff: [OpenLayers-Users] OpenLayers/Leaflet+MapServer (WMS) 
> -coordinate-problem
> 
> Hello community,
> 
> I got a bad problem with coordinates. I tried to setup a raw MapServer 
> WMS with OpenLayers frontend. My aim is to show measurement data from 
> a database as a single tile with OpenLayers.
> 
> Some facts: OpenLayers: - Background-Map: OSM (new
> OpenLayers.Layer.OSM();)
> - requesting my MapServer WMS (new OpenLayers.Layer.WMS) with 
> Single-Tile-Mode
> 
> MapServer: - Raw WMS - means I'm fetching the querystring by myself 
> and trying to apply it to the map - No mapfile used - all settings in 
> map-generating file itself
> 
> My problem is, that OpenLayers creates a querystring like that...
> 
> LAYERS->basic
> FORMAT->image/png
> PROJECTION->EPSG:4326
> UNITS->m
> SERVICE->WMS
> VERSION->1.1.1
> REQUEST->GetMap
> STYLES->
> EXCEPTIONS->application/vnd.ogc.se_inimage
> BBOX->-11231962.682325,-2416633.0858313,19763558.029875,12161436.94610
> BBOX->6
> WIDTH->1584
> HEIGHT->745
> 
> ...and mapserver has a method to set the bounding box from OpenLayers...
> 
> $Map->setExtent(lat1,lon1,lat2,lon2);
> 
> but the coordinates have a different format. OpenLayers provides 
> coordinates in UTM(?) while setExtent expects decimal values as I 
> often saw them in example scripts.
> 
> My question is: How can I create a map which fits perfectly with the 
> OSM map, but without using a mapfile and tilemode since I need 
> singletile-mode?
> I couldn't figure out to set the bounding box correctly or even 
> convert the coordinates. Additionally I suppose that something is 
> wrong with my projections.
> 
> BTW using leaflet causes the same problem. Coordinates look like
> bbox->1878516.4071364915,5635549.221409475,2504688.5428486555,6261721.
> bbox->357121
> 64 while setExtent() needs decimal values (lat/lon)
> 
> I hope someone can help me.:)
> --
> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen 
> Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
> 

-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de



More information about the Users mailing list