GD library error. Invalid bitmap font

Hallgren Johan E jhhal at WMDATA.COM
Tue Oct 31 09:48:51 EST 2006


It wasn't so easy to know but now it works for me to,

MANY THANKS.

Johan

___________________________________


Johan Hallgren

 
WM-data a LogicaCMG company 
Pelle Bergs backe 3
Box 1938, 791 19 Falun
Tel: 023-547 46 (int: +46-2354746)

Mobil: 070-588 44 28 (int: +46-705884428)

johan.e.hallgren at wmdata.com
http://www.wmdata.se

-----Original Message-----
From: UMN MapServer Developers List [mailto:MAPSERVER-DEV at LISTS.UMN.EDU]
On Behalf Of Tamas Szekeres
Sent: den 31 oktober 2006 15:14
To: MAPSERVER-DEV at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-DEV] GD library error. Invalid bitmap font

Johan,

You have created a new labelObj instead of using classObj.label.

Therefore you should replace 'labelObj oLabelObj = new labelObj();'
with labelObj oLabelObj = oClassObj.label;

In addition you should remove 'oMapObj.insertLayer(oLayerObj, -1);' to
prevent from adding the layer to the map twice. The layer has already
been added at the construction of the layer 'layerObj oLayerObj = new
layerObj(oMapObj);'

Best Regards,

Tamas


