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

Armin Burger armin.burger at libero.it
Thu Aug 14 12:38:40 EDT 2003


Hi

I found a problem with map and layer having different projections:

For queries I want to display the result with a link that allows a zoom
to the respective feature in the map. In MapScript I use the function
$shape->bounds
to get the shape extent used for the zoom-to-feature. This works well,
when layers are in the same projection as the map.

If the layer, however, has a different projection, then the shape bounds
are returned in the layer projection, not in the map projection. This
way, you cannot use this extent rectangle to make a zoom in because it
typically is of a completely different dimension compared to the map
projection.

I was thinking of a workaround by re-projecting the shape extent
rectangle. For that I have to get the map projection and apply this
projection to the rectangle. This may work when the projection is defined
explicitely with all parameters (lat_0, lon_0, ellipsoid, etc) but not
when using the 'init=epsg:xxxx' notation. With epsg, the request
$map->getProjection() just retrieves the string 'init=epsg:xxxx'. But to
define a new projection object (ms_newprojectionobj) I have to define the
projection with all the single parameters and not just the epsg.

I hope that I expressed this small 'problem' in  an understandable way

Is there a solution possible to solve that? The best would be to have the
'$shape->bounds' return the extent in map projection. A maybe simpler
solution might be to have the ability to define a projection object via
epsg. Perhaps this would be similar to the 'setWKTProjection()' method
that exists for layers and maps.

Any thoughts about it?

Regards

Armin





More information about the mapserver-users mailing list