[mapserver-users] Re: Java Mapscript

Sathiskumar Govindasamy gsathis@hashprompt.com
Thu, 18 Apr 2002 13:37:04 -0500


This is a multi-part message in MIME format.
--------------060603020509000302080800
Content-Type: multipart/alternative;
 boundary="------------090408020009050902060308"


--------------090408020009050902060308
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

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




--------------090408020009050902060308
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body>
Andreas, <br>
 <br>
This is what I did. <br>
 <br>
I got the mapserver source code and untarred it and did the following <br>
 <br>
./configure --with-jpeg --with-gd --with-proj  --with-gdal=/usr/local/bin/gdal-config 
<br>
make <br>
 <br>
Then I got the SWIG Version 1.3.11 source. <br>
 <br>
.<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>configure --with-javac=/usr/java/j2sdk1.4.0/bin<span
 class="moz-txt-tag">/</span></i>  --with-java=<i class="moz-txt-slash"><span
 class="moz-txt-tag">/</span>usr/java/j2sdk1.4.0/bin<span
 class="moz-txt-tag">/</span></i>  --with-javaincl=<i
 class="moz-txt-slash"><span class="moz-txt-tag">/</span>usr/java/j2sdk1.4.0/include<span
 class="moz-txt-tag">/</span></i> <br>
make <br>
make install <br>
 <br>
I created a directory called java in mapserver-src/mapscript and created
 a symlink for mapscript.i inside it. &nbsp;(In the new nightly builds, you might
not need this step since it should be already in there)<br>
 <br>
/usr/local/bin/swig -java -shadow -package mapscript mapscript.i <br>
 <br>
It created some java files. <br>
Then I did <br>
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 <br>
gcc -fpic -shared -o libmapscript.so -L/usr/lib -lgd -ljpeg -lfreetype  -lpng
-lz -ltiff&nbsp; -L/usr/local/lib -lgdal.1.1 -lproj mapscript_wrap.o  ../../libmap.a 
<br>
 <br>
 <br>
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) <br>
<br>
In tomcat, I added the following line in /etc/tomcat4/conf/tomcat4.conf<br>
<br>
export LD_LIBRARY_PATH=/opt/mapserver/mapscript/java:$LD_LIBRARY_PATH<br>
<br>
I have the mapserver installed on /opt/<br>
<br>
I have attached a servlet sample .<br>
<br>
Thanks <br>
Sathis <br>
Andreas Hirner wrote:<br>
<blockquote type="cite"
 cite="midF236JFUZJPg7g0bBVuN00019231@hotmail.com">Hello, <br>
 <br>
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. <br>
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.. <br>
I would appreciate any information or hints concerning the compilation and
 usage of Java mapscript in the linux environment. <br>
 <br>
Thanks in advance <br>
Andreas Hirner <br>
 <br>
 <br>
_________________________________________________________________ <br>
Chat with friends online, try MSN Messenger: <a class="moz-txt-link-freetext" href="http://messenger.msn.com">http://messenger.msn.com</a> <br>
</blockquote>
<br>
<br>
</body>
</html>

--------------090408020009050902060308--

--------------060603020509000302080800
Content-Type: text/plain;
 name="map.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="map.java"

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);


	}
	
}

--------------060603020509000302080800--