From 53122bfa9f71a61a50bb4d376cf3644527ed00a7 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 9 Dec 2013 17:06:25 -0600 Subject: [PATCH] possible implementation of st_dwithin, thanks User --- VERSION | 2 +- gluon/dal.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 3798cc07..f7da9d28 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.8.2-stable+timestamp.2013.12.08.09.32.29 +Version 2.8.2-stable+timestamp.2013.12.09.17.05.33 diff --git a/gluon/dal.py b/gluon/dal.py index b3dc64c3..df2c6425 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -2980,11 +2980,12 @@ class PostgreSQLAdapter(BaseAdapter): """ return 'ST_Within(%s,%s)' %(self.expand(first), self.expand(second, first.type)) - def ST_DWITHIN(self, first, second): + def ST_DWITHIN(self, first, (second, third)): """ http://postgis.org/docs/ST_Within.html """ - return 'ST_DWithin(%s,%s)' %(self.expand(first), self.expand(second, first.type)) + return 'ST_DWithin(%s,%s)' %(self.expand(first), self.expand(second, first.type), + self.expand(third, 'double')) def represent(self, obj, fieldtype): field_is_type = fieldtype.startswith @@ -9674,6 +9675,10 @@ class Expression(object): db = self.db return Query(db, db._adapter.ST_WITHIN, self, value) + def st_dwithin(self, value, distance): + db = self.db + return Query(db, db._adapter.ST_DWITHIN, self, (value, distance)) + # for use in both Query and sortby