Opened 17 years ago

Last modified 15 years ago

#2016 assigned enhancement

Cannot add attributes to a new ShapeObj — at Version 6

Reported by: franck@… Owned by: sdlime
Priority: high Milestone: 6.0 release
Component: MapScript Version: 4.6
Severity: minor Keywords:
Cc: dmorissette

Description (last modified by dmorissette)

From the documentation it seems that the shapeObj member values (which is an
array) is read-only.
I have not found any function that allows to add attributes to a shapeObj which
can be added to a shapefileObj and then saved.

Such enhancement would allow to fully create new layers inside Mapscript.

Change History (6)

comment:1 by fwarmerdam, 17 years ago

Cc: warmerdam@… added

comment:2 by sdlime, 17 years ago

One thing to keep in mind is that MapScript does not contain much in the way of 
attribute handling for shapefiles for a reason. It's that there are simply 
better tools out there for manipulating XBase files. Each scripting language 
has one of these. So for shapefiles you end up only populating the spatial 
portion of the shapeObj with MapScript and using the other tool for the 
attributes. Seems awkward though but works ok in practice.

Could you describe the use case you're thinking about?

Steve

comment:3 by fwarmerdam, 17 years ago

Steve,

Franck and I discussed a bit about this in irc, and I think the rationale
for this report was the ability to create inline features with attributes
from mapscript.   Is this supported?  I seems desirable to me to be able
to create "full featured" inline features for some purposes but Franck
and I couldn't see any way of attaching regular attributes to inline 
features. 


comment:4 by szekerest, 17 years ago

Cc: szekeres.tamas@… added
Before 4.10 shapeObj have allocated 4 predefinied values that could be used
through getValue and setValue by index. We have discovered that this solution
may lead to memory corruption in some cases related to:
http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=1801

So this behaviour was modified so that initValues should be explicitly called
passing the expected number of the attributes. After that, getValue and setValue
can be used as usual.

So creating inline features with attributes is supported now.

Tamas

comment:5 by sdlime, 17 years ago

Thanks for the clarification. That was Sean's area of expertise and I hadn't 
payed that close of attention. Has anyone tested classifications and such based 
on those attributes?

Steve

comment:6 by dmorissette, 17 years ago

Description: modified (diff)
Milestone: 5.2 release

I don't think layer classification and labelling using values set by initValues()/setValues() works yet (see http://trac.osgeo.org/mapserver/ticket/2161#comment:3)

So the real issue of this bug remains: we need to define a usable mechanism to set attribute values on an inline shape that works with layer classification and labelling.

Once something is in place for SWIG MapScript please update ticket #2161 so that we port the same thing to PHP MapScript.

Note: See TracTickets for help on using tickets.