[Fwd: Re: [UMN_MAPSERVER-USERS] symbols in mapfile or symbolset file?]

Dolf Andringa dolf.andringa at ELCYION.NL
Fri Jan 12 07:18:57 EST 2007


Ok, I have got it to work with a workaround. It is not very clean, but 
it works :)
I first write the mapObj to a file
Then I read that file with python
I remove the last END statment
and then I add all symbol statements to it.
I add the END statement again at the end of the file and write it to 
disk again. Then I create a new mapObj from that mapfile.

Script:

mpobj.save("tmp.map")
lines=open("tmp.map",'r').readlines()
lines[-1]=""
for s in symbols:
	lines.append(s)
lines.append("\nEND\n")
open("tmp.map",'w').writelines(lines)
mpobj=mapscript.mapObj("tmp.map")


The symbols variable is a list of strings where each string is a symbol 
definition like:
SYMBOL
  NAME 'point5'
  TYPE ELLIPSE
  FILLED FALSE
  POINTS
   5.0 5.0
  END
END


I know, it is not very clean but it works for now. I am really open to 
better ways of doing this. :) Thanks,

Dolf.

Dolf Andringa schreef:
> Nicol showd be the link below as an answer to my question, which it 
> would be if I was using PHPMapscript, but I am using the python 
> mapscript module. the nomal mapscript API 
> (http://mapserver.gis.umn.edu/docs/reference/mapscript/index_html) does 
> not seem to offer this possibility. Is that correct? To me it would be 
> very logical if you could just create a mapObj, then create symbolSetObj 
> and then some symbolObj's, add the symbolObj's to the symbolSetObj and 
> add the symbolSetObj to the mapObj. Just like you can create classObj's, 
> add them to layerObj's, and add layerObj's to a mapObj. I am trying this 
> to circumvent the problem I posted yesterday with the strange parsing 
> error when adding a symbolset file to a mapObj.
> Hope somebody can help me with either of the problems.
> 
> Dolf.
> 
> Nicol Hermann schreef:
>> Dolf,
>>
>> you can add symbols to the mapObj via mapscript. See e.g.
>> http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/symbolobj 
>>
>>
>> HTH Nicol
>>
>> Am Donnerstag, den 11.01.2007, 14:07 +0100 schrieb Dolf Andringa:
>>> Yeah I know. THe question is just where I define them. When you 
>>> normally use mapfiles you create a separate symbolset file with your 
>>> symbol definitions and in the mapfile in the map description you add 
>>> "symbolsetfile <filename>" or you directly put the symbol 
>>> descriptions in the map description instead of in a separate file.
>>>
>>> I am not writing mapfiles though, I am creating maps using mapscript 
>>> (and directly draw them). And mapscript does not give you the option 
>>> to add symbols to the mapObj, it just gives you the possibility to 
>>> add a separate symbolSet file to the mapObj. That is my point. When I 
>>> manually write mapfiles, I have the option to either define my 
>>> symbols directly in the map  description or in a separate file and 
>>> reference that from the map description. With mapscript I do not have 
>>> that option.
>>>
>>> Dolf
>>>
>>> Kai Behncke schreef:
>>>> On Thu, 11 Jan 2007 13:28:59 +0100, Dolf Andringa wrote
>>>>> sorry, meant to send it to the mailinglist, not just Kristian.
>>>>>
>>>>> -------- Originele bericht --------
>>>>> Onderwerp: Re: [UMN_MAPSERVER-USERS] symbols in mapfile or 
>>>>> symbolset file?
>>>>> Datum: Thu, 11 Jan 2007 13:28:13 +0100 Van: Dolf Andringa
>>>> <dolf.andringa at elcyion.nl>
>>>>> Aan: Thy, Kristian <Kristian.Thy at ATKINSGLOBAL.COM>
>>>>> Referenties: 
>>>>> <CE2BE61DABB9384A934BD4E648DFDA37B7E86D at EXCVS1.rdg.bane.dk>
>>>>>
>>>>> Ok,thanks. I don't think it is possible to do this with mapscript 
>>>>> though
>>>>> is it? It would be nice if there was an addSymbol method on the 
>>>>> mapObj object in mapscript which allows you to add symbols to the 
>>>>> map declaration. Or am I completely missing something?
>>>>>
>>>>> Dolf.
>>>> Hi Dolf,
>>>> normally you need to define symbols by yourself, or you use code 
>>>> that other
>>>> user have produced.
>>>>
>>>>
>>>> One example to define it inside a mapfile:
>>>>
>>>> SCALEBAR
>>>>   STATUS embed
>>>>   TRANSPARENT off
>>>>   INTERVALS 4
>>>>   SIZE 200 3
>>>>   UNITS kilometers
>>>>   COLOR 250 250 250
>>>>   OUTLINECOLOR 0 0 0
>>>>   BACKGROUNDCOLOR 100 100 100
>>>>   STYLE 0
>>>>   POSTLABELCACHE true
>>>>   LABEL
>>>>     COLOR 0 0 90
>>>>     #OUTLINECOLOR 200 200 200
>>>>     SIZE small
>>>>   END  END 
>>>>
>>>>
>>>> # SYMBOLS USED IN PMAPPER
>>>> # - 'circle' always necessary (used e.g. for highlight)
>>>> # - 'square' used in currecnt map file
>>>> # Symbols can also be defined via tag SYMBOLSET (see above)
>>>> Symbol
>>>>   Name 'circle'
>>>>   Type ELLIPSE
>>>>   Filled TRUE
>>>>   Points
>>>>     1 1
>>>>   END
>>>> END
>>>>
>>>> Symbol
>>>>   Name 'square'
>>>>   Type VECTOR
>>>>   Filled TRUE
>>>>   Points
>>>>     0 1
>>>>     0 0
>>>>     1 0
>>>>     1 1
>>>>     0 1
>>>>   END
>>>> END
>>>>
>>>>
>>>> #================== START OF LAYER SECTION =====================#
>>>>
>>>>
>>>> LAYER
>>>>   NAME "jpl_wms_global_mosaic"
>>>>   TYPE RASTER
>>>>   STATUS OFF
>>>>   CONNECTION
>>>> ............
>>>>
>>>>
>>>>
>>>> But in my opinion, if you have quite a lot symbols:
>>>> Use the symbolfile for it. Its cleaner,
>>>> Regards, Kai
>>>>
>>>>
>>>>
>>>> --------------------
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Dipl.-Geogr. Dipl.-Umweltwiss. Kai Behncke
>>>>
>>>> Institut für Geoinformatik und Fernerkundung (IGF)
>>>> Universität Osnabrück
>>>> Kolpingstr. 7
>>>> 49074 Osnabrück
>>>>
>>>> Raum: 01/308
>>>> Tel.: +49 541 969-4450
>>>> E-Mail: mailto:kbehncke at igf.uni-osnabrueck.de Web:  
>>>> http://www.igf.uni-osnabrueck.de
>>>
>>
> 



More information about the mapserver-users mailing list