On 03/27/2014 04:53 AM, Shoaib Ijaz wrote:
>
>>
>> I am doing sql queries in django, the queries that i mentioned above are
>> print queries of django
>
>
> Network.objects.transform(srid=3857).values('geometry', 'bbox')
>
> *This is printed SQL query output of above django query *
>
> SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" FROM "tbl_network"
>
> Network.objects.transform(srid=3857).values('bbox')
>
> *This is printed SQL query output of above django query *
>
> SELECT "tbl_network"."bbox" FROM "tbl_network"
>
>
I see so the 1st query works and the 2nd one fails to do the transform.
I think the problem may be related to you having 2 geometry columns in
the same Postgis table.
Are both of them listed in the geometry_columns view of Postgis.
Typically only 1 can be the default. In this case geometry, so
Geodjango/Postgis is recognizing it as a spatial column. But when it
get's to bbox it doesn't recognize it and doesn't know what the FROM
(current) srid is so a Transform wouldn't work.
One option would be to return the data and then transform it once you
have the spatial objects into python variables.
Thanks,
Alex