Skip to content

Instantly share code, notes, and snippets.

@mikew
Created April 17, 2009 23:45
Show Gist options
  • Save mikew/97352 to your computer and use it in GitHub Desktop.
Save mikew/97352 to your computer and use it in GitHub Desktop.
#!/bin/sh
calculate ()
{
local value=$(echo "$*" | bc -q)
echo $value
}
float_conditional ()
{
local result=0
result=$(echo "$*" | bc -q)
result=$(($result == 0))
return $result
}
MIN_LAT=46.5
MAX_LAT=52
MIN_LON=52.5
MAX_LON=59.5
FACTOR=0.5
cd ~/tg2/MyScenery/work
echo "Enter piece width"
read WIDTH
echo "Enter piece height"
read HEIGHT
j=$(calculate "$MIN_LON + $WIDTH * $FACTOR")
i=$(calculate "$MIN_LAT + $HEIGHT * $FACTOR")
while float_conditional "$j < $MAX_LON"
do
while float_conditional "$i < $MAX_LAT"
do
fgfs-construct --work-dir=. \
--output-dir=Scenery/Terrain \
--lon=-$i --lat=$j \
--xdist=$WIDTH --ydist=$HEIGHT \
AirportArea AirportObj DEM-USGS-3 LandMass Cities Crops Forest Freeways Lakes Railroads Rivers Roads Towns
i=$(calculate "$i + $HEIGHT")
done
i=$(calculate "$MIN_LAT + $HEIGHT * $FACTOR")
j=$(calculate "$j + $WIDTH")
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment