为 ONVIF 设备增加经纬度标签以支持 Geomap
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -31,7 +31,7 @@ ONVIF_TEMP=$(mktemp)
|
||||
PING_TEMP=$(mktemp)
|
||||
|
||||
# 处理CSV文件(跳过注释行和标题行)
|
||||
tail -n +2 "$CSV_FILE" | grep -v '^#' | while IFS=',' read -r type ip device group network device_type model location username password onvif_port; do
|
||||
tail -n +2 "$CSV_FILE" | grep -v '^#' | while IFS=',' read -r type ip device group network device_type model location username password onvif_port lat lon; do
|
||||
# 去除空格
|
||||
type=$(echo "$type" | xargs)
|
||||
ip=$(echo "$ip" | xargs)
|
||||
@@ -49,6 +49,8 @@ tail -n +2 "$CSV_FILE" | grep -v '^#' | while IFS=',' read -r type ip device gro
|
||||
username=$(echo "$username" | xargs)
|
||||
password=$(echo "$password" | xargs)
|
||||
onvif_port=$(echo "$onvif_port" | xargs)
|
||||
lat=$(echo "$lat" | xargs)
|
||||
lon=$(echo "$lon" | xargs)
|
||||
|
||||
labels="{
|
||||
\"device_type\": \"$device_type\",
|
||||
@@ -61,6 +63,16 @@ tail -n +2 "$CSV_FILE" | grep -v '^#' | while IFS=',' read -r type ip device gro
|
||||
labels="$labels,
|
||||
\"onvif_port\": \"$onvif_port\""
|
||||
fi
|
||||
|
||||
if [ -n "$lat" ]; then
|
||||
labels="$labels,
|
||||
\"lat\": \"$lat\""
|
||||
fi
|
||||
|
||||
if [ -n "$lon" ]; then
|
||||
labels="$labels,
|
||||
\"lon\": \"$lon\""
|
||||
fi
|
||||
|
||||
labels="$labels
|
||||
}"
|
||||
|
||||
Reference in New Issue
Block a user