Files
secondo/Tools/Converter/NMEA2Secondo/Traces2SecDB
2026-01-23 17:03:45 +08:00

166 lines
3.4 KiB
Plaintext

# !/bin/bash
#
# Script converting a set of traces into a relation of secondo.
#
#set defaults
TRACE=false
HEIGHT=false
SPEED=false
if [ "$1" = "--oldstyle" ]; then
END=")())"
shift
else
END="))";
fi
function showUsage() {
echo "usage: Traces2SecDB [options] <relation name> <file_1> ... <file_n>" >&2
echo "allowed options: " >&2
echo " -trace: extracts the trip as a moving point" >&2
echo " -height: extracts the height as a moving real" >&2
echo " -speed: extracts the speed as a moving real" >&2
echo " -all: the same as -trace -height -speed" >&2
echo " -maxDop=<maxDop>: sets the maximum dilution of prcision for measures of the height"
echo " -help: this help message" >&2
echo " Note: if no option is given, the tript is extracted from the nmea files" >&2
exit 1
}
function extractOption() {
options="$1"
pos=0
length=${#options}
while [ "$pos" -lt "$length" ]; do
arg=${options:pos:1}
case $arg in
h)
HEIGHT=true
;;
t)
TRACE=true
;;
s)
SPEED=true
;;
*)
echo "unknown argument : -$options" >&2
showUsage
;;
esac
(( pos += 1 ))
done
}
# parse arguments without getopts
OPTION=$1
OptId=${OPTION:0:1}
while [ "$OptId" = "-" ]; do
case $OPTION in
-height)
HEIGHT=true
;;
-trace)
TRACE=true
;;
-speed)
SPEED=true
;;
-all)
HEIGHT=true
SPEED=true
TRACE=true
;;
-help)
showUsage
;;
-maxDop=[0-9]*)
MAXDOP=${OPTION:8}
;;
*)
extractOption ${OPTION:1}
;;
esac
shift
OPTION=$1
OptId=${OPTION:0:1}
done
if [ "$TRACE" = "false" -a "$SPEED" = "false" -a "$HEIGHT" = "false" ]; then
# if no arguments are given, we switch to trace extraction
TRACE=true
fi
if [ -z $1 ]; then
echo "missing name of relation " >&2
showUsage
fi
NAME=$1
shift
CLASSPATH=$SECONDO_BUILD_DIR/Tools/Converter/NMEA2Secondo
ARGUMENTS=" file local 0.0 -value";
# print header
echo '( OBJECT '$NAME ' () (rel (tuple('
echo " (Name string) "
if [ "$TRACE" = "true" ]; then
echo " (Trip mpoint) "
fi
if [ "$SPEED" = "true" ]; then
echo " (Speed mreal) "
fi
if [ "$HEIGHT" = "true" ]; then
echo " (Height mreal) "
fi
echo " )))"
# open value list
echo ' ('
for f in $*
do
echo -ne '('
# remove .trx from filename if exists
pos=`expr index "$f" '\.'`
pos=$(expr $pos - 1 )
if [ "$pos" -gt "0" ]; then
name=${f:0:pos}
else
name=$f
fi
echo -ne "\""$name"\" "
if [ "$TRACE" = "true" ]; then
java -classpath $CLASSPATH NMEA2Secondo $f $ARGUMENTS $MAXDOP
fi
if [ $? -ne "0" ]; then
echo "problem in calling java program" >&2
exit -1
fi
if [ "$SPEED" = "true" ]; then
java -classpath $CLASSPATH NMEA_SpeedExtractor $f $ARGUMENTS $MAXDOP
fi
if [ $? -ne "0" ]; then
echo "problem in calling java program" >&2
exit -1
fi
if [ "$HEIGHT" = "true" ]; then
java -classpath $CLASSPATH NMEA2MReal $f $ARGUMENTS $MAXDOP
fi
if [ $? -ne "0" ]; then
echo "problem in calling java program" >&2
exit -1
fi
echo -ne ')'"\n"
done
# print end
echo "$END"