GeoDjango

Kategorier: Django , Udvikling

22. april, 2008

This morning, I spotted this piece of information about GeoDjango on Slashgeo, a geoinformatics newssite.

Apparently, there is an effort going on to make a geospatial extension to Django, my favourite web development framework. How cool is that?!

You should be able to handle geographic queries and data in Django's very easy-to-use database model framework. It adds the following field types:

Queries are written like regular Django as one or more filters. This example will simply select all points (cities) within a polygon (region).

#The model from django.contrib.gis.db import models Region(models.Model): name = models.CharField(maxlength=35) poly = models.PolygonField() objects = models.GeoManager() City(models.Model): name = models.CharField(maxlength=35) point = models.PointField() objects = models.GeoManager() #The query region = Region.objects.get(name="Midtjylland") cities = District.objects.filter(point__within=region.poly)

Easy as pie!

At least this is the way it should work, I haven't really tested it yet. But I know I am going to as soon as I find the time - hopefully this sunday, if I'm not too hung-over from the Ubuntu Release Party and Afterparty.

Kommentarer

Kategorier

Arkiv

Blogroll