Hello everybody.
I don't find the solution for selecting what I need, selecting comments for
events in a specific area.
DB:
#Events table with a geometry fields. I use a PostGis DB.
db.define_table('events',
Field('title', type='string', requires=IS_NOT_EMPTY(), label=T('Title'
)),
Field('latitude', type='string', requires=IS_NOT_EMPTY(), label=T(
'Latitude')),
Field('longitude', type='string', requires=IS_NOT_EMPTY(), label=T(
'Longitude')),
Field('geometry', 'geometry()', compute=lambda r: geoPoint(float(r[
'longitude']),float(r['latitude']))),
)
#Comments for the events table
db.define_table('events_comments',
Field('commented_event', 'reference events'),
Field('event_comment', type='text'),
auth.signature)
CONTROLLER:
#In session I have the four points of the events area.
#For getting the last 3 comments from this area, the query must be I think:
events_comments = db(db.events_comments.commented_event.geometry.
st_within(geoPolygon((session.west, session.south), (session.east, session.
south), (session.east, session.north), (session.west, session.north), (
session.west, session.south)))).select(
limitby=(0,3),
orderby=~db.events_comments.id
)
But I've got a ticket that says that the 'geometry' field don't exist. As
I've already experienced strange problems for tables with this field type I
think I can't resolve it.
So I would like to make a query and a subquery, something like:
#A set for the events in this area
events = db(db.events.geometry.st_within(geoPolygon((session.west, session.
south), (session.east, session.south), (session.east, session.north), (
session.west, session.north), (session.west, session.south)))).select()
#And a set that gone select only the events_comments from these events
#The simple select without the events set is like that:
events_comments = db(db.events_comments.id > 0).select(
limitby=(0,3),
orderby=~db.events_comments.id
)
Someone knows how I can do it?
Thanks, regards.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.