[mapserver-users] Using JSP with ms4w

Venkat Rao Tammineni vtammineni at roulacglobal.com
Fri Apr 17 03:15:25 EDT 2009


Hi,

 

  Have a look into the sample code .. Refer some urls in mapserver  portal
"how to compile  mapserver with java".But basically I m not java developer.I
am  into C#.net.May the below sample can help you at least it guides you.

 

 

<%@page contentType="text/html; charset=GB2312" language="java" %>

<%@page import="edu.umn.gis.mapscript.*" %>

<%@page import="java.util.Iterator, java.util.ArrayList"%>

<%@page import="java.util.Date"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<TITLE> my first mapserver-webgis Good-luck </TITLE>

</HEAD>

<BODY>

<FORM METHOD=POST ACTION="index.jsp">

 

<%!

 static int i=0;

%>

<%

 mapObj map;

 String vMapFile="";

 String vScaleBarFile="";

 String vLengdBarFile="";

 String vReferenceFile="";

 double rodio=1;

 map = new mapObj ("D:/webapps/mapserver/tutorial.map");

 if(map==null)

 {

  System.out.println("!ok");

  

 }

 else

 {  

 if(request.getParameter("rodio")!=null)

 {

  if(request.getParameter("rodio")!="")

  {

   rodio=Double.parseDouble(request.getParameter("rodio"));

  }

 }

 rectObj ro=map.getExtent();

 double xw=ro.getMaxx()-ro.getMinx();

 double yw=ro.getMaxy()-ro.getMiny();

 double cx=(ro.getMaxx()+ro.getMinx())/2;

 double cy=(ro.getMaxy()+ro.getMiny())/2;

 double newxw=xw*rodio;

 double newyw=yw*rodio;

 double maxx=cx+newxw/2;

 double minx=cx-newxw/2;

 double maxy=cy+newyw/2;

 double miny=cy-newyw/2;

 map.setExtent( minx,  miny,  maxx,  maxy);

 System.out.println("minx:"+minx);

 System.out.println("miny:"+miny);

 System.out.println("maxx:"+maxx);

 System.out.println("maxy:"+maxy);

   map.setImagecolor(new colorObj(10,128,98,13));

   imageObj imagen=map.draw();

   //imagen.setImageDir("/tmp");

   Date dt=new Date();

   vMapFile="output/tangnf"+(dt.getTime())+".png";

  // map.embedScalebar(imagen);

   imagen.save(vMapFile,map);

   

   scalebarObj  scalebar=map.getScalebar();

   scalebar.setHeight(10);

   scalebar.setWidth(200);

   scalebar.setBackgroundcolor(new colorObj(0,255,0,13));

   scalebar.setColor(new colorObj(230,0,0,13));

   scalebar.setImagecolor(new colorObj(255,255,255,13));

   scalebar.setOutlinecolor(new colorObj(0,230,255,13));

   //scalebar.setStyle(3);

   scalebar.setUnits(3);

   scalebar.setIntervals(3);

   //scalebar.setLabel(new labelObj

      imageObj Scalebarimage=map.drawScalebar();

   vScaleBarFile="output/scalebar"+(dt.getTime())+".jpg";

   Scalebarimage.save(vScaleBarFile,map);

 

    legendObj legend=map.getLegend();

    legend.setHeight(200);

    legend.setWidth(100);

    System.out.println(legend.getLabel().getEncoding()); 

   imageObj Legendimage=map.drawLegend();

   vLengdBarFile="output/Legend"+(dt.getTime())+".png";

   Legendimage.save(vLengdBarFile,map);

   int layerCount=map.getNumlayers();

   for(int i=0;i<layerCount;i++)

  {

    layerObj layer=map.getLayer(i);

    System.out.println("layer"+(i)+":"+layer.getName());

  }

       System.out.println("layerCount:"+layerCount);

  

      referenceMapObj referenceMap=map.getReference();

   referenceMap.setHeight(200);

   referenceMap.setWidth(200);

 

                                

 

   imageObj ReferenceImg=map.drawReferenceMap();

   vReferenceFile="output/Reference"+(dt.getTime())+".png";

   ReferenceImg.save(vReferenceFile,map);

  System.out.println("test");

 }

 

                                

 

%>

<table border=1>

<tr><td>

<INPUT TYPE="text" NAME="rodio" value="<%=rodio%>" id="rodio" >

</td>

<td>

<INPUT TYPE="submit" value="test">

</td>

<tr><td width=80 >

<INPUT NAME="ScaleBar" TYPE="image" SRC="<%=vScaleBarFile%>"  border=1>

<!--  <img SRC="<%=vScaleBarFile%>"  border=0 width=100 height=17></img> -->

 </td>

 </tr>

 <tr><td>

 <INPUT NAME="imgMap" TYPE="image" SRC="<%=vMapFile%>"  width=600 height=400
border=0>

 </td>

 </tr>

 <tr><td>

<INPUT NAME="imgLengd" TYPE="image" SRC="<%=vLengdBarFile%>"   border=0>

 </td>

 <td>

<INPUT NAME="vReferenceF" TYPE="image" SRC="<%=vReferenceFile%>"   border=0>

 </td>

 </tr>

 </table>

</FORM>

</BODY>

</HTML>

 

Thanks,

 

Venkat

GIS Developer

Hyderbad

India

 

 

From: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Mukul Gupta
Sent: Friday, April 17, 2009 12:25 PM
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] Using JSP with ms4w

 

Hi
I am new to this mapserver thing and cant figure out how to work with JSP
instead of PHP for my GIS application development.I already have Tomcat 6
installed and its working fine. Tell me how to configure it so that it will
work with ms4w.Please also suggest some tutorials and examples for me to
start working.
--Mukul

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20090417/bc8ca30b/attachment-0001.html


More information about the mapserver-users mailing list