[Mapserver-users] shape bounds for map and layer with different projections

Armin Burger armin.burger at libero.it
Thu Aug 14 16:56:12 EDT 2003


Sean,

Thanks for the reply. You're right: the problem lies not in the
definition of the projection via epsg code. I thought so because the
shape rectangle extent (minx/miny/maxx/maxy) remained the same after
re-projection when defining the projections like that.

I now found the reason for this behaviour: I tested it with a point
layer. For points the '$shape->bounds' function produces a rectangle
where minx=maxx and miny=maxy. Therefore the 'project(inPJ, outPJ)'
method did not re-projection this 'rectangle' (which has actually only 1
dimension). When setting a buffer to the min/max values everything worked
ok.

Armin


> You _can_ construct a projectionObj from an "init=epsg:xxxx" string.
> In the code below I create a rectObj and then project it from map
> projection to an arbitrary EPSG projection.  This is using the 4.0
> MapScript and should be equally applicable to Perl.

> Python 2.1.3 (#18, Jun 24 2003, 18:02:42)
> [GCC 3.1 20020420 (prerelease)] on darwin6
> Type "copyright", "credits" or "license" for more information.
>  >>> from mapscript import *
>  >>> mapobj = mapObj('/Users/sean/Projects/ZMapServer/demo/demo.map')
>  >>> e = mapobj.extent
>  >>> e.minx, e.miny, e.maxx, e.maxy
> (388108.0, 5203121.0, 500896.0, 5315909.0)
>  >>> mapobj.getProjection()
> 'init=epsg:26915'
>  >>> prj_map = projectionObj(mapobj.getProjection())
>  >>> prj_nad83 = projectionObj("init=epsg:4269")
>  >>> f = rectObj()
>  >>> f.minx = e.minx
>  >>> f.minx, f.miny, f.maxx, f.maxy = e.minx, e.miny, e.maxx, e.maxy
>  >>> f.project(prj_map, prj_nad83)
> 0
>  >>> e.minx, e.miny, e.maxx, e.maxy
> (388108.0, 5203121.0, 500896.0, 5315909.0)
>  >>> f.minx, f.miny, f.maxx, f.maxy
> (-94.499615104017138, 46.972164652306077, -92.987989369267908,
> 47.996480038279742)

> cheers,
> Sean

> --
> Sean Gillies
> sgillies at frii dot com
> http://www.frii.com/~sgillies





More information about the mapserver-users mailing list