2006/10/31, Hallgren Johan E <jhhal at wmdata.com>:
> Hello Tamas
>
> Here is a code snippet
>
> **************
> mapObj oMapObj = new mapObj(mapFile.Text);
>
> layerObj oLayerObj = new layerObj(oMapObj);
> oLayerObj.name = "textLayer";
> oLayerObj.type = MS_LAYER_TYPE.MS_LAYER_ANNOTATION;
> oLayerObj.connectiontype = MS_CONNECTION_TYPE.MS_INLINE;
> oLayerObj.status = 1;
> oMapObj.insertLayer(oLayerObj, -1);
>
> classObj oClassObj = new classObj(oLayerObj);
> labelObj oLabelObj = new labelObj();
> oLabelObj.type = MS_FONT_TYPE.MS_TRUETYPE;
> oLabelObj.font = "verdanab";
> oLabelObj.color = new colorObj(120, 220, 10, -4);
> oLabelObj.size = 12;
> oLabelObj.antialias = mapscript.MS_TRUE;
> oLabelObj.encoding = "CP437";
> oLabelObj.maxsize = 256;
> oLabelObj.minsize = 4;
>
> bool isDatabaseCoord = false;
>
> lineObj oLineObj = new lineObj();
> oLineObj.add(getPointObj("50 50", isDatabaseCoord, oMapObj));
>
> shapeObj oShapeObj = new shapeObj((int)MS_SHAPE_TYPE.MS_SHAPE_POINT);
> oShapeObj.add(oLineObj);
>
> string strVal = "Johan Hallgren";
>
> oShapeObj.text = strVal;
>
> oLayerObj.addFeature(oShapeObj);
>
> imageObj i_obj = null;
> i_obj = oMapObj.draw();
> string fn = "c:\\temp\\" + GetTempFileName() + "." +
> i_obj.format.extension;
>
> i_obj.save(fn, oMapObj);
> pictureBox2.Image = Image.FromFile(fn);
> **************
>
> Function used:
> **************
> private pointObj getPointObj(string str, bool isDatabaseCoord, mapObj
> mo)
> {
>         double x;
>         double y;
>         if (!isDatabaseCoord)
>         {
>
>                 GMSAgent_WP.Libs.Envelope currentExtent = new
> GMSAgent_WP.Libs.Envelope(mo);
>
>                 x = currentExtent.FromMapX(Convert.ToInt32(str.Split('
> ')[0]));
>                 y = currentExtent.FromMapY(currentExtent.ImageHeight -
> Convert.ToInt32(str.Split(' ')[1]));
>         }
>         else
>         {
>                 x = GenericIMS_lib.Libs.Utilities.ToDouble(str.Split('
> ')[0]);
>                 y = GenericIMS_lib.Libs.Utilities.ToDouble(str.Split('
> ')[1]);
>         }
>         pointObj oPointObj = new pointObj(x, y, 0, -2e38);
>         return oPointObj;
> }
> **************
>
> On the row i_obj = oMapObj.draw(); I've get the following error.
> msGetBitmapFont(): GD library error. Invalid bitmap font. Must be one
of
> tiny, small, medium, large or giant.
>
>
> This is mu mapfile:
> ***************
> #
> # Start of map file
> #
> MAP
>   NAME WMSE
>   STATUS ON
>         EXTENT 1194973 6083188 1973312 7687503
>         SIZE 600 600
>   UNITS METERS
>   IMAGECOLOR 255 255 255
> #  TEMPLATEPATTERN "itasca"
>   FONTSET "C:\Project\applications\GMS\GMSAgent\MapFiles\fonts.txt"
>         SYMBOLSET
> "C:\Project\applications\GMS\GMSAgent\MapFiles\Symbol\symbolset.sym"
>         SHAPEPATH "C:\Project\DATA\/GIMS"
>         RESOLUTION 200
>         DEBUG OFF
>
>   IMAGETYPE PNG
>
>   #
>   # Start of web interface definition (including WMS enabling
metadata)
>   #
>   WEB
> #    HEADER templates/header.html
>     TEMPLATE "c:\temp\template.txt"
> #    FOOTER templates/footer.html
>     MINSCALE 1000
>     MAXSCALE 1550000
>     IMAGEPATH "set in index.html"
>     IMAGEURL "set in index.html"
>     LOG "c:\temp\ms.log"
>
>   END
>
>   #
>   # Start of legend
>   #
>   LEGEND
>     KEYSIZE 18 12
>     LABEL
>       TYPE BITMAP
>       SIZE MEDIUM
>       COLOR 0 0 89
>     END
>     STATUS ON
>   END
>
>   #
>   # Start of reference map
>   #
>
>   #
>   # Start of layer definitions
>   #
>
> #  LAYER
> #    NAME sj_large_os
> #    TYPE POLYGON
> #    STATUS OFF
> #    CONNECTION "OCI:tfk/tfk at wmsi1394"
> #    CONNECTIONTYPE OGR
> #    DATA "sj_large_os"
> #    CONNECTION "tfk/tfk at wmsi1394"
> #    CONNECTIONTYPE oraclespatial
> #    DATA "shape from sj_large_os"
> #    TEMPLATE "c:\temp\template.txt"
> #    DEBUG on
> #   CLASS
> #      STYLE
> #        OUTLINECOLOR 0 0 255
> #        COLOR 255 0 0
> #      END
> #    END
> #  END
> #
> #   LAYER
> #    NAME SJ_large_SDE
> #    TYPE POLYGON
> #    STATUS OFF
> #    CONNECTION "wmsi001394,port:5151,wmgis,wmgis,wmgis01"
> #    CONNECTIONTYPE SDE
> #    DATA "SJ_large_sde,shape"
> #    TEMPLATE "c:\temp\template.txt"
> #    DEBUG on
> #    CLASS
> #      STYLE
> #        OUTLINECOLOR 0 0 255
> #        COLOR 255 0 0
> #      END
> #    END
> #  END
> #
> #  LAYER
> #    NAME SJ_large_SDO
> #    TYPE POLYGON
> #    STATUS OFF
> #    CONNECTION "wmsi001394,port:5151,wmgis,wmgis,wmgis01"
> #    CONNECTIONTYPE SDE
> #    DATA "SJ_large_sdo,shape"
> #    TEMPLATE "c:\temp\template.txt"
> #    DEBUG on
> #    CLASS
> #      STYLE
> #        OUTLINECOLOR 0 0 255
> #        COLOR 255 0 0
> #      END
> #    END
> #  END
> #
> #
> #  LAYER
> #    NAME SJ_large_SDO_Direct
> #    TYPE POLYGON
> #    STATUS OFF
> #    CONNECTION "wmgis/wmgis01 at wmsi1394"
> #    CONNECTIONTYPE oraclespatial
> #    DATA "shape FROM (SELECT objectid, shape, KKOD FROM SJ_large_sdo)
> USING UNIQUE OBJECTID VERSION 10g"
> #    TEMPLATE "c:\temp\template.txt"
> #    DEBUG on
> #    CLASS
> #      STYLE
> #        OUTLINECOLOR 0 0 255
> #        COLOR 255 0 0
> #      END
> #    END
> #  END
>
> #  LAYER
> #    NAME Fastigheter
> #    TYPE POLYGON
> #    STATUS OFF
> #    CONNECTION "wfast/wfast at skogdb"
> #    CONNECTIONTYPE oraclespatial
> #    DATA "shape FROM fastighetsytor USING UNIQUE OBJECTID VERSION
10g"
> #    TEMPLATE "c:\temp\template.txt"
> #    MAXSCALE 100000
> #    DEBUG on
> #    CLASS
> #                       MAXSCALE 100000
> #                       MINSCALE 20000
> #      STYLE
> #        OUTLINECOLOR 0 0 0
> #        WIDTH 1
> #      END
> #    END
> #    CLASS
> #                       MAXSCALE 20000
> #      STYLE
> #        SYMBOL dashed
> #        OUTLINECOLOR 240 240 240
> #        WIDTH 2
> #      END
> #    END
> #  END
>
> #  LAYER
> #    NAME "Fastigheter Namnjh"
> #    STATUS ON
> #    CONNECTION "wfast/wfast at skogdb"
> #    CONNECTIONTYPE oraclespatial
> #    DATA "shape FROM fastighetsytor USING UNIQUE OBJECTID VERSION
10g"
> #    TEMPLATE "c:\temp\template.txt"
> #    TYPE POLYGON
> #    MAXSCALE 20001
> #    LABELITEM "FASTIGHET"
> #    CLASS
> #      LABEL
> #                               TYPE truetype
> #                               FONT verdanab
> #                               SIZE 8
> #                               COLOR 240 240 240
> #      END
> #    END
> #  END
>
> #  LAYER
> #    NAME BergvikMark_SDE
> #    TYPE POLYGON
> #    STATUS OFF
> #    CONNECTION "wmsi001394,port:5151,wmgis,wmgis,wmgis01"
> #    CONNECTIONTYPE SDE
> #    DATA "bergvikmark,shape"
> #    TEMPLATE "c:\temp\template.txt"
> #    DEBUG off
> #    CLASS
> #      STYLE
> #        OUTLINECOLOR 0 0 255
> #        COLOR 255 0 0
> #      END
> #    END
> #  END
>
>   LAYER
>     NAME sj
>     TYPE POLYGON
>     STATUS ON
>     DATA vv/sj
>     TEMPLATE "c:\temp\template.txt"
>                 MAXSCALE 750000
>     CLASS
>       STYLE
>         OUTLINECOLOR 0 0 255
>         COLOR 165 250 255
>       END
>     END
>   END
>
>   LAYER
>     NAME sj_large
>     TYPE POLYGON
>     STATUS ON
>     DATA vv/sj_large
>     TEMPLATE "c:\temp\template.txt"
>                 MINSCALE 750000
>     CLASS
>       STYLE
>         OUTLINECOLOR 0 0 255
>         COLOR 165 250 255
>       END
>     END
>   END
>
>   LAYER
>     NAME rsv_hv_grid
>     TYPE POLYGON
>     STATUS ON
>     DATA vv/rsv_hv_grid
>     TEMPLATE "c:\temp\template.txt"
>                 MINSCALE 30000
>     CLASS
>       STYLE
>         COLOR 165 250 255
>       END
>     END
>   END
>
>   LAYER
>     NAME Or
>     TYPE POLYGON
>     STATUS ON
>     DATA vv/Or
>     TEMPLATE "c:\temp\template.txt"
>                 MAXSCALE 300000
>                 MINSCALE 30000
>     CLASS
>       STYLE
>         OUTLINECOLOR 0 130 255
>         COLOR 255 255 255
>       END
>     END
>   END
>
>   LAYER
>     NAME TATYT
>     TYPE POLYGON
>     STATUS ON
>     DATA vv/TATYT
>     TEMPLATE "c:\temp\template.txt"
>                 MAXSCALE 1000000
>     CLASS
>       STYLE
>         OUTLINECOLOR 0 0 0
>         COLOR 210 210 210
>       END
>     END
>   END
>
>   LAYER
>     NAME vdb_m
>     TYPE LINE
>     STATUS ON
>     DATA vv/vdb_m
>     TEMPLATE "c:\temp\template.txt"
>                 MAXSCALE 2000000
>     CLASS
>                         EXPRESSION ([VAEGNR] > 1 AND [VAEGNR] < 100)
>       STYLE
>                                 SYMBOL solid
>                                 SIZE 2
>         COLOR 105 105 105
>       END
>     END
>     CLASS
>                         MAXSCALE 1000000
>                         EXPRESSION ([VAEGNR] >= 100 AND [VAEGNR] <
500)
>       STYLE
>                                 SYMBOL solid
>                                 SIZE 2
>         COLOR 105 105 105
>       END
>     END
>     CLASS
>                         MAXSCALE 1000000
>                         EXPRESSION ([VAEGNR] >= 500)
>       STYLE
>         COLOR 105 105 105
>       END
>     END
>   END
>
>   LAYER
>     NAME Granser
>     TYPE LINE
>     STATUS ON
>     DATA vv/Granser
>     TEMPLATE "c:\temp\template.txt"
>     CLASS
>                         EXPRESSION ([TYP] = 5)
>       STYLE
>               SYMBOL dot
>         COLOR 255 173 0
>         SIZE 2
>       END
>     END
>     CLASS
>                         EXPRESSION ([TYP] = 6)
>       STYLE
>         COLOR 255 173 0
>       END
>     END
>     CLASS
>                         EXPRESSION ([TYP] = 7)
>       STYLE
>         COLOR 255 173 0
>       END
>     END
>     CLASS
>                         EXPRESSION ([TYP] = 8)
>       STYLE
>               SYMBOL solid
>         COLOR 255 173 0
>         SIZE 2
>       END
>     END
>   END
>
>   LAYER
>     NAME vd
>     TYPE LINE
>     STATUS ON
>     DATA vv/vd
>     TEMPLATE "c:\temp\template.txt"
>                 MAXSCALE 500000
>     CLASS
>       STYLE
>         COLOR 0 219 255
>       END
>     END
>   END
>
>   LAYER
>     NAME TATTXT
>     TYPE LINE
>     STATUS OFF
>     DATA vv/TATTXT
>     TEMPLATE "c:\temp\template.txt"
>                 MAXSCALE 1250000
>     LABELITEM "TEXT"
>     CLASS
>       LABEL
>                                 ENCODING CP437
>                                 TYPE truetype
>                                 FONT verdanab
>                                 SIZE 10
>       END
>     END
>   END
>
>   LAYER
>     NAME SMAORTTX
>     TYPE LINE
>     STATUS OFF
>     DATA vv/SMAORTTX
>     TEMPLATE "c:\temp\template.txt"
>                 MAXSCALE 1250000
>     LABELITEM "TEXT"
>     CLASS
>       LABEL
>                                 ENCODING CP437
>                                 TYPE truetype
>                                 FONT verdana
>                                 SIZE 8
>       END
>     END
>   END
>
>         LAYER
>     NAME "Raster, sth"
>     STATUS OFF
>     TILEINDEX "Rasterdata/d3/index.shp"
>     TILEITEM "Location"
>     TYPE RASTER
>   END
>
> END # Map File
> ***************
>
> Good luck
> /Johan
> ___________________________________
>
>
> Johan Hallgren
>
>
> WM-data a LogicaCMG company
> Pelle Bergs backe 3
> Box 1938, 791 19 Falun
> Tel: 023-547 46 (int: +46-2354746)
>
> Mobil: 070-588 44 28 (int: +46-705884428)
>
> johan.e.hallgren at wmdata.com
> http://www.wmdata.se
>
> -----Original Message-----
> From: Tamas Szekeres [mailto:szekerest at gmail.com]
> Sent: den 27 oktober 2006 23:26
> To: Hallgren Johan E
> Cc: MAPSERVER-DEV at lists.umn.edu
> Subject: Re: GD library error. Invalid bitmap font
>
> Would you post a code fragment that adds the text to this layer
inline?
>
> Tamas
>
>
> 2006/10/27, Hallgren Johan E <jhhal at wmdata.com>:
> >
> >
> >
> >
> > Hello
> >
> >
> >
> > In the migration from MapServer 4.8 to mapserver 4.10 I have problem
> when
> > adding text to the Map.
> >
> >
> >
> > This is the error message I've get:
> >
> > msGetBitmapFont(): GD library error. Invalid bitmap font. Must be
one
> of
> > tiny, small, medium, large or giant.
> >
> >
> >
> > A add texts in runtime and as far as I know the only size I set is
> >
> > oLabelObj.size = 12;
> >
> >
> >
> > And I don't use bitmap fonts, I use
> >
> > oLabelObj.type = MS_FONT_TYPE.MS_TRUETYPE;
> >
> >
> >
> > My environment is CSharp, VS 2005.
> >
> >
> >
> > Could anyone give me a hint about what this is all about?
> >
> >
> >
> > /Johan
> > ___________________________________
> > Johan Hallgren
> >
> >
> >
> >
> >
> > WM-data a LogicaCMG company
> >
> >
> > Pelle Bergs backe 3
> >
> >
> > Box 1938, 791 19 Falun
> >
> >
> >
> > Tel: 023-547 46 (int: +46-2354746)
> >
> > Mobil: 070-588 44 28 (int: +46-705884428)
> >
> >
> > johan.e.hallgren at wmdata.com
> >
> >
> > http://www.wmdata.se
> >
> >
>



More information about the mapserver-dev mailing list