2015-10-20 77 views
1

使用hurl.it,我試圖對西雅圖市開放數據進行API調用。使用within_polygon函數返回錯誤的Socrata API調用返回錯誤

這裏的GET目標:

https://data.seattle.gov/resource/82su-5fxf.json?$where=within_polygon(location, 'MULTIPOLYGON(((-122.345239999941 47.7339842230969,-122.344670705637 47.7051200031236, -122.35540073991 47.7051536806063,-122.355548433321 47.7340195160745, -122.345239999941 47.7339842230969)))')

錯誤我收到:

Error: function within_polygon is not defined in SoQL.

然而,在這兩個within_box和within_circle工作endpoint-只是沒有within_polygon。城市西雅圖的開放數據中 的數據來源於docs-這個特定的數據集被稱爲我的鄰居:

https://data.seattle.gov/Community/My-Neighborhood-Map/82su-5fxf

這裏是「within_polygon`工作示例,但使用不同的端點:

https://data.seattle.gov/resource/pu5n-trf4.json? $where=within_polygon(incident_location, 'MULTIPOLYGON(((-122.345239999941 47.7339842230969,-122.344670705637 47.7051200031236, -122.35540073991 47.7051536806063,-122.355548433321 47.7340195160745, -122.345239999941 47.7339842230969)))')

在此先感謝您的幫助。

回答

1

within_polygon函數僅適用於每個數據集的最新API端點,因此請確保您使用的是正確的端點。您應該使用這個來代替:

https://dev.socrata.com/foundry/#/data.seattle.gov/3c4b-gdxv

使用該端點,並校正位置字段名到location,我能夠創建此查詢的工作原理:

https://data.seattle.gov/resource/3c4b-gdxv.json?$where=within_polygon(location,%20%27MULTIPOLYGON(((-122.345239999941%2047.7339842230969,-122.344670705637%2047.7051200031236,%20-122.35540073991%2047.7051536806063,-122.355548433321%2047.7340195160745,%20-122.345239999941%2047.7339842230969)))%27) 
+0

謝謝。這樣可行。 –

+0

真棒,很高興我能幫到你! – chrismetcalf