Opened 17 years ago

Last modified 15 years ago

#2161 new enhancement

Php-mapscript does not implement setValue(), initValue()

Reported by: fantognini Owned by: mapserverbugs
Priority: normal Milestone: 6.0 release
Component: MapScript-PHP Version:
Severity: normal Keywords:
Cc: dmorissette, assefa, sdlime, tamas

Description

Dealing with the ms4w version of mapscript php, I found out that the following ShapeObj methods are not implemented in the extension dll php_mapscript.dll.

* initValues( int numvalues ) : void
* setValue( int i, string value ) : int

As far as I know this is not an issue specific to ms4w. Also, other languages (java) seem to support those methods.

It's a functionality that becomes useful when dealing with non tabular data sources, for instance web services. The usual workaround is to create a temporary table (dbf) and shape file. However it is a rather cumbersome approach especially if a new table has to be created for each web server request.
Setting attributes directly would simplify the process and likely make it faster.

As a side note, other methods of ShapeObj seem to be missing and would be nice to have:

* clone() : shapeObj
* copy( shapeObj shape_copy ) : int

Thanks
Francesco

Change History (6)

comment:1 by dmorissette, 17 years ago

Cc: dmorissette assefa added
Milestone: 5.0 release

Let's see if we'll have time to get this in 5.0

comment:2 by dmorissette, 17 years ago

Cc: sdlime tamas added
Milestone: 5.0 release5.2 release

Pushing to 5.2.

Can Francesco or someone else please explain the way those methods work in real life? I presume these methods are mostly (only?) useful when creating inline shapes on a layer?

I see that Steve initally wrote code in r5118 that always allocated 4 values, and then in r5577, Tamas replaced that default allocation of 4 values with an initValues().

How are the values set using those methods intended to be used by MapServer? How do you tell MapServer the attribute name that corresponds to each value?

I think we need to clarify the usage scenario before we port those methods to PHP MapScript.

comment:3 by tamas, 17 years ago

My opinion about the expected usage has been described in the 4.8->4.10 migration guide:

"When constructing a new shapeObj 4 predefined values were implicitly created that could be accessed and modified using getValue and setValue. Using this shape as a parameter of other functions like layerObj.getShape might result in memory leak.So as to allow explicit creation of the values the shapeObj.initValues was introduced. The user can initialize arbitrary number of the values and use getValue and setValue to access them."

Related bugs: #1801 #2016

The initValues have been intruduced so that the user can continue to set and get the values in their scripts. Currently these values can be used only for preserving strings along with the shapes. However we should provide these values to participate in the renderings (using annotation etc.) as well. In this regard at least the support for LayerInitItemInfo is still missing for the inline layers. The inline layers should accept the attribute names in the same order as the values have been set, and later copy the values according to the correct order expected by the WhichShapes function.

comment:4 by dmorissette, 17 years ago

Thanks for the clarifications Tamas.

It seems that the current initValues/setValues won't allow you (Francesco) to use the shape attributes in an inline layer so there is no point in porting them to PHP now. The issue of defining an acceptable mechanism to set values in inline shapes so that they can be used for classification or labelling is already the object of ticket #2016.

We'll keep the current ticket open to port to PHP whatever comes out of #2016.

comment:5 by dmorissette, 16 years ago

Milestone: 5.2 release5.4 release

comment:6 by dmorissette, 15 years ago

Milestone: 5.4 release6.0 release
Note: See TracTickets for help on using tickets.