【发布时间】:2021-07-27 11:06:40
【问题描述】:
我需要从mongodb中提取数据,但是这个数据坐标不同,我可以创建一个基子类结构并POST到mongodb,但是GET操作中没有坐标。
public class Geometry
{
public string type { get; set; }
}
public class GeoPoly:Geometry
{
public double[][][] coordinates { get; set; }
}
public class GeoMultipoly : Geometry
{
public double[][][][] coordinates { get; set; }
}
我该怎么做
- 序列化约定是否应该改变以及如何改变
- 基子类结构适合这个问题吗?
数据库条目:
{
"type": "Polygon",
"coordinates": [
[
[
[
51.263632,
60.962938
],
[
30.884274,
20.065517
],
[
68.832044,
14.362602
],
[
51.263632,
60.962938
]
]
]
]
},
{
"type": "MultiPolygon",
"coordinates": [
[
[
[
43.182162,
64.042209
],
[
14.721334,
22.358269
],
[
51.263632,
17.738761
],
[
43.182162,
64.042209
]
]
],
[
[
[
55.831419,
51.446822
],
[
65.66973,
20.065517
],
[
97.64424,
37.509124
],
[
55.831419,
51.446822
]
]
]
]
}
【问题讨论】:
标签: c# .net .net-core geojson system.text.json