Opened 16 years ago

Closed 14 years ago

#2578 closed defect (fixed)

MapServer computes WMS LatLonBoundingBox in the GCS of data's coordinate system

Reported by: guillaume Owned by: warmerdam
Priority: high Milestone: 5.6.6 release
Component: WMS Server Version: svn-trunk (development)
Severity: major Keywords: wms 1.3.0
Cc: assefa, tomkralidis, sdlime

Description

When requesting a WMS GetCapabilities, the LatLonBoundingBox value is computed in data's geographic coordinate system, without tranforming them to WGS84. As a result, the bounding box is wrong when the data projection doesn't use Greenwich for prime meridian. As Frank Warmerdam suggested, msOWSPrintLatLonBoundingBox() just passes NULL for the destination coordinate system, and msProjectPoint() just treats this as a special case to use the lat/long coordinate system (GCS) associated with the projected coordinate system.

Attachments (1)

wms_1.3.0.patch (448 bytes ) - added by guillaume 14 years ago.
patch for WMS 1.3.0 to display correct GeoBBOX when prime meridian is not Greenwich

Download all attachments as: .zip

Change History (15)

comment:1 by warmerdam, 16 years ago

Cc: warmerdam assefa added; warmerdam@… removed
Keywords: wms wcs added

I believe this problem affects at least WMS and WCS. Possibly also WFS and SOS.

I wouldn't mind taking a crack at resolving it, but would want help testing the effects in the different modes.

comment:2 by tomkralidis, 16 years ago

Cc: tomkralidis added

comment:3 by pinpin, 15 years ago

I confirm this problem. If I compute a map on a french departement, the getMap result of QGIS or uDIG is shift of two degrees. So I have got a blank map instead of my departement.

Qgis or uDIG calculate a wrong BoundingBox from the LatLonBoundingBox value line of the GetCapabilities.

Here is my GetCapabilities :

<Layer queryable="1" opaque="0" cascaded="0">
<Name>communes_31</Name>
<Title>communes_31</Title>
<Abstract/>
<SRS>IGNF:LAMBE</SRS>
<SRS>EPSG:4326</SRS>
<SRS>epsg:27582</SRS>
<LatLonBoundingBox minx="-1.92546" miny="42.6858" maxx="-0.284421" maxy="43.9238"/>
−
<Style>
<Name>default</Name>
<Title>default</Title>
−
<LegendURL width="129" height="23">
<Format>image/png</Format>
<OnlineResource xlink:type="simple" xlink:href="http://10.202.25.57/cgi-bin/mapserv?map=/var/www/donnees_mapserver/stock_mapfiles/25.map&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=communes_31&format=image/png&STYLE=default"/>
</LegendURL>
</Style>
</Layer>

LatLonBoundingBox values should be : minx="0.08" miny="42.6858" maxx="2.10" maxy="43.9238"

comment:4 by sdlime, 15 years ago

Cc: sdlime added; warmerdam removed
Owner: changed from sdlime to warmerdam

comment:5 by landry, 15 years ago

I have this problem too, using mapserver 5.2.1 from debian backports.

With the given chunk of mapfile :

        PROJECTION
                "init=epsg:27582"
        END
        EXTENT 550000 1950000 800000 2220000

        WEB
                METADATA

                        "wms_title" "WMS"
                        "wms_onlineresource" "http://192.168.1.27:81/cgi-bin/mapserv?map=/var/www/data_carto/mapfile/scan25.map&"
                END
        END

I'm getting this xml output when QGIS queries the layer :

 <Layer>
    <Name>WMS</Name>
    <Title>WMS</Title>
    <SRS>EPSG:27582</SRS>
    <LatLonBoundingBox minx="-0.657196" miny="44.5222" maxx="2.62786" maxy="46.9799" />
    <BoundingBox SRS="EPSG:27582"
                minx="550000" miny="1.95e+06" maxx="800000" maxy="2.22e+06" />
  </Layer>

