OK, so I have the data from downloading but I need to get the geocoding compatible. This works well for me:
[{$addFields: {
actorCodes: {
$concatArrays: [
[
'$Actor1Name'
],
[
'$Actor2Name'
]
]
},
geoCodes: {
$concatArrays: [
[
[
'$ActionGeo_Long',
'$ActionGeo_Lat'
]
],
[
[
'$Actor1Geo_Long',
'$Actor1Geo_Lat'
]
],
[
[
'$Actor2Geo_Long',
'$Actor2Geo_Lat'
]
]
]
}
}}, {$addFields: {
geoCodes: {
$map: {
input: '$geoCodes',
as: 'a',
'in': {
$map: {
input: '$$a',
as: 'b',
'in': {
$convert: {
input: '$$b',
to: 'double',
onError: ''
}
}
}
}
}
}
}}, {$addFields: {
geoCodes: {
$filter: {
input: '$geoCodes',
as: 'b',
cond: {
$and: [
{
$ne: [
{
$arrayElemAt: [
'$$b',
0
]
},
''
]
},
{
$ne: [
{
$arrayElemAt: [
'$$b',
1
]
},
''
]
}
]
}
}
}
}}, {$addFields: {
points: {
$map: {
input: '$geoCodes',
'in': {
geometry: {
type: 'Point',
coordinates: '$$this'
}
}
}
}
}}, {$project: {
geoCodes: 0
}}, {$merge: {
into: 'eventscsv',
on: '_id',
whenMatched: 'replace',
whenNotMatched: 'discard'
}}]