
Documentation Center
//TTN
case
1
:
gw_lat
[
idx
]
=
rawPayload
.
uplink_message
.
rx_metadata
[
idx
].
location
.
latitude
;
gw_long
[
idx
]
=
rawPayload
.
uplink_message
.
rx_metadata
[
idx
].
location
.
longitude
;
break
;
// Helium
case
2
:
gw_lat
[
idx
]
=
rawPayload
.
hotspots
[
idx
].
lat
;
gw_long
[
idx
]
=
rawPayload
.
hotspots
[
idx
].
long
;
break
;
// Chirpstack
case
3
:
gw_lat
[
idx
]
=
rawPayload
.
rxInfo
[
idx
].
location
.
latitude
;
gw_long
[
idx
]
=
rawPayload
.
rxInfo
[
idx
].
location
.
longitude
;
break
;
default
:
console
.
log
(
"Unknown LNS"
);
break
;
}
console
.
log
(
"IDX "
+
idx
+
" lat "
+
gw_lat
[
idx
]
+
" long "
+
gw_long
[
idx
]);
// decoded.gw_lat[idx] = gw_lat;
// decoded.gw_long[idx] = gw_long;
// Calculate distance
var
new_distance
=
distance
(
gw_lat
[
idx
],
gw_long
[
idx
],
decoded
.
latitude
,
decoded
.
long
if
((
new_distance
<
decoded
.
minDistance
)
||
(
decoded
.
minDistance
==
0
))
{
decoded
.
minDistance
=
new_distance
*
1000
;
}
if
((
new_distance
>
decoded
.
maxDistance
)
||
(
decoded
.
maxDistance
==
0
))
{
decoded
.
maxDistance
=
new_distance
*
1000
;
}
}
switch
(
decoded
.
num_gw
)
{
case
20
:
decoded
.
hotspot_10
=
"("
+
gw_lat
[
19
]
+
","
+
gw_long
[
19
]
+
")"
;
case
19
:
decoded
.
hotspot_09
=
"("
+
gw_lat
[
18
]
+
","
+
gw_long
[
18
]
+
")"
;
case
18
:
decoded
.
hotspot_08
=
"("
+
gw_lat
[
17
]
+
","
+
gw_long
[
17
]
+
")"
;
case
17
:
decoded
.
hotspot_07
=
"("
+
gw_lat
[
16
]
+
","
+
gw_long
[
16
]
+
")"
;
case
16
:
decoded
.
hotspot_06
=
"("
+
gw_lat
[
15
]
+
","
+
gw_long
[
15
]
+
")"
;
case
15
:
decoded
.
hotspot_05
=
"("
+
gw_lat
[
14
]
+
","
+
gw_long
[
14
]
+
")"
;
case
14
:
decoded
.
hotspot_04
=
"("
+
gw_lat
[
13
]
+
","
+
gw_long
[
13
]
+
")"
;
case
13
:
decoded
.
hotspot_03
=
"("
+
gw_lat
[
12
]
+
","
+
gw_long
[
12
]
+
")"
;
case
12
:
decoded
.
hotspot_02
=
"("
+
gw_lat
[
11
]
+
","
+
gw_long
[
11
]
+
")"
;
case
11
:
decoded
.
hotspot_01
=
"("
+
gw_lat
[
10
]
+
","
+
gw_long
[
10
]
+
")"
;
case
10
:
decoded
.
hotspot_10
=
"("
+
gw_lat
[
9
]
+
","
+
gw_long
[
9
]
+
")"
;
case
9
:
decoded
.
hotspot_09
=
"("
+
gw_lat
[
8
]
+
","
+
gw_long
[
8
]
+
")"
;
case
8
:
decoded
.
hotspot_08
=
"("
+
gw_lat
[
7
]
+
","
+
gw_long
[
7
]
+
")"
;
case
7
:
decoded
.
hotspot_07
=
"("
+
gw_lat
[
6
]
+
","
+
gw_long
[
6
]
+
")"
;