[mapserver-users] confusion about postgis bounding box -> valid map extent
Steve Lime
steve.lime at dnr.state.mn.us
Fri Aug 23 12:27:52 PDT 2002
>>> Alex Rice <alex_rice at arc.to> 08/23/02 01:46PM >>>
> I am using PostGIS and getting a bounding box of objects in
> PostGIS with the functions Envelope() or Box3d(). The bounding
> box will not be the same aspect ratio as my Map object.
> Here are some things I am confused about.
> - Is it correct that in Perl mapscript, the only way to set the
> extent of the map object is directly accessing
> $mapObj->{extent}->{minx} etc.? Pretty sure this is true, just
> want to verify I'm not missing something.
This is true. PHP MapScript has a couple of utility methods that need
to be replicated in the Swig version.
> - What's the expected behavior if in Perl mapscript I set the
> extent as above, call prepareQuery(), then draw, if the new
> extent has a different aspect ratio than the output image size?
In the C code the extent will be adjusted for output image size.
> - In php_mapscript.c there are functions for dealing with the
> map extent based on a box inside the visible image, or a point +
> scale, etc. Does anyone have example Perl code, for instance, of
> the map->zoomRectange() function in php_mapscript.c? I have seen
> the &set_extent() method from mapquakes.pl and seen the examples
> Lowell posted in Perl, but those are zoom & pan, not fitting an
> extent to another rect. If there isn't sample perl code
I've got all those written in C and javascript. Let me know what you'd like
to see. Otherwise MapScript already has a method to fit a rectangle to
a new window size. It's part of the rectObj class (of which extent is one)
and is called fit. For example:
$cellsize = $map->{extent}->fit($newwidth, $newheight);
> - In maptemplate.c, the function setExtent() has several cases
> for the "source" of the change in extent. Do any of those cases
> apply to my situation? Maybe I can adapt the C code to a Perl
> method.
Nope. The code for zooms etc. is in mapserv.c
> - Is there a way to get PostGIS to fit a bounding box to an
> aspect ratio? It would be nice if I didn't have to do it in perl
> at all. A function like this is what I'm imagining
> select extent2extent(5, 3, box3d(the_geom), centroid(the_geom));
> where 5:3 is the aspect ratio
> box3d is the extent of the object
> centroid is the center of the requested new extent
Already addressed in a generic way with the fit method.
> Thanks,
> Alex Rice, Software Developer
Steve
More information about the MapServer-users
mailing list