[GRASS-SVN] r72881 - grass/branches/releasebranch_7_4/vector/v.to.db
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jun 22 13:23:47 PDT 2018
Author: mmetz
Date: 2018-06-22 13:23:47 -0700 (Fri, 22 Jun 2018)
New Revision: 72881
Modified:
grass/branches/releasebranch_7_4/vector/v.to.db/areas.c
grass/branches/releasebranch_7_4/vector/v.to.db/report.c
grass/branches/releasebranch_7_4/vector/v.to.db/update.c
Log:
v.to.db: fix fractal dimension index (backport trunk r72880)
Modified: grass/branches/releasebranch_7_4/vector/v.to.db/areas.c
===================================================================
--- grass/branches/releasebranch_7_4/vector/v.to.db/areas.c 2018-06-22 20:21:24 UTC (rev 72880)
+++ grass/branches/releasebranch_7_4/vector/v.to.db/areas.c 2018-06-22 20:23:47 UTC (rev 72881)
@@ -40,7 +40,7 @@
(options.option == O_PERIMETER)) {
perimeter = Vect_get_area_perimeter(Map, area_num);
if (G_projection() != PROJECTION_LL && G_projection() != PROJECTION_XY)
- perimeter = perimeter * G_database_units_to_meters_factor();
+ perimeter = perimeter * G_database_units_to_meters_factor();
}
if (options.option == O_BBOX) {
Vect_get_area_box(Map, area_num, &Bbox);
Modified: grass/branches/releasebranch_7_4/vector/v.to.db/report.c
===================================================================
--- grass/branches/releasebranch_7_4/vector/v.to.db/report.c 2018-06-22 20:21:24 UTC (rev 72880)
+++ grass/branches/releasebranch_7_4/vector/v.to.db/report.c 2018-06-22 20:23:47 UTC (rev 72881)
@@ -58,7 +58,8 @@
break;
case O_COMPACT:
- /* perimeter / (2.0 * sqrt(M_PI * area)) */
+ /* perimeter / perimeter of equivalent circle
+ * perimeter of equivalent circle: 2.0 * sqrt(M_PI * area) */
if (G_verbose() > G_verbose_min())
fprintf(stdout, "cat%scompact\n", options.fs);
for (i = 0; i < vstat.rcat; i++) {
@@ -69,16 +70,21 @@
case O_FD:
/* 2.0 * log(perimeter) / log(area)
+ * this is neither
+ * log(perimeter) / log(perimeter of equivalent circle)
+ * perimeter of equivalent circle: 2 * sqrt(M_PI * area)
+ * nor
+ * log(area of equivalent circle) / log(area)
+ * area of equivalent circle: (perimeter / (2 * sqrt(M_PI))^2
+ *
* avoid division by zero:
- * 2.0 * log(1 + perimeter) / log(1 + area)
- * more in line with compactness:
- * 2.0 * log(perimeter / (2.0 * sqrt(M_PI)) / log(area) */
+ * 2.0 * log(1 + perimeter) / log(1 + area) */
if (G_verbose() > G_verbose_min())
fprintf(stdout, "cat%sfd\n", options.fs);
for (i = 0; i < vstat.rcat; i++) {
if (Values[i].d1 == 1) /* log(1) == 0 */
Values[i].d1 += 0.000001;
- Values[i].d1 = 2.0 * log(Values[i].d2 / (2.0 * sqrt(M_PI))) / log(Values[i].d1);
+ Values[i].d1 = 2.0 * log(Values[i].d2) / log(Values[i].d1);
fprintf(stdout, "%d%s%.15g\n", Values[i].cat, options.fs, Values[i].d1);
}
break;
Modified: grass/branches/releasebranch_7_4/vector/v.to.db/update.c
===================================================================
--- grass/branches/releasebranch_7_4/vector/v.to.db/update.c 2018-06-22 20:21:24 UTC (rev 72880)
+++ grass/branches/releasebranch_7_4/vector/v.to.db/update.c 2018-06-22 20:23:47 UTC (rev 72881)
@@ -119,7 +119,8 @@
break;
case O_COMPACT:
- /* perimeter / (2.0 * sqrt(M_PI * area)) */
+ /* perimeter / perimeter of equivalent circle
+ * perimeter of equivalent circle: 2.0 * sqrt(M_PI * area) */
Values[i].d1 = Values[i].d2 / (2.0 * sqrt(M_PI * Values[i].d1));
sprintf(buf2, "%s %f where %s = %d", buf1, Values[i].d1, Fi->key,
Values[i].cat);
@@ -127,13 +128,18 @@
case O_FD:
/* 2.0 * log(perimeter) / log(area)
+ * this is neither
+ * log(perimeter) / log(perimeter of equivalent circle)
+ * perimeter of equivalent circle: 2 * sqrt(M_PI * area)
+ * nor
+ * log(area of equivalent circle) / log(area)
+ * area of equivalent circle: (perimeter / (2 * sqrt(M_PI))^2
+ *
* avoid division by zero:
- * 2.0 * log(1 + perimeter) / log(1 + area)
- * more in line with compactness:
- * 2.0 * log(perimeter / (2.0 * sqrt(M_PI)) / log(area) */
+ * 2.0 * log(1 + perimeter) / log(1 + area) */
if (Values[i].d1 == 1) /* log(1) == 0 */
Values[i].d1 += 0.000001;
- Values[i].d1 = 2.0 * log(Values[i].d2 / (2.0 * sqrt(M_PI))) / log(Values[i].d1);
+ Values[i].d1 = 2.0 * log(Values[i].d2) / log(Values[i].d1);
sprintf(buf2, "%s %f where %s = %d", buf1, Values[i].d1, Fi->key,
Values[i].cat);
break;
More information about the grass-commit
mailing list