Deferred reverse geo coding upon record save/update

7 views
Skip to first unread message

Subodh Nijsure

unread,
Apr 17, 2014, 7:19:25 PM4/17/14
to django...@googlegroups.com
I have application where mobile devices are collecting data from
sensors, and along with sensor reading they also save gps co-ordinates
where the sensor data is taken. This is uploaded to web server using
REST interface on django platform.

But I am trying to figure out how do I reverse geo decode those
lat/lang numbers to actual address using google reverse geo-coder
APIs. I know I could do this in save method but that would make save
operation slower. Is there some way I can queue these operations
within django implementation so the save can proceed but queue up a
job that will reverse geo-decode lat/long and update a record.

Say:

My REST api creates a new record in table sensordata, with lat, long
of (10.1, -120.202) what I want to happen is new record for sensordata
say unique id 1234 gets created. At the same time job is queued
somewhere that will update record #1234 that will reverse geo-decode
10.1,-120.202 to the street address.

-Subodh

-Subodh

Ramón Carrillo

unread,
Apr 17, 2014, 11:18:42 PM4/17/14
to django...@googlegroups.com
Hi Subodh,

I would use use the same model as a queue.

Add a address field to the sensordata model, make it nullable
(null=True). Then write a custom django-admin command [0] that gets
all the records in sensordata with null address, make the request to
the geodecoder and save the result in the address field.

Let's say you name your command 'geodecode':
$ manage.py geodecode
will fill the address for all the sensordata records with null address.

If you're in a Unix environment, you could use cron [1] to run this
command every certain time.

[0] https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/
[1] http://www.thegeekstuff.com/2011/07/cron-every-5-minutes/

Regards,
Ramón
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALr9Q3ZtH_MKKRhddmmRrqW_LAe7nFB6dbQ06TfGO%2B1Fe_BFTA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages