我对存储由GPS坐标(经度&纬度)和时间戳组成的GPS轨道的最有效(或最智能)方式感兴趣。MongoDB:如何存储包括时间戳在内的GPS轨迹
我在想这两个思路:
gpsTrack = {
"gps_track" : {
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": [104.0, 0.3]},
"properties": {
"absolute_timestamp" : "2011-12-31T23:50:59Z"
}
},
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": [128.0, 0.5]},
"properties": {
"absolute_timestamp" : "2011-12-31T23:59:59Z"
}
}
] }
}
或者使用以GeoJSON点对多点和时间戳作为数组。
gpsTrack = {
"geometry": {"type": "MultiPoint", "coordinates": [[104.0, 0.3], [128.0, 0.5]]},
"properties": {
"timestamps" : ["2011-12-31T23:50:59Z", "2011-12-31T23:59:59Z"]
}
航点总数假设为4.000至10.000,但肯定低于100.000。对于第一个想法,恐怕集合会变得很长,因为每个点和它的时间戳都是分开存储的。而第二个想法更加紧凑并且使用MultiPoint GeoJSON类型。
感谢您的输入。
是不是[LineString](https://docs.mongodb.com/manual/reference/geojson/#linestring)更适合跟踪数据的'MultiPoint'? – barbakini
可能是,但你不能在MongoDB中做任何地理空间查询。但我更关心如何加入时间戳。 – Matthias
MongoDB地理查询也支持LineString。在lineString或MultiPoint旁边,用于时间戳部分;如果你把坐标子数组中的时间标记作为第三个元素呢?我没有尝试,但很可能mongodb会忽略它的地理查询,但你可以使用它,并且将不需要匹配坐标数组和时间戳数组 – barbakini