[mapserver-users] Fwd: Zoom to something and display in one shot from MapServer CGI.
Lime, Steve D (MNIT)
steve.lime at state.mn.us
Tue Jul 11 14:55:52 PDT 2017
You can also do pure mapserver with a query layer and a URL template. It's doing a dynamic redirect but it's a single call from your perspective. You'd have a layer like so:
LAYER
NAME 'parcel_query'
TYPE QUERY
DATA 'parcels'
VALIDATION
qstring '^[0-9]{16}$' # 16-digit pin number
END
TEMPLATE 'http://{url to display service}&mapext=[shpext]'
END
and then a query URL like so:
http://.../cgi-bin/mapserv?map=mymap.map?mode=itemquery&qlayer=parcels&qitem=pin&qstring=202923230045
Assumes one feature per pin...
It's not a pretty URL, if that's needed use a script as Steve suggests or something like mod_rewrite in front.
Steve
-----Original Message-----
From: mapserver-users [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Stephen Woodbridge
Sent: Tuesday, July 11, 2017 1:07 PM
To: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] Fwd: Zoom to something and display in one shot from MapServer CGI.
Bobb,
If you using sql you can do this in one pass, just write a trivial php
script that returns an image.
1. connect to db
2. sql to query expanded bbox of parcel
select st_astext(st_extent(st_expand(geom, delta)))
from parcels where pin=?
3. create url to mapserver based on bbox and image size
5. header('Content-type: image/png');
4. passthru(url);
Don't make it more complicated than it needs to be. You can do the same
using perl, python, script language of your choice.
-Steve
On 7/11/2017 12:22 PM, Basques, Bob (CI-StPaul) wrote:
>
>>
>> Hi Steve,
>>
>> I want to send a CGI request like : ServerName?pin=202923230045
>>
>> And zoom to the pin (parcel polygon) in the returned image and also
>> add a buffer percentage. This is for a reporting application. I can
>> do it with an intermediate service, but it’s been awhile since I did
>> this, and was wondering if anything new in MapServer might help with
>> this for a single pass approach.
>>
>> The zoom parameters would be hardcoded into the MapFILE in an ideal
>> world, I can build an SQL for this for example, but I recall I
>> couldn’t use the BBOX returned from the SQL as a BBOX for Mapserver
>> parent call, my memory is cloudy on that capability from MapServer
>> though, hence the question. Now that you have me talking it through
>> though, I think the last time I asked about this it was to inquire
>> about possibly chaining more than one MapServer call together to get
>> the result. I think there were fears at the time about possible
>> runaway processes being created . . . .
>>
>> bobb
>>
>>
>>> On Jul 11, 2017, at 10:38 AM, Stephen Woodbridge
>>> <woodbri at swoodbridge.com <mailto:woodbri at swoodbridge.com>> wrote:
>>>
>>> On 7/11/2017 10:39 AM, Basques, Bob (CI-StPaul) wrote:
>>>> All,
>>>> It’s probably because it’s Tues. but I think I’ve asked this before
>>>> in the past . . .
>>>> I have a DB with PIN numbers for PARCELS and I want to be able to
>>>> auto-zoom(with buffer) to a PARCEL by just sending in a PIN number
>>>> via CGI.
>>>> can the BBOX be pulled from the DB based on the geom in one shot?
>>>> I’ve done this in the past with a Webservice that went and grabbed
>>>> the BBOX separately, then assembled the url for getting the graphic
>>>> back from Mapserver.
>>>
>>> Bobb,
>>>
>>> What are you trying to zoom? the image or the client?
>>>
>>> If it is the client then how is mapserver on the server supposed to
>>> tell the client it needs to zoom? You have to query the server to get
>>> the bbox then make the client zoom appropriately.
>>>
>>> For the image, assuming you want a static image showing the parcel,
>>> then I would write a php/python/perl script the you pass the PIN to
>>> and it does the work to figure out the extents and return the image.
>>>
>>> -Steve W
>>>
>>> ---
>>> This email has been checked for viruses by Avast antivirus software.
>>> https://www.avast.com/antivirus
>>>
>>> _______________________________________________
>>> mapserver-users mailing list
>>> mapserver-users at lists.osgeo.org <mailto:mapserver-users at lists.osgeo.org>
>>> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>>
>> "If you're going through hell, keep going. “
>> - Winston Churchill
>>
>>
>
>
>
> "Be nice to people on your way up because you meet them on your way down."
> - Jimmy Durante
>
>
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list