[mapserver-users] Dynamic WMS Service - Projections problem?
myOpenLayersUName
joanne.mcgraw at SYMPATICO.CA
Tue Feb 8 09:54:49 PST 2011
First, the background...
I have a WMS Service that has an "empty" point layer in it. I use it to
display labels at dynamically generated coordinates by passing x,y within
the request. For example:
http://<domain>/ogc/mapserv?map=/path/fenceLabelWms_en.map&map.layer[fencelabel]=FEATURE
POINTS -105.5620661354989 51.14394472618872 END TEXT "Fence 1"
END&map.layer[fencelabel].class[0]=COLOR 255 0 0
END&map.layer[fencelabel].class[0]=LABEL COLOR 255 0 0 SIZE 10 POSITION UR
END&LAYERS=fencelabel&mode=map
The entire map file is as follows:
MAP
NAME "fenceLabelWms_en"
FONTSET "../../../mapserv/etc/fonts.txt"
SYMBOLSET "../../../mapserv/etc/symbols.sym"
SIZE 400 300
IMAGETYPE PNG
IMAGECOLOR 255 255 255
RESOLUTION 96
EXTENT -141.5 41.5 -51.5 83.5 # all of Canada
UNITS METERS
PROJECTION
"init=epsg:4269" # lat/long
END
WEB
METADATA
"wms_srs" "EPSG:42304"
END
END
OUTPUTFORMAT
NAME png
DRIVER 'GD/PNG'
MIMETYPE 'image/png'
IMAGEMODE PC256 #RGB
FORMATOPTION "INTERLACE=OFF"
EXTENSION 'png'
TRANSPARENT ON
END
LAYER
NAME "fencelabel"
STATUS ON
TYPE point
CLASS
SIZE 0
COLOR 0 0 0
LABEL
TYPE truetype
FONT verdana
ANTIALIAS false
END
END
END
END
A number of applications use this WMS and each has its own projection but,
as in the request above, all pass the x,y as lat/long (EPSG:4269). The MAP
METADATA's "wms_srs" lists the supported projections (for the purposes of
this example, I'm simplifying by only including EPSG:42304).
So, this allows me to provide the point coordinates in lat/long, but display
them using the projection from the application itself. For example:
http://<domain>/ogc/mapserv?map=/path/fenceLabelWms_en.map&map.layer[fencelabel]=FEATURE
POINTS -105.5620661354989 51.14394472618872 END TEXT 'Fence 1'
END&map.layer[fencelabel].class[0]=COLOR 255 0 0
END&map.layer[fencelabel].class[0]=LABEL COLOR 255 0 0 SIZE 10 POSITION UR
END&LAYERS=fencelabel&FORMAT=image/png&SRS=EPSG:42304&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&BBOX=-2903297.000,-789911.0000,3431059.000,3959683.000&WIDTH=1219&HEIGHT=601
Knowing this, I can define this "dynamic" layer within a WMC <Layer> tag and
load it into an OpenLayers Map (whose projection is set to EPSG:42304 and
extents encompass all of Canada). The WMC definition for the above layer is
as follows (we use a batch script to set the path to the MapServer
executable and MAP file, "fenceLabelWms_en"):
<Layer queryable="0" hidden="0">
<Server service="OGC:WMS" version="1.1.1">
<OnlineResource xlink:type="simple"
xlink:href="http://<domain>/ogc/fenceLabelWms_en?map.layer[fencelabel]=FEATURE%20POINTS%20-105.5620661354989%2051.14394472618872%20END%20TEXT%20'Fence%201'%20END&map.layer[fencelabel].class[0]=COLOR%20255%20105%200%20END&map.layer[fencelabel].class[0]=LABEL%20COLOR%20255%20105%200%20SIZE%2010%20POSITION%20LR%20END"/>
</Server>
<Name>fencelabel</Name>
<Title>Fence 1</Title>
<SRS>EPSG:42304</SRS>
<FormatList>
<Format current="1">image/png</Format>
</FormatList>
<Extension>
<ol:maxExtent minx="-2903297.000" miny="-789911.0000"
maxx="3431059.000" maxy="3959683.000"/>
<ol:transparent>true</ol:transparent>
<ol:numZoomLevels>5</ol:numZoomLevels>
<ol:units>m</ol:units>
<ol:isBaseLayer>false</ol:isBaseLayer>
<ol:displayInLayerSwitcher>false</ol:displayInLayerSwitcher>
<ol:singleTile>true</ol:singleTile>
</Extension>
</Layer>
Okay, everything works fine up to this point. The fence label WMS is
displayed in the OpenLayers Map correctly in relation to the other layers it
contains, all of which have projections of EPSG:42304.
Now, the problem ...
I’d like to print the image displayed to the user. To do this, I have
another "empty" MAP file that I use to print the WMC; the same WMC I loaded
into OpenLayers. The entire contents of this MAP file are:
MAP
NAME "wmsContextServer"
FONTSET "../../../mapserv/etc/fonts.txt"
SYMBOLSET "../../../mapserv/etc/symbols.sym"
SIZE 400 300
STATUS ON
IMAGETYPE PNG
IMAGECOLOR 255 255 255
EXTENT -2338951 -800000 3008692 3900000
UNITS METERS
CONFIG "CGI_CONTEXT_URL" "1"
PROJECTION
"init=epsg:42304"
END
RESOLUTION 96
REFERENCE
# Parameter settings NOT to change
STATUS ON
COLOR -1 -1 -1
OUTLINECOLOR 255 0 0
# Parameter settings that will change if you replace the default
'refmap.png'
IMAGE "../htdocs/images/refmap.png"
SIZE 100 74
EXTENT -2.2e+006 -712631 3.0728e+006 3.84e+006
END # REFERENCE
SCALEBAR
STATUS EMBED
INTERVALS 1
POSITION LL
TRANSPARENT true
UNITS kilometers
STYLE 1
SIZE 100 7
LABEL
SIZE small
END
END
WEB
INCLUDE "../../../mapserv/conf/imagepath.inc.map"
METADATA
# Used for App Page Title
"wms_title" "WMC Context Client"
"wms_connectiontimeout" "60"
END
END
OUTPUTFORMAT
NAME png
DRIVER 'GD/PNG'
MIMETYPE 'image/png'
IMAGEMODE RGB
FORMATOPTION "INTERLACE=OFF"
EXTENSION 'png'
#TRANSPARENT ON
END
OUTPUTFORMAT
NAME gif
DRIVER 'GD/GIF'
MIMETYPE 'image/gif'
IMAGEMODE RGB
FORMATOPTION "INTERLACE=OFF"
EXTENSION 'gif'
END
END
Unfortunately, the "dynamic" WMS layer doesn't appear in the output image. I
can use the following URL to get an image of all the other layers in the WMC
successfully, but the fence label is not shown and there is no error
message:
http://<domain>/ogc/mapserv?map=/path/wmsContextServer.map&mode=map&context=http://<domain>/contexts/WMCwFenceLabels.xml&layers=all
I'm guessing MapServer is getting a blank image when it's assembling the
layers for the output image and I'm further guessing that this is the result
of the projections somehow getting out of whack somewhere along the line.
I'm thinking that the point is being evaluated as not actually existing
within the extents of the output image being generated, perhaps? But, I
can't guess why this would be the case. There is no question that it does
fall within the extents (as witnessed by loading the same WMC in
OpenLayers).
As it is now, I am completely stuck as to what the problem might be. Can
anyone suggest anything that might help me narrow down exactly what the
problem is or a direction I can investigate further?
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Dynamic-WMS-Service-Projections-problem-tp6004893p6004893.html
Sent from the Mapserver - User mailing list archive at Nabble.com.
More information about the MapServer-users
mailing list