[mapserver-dev] Re: Correct usage of SWIG-MapScript-SYMBOL generation

Raimund Renkert raimund.renkert at intevation.de
Wed May 25 06:41:35 EDT 2011


Hello,

we use Java MapScript as described in the mail send to this list on 2011-05-20 
(see subject above).
Now we found some further problems creating symbols/styles with a pattern and 
linewidth.

When trying to set pattern for a linesymbol with the following lines of code, 
we get a Java exception.

-----------
mapObj map = new mapObj("template.map");
layerObj layer = new layerObj(map);
classObj co = new classObj(layer);
styleObj style = new styleObj(co);

double[] values = new double[] {1.0, 2.0};
style.setPattern(values);
-----------

Calling setPattern() allways throws the following exception:

java.lang.IndexOutOfBoundsException: incorrect array size.

We tried different arrays with different length and values and we also tried 
to set the pattern length using setPatternlength().

The next is when setting the line width. The situation seems like the problem 
setting a character (see below).
Calling style.setWidth() has no effect on the attributes written to the 
mapfile.

Is there anybody who can give an advice how to set the attributes correctly?

Regards

Raimund


Am Freitag 20 Mai 2011 15:11:19 schrieb Stephan Holl:
> Hello Mapserver-devs,
>
> we try to add symbols to a SYMBOLSET with Java (1.6.2 on Windows)
> MapScript dynamically (with MS 6.0.0-rc2 with MS4W) with this code:
> -------------------
> import java.io.IOException;
> import java.io.File;
>
> import edu.umn.gis.mapscript.mapObj;
> import edu.umn.gis.mapscript.layerObj;
> import edu.umn.gis.mapscript.classObj;
> import edu.umn.gis.mapscript.styleObj;
> import edu.umn.gis.mapscript.symbolObj;
> import edu.umn.gis.mapscript.symbolSetObj;
> import edu.umn.gis.mapscript.MS_SYMBOL_TYPE;
>
> public class CharTest {
>
>     /**
>      * Entrypoint for the application.
>      */
>     public static void main(String[] args) {
>        mapObj map = new mapObj("template.map");
>        layerObj layer = new layerObj(map);
>        classObj co = new classObj(layer);
>
>        symbolSetObj symbolSet = map.getSymbolset();
>        symbolObj symbol = symbolSet.getSymbolByName("testname");
>        symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue());
>        symbol.setFont("Arial-alike");
>        symbol.setAntialias(1);
>        // see
>        //
>       
> http://mapserver.org/mapfile/symbology/construction.html#symbols-of-type-tr
>uetype symbol.setCharacter("");
>
>        symbolSet.save("symbols.sym");
>     }
> }
> -------------------
>
> The resulting symbol is
>   SYMBOL
>     NAME "testname"
>     TYPE TRUETYPE
>   END
>
> There is no error raising up with the above program, but the result
> seems odd. At least FONT and CHARACTER-keywords should be set within
> the exported symbolset.
>
> Btw. the keyword SYMBOLSET at the beginning is also missing (see [1]
> for a separate issue).
>
> Does anybody can give some advice how to use the
> SWIG-based MapScript-API to construct symbolsets correctly.
>
> Best
> 	Stephan
>
> [1] http://trac.osgeo.org/mapserver/ticket/3885


-- 
Raimund Renkert |  http://www.intevation.de/
Intevation GmbH, Neuer Graben 17, 49074 Osnabrück | AG Osnabrück, HR B 18998
Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner


More information about the mapserver-dev mailing list