[mapserver-users] run-time substitution
Eva Jelínková
evka.jelinkova at gmail.com
Mon Jul 11 08:39:46 PDT 2016
Dear mapserv people,
does anybody has an experience with runtime substitution in MAP->WEB:
METADATA section of mapfile (MapServer 7)?
http://mapserver.org/cgi/runsub.html#parameters-supported
I am trying to substitute part of 'wms_onlineresource' value, using default
value in VALIDATION. GetCapabilities request gives me string with
%name_of_parameter% in the URL.
Other substitutions (in LAYER: CONNECTION) work well.
My *mapfile* looks like this:
MAP
NAME test
SHAPEPATH '/path/to/data/'
STATUS ON
SIZE 600 600
EXTENT -12370335 5011146 -11573462 5632806
UNITS METERS
IMAGECOLOR 255 255 255
OUTPUTFORMAT
NAME 'png'
DRIVER AGG/PNG
MIMETYPE 'image/png'
IMAGEMODE RGB
EXTENSION 'png'
END
IMAGETYPE png
PROJECTION
'init=epsg:3857'
END
WEB
VALIDATION
'ma_name' '[a-z\-]+'
'db_name' '[a-z\_]+'
'db_schema' '[a-z\_]+'
'db_user' '[a-zA-Z\-]+'
'db_pw' '[a-zA-Z\-]+'
'default_db_user' 'user'
'default_db_pw' 'pw'
'default_ma_name' 'test-ma'
'default_db_name' 'test_ma'
'default_db_schema' 'test'
END
METADATA
'wms_title' 'MapServer WMS'
'wms_abstract' 'test'
'wms_srs' 'EPSG:3857 EPSG:900913 EPSG:4326'
'wms_encoding' 'UTF-8'
'wms_onlineresource' 'http://url/cgi-bin/gp_%ma_name%_com_wms?'
'wms_enable_request' '*'
END
END
LAYER
NAME 'polygons'
CONNECTIONTYPE postgis
CONNECTION 'user=%db_user% password=%db_pw% dbname=%db_name%
host=db.server.url'
DATA 'geom FROM %db_schema%.polygons'
STATUS ON
TYPE POLYGON
METADATA
'wms_title' 'polygons'
END
PROJECTION
'init=epsg:3857'
END
PROCESSING 'LABEL_NO_CLIP=ON'
LABELITEM 'id'
CLASS
LABEL
TYPE truetype
FONT ubuntu
ANTIALIAS false
SIZE 10
COLOR 10 10 10
OFFSET 2 -3
BUFFER 5
END
END
END
END
*GetCapabilities* request gives me:
<?xml version='1.0' encoding="UTF-8" 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 7.0.1 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML
SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO
SUPPORTS=SVG_SYMBOLS SUPPORTS=RSVG 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 WMS</Title>
<Abstract>test</Abstract>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="
http://url/cgi-bin/gp_%ma_name%_com_wms?"/>
<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://url/cgi-bin/gp_%ma_name%_com_wms?"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="http://url/cgi-bin/gp_%ma_name%_com_wms?"/></Post>
</HTTP>
</DCPType>
</GetCapabilities>
...
If I add my *parameter to URL request*:
http://url/cgi-bin/mapserv7.fcgi?MAP=/path/to/mapfile.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities&ma_name=testing
I get:
"msWMSDispatch(): WMS server error. Incomplete or unsupported WMS request"
If anyone has ever tried to use this substitution, please, let me know.
Thanks,
Eva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20160711/4b77d4b5/attachment.htm>
More information about the MapServer-users
mailing list