[mapserver-users] Strange coordinates used in GetFeatureInfo request

Daniel Morissette dmorissette at mapgears.com
Sat Jun 23 08:00:31 PDT 2012


I didn't read your whole mail, but short answer is that I suspect you 
are overlooking the fact that in GetFeatureInfo, the X and Y coordinates 
are in pixels within the view of the map (which is 500x500 pixels in 
your example).

So when you write x=0&y=0 that refers to the top-left corner of the map 
view, and not the 0,0 of the SRS coordinate system... which corresponds 
to longitude=-10, and latitude=+10. Actually, the x,y value is 
translated to be the center of the top-left pixel (and not its top-left 
boundary), which explains why you get lon,lat=9.98,9.98 in the query.

Daniel

On 12-06-22 5:40 PM, Anzel, Phil - NRCS, Fort Collins, CO wrote:
> All,
>
> Does "GetFeatureInfo" have a coordinate translation problem?
>
> Consider the WMS request shown here (ignore line wrapping):
>    http://localhost/mapserver/mapserv.exe
>      ?map=m01.map
>      &SERVICE=WMS
>      &VERSION=1.1.1
>      &REQUEST=GetFeatureInfo
>      &LAYERS=External
>      &QUERY_LAYERS=External
>      &INFO_FORMAT=text/plain
>      &x=0.0&y=0.0
>      &SRS=EPSG:4326
>      &BBOX=-10,-10,10,10
>      &width=500&height=500
>
> In the mapfile below, all coordinate system references are to "4326". Forcing an error in the DATA statement makes me think the (0,0) coordinate pair is mistranslated, as shown by the message below which includes:
>    shape_BOGUS.STIntersects(
>             geometry::STGeomFromText('POINT(-9.98 9.98)',4326)) = 1
>
> Is there a problem with my request or with my mapfile?
>
> Following is the mapfile and some experiments that I performed. I'm using MapServer 6.1-DEV with Sql Server 2008 under Windows XP.
>
> The relevant mapfile is defined as:
>
> map
>    name m01
>    status on
>    size 500 500
>    extent -20 -20 20 20
>    units dd
>    imagecolor 255 255 255
>    projection "init=epsg:4326" end
>
>    web
>      imagepath "c:\ms4w\tmp\ms_tmp"
>      imageurl "/ms_tmp/"
>      metadata
>        "wms_title"             "test-title"
>        "wms_extent"            "-180 -90 180 90"
>        "wms_srs"               "EPSG:4326"
>        "ows_enable_request"    "GetCapabilities GetMap GetFeature GetFeatureInfo"
>      end
>    end
>    layer
>      name "External"
>      type polygon
>      status on
>      metadata
>        "wms_title"             "External"
>        "wms_extent"            "-180 -90 180 90"
>        "wms_srs"               "EPSG:4326"
>        "ows_include_items"     "all"
>        "wms_include_items"     "all"
>        "gml_include_items"     "all"
>        "gml_geometries"        "multiPolygon"
>        "gml_multiPolygon_type" "multipolygon"
>      end
>      dump true
>      header "C:\ms4w\Apache\cgi-bin\m01_header.htm"
>      template "C:\ms4w\Apache\cgi-bin\m01_template.html"
>      footer "C:\ms4w\Apache\cgi-bin\m01_footer.html"
>      projection "init=epsg:4326" end
>      units dd
>      # ExternalData table created and populated in Sql Server 2008 with:
>      # create table ExternalData
>      #   (ID varchar(10) primary key, shape Geometry not null);
>      # insert into ExternalData (id, shape) values ('x102',
>      #   geometry::STGeomFromText('polygon((-20 -20,-20 20,20 20,20 -20,-20 -20))', 4326))
>      connection "server=...;database=test;uid=...;pwd=..."
>      connectiontype plugin
>      plugin "C:/ms4w/Apache/specialplugins/msplugin_mssql2008.dll"
>      data "shape from dbo.ExternalData using unique ID using srid=4326"
>      labelitem "ID"
>      class
>        name "ExternalClass"
>        style color 255 0 0 outlinecolor 0 255 0 end
>        label position auto size small color 0 0 0 end
>      end
>    end
> end
>
> Note that the WMS request, the MAP and the LAYER are all defined with the "4326" projection.
>
> If I change the DATA statement to force an error,
>      data "shape_BOGUS from dbo.ExternalData using unique ID using srid=4326"
> the error returned shows:
>        msMSSQL2008LayerGetShape(): Query error.
>        Error executing MSSQL2008 SQL statement:
>          SELECT
>             convert(varchar(max), id),
>             shape_BOGUS.STAsBinary(),
>             convert(varchar(36), ID)
>          from dbo.ExternalData
>          WHERE shape_BOGUS.STIntersects(
>             geometry::STGeomFromText('POINT(-9.98 9.98)',4326)) = 1
>
> Please note that the POINT location should be (0,0). Why isn't it?
>
> A similar problem occurs if the feature is defined "inline" as described below.
>
> Some additional details:
>
> 1. If I remove the "_BOGUS", a result is returned. Therefore I believe that the mapfile is well-formed.
>
> 2. With "_BOGUS" removed, and the polygon redefined in the database as POLYGON((-5 -5,-5 5,5 5,5 -5,-5 -5)), no result is returned. Therefore I believe that the bad coordinates in the query are being used.
>
> 3. If I define and use an "Internal" layer:
>    layer
>      name "Internal"
>      type polygon
>      status on
>      metadata
>        "wms_title"             "Internal"
>        "wms_extent"            "-180 -90 180 90"
>        "wms_srs"               "EPSG:4326"
>        "ows_include_items"     "all"
>        "wms_include_items"     "all"
>        "gml_include_items"     "all"
>        "gml_geometries"        "multiPolygon"
>        "gml_multiPolygon_type" "multipolygon"
>      end
>      dump true
>      header "C:\ms4w\Apache\cgi-bin\m01_header.htm"
>      template "C:\ms4w\Apache\cgi-bin\m01_template.html"
>      footer "C:\ms4w\Apache\cgi-bin\m01_footer.html"
>      projection "init=epsg:4326" end
>      units dd
>      feature
>        wkt   "polygon((-20 -20,-20 20,20 20,20 -20,-20 -20))"
>        items "x101"
>      end
>      processing "items=ID"
>      labelitem "ID"
>      class
>        name "InternalClass"
>        style color 255 0 0 outlinecolor 0 255 0 end
>        label position auto size small color 0 0 0 end
>      end
>    end
> then the query returns a result. Therefore I believe that the mapfile is well-formed.
>
> 4. If I change the feature to "POLYGON((-5 -5,-5 5,5 5,5 -5,-5 -5))", no result is returned by the query. Therefore I believe that the bad coordinate problem occurs not only for Sal Server but for an inline feature as well.
>
> 5. GetMap shows the expected polygons for both the Internal and External layers when specifying "&x=0&y=0" and using a feature defined as "POLYGON((-5 -5,-5 5,5 5,5 -5,-5 -5)). Therefore I believe that the problem is specific to GetFeatureInfo.
>
> - Phil Anzel
>         Contractor for USDA/NRCS
>         ITC Web Soil Survey Team Member
>
> This electronic message contains information generated by the USDA solely for the intended recipients.  Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties.  If you believe you have received this message in error, please notify the sender and delete the email immediately.
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>


-- 
Daniel Morissette
http://www.mapgears.com/
Provider of Professional MapServer Support since 2000





More information about the mapserver-users mailing list