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
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
> Thanks!
> Jared
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "Cascadia Users of Geospatial Open Source" group.
> To post to this group, send email to cugos@googlegroups.com
> To unsubscribe from this group, send email to cugos+unsubscribe@googlegroups.com
> For more options, visit this group at
http://groups.google.com/group/cugos?hl=en > -~----------~----~----~----~------~----~------~--~---