[ckan-dev] use Data Api for querying individual records in dataset

Arjen Hof arjenhof at gmail.com
Mon Apr 6 13:47:33 UTC 2015


This is my first question to this mailinglist, so apologies if I´m asking
something that was already adressed by someone else (couldn´t find it in
the documentation/mailinglist).

We recently created our own instance of CKAN (still in beta, based on
CentOS, CKAN 2.3) with the datastore and Ckanext-spatial. It was a steap
learning curve ;-)

One of our goals is to connect the CKAN data API to an Open 311 request
service (we have the first iteration completed). Our aim is that we show
objects on a map (from CKAN data API) and make it possible to click on the
object (a lamppost, busstation, garbage bin, etc) to do a request. Citizens
don´t have to fill in information already available and Open311 makes it
possible to route the request to the right organization.

If we only want to show objects in a certain area/bbox around someones
GPS-location, we have to do a request to the CKAN Data Api. We haven´t
found out how to do it. There is a way to do it with a SQL-statement
(http://<our
server>/api/action/datastore_search_sql?sql=SELECT%20*%20%20FROM%20(SELECT%20*%2C%20(6371%20*%20acos(%20cos(%20radians(52.404322)%20)%20*%20cos(%20radians(%20latitude%20)%20)%20*%20cos(%20radians(%205.299055%20)%20-%20radians(longitude)%20)%20%2B%20sin(%20radians(52.404322)%20)%20*%20sin(%20radians(latitude)%20)%20))%20AS%20distance%20FROM%20%22dfe87ec7-e11f-4efe-991e-1f81a5a4bc59%22)%20as%20distance%20where%20distance%20%3C%200.05%20order%20by%20distance
<http://ckan.civity.nl/api/action/datastore_search_sql?sql=SELECT%20*%20%20FROM%20(SELECT%20*%2C%20(6371%20*%20acos(%20cos(%20radians(52.404322)%20)%20*%20cos(%20radians(%20latitude%20)%20)%20*%20cos(%20radians(%205.299055%20)%20-%20radians(longitude)%20)%20%2B%20sin(%20radians(52.404322)%20)%20*%20sin(%20radians(latitude)%20)%20))%20AS%20distance%20FROM%20%22dfe87ec7-e11f-4efe-991e-1f81a5a4bc59%22)%20as%20distance%20where%20distance%20%3C%200.05%20order%20by%20distance>
) but this is not the way we prefer.

Does someone know of a way to do an API call to show a subset of records
from a dataset, based on current GPS-location (bbox)?

Thanks a lot for your help!

Arjen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150406/deb46c75/attachment-0002.html>


More information about the ckan-dev mailing list