[mapserver-users] Migrating to PHP SWIG drawFeature missing

Moen, Paul T. pmoen at nd.gov
Sat Feb 6 07:44:01 PST 2021


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



More information about the MapServer-users mailing list