Opened 20 years ago

Closed 15 years ago

#762 closed defect (fixed)

[PHP MapScript] Add mapObj::insertLayer and mapObj::removeLayer

Reported by: dmorissette Owned by: aboudreault
Priority: high Milestone: 5.4 release
Component: MapScript-PHP Version: 4.3
Severity: normal Keywords:
Cc: jmckenna, dmorissette

Description (last modified by dmorissette)

In bug #759, mapObj::insertLayer and mapObj::removeLayer were added to SWIG MapScript.

They need to be added to PHP MapScript as well.

Attachments (4)

php_mapscript.c.diff (2.8 KB ) - added by armin 16 years ago.
php_mapscript.h.diff (843 bytes ) - added by armin 16 years ago.
mapscript_i.c.diff (474 bytes ) - added by armin 16 years ago.
bug762.patch (6.9 KB ) - added by aboudreault 15 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by dmorissette, 20 years ago

Milestone: 4.4 release

comment:2 by sgillies@…, 20 years ago

Cc: sgillies@… removed

comment:3 by dmorissette, 19 years ago

Milestone: 4.4 releaseFUTURE
We've got ms_newLayerObj() already to add layers, and status MS_DELETE to remove
them, so this is low priority. Setting FUTURE target milestone.

comment:4 by dmorissette, 16 years ago

Description: modified (diff)

A question about the missing removeLayer() came up on the -users list today. Here is an exceprt from my reply explaining why we never addressed this ticket:

"... then I started to wonder why we never implemented removeLayer(), and it came back to me that removeLayer() returns a standalone layerObj that's decoupled from the mapObj and can even be reinserted into the map at another location later on with insertLayer(). Without looking into this in any detail, it sounds like adding this may be more involved than just adding a new method since PHP MapScript doesn't allow decoupling objects like this at the moment. That and the fact that there are simpler alternatives to do the same thing (i.e. setting status MS_DELETE) probably explains why we never did it."

comment:5 by dmorissette, 16 years ago

Description: modified (diff)

comment:6 by assefa, 16 years ago

Cc: jmckenna added

add insertLayer r7574. README and online php mapscript doc updated.

comment:7 by armin, 16 years ago

I do not really understand why it's not possible to also add a 'removeLayer' method. Setting the layer status to MS_DELETE is in most cases not working as workaround. The layers still appear in the layers list and have an index, they still appear in WMS capabilities responses.

Defining the removeLayer method was quite straightforward. If you want to include it in a new Mapscript version I can send you the patch.

I have not understood the problem of 'decoupled layers'. If I remove a layer I get a valid layer object back, I can modify its properties and reinsert it into the map object, I have not experienced any problems for this. Anyway, the purpose of removing a layer is normally not to continue to use this layer but to have it completely removed from the map object. In my opinion it's also a cleaner approach than trying to work with statuses.

comment:8 by dmorissette, 16 years ago

Cc: dmorissette added
Milestone: FUTURE5.4 release
Owner: changed from mapserverbugs to aboudreault

Armin, please attach your patch and we'll have a look.

by armin, 16 years ago

Attachment: php_mapscript.c.diff added

by armin, 16 years ago

Attachment: php_mapscript.h.diff added

by armin, 16 years ago

Attachment: mapscript_i.c.diff added

comment:9 by aboudreault, 16 years ago

The patch looks good and it works. I simply added a condition in the removeLayer fonction to ensure that the layer index passed in argument is a long. (otherwise... a null or a string parameter could be converted in a long and the wrong layer will be removed). I'll join the official patch for trunk.

Thanks armin!

by aboudreault, 15 years ago

Attachment: bug762.patch added

comment:10 by aboudreault, 15 years ago

Resolution: fixed
Status: newclosed

Committed to SVN trunk r8134

Note: See TracTickets for help on using tickets.