[mapserver-users] Mapscript / Projection Question

Stephen Lime steve.lime at dnr.state.mn.us
Fri Oct 12 12:37:35 EDT 2001


I like it when you figure it out yourself. You are correct though, projections
and objects are independant. It's up to you to make sure you've got things
in order. Internally at feature inherits it's projection from it's parent layer
and if that's not defined then the overall map projection. You can access
and set those projections as well from MapScript.

Steve

Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> Paul Ramsey <pramsey at refractions.net> 10/11/01 11:31AM >>>

In answer to my question, I have found that when using perl mapscript
the internal projection and extent seem pretty independant. all that
setProjection() does is change the projection object, it does not alter
any of the associated info, like the extent, to match the new
projection. So, the trick is to always ensure that any extent you set is
in the same projection as the internal one. The order of operations is
like this:

- setProjection (P1)
- new rectObj() with your extent in P1
- $rect->project(P2,P1)
- now set $map->{extent} = $rect

Basically, keep track of what projection corresponds to what object and
do all the transformations by hand, and stuff works.


> Paul Ramsey wrote:
> >
> > OK, to start with, I have a map file with a default planar projection.
> >
> > $map->{extent}->{minx} gives me a nice planar value : 167053
> >
> > I do a $map->setProjection("init=epgs:4269") where EPSG 4269 is a
> > lat/lon projection.
> >
> > $map->{extent}->{minx} *still* gives me a nice planar value : 167053
> >
> > What precisely does setProjection effect? The output image only? If so,
> > how do I specify an input extent? In the default projection only? I
> > *thought* the correct chain of operations was like this:
> >
> > - Mapserver with default projection P1
> > - Given desired extent E1 in projection P2
> >   - $map->setProjection(P2)
> >   - $map->{extent} = E1
> > - Given that one wants output in projection P3
> >   - $map->setProjection(P3)
> >   - $map->draw()
> >
> > So
> >
> > 1) how to I set the projection the output image will be generated in?
> > 2) how do I specify an image extent, given that I am doing something
> > like 1) ?
> >
> > Thanks,
> > Paul
> 
> --
>       __
>      /
>      | Paul Ramsey
>      | Refractions Research
>      | Email: pramsey at refractions.net 
>      | Phone: (250) 885-0632
>      \_

-- 
      __
     /
     | Paul Ramsey
     | Refractions Research
     | Email: pramsey at refractions.net 
     | Phone: (250) 885-0632
     \_




More information about the mapserver-users mailing list