Query arguments in couchcocoa
Wed, 10/26/2011 - 05:32
Hi, I'm setting up an app using geocouch and Couchbase Mobile iOS and testing this query example from https://github.com/couchbase/geocouch:
http://localhost:5984/places/_design/main/_spatial/points?bbox=-30,-60,110,15&plane_bounds=-180,-90,180,90
What is the best way to make this query from couchcocoa? There are methods like [CouchDesignDocument queryViewNamed:@""], but where would I put the bounding box parameters?
Thanks in advance.
Good question. CouchCocoa doesn't have any support for GeoCouch yet, so there's no straightforward way to do it. You would either have to use the lower-level REST API to construct the query and parse the results, or modify CouchCocoa to add support for GeoCouch. (The second option would take less code but requires learning more about how CouchCocoa works.)
The main issues are that
(1) CouchDesignDocument can't generate query URLs with the "_spatial" path component, only "_view".
(2) CouchQuery doesn't have spatial attributes like "bbox" and "plane_bounds".
So probably the solution is to add a -spatialQueryNamed: method to CouchDesignDocument, and a CouchSpatialQuery subclass of CouchQuery with the required properties.
If you could file a bug report on this, it would be great, else I'll try to remember to do it. It's a feature I'd like to add, but I can't say when I'd be able to get to it; if you wanted to tackle it, I'd be glad to help out and incorporate your patch when it's ready.
--Jens