Ticket #2578 (closed defect: fixed)

Opened 5 years ago

Last modified 3 years ago

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

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

Change History

Changed 5 years ago by warmerdam

  • 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.

Changed 5 years ago by tomkralidis

  • cc tomkralidis added

Changed 5 years ago by pinpin

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"

Changed 4 years ago by sdlime

  • cc sdlime added; warmerdam removed
  • owner changed from sdlime to warmerdam

Changed 4 years ago by landry

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 ?

Changed 4 years ago by warmerdam

  • status changed from new to assigned
  • milestone set to 5.6 release

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.

Changed 4 years ago by landry

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" />

Changed 4 years ago by warmerdam

  • status changed from assigned to closed
  • resolution set to fixed

I have committed the patch in trunk (r9512).

Changed 3 years ago by guillaume

  • keywords 1.3.0 added; wcs removed
  • priority changed from normal to high
  • component changed from MapServer C Library to WMS Server
  • severity changed from normal to major
  • milestone changed from 5.6 release to 5.6.6 release

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);

}

Changed 3 years ago by guillaume

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

Changed 3 years ago by warmerdam

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

Changed 3 years ago by guillaume

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

Changed 3 years ago by guillaume

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

Changed 3 years ago by rouault

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 3 years ago by assefa

  • status changed from reopened to closed
  • resolution set to fixed

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

Note: See TracTickets for help on using tickets.