Java mapscript problems with graphs

maurosa at iol.it maurosa at IOL.IT
Thu Oct 18 19:50:06 EDT 2007


Hi list

I am trying to do same graphs in mapserver5 using java mapscript. It works, but I found some limits.

1)

I do not known in advance which variable to plot, 
so I should set it in a dynamic way.

But I can not set the style size as a binding variable from java. Infact style.setSize accepts only numbers, like this:

layer.getClass(0).getStyle(0).setSize(10);

it does not accepts strings, like this:

layer.getClass(0).getStyle(0).setSize("[V1]");

2)

I do not known in advance how many variables to plot, 
so I should set it in a dynamic way.

I thought to add as many classes to the layer as many variables to plot.
Since I cannot set the binding variables due to the former problem, I manage to clone somehow prepared classes with the proper size (that is with the proper binding variable).

But when I clone a class, the cloned class strangely misses
the style size attribute.

For instance, after the following instruction:

layer.insertClass(layer.getClass(0).cloneClass(), 0);

the original class looked like this:

    CLASS
      NAME "V1"
      STYLE
        COLOR 255 0 0
        OUTLINECOLOR 0 0 50
        SIZE [V1]
      END
    END

but the cloned class misses the size attribute and becomes:

    CLASS
      NAME "V1"
      STYLE
        COLOR 255 0 0
        OUTLINECOLOR 0 0 50
      END
    END

The same thing happens if I clone an entire layer:

map.insertLayer(layer.cloneLayer(), -1);

-----------

The way to go until now is to prepare, say, 10 ready classes
with 10 binding variables (V1, V2, ecc.) and to cancel
at run time the unwanted variables.
It is a strange compromise, but it works.

If it were possible to add classes and set for each 
one the proper binding variable, I think that graphs worked very well.

Thanks for any suggestion.

Mauro Sartori



More information about the mapserver-users mailing list