如何以以下格式存储数据?
var markers = {
type: "FeatureCollection",
features: $.map([
{
coordinates: [-74, 40.7],
text: "New York City",
value: 8406
},
{
coordinates: [100.47, 13.75],
text: "Bangkok",
value: 8281
},
{
coordinates: [44.43, 33.33],
text: "Baghdad",
value: 7181
},
{
coordinates: [37.62, 55.75],
text: "Moscow",
value: 12111
},
{
coordinates: [121.5, 31.2],
text: "Shanghai",
value: 24150
},
{
coordinates: [-43.18, -22.9],
text: "Rio de Janeiro",
value: 6429
},
{
coordinates: [31.23, 30.05],
text: "Cairo",
value: 8922
},
{
coordinates: [28.95, 41],
text: "Istanbul",
value: 14160
},
{
coordinates: [127, 37.55],
text: "Seoul",
value: 10388
},
{
coordinates: [139.68, 35.68],
text: "Tokyo",
value: 9071
},
{
coordinates: [103.83, 1.28],
text: "Singapore",
value: 5399
},
{
coordinates: [30.3, 59.95],
text: "Saint Petersburg",
value: 5131
},
{
coordinates: [28.03, -26.2],
text: "Johannesburg",
value: 4434
},
{
coordinates: [144.95, -37.8],
text: "Melbourne",
value: 4252
}
], function (data) {
return {
type: "Feature",
geometry: {
type: "Point",
markers: data.coordinates
},
properties: {
text: data.text,
value: data.value,
tooltip: "<b>" + data.text + "</b>\n" + data.value + "K"
}
};
})
};
如果我的数据库包含纬度,经度,计数为值,邮政编码为文本
CT postcode latitude longitude
1 EC1WER 51.52514 -0.111183
3 E1 WQP 51.5125 -0.052098
3 EC1WER 51.52514 -0.111183
答案 0 :(得分:0)
很明显,您要将2d对象存储到Db中。 mongoDb非常适合非结构化数据存储。您可以通过使用Geo-Json来受益。 链接在这里 https://docs.mongodb.com/manual/geospatial-queries/
您可以具有许多功能,例如坐标相交,geoWithin,geoNear ...等。