[GRASS-SVN] r36745 - grass/trunk/vector/v.what
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Apr 16 05:33:54 EDT 2009
Author: hamish
Date: 2009-04-16 05:33:54 -0400 (Thu, 16 Apr 2009)
New Revision: 36745
Modified:
grass/trunk/vector/v.what/v.what.html
grass/trunk/vector/v.what/what.c
Log:
cleanup conversion to acres (merge from devbr6)
Modified: grass/trunk/vector/v.what/v.what.html
===================================================================
--- grass/trunk/vector/v.what/v.what.html 2009-04-16 09:28:59 UTC (rev 36744)
+++ grass/trunk/vector/v.what/v.what.html 2009-04-16 09:33:54 UTC (rev 36745)
@@ -6,7 +6,11 @@
<em>d.what.vect</em> module by removing all interactive code and
modification of the output for easy parsing. Using the <em>-g</em> flag permits to
generate script style output which is easily parsable.
+<P>
+This module always reports standard acres, even when the location uses
+US Survey feet as the map unit.
+
<h2>EXAMPLE</h2>
Spearfish example:
@@ -14,13 +18,16 @@
v.what fields east_north=599121.75,4922981.125
</pre></div>
+
<h2>SEE ALSO</h2>
<em><a HREF="d.what.vect.html">d.what.vect</a></em>
+
<h2>AUTHOR</h2>
Trevor Wiens<br>
Edmonton, Alberta, Canada
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>
Modified: grass/trunk/vector/v.what/what.c
===================================================================
--- grass/trunk/vector/v.what/what.c 2009-04-16 09:28:59 UTC (rev 36744)
+++ grass/trunk/vector/v.what/what.c 2009-04-16 09:33:54 UTC (rev 36745)
@@ -107,7 +107,7 @@
{
int type;
char east_buf[40], north_buf[40];
- double sq_meters;
+ double sq_meters, sqm_to_sqft, acres, hectares, sq_miles;
double z = 0, l = 0;
int notty = 0;
int getz = 0;
@@ -124,6 +124,12 @@
Cats = Vect_new_cats_struct();
db_init_string(&html);
+ /* 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 );
+
+
for (i = 0; i < nvects; i++) {
Vect_reset_cats(Cats);
@@ -134,8 +140,7 @@
maxdist, 0, 0);
if (line == 0) {
line = Vect_find_line(&Map[i], east, north, 0.0,
- GV_LINE | GV_BOUNDARY | GV_FACE, maxdist, 0,
- 0);
+ GV_LINE | GV_BOUNDARY | GV_FACE, maxdist, 0, 0);
}
if (line == 0) {
@@ -364,7 +369,16 @@
fprintf(stdout, _("Type: Area\n"));
}
}
+
+
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;
@@ -405,26 +419,23 @@
else {
if (script) {
fprintf(stdout, "Sq_Meters=%.3f\nHectares=%.3f\n",
- sq_meters, (sq_meters / 10000.));
+ sq_meters, hectares);
fprintf(stdout, "Acres=%.3f\nSq_Miles=%.4f\n",
- ((sq_meters * 10.763649) / 43560.),
- ((sq_meters * 10.763649) / 43560.) / 640.);
+ acres, sq_miles);
}
else {
fprintf(stdout, _("Sq Meters: %.3f\nHectares: %.3f\n"),
- sq_meters, (sq_meters / 10000.));
+ sq_meters, hectares);
fprintf(stdout, _("Acres: %.3f\nSq Miles: %.4f\n"),
- ((sq_meters * 10.763649) / 43560.),
- ((sq_meters * 10.763649) / 43560.) / 640.);
+ acres, sq_miles);
}
if (notty) {
fprintf(stderr,
_("Sq Meters: %.3f\nHectares: %.3f\n"),
- sq_meters, (sq_meters / 10000.));
+ sq_meters, hectares);
fprintf(stderr,
_("Acres: %.3f\nSq Miles: %.4f\n"),
- ((sq_meters * 10.763649) / 43560.),
- ((sq_meters * 10.763649) / 43560.) / 640.);
+ acres, sq_miles);
}
nlines += 3;
}
More information about the grass-commit
mailing list