|
This code shows how to produce a map server that enables the requests of composit images
from a given region and with a given scale.
If UCase(Request.ServerVariables("HTTP_REFERER")) = UCase("http://www.inovagis.org/freeware/asp/srcrgb.asp") Then ' protect your site from intruders requests
Option Explicit
Dim map, mapR, mapG, mapB ' rgb and differents bands
Dim buf ' final JPEG buffer
Dim nx, ny ' rows and collumns
Dim pR, pG, pB ' Point Values of RGB
Dim NameR, NameG, NameB 'File names for the different bands
Dim X1, X2, Y1, Y2, step 'Geographic Zone to display
'----------------------------------------------------------------
'Tell the server to buffer the output
response.buffer=true
'----------------------------------------------------------------
'Create the inovaGIS objects
Set mapR = CreateObject ("inovaGIS.iImg")
Set mapG = CreateObject ("inovaGIS.iImg")
Set mapB = CreateObject ("inovaGIS.iImg")
' the resulting map has to be RST because IMG does not accept
' RGB 24-Bit images files
Set map = CreateObject("inovaGIS.iRst")
'----------------------------------------------------------------
' get the necessary elements for diaplay
X1 = Request ("x1")
X2 = Request ("x2")
Y1 = Request ("y1")
Y2 = Request ("y2")
step = Request ("step")
NameR= Request ("red")
If NameR="" Then End If
NameG= Request ("green")
If NameR="" Then End If
NameB= Request ("blue")
If NameR="" Then End If
'----------------------------------------------------------------
' Set the names and directories of the different files
mapR.document.name= NameR
mapG.document.name= NameG
mapB.document.name= NameB
mapR.document.directory = "h:\landsat\israel\"
mapG.document.directory = mapR.document.directory
mapB.document.directory = mapR.document.directory
'----------------------------------------------------------------
' Open all three bands
If (mapR.OpenWindow ( CDbl (x1), CDbl (y1), CDbl (x2), CDbl (y2),Step)) AND (mapG.OpenWindow ( CDbl (x1), CDbl (y1), CDbl (x2), CDbl (y2),step)) AND (mapB.OpenWindow ( CDbl (x1), CDbl (y1), CDbl (x2), CDbl (y2),Step)) Then
'----------------------------------------------------------------
' Creates a new Map of the same size
map.New "rgb", 10, mapR.Cols, mapR.Rows,0
map.legend.maxvalue=16777215 ' white
'----------------------------------------------------------------
' Calculate to each pixel the RGB formula Red*65536 + Green*256 + Blue
For nx=1 to mapR.Cols
For ny=1 to mapR.Rows
pR=mapR.PointXY (nx,ny)
pG=mapG.PointXY (nx,ny)
pB=mapB.PointXY (nx,ny)
If NOT ( (pR=0) AND (pG=0) AND (pB=0)) Then ' if there is data in all images
map.PointXY (nx,ny) = (pR* 65536) + pG*256 + pB
Else
map.PointXY (nx,ny) = 16777215 ' else just paint white
End If
Next
Next
'----------------------------------------------------------------
' Done with updating tell inovaGIS to update the internal Bitmap
map.Refresh
'----------------------------------------------------------------
' Retrieve the buffer in JPEG format (iJPEGVeryHighQuality=20)
buf = map.StreamAs (20)
' the other formats possible are :
'iOriginalFormat = 0; RasterDataRowMajor = 1; iRasterDataColMajor = 2
'iBMP24Bits = 10; iWbmpStream = 15
'iJPEGVeryHighQuality = 20; iJPEGHighQuality = 21; iJPEGMediumQuality = 22;
'iJPEGLowQuality = 23; iJPEGVeryLowQuality = 24;
'iGifStream = 30
'----------------------------------------------------------------
' Tell the server to put the header corresponding to a JPEG file
Response. ContentType = "image/jpeg"
'----------------------------------------------------------------
' Send the image Buffer
Response. BinaryWrite buf
Else
Error!
<UL>
<LI>MapR :
<LI>MapG :
<LI>MapB :
<LI>Map :
</UL>
End If
'----------------------------------------------------------------
'Terminate and kill all objects
map.Terminate
mapR.Terminate
mapG.Terminate
mapB.Terminate
Set map = nothing
Set mapR = nothing
Set mapG = nothing
Set mapB = nothing
Else
security error ... please return to inovaGIS <a href="/freeware/asp/">ASP freeware</a> page
End If
try the code here
[inovagis.dcea.fct.unl.pt]
Query String is "?red=il-2-30& green=il-2-20& blue=il-2-10& step=2& x1=739637.5& x2=747137.5& y1=3614237.5& y2=3621737.5"
[home] [back] [next]
Recommended book to learn more about ASP:
|