QGIS uses LatLonBoundingBox as default BBOX, and then requests GetMap with BBOX=361989.801731,1949734.943716,522234.843217,2224341.557223

LatLonBoundingBox should be, according to cs2cs :

cs2cs +init=epsg:27582 +to +init=epsg:4236
550000 1950000
1d42'51.836"E	44d32'49.713"N 445.768
800000 2220000
4d58'15.449"E	46d56'50.615"N 453.621

Strangely, using MapInfo or ArcGis or OpenLayers as client works fine..i suppose they use BoundingBox value, so i don't know if Mapserver or QGIS is to blame here. Any idea where to poke at source to fix that, if it has to be fixed in Mapserver ?

comment:6 by warmerdam, 15 years ago

Milestone: 5.6 release
Status: newassigned

I think the following patch would be appropriate, but I have not tested it:

Index: mapows.c
===================================================================
--- mapows.c    (revision 9505)
+++ mapows.c    (working copy)
@@ -1213,7 +1213,11 @@
 
   if (nService == OWS_WMS) { /* always project to lat long */
     if (srcproj->numargs > 0 && !pj_is_latlong(srcproj->proj)) {
-      msProjectRect(srcproj, NULL, &ext);
+        projectionObj wgs84;
+        msInitProjection(&wgs84);
+        msLoadProjectionString(&wgs84, "+proj=longlat +datum=WGS84");
+        msProjectRect(srcproj, &wgs84, &ext);
+        msFreeProjection(&wgs84);
     }
   }
 

This only affects WMS. If there are lat/long bounding boxes for WCS they must be generated somewhere else. The process for WFS seems somewhat different.

If you can test the patch, we could consider whether to apply it before 5.6 release.

comment:7 by landry, 15 years ago

Many thanks, it definitely fixes the issue with QGIS, and ArcGis still shows the wms fine. I backported the patch on my 5.2.1 version, and now i get the correct LatLonBoundingBox :

<Name>WMS</Name>
<Title>WMS</Title>
<SRS>EPSG:27582</SRS>
<LatLonBoundingBox minx="1.67931" miny="44.5222" maxx="4.9645" maxy="46.9799" />
<BoundingBox SRS="EPSG:27582" minx="550000" miny="1.95e+06" maxx="800000" maxy="2.22e+06" />

comment:8 by warmerdam, 15 years ago

Resolution: fixed
Status: assignedclosed

I have committed the patch in trunk (r9512).

comment:9 by guillaume, 14 years ago

Component: MapServer C LibraryWMS Server
Keywords: 1.3.0 added; wcs removed
Milestone: 5.6 release5.6.6 release
Priority: normalhigh
Severity: normalmajor

The problem still occurs with WMS 1.3.0. Here is a patch :

--- mapows.c (revision new) +++ mapows.c (working copy) @@ -1180,7 +1180,11 @@

/* always project to lat long */ if (srcproj->numargs > 0 && !pj_is_latlong(srcproj->proj)) {

  • msProjectRect(srcproj, NULL, &ext);

+ projectionObj wgs84; + msInitProjection(&wgs84); + msLoadProjectionString(&wgs84, "+proj=lonlat +datum=WGS84"); + msProjectRect(srcproj, &wgs84, &ext); + msFreeProjection(&wgs84);

}

comment:10 by guillaume, 14 years ago

Copy and paste from vi messed up the patch here. Please see attachment instead.

comment:11 by warmerdam, 14 years ago

Please use +proj=longlat instead of +proj=lonlat

by guillaume, 14 years ago

Attachment: wms_1.3.0.patch added

patch for WMS 1.3.0 to display correct GeoBBOX when prime meridian is not Greenwich

comment:12 by guillaume, 14 years ago

fixed in last attachment. Thanks for pointing out the typo Frank.

comment:13 by rouault, 14 years ago

Resolution: fixed
Status: closedreopened

comment:14 by assefa, 14 years ago

Resolution: fixed
Status: reopenedclosed

committed in r10641 in trunk and r10642 in 5.6 branch. Thanks.

Note: See TracTickets for help on using tickets.