[MS4W-Users] Missing functions/attributes in MapScript (PHP)
Jeff McKenna
jmckenna at gatewaygeomatics.com
Fri Jan 28 18:55:53 UTC 2022
Hi Jens,
Thank-you for the complements.
In the MS4W 5.0-beta2 announcement I mentioned that I had created a
Migration Guide on the wiki, that I recommend that you take the time to
go through in detail: https://ms4w.com/trac/wiki/MigrationGuide5.x
There you will find a section on SWIG MapScript, that also includes 4
working PHP scripts for MS4W 5.0-beta2, with a note about changes to
setting metadata using the new hashTableObj way. I also now added a
working example for *getting* a metadata value (see the last 'echo'
command below), such as:
<?php
//set metadata using the new 'metadata' hashTableObj keys and value
directly
$oWMSLayer->metadata->set("wms_name", "popplace");
$oWMSLayer->metadata->set("wms_title", "Cities");
$oWMSLayer->metadata->set("wms_srs", "EPSG:3978");
$oWMSLayer->metadata->set("wms_server_version", "1.1.1");
$oWMSLayer->metadata->set("wms_format", "image/png");
//get metadata using the new 'metadata' hashTableObj keys directly
echo $oWMSLayer->metadata->get("wms_title");
?>
As always, I kindly ask you that you add to that wiki page, by adding
your examples and notes so others can learn from your tips. (it's a wiki
on purpose, to hopefully get everyone editing it and adding migration
examples, as you modify your mapfiles for MS4W 5.0).
I hope this brings you out of the 'darkness', ha, and that you have a
nice, quiet weekend.
Thank-you for using MS4W.
"MS4W: open doors as well as windows"
-jeff
--
Jeff McKenna
GatewayGeo: Developers of MS4W, MapServer Consulting and Training
co-founder of FOSS4G
http://gatewaygeo.com/
On 2022-01-28 6:48 a.m., Gramenz, Jens via MS4W-Users wrote:
> Dear list and especially dear Jeff,
>
> thank you for creating and supporting MS4W. Although MS4W doesn't
> completely fit our demand, it is marvelous how easy it is to set it up. :)
>
> I wanted to have a look at the new Mapserver/PHP-Combo and tried to make
> one of our projects work with it. After fixing some deprecations here
> and there, I encountered some difficulties with MapScript I was not able
> to circumvent. :(
>
> When switching to PHP7 I had to include the php_mapscript.dll and (I
> guess that was the SWIG-Version then?!) a mapscript.php.
>
> Sven brought this up in a message in december. This time there is no
> more mapscript.php and if I include the old one it raises an error, that
> the classes are already there, which is plausible. But if I don't it
> seems that there is something (i.e. some functions and attributes [e.g.
> mapObject->numLayers]) missing. But in general MapScript is loaded and
> does work.
>
> Since I wasn't sure if it is a problem with my software setup, I used a
> plain version of MS4W (5beta2) on another machine to reproduce it. Took
> about 5 Minutes to unzip and about 5 seconds to make it work... Wow!
>
> An example to reproduce my problem is to add the following lines to
> quickmap.php at line 20 and comment the rest of the file.
>
> $layer = $oMap->getLayer(0);
>
> echo "Layer: ".$layer->name."<br>";
>
> print_r(get_object_vars($layer->metadata));
>
> echo $layer->metadata->wms_title."<br>";
>
> $layer->getMetaData("wms_title");
>
> Getting the layer and printing the name ("ocean") does work. The
> metadata actually is a hashTableObj, but get_object_vars gives an empty
> array. Directly accessing the attribute just returns NULL. Calling
> getMetaData() like we used to leads to the "Fatal error: Uncaught Error:
> Call to undefined method layerObj::getMetaData()" although is it
> mentioned in both the SWIG and PHP MapScript API.
>
> Don't know if these a bugs or features. =) Could it be that there have
> been some changes in the code that are not yet documented? Maybe one of
> you can bring some light into the darkness?!
>
> Kind regards,
>
> Jens
>
>
> _______________________________________________
> MS4W-Users mailing list
> MS4W-Users at lists.ms4w.com
> https://lists.ms4w.com/mailman/listinfo/ms4w-users
More information about the MS4W-Users
mailing list