Reputation: 611
I'm currently building my first Django-based app, which is proceeding fairly well, thus far. One of the goals is to allow users to post information (text, pics, video) and for the app to be able to automatically detect the location where they posted this information (i.e., pulling location info from the browser). That data would then ideally be able to be filtered later, such as viewing the posts that were made within a specific radius.
I've been reading a bit about GeoDjango and it sounds intriguing,
if perhaps more sophisticated than the requirements of this project.The querying aspects appear promising.
A colleague, though, suggested everything that can be done using
GeoDjango is equally efficient utilizing the Google Maps API with
JavaScript or JQuery to obtain the proper coordinates.
Essentially, I'm looking to see what benefits GeoDjango would offer this fairly straightforward project over using just the Google Maps API. If I've already started a project in basic Django; is incorporating GeoDjango problematic? I'm still attempting to master the basics of Django and venturing into GeoDjango may be too much for a novice developer. Or not.
Any insight appreciated.
Upvotes: 3
Views: 428
Reputation: 548
To accurately find geolocated posts within a given radius of a location, you need to calculate distances between geographic locations. The calculations are not trivial. To quote the Django docs (with a minor grammatical correction):
Distance calculations with spatial data are tricky because, unfortunately, the Earth is not flat.
Fortunately using GeoDjango hides this complexity. Distance queries are as simple as the following:
qs = SouthTexasCity.objects.filter(point__distance_lte=(pnt, 7000))
Although one could program this logic using JavaScript/JQuery, I don't see a reason to because you are already using Django. Unless if you are:
unable to use a spatial database. GeoDjango distance queries are only available if you use PostGIS, Oracle, or SpatiaLite as your database. (i.e. MySQL does not support distance queries)
unable to install the geospatial libraries that GeoDjango depends on.
Upvotes: 3