[Mapserver-users] querying via cgi-bin?
Frank Horowitz
frank at horow.net
Thu Jan 2 06:32:52 PST 2003
Hi Folks,
I'm a newbie to MapServer, so go easy on me! ;-) (Also, I don't
subscribe to this list, so please reply directly. Thanks!)
I am interested in "scraping" a remote MapServer
<http://www.auslig.gov.au/cgi-bin/mapserv?map=%2Fwww%2Fwwwprod%2Fmapserver%2Fglobal.map&maxy=-4.5&minx=111&maxx=155&miny=-48> for a bunch of map images, which in turn are to be fed to a downstream application. The server is running v3.3.something if it matters.
I've figured out the appropriate GET/POST request, and have that
scripted up in a little Python wrapper, ready to be looped over the
region of interest.
So far, so good. Except for one little problem. My downstream app
<http://www.gpsdrive.de> requires images at 1280x1024 (yes, I know, ugh,
but looking at the source, it's not a simple matter to change those
magic numbers, and they a entrenched *everywhere* in gpsdrive's source).
The auslig MapServer refuses to serve any image greater than 1024x1024
(I am sympathetic to the reasons why). This leaves me with my little
problem.
It occurred to me that a hacky way around the problem is to simply
retrieve two map images (where I'd ideally like to get only one) each of
size 640x1024 and paste them together using some other means. However,
my downstream app's queries rely on specifying a center point (lat,lon)
and a map scale (whatever *that* means on a raster device with
undetermined pixel sizes). Now, in an ideal world (so to speak ;-), the
calculation of the pixel size and hence lat,lon boundaries would be a
trivial matter. But this is a GIS we're talking about, and I do *NOT*
want to get involved with ellipsoid calculations, etc. etc. if I can
possibly avoid it. IMHO, that's the job of the GIS, not my script.
So that all brings me to the question in my Subject line. Is there some
way to use the cgi-bin interface to perform something like the following
steps?
1) Build a correctly scaled and centered image query (with only one
layer to take it easy on the database) sized at 640x512. (I more or less
already know how to do this, in at least one way that might not be
relevant to an ultimate solution.)
2) Somehow, through some cgi-bin magic that I don't understand, retrieve
the map extents for the image of step 1, in some kind of form that I can
grab the numerical results with my Python script. (IOW, maybe coerce the
MapServe to return some html with the values I need inside; then it
should be a 'simple' matter of busting apart the html to get at the
values I really want.)
3) Double the intervals in lat,lon and combine with the (known) center
lat,lon values to build two queries for the "left" and "right" halfs of
the 1280x1024 image that I ultimately need. (I think this gets around
the ellipsoid calculations; the GIS is determining the "small" bounds
correctly (presumably). Once I'm dealing with lat,lon boundaries, as
estimated for the centroid of the region, doubling the angles should
give me a lat,lon coordinate image that is double the pixel count in
each direction.
4) Glue them all together using some strategy that still needs to be
hacked up. (Straightforward.)
Step 2) is the only one I don't have a clue about how to go about, since
it seems to involve advanced cgi-bin variable magic or templates or
something. If anyone on this list has any suggestions (hopefully with
example GET/POST strings ;-) I'd be most grateful!
Obviously, if there is some easy way of coercing the MapServer to return
a 1280x1024 image straight away, I can avoid all of the hackery, and
that would be a *much* better solution.
TIA for any help you might be able to provide!
Cheers,
Frank Horowitz
More information about the MapServer-users
mailing list