[mapserver-users] PHP_Mapscript swig issue on macOS.

Paul Moen pmoen at offroadsoftware.com
Mon Aug 26 14:45:10 PDT 2019


I am running into an error after trying Mapserver 7.4.1 on macOS 10.14 mojave with the php swig version of mapscript.

Here is the output from php -i when I am using php_mapscriptng.so

PHP Version => 7.3.8

mapscript

MapServer Version => MapServer version 7.4.1 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=ICONV SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=GEOS SUPPORTS=PBF INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE

I have a simple mapfile called test.map as follows.

MAP
	NAME TEST
	EXTENT 1026879.6641881098 54774.288373764844 2999091.3458675575 1331032.7378794178
	SIZE 978 517
	MAXSIZE 3072
	UNITS FEET
	SHAPEPATH ""
	IMAGECOLOR 240 240 240
	IMAGETYPE png
	CONFIG "MS_ERRORFILE" "stderr"
	# DEBUG 5
	SYMBOLSET "symbols.dat"
	FONTSET "fonts.list"

	PROJECTION
		"init=epsg:2266" # ND State Plane - South Zone - NAD83 - feet
	END

	LAYER
		NAME "Counties"
		STATUS ON
		TYPE POLYGON
		DATA counties
		CLASS
			NAME "County Boundaries"
			STYLE
				WIDTH 4.0
				MAXWIDTH 6.0
				OUTLINECOLOR 0 0 0
			END
		END
		
	END # Counties - Lines

	LAYER
		NAME "a_Counties"
		STATUS ON
		TYPE POLYGON
		DATA counties
		LABELITEM "name_caps"
		CLASS
			NAME "Label"
			LABEL
			  COLOR  150 150 150
			  OUTLINECOLOR 255 255 255
			  FONT mon
			  TYPE TRUETYPE
			  SIZE 10
			  POSITION AUTO
			END
		END
	END
END 

I create 3 pngs using 3 methods.

1. shp2img -m test.map > shp.png

For the next 2 I have enable_dl = On in my php.ini file so I can dynamically load the 
php_mapscript of my choice in the scripts.

2. To test php_mapscript, no swig, I use the following in a script called testOrig.php.
<?php
	dl('php_mapscript.so');
	$map= new mapObj('test.map');
	$name = "orig.png";
	$img = $map->draw();
	$img->saveImage($name);
?>
I call with the following,
php -f testOrig.php
It outputs the png file named orig.png

Both methods 1 and 2 output png files that are exactly the same.

3. To test php_mapscript via swig, I use the following in a script called testSwig.php.

<?php
	dl('php_mapscriptng.so');
	require('mapscript.php');
	$map= new mapObj('test.map');
	$name = "swig.png";
	$img = $map->draw();
	$img->save($name);	
?>
I call with the following,
php -f testSwig.php
It should output swig.png, but gives the following error.

msGetFontFace(): General error message. Freetype was unable to load font file "/Volumes/Data/WebServer/newswc/mapfiles/././Montserrat-Regular.ttf" for key "mon"
PHP Fatal error:  Uncaught Error: Call to a member function save() on null in /Volumes/Data/WebServer/newswc/mapfiles/testSwig.php:7
Stack trace:
#0 {main}
  thrown in /Volumes/Data/WebServer/newswc/mapfiles/testSwig.php on line 7

Fatal error: Uncaught Error: Call to a member function save() on null in /Volumes/Data/WebServer/newswc/mapfiles/testSwig.php:7
Stack trace:
#0 {main}
  thrown in /Volumes/Data/WebServer/newswc/mapfiles/testSwig.php on line 7

My fonts.list is a one liner, shown below with the font in the same directory as the mapfile.

mon	Montserrat-Regular.ttf

The map draws fine and the png is created if I take out the label.  The map will not work with any truetype font I have tried.  
How can I get more information regards to the freetype error that only happens with the swig version of mapscript?  

Thanks,





More information about the mapserver-users mailing list