Francesco,

MaxMind(R) produces commercial and free IP geolocation datasets.  As a
proof of concept I created GeoDjango-enabled models and import scripts
for their CSV files:

http://www.djangosnippets.org/snippets/327/
http://www.djangosnippets.org/snippets/328/

To create this code I had to patch Django since it lacks large integer
support; specifically, IP address queries require conversion to a long
integer.  I used Peter Nixon's latest patch to get BigIntegerField:
http://code.djangoproject.com/attachment/ticket/399/django-bigint-20070712.patch

I'm not sure about the utility of including it in GeoDjango.  The
large database size (3 million rows for LocationBlock), makes queries
slower -- however, there are much fewer CountryBlock rows.  I will try
out their C API and compare.  This may be useful for some research
purposes (e.g. how many IP allocations within a political boundary,
etc.).

Example:

>>> from geoip.models import LocationBlock, CountryBlock
>>> lb = LocationBlock.objects.ipquery('72.14.207.99')
>>> print unicode(lb.location)
Location 2633: United States - CA, Mountain View 94043
>>> print lb.location.point
POINT (-122.0574000000000012 37.4191999999999965)
>>> cb = CountryBlock.objects.ipquery('66.64.46.23')
>>> print unicode(cb.location)
United States: 66.60.64.0 to 66.70.70.109

-Justin


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to