Tuesday, May 3, 2016

Re: manipulate n insert field values

#Z value calculation
#................................
#step1: converting lat and long to int

latitude int = (latitude + 90) × 10^6
longitude int = (latitude + 180) × 10^6

#note 10^6 = 1000000

We compute the Morton value for a spatial point P (x, y)
by interleaving the bits of x and y. For example, when x =
3(011 ) and y = 4(100), the Morton value for P is
100101 = 37

#step2: convert int (base 10) to binary digits (base 2)
..........?
#step3: interleave both values bits and compute z value
#take first bit from y cordinate  (longitude) : 1
#take first bit from x cordinate  (lat) : 0
#take 2nd bit from y cordinate  (longitude) :0
#take 2nd bit from x cordinate  (lat) : 1
#take 3rd bit from y cordinate  (longitude) : 0
#take 3rd bit from x cordinate  (lat) : 1

therefore z binary value is 100101
and z value is 37

#this is the technique used to convert spatial 2D indexing to 1D to improve efficiency.

I do not know the python syntax. Kindly help.





On Tue, May 3, 2016 at 3:22 PM, Erik Cederstrand <erik+lists@cederstrand.dk> wrote:

> Den 3. maj 2016 kl. 02.45 skrev Shameema Mohsin <itz.shameema@gmail.com>:
>
>
> Stil stuck with the z order calculation and usage of the property field. Kindly help. I am new to Django, only knows php well.

Where are you stuck? Show your error messages, current non-working code and expected result, or describe your problem in more detail.

I assume you have code to calculate the z order (I have no idea what it is). Otherwise, other forums would be better for help on this. Assuming that, you would do:

def get_z_order(lat, long):
   # Jiggle those numbers
   return z_order


class Employees(models.Model):
   [...]
   @property
   def zval(self):
       return get_z_order(self.empLat, self.empLong)


You can then access zval as if it was a model field.

Erik

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/8IzLt_0cO8Y/unsubscribe.
To unsubscribe from this group and all its topics, 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0E25E884-F38C-4314-B2B3-0ADAF813253E%40cederstrand.dk.
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPKy%3DsHWDCerQ29JD8JM6m%2Bxq1ogfiqw3SMOkmHz8o1R_CYs3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment