我正在尝试从深度嵌套的数组中删除重复的值。我将数据库的结构放在下面。我想将步骤的位置相互比较,并检查是否重复。我当时在考虑使用db.collection.aggregate
,但是在尝试搜索所有步骤时,这变成了一个问题,因为据我所知{ $unwind: '$mapbox.routes.legs.0.steps' }
要求这些步骤有特定的索引。
"mapboxRoute" : {
"routes" : [
{
"distance" : 105375,
"duration" : 8261.3,
"weight" : 11365.5,
"weight_name" : "routability",
"geometry" : "iv||H_{f^w@b@AFDZHb@DTBL?B@LN`ALx@BPA@WPEBc@X[PIFADFb@T|AHd@DZL~@@DF\\Hd@DVFVBPDL?BBL@DBFJb@FV?@BHDL@FKBa@`@MJx@y@@FKBa@`@MJi@b@WN]ROLSPWkAFS@s@Mg@Lf@Ar@GRVjAIHKJ_@b@INEFI^CHMPA@]\\IFa@\\s@l@MJMLIHe@b@_@^w@j@KFEBk@d@EDEDEBEBEBKJKHEBMLIHEDQDQLGFMHTQGFMHq@d@e@^GFg@b@ABQNCBIFWRQNm@h@QNa@\\ONGF?FAZBJv@vDd@xBd@fBj@hA`A`Cf@lAz@xBd@r@Z\\PRE\\CXCPB`A?r@A|@EdAR?DqABmDC]Ge@Me@m@yA}@wBiBeEo@uAg@cBMa@oAgGAKOU{AnAIFKJNRNMnAeABJNt@BNb@pBb@tB@BH\\ZhADF\\p@FN`A`Cf@lAHTFLDNb@dALRV^BBVXWYVZRPLHHDHDHDJCRCLAPG~@UNGLEDCRGPGJEl@UJEREBAVA\\BLBHF@@PPHJJJNPBDFLBBL^Qc@BBL`@DJBDHPDPHNDJHPFJ@BBDPRPRNNRPBBHFNPDJP\\BDNf@@D`BlHHTBLP^T^BBRVFFDBVLj@VLF~@b@FBGCHDJDB@ZJJF`@PTJNJZN^ZJHVVRTFJRVr@bAHJf@v@DFDF@BJL`@n@l@~@RXT^T\\f@t@FH@@LRLRjAjB`@r@r@hA~AhCVj@kD_Gr@hA~AhCVj@Zl@BFXj@`@z@Xp@N^HTXx@FPVz@Vv@Tt@@Fd@xAPn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Z??H`@?@DT??BL???B@LN`A??Lx@??BP",
"name" : "Mariaplaats",
"ref" : null,
"destinations" : null,
"exits" : null,
"driving_side" : "right",
"mode" : "driving",
"maneuver" : {
"location" : [
5.117934,
52.089493
]
有人知道我如何比较步骤的位置吗?
答案 0 :(得分:0)
最后,我停止制作用于连接mongodb和清理数据库的单独文件,并开始使用现有的API创建调用。在此调用中,我循环浏览了数据库中的步骤,并将位置映射到键。之后,我检查该键是否已经存在并将该索引推入重复数组。
然后,我继续遍历重复列表,并使用步骤将列表中的重复项拼接起来。之后,我运行以下函数来更新条目:Sub test()
Dim arr As Variant, aKeys As Variant, aItems As Variant
Dim dict As New Scripting.Dictionary
Dim posArr As String
Dim i As Long, k As Long
With Sheets("Sheet1")
arr = .Range(.Cells(2, 1), .Cells(.Cells(.Rows.Count, 1).End(xlUp).Row, 2))
End With
With Application
' Separates the arr array into two 1D arrays
aKeys = .Transpose(.Index(arr, 0, 1))
aItems = .Transpose(.Index(arr, 0, 2))
' Loops through aKeys array
For i = LBound(aKeys) To UBound(aKeys)
' Reset the posArr string, this is used for indexing the arrays at the correct locations
posArr = vbNullString
' Test if key already exists in dictionary. As we are getting all the possible values in one go we don't
' need to worry about if it does exist. Testing here means we skip the second loop if not needed
If Not dict.Exists(aKeys(i)) Then
' Loop through aKeys to find all the positions of the items we want in the array
For k = LBound(aKeys) To UBound(aKeys)
' If the key in position k is equal to the key in position i then add it to posArr string
If aKeys(k) = aKeys(i) Then
' We will late split this into an array itself on the "," delimiter
posArr = posArr & k & ","
End If
Next k
' Add our key and all our matching items to the dictionary
' Here we split the posArr string on the "," delimiter and index the aItems array. This returns
' All the values from aItems that have a matching position in the aKeys array.
' For this to work it aKeys and aItems must have the exact same size (i.e. 1D and matching length)
dict.Add Key:=aKeys(i), Item:=.Index(aItems, Split(Left(posArr, Len(posArr) - 1), ","))
End If
Next i
End With
' Read back the dictionary
' Delete this and update with whatever you want to do with your data - This is currently just a check everything
' has worked as expected
Dim dictKey
Dim dictStr As String
dictStr = "{"
For Each dictKey In dict.Keys
dictStr = dictStr & vbNewLine & vbTab & "'" & dictKey & "':[" & Join(dict(dictKey), ",") & "],"
Next dictKey
dictStr = Left(dictStr, Len(dictStr) - 1) & vbNewLine & "}"
MsgBox dictStr
End Sub