[Mapserver-users] shape bounds for map and layer with different projections
Norman Vine
nhv at cape.com
Thu Aug 14 09:32:47 PDT 2003
Armin Burger writes:
>
> 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 have never found a good solution to this problem for all possible
combinations of projections in any mapping system
What I usually end up doing is creating the new projection parameters
from a 'zoom factor' and the areal size of the pixel at the new center
of interest in the original projection to get the desired areal size of said
pixel in the new projection
I have found this to be a reasonably satisfactory method
even though it requires a 'bit' more computation
HTH
Norman
More information about the MapServer-users
mailing list