Java mapscript problems with graphs

thomas bonfort thomas.bonfort at GMAIL.COM
Fri Oct 19 00:51:23 PDT 2007


mauro,
I think what you are looking for is the setBinding method of the styleObj....

unfortunately I haven't found the MS_STYLE_BINDING_* constants defined
for java mapscript, so for the time being there's no way to do what
you want.
I've cc'd umberto on this so he can confirm, and there will probably
be a bug opened on this

thanks,
tb

On 10/19/07, maurosa at iol.it <maurosa at iol.it> wrote:
> 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