Perl Mapscript Problem
Sean Gillies
sgillies at FRII.COM
Thu Sep 15 09:14:17 PDT 2005
On Sep 15, 2005, at 9:27 AM, Stephen Woodbridge wrote:
> Sean Gillies wrote:
>> On Sep 13, 2005, at 7:09 PM, Stephen Woodbridge wrote:
>>
>>> Hi All,
>>>
>>> I had dynamic symbol manipulation working on MS 4.01 but can not get
>>> it
>>> to work on 4.4.1 or 4.6.1. In the following code snippets every think
>>> works with the default symbol that is defined in symbolset file, but
>>> the
>>> code does not let me change the imagepath on the fly.
>>>
>>> Also, I can not get the label on the umarker layer to show unless I
>>> specify LABELCACHE FALSE and umarker layer is the last in the
>>> mapfile.
>>>
>>> Any ideas or help would be appreciated.
>>>
>>> -Steve W.
>>>
>>
>> Steve,
>>
>> Perhaps mutating the imagepath has no effect due to caching of symbol
>> images. About the labelcache, I would guess that the label is losing
>> the
>> battle against other in the map.
>
> Sean,
>
> Thank you for your response. You are probably correct on the labelcache
> issue now that I think about it. While it is the last layer and should
> take priority in the cache, it is being drawn after all the other
> labels
> in the cache are drawn so the only way to get it on top is to not use
> the cache as it is too late in the process.
>
>> This is how I do dynamic symbols
>>
>> # create a new symbol
>> new_symbol = mapscript.symbolObj('symbol_a',
>> '/path/to/symbol_a.png')
>>
>> # add a *copy* of the symbol to the map symbolset and get the
>> index
>> new_symbol_index = map.symbolset.appendSymbol(new_symbol)
>>
>> See http://zcologia.com/mapserver/mapscript#symbolobj and
>> http://zcologia.com/mapserver/mapscript#symbolsetobj or the same docs
>> on
>> the new mapserver site.
>>
>> The symbolObj also has a method to set symbol imagery directly. See
>> http://zcologia.com/mapserver/imagery-howto#images-and-symbols.
>
> I will look at this, but my concern is that we generate a large number
> of symbols (actually numbered dots on the map) and I'm concerned we
> will
> exceed the hardcoded limit on symbols in map.h
>
Numbered dots? I have an application that requires numbered symbols:
highway shields with the highway number. I'm simply using an annotation
type layer with an unnumbered shield image as a symbol and then using
the class label to render the highway number over the top. Works
perfectly. I don't know if this method is something you can use, but it
would be faster as well as simpler.
> I think that the mapscript API needs to fix the cached image if the
> image file is changed. This is a bug. What good is it to change the
> symbol name if it does not change the symbol also? Would you concur on
> this?
>
Remember that mapscript is basically a mapfile as an object tree. In
theory, you can freely modify attributes of the objects, like a
symbol's imagepath. In practice, much of MapServer's code is still
based on the assumption that a mapfile is read only once at the very
beginning and afterwards remains immutable during execution. A similar
issue is arising in a discussion about layer feature source plugins.
Many people, it turns out, have been mutating layer.connectiontype in
their scripts.
IMO, the right solution might be to implement a method for symbolObj
that loads imagery from disk and updates the cache, and to make
symbolObj.imagepath immutable. Explicit is better.
> Thank you for your suggestions, I will see if I can get them to work.
>
> -Steve
>
You're welcome, Steve. I hope my highway shield suggestion is useful.
That would be the most efficient, and worth some data preprocessing.
Sean
--
Sean Gillies
sgillies at frii dot com
http://zcologia.com
More information about the MapServer-users
mailing list