layeritems with java mapscript

Sean Gillies sgillies at FRII.COM
Tue Dec 14 10:10:09 EST 2004


On Dec 14, 2004, at 2:24 AM, Nicol Hermann wrote:

> Hi List,
>
> i would like to detect the names of the attribut fields with java
> mapscript. I tried the code below but i alway get back zero fields.
> What i am doing wrong?
>
> Thanks for any help
> Nicol
>
>
> package msjava;
> import edu.umn.gis.mapscript.*;
>
> public class layeritems {
>         public static void main(String[] args)  {
>            System.loadLibrary("mapscript");
>
>            mapObj map = new
> mapObj("/home/nicol/public_html/mapserver/dev/brd.map");
>            layerObj layer = map.getLayer(0);
>            System.out.println("Count of fields from layer "
> +layer.getName()
> + " : " + layer.getNumitems());
>            for (int i =0; i < layer.getNumitems(); i++) {
>                    System.out.println("Fieldname: " +
> layer.getItem(0));
>            }
>         }
> }
>
>

Nicol,

You have to open a layer before you can get the items or any values
of shapes.

cheers,
Sean


--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies



More information about the mapserver-users mailing list