[GRASS-SVN] r62387 - in grass/branches/releasebranch_7_0: . raster/r.profile
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Oct 26 11:42:23 PDT 2014
Author: annakrat
Date: 2014-10-26 11:42:23 -0700 (Sun, 26 Oct 2014)
New Revision: 62387
Modified:
grass/branches/releasebranch_7_0/
grass/branches/releasebranch_7_0/raster/r.profile/main.c
Log:
r.profile: simplify computation based on Glynn's suggestions to avoid infinity values (merge from trunk, r62327)
Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Modified: svn:mergeinfo
- /grass/trunk:61095,61788,61897,62141,62346,62352,62354,62356,62364
+ /grass/trunk:61095,61788,61897,62141,62327,62346,62352,62354,62356,62364
Modified: grass/branches/releasebranch_7_0/raster/r.profile/main.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.profile/main.c 2014-10-26 17:25:09 UTC (rev 62386)
+++ grass/branches/releasebranch_7_0/raster/r.profile/main.c 2014-10-26 18:42:23 UTC (rev 62387)
@@ -273,7 +273,7 @@
char *null_string, const char *unit, double factor)
{
float rows, cols, LEN;
- double Y, X, AZI;
+ double Y, X, k;
cols = e1 - e2;
rows = n1 - n2;
@@ -292,18 +292,20 @@
read_rast(e, n, dist / factor, fd, coords, data_type, fp, null_string);
}
+ k = res / hypot(rows, cols);
+ Y = k * rows;
+ X = k * cols;
+ if (Y < 0)
+ Y = Y * -1.;
+ if (X < 0)
+ X = X * -1.;
+
+ if (e != 0.0 && (e != e1 || n != n1)) {
+ dist -= G_distance(e, n, e1, n1);
+ }
+
if (rows >= 0 && cols < 0) {
/* SE Quad or due east */
- AZI = atan((rows / cols));
- Y = res * sin(AZI);
- X = res * cos(AZI);
- if (Y < 0)
- Y = Y * -1.;
- if (X < 0)
- X = X * -1.;
- if (e != 0.0 && (e != e1 || n != n1)) {
- dist -= G_distance(e, n, e1, n1);
- }
for (e = e1, n = n1; e < e2 || n > n2; e += X, n -= Y) {
read_rast(e, n, dist / factor, fd, coords, data_type, fp, null_string);
/* d+=res; */
@@ -313,19 +315,6 @@
if (rows < 0 && cols <= 0) {
/* NE Quad or due north */
- AZI = atan((cols / rows));
- X = res * sin(AZI);
- Y = res * cos(AZI);
- if (Y < 0)
- Y = Y * -1.;
- if (X < 0)
- X = X * -1.;
- if (e != 0.0 && (e != e1 || n != n1)) {
- dist -= G_distance(e, n, e1, n1);
- /*
- * read_rast (e1, n1, dist, fd, coords, data_type, fp, null_string);
- */
- }
for (e = e1, n = n1; e < e2 || n < n2; e += X, n += Y) {
read_rast(e, n, dist / factor, fd, coords, data_type, fp, null_string);
/* d+=res; */
@@ -335,16 +324,6 @@
if (rows > 0 && cols >= 0) {
/* SW Quad or due south */
- AZI = atan((rows / cols));
- X = res * cos(AZI);
- Y = res * sin(AZI);
- if (Y < 0)
- Y = Y * -1.;
- if (X < 0)
- X = X * -1.;
- if (e != 0.0 && (e != e1 || n != n1)) {
- dist -= G_distance(e, n, e1, n1);
- }
for (e = e1, n = n1; e > e2 || n > n2; e -= X, n -= Y) {
read_rast(e, n, dist / factor, fd, coords, data_type, fp, null_string);
/* d+=res; */
@@ -354,16 +333,6 @@
if (rows <= 0 && cols > 0) {
/* NW Quad or due west */
- AZI = atan((rows / cols));
- X = res * cos(AZI);
- Y = res * sin(AZI);
- if (Y < 0)
- Y = Y * -1.;
- if (X < 0)
- X = X * -1.;
- if (e != 0.0 && (e != e1 || n != n1)) {
- dist -= G_distance(e, n, e1, n1);
- }
for (e = e1, n = n1; e > e2 || n < n2; e -= X, n += Y) {
read_rast(e, n, dist / factor, fd, coords, data_type, fp, null_string);
/* d+=res; */
More information about the grass-commit
mailing list