Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ii unzip 6.0-16+deb8u2 amd64 De-archiver for .zip files
ii time 1.7-25 amd64 The GNU time program for measuring cpu resource usage
```

Success was also reported on Ubuntu, FreeBSD, and OpenBSD.
Success was also reported on Ubuntu, FreeBSD, OpenBSD and Archlinux.

## Configuration

Expand Down Expand Up @@ -61,7 +61,7 @@ down to:
## Usage

```
$ ./splat-radio.sh example.cfg
$ ./splat-radio.sh -c example.cfg
```

```
Expand Down
124 changes: 114 additions & 10 deletions splat-radio.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been targeting bourne shell for portability to BSD and OSX.

#
# Generate Splat map and HAAT calculation

Expand All @@ -16,12 +16,22 @@ TOPOFILEDIR=splat-datafiles/sdf/
# file for state/county borders
BORDERFILE=splat-datafiles/borders/co99_d00.dat

# Usage: ./splat-radio.sh example.cfg
#commands:
SPLAT=splat
SPLAT_HD=splat-hd

# load config
. ./$1
#default options:
USE_HIGHRES=false
USE_BGWHITE=false
SPLAT_CMD=$SPLAT
SPLAT_OPTIONS=("")
OPTIONS_RADIUS="100" #radius to render in [km]
OPTIONS_AGL="2" #above ground level for receiving antenna [m]
OPTIONS_MR="1.333" #Earth radius multiplier
OPTIONS_DB="160" #max attenuation to plot if no ERP given

if [ ! -x `which splat` ]; then
#we assume that splat-hd is installed too
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check if the user is going to use splat-hd.

echo "error: not found in path: splat"
exit 1
fi
Expand All @@ -36,8 +46,78 @@ if [ ! -x `which optipng` ]; then
exit 1
fi

# no more variables to edit below here

function helptext {
cat <<EOF

Usage: $0 -c CONFIGFILE [-b]

-c CONFIGFILE
The file with your configuration, see README.md

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we have these particular options on the command line and not the config file? I'm not sure of the use case.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the -b option is used to render images with white background instead of topography hillshading.
This allows calling the script by create_overlay.sh because white background can easily converted to transparency.

-r is used to quickly change between a large scale image (splat) and a detailed image (splat-hd). So you can render images with either tool without changing the configfile.

-R is just a convenience so i can adjust rendering radius (and therefore time) for debugging

-h and -c are to make it easier with getopts and get consistency

-R RADIUS
Render only up to a radius from QTH-File in [km]

-b Render Topograpy Background in white, used to generate
transparent overlays

-r Use splat-hd to render high-res images, implies
sdf-hd datafiles.

-h Display this help message

EOF
}

#Extract commandline options, see helptext for explanation
while getopts ":c:brhR:" opt; do
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bashism

case $opt in
b)
USE_BGWHITE=true
SPLAT_OPTIONS+=("-ngs")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bashism?

echo "Rendering Background in white, -b option set"
;;
r)
USE_HIGHRES=true
SPLAT_CMD=$SPLAT_HD
echo "Rendering high-res with splat-hd, -r option set"
;;
R)
OPTIONS_RADIUS=$OPTARG
echo "Setting rendering radius to ${OPTARG}km"
;;
c)
echo "Using configuration file: ${OPTARG}"
CONFIGFILE=$OPTARG
;;
h)
helptext
exit 1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
helptext
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
helptext
exit 1
;;
esac
done

#check for configfile, load if given
if [ ! -z "$CONFIGFILE" ] && [ -r $CONFIGFILE ]; then
echo "read in configfile"
source $CONFIGFILE
else
echo "No configfile given, exiting now"
helptext
exit 1
fi

# no more variables to edit below here
CLEANCALL=`echo $CALL | sed -e 's|/|-|g;'`
QTHFILE=$NAME.qth
LRPFILE=$NAME.lrp
Expand All @@ -49,6 +129,7 @@ MAPJPGTHMBFILE=$NAME-map-thumb.jpg
REPFILE=$CLEANCALL-site_report.txt
HAATFILE=$NAME-haat.txt


# invert the longitude, because splat is backwards
REVLON=`echo "$LON * -1" | bc`

Expand Down Expand Up @@ -146,14 +227,37 @@ EOF
# -d = path to elevation data files
# -o = output file
# -olditm = old ITM analysis, seems more accurate
if [ $ERP -eq 0 ] ; then
time $NICE splat -t $QTHFILE -R 100 -L 6 -m 1.333 -db 160 -erp $ERP \
-d $TOPOFILEDIR -b $BORDERFILE -olditm -o $MAPPPMFILE
# -ngs = display topograpy as white

#add all needed options:
#danger may not be compatible with spaces in filenames
SPLAT_OPTIONS+=("-olditm")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bashism?

SPLAT_OPTIONS+=("-metric")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the practical effect of this? Just HAAT output changes or something else?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this way splat treats all input/output in metric format.
I added this so that all input is treated equals wether or not the "m" is specified in the
configfile.
If this behaviour is intentional, we should comment out this flag

SPLAT_OPTIONS+=("-t ${QTHFILE}")
SPLAT_OPTIONS+=("-R ${OPTIONS_RADIUS}")
SPLAT_OPTIONS+=("-L ${OPTIONS_AGL}")
SPLAT_OPTIONS+=("-m ${OPTIONS_MR}")
SPLAT_OPTIONS+=("-o ${MAPPPMFILE}")
SPLAT_OPTIONS+=("-erp ${ERP}")
SPLAT_OPTIONS+=("-d ${TOPOFILEDIR}")

if [ -r $BORDERFILE ];then
SPLAT_OPTIONS+="-b ${BORDERFILE}"
else
time $NICE splat -t $QTHFILE -R 100 -L 6 -m 1.333 -erp $ERP \
-d $TOPOFILEDIR -b $BORDERFILE -olditm -o $MAPPPMFILE
echo "No Borderfile found, skipping"
fi

if [ $ERP -eq 0 ] ; then
echo "ERP is null, plot to max attenuation of ${OPTIONS_DB}db"
SPLAT_OPTIONS+="-db ${OPTIONS_DB} "
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bashism?

fi

echo "Running $SPLAT_CMD to generate images:"
echo "Options: ${SPLAT_OPTIONS[@]}"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bashism

#echo $SPLAT_CMD ${SPLAT_OPTIONS[@]}
time $NICE $SPLAT_CMD ${SPLAT_OPTIONS[@]}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bashism



rm -f $MAPPNGFILE $MAPJPGTHMBFILE

echo "converting PPM to PNG"
Expand Down