Skip to content

Instantly share code, notes, and snippets.

@tomkralidis
Last active December 31, 2015 05:58
Show Gist options
  • Save tomkralidis/7944157 to your computer and use it in GitHub Desktop.
Save tomkralidis/7944157 to your computer and use it in GitHub Desktop.
WorldWeatherSymbols usage in MapServer
#!/bin/sh
WMO_SYMBOLS_DIR=build/WorldWeatherSymbols
if [ ! -d $WMO_SYMBOLS_DIR ]; then
echo "Downloading WMO World Weather Symbols"
git clone https://github.com/OGCMetOceanDWG/WorldWeatherSymbols.git $WMO_SYMBOLS_DIR
echo "Converting all symbols to PNG"
$WMO_SYMBOLS_DIR/scripts/wws_manage.sh png
echo "Rotating missing wind arrows image 90 degrees CCW"
convert $WMO_SYMBOLS_DIR/png/WeatherSymbol_WMO_WindArrowMissing_99.png -rotate -90 $WMO_SYMBOLS_DIR/png/WeatherSymbol_WMO_WindArrowMissing_99.png
echo "Rotating north wind arrows images 90 degrees CW"
for sym in `find $WMO_SYMBOLS_DIR/png -type f -name "WeatherSymbol_WMO_WindArrowNH*.png"`
do
convert ${sym} -rotate 90 ${sym}
done
echo "Rotating south wind arrows images 90 degrees CCW"
for sym in `find $WMO_SYMBOLS_DIR/png -type f -name "WeatherSymbol_WMO_WindArrowSH*.png"`
do
convert ${sym} -rotate -90 ${sym}
done
else
echo "$WMO_SYMBOLS_DIR already exists"
fi
Notes:
- two columns need to exist in data table
- WIND_DIRECTION_COLUMN: this is the angle, in degrees, which drives the symbol rotation
- WIND_SPEED_SYMBOL_ABSOLUTE_FILEPATH: this is managed in the data table as an easy means to specify the symbol as driven from the data. This requires a pre-processing step to set the filepath column value based on the wind speed value of an observation. We bind the SYMBOL object like this to save from specifying numerous class defs
Steps:
- build the WorldWeatherSymbols PNGs (build.sh)
- FYI once the symbols are converted in SVG (see https://github.com/OGCMetOceanDWG/WorldWeatherSymbols/issues/7), the rotation steps in build.sh will not be required
- add wind_speed-class.inc to the LAYER def
## STYLES=wind_speed
CLASSGROUP "wind_speed"
CLASS #
NAME "Wind Speed (km/h)"
GROUP "wind_speed"
TEXT ""
STYLE
ANGLE [WIND_DIRECTION_COLUMN]
SYMBOL [WIND_SPEED_SYMBOL_ABSOLUTE_FILEPATH]
SIZE 30
END
LABEL
TYPE truetype
FONT arial
SIZE 8
OUTLINECOLOR 255 255 255
OUTLINEWIDTH 2
COLOR 46 46 46
POSITION AUTO
MAXSCALEDENOM 11000000
END
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment