我正在尝试使用节点js在mongodb中的两个集合之间进行查询.
我在db中有这两个集合:
旅
{
"_id":ObjectId("55a922531e35772c1b17d4a0"),
"name":"trip_name",
"waypoints":[
"4c828999d8086dcb03877752",
"4dd2ae657d8b4c6585f1a6fd",
"4c59c3e4f346c928a8634dca"
],
"line_points":[
[
42.850937,
13.569256
],
[
42.85109,
13.569377
],
[
42.851131,
13.569225
]
],
"time":"00:10:23",
"distance":6.622,
"hashKey":"object:8207"
};
Run Code Online (Sandbox Code Playgroud)
POI
{
"_id":"4c828999d8086dcb03877752",
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[
13.575249910354614,
42.85484995890166
]
},
"properties":{
"title":"Lorenz Cafè",
"id":"4c828999d8086dcb03877752",
"poi-type":1,
"category":"ristorazione",
"subCategory":"Café",
"categoryIds":"4bf58dd8d48988d16d941735",
"marker-color":"#FF7519",
"marker-size":"small",
"marker-symbol":"restaurant",
"indirizzo":"Piazza del Popolo, 5",
"citta":"Ascoli Piceno",
"regione":"Marche"
}
Run Code Online (Sandbox Code Playgroud)
通过这条路线,我根据id那个步骤进行查询,我希望查询我会像这样恢复一个json:
我想要的结果
{"_id":"55a922531e35772c1b17d4a0","name":"trip_name","waypoints":[{"4c828999d8086dcb03877752":{"title":"Lorenz Cafè","id":"4c828999d8086dcb03877752","category":"ristorazione","position":{"lat":42.85484995890166,"lng":13.575249910354614}}},{"4dd2ae657d8b4c6585f1a6fd":{"title":"Ottica Di Ferdinando","id":"4dd2ae657d8b4c6585f1a6fd","category":"negozi","position":{"lat":42.85485741498569,"lng":13.57675423240643}}},{"4c59c3e4f346c928a8634dca":{"title":"Leopoldus Ristorante","id":"4c59c3e4f346c928a8634dca","category":"ristorazione","position":{"lat":42.85648980743132,"lng":13.575512766838072}}}],"line_points":[[42.850937,13.569256],[42.85109,13.569377],[42.851131,13.569225]],"time":"00:10:23","distance":6.622}
Run Code Online (Sandbox Code Playgroud)
我实现了这条路线:
/*
TRIP BY ID
*/
var j=0;
router.get('/:id', function(req, res) { …Run Code Online (Sandbox Code Playgroud) 我想在同一情节中多个堆叠的酒吧。这是我的代码:
file_to_plot = file_to_plot.set_index(['user'])
fig, ax = plt.subplots()
fontP = FontProperties()
fontP.set_size('small')
file_to_plot[[" mean_accuracy_all_classes_normal", " delta_all_classes"]].plot(ax=ax, kind='bar', color= ['g', 'r'], width = 0.65, align="center", stacked=True)
file_to_plot[[" mean_accuracy_user_classes_normal", " delta_user_classes"]].plot(ax=ax, kind='bar', color=['y', 'b'], width=0.65, align="center", stacked = True)
lgd = ax.legend(['Tutte le classi (normale)', 'Tutte le classi (incrementale)', 'Classi utente (normale)', 'Classi utente (incrementale)'], prop=fontP, loc=9, bbox_to_anchor=(0.5, -0.15), ncol=4,borderaxespad=0.)
ax.set_ylabel('% Accuratezza')
ax.set_xlabel('Utenti')
Run Code Online (Sandbox Code Playgroud)
结果如下: