How to update location #2
Replies: 4 comments
-
|
Hey @ilarimikkonen and many thanks! |
Beta Was this translation helpful? Give feedback.
-
|
Hey again @ilarimikkonen ! <?xml version="1.0"?>
<gpx version="1.1" creator="gpxgenerator.com">
<wpt lat="51.726578514305174" lon="8.759472002022175">
<ele>112.62</ele>
<time>2021-03-30T09:53:58Z</time>
</wpt>
<wpt lat="51.72652534946479" lon="8.759300340645222">
<ele>112.75</ele>
<time>2021-03-30T09:53:59Z</time>
</wpt>
</gpx>Using xmlscarlet in a bash-script makes it easy to parse such a gpx-file. #!/bin/bash
# empty arrays for the values
lat=()
lon=()
time=()
# read latitudes
for l in $(xmlstarlet select -t -v '//wpt/@lat' sample.gpx)
do
lat+=("$l")
done
# read longitudes
for l in $(xmlstarlet select -t -v '//wpt/@lon' sample.gpx)
do
lon+=("$l")
done
# read times
for t in $(xmlstarlet select -t -v '//wpt/time' sample.gpx)
do
time+=("$t")
done
# show what we've got
echo "Found "${#lat[@]}" latitudes."
echo "Found "${#lon[@]}" longitudes."
echo "Found "${#time[@]}" times."
echo
# TODO: check if the array sizes are identical
# loop though arrays
StartDate=$(date -u -d "${time[0]}" +"%s.%N")
for (( i=0; i<${#lat[@]}; i++ ))
do
echo "Waypoint #$i:"
# calculate sleep
ThisDate=$(date -u -d "${time[$i]}" +"%s.%N")
difference=$(awk '{print $1-$2}' <<< "$ThisDate $StartDate")
echo "Sleeping for "$difference" second(s)"
sleep $difference
StartDate=$ThisDate
echo "lat: ${lat[$i]}"
echo "lon: ${lon[$i]}"
echo
doneHaving called OpenSim instead of echoing latitude and longitude will be an easy task. I think it's worth a new "how to" for this use case...So feel free to play around with the script above or simply wait until the "howto.md" is written :-) |
Beta Was this translation helpful? Give feedback.
-
|
You can quickstart with the two attached files (sample.gpx is a very short route and track.sh is the script from above). ./datasim.py -s http://orion:1026 --tenant magicbeans-y beanbag -ad dateObserved -an temperature,f,21.5 -al location,${lat[$i]},${lon[$i]} -an batteryLevel,i,99 -an speed,i,12 -i -m 2 |
Beta Was this translation helpful? Give feedback.
-
|
Hey @ilarimikkonen . |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @WillFreitag cool tool!
I used it like this to update location:
floating match is kinda hard in shell scripting
Beta Was this translation helpful? Give feedback.
All reactions