Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Mapnik ShieldSymbolizer
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jared  
View profile  
 More options Aug 21 2008, 7:18 pm
From: Jared <jared.erick...@gmail.com>
Date: Thu, 21 Aug 2008 16:18:07 -0700 (PDT)
Local: Thurs, Aug 21 2008 7:18 pm
Subject: Mapnik ShieldSymbolizer
The presentation on Mapnik really got me interested so I started
playing around.  Could anyone point out some good/any documentation or
better yet an example on how to use the ShieldSymbolizer?  Also, where
are the Python API docs?  I am primarily a Java programmer and I can't
find anything resembling JavaDocs for the python bindings.

Thanks!
Jared


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dane Springmeyer  
View profile  
 More options Aug 22 2008, 2:02 pm
From: Dane Springmeyer <dane.springme...@gmail.com>
Date: Fri, 22 Aug 2008 11:02:37 -0700
Local: Fri, Aug 22 2008 2:02 pm
Subject: Re: [CUGOS] Mapnik ShieldSymbolizer

Hi Jared,

Good questions.

I will answer inline...

On Aug 21, 2008, at 4:18 PM, Jared wrote:

> The presentation on Mapnik really got me interested so I started
> playing around.

Great, so you were able to install mapnik without a problem? It would  
be great to know your system and method to get a sense of how you  
faired.

>  Could anyone point out some good/any documentation or
> better yet an example on how to use the ShieldSymbolizer?

Right, the ShieldSymbolizer sounds more tricky that is actually is.  
All is it is kind of a combination of a PointSymbolizer with both text  
and a graphic. A good example of the SheildSymbolizer is the  
OpenStreetMap usage:

http://openstreetmap.org/?lat=47.6611&lon=-122.3346&zoom=14&layers=B0...

For highways they use a specific color and size rectangle

  motorway_shield4.png
< 1K Download

as a png graphic, and then add text on top of it. You can get more  
fancy with the graphic, but you will have to create it yourself.  
Mapnik does the rendering combination but DOES NOT have any prebuilt  
graphics or symbols.

So, assuming your are rendering data from PostGIS in WGS 84  
projection, to set this up you would download a sample 'shield'  
rectangle png graphic from here:

http://svn.openstreetmap.org/applications/rendering/mapnik/symbols/mo...

then create a your XML mapfile like this while filling in the ALL_CAPS  
values:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map bgcolor="white" srs="+proj=latlong +datum=WGS84">

   <Style name="roads-text">
     <Rule>
       <ShieldSymbolizer name="FIELD_NAME_TO_LABEL" face_name="DejaVu  
Sans Bold" size="11" fill="#809bc0" placement="line" file="/PATH/TO/
YOUR/symbols/motorway_shield4.png" type="png" width="31" height="17"  
min_distance="100"/>
     </Rule>
   </Style>

   </Layer>
    <Layer name="roads text labels" status="on" srs="+proj=latlong  
+datum=WGS84">
      <StyleName>roads-text</StyleName>
      <Datasource>
       <Parameter name="type">postgis</Parameter>
       <Parameter name="host">localhost</Parameter>
       <Parameter name="port">5432</Parameter>
       <Parameter name="user">postgres</Parameter>
       <Parameter name="dbname">YOUR_POSTGIS_DATABASE</Parameter>
       <Parameter name="table">YOUR_POSTGIS_ROADS_TABLE </Parameter>
     </Datasource>
   </Layer>

</Map>

Then read that into your python script and you should be able to  
render your field value (a road name or id) on top of/within the  
shield symbol.

>  Also, where
> are the Python API docs?  I am primarily a Java programmer and I can't
> find anything resembling JavaDocs for the python bindings.

There are not currently API docs, infortunately. Luckily the mapnik  
python bindings are fairly simple and straightforward names, so  
experiementing with sample code and doing:
$ python
 >>>import mapnik
 >>>dir(mapnik)
 >>>help(mapnik)

will get you basic api help.

Beyond that what I like to do is in a shell run:

$ pydoc -p 8080

and then open a browser and go to :

http://localhost:8080/mapnik.html

which will give you python-style api docs. Then click on the '_mapnik'  
link to see the C++ api that is exposed within python. Docstrings and  
code comments are wanting, so consider contributing patches when you  
figure out what a function does!

Cheers,

Dane


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jared  
View profile  
 More options Aug 26 2008, 6:12 pm
From: Jared <jared.erick...@gmail.com>
Date: Tue, 26 Aug 2008 15:12:00 -0700 (PDT)
Subject: Re: Mapnik ShieldSymbolizer
Thanks Dane!

I installed Mapnik on a windows machine using the win32 binaries.  I
did discover that you can only install these binaries at C:
\mapnik-0_5_1 otherwise it complains that it can't find the font
files.  I first tried to install on my D:\ drive.  It appears that the
font directory is hard coded somewhere.

I got the ShieldSymbolizer working in the XML format using your code
and then figured out how its done in Python by looking at the C++ code
in the Mapnik Trac subversion repository.

shield = ShieldSymbolizer('NAME','DejaVu Sans Bold',
6,Color('#000000'),'images/ushighway_shield_20.png','png',20,20)

The parameters are:
name, font name, font size, font color, image file, image type, width,
height

To avoid having a lot of shield symbols close together, you can
specify the minimum_distance attribute like this:

shield.minimum_distance = 50

I am not sure what units that is in, but 50 worked well for me.

Again thank you for the help!

Jared

On Aug 22, 11:02 am, Dane Springmeyer <dane.springme...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »