Pages: 1
- Sujet précédent - Problème d'encodage d'url avec MapServer, WMS et OpenLayers - Sujet suivant
#1 Fri 08 July 2011 16:39
- Léo D.
- Juste Inscrit !
- Date d'inscription: 8 Jul 2011
- Messages: 2
Problème d'encodage d'url avec MapServer, WMS et OpenLayers
Bonjour,
Je chercher depuis plusieurs jours à projeter dans une interface OpenLayers un couche shape depuis une base PostGIS à travers un serveur WMS via MapServer, le tout sans succès.
La couche shape en question est en Lambert I Nord (epsg:27561).
Lorsque j'exécute la page contenant mon code OpenLayers, des tuiles s'affichent, mais au lieu de contenir ma carte, elles affichent le message d'erreur suivant :
Code:
msWMSLoadGetMapParams(): WMS server error. Invalid SRS given : SRS must be valid for all requested layers.
Je comprends bien que ce message signifie qu'il y a un problème de projection, mais je ne parviens pas à le résoudre… Je pense que l'erreur se situe au niveau du code JavaScript OpenLayers, car lorsque je tente d'accéder à la couche via le mapefile directement cela fonctionne parfaitement, voici l'url que j'ai utilisé pour ce résultat :
Code:
http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&VERSION=1.1.1&REQUEST=GetMap&LAYERS=plan&STYLES=&SRS=EPSG:27561&BBOX=596320.332137793,125469.939357467,604889.312972374,131578.734095216&WIDTH=500&HEIGHT=400&FORMAT=image/png
En regardant le code source produit par OpenLayers, j'ai l'impression que le problème se situe au niveau de l'url qui sert de source aux images à afficher. L'encodage semble en effet mauvais et fait notamment sauter la définition du paramètre SRS (ce qui expliquerait l'erreur de projection) :
Code:
http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&LAYERS=plan&SRS=EPSG%3A4326&WIDTH=256&HEIGHT=256&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&BBOX=-180,0,-90,90
Tous mes fichiers sont encodés en ISO-8859-1 et reconnus comme tels par mon navigateur (Firefox).
Un intervenant du forum aurait-il une idée pour résoudre mon problème ?
Voici mon fichier HTML contenant mon code OpenLayers :
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta title="WMS MapServer et OpenLayers">
<script src="http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var map = new OpenLayers.Map("map", {displayProjection:new OpenLayers.Projection("EPSG:27561")});
var wms = new OpenLayers.Layer.WMS("plan", "http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&",
{layers: "plan",
srs: "EPSG:27561",
width: "500",
height: "400",
format: "image/png"});
map.addLayer(wms);
</script>
</body>
</html>Voici mon mapfile :
Code:
MAP
EXTENT 596320.332137793 125469.939357467 604889.312972374 131578.734095216
IMAGECOLOR 0 0 0
SIZE 600 600
NAME "Paris"
PROJECTION
"init=epsg:27561"
END #PROJECTION
WEB
IMAGEPATH '/Users/macbook/Sites/mapserver/temp/'
IMAGEURL '../../temp/'
METADATA
"wms_enable_request" "*"
"wms_title" "WMS Demo Server"
"wms_onlineresource" "http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"
"wms_srs" "epsg:27561"
"wms_format" "image/png"
END #METADATA
END #WEB
LAYER
NAME "plan"
METADATA
"wms_title" "plan"
"wms_srs" "epsg:27561"
END #METADATA
PROJECTION
"init=epsg:27561"
END #PROJECTION
CONNECTIONTYPE POSTGIS
CONNECTION "user=*** password=*** dbname=*** host=localhost"
DATA "the_geom FROM paris USING UNIQUE gid USING srid=27561"
STATUS OFF
TYPE POLYGON
CLASS
COLOR 255 255 255
OUTLINECOLOR 0 100 0
END #CLASS
END #LAYER
END #MAPEt voici le contenu du document XML renvoyé par la requête GetCapabilities pour aider le debugging :
Code:
<?xml version='1.0' encoding="ISO-8859-1" standalone="no" ?>
<!DOCTYPE WMT_MS_Capabilities SYSTEM "http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd"
[
<!ELEMENT VendorSpecificCapabilities EMPTY>
]> <!-- end of DOCTYPE declaration -->
<WMT_MS_Capabilities version="1.1.1">
<!-- MapServer version 6.0.0 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=CAIRO SUPPORTS=FREETYPE SUPPORTS=ICONV SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=THREADS SUPPORTS=GEOS INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE -->
<Service>
<Name>OGC:WMS</Name>
<Title>WMS Demo Server</Title>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/>
<ContactInformation>
</ContactInformation>
</Service>
<Capability>
<Request>
<GetCapabilities>
<Format>application/vnd.ogc.wms_xml</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Post>
</HTTP>
</DCPType>
</GetCapabilities>
<GetMap>
<Format>image/png</Format>
<Format>image/jpeg</Format>
<Format>image/gif</Format>
<Format>image/png; mode=8bit</Format>
<Format>application/x-pdf</Format>
<Format>image/svg+xml</Format>
<Format>image/tiff</Format>
<Format>application/vnd.google-earth.kml+xml</Format>
<Format>application/vnd.google-earth.kmz</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Post>
</HTTP>
</DCPType>
</GetMap>
<GetFeatureInfo>
<Format>text/plain</Format>
<Format>application/vnd.ogc.gml</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Post>
</HTTP>
</DCPType>
</GetFeatureInfo>
<DescribeLayer>
<Format>text/xml</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Post>
</HTTP>
</DCPType>
</DescribeLayer>
<GetLegendGraphic>
<Format>image/png</Format>
<Format>image/jpeg</Format>
<Format>image/gif</Format>
<Format>image/png; mode=8bit</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Post>
</HTTP>
</DCPType>
</GetLegendGraphic>
<GetStyles>
<Format>text/xml</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/cgi-bin/mapserv?map=/Users/macbook/Sites/mapserver/paris/wms/postgis.map&"/></Post>
</HTTP>
</DCPType>
</GetStyles>
</Request>
<Exception>
<Format>application/vnd.ogc.se_xml</Format>
<Format>application/vnd.ogc.se_inimage</Format>
<Format>application/vnd.ogc.se_blank</Format>
</Exception>
<VendorSpecificCapabilities />
<UserDefinedSymbolization SupportSLD="1" UserLayer="0" UserStyle="1" RemoteWFS="0"/>
<Layer>
<Name>Vasserot</Name>
<Title>WMS Demo Server</Title>
<Abstract>Vasserot</Abstract>
<SRS>epsg:27561</SRS>
<LatLonBoundingBox minx="2.28633" miny="48.8297" maxx="2.40317" maxy="48.8846" />
<BoundingBox SRS="EPSG:27561"
minx="596320" miny="125470" maxx="604889" maxy="131579" />
<Layer queryable="0" opaque="0" cascaded="0">
<Name>plan</Name>
<Title>plan</Title>
<SRS>epsg:27561</SRS>
<LatLonBoundingBox minx="-180" miny="-67.866" maxx="180" maxy="-36.074" />
<BoundingBox SRS="epsg:27561"
minx="-2.5e+07" miny="-2.5e+07" maxx="2.5e+07" maxy="2.5e+07" />
</Layer>
</Layer>
</Capability>
</WMT_MS_Capabilities>Merci d'avance pour votre aide.
PS : J'utilise la version 6 de MapServer.
Hors ligne
#2 Fri 08 July 2011 19:39
- Léo D.
- Juste Inscrit !
- Date d'inscription: 8 Jul 2011
- Messages: 2
Re: Problème d'encodage d'url avec MapServer, WMS et OpenLayers
Je me permets de faire un double-post, car je viens de résoudre mon problème !
Il semblerait que cela venait d'une erreur de syntaxe dans les options de la fonction OpenLays.Map :
Il fallait écrire :
Code:
projection: "EPSG:27561"
Et non pas :
Code:
displayProjection:new OpenLayers.Projection("EPSG:27561")Désolé d'avoir, du coup, créé un sujet pour rien… Peut-être que mon cas servira à quelqu'un.
Hors ligne
Pages: 1
- Sujet précédent - Problème d'encodage d'url avec MapServer, WMS et OpenLayers - Sujet suivant


