I have this many to many relationship example:
db.define_table('location',
Field('geom', 'geometry()'))
db.define_table('item',
Field('name'))
db.define_table('item_location',
Field('item', db.item),
Field('location_one', db.location),
Field('location_two', db.location))
The goal is to find all items that are NOT the given item.id, but matches
locations.
An example query would be:
Given: item.id==1 and two points POINT(x,y) and POINT(n,m),
Result: "get all items that are not item.id==1, but has
location_one==POINT(x,y) and location_two==POINT(n,m)"
I am able to get it matching one of the points, but not the other with this:
point_x_y = "POINT(1,2)"
point_n_m = "POINT(3,4)"
itemid = 1
t = db( (db.item.id==db.item_location.item) &
( (db.location.id==db.item_location.location_one) & (db.location.
geom.st_equals(point_x_y))))
result = t( db.item.id != itemid ).select()
This will successfully match all items that do not have an id=1, and has
location_one as point_x_y.
The problem is I do not know how to match location_two with point_n_m. I
tried this, but it doesn't make sense (it also returns in nothing):
t = db( (db.item.id==db.item_location.item) &
( (db.location.id==db.item_location.location_one) & (db.location.
geom.st_equals(point_x_y)))
( (db.location.id==db.item_location.location_two) & (db.location.
geom.st_equals(point_n_m))))
Any help would be great!
--
---
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/groups/opt_out.