[mapserver-users] MapServer 4.8.3: MapScript setProjection
Daniel Morissette
dmorissette at mapgears.com
Thu Mar 27 11:37:05 PDT 2008
Simon Greig wrote:
>
> If we ask for a large bounding box with a 300x300 PNG image then we get
> this error:
>
> "Layer must have an EPSG or AUTO projection code (in its PROJECTION
> object or wms_srs metadata)"
>
>
Sounds like you may have a layer which uses CONNECTIONTYPE WMS. This is
a layer that is actually a connection to a remote WMS service, and one
of the things MapServer needs to know in order to build a succesful
GetMap request to that remote server is the SRS supported by that server.
The simple fix should be to add the following metadata entry in that layer:
LAYER
...
METADATA
"wms_srs" "EPSG:27700"
...
END
...
END
There is no way around using EPSG codes with WMS connections... you have
to use them, that's part of the protocol.
Also, your use of WKT projections instead of EPSG codes for the
top-level PROJECTION in the mapfile is probably going to defeat
MapServer's ability to detect that the layer projection and the oputput
map projection are the same and will probably result in the on-the-fly
reprojection code kicking in for that WMS layer and causing a
performance hit.
Since you are using WMS services in some of your layers then you may be
better use an "init=epsg:27700" definition for the top-level projection
block in your mapfile (and move that definition to the top of the epsg
file to reduce the performance hit). This way MapServer will detect that
the is in the same projection as the output map and no reprojection of
the WMS GetMap image will happen.
You also wrote that you set a projection on all your layers. This may
not be necessary if the data in all layers is already in the same
projection as the output map, and actually, you are better not set a
projection on your layers unless you really need one, otherwise the
reprojection code may kick in to reproject the data in all layers from
the WKT projection to EPSG:27700 which are really the same things and
don't require reprojection.
The reprojection of layer data happens only if (1) the map has a
projection set and (2) the layer has a projection set and (3) the two
projection definitions are not identical. The test to detect identical
projections if fairly simplistic and will be unable to detect that your
WKT definition is identical to EPSG:27700 ... that's why mixing both
definition types will defeat MapServer and result in unnecessary
reprojection of layer data.
I hope that makes some sense and doesn't just add to the confusion...
Daniel
--
Daniel Morissette
http://www.mapgears.com/
More information about the MapServer-users
mailing list