Opened 12 years ago

Last modified 12 years ago

#4235 new defect

make shapeObj leaner

Reported by: tbonfort Owned by: sdlime
Priority: low Milestone: FUTURE
Component: MapServer C Library Version: svn-trunk (development)
Severity: normal Keywords:
Cc: sdlime, dmorissette, aboudreault

Description (last modified by tbonfort)

The shapeObj structure is used in multiple places as a placeholder for geometries only, it's other members (values, tileindex, etc... ) being unnecessary.

In the labelcache and rendering phase these shapeObjs are copied around and allocated, and we might gain a bit of performance and memory allocations if these places in the code used a leaner object for storing geometries.

We could rename the actual shapeObj to featureObj, and use a trimmed down version of shapeObj where only the actual geometry is used. Example structs could be:

struct {
  lineObj *line;
  int nlines;
  int type;
  rectObj bounds;
} shapeObj;

struct {
  shapeObj shape;
  char *text;
  int layerindex;
  /* ... etc ... all values from current shapeObj */
} featureObj;

Change History (3)

comment:1 by tbonfort, 12 years ago

Cc: dmorissette added

Not sure what the backwards incompatibility will be in mapscript. Daniel, are shapeObjs exposed to mapscript and used extensively?

comment:2 by tbonfort, 12 years ago

Description: modified (diff)

comment:3 by dmorissette, 12 years ago

Cc: aboudreault added

The short answer is that yes, shapeObj's and their member variables are exposed and used by MapScript scripts, so there would be a side-effect to this change. See: http://mapserver.org/mapscript/php/index.html#shapeobj and http://mapserver.org/mapscript/mapscript.html#shapeobj

However, I do see the value behind your suggested change so I wonder if we could provide some kind of compatibility layer for old MapScript scripts.

For instance, we could get rid of shapeObj completely and instead adopt new geometryObj and a featureObj types with support for all the methods that used to be provided with the shapeObj class:

struct {
  lineObj *line;
  int nlines;
  int type;
  rectObj bounds;
} geometryObj;

struct {
  geometryObj geom;
  char *text;
  int layerindex;
  /* ... etc ... all values from current shapeObj */
} featureObj;

And then each flavor of MapScript could provide some kind of wrapper shapeObj interface to accommodate old scripts. We would document that the old shapeObj class and methods are deprecated and encourage scripts to switch to the new featureObj/geometryObj classes.

I am confident that this wrapper interface for shapeObj would be possible with PHP MapScript (adding Alan to get his feedback), but am not sure how hard it would be for SWIG (hopefully Steve can comment on the SWIG side of things).

Note: See TracTickets for help on using tickets.