[mapserver-users] RE: is there such a thing as a pixel/screen projection?

Arthur Clifford art at artspad.net
Fri Jan 23 20:29:17 PST 2009


Hi Brent (and Frank),

Yes, as someone who has ramped up in a variety of object oriented
programming languages over time my expectation was that there would be a way
to define a point as being in pixels and that there would be a way of
projecting from pixels to a target projection and projecting from a given
projection back to pixels. So, the fact I can't do that is surprising. The
forward and reverse projection stuff from Pixels to at least lat/lon has to
exist somewhere in the MapServer codebase or the other functions it provides
(like zooming and panning) would not be possible. So its not only doable,
its been done, its just not exposed ... yet.

So, where do I go to submit feature requests?

Since the server has a habit of correcting extents and adjusting things to
what it thinks is appropriate (which is good, it probably should), I would
like to be able to pass pixel values I've collected for a given extent and
view-dimensions and send them to the server to be processed into lat/lon for
storage or for querying stored values such that the projected value is
consistent with MapServer's own projection math/technique. Someone else was
doing the storage of lat/lon values from pixel values and I found a Nabble
entry about it from exactly two years ago (Jan 23, 2007). But they were
doing the math themselves, and while I will probably use the routine they
shared in the near-term it seems like the API is missing something.

To me the process would be more logical if I could do something like:
$projectionFrom = ms_newProjectionObj("+screen +width=200 +height=100
+units=pixels +dpi=72");
$projectionTo = ms_newProjectionObj($latLonProj4);
$pointObj = ms_newPointObj( 100 , 50 );
$poinObj->project( $projectionFrom, $projectionTo );
$latLonX = $pointObj->x;
$latLonY = $pointObj->y;

Note that the only difference between this and other projection operations
is the setting of the from projection.

I realize that proj4 doesn't support screen coordinates, but if there were
some equivalent way of defining a screen-type projection, such as
ms_newScreenProjection( 200,100,"pixels",72), for use with the PointObj's
and RectObj's project() functions that would a provide a more complete API
for handling user interactions on the map via languages like PHP. 

And, as Brent pointed out, if you can set the rotation but not get the
rotation, then something ain't right. That's incomplete functionality
especially if MapServer is adjusting values when switching between
projections/extents/view sizes, such that the rotation may not be now what
you specified it to be at the beginning.

FWIW I like MapScript and MapServer, I'm trying not to complain as much as
help MapServer round out its functionality by being vocal ;).

ArtC
Arthur Clifford





More information about the MapServer-users mailing list