[mapserver-users] Re: Java Mapscript

Andreas Hirner andreas_hirner at hotmail.com
Fri May 3 07:21:05 PDT 2002


Hello Sathis,

i have been off for a while and resumed my work yesterday. The library and 
java classes compiled fine. Now I am going to look at the implementation. 
Thanks for your help. It made things much easier.

Cheers
Andreas


>Andreas,
>
>This is what I did.
>
>I got the mapserver source code and untarred it and did the following
>
>./configure --with-jpeg --with-gd --with-proj
>--with-gdal=/usr/local/bin/gdal-config
>make
>
>Then I got the SWIG Version 1.3.11 source.
>
>./configure --with-javac=/usr/java/j2sdk1.4.0/bin/
>--with-java=/usr/java/j2sdk1.4.0/bin/
>--with-javaincl=/usr/java/j2sdk1.4.0/include/
>make
>make install
>
>I created a directory called java in mapserver-src/mapscript and created
>a symlink for mapscript.i inside it.  (In the new nightly builds, you
>might not need this step since it should be already in there)
>
>/usr/local/bin/swig -java -shadow -package mapscript mapscript.i
>
>It created some java files.
>Then I did
>FLAGS="-DUSE_PROJ -DUSE_PROJ_API_H -DUSE_GD_PNG -DUSE_GD_JPEG
>-DUSE_GD_WBMP -DUSE_GD_FT -DUSE_WMS -DUSE_TIFF -DUSE_JPEG -DUSE_EPPL
>-DUSE_GDAL"gcc -fpic -c $FLAGS -I/usr/java/j2sdk1.4.0/include
>-I/usr/java/j2sdk1.4.0/include/linux mapscript_wrap.c
>gcc -fpic -shared -o libmapscript.so -L/usr/lib -lgd -ljpeg -lfreetype
>-lpng -lz -ltiff  -L/usr/local/lib -lgdal.1.1 -lproj mapscript_wrap.o
>../../libmap.a
>
>
>Java programs didn't compile right off the bat. I need to correct all
>those 'long' variable types and return types. Then it compiled. (New
>nightly build should compile clean)
>
>In tomcat, I added the following line in /etc/tomcat4/conf/tomcat4.conf
>
>export LD_LIBRARY_PATH=/opt/mapserver/mapscript/java:$LD_LIBRARY_PATH
>
>I have the mapserver installed on /opt/
>
>I have attached a servlet sample .
>
>Thanks
>Sathis
>Andreas Hirner wrote:
>
>>Hello,
>>
>>I have been able to compile mapserver 3.5 on Linux/Suse 7.3 and got
>>the demo running. Now I am thinking of using Java mapscript within Jsp
>>Pages.
>>Does anybody know how to go about this. Do I have to use Swig to
>>create the Java sources from the nightly builds or are there other
>>Java sources available. Is the functionality or reliability of Java
>>mapscript similar to that of the Perl or PHP versions or are there any
>>limitations. Are there any manuals covering the usage of Java
>>mapscript. And so on..
>>I would appreciate any information or hints concerning the compilation
>>and usage of Java mapscript in the linux environment.
>>
>>Thanks in advance
>>Andreas Hirner
>>
>>
>>_________________________________________________________________
>>Chat with friends online, try MSN Messenger: http://messenger.msn.com
>
>
>
>import javax.servlet.*;
>import javax.servlet.http.*;
>import java.io.*;
>import java.util.*;
>
>import mapscript.*;
>
>public class demo extends HttpServlet
>{
>	static
>	{
>		try
>		{
>			System.loadLibrary("mapscript");
>			System.err.println("Loaded the Mapscript library");
>		}
>		catch (UnsatisfiedLinkError e)
>		{
>			e.printStackTrace();
>		}
>	}
>
>	public void doGet(HttpServletRequest req, HttpServletResponse resp)
>	throws ServletException, IOException
>	{
>
>		System.err.println("doGet Method Accessed");
>		String strTruckID = req.getParameter("trucklocid");
>
>		mapObj map = new 
>mapObj("/var/tomcat4/webapps/fleetmanager/nationalatlas/demo.map");
>		long image = map.prepareImage();
>
>		layerObj layerstate = map.getLayerByName("statesp020");
>		layerstate.draw(map.getCPtr(),image);
>
>		layerObj layerroad = map.getLayerByName("roadtrl020");
>		layerroad.draw(map.getCPtr(),image);
>
>		layerObj layerwater= map.getLayerByName("hydrogp020");
>		layerwater.draw(map.getCPtr(),image);
>
>		layerObj layercities= map.getLayerByName("cities");
>		layercities.draw(map.getCPtr(),image);
>
>		String filename = "temp/temp.jpg"
>
>		//msSaveImage(img,filename,type,transparent,interlace,quality)
>		mapscript.msSaveImage(image,"/var/tomcat4/webapps/fleetmanager/"+filename,map.getImagetype(),
>					map.getTransparent(),map.getInterlace(),map.getImagequality());
>
>		resp.sendRedirect(filename);
>
>
>	}
>
>}


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx




More information about the MapServer-users mailing list