Skip to content

Instantly share code, notes, and snippets.

@nbessi
Created October 7, 2011 15:42
Show Gist options
  • Save nbessi/1270572 to your computer and use it in GitHub Desktop.
Save nbessi/1270572 to your computer and use it in GitHub Desktop.
GeoEngine Relational ORM support
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; """
@nbessi
Copy link
Author

nbessi commented Oct 7, 2011

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