#!/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,directory,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/$MAPSET ORTHOIGEN_EXEC=ossim-orthoigen arch=$(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 fi fi if [ $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" fi if [ -z $tiling ] ; then echo "You should set a tiling." exit 1 fi echo " // igen.slave_tile_buffers: 5 igen.tiling.type: ossimTiling igen.tiling.tiling_distance: 1 1 igen.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 1201 igen.tiling.delta: $tiling $tiling igen.tiling.delta_type: total_pixels //igen.tiling.tile_name_mask: %SRTM% igen.tiling.padding_size_in_pixels: 0 0 object1.description: object1.enabled: 1 object1.id: 1 object1.object1.description: object1.object1.enabled: 1 object1.object1.id: 2 object1.object1.resampler.magnify_type: bilinear object1.object1.resampler.minify_type: bilinear object1.object1.type: ossimImageRenderer object1.object2.type: ossimCastTileSourceFilter object1.object2.scalar_type: ossim_sint16 object1.type: ossimImageChain object2.type: ossimGeneralRasterWriter object2.byte_order: big_endian object2.create_overview: false object2.create_histogram: false object2.create_external_geometry: false product.projection.type: ossimEquDistCylProjection " > $orthoigen_srtm #create directory to store the output if [ -z $output_directory ] ; then output_directory=/tmp/ossim_output fi mkdir -p $output_directory cd $output_directory mkdir -p srtm_elevation g.region save=region.saved g.region rast=$elevation -a r.out.gdal input=$elevation format=GTiff type=Float32 output=$name g.region region.saved g.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