Spatial search only works for GeoJSON points?

Hi there.

I am using the newest community edition, 3.0.1.

I have several GeoJSON 'Point’s in my bucket, and a single ‘Polygon’. I get a the following error when trying to query with a spatial view:

{“error”:“error”,“reason”:“function_clause”}

If i remove the Polygon, the spatial view works fine. Are other GeoJSON types not supported? Or am I doing something wrong?

Regards, Asbjørn

Could you provide a sample of the data points and the format of the way you are building your index and the code to perform the query. I too am trying to get to the bottom of spatial indexes and their functional differences with normal secondary indexes.

Hello md1,

Here is my spatial view:

function (doc) { if (doc.geometry) { emit(doc.geometry, doc); } }

And here is the data in my bucket, formatted as result from a view encompassing all data:

{"total_rows":4,"rows":[ {"id":"0","key":"0","value":{"type":"Feature","geometry":{"type":"Point","coordinates":[0,0]},"properties":{"prop0":0}}}, {"id":"1","key":"1","value":{"type":"Feature","geometry":{"type":"Point","coordinates":[1,1]},"properties":{"prop0":1}}}, {"id":"2","key":"2","value":{"type":"Feature","geometry":{"type":"Point","coordinates":[2,2]},"properties":{"prop0":2}}}, {"id":"3","key":"3","value":{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[0,0],[1,0],[1,1],[0,1]]},"properties":{"prop0":3}}} ] }

When the polygon is present, the query fails with the previously mentioned error. When it is removed, the query succeeds in selecting the correct points inside specified the bounding box.

Well, let us see the response time from the couchbase Devs on this issue.

I really don’t like the bounding box, I would rather an option be for a bounding SPHERE available and have the calculation distributed instead of having to use the bounding and retrieve a lot of edge cases and the prune them down using application logic on a dedicated client.

The bounding box is good for the multi dimensional searchs. Each one considered 90 degrees out of phase with the other dimension, very square edges.

But you would figure that GeoCouch should at least have something with specific Geographic support.

I agree. A bounding sphere and a nearest neighbor would be very nice to have. Lets hope there will be some official-ish response soon.

Hi all,

first of all, your GeoJSON polygon isn’t a valid one, you need to wrap the coordinates in another array. Besides that, the spatial stuff in 3.0.1 is a bit broken, it got better in 3.0.2. so please use that version (sadly Enterprise Edition only atm). I’ve tested your view in 3.0.2.

For the future I surely want to implement radius and nearest neighbour search. Though at the moment the development focus is on getting the foundation solid (the bounding boxes). Another thing I plan to implement is geometry search, so that you can query with any geometry you like and it will then do the intersection really on the geometry and not only on the bounding box level.

Cheers,
Volker

Hello Volker,

Thanks for your reply! It is always great to get information directly from the author. :smile:

The coordinates in my GeoJSON polygon are coordinate pairs wrapped in a list, so a list of lists. To my knowledge, this is exactly the way to construct a GeoJSON polygon. The structure was copied from geojson.org and modified slightly.

Edit: Sorry, you are right! It must be a list of lists of lists. My bad!

Is there any way to know when there will be a 3.0.2 Community Edition?

This is great news! Ill be writing my masters thesis over the next 5 months, which will include some Erlang, so I might just look into GeoCouch some time after that. :slight_smile:

Regards, Asbjørn