clean up aircraft operator name for MQTT

This commit is contained in:
kx1t
2024-12-11 13:59:47 -05:00
parent 8af679502c
commit 553084749a
2 changed files with 5 additions and 3 deletions

View File

@@ -407,17 +407,19 @@ then
#Get an owner if there's none, we have a tail number and we are in the US
OWNER="${TAGLINE[2]}"
if [[ -z $OWNER ]] && [[ -n $TAIL ]]; then
if [[ -z "$OWNER" ]] && [[ -n $TAIL ]]; then
#if [[ "${TAIL:0:1}" == "N" ]]; then
if [[ $TAIL =~ ^N[0-9][0-9a-zA-Z]+$ ]]; then
OWNER="$(/usr/share/planefence/airlinename.sh "$TAIL")"
fi
fi
#Get an owner if there's none and there is a flight number
if [[ -z $OWNER ]] && [[ -n ${pa_record[8]/ */} ]]; then
if [[ -z "$OWNER" ]] && [[ -n ${pa_record[8]/ */} ]]; then
OWNER="$(/usr/share/planefence/airlinename.sh "${pa_record[8]/ */}")"
fi
if [[ -n "$OWNER" ]]; then OWNER="$(echo "${OWNER}" | xargs -0)"; fi # clean up any stray spaces
# now put all relevant info into the associative array:
msg_array[icao]="${pa_record[0]//#/}"
msg_array[tail]="${pa_record[1]//#/}"

View File

@@ -351,7 +351,7 @@ then
msg_array[icao]="${RECORD[0]}"
msg_array[flight]="${RECORD[1]#@}"
msg_array[operator]="${AIRLINE}"
msg_array[operator]="$(echo "${AIRLINE}" | xargs -0)"
if [[ -n "$ROUTE" ]]; then
if [[ "${ROUTE:0:4}" == "org:" ]]; then msg_array[origin]="${ROUTE:6}"
elif [[ "${ROUTE:0:5}" == "dest:" ]]; then msg_array[destination]="${ROUTE:7}"