Skip to main content
5 of 5
Removed unnecessary information, added code examples to the end of the document.
afaf12
  • 84
  • 2
  • 15

Which projection should I use to get my WMS service to work?


All of my shapefiles have exactly the same WKT. Using http://prj2epsg.org I have verified that EPSG:3059 has the same parameters as WKT definition of my shapefiles, so I'm using 3059 in my mapfile.

I want to know what changes I must make in my mapfile for my WMS service to work.

What I have tried:

  • I thought maybe epsg:3059 is not supported by my mapserver version 6.0.3. I checked file C:\MS4W\ms4w\proj\nad\epsg and 3059 is listed there. Still, I tried to convert the shapefile to different epsg, for example, 4326 and 3857. No success. I also tried setting up the newest stable Mapserver version 6.4.1. No success.

When I send GetCapabilities request...

http://localhost:1025/cgi-bin/mapserv.exe
?map=C:\MS4W\ms4w\Apache\htdocs\gis\mapfile2.map
&SERVICE=WMS&VERSION=1.1.1%20
&REQUEST=GetCapabilities

I get a response XML document with no errors and warnings.


When I send a GetMap request...

http://localhost:1025/cgi-bin/mapserv.exe
?map=C:\MS4W\ms4w\Apache\htdocs\gis\mapfile2.map
&SERVICE=WMS
&VERSION=1.1.1%20
&STYLES=
&REQUEST=GetMap
&LAYERS=lat_rob_region
&SRS=EPSG:3059%20
&BBOX=313187.4,146161.56,766469.92,470367.64
&WIDTH=800
&HEIGHT=600%20
&FORMAT=image/png

I get this message as response:

...
msWMSLoadGetMapParams(): WMS server error. Invalid SRS given : SRS must be valid for all requested layers.
...


If I access mapfile via browser, I can see the layer displayed correctly:

http://localhost:1025/cgi-bin/mapserv.exe?map=C:\MS4W\ms4w\Apache\htdocs\gis\mapfile2.map&layer=lat_rob_region

mapfile2.map:

MAP

    CONFIG "MS_ERRORFILE" "C:/MS4W/ms4w/Apache/htdocs/gis/tmp/log.txt"
    DEBUG 5
    NAME map
    STATUS ON
    SIZE 800 500
    EXTENT 313187.4 146161.56 766469.92 470367.64
    UNITS METERS
    SHAPEPATH "shapefiles3"
    IMAGECOLOR 155 155 155
 
    WEB
        TEMPLATE "MapServerCGI.html"
        IMAGEPATH "C:/MS4W/ms4w/Apache/htdocs/gis/output/"
        IMAGEURL "/gis/output/"
        
        METADATA
            "wms_title"             "MapServer Openlayers testa aplikacija"
            "wms_onlineresource"    "http://localhost:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map"
            "wms_enable_request"    "*"
            "wms_srs"               "EPSG:3059"
            
        END
    END

    PROJECTION
        "init=epsg:3059"
    END
    
# lat_rob_region
    LAYER
        METADATA
            "wms_title"           "lat_rob_region"
            "wms_srs"             "EPSG:3059"
        END
        NAME "lat_rob_region"
        DATA lat_rob_region
        STATUS ON
        TYPE POLYGON
        CLASS
            NAME "lat_rob_region"
            STYLE
                COLOR 0 255 0
            END
        END
    END

END

WKT definition:

PROJCS["GRS_1980_Transverse_Mercator",
GEOGCS["GCS_GRS_1980",
DATUM["D_GRS_1980",
SPHEROID["GRS_1980",6378137,298.257222101]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]],
PROJECTION["Transverse_Mercator"],
PARAMETER["False_Easting",500000],
PARAMETER["False_Northing",-6000000],
PARAMETER["Central_Meridian",24],
PARAMETER["Scale_Factor",0.9996],
PARAMETER["Latitude_Of_Origin",0],
UNIT["Meter",1]]

GetCapabilities.xml looks like this:

<?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.3 (MS4W 3.0.6) OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=CAIRO SUPPORTS=FREETYPE SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE -->

<Service>
  <Name>OGC:WMS</Name>
  <Title>MapServer Openlayers testa aplikacija</Title>
  <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/>
  <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:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></Get>
          <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></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:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></Get>
          <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></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:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></Get>
          <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></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:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></Get>
          <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></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:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></Get>
          <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></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:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></Get>
          <Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;"/></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>karte</Name>
    <Title>MapServer Openlayers testa aplikacija</Title>
    <Abstract>karte</Abstract>
    <SRS>EPSG:3059</SRS>
    <LatLonBoundingBox minx="20.809" miny="55.3892" maxx="28.5475" maxy="58.3742" />
    <BoundingBox SRS="EPSG:3059"
                minx="313187" miny="146162" maxx="766470" maxy="470368" />
    <Layer queryable="0" opaque="0" cascaded="0">
        <Name>lat_rob_region</Name>
        <Title>lat_rob_region</Title>
        <SRS>EPSG:3059</SRS>
        <LatLonBoundingBox minx="20.829" miny="55.6313" maxx="28.4458" maxy="58.0913" />
        <BoundingBox SRS="EPSG:3059"
                    minx="312878" miny="172940" maxx="762571" maxy="438874" />
        <Style>
          <Name>default</Name>
          <Title>default</Title>
          <LegendURL width="119" height="21">
             <Format>image/png</Format>
             <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://localhost:1025/cgi-bin/mapserv.exe?map=C:\MS4W/ms4w/Apache/htdocs/gis/mapfile2.map&amp;version=1.1.1&amp;service=WMS&amp;request=GetLegendGraphic&amp;layer=lat_rob_region&amp;format=image/png&amp;STYLE=default"/>
          </LegendURL>
        </Style>
    </Layer>
  </Layer>
</Capability>
</WMT_MS_Capabilities>
afaf12
  • 84
  • 2
  • 15