#!/bin/sh############################################################################## MODULE: r.out.planet## AUTHOR(S): Di Stefano Massimo# ## PURPOSE: convert elevation data from grass mapset to ossim srtm data# ## COPYRIGHT: (c) 2006 by the GRASS Development Team## This program is free software under the GNU General Public# License (>=v2). Read the file COPYING that comes with GRASS# for details.## REQUIRES: OSSIM (OpenSource-Software-Image-Mapping)# ###############################################################################%Module#% description: load/convert data from grass mapset into ossim #%End#%flag#% guisection: elevation#% key: 1#% description: use raster resolution to set the tiling (only for meters)#%END#%flag#% guisection: elevation#% key: 2#% description: copy data in ossm elevation folder #%END#%option#% guisection: elevation#% key: elevation#% type: string#% gisprompt: old,cell,raster#% description: Input elevation data#% required: yes#%end#%option#% guisection: elevation#% key: name#% type: string#% description: Name elevation export#% required : yes#%end#%option#% guisection: elevation#% key: output_directory#% type: string#% gisprompt: new_file,file,output#% description: Directory where save output (default /tmp/ossim_output)#% required : no#%end#%option#% guisection: elevation#% key: tiling#% type: double#% description: Tiling size #% required : no#%end output_directory=$GIS_OPT_output_directory elevation=$GIS_OPT_elevation name=$GIS_OPT_name tiling=$GIS_OPT_tiling orthoigen_srtm="/tmp/orthoigen_srtm.kwl" if [ -z $GISBASE ] ; then echo "You must be in GRASS GIS to run this program." exit 1 fi if [ "$1" != "@ARGS_PARSED@" ] ; then exec g.parser "$0" "$@" fi### setup enviro vars ###eval `g.gisenv`: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}LOCATION=$GISDBASE/$LOCATION_NAME/$MAPSETORTHOIGEN_EXEC=ossim-orthoigenarch=$(uname)if [[ $arch == 'Darwin' ]] ; then orthoigen='/private/var/tmp/XcodeBuilds/Release/ossim-orthoigen'elif [[ $arch == 'Linux' ]]; then echo "epifan" # Controlla se orthoigen è nel path for i in `echo $PATH | sed 's/:/ /g'` do orthoigen=$i/$ORTHOIGEN_EXEC if [ -f $orthoigen ] ; then # Save the path of the grass60 command # Use the first one in user's path echo "Using the orthogen: $orthoigen" break fi done if [ ! -f $orthoigen ] ; then echo "Orthoigen execatable not found!" exit 1 fifiif [ $GIS_FLAG_1 -eq 1 ] ; then echo "Using raster resolution to set the tiling" eval $( r.info $elevation -s ) tiling="`echo \"( (108000+$nsres)/$nsres )\"|bc `" echo "Tiling size: $tiling"fiif [ -z $tiling ] ; then echo "You should set a tiling." exit 1fiecho "//igen.slave_tile_buffers: 5igen.tiling.type: ossimTilingigen.tiling.tiling_distance: 1 1igen.tiling.tiling_distance_type: degrees// for 5 meters use tiling = 21601 21601// for 10 meters use tiling = 10801 10801// for 30 meters use tiling = 3601 3601// for 90 meters use tiling = 1201 1201igen.tiling.delta: $tiling $tilingigen.tiling.delta_type: total_pixels//igen.tiling.tile_name_mask: %SRTM%igen.tiling.padding_size_in_pixels: 0 0object1.description:object1.enabled: 1object1.id: 1object1.object1.description: object1.object1.enabled: 1object1.object1.id: 2object1.object1.resampler.magnify_type: bilinearobject1.object1.resampler.minify_type: bilinearobject1.object1.type: ossimImageRendererobject1.object2.type: ossimCastTileSourceFilterobject1.object2.scalar_type: ossim_sint16object1.type: ossimImageChainobject2.type: ossimGeneralRasterWriterobject2.byte_order: big_endianobject2.create_overview: falseobject2.create_histogram: falseobject2.create_external_geometry: falseproduct.projection.type: ossimEquDistCylProjection" > $orthoigen_srtm#create directory to store the outputif [ -z $output_directory ] ; then output_directory=/tmp/ossim_outputfimkdir -p $output_directorycd $output_directorymkdir -p srtm_elevationg.region save=region.savedg.region rast=$elvation -ar.out.gdal input=$elevation format=GTiff type=Float32 output=$nameg.region region.savedg.remove region=region.saved#export DYLD_FRAMEWORK_PATH = /var/tmp/XcodeBuilds/Release/#export GDAL_DRIVER_PATH = /Users/Shared/source/grass7/distLEO/#export OSSIM_PREFS_FILE = /Users/sasha/ossim_preferences$orthoigen --tiling-template $orthoigen_srtm --view-template $orthoigen_srtm --writer-template $orthoigen_srtm --chain-template $orthoigen_srtm $name srtm_elevation/%SRTM%if [ $GIS_FLAG_2 -eq 1 ] ; then #cp -r srtm_elevation /Library/Application\ Support/ossim/elevation/$name cp -r srtm_elevation $HOME/.ossim/elevation echo "srtm_elevation was copied to $HOME/.ossim/elevation"fi