[mapserver-users] Swig mapscript troubles

Jeff McKenna jmckenna at gatewaygeomatics.com
Wed Jun 24 14:10:07 PDT 2020


Hi Eric!

First sorry for my poorly formatted response, in fact your email never 
made it to my inbox, as the email server for this list is hosted on a 
machine that was recently tagged on a spam 'blacklist' (see 
https://trac.osgeo.org/osgeo/ticket/2475), so I'm piecing together a 
response to you manually ha.

Regarding upgrading to MapScript SWIG, the MapServer migration guide 
actually lists 2 very important points regarding PHP that must now 
always be followed (see 
https://mapserver.org/MIGRATION_GUIDE.html#mapserver-7-2-to-7-4-migration). 


    1) all of your PHP scripts (that leverage MapServer objects and 
functions) must now always first include the generated 'mapscript.php' 
file containing MapServer constants:

        // required SWIG include (contains MapServer constants for PHP7)
        include("C:/ms4w/apps/phpmapscriptng-swig/include/mapscript.php");

    2) take note of the change in how to declare your new objects with 
the "new ..Obj" syntax :

        // open map
        $oMap = new mapObj("C:/ms4w/apps/phpmapscriptng-swig/


Regarding the required file 'mapscript.php', if you are compiling 
MapServer yourself, it will be generated in your build folder alongside 
the generated 'php_mapscriptng.so' (such as in

     /mapserver-master/build/mapscript/phpng/

By odd chance, earlier today I added a working example for how to create 
a new point object (with an inline feature) through PHP mapscript SWIG: 
https://ms4w.com/trac/wiki/SWIGMapScriptNewLayer

The important parts of the example PHP script are:

   <?php

   // define variables
   define( "MAPFILE", "C:/ms4w/apps/phpmapscriptng-swig/sample.map" );

   // required SWIG include (contains constants for PHP7)
   include("C:/ms4w/apps/phpmapscriptng-swig/include/mapscript.php");

   // open map
   $oMap = new mapObj(MAPFILE);

   //******
   // create new point layerObj
   //******
   $oPointLayer = new layerObj($oMap);
   ...

   // draw map
   $oImage = $oMap->draw();

   ?>

Hope that makes a little sense ha!

-jeff



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









More information about the MapServer-users mailing list