Setting attributes of shapes on php-mapscript

Francesco Antognini fantognini at GMAIL.COM
Tue Jul 17 08:11:30 PDT 2007


Thanks for all the replies.

Calling $shp->initValues() generates this error

Fatal error:  Call to undefined method ms_shape_obj::initValues() in
C:\ms4w\Apache\htdocs\test\test-ms_caplib.php  on line 151

Checking the php_mapscript.dll extension reveals that both initValues
and setValues are not defined. So php does not support them.

Using the dbf tables is a kind of a last resort approach, since the
attributes must be generated dynamically for each user (specifications
are still sketchy so I can't be more precise). That implies creating
temporary dbf tables and shape files, which is not ideal.

The other idea I have is to build a module in a different language
(java) just to perform the requested functionality and then let php
call it when needed. Php can invoke java classes and java seems to
support both initValues() and setValues(). However even this approach
is less than perfect as it requires additional stuff to be installed
and may well present other unexpected pitfalls.

Is there any hope that one day php mapscript will be updated ?
(shpeobj::clone is missing too...)

Thanks for the help.
F.Antognini

On 7/17/07, Daniel Morissette <  dmorissette at mapgears.com> wrote:
> I'm not sure about SWIG MapScript, but in PHP MapScript, the
> shape->values[] array is read-only and there is no way to set the
> values[] with PHP MapScript.
>
> If working with a shapefile then the recommended way to update
> attributes is to use the PHP dbase functions as was pointed out in
> another post earlier in this thread.
>
> Daniel
>
>
> Rodrigo Del C. Andrade wrote:
> >    Hi.
> >
> >    As of mapscript 4.10 you need to initialize the shapes to receive
> > values.
> >    try issuing a
> >
> >    $shp->initValues(1);
> >
> >    before setValue. The int argument is the number of values you will
> > set in that shape.
> >    I know this was changed for the SWIG versions of mapscript, I am not
> > sure about it on the PHP front, but someone will correct me if its not
> > the case.
> >
> >    Cheers,
> >
> >    Rodrigo
> >
> >
>
>
> --
> Daniel Morissette
>   http://www.mapgears.com/
>



-- 
Francesco Antognini
Computer Consultant
Switzerland
 fantognini at gmail.com



More information about the MapServer-users mailing list