#!/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: export elevation data #%END #%flag #% guisection: elevation #% key: 2 #% description: copy data in ossm elevation folder #%END #%flag #% guisection: elevation #% key: a #% description: set the tiling size #%END #%flag #% guisection: elevation #% key: b #% description: use raster resolution to set the tiling (only for meters) #%END #%option #% guisection: elevation #% key: elevation #% type: string #% gisprompt: old,cell,raster #% description: Input elevation data #% required: no #%end #%option #% guisection: elevation #% key: tiling #% type: double #% description: tiling size #% required : no #%end #%option #% guisection: elevation #% key: directory #% type: string #% gisprompt: new_file,file,output #% description: directory where save output #% required : no #%end #%option #% guisection: elevation #% key: name #% type: string #% description: nome elevation export #% required : no #%end directory=$GIS_OPT_directory elevation=$GIS_OPT_elevation name=$GIS_OPT_name tiling=$GIS_OPT_tiling surface=$GIS_OPT_surface name_surf=$GIS_OPT_name_surf surf=$GIS_OPT_surf pcs=$GIS_OPT_pcs 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 arch=$(uname) if [[ $arch == 'Darwin' ]] ; then orthoigen='/private/var/tmp/XcodeBuilds/Release/orthoigen' fi if [[ $arch == 'Linux' ]]; then echo "epifan" orthoigen='/usr/local/bin/orthoigen' fi if [ $GIS_FLAG_1 -eq 1 ] ; then if [ $GIS_FLAG_a -eq 1 ] ; then #create directory to store the output mkdir $directory cd $directory mkdir srtm_elevation PROG=`basename $0` # Controlla se orthoigen è nel path for i in `echo $PATH | sed 's/^:/.:/ s/::/:.:/g s/:$/:./ s/:/ /g'` do if [ -f $i/orthoigen ] ; then # Save the path of the grass60 command # Use the first one in user's path break fi done g.region save=region.saved g.region rast=$elvation -a r.out.gdal input=$elevation format=GTiff type=Float32 output=$name g.region region.saved g.remove region=region.saved 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.kwl #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.kwl --view-template ./orthoigen_srtm.kwl --writer-template ./orthoigen_srtm.kwl --chain-template ./orthoigen_srtm.kwl $name srtm_elevation/%SRTM% if [ $GIS_FLAG_2 -eq 1 ] ; then cp -r srtm_elevation ~/.ossim/elevation/$name fi fi if [ $GIS_FLAG_b -eq 1 ] ; then #create directory to store the output mkdir $directory cd $directory mkdir srtm_elevation PROG=`basename $0` # Controlla se orthoigen è nel path for i in `echo $PATH | sed 's/^:/.:/ s/::/:.:/g s/:$/:./ s/:/ /g'` do if [ -f $i/orthoigen ] ; then # Save the path of the grass60 command # Use the first one in user's path break fi done g.region save=region.saved g.region rast=$elvation -a r.out.gdal input=$elevation format=GTiff type=Float32 output=$name g.region region.saved g.remove region=region.saved eval $( r.info $elevation -s ) tiling="`echo \"( (108000+$nsres)/$nsres )\"|bc `" 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.kwl $orthoigen --tiling-template ./orthoigen_srtm.kwl --view-template ./orthoigen_srtm.kwl --writer-template ./orthoigen_srtm.kwl --chain-template ./orthoigen_srtm.kwl $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 ~/.ossim/elevation/$name fi fi fi