Annotation trouble within mapscript
Sean Gillies
sgillies at FRII.COM
Wed Mar 2 14:39:00 PST 2005
On Mar 2, 2005, at 3:32 PM, Jean-Denis Giguere wrote:
> Hi !
>
> I have trouble with an annotation layer using python mapscript.
>
> This layer is drawn without trouble using mapserv cgi. I have no error
> message when I try to draw it with mapscript, but I get no label. The
> annotation layer is routesEti. Following the related part of the script
> and mapfile.
>
> Any hint would be really appreciated.
>
> Regards,
>
> Jean-Denis
>
> *** Script
>
> #Mapfile
> mapfile = "../../mapserv/mapfile/sbk-demo.map"
>
> #La cartographic object
> carto = mapscript.mapObj(mapfile)
>
> #Map
> carte = carto.prepareImage()
>
> #Layer to draw
> aAfficher = []
> aAfficher.append("routes")
> aAfficher.append("rivieres")
> aAfficher.append("batiments")
> aAfficher.append("parcs")
> aAfficher.append("routesEti")
>
> for nm in aAfficher:
> layer = carto.getLayerByName(nm)
> layer.status = mapscript.MS_ON
> layer.draw(carto, carte)
>
> #Name of map
> prefix = "/home/data/www/geodemo/tmp/"
> nomCarte = carto.name
> nomFichCarte = '%s%s.%s' % (prefix, nomCarte,
> carto.outputformat.extension)
>
> #Write map
> carte.save(nomFichCarte)
>
> #Access file
> accesCarte = "/tmp/%s.%s" % (nomCarte, carto.outputformat.extension)
>
> ***
>
> *** Mapfile
>
> LAYER
> NAME "routesEti"
> CONNECTIONTYPE postgis
> CONNECTION "dbname=sbk-demo"
> DATA "wkb_geometry from (SELECT nom_rue, gen_rue,
> collect(wkb_geometry) as wkb_geometry FROM troncons GROUP BY nom_rue,
> gen_rue) as foo using SRID=32187 using unique nom_rue"
> STATUS ON
> TYPE annotation
>
> METADATA
> "wms_title" "Routes"
> END
>
> #CLASS
> # EXPRESSION ( '[vitesse]' = '80')
> # NAME "Voie rapide"
> # STYLE
> # END
> #END
> CLASS
> NAME "Boulevards"
> EXPRESSION ( '[gen_rue]' = 'BOULEVARD')
> #TEXT ([nom_rue])
> TEXT "Boulevard"
> LABEL
> ANGLE auto
> ANTIALIAS true
> POSITION auto
> TYPE truetype
> FONT 'vera-bold'
> SIZE 8
> BUFFER 4
> END
> END
> CLASS
> NAME "Routes"
> TEXT ([nom_rue])
> LABEL
> ANGLE AUTO
> TYPE truetype
> FONT 'vera'
> SIZE 8
> OFFSET -6 -6
> BUFFER 4
> END
> END
> END
>
> ***
>
>
Jean-Denis,
If you do not use mapObj.draw(), you must explicitly draw the label
layer after you have drawn your thematic layers. Add the following
line
carto.drawLabelCache(carte)
to your code before you output the image.
cheers,
Sean
--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies
More information about the MapServer-users
mailing list