Hi Tobias,
your tip worked like a charm ... and helped me with just another
problem: restricting queries by bbox. Here's my code for this, which
makes use of the custom operator function from sqlalchemy.sql.operators
from sqlalchemy.sql.operators import op
winzer = db_session.query(LemoWinzer).filter(
LemoWinzer.geom.op('&&')(
func.setsrid(
func.box2d('BOX(90771 69171, 103118 81518)'), 2169
)
)
).count()
print winzer
Just for the archives and others who might be interested
Frank
Am 18.05.2010 15:54, schrieb Tobias Sauerwein:
> Hi Frank,
>
> this should do the job:
>
> session.query(func.extent(Spot.spot_location)).first()
>
> With '
func.xyz(..)' you can call any database function, see also:
>
http://www.sqlalchemy.org/docs/reference/sqlalchemy/expressions.html#sqlalchemy.sql.expression.func
>
>
> Tobias
>
>
> On Tue, May 18, 2010 at 3:37 PM, Frank Broniewski<
br...@metrico.lu> wrote:
>> Hello,
>>
>> maybe its just my blindness, but how would I query for the bounding box of a
>> resultset?
>>
>> resultset:
>> layer = db_sesion.query(GAClass).all()
>>
>> I know I can get the bbox by using session.scalar -> envelope, but that
>> works only on a concrete geometry ...
>>
>> In postgis one would do
>> select extent(geom) from table
>> where extent is a aggregate function and returns a box2d
>>
>> Many thanks for tipps
>>
>>
>> Frank
>>
>>
>>
>>
>> --
>> Frank BRONIEWSKI
>>
>> METRICO s.� r.l.
>> g�om�tres
>> technologies d'information g�ographique
>> rue des Romains 36
>> L-5433 NIEDERDONVEN
>>
>> t�l.:
+352 26 74 94 - 28
--
Frank BRONIEWSKI
METRICO s.� r.l.
g�om�tres
technologies d'information g�ographique
rue des Romains 36
L-5433 NIEDERDONVEN
t�l.:
+352 26 74 94 - 28