[GRASS-SVN] r34023 - grass/trunk/scripts/d.out.gpsdrive

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Oct 27 12:12:14 EDT 2008


Author: hamish
Date: 2008-10-27 12:12:14 -0400 (Mon, 27 Oct 2008)
New Revision: 34023

Modified:
   grass/trunk/scripts/d.out.gpsdrive/d.out.gpsdrive
   grass/trunk/scripts/d.out.gpsdrive/d.out.gpsdrive.html
Log:
* fix parsing of g.region after "cosmetic" change of module output.
* comment on and report convergence angle.
* update to new gpsdrive default map dir.


Modified: grass/trunk/scripts/d.out.gpsdrive/d.out.gpsdrive
===================================================================
--- grass/trunk/scripts/d.out.gpsdrive/d.out.gpsdrive	2008-10-27 16:09:18 UTC (rev 34022)
+++ grass/trunk/scripts/d.out.gpsdrive/d.out.gpsdrive	2008-10-27 16:12:14 UTC (rev 34023)
@@ -9,7 +9,7 @@
 #
 # PURPOSE:      Export display monitor to a gpsdrive compatible image
 #
-# COPYRIGHT:    (c) 2005 The GRASS Development Team
+# COPYRIGHT:    (c) 2005-2008 The GRASS Development Team
 #
 #               This program is free software under the GNU General Public
 #               License (>=v2). Read the file COPYING that comes with GRASS
@@ -33,10 +33,21 @@
 #    2817 is maybe someones screen dpi converted to pixels/meter??
 #
 #  At scales wider than say 1:250,000 the curvatute of the Earth really starts
-#   to play havoc with gpsDrive's simple projection system if you are using
+#   to play havoc with GpsDrive's simple projection system if you are using
 #   a UTM or other non-lat/lon projection. Best to use output from a lat/lon
-#   location in that case.
+#   location in that case. i.e. to avoid distortion, anything more global than
+#   1:150k to 1:500k should use "top_*".
 #
+# Beware  if you are using an image originating from a map projection with
+# a significant deviation between true  north  and  the  map  projection's
+# local  +y  direction  (known as the Convergence Angle). GpsDrive assumes
+# that true north is always directly up! i.e. the Central Meridian of  the
+# map projection is located at the map tile's center. For some map projec-
+# tions and areas of the country this can be a really bad  assumption  and
+# your  map  will be significantly rotated. This effect is most visible at
+# map scales covering a large area. This does not affect lat/lon maps.
+# The pnmrotate program may help, or gdalwarp to a custom map-centered tmerc.
+#
 # A series of 1:50,000 maps may not be so bad.
 #   This translates to approx a 22.7km x 18.2km image window in the GIS.
 #     x_ext=scale*(1280/2817.9)
@@ -50,7 +61,9 @@
 #   export GRASS_HEIGHT=512
 #   d.mon x0
 #
+#############################################################################
 
+
 #%Module
 #%  description: Export display monitor to a GpsDrive compatible backdrop image
 #%  keywords: display, export, GPS
@@ -59,7 +72,7 @@
 #% key: output
 #% type: string
 #% gisprompt: new_file,file,output
-#% description: name for new map image (lives in ~/.gpsdrive)
+#% description: name for new map image (lives in ~/.gpsdrive/maps/)
 #% required : yes
 #%end
 #%flag
@@ -98,12 +111,12 @@
 export LC_NUMERIC
 
 
-if [ ! -d "$HOME/.gpsdrive" ] ; then
-    mkdir "$HOME/.gpsdrive"
+if [ ! -d "$HOME/.gpsdrive/maps" ] ; then
+    mkdir -p "$HOME/.gpsdrive/maps"
 fi
 
 # GpsDrive scales maps named top_* as lat/lon (1:1) on-screen
-# GpsDrive scales maps named map_* as UTM-like (1:cos(lat) ?) on-screen
+# GpsDrive scales maps named map_* as UTM-like (1:cos(lat) ) on-screen
 PROJ=`g.region -p | grep ^proj | cut -f2 -d' '`
 if [ "$PROJ" -eq 3 ] ; then
    IS_LATLON=1
@@ -112,11 +125,16 @@
    IS_LATLON=0
    TYPE="map"
    if [ "$PROJ" -ne 1 ] ; then
-      g.message "GpsDrive assumes northings are not rotated compared to true-geographic north."
-      g.message "If you are using a projection with significant curvature away from the central"
-      g.message 'meridian, then you will likely end up with a distorted background map!'
-      g.message "Keeping the area small will lessen the error, but not eliminate it."
-      g.message "Consider output from a Lat/Lon location."
+      g.message message="GpsDrive assumes northings are not rotated compared "\
+"to true-geographic north. If you are using a projection with significant "\
+"curvature away from the central meridian, then you will likely end up with "\
+'a distorted background map! '\
+"Keeping the area small will lessen the error, but not eliminate it. "\
+"Consider output from a Lat/Lon location if the convergence angle is "\
+"more than a couple of degrees."
+      g.region -n
+
+	# TODO: add a flag to correct for convergence angle with pnmrotate
    fi
 fi
 
@@ -130,7 +148,7 @@
 # get rid of no or double extension
 output="${TYPE}_`basename $GIS_OPT_OUTPUT .png`.png"
 
-GRASS_PNGFILE="$HOME/.gpsdrive/$output"
+GRASS_PNGFILE="$HOME/.gpsdrive/maps/$output"
 export GRASS_PNGFILE
 
 # As .jpg output will overwrite .png of the same name, we check,
@@ -158,17 +176,17 @@
 
 #export display to PNG driver
 dsave=`d.save -a`
-d.mon start=PNG
+d.mon start=PNG --quiet
   FRAME_DIMS="`d.info -b | cut -f2- -d' '`"
   eval "$dsave"
