Opened 19 years ago

Closed 19 years ago

#1472 closed defect (fixed)

API regression handling dymanic pixmap symbol path changes

Reported by: woodbri@… Owned by: nacional@…
Priority: high Milestone:
Component: Documentation - MapServer Version: 4.6
Severity: major Keywords:
Cc: woodbri@…

Description

On MS 4.01, we were able to create a layer in the mapfile for a user marker and
then in perl/mapscript you could set the position, text and the imagepath and
draw the symbol on the image. This could be repeated for any number of locations
and each location could have a unique imagepath set for it.

It seems this behavior changed, maybe on 4.4.0, where the symbol image seems to
be cached. You can change the imagepath, but the image that gets added to the
map image is always the default one that is contained in the mapfile.

Talking with Sean Gillies, it seems that we need to add a new method call that
will allow you to change the imagepath on a symbol that will also replace the
cached image. Just adding new symbols dynamically will cause you to hit the
MAXSYMBOL limit in map.h so that is not a work-a-round.

Change History (12)

comment:1 by sgillies@…, 19 years ago

From a thread on mapserver-users:

> 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.

comment:2 by sgillies@…, 19 years ago

Cc: steve.lime@… added
I don't think I'll be able to get to this any time soon. As I said at the
conference this summer, I am pretty much finished with my work on mapscript and
moving on to being a user and developer of the C part of mapserver only.

Since the actual bug part of this is in the C lib (symbol caching), I'm cc'ing
Steve Lime. Please consider creating a new bug in that component to track the
symbol caching issue.

comment:3 by sdlime, 19 years ago

Status: newassigned
There are a couple of types of image caching going on in MapServer. The symbol
drawing code has a built in cache for use when tiles, markers or brushes are
generated dynamically. For PIXMAP symbols that is not the case. They are never
cached like that- there's no need.

So, I assume we're talking about the image that is part of a symbol object.
That's not a cache per se...

Steve: can you provide a test script that shows the problem? How exactly are you
swapping the symbol? Originally you could do something like:

  $class->{symbol} = 'myfavorite.gif';
  ...draw...
  $class->{symbol} = 'myotherfavorite.gif';

Is that what you're trying? I'm not sure why imagepath is being refered to here
it was never intended to be used for anything more than bookeeping.

In fact I didn't think symbolObj's were exposed via MapScript until just recently.

Regardless seems like a method like setImagepath would do the trick. It would
clear any previous image (set symbol->type to PIXMAP?), free the previous
imagepath, set a new imagepath and load the new image. Correct?

Steve

comment:4 by sdlime, 19 years ago

Owner: changed from sgillies@… to sdlime
Status: assignednew
Taking from Sean...

comment:5 by sdlime, 19 years ago

Status: newassigned
Steve: I did commit a new method to the shapeObj API list night. It's called 
setImagepath and it takes a filename as a parameter. It's basically a wrapper 
for msGetImageSymbol. I modified that function to clean up any previously 
allocated img and imagepath values so it should not leak memory. Please give 
that a try. Sean, assuming this works we should mark imagepath as immutable in 
mapsymbol.h correct?

Steve

comment:6 by sdlime, 19 years ago

Cc: mapserver-bugs@… added
Ok, I've got confirmation from Steve that the fix indeed works. I can back port
to 4.6 if necessary. I'll also mark imagepath as immutable in mapsymbol.h. I've
included the DM guys so they can add the same method to PHP mapscript...

The new method is very simple, it extends the symbolObj and looks like:

int setImagepath(constant char *filename) {
  return msLoadImageSymbol(self, filename);
}

Steve

comment:7 by assefa, 19 years ago

Added method in php.

comment:8 by sdlime, 19 years ago

Component: MapScript-SWIGMapServer Documentation
Owner: changed from sdlime to kgeurts@…
Status: assignednew
Changing to a documentation bug at this point. Implemented successfully in both
SWIG and PHP MapScript.

Steve

comment:9 by sdlime, 19 years ago

Assigning to doc owner...

comment:10 by kgeurts@…, 19 years ago

Owner: changed from kgeurts@… to nacional@…
Re-assigning to Perry, he will be taking on my old responsibilities.

comment:11 by kgeurts@…, 19 years ago

Re-assigning to Perry, he will be taking on my old responsibilities.

comment:12 by nacional@…, 19 years ago

Resolution: fixed
Status: newclosed
Sorry I didn't catch this earlier.  MapScript API Reference has been updated.

Note: See TracTickets for help on using tickets.