0

When I make a query from the CMS Nursing Home Compare data and attempt to order using distance_in_meters(...) I get the following error:

Error: function distance_in_meters is not defined in SoQL.

The docs say distance_in_meters(...) works with the 2.1 endpoint (further information on endpoints are stuck in a redirect loop from the link at the top of that page at the time of this writing but you can get it from Google cache): https://dev.socrata.com/docs/functions/distance_in_meters.html

I have confirmed the data set is using the 2.1 endpoint.

To be sure it wasn't an issue with just the order clause, I also set it up in the select. Two variations:

  1. https://data.medicare.gov/resource/4pq5-n9py.json?$select=*,%20distance_in_meters(location,%20%27POINT%20(-78.9627624%2043.0171854)%27)%20AS%20range&$where=within_circle(location,43.0171854,-78.9627624,16093.44)
  2. https://data.medicare.gov/resource/4pq5-n9py.json?$where=within_circle(location,43.0171854,-78.9627624,16093.44)&$order=distance_in_meters(location,%20%27POINT%20(-78.9627624%2043.0171854)%27)

So, the question ultimately is does the 2.1 endpoint not support distance_in_meters(...) or am I missing something stupid obvious?

4

1 回答 1

1

看起来虽然您正在查看 2.1 端点的 API 文档,但实际上您在查询中使用的是 2.0 文档。你应该使用:

https://data.medicare.gov/resource/b27b-2uc7.json

... 代替:

https://data.medicare.gov/resource/4pq5-n9py.json

我将根端点更改为 2.1 版本,查询看起来返回了您期望的结果:

https://data.medicare.gov/resource/b27b-2uc7.json?$where=within_circle(location,43.0171854,-78.9627624,16093.44)&$order=distance_in_meters(location,%20%27POINT%20(-78.9627624%2043.0171854)%27)
于 2016-05-20T21:11:12.320 回答