Thursday, April 17, 2014

Re: Deferred reverse geo coding upon record save/update

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

On Thu, Apr 17, 2014 at 6:19 PM, Subodh Nijsure
<subodh.nijsure@gmail.com> wrote:
> 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
>
> --
> 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+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@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.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/CABoKswjrAYxQ1SiCfstWxCZf%3DBe5cj-LnW0W6Awuq-biaUO_0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment