I'm working on a Android app which should manage data on a remote PostGIS database. Before diving into actual programming, I'm searching for ORMs for Android. I've found a couple, namely androrm and ormlite.

However, these don't seem to give me an interface to query objects by the geometry column. For example, find all objects within a radius from the current location... I'd need to write SQL for this...

What are my best options here?

Is there a way to completely avoid PostGIS SQL?

Or not really?

Thanks in advance.

(EDIT, 19/08/11: changed the title)

  • The new title, added by whuber, is probably deceiving. I'm not looking for an application or interface, but rather a programming object relational mapping layer. So I think I'll rewrite the title...(don't really know the 'protocol' on these situations, I'm a new user here) Aug 19 '11 at 8:27

The only ORM for PostGIS that I'm aware of is the one used in GeoDjango. If you can, move the spatial querying functionality to the server with GeoDjango on the backend and send HTTP queries from Android.

The Android app would send POST or GET requests with the parameter e.g. object id and a distance to search. The GeoDjango views would do all of the PostGIS query construction for you. A search for ZIP codes within 5km of a point (where 'geom' is the Point object) would look like:

Zipcode.objects.filter(poly__dwithin=(geom, D(km=5)))

No SQL to write. You can get the geometries back as GeoJSON, KML, EWKB, WKB, WKT, etc.

  • It depends on GEOS which i'm not sure it's avaliable for android. There was some efforts (along with the aforementioned) QGIS for android software to compile GEOS for it... Aug 19 '11 at 15:03
  • I didn't suggest running it on Android. I suggested running it on the server. He's accessing a remote PostGIS database. He can easily put GeoDjango on the server in between. Also, GEOS is not necessarily required if using PostGIS with GeoDjango.
    – Sean
    Aug 19 '11 at 15:19
  • Seems an acceptable way to do this... seems a good a idea, if nothing really oriented to PostGIS works on Android. Aug 19 '11 at 15:24
  • If this is a public app, you probably don't want the client hitting the database directly, anyhow. Having something like Django in between will make it more secure. An internal app might be a different story.
    – Sean
    Aug 22 '11 at 13:30
  • Yup, did not think about that... Aug 22 '11 at 16:12

Quantum GIS on an android (3.2) tablet (Asus transformer)

*Still in development and not all functions work


Do not think there is an option to avoid PostGIS SQL


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.