1

Cloudant Geo Inconsistencies

I am new to IBM Cloudant CouchDB and would like to be able to query records that I have uploaded and tagged with GPS coords.

I would like to be able to query all records that re within 100km of a provided location.

The cloudant website information is inconsistent around geo.

e.g

Page still says geo query is in beta (but support says it is not): tinyurl DOT com SLASH mkcyur2

Missing Tables in the sample (probably because my location (auto picked)and there is no data near me)? tinyurl DOT com SLASH lvxlb4q

API ref does not mention geo (released before geo was launched): https://cloudant.com/wp-content/uploads/Cloudant-API-Reference.pdf

Geo querying may only be for for dedicated customers? https://cloudant.com/blog/announcing-cloudant-geospatial/#.U6wiqRYRpNN

This is how I am inserting geo tagged records with gps and time with python.

import requests
import json

auth = ('username', 'password')
headers = {'Content-type': 'application/json'}
doc = r.json()
doc['event_title'] = "Blah"
doc['event_datetime_utc_epoch'] = 1403768195000
doc['event_lat'] = -31.089675
doc['event_lon'] = 150.932309
post_url = "https://account.cloudant.com/database".format(auth[0])
r = requests.post( post_url, auth=auth, headers=headers, data=json.dumps(doc) )
print json.dumps(r.json(), indent=1)

This is how i query 10 records in Python.

import requests
import json
auth = ('username', 'password')
get_url = "https://account.cloudant.com/database/_all_docs?limit=10".format(auth[0])
r = requests.get(get_url, auth=auth)
print json.dumps(r.json(), indent=1)

I would like to be able to query all records near me (100km radius) and after a certain time (within 30 mins of record saved date)?

0

1 Answer 1

2

Cloudant has a GIS query layer (Cloudant Geo) which is currently only available for dedicated customers. If you contact the support team they may be able to arrange a trial period.

Cloudant Search also offers some limited geospatial querying via Lucene - you can sort search results by distance to a point and perform bounding box queries. This sounds like the most appropriate option for you at the moment (though it won't be a true radial search).

I'd suggest a search function along the lines of

function(doc) {
    index('event_lat', doc.event_lat);
    index('event_lon', doc.event_lon);
    index('event_datetime', doc.event_datetime_utc_epoch);     
}

and then a query along the lines of:

https://account.cloudant.com/database/_design/myddoc/_search/mysearch?q=event_lat:[10 to 30] AND event_lon:[140 TO 160] AND event_datetime:[1403768195000 TO Infinity]&sort="<distance,event_lon,event_lat,15,150,mi>"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.