Thursday, March 27, 2014

How transform geometry column using GeoDjango

I am trying to transform geometry column in django, here is my model

class Network(models.Model):      name = models.CharField(max_length=50, blank=True)      alias = models.CharField(max_length=100, blank=True)      geometry = models.GeometryField(srid=3857, null=True, blank=True)      bbox = models.GeometryField(srid=3857, null=True, blank=True)      objects = models.GeoManager()        class Meta:          db_table = u'tbl_network'        def __unicode__(self):          return '%s' % self.name

I am trying to transform bbox column but GeoQuerySet automatically tranform geometry column

Network.objects.transform(srid=3857).values('geometry','bbox')

SQL query output of above django query

  SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" FROM "tbl_network"

So i tried it different way, now i exclude geometry column

 Network.objects.transform(srid=3857).values('bbox')

SQL query output of above django query

 SELECT "tbl_network"."bbox" FROM "tbl_network"

Now GeoQuerySet totally ignore transform function.

So my questions is,

How can i transform specific column of model?

--
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/e99f8f98-b9b3-48fa-8eb2-699da60bb97d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment