[Mapserver-users] Passing CGI variables
Dharani Babu
dharanibabus at hotmail.com
Wed Apr 14 21:05:27 PDT 2004
Thanks
jan ,tyler and daniel. Here is my solutions to remove the browser dependency
of Map Server . I hope this would be useful for others also . The code is
vb.net .
Had a button and the its event is ....
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim url
Dim msxml As New MSXML.XMLHTTPRequest
msxml.open("GET",
"http://localhost/cgi-bin/mapserv_40.exe?map=C%3A%2Fms4w%2Fapache%2Fhtdocs%2Fdemof%2Frock_pic.map&layer=tigerdata&zoomdir=1&zoomsize=2&program=%2Fcgi-bin%2Fmapserv_40.exe&map_web_imagepath=C%3A%2Fms4w%2Fapache%2Fhtdocs%2Ftemp_rm6%2F&map_web_imageurl=%2Ftemp_rm6%2F",
False)
msxml.send("")
url = msxml.responseText
Dim objdocument
objdocument = CreateObject("HTMLFILE")
objdocument.open("text/html")
objdocument.write(url)
Dim objforms
Dim ctrl
Dim strpath
Dim arr() As String
Dim imgxy() As String
Dim imgext() As String
For Each objforms In objdocument.documentElement.document.Forms
For Each ctrl In objforms.getElementsByTagName("*")
If ctrl.tagName = "INPUT" Then
If ctrl.Name = "img" Then
arr = Split(ctrl.src, "/")
End If
If ctrl.Name = "imgxy" Then
strXY = ctrl.Value
End If
If ctrl.Name = "imgext" Then
strEXT = ctrl.Value
End If
End If
Next
Next
objdocument.close()
strpath = "C:\ms4w\Apache\htdocs\temp_rm6\" & arr(2)
PictureBox1.BorderStyle = BorderStyle.Fixed3D
PictureBox1.Image = Image.FromFile(strpath)
End Sub
Here first we pass the default html stream that is fed to the ms exe after
the init html . Now we get the resultant text output from MS in xml form and
search for the image path ( the one created at /tmp ) , the imgxy values
and the imgext values and store them in a global variable . Now with the
image path obtained we render the image at the picture box . Now the next
job is to imitate the feed back from the template html thro the picture box
. The code for it is written in the click event of picture box ....
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Dim xpos
Dim ypos
Dim strtemp
xpos = e.X()
ypos = e.Y()
strtemp =
"http://localhost/cgi-bin/mapserv_40.exe?zoomdir=1&zoomsize=2&"
strtemp = strtemp & "imgxy=" & Replace(strXY, " ", "+") & "&imgext="
& Replace(strEXT, " ", "+") & ""
strtemp = strtemp &
"&map=C%3A%2Fms4w%2Fapache%2Fhtdocs%2Fdemof%2Frock_pic.map&savequery=true&program=%2Fcgi-bin%2Fmapserv_40.exe&map_web_imagepath=c%3A%2Fms4w%2FApache%2Fhtdocs%2Ftemp_rm6%2F&map_web_imageurl=%2Ftemp_rm6%2F"
strtemp = strtemp & "&img.x=" & xpos & "&img.y=" & ypos
Dim url
Dim msxml As New MSXML.XMLHTTPRequest
msxml = New MSXML.XMLHTTPRequest
msxml.open("GET", strtemp, False)
msxml.send("")
url = msxml.responseText
Dim objdocument
objdocument = CreateObject("HTMLFILE")
objdocument.open("text/html")
objdocument.write(url)
Dim objforms
Dim ctrl
Dim strpath
Dim arr() As String
For Each objforms In objdocument.documentElement.document.Forms
For Each ctrl In objforms.getElementsByTagName("*")
If ctrl.tagName = "INPUT" Then
If ctrl.Name = "img" Then
arr = Split(ctrl.src, "/")
End If
If ctrl.Name = "imgxy" Then
strXY = ctrl.Value
End If
If ctrl.Name = "imgext" Then
strEXT = ctrl.Value
End If
End If
Next
Next
objdocument.close()
strpath = "C:\ms4w\Apache\htdocs\temp_rm6\" & arr(2)
PictureBox1.BorderStyle = BorderStyle.Fixed3D
PictureBox1.Image = Image.FromFile(strpath)
msxml = Nothing
End Sub
Now the newly obtained X pos and Y pos of the click event are concatenated
with the default
http://localhost/....../file.map with imgxy + imgext + xpos +ypos . Thats
all . Now the next created image path is obtained and cool we go . This
wrapper can be used for adding panning , zoom out etc .
with thanks in advance
dharani
>From: Jan Hartmann <j.l.h.hartmann at uva.nl>
>To: Dharani Babu <dharanibabus at hotmail.com>,
>mapserver-users at lists.gis.umn.edu
>Subject: Re: [Mapserver-users] Passing CGI variables
>Date: Tue, 13 Apr 2004 11:10:51 +0200
>
>
>
>Dharani Babu wrote:
>
>>
>>Thanks lot
>>thanks for daniel also. I have a doubt say we click on the template html
>>image . Now we have a automatic image number created like
>>tmp/DEMO1080825720168.png . Now As I am trying to automatically point to
>>the recently created png image , how to find out the image number ( thats
>>the image file name DEMO+ 1080825720168? ) I am writing a skin with vb.net
>>to handle this so that I display the images without browser support .
>>
>
>If you create don't need web access cou can create a very simple template
>file:
>
><img>
>
>
>When you do a call to MapServer with a mapfile pointing to this template,
>you'll get back the picture in the tmp directory, and the path to that file
>on standard output. You can use that name in your vb.net application.
>
>Jan
>
>
_________________________________________________________________
Need quick cash? http://go.msnserver.com/IN/46923.asp Click here !
More information about the MapServer-users
mailing list