-d.mon stop=PNG
+d.mon stop=PNG --quiet
 #reset
 sleep 1
 d.mon select="$curr_mon"
 
 if [ "$GIS_FLAG_J" -eq 1 ] ; then
    out_jpeg="`basename $output .png`.jpg"
-   cd "$HOME/.gpsdrive"
+   cd "$HOME/.gpsdrive/maps/"
    sync  # sleep 1
    pngtopnm "$output" | pnmtojpeg > "$out_jpeg"
    rm -f "$output"
@@ -181,28 +199,26 @@
 FRAME_HEIGHT="`echo $FRAME_DIMS | awk '{printf("%f", $4 - $3)}'`"
 
 if [ $IS_LATLON -eq 0 ] ; then
-   LAT=`g.region -l | grep 'Center lat' | cut -f2 -d'[' | sed -e 's/]$//'`
-   LON=`g.region -l | grep 'Center lon' | cut -f2 -d'[' | sed -e 's/]$//'`
+   LAT=`g.region -lg | grep 'center_lat' | cut -f2 -d'='`
+   LON=`g.region -lg | grep 'center_long' | cut -f2 -d'='`
 
    M_PER_PIXEL=`echo $e $w $FRAME_WIDTH | awk '{printf("%f", ($1 - $2) / $3)}'`
 else
-   LAT=`g.region -c | grep 'northing' | cut -f2 -d':' | awk '{print $1}'`
-   LON=`g.region -c | grep 'easting' | cut -f2 -d':' | awk '{print $1}'`
+   LAT=`g.region -cg | grep 'northing' | cut -f2 -d'='`
+   LON=`g.region -cg | grep 'easting' | cut -f2 -d'='`
 
-   EXTENT=`g.region -e | grep 'north-south extent' | cut -f2 -d':' | awk '{print $1}'`
+   EXTENT=`g.region -eg | grep 'ns_extent' | cut -f2 -d'='`
    M_PER_PIXEL=`echo $EXTENT $FRAME_HEIGHT | awk '{printf("%f", ($1 * 1852*60.) / $2)}'`
 fi
 
 SCALE=`echo $M_PER_PIXEL | awk '{printf("%d", 0.5 + ($1 * 2817.947378) )}'`
 
 if [ $IS_LATLON -eq 0 ] && [ "$SCALE" -ge 125000 ] ; then
-   g.message -w "Projected input maps may be somewhat inaccurate at this scale."
+   g.message -w "Projected input maps may be somewhat inaccurate at this scale. Better to use lat/lon"
 fi
 
-echo "$output $LAT $LON $SCALE" >> "$HOME/.gpsdrive/map_koord.txt"
+echo "$output $LAT $LON $SCALE" >> "$HOME/.gpsdrive/maps/map_koord.txt"
 
-g.message "Center lat,lon is [$LAT,$LON]"
-g.message "Scale is [1:${SCALE}]"
+g.message -v "Center lat,lon is [$LAT,$LON],  scale is [1:${SCALE}]"
 
 g.message "Done."
-

Modified: grass/trunk/scripts/d.out.gpsdrive/d.out.gpsdrive.html
===================================================================
--- grass/trunk/scripts/d.out.gpsdrive/d.out.gpsdrive.html	2008-10-27 16:09:18 UTC (rev 34022)
+++ grass/trunk/scripts/d.out.gpsdrive/d.out.gpsdrive.html	2008-10-27 16:12:14 UTC (rev 34023)
@@ -13,8 +13,9 @@
 <P>
 <H2>NOTES</H2>
 
-Maps are saved in the user's <tt>~/.gpsdrive</tt> directory. Geo-referencing
-information is added to the user's <tt>~/.gpsdrive/map_koord.txt</tt> file.
+Maps are saved in the user's <tt>~/.gpsdrive/maps/</tt> directory.
+Geo-referencing information is added to the user's
+<tt>~/.gpsdrive/maps/map_koord.txt</tt> file.
 
 <P>
 JPEG output requires the <tt>pngtopnm</tt> and <tt>pnmtojpeg</tt> programs
@@ -25,12 +26,20 @@
 If you are using a projection with significant curvature away from the central
 meridian, or a map datum with a significant rotational component, then you will 
 likely end up with a distorted or inexact background map!
-Keeping the area small will lessen the error, but not eliminate it.
+Keeping the area small will lessen the error, but not eliminate it, if
+necessary you could reproject the map into a custom projection (such as tmerc)
+centered directly on the center of your map. You can check the local
+convergence angle (difference between grid north and true north) with
+"<tt>g.region -n</tt>".
 <P>
-Best output is created from a Lat/Lon location or by keeping the output area
-small (1:50,000). This translates to approx a 22.7km x 18.2km image window in the 
-GIS. [<tt>x_ext=scale*(1280/2817.95)</tt>]
+To avoid distortion, anything more global than 1:150k to 1:500k
+should come from a lat/lon location. Anything more local than that
+will look better coming from a projected system such as UTM.
 <P>
+The extent of a map given a target scale can be calculated with 
+<tt>x_ext=scale*(1280/2817.95)</tt>. e.g. 1:50,000 translates to approx
+a 22.7km x 18.2km image window in the GIS.
+<P>
 For your convenience (calculations are rough, but nominal):
 <div class="code"><pre>
 1:50,000 uses a region 22.7km x 18.2km.
@@ -108,7 +117,8 @@
 
 <BR>
 Note that to get a smoother transition between backdrop maps this script
-creates overlapping tiles.
+creates overlapping tiles. For best results at least 1/3rd overlap should
+be maintained.
 
 
 <BR><BR>
@@ -135,4 +145,5 @@
 New Zealand</i><BR>
 <BR>
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>



More information about the grass-commit mailing list