I'm really new to GeoDjango myself, and I agree that jumping right in
is a bit of a shock. Hopefully someone more knowledgeable will also
pipe-up, but I think I can start you off in the right direction.

On Apr 14, 9:43 pm, Alex Ezell <[EMAIL PROTECTED]> wrote:
> The system would then show them trips which have start, end, or both
> points in common with the locations they have entered in the search.
> "In common" being defined as within a radius of say 100 miles or so.

If I understand your question correctly, you're only interested in the
start and end points and not the points along that line between the
two. So define a regular model with a ``PointField`` [1] to hold the
lat/long for a location and make sure to use a ``GeoManager`` [2] for
that model. I've been using GeoPy [3] to obtain lat/long from
addresses and zipcodes. If you need to do complex lookups that you
would normally use a ``Q`` object for, make sure to use a ``GeoQ``
object [4] instead.

Once you've done that and have a few items in your database you can
query proximity pretty easily [5]. You can search for other points in
the database that are within a certain radius using a regular queryset
filter like
``yourmodel.objects.filter(point__distance_lte=(STARTINGPOINT,
D(mi=100))``. If you want to return the distance between your starting
point and a bunch of objects use the ``distance()`` manager method
[6]. Also, I've found the built-in Distance measure functions [7]
really helpful for doing conversions.

.. [1] http://code.djangoproject.com/wiki/GeoDjangoModelAPI#FieldTypes
.. [2] http://code.djangoproject.com/wiki/GeoDjangoModelAPI#GeoManager
.. [3] http://exogen.case.edu/projects/geopy/
.. [4] from django.contrib.gis.db.models import GeoQ
.. [5] http://code.djangoproject.com/wiki/GeoDjangoDatabaseAPI#DistanceLookups
.. [6] http://code.djangoproject.com/wiki/GeoDjangoDatabaseAPI#distance
.. [7] http://code.djangoproject.com/wiki/GeoDjangoExtras#Measure

So I just mentioned three completely different parts of GeoDjango all
named "distance", hopefully I didn't confuse you even more!  :-P

Good luck.
- whiteinge
--~--~---------~--~----~------------~-------~--~----~
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