Selaa lähdekoodia

cleanup conversion to acres (merge from v.what; devbr6)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@36748 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 16 vuotta sitten
vanhempi
commit
95dd2fd64e
2 muutettua tiedostoa jossa 33 lisäystä ja 14 poistoa
  1. 15 7
      display/d.what.vect/d.what.vect.html
  2. 18 7
      display/d.what.vect/what.c

+ 15 - 7
display/d.what.vect/d.what.vect.html

@@ -5,13 +5,15 @@ outputs the category value(s) associated with user-specified location(s)
 in user-specified vector map layer(s). 
 
 <p>
-
 The program activates the mouse, and expects the user to indicate the 
 location(s) to be queried by depressing a mouse button over desired location(s) 
 within the current geographic region in the active display frame on the 
 graphic monitor. Query results from map(s) are by default displayed in a new 
 monitor, where label values can be added or changed. Using parameter <b>-x</b> 
 informations will be displayed as plain text to terminal window.
+<P>
+This module always reports standard acres, even when the location uses
+US Survey feet as the map unit.
 
 <h2>EXAMPLE</h2>
 
@@ -41,17 +43,23 @@ The query may be repeated as often as desired using the left mouse button. The
 middle mouse button toggles the flash color.
 The right button on the mouse is used to quit the <em>d.what.vect</em> session. 
 
+
 <h2>SEE ALSO</h2>
 
-<em><a HREF="d.rast.html">d.rast</a></em><br>
-<em><a HREF="d.vect.html">d.vect</a></em><br>
-<em><a HREF="d.what.rast.html">d.what.rast</a></em><br>
-<em><a HREF="g.region.html">g.region</a></em><br>
+<em><a HREF="d.rast.html">d.rast</a><br>
+<a HREF="d.vect.html">d.vect</a><br>
+<a HREF="d.what.rast.html">d.what.rast</a><br>
+<a HREF="g.region.html">g.region</a><br>
+<a HREF="v.what.html">v.what</a>
+</em>
+
 
 <h2>AUTHOR</h2>
 
 Jim Hinthorne,
 Central Washington University<br>
-Upgrades by Dennis Finch, National Park Service and Radim Blazek, ITC-Irst, Trento, Italy
+Upgrades by Dennis Finch, National Park Service
+ and Radim Blazek, ITC-Irst, Trento, Italy
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>

+ 18 - 7
display/d.what.vect/what.c

@@ -26,7 +26,7 @@ int what(int once, int txt, int terse, int width, int mwidth,
     double east, north;
     int button;
     char east_buf[40], north_buf[40];
-    double sq_meters;
+    double sq_meters, sqm_to_sqft, acres, hectares, sq_miles;
     double x1, y1, x2, y2, z = 0, l = 0;
     int notty;
     double maxdist;
@@ -62,6 +62,12 @@ int what(int once, int txt, int terse, int width, int mwidth,
     else
 	notty = 0;
 
+    /* always use plain feet not US survey ft */
+    /*  if you really want USfeet, try G_database_units_to_meters_factor()
+	here, but then watch that sq_miles is not affected too */
+    sqm_to_sqft = 1 / ( 0.0254 * 0.0254 * 12 * 12 );
+
+
     do {
 	if (!terse)
 	    show_buttons(once);
@@ -321,6 +327,13 @@ int what(int once, int txt, int terse, int width, int mwidth,
 		}
 
 		sq_meters = Vect_get_area_area(&Map[i], area);
+		hectares  = sq_meters / 10000.;
+		/* 1 acre = 1 chain(66') * 1 furlong(10 chains),
+		    or if you prefer ( 5280 ft/mi ^2 / 640 acre/sq mi ) */
+		acres = (sq_meters * sqm_to_sqft) / (66 * 660);
+		sq_miles = acres / 640.;
+
+
 		if (topo) {
 		    int nisles, isleidx, isle, isle_area;
 
@@ -347,21 +360,19 @@ int what(int once, int txt, int terse, int width, int mwidth,
 		else if (txt) {
 		    fprintf(stdout,
 			    _("Size - Sq Meters: %.3f\t\tHectares: %.3f\n"),
-			    sq_meters, (sq_meters / 10000.));
+			    sq_meters, hectares);
 
 		    fprintf(stdout,
 			    _("           Acres: %.3f\t\tSq Miles: %.4f\n"),
-			    ((sq_meters * 10.763649) / 43560.),
-			    ((sq_meters * 10.763649) / 43560.) / 640.);
+			    acres, sq_miles);
 		    if (notty) {
 			fprintf(stderr,
 				_("Size - Sq Meters: %.3f\t\tHectares: %.3f\n"),
-				sq_meters, (sq_meters / 10000.));
+				sq_meters, hectares);
 
 			fprintf(stderr,
 				_("           Acres: %.3f\t\tSq Miles: %.4f\n"),
-				((sq_meters * 10.763649) / 43560.),
-				((sq_meters * 10.763649) / 43560.) / 640.);
+				acres, sq_miles);
 		    }
 		    nlines += 3;
 		}