【发布时间】:2019-07-01 14:36:49
【问题描述】:
我有一个基本的 API 正在运行,我可以像往常一样存储和获取数据。但是,我在格式化我的内容时遇到了问题。我可以使用 HTTPGet 获取我所有用户的列表,它看起来像这样......
[
{
"userId": "1 ",
"geoHash": "123456789",
"latitude": 1.234,
"longitude": 5.689,
"locationDate": "2019-07-01T00:00:00"
},
{
"userId": "2 ",
"geoHash": "123456789",
"latitude": 1.234,
"longitude": 5.689,
"locationDate": "2019-07-01T00:00:00"
},
{
"userId": "3 ",
"geoHash": "123456789",
"latitude": 1.234,
"longitude": 5.689,
"locationDate": "2019-07-01T00:00:00"
}
]
但是,我不知道如何将它变成一个 GeoJson (https://geojson.org/),看起来像这样......
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}
}
这是我获取用户列表的基本方法
[HttpGet]
public IEnumerable<Users> GetUsers()
{
return _context.Users;
}
我已经搜索了几个小时,围绕这个主题的内容似乎让我有些困惑,我非常感谢这里的一些帮助。
【问题讨论】:
-
您要返回所有用户的FeatureCollection 吗?
-
是的,我相信是的。不确定是否可以将数组转换为“坐标”
标签: c# .net api ienumerable geojson