Kevin,

Very nice map image and interesting ideas.

For a while I've also been pondering asking the list what it would  
take to be able to draw auxiliary layers on the map surface.

My use case is similar in the sense that I'd like to dynamically  
create and overlay shapes. I would be defining them in projected  
coordinates rather than screen coordinates, but I can definitely see  
value in the latter too.

One example could be the ability to define a layer from a WKT or WKB  
string, so you could define your geometry on-the-fly with geodjango or  
shapely and therefore be able to do something like:

# Use geodjango to create a geometry
 >>> from django.contrib.gis.geos import fromstr
 >>> pnt = fromstr('POINT(-122 48)',srid=4326)

# Play around, reproject, buffer geometries ...
 >>> pnt.wkt
'POINT (-122.0000000000000000 48.0000000000000000)'
 >>> pnt.transform(900913)
 >>> pnt.srid, pnt.valid, pnt.ewkt, pnt.json
(900913, True, 'SRID=900913;POINT (-13580977.8767793662846088  
6106854.8348850663751364)', '{ "type": "Point", "coordinates":  
[ -13580977.876779, 6106854.834885 ] }')
 >>> buffered = pnt.buffer(1)

# draw with mapnik ...
 >>> from mapnik import Layer
 >>> lyr = Layer('Test layer from string')
 >>> lyr.datasource = WKB(pnt.wkb)
 >>> lyr_buffered = Layer('Test layer buffered from string')
 >>> lyr_buffered.datasource = WKB(buffered.wkb)

I've yet to rebuild mapnik with the pycairo support, so perhaps  
something like this is possible (though I'm sure wouldn't be  
implemented as a datasource, rather a cairo surface).

Either way I support the api being exposed in this way and see lots of  
interesting possibilities.

I'd love to hear ideas from those more experienced with graphics about  
how this should work.

Cheers,

Dane




On Jul 10, 2008, at 11:32 AM, Kevin Webb wrote:

> Artem,
>
> Thanks for the response! I was curious about an approach like using
> pyCairo to draw on the image. However, I wasn't clear on how to get
> the actual coordinate dimensions for the image such that I could
> transform my drawing operations onto the map. Is there a way to do
> this in Python after the map is rendered? Or is pyCairo using the
> coordinate system from the map?
>
> As for the API, I'm still not sure about how far I'd need to go.
> Ideally I'd expose the full range of drawing operations that are
> provided by the renderer but that might be overkill. I'll probably
> start by just exposing a subset and see if that's any easier.
>
> Also, has there been any discussion about adding support for the new
> SQL/MM curve types?
>
>
> In case you're curious, here's an example of one of the maps I'm
> making. This was done with the PostGIS approach - it's still a work in
> progress but it did what I needed.
>
> http://www.structuralknowledge.com/maps/flow_map.png
>
> Thanks,
> Kevin
>
>
> On Thu, Jul 10, 2008 at 4:11 AM, Artem Pavlenko <[EMAIL PROTECTED]>  
> wrote:
>> Hi Kevin,
>>
>> On 9 Jul 2008, at 18:01, Kevin Webb wrote:
>>
>>> Hi,
>>>
>>> I'm interested to know if anyone has developed an approach with  
>>> Mapnik
>>> to draw layers manually (i.e. using graphics primitives directly)
>>> rather than going through the existing symbolizers. My interests  
>>> is to
>>> take a map (via a shapefile, or postgis data source) and overlay
>>> structural, in my case non-cartographic/topological, data over top  
>>> of
>>> it using the coordinate space from the map. I've devised a way to do
>>> this by inserting my markup into a postgis datasource and then
>>> rendering that as a layer. It works but is a bit clunky and doesn't
>>> allow for easy programmatic control of the drawing - it also makes
>>> certain kinds of drawing operations very challenging. In my case I  
>>> am
>>> drawing arc segments between points with arrowhead caps.
>>>
>>
>> You can try using something like pycairo to draw on top of map.
>>
>>> Ideally the next step would be to expose a layer with graphics
>>> primitives through the API (in my case Python). I've looked at the
>>> source already and don't see anything heading in this direction,
>>> however, I'm curious if this is something that people have played
>>> with? I'm going to start hacking on the current 0.51 source to see
>>> investigate the feasibility of this change but would love any  
>>> guidance
>>> that others may have.
>>
>> Yes, I can see this can be useful. What kind of API are you  
>> envisaging ?
>>
>>> Thanks,
>>> Kevin
>>
>> Cheers
>> Artem
>>>
>>> _______________________________________________
>>> Mapnik-users mailing list
>>> [email protected]
>>> https://lists.berlios.de/mailman/listinfo/mapnik-users
>>>
>>
>>
> _______________________________________________
> Mapnik-users mailing list
> [email protected]
> https://lists.berlios.de/mailman/listinfo/mapnik-users

_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to