Hi Paul,

I have recently had to upgrade all of my PHP scripts for several client's applications, to SWIG MapScript, and your fromWKT() note is a common one in all of my scripts too. Good news though: your/our scripts are easily updated for SWIG as follows:


  $map = new mapObj("simple.map");
  $drawLayer = $map->getLayerByName('drawshape1');
  $newshp = new shapeObj(MS_SHAPE_POLYGON);
  $newshp = $newshp->fromWKT($curwkt);

(the issue is that you must first declare the new shape object separately, and then next use that same variable to call & load the WKT)

You're correct that the upcoming release will drop the old native mapscript, so please definitely don't be afraid to jump into existing tickets (such as this one that lists a few missing SWIG functions https://github.com/MapServer/MapServer/issues/1822 ) so we can all work together on making the 8.0 release great.

Thanks for your feedback,

-jeff



--
Jeff McKenna
GatewayGeo: MapServer Consulting and Training Services
co-founder of FOSS4G
http://gatewaygeo.com/



On 2021-02-06 11:44 a.m., Moen, Paul T. wrote:
The ‘native’ PHP MapScript will go away with MapServer 8.  Will all the 
functionality be added to the SWIG PHP MapScript before that happens?  I tried 
the transition with the change to MapServer 7.4 and was unsuccessful do to 
missing pieces (or my lack of knowledge).  Thankfully, others also needed the 
php_mapscript functionality and put forth a tremendous effort to make the 
‘native’ PHP MapScript work with PHP 7.  Thank you to all that were involved 
with that effort.  Here I go again, hoping that I will be able to make the 
transition and I still do not see a path forward.  Of course, just because I 
don’t see a path, doesn’t mean there isn’t one.  That is why I am asking how to 
add a feature to a layer using SWIG PHP MapScript.  The following explains how 
I have done this in the ‘native’ PHP MapScript.
I use a layer called drawshape1 in a mapfile to highlight something on a map by dynamically adding a feature to that layer. LAYER
                 NAME "drawshape1"
                 TYPE POLYGON
                 STATUS ON
                 COMPOSITE
                                 OPACITY 60
                 END
                 CLASS
                                 STATUS ON
                                 NAME "tmpshp1"
                                 STYLE
                                                 COLOR 0 0 255
                                 END
                 END
END
I use a WKT to create the shape that is added to the drawshape1 layer.  This highlights the WKT on the image returned by drawQuery(). $map = new mapObj("simple.map");
$drawLayer = $map->getLayerByName('drawshape1');
$newshp = ms_shapeObjFromWkt($curwkt);
$drawLayer->set('status',MS_ON);
$test = $drawLayer->addFeature($newshp);
$img = $map->drawQuery();
Presumably, I could do the following. $map = new mapObj("simple.map");
$drawLayer = $map->getLayerByName('drawshape1');
$newshp = new shapeObj(MS_SHAPE_POLYGON);
$tmpShape = newshp->fromWKT($curwkt);
$test = $drawLayer->addFeature($newshp); This doesn’t seem to be finished in SWIG mapscript.  I see that in the documentation says TODO. addFeature( https://mapserver.org/mapscript/mapscript.html#shapeobj shape )int
        Add a new inline feature on a layer. Returns -1 on error. TODO: Is this 
similar to inline features in a mapfile? Does it work for any kind of layer or 
connection type?

I could use inline features to accomplish this also.  But this also seems to be 
missing in SWIG PHP mapscript and has a TODO by it.
addFeature( https://mapserver.org/mapscript/mapscript.html#shapeobj shape )int
        Add a new inline feature on a layer. Returns -1 on error. TODO: Is this 
similar to inline features in a mapfile? Does it work for any kind of layer or 
connection type?

Does anyone know how can I replace this functionality?  Will these TODOs be 
done before MapServer 8?  It is difficult to work on the transition when pieces 
are missing.
Thanks, Paul





_______________________________________________
mapserver-users mailing list
mapserver-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to