Hi,

I mostly use Django for my projects and I enjoy really much the GEOS and
OGR integrated bindings. I've sometimes wished there was a simple way to
display the objects of a geo-model. I know that GeoDjango already have
GeoFeeds to stream objects as vector data, olWidget is also nice in
order to display/edit a geometric field. Unfortunately, I can't find a
clean and easy way to stream maps of my objects (WMS or equivalent). I
believe Mapnik and its Python bindings would fit very well for this purpose.

I could set up ogcserver and configure a datasource reading in the
underlying database but in such architecture, map rendering lives
completely outside Django and this is really "static" and involves many
limitations. What I would like to do is the following:

    # Import my Django model
    from models import MySuperModel

    # Import mapnik and something that ease integration with Django
    import mapnik
    from ... import MapnikLayer

    # Instantiate a Mapnik map
    m = mapnik.Map(600,300,"+proj=latlong +datum=WGS84")

    # create style here

    # Create a mapnik layer based on my Django model
    lyr = MapnikLayer(name='supermodel',
                      queryset=MySuperModel.objects.all())

    # finalize map here

Using a Django queryset would allow simple filtering of objects through
Django's ORM. For example, one could use such code in a Django view in
order to render a map of the current user's objects.

I can imagine two ways of implementing this:
- The first is to write a Mapnik plug-in but I am not sure it's even
possible. I don't know much about C++ but I believe that the C++ plug-in
code can't use Django's ORM functionalities, am I right?
- The second is to write an helper function or class which detect the
back-end, the queryset SQL query, the queryset geometric attribute and
instantiate the proper mapnik Layer with this information.

I'm merely thinking out loud here. I've not yet planned any development
but I may try to code something like this in the future and, if so, I'd
be pleased to get your comments as I'm not sure if it is feasible or if
I'm on the right track.

Cheers

-- 
Gilles Bassière - Web/GIS software engineer
http://gbassiere.free.fr/
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to