[GRASS-SVN] r40329 - grass-addons/vector/v.surf.icw

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 8 21:23:55 EST 2010


Author: hamish
Date: 2010-01-08 21:23:54 -0500 (Fri, 08 Jan 2010)
New Revision: 40329

Modified:
   grass-addons/vector/v.surf.icw/v.surf.icw
Log:
allow coeff of friction to be FP, placeholder stuff for a max_cost= option

Modified: grass-addons/vector/v.surf.icw/v.surf.icw
===================================================================
--- grass-addons/vector/v.surf.icw/v.surf.icw	2010-01-08 21:44:51 UTC (rev 40328)
+++ grass-addons/vector/v.surf.icw/v.surf.icw	2010-01-09 02:23:54 UTC (rev 40329)
@@ -68,7 +68,7 @@
 #%end
 #%option
 #% key: friction
-#% type: integer
+#% type: double
 #% description: Friction of distance, (the 'n' in 1/d^n)
 #% answer: 2
 #% options: 1-6
@@ -88,6 +88,14 @@
 #% description: Example: income < 1000 and inhab >= 10000
 #% required : no
 #%end
+
+##%option
+##% key: max_cost
+##% type: integer
+##% description: Optional maximum cumulative cost before setting weight to zero
+##% required : no
+##%end
+
 #%option
 #% key: post_mask
 #% type: string
@@ -137,10 +145,13 @@
     exit 1
 fi
 
-DIVISOR=""
-if [ "$FRICTION" -eq 4 ] ; then DIVISOR=" / 10.0" ; fi
-if [ "$FRICTION" -eq 5 ] ; then DIVISOR=" / 100.0" ; fi
-if [ "$FRICTION" -eq 6 ] ; then DIVISOR=" / 500.0" ; fi
+# adjust so that tiny numbers don't hog all the FP precision space
+#DIVISOR=""
+#if [ "$FRICTION" -eq 4 ] ; then DIVISOR=" / 10.0" ; fi
+#if [ "$FRICTION" -eq 5 ] ; then DIVISOR=" / 100.0" ; fi
+#if [ "$FRICTION" -eq 6 ] ; then DIVISOR=" / 500.0" ; fi
+# fp version:
+DIVISOR=`echo "$FRICTION" | awk '{if ( $1 > 4 ) {print 0.01 * $1^6 }}'`
 
 
 POINTS_FILE="$GIS_OPT_INPUT"
@@ -233,7 +244,9 @@
     fi
 
 #    echo "$EASTING $NORTHING $DATA_VALUE" | v.in.ascii output=tmp_idw_cost_site_$$ fs=space --o 2> /dev/null
-    r.cost $VERBOSE -k in=tmp_icw_area_$$ output=cost_site.$NUM coordinate=$EASTING,$NORTHING
+    r.cost $VERBOSE -k in=tmp_icw_area_$$ output=cost_site.$NUM \
+        coordinate=$EASTING,$NORTHING
+        #max_cost="$GIS_OPT_MAX_COST"  : commented out until r.null cleansing/continue code is sorted out
         #start_points=tmp_idw_cost_site_$$
 
     # so the divisor exists and the weighting is huge at the exact sample spots



More information about the grass-commit mailing list