Created
October 7, 2011 15:42
-
-
Save nbessi/1270572 to your computer and use it in GitHub Desktop.
GeoEngine Relational ORM support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_greater', Polygon([(3, 0), (4, 1), (4, 0)]))]) | |
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_greater', 0)]) | |
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_intersect', {'geoengine.demo.automatic.retailing.machine.the_point': []})]) | |
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_intersect', {'geoengine.demo.automatic.retailing.machine.the_point': [('name','!=','Vallorbe')]})]) | |
#will generate | |
""" | |
SELECT "res_better_zip".id FROM "res_better_zip" WHERE (res_better_zip."name" ilike E'%Lausanne%') AND ST_Area(res_better_zip.the_geom) > ST_Area(ST_GeomFromText('POLYGON ((3.0000000000000000 0.0000000000000000, 4.0000000000000000 1.0000000000000000, 4.0000000000000000 0.0000000000000000, 3.0000000000000000 0.0000000000000000))')) ORDER BY priority; | |
SELECT "res_better_zip".id FROM "res_better_zip" WHERE (res_better_zip."name" ilike E'%Lausanne%') AND ST_Area(res_better_zip.the_geom) > 0 ORDER BY priority; | |
SELECT "res_better_zip".id FROM "res_better_zip", geoengine_demo_automatic_retailing_machine WHERE (res_better_zip."name" ilike E'%Lausanne%') AND ( ST_Intersects(res_better_zip.the_geom, geoengine_demo_automatic_retailing_machine.the_point)) ORDER BY priority; | |
SELECT "res_better_zip".id FROM "res_better_zip", geoengine_demo_automatic_retailing_machine WHERE (res_better_zip."name" ilike E'%Lausanne%') AND ((geoengine_demo_automatic_retailing_machine."name" != E'Vallorbe') AND ST_Intersects(res_better_zip.the_geom, geoengine_demo_automatic_retailing_machine.the_point)) ORDER BY priority; """ |
Sorry I did not get your point at first but I agree with you we can do better and only have one named parameter domain. I'm waiting for your patch ^_^
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That was the first idea, but we had two problems, first we have to manage the fact that any object in the ERP can be linked only by spatial relation, second expression.py did not allow us to du so … ;)