--
from gluon.dal import geoPoint, geoLine, geoPolygon
db.define_table('test_geo',
Field('loc_test','geometry()'))
db.test_geo.insert(loc_test=geoPoint(45.89096,11.0401399))
db.test_geo.insert(loc_test=geoPolygon((0,0),(150,0),(150,150),(0,150),(0,0)))
query = db.test_geo.loc_test.st_contains(geoPoint(1,1))
print db(query).select(db.test_geo.id, db.test_geo.loc_test)
dist = db.test_geo.loc_test.st_distance(geoPoint(45.0,11.0)).with_alias('dist')
print db(db.test_geo.id>0).select(db.test_geo.id, dist)
dist = db.test_geo.loc_test.st_distance(geoPoint(45.0,11.0))
print db(db.test_geo.id>0).select(db.test_geo.id, dist)Traceback (most recent call last):
File "/home/paolo/Dropbox/git/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/home/paolo/Dropbox/git/web2py/applications/bikend/models/db.py", line 589, in <module>
print db(db.test_geo.id>0).select(db.test_geo.id, dist)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 8975, in select
return adapter.select(self.query,fields,attributes)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1636, in select
return self._select_aux(sql,fields,attributes)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1601, in _select_aux
self.execute(sql)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1714, in execute
return self.log_execute(*a, **b)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1708, in log_execute
ret = self.cursor.execute(*a, **b)
ProgrammingError: syntax error at or near "AS"
LINE 1: ...GeomFromText('POINT (45.000000 11.000000)',4326)) AS dist) F...
Traceback (most recent call last):
File "/home/paolo/Dropbox/git/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/home/paolo/Dropbox/git/web2py/applications/bikend/models/db.py", line 586, in <module>
print db(db.test_geo.id>0).select(db.test_geo.id, dist)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 8975, in select
return adapter.select(self.query,fields,attributes)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1636, in select
return self._select_aux(sql,fields,attributes)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1601, in _select_aux
self.execute(sql)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1714, in execute
return self.log_execute(*a, **b)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1708, in log_execute
ret = self.cursor.execute(*a, **b)
ProgrammingError: function st_astext(double precision) does not exist
LINE 1: SELECT test_geo.id, ST_AsText(ST_Distance(test_geo.loc_test...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
exist
LINE 1: SELECT test_geo.id, ST_AsText(ST_Distance(test_geo<span style="color: #660;"...
Show original
Traceback (most recent call last):
File "/home/paolo/Dropbox/git/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/home/paolo/Dropbox/git/web2py/applications/bikend/models/db.py", line 586, in <module
>
print db(query)._select(db.test_geo.id, db.test_geo.loc_test)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 8928, in _select
return adapter._select(self.query,fields,attributes)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1478, in _select
sql_f = ', '.join(map(geoexpand, fields))
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1477, in geoexpand
return self.expand(field)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1312, in expand
return op(first, second)
TypeError: ST_ASTEXT() takes exactly 2 arguments (3 given)
db.define_table('test_geo',
Field('loc_Test','geometry()'),
)Traceback (most recent call last):
File "/home/paolo/Dropbox/git/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in
environment
File "/home/paolo/Dropbox/git/web2py/applications/bikend/models/db.py", line 585, in <module>
db.test_geo.insert(loc_Test=geoPoint(45.89096,11.0401399))
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 7977, in insert
ret = self._db._adapter.insert(self,self._listify(fields))
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1175, in insert
raise e
ProgrammingError: column "loc_test" of relation "test_geo" does not exist
LINE 1: INSERT INTO test_geo(loc_Test) VALUES (ST_GeomFromText('POIN...
Traceback (most recent call last):
File "/home/paolo/Dropbox/git/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in
environment
File "/home/paolo/Dropbox/git/web2py/applications/bikend/models/db.py", line 585, in <module>
db.test_geo.insert(loc_test=geoPoint(45.89096,11.0401399))
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 7977, in insert
ret = self._db._adapter.insert(self,self._listify(fields))
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 7915, in _listify
'Field %s does not belong to the table' % name)
SyntaxError: Field loc_test does not belong to the table
Traceback (most recent call last):
File "/home/paolo/Dropbox/git/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in
environment
File "/home/paolo/Dropbox/git/web2py/applications/bikend/models/db.py", line 583, in <module>
db.test_geo.insert(Name='paolo')
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 7313, in __getattr__
return self.lazy_define_table(tablename,*fields,**args)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 7281, in lazy_define_table
polymodel=polymodel)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 965, in create_table
fake_migrate=fake_migrate)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1068, in migrate_table
self.execute(sub_query)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1714, in execute
return self.log_execute(*a, **b)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1708, in log_execute
ret = self.cursor.execute(*a, **b)
ProgrammingError: syntax error at or near "SELECT"
LINE 1: ALTER TABLE test_geo ADD loc_test__tmp SELECT AddGeometryCol...
print db(db.city).select(db.city.latlng,
db.city.latlng.st_x(),
db.city.latlng.st_y())
city.latlng,ST_X(city.latlng),ST_Y(city.latlng)
POINT(51.507335 -0.127683),51.507335,-0.127683
POINT(41.901514 12.460774),41.901514,12.460774
POINT(40.851775 14.268124),40.851775,14.268124
)
<span st...
Show original
db.define_table('test_geo1_name',
Field('name_P', 'string'),
Field('location_P','geometry()'),
).lower() at line 832:ftype = ftype % dict(schema=schema,
tablename=tablename,
fieldname=field_name.lower(), srid=srid,
dimension=dimension)
--
from gluon.dal import geoPoint, geoPolygon
db.define_table('test_3d_1',
Field('location_test', 'geometry()'),
)
db.test_3d_1.insert(location_test=geoPoint(45.89096,11.0401399, 345))
x = db.test_3d_1.location_test.st_x().with_alias('lng')
y = db.test_3d_1.location_test.st_y().with_alias('lat')
z = db.test_3d_1.location_test.st_z().with_alias('ele')
dist = db.test_3d_1.location_test.st_distance(geoPoint(45.0,11.0)).with_alias('dist')
print db(db.test_3d_1).select(x, y, z, dist)Traceback (most recent call last):
File "/home/paolo/Dropbox/git/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in
environment
File "/home/paolo/Dropbox/git/web2py/applications/test_pg/models/db.py", line 72, in <module>
Field('location_test', 'geometry()'),
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 7337, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 7373, in lazy_define_table
polymodel=polymodel)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 967, in create_table
fake_migrate=fake_migrate)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1070, in migrate_table
self.execute(sub_query)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1716, in execute
return self.log_execute(*a, **b)
File "/home/paolo/Dropbox/git/web2py/gluon/dal.py", line 1710, in log_execute
ret = self.cursor.execute(*a, **b)
ProgrammingError: syntax error at or near "SELECT"
LINE 1: ALTER TABLE test_2d_1 ADD location_test__tmp SELECT AddGeome...