Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I use mapserver with MS SERVER 2008. The problem with the correctly computing layer extend of Map server.

If map file like this

 MAP
      NAME "test map"
      IMAGETYPE      GIF
      EXTENT         19.63 41.10 180.00 81.6
      SIZE           1900 800
      IMAGECOLOR     255 255 255
      CONFIG "PROJ_LIB" "C:\inetpub\wwwroot\MapServ\proj\nad" 

    WEB
    IMAGEPATH "img_tmp/"
    IMAGEURL "img_tmp/"
    METADATA
        "wms_enable_request" "*"
        "wms_title" "test"
        "wms_onlineresource"  "******"
        "wms_srs"  "epsg:4326"
        "wms_abstract" "test"
        "wms_encoding" "windows-1251"
        "wms_extent" "19.63 41.10 180.00 81.6"
    END
END

PROJECTION
    "init=epsg:4326"
END

LAYER
    TEMPLATE "template/template.html"
    NAME "okato"
    METADATA
        "wms_title" "OKATO"
        "wms_srs"  "epsg:4326"
        "wms_include_items" "all"
        "wms_abstract" "test"
    END
    TYPE POLYGON
    STATUS ON
  ####
    CONNECTIONTYPE PLUGIN
    PLUGIN "C:/inetpub/wwwroot/MapServ/specialplugins/msplugin_mssql2008.dll"
    CONNECTION "Server=... ; uid=... ; pwd=... ; Database=... ; Integrated Security=true"
    DATA "geom from dbo.okato USING UNIQUE ID USING SRID=4326"
  ####
    PROJECTION
        "init=epsg:4326"
    END

Map server generate XML with the following BoundingBox of layer:

<CRS>epsg:4326</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-3.40282e+038</westBoundLongitude>
<eastBoundLongitude>3.40282e+038</eastBoundLongitude>
<southBoundLatitude>-3.40282e+038</southBoundLatitude>
<northBoundLatitude>3.40282e+038</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="epsg:4326" minx="-3.40282e+038" miny="-3.40282e+038" maxx="3.40282e+038" maxy="3.40282e+038"/>

If I add extent layer like this:

LAYER
...
    EXTENT         19.63 41.10 180.00 81.6
...
END

or

LAYER
...
    METADATA
        ......
        "wms_extent" "19.63 41.10 180.00 81.6"
    END
...
END

It works correctly

<CRS>epsg:4326</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>19.63</westBoundLongitude>
<eastBoundLongitude>180</eastBoundLongitude>
<southBoundLatitude>41.1</southBoundLatitude>
<northBoundLatitude>81.6</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="epsg:4326" minx="41.1" miny="19.63" maxx="81.6" maxy="180"/>

How to make that mapserver dynamically to calculate the extent (and BBOX) of layer, and not add it manually?

share|improve this question
    
I also having problems with extent calculation with postgis data source too. Using manual extent maybe a problem with editable layers that change often. –  cavila Apr 6 at 0:20
add comment

2 Answers

up vote 1 down vote accepted

Mapserver needs the explained below to work correctly with SQL Server 2008.

This is the code from MapServer. FLT_MAX is const and FLT_MAX=3.40282e+038

/* Get the layer extent as specified in the mapfile or a largest area */
/* covering all features */
int msMSSQL2008LayerGetExtent(layerObj *layer, rectObj *extent)
{
  if(layer->debug) {
    msDebug("msMSSQL2008LayerGetExtent called\n");
  }

  if (layer->extent.minx == -1.0 && layer->extent.miny == -1.0 &&
      layer->extent.maxx == -1.0 && layer->extent.maxy == -1.0) {
    extent->minx = extent->miny = -1.0 * FLT_MAX;
    extent->maxx = extent->maxy = FLT_MAX;
  } else {
    extent->minx = layer->extent.minx;
    extent->miny = layer->extent.miny;
    extent->maxx = layer->extent.maxx;
    extent->maxy = layer->extent.maxy;
  }

  return MS_SUCCESS;
}

That's why MapServer generates XML with the following BoundingBox of layer if the extent has not been added manually

<EX_GeographicBoundingBox>
<westBoundLongitude>-3.40282e+038</westBoundLongitude>
<eastBoundLongitude>3.40282e+038</eastBoundLongitude>
<southBoundLatitude>-3.40282e+038</southBoundLatitude>
<northBoundLatitude>3.40282e+038</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="epsg:4326" minx="-3.40282e+038" miny="-3.40282e+038" maxx="3.40282e+038" maxy="3.40282e+038"/>
share|improve this answer
add comment

try adding:

UNITS DD

below the EXTENT property of the MAP section. Also try adding EPSG instead of epsg in the WEB section. However the problem can be related to the geography/geometry options provided by SQL server. Please take a look at these links:

http://osgeo-org.1560.x6.nabble.com/Beginning-Mapserver-amp-sql-server-2008-td4259151.html http://www.bostongis.com/PrinterFriendly.aspx?content_name=sql2008_tut01

The first link contains discussion similar to what your issue, please refer to the last post of that link for an explanation. The second link is a tutorial that may help you.

Hope this helps,

share|improve this answer
    
thank you, but it not help (( EXTENT 19.63 41.10 180.00 81.6 UNITS DD SIZE 1900 800 –  Anton Jun 28 '13 at 13:02
    
I edited my post, please take a look at it. –  Gery Jun 28 '13 at 14:08
    
Thank you for your active participation,but it not help too. I understand that discussion concerned the types of geometry. My geometric data is already as type geometry(planar). Incidentally with the same data in postgis or shape everything is working fine... –  Anton Jul 2 '13 at 10:34
    
if it works in postgis, sqlserver is the problem. What kind of error do you get by the way? The "it didn't help" phrase without any further details about the error messages won't help anybody to help you. –  Gery Jul 2 '13 at 12:53
    
Looks like I found what the problem is. See the answer below. –  Anton Jul 3 '13 at 8:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.