[mapserver-users] Java Wrapper for mapserver
Sathiskumar Govindasamy
gsathis@yahoo.com
Tue, 19 Feb 2002 17:11:51 -0600
This is a multi-part message in MIME format.
--------------020701010109020102020508
Content-Type: multipart/alternative;
boundary="------------080807010904020601020603"
--------------080807010904020601020603
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Harald,
One good thing. I found a native method in the big mapscript class
msSaveImage(). It worked. It saved the image to the place I wanted. I
have attached the modified version of your example file.
Cool.
Sathios
Harald Wehr wrote:
>> 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
>
>
>
> Looks good to me. Attached you find my compile-file. But I think it's
> nearly the same.
>
>
>>
>> Java programs didn't compile right off the bat. I need to correct all
>> those 'long' variable types and return types. Then it compiled. Also,
>> I have a basic doubt. In that directory there are two library files.
>>
>> 1. libmapscript.so
>> 2. mapscript_wrap.o
>>
>> Which one do I need to load with System.load ?
>
>
>
> In my opinion you only need the first one. Also attached, you find a
> short java-program that works for me and writes the name of the
> template file if there is one in you map-file.
>
> I use tomcat4 as the
>
>> servlet engine and I couldn't figure out where to put the files to
>> use System.loadLibrary. It keeps complining that it could not find
>> the library file in the library path. Do you happen to know where
>> should I put the library file to use System.loadLibrary ? If I try to
>> give full path in that it throws and exception that directory
>> seperators should not be use.
>
>
>
> Hm, try to test my java-programm. I can move the java-prog,
> libmapscript.so and the java-classes wherever i want on my system and
> it works. The libmapscript.so is in the same directory as the
> java-program. The java-classes are in the package mobiharz i send in
> the last mail to you.
>
> Harald
>
>
>------------------------------------------------------------------------
>
>#!/bin/sh
>
>FLAGS="-DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP -DUSE_GD_FT -DUSE_TIFF -DUSE_JPEG -DUSE_GDAL -DUSE_EPPL -DUSE_PDF"
>
>
>gcc -fpic -c $FLAGS -I/opt/java/jdk1.3.1_02/include -I/opt/java/jdk1.3.1_02/include/linux mapscript_wrap.c
>
>gcc -fpic -shared -o libmapscript.so -lgd -L/usr/lib -lgd -ljpeg -lfreetype -lpng -lz -ltiff -lpdf -L/usr/local/lib -lgdal.1.1 mapscript_wrap.o ../../libmap.a
>
>
>#gcc -fpic -c $FLAGS -I/usr/java/jdk1.3.1_01/include
>#-I/usr/java/jdk1.3.1_01/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
>
>
>
>------------------------------------------------------------------------
>
>import mobiharz.*;
>
>
>public class version {
> static {
> try {
> System.loadLibrary("mapscript");
> } catch (UnsatisfiedLinkError e) {
> System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
> System.exit(1);
> }
> }
>
> public static void main(String argv[]) {
> mapObj map = new mapObj("/home/hawe/public_html/lk/own.map");
> webObj web = map.getWeb();
> System.out.println(web.getTemplate());
> }
>}
>
--------------080807010904020601020603
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<html>
<head>
</head>
<body>
Harald,<br>
<br>
One good thing. I found a native method in the big mapscript class msSaveImage().
It worked. It saved the image to the place I wanted. I have attached the
modified version of your example file.<br>
<br>
Cool.<br>
Sathios<br>
<br>
Harald Wehr wrote:<br>
<blockquote type="cite" cite="mid:3C726FC5.2040801@hs-harz.de">
<blockquote type="cite">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 -L/usr/local/lib -lgdal.1.1 -lproj mapscript_wrap.o ../../libmap.a
<br>
</blockquote>
<br>
<br>
Looks good to me. Attached you find my compile-file. But I think it's nearly
the same. <br>
<br>
<br>
<blockquote type="cite"><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. Also, I have a
basic doubt. In that directory there are two library files. <br>
<br>
1. libmapscript.so <br>
2. mapscript_wrap.o <br>
<br>
Which one do I need to load with System.load ? </blockquote>
<br>
<br>
In my opinion you only need the first one. Also attached, you find a short
java-program that works for me and writes the name of the template file
if there is one in you map-file. <br>
<br>
I use tomcat4 as the
<blockquote type="cite">servlet engine and I couldn't figure out where
to put the files to use System.loadLibrary. It keeps complining that it
could not find the library file in the library path. Do you happen to know
where should I put the library file to use System.loadLibrary ? If I try
to give full path in that it throws and exception that directory seperators
should not be use. <br>
</blockquote>
<br>
<br>
Hm, try to test my java-programm. I can move the java-prog, libmapscript.so
and the java-classes wherever i want on my system and it works. The libmapscript.so
is in the same directory as the java-program. The java-classes are in the
package mobiharz i send in the last mail to you. <br>
<br>
Harald <br>
<br>
<pre wrap=""><br><hr width="90%" size="4"><br>#!/bin/sh<br><br>FLAGS="-DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP -DUSE_GD_FT -DUSE_TIFF -DUSE_JPEG -DUSE_GDAL -DUSE_EPPL -DUSE_PDF"<br><br><br>gcc -fpic -c $FLAGS -I/opt/java/jdk1.3.1_02/include -I/opt/java/jdk1.3.1_02/include/linux mapscript_wrap.c<br><br>gcc -fpic -shared -o libmapscript.so -lgd -L/usr/lib -lgd -ljpeg -lfreetype -lpng -lz -ltiff -lpdf -L/usr/local/lib -lgdal.1.1 mapscript_wrap.o ../../libmap.a<br><br><br>#gcc -fpic -c $FLAGS -I/usr/java/jdk1.3.1_01/include<br>#-I/usr/java/jdk1.3.1_01/include/linux mapscript_wrap.c<br>#gcc -fpic -shared -o libmapscript.so -L/usr/lib -lgd -ljpeg -lfreetype -lpng<br>#-lz -ltiff -L/usr/local/lib -lgdal.1.1 -lproj mapscript_wrap.o<br><br><br></pre>
<pre wrap=""><br><hr width="90%" size="4"><br>import mobiharz.*;<br><br><br>public class version {<br> static {<br> try {<br> System.loadLibrary("mapscript");<br> } catch (UnsatisfiedLinkError e) {<br> System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);<br> System.exit(1);<br> }<br> }<br><br> public static void main(String argv[]) {<br> mapObj map = new mapObj("/home/hawe/public_html/lk/own.map");<br> webObj web = map.getWeb();<br> System.out.println(web.getTemplate());<br> }<br>}<br><br></pre>
</blockquote>
<br>
</body>
</html>
--------------080807010904020601020603--
--------------020701010109020102020508
Content-Type: text/plain;
name="version.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="version.java"
package mapserver;
import mapscript.*;
public class version {
static {
try {
System.loadLibrary("mapscript");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
mapObj map = new mapObj("/var/www/html/nationalatlas/demo.map");
long image = map.draw();
//msSaveImage(img,filename,type,transparent,interlace,quality)
mapscript.msSaveImage(image,"/tmp/example.png",map.getImagetype(),map.getTransparent(),map.getInterlace(),map.getImagequality());
}
}
--------------020701010109020102020508--