MapServer / MapServer-import

3 stars 2 forks source link

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

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: fantognini Date: 2007/07/18 - 17:31 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.[[BR]] 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[[BR]] Francesco

tbonfort commented 12 years ago

Author: dmorissette Date: 2007/07/18 - 21:37 Let's see if we'll have time to get this in 5.0

tbonfort commented 12 years ago

Author: dmorissette Date: 2007/08/01 - 19:42 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 dc3f0d64a86a780e565d60fd7d48d13a305c5cf3 (r5118) that always allocated 4 values, and then in 93fb684f7bc4be318e3fb2cf82e6c6c3f1831b00 (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.

tbonfort commented 12 years ago

Author: tamas Date: 2007/08/02 - 12:43 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.

tbonfort commented 12 years ago

Author: dmorissette Date: 2007/08/06 - 19:47 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.