[GRASS-SVN] r57833 - grass-addons/grass7/vector/v.centerpoint
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 25 01:26:55 PDT 2013
Author: mmetz
Date: 2013-09-25 01:26:54 -0700 (Wed, 25 Sep 2013)
New Revision: 57833
Modified:
grass-addons/grass7/vector/v.centerpoint/areas.c
grass-addons/grass7/vector/v.centerpoint/lines.c
grass-addons/grass7/vector/v.centerpoint/local_proto.h
grass-addons/grass7/vector/v.centerpoint/main.c
grass-addons/grass7/vector/v.centerpoint/points.c
grass-addons/grass7/vector/v.centerpoint/v.centerpoint.html
Log:
v.centerpoint: geometric mean -> arithmetic mean
Modified: grass-addons/grass7/vector/v.centerpoint/areas.c
===================================================================
--- grass-addons/grass7/vector/v.centerpoint/areas.c 2013-09-25 08:26:27 UTC (rev 57832)
+++ grass-addons/grass7/vector/v.centerpoint/areas.c 2013-09-25 08:26:54 UTC (rev 57833)
@@ -6,20 +6,6 @@
#include <grass/glocale.h>
#include "local_proto.h"
-static double d_ulp(double d)
-{
- int exp;
-
- if (d == 0)
- return GRASS_EPSILON;
-
- d = frexp(d, &exp);
- exp -= 51;
- d = ldexp(d, exp);
-
- return d;
-}
-
int areas_center(struct Map_info *In, struct Map_info *Out, int layer,
struct cat_list *cat_list, int mode)
{
@@ -46,7 +32,7 @@
nareas = Vect_get_num_areas(In);
- /* geometric mean = center of gravity */
+ /* arithmetic mean = center of gravity */
if (mode & A_MEAN) {
G_message(_("Calculating centers of gravity for areas..."));
@@ -127,7 +113,7 @@
}
}
- /* approximate geometric median with Weiszfeld's algorithm:
+ /* approximate point of minimum distance (geometric median) with Weiszfeld's algorithm:
* iterative least squares reduction */
if (mode & A_MEDIAN) {
struct line_pnts *CPoints;
@@ -412,7 +398,7 @@
double dist, distsum, dist2all, lastdist2all;
int j, iter, maxiter = 1000;
- G_message(_("Calculating geometric medians for areas..."));
+ G_message(_("Calculating geometric medians for area boundaries..."));
CPoints = Vect_new_line_struct();
Modified: grass-addons/grass7/vector/v.centerpoint/lines.c
===================================================================
--- grass-addons/grass7/vector/v.centerpoint/lines.c 2013-09-25 08:26:27 UTC (rev 57832)
+++ grass-addons/grass7/vector/v.centerpoint/lines.c 2013-09-25 08:26:54 UTC (rev 57833)
@@ -6,20 +6,6 @@
#include <grass/glocale.h>
#include "local_proto.h"
-static double d_ulp(double d)
-{
- int exp;
-
- if (d == 0)
- return GRASS_EPSILON;
-
- d = frexp(d, &exp);
- exp -= 51;
- d = ldexp(d, exp);
-
- return d;
-}
-
int lines_center(struct Map_info *In, struct Map_info *Out, int layer,
struct cat_list *cat_list, int n_primitives, int mode)
{
@@ -37,6 +23,7 @@
if (mode & L_MID) {
double len;
+ G_message(_("Calculating mid point coordinates..."));
counter = 0;
Vect_rewind(In);
@@ -73,6 +60,7 @@
double dx, dy, dz;
int i;
+ G_message(_("Calculating centers of gravity for lines..."));
counter = 0;
Vect_rewind(In);
@@ -133,6 +121,7 @@
SPoints = Vect_new_line_struct();
+ G_message(_("Approximating geometric medians..."));
counter = 0;
Vect_rewind(In);
@@ -185,7 +174,7 @@
lastdist2all = -1;
- G_debug(3, "Approximating geometric median...");
+ G_debug(3, "Approximating geometric median...", );
for (iter = 0; iter < maxiter; iter++) {
Modified: grass-addons/grass7/vector/v.centerpoint/local_proto.h
===================================================================
--- grass-addons/grass7/vector/v.centerpoint/local_proto.h 2013-09-25 08:26:27 UTC (rev 57832)
+++ grass-addons/grass7/vector/v.centerpoint/local_proto.h 2013-09-25 08:26:54 UTC (rev 57833)
@@ -10,6 +10,7 @@
int points_center(struct Map_info *, struct Map_info *, int,
struct cat_list *, int, int);
+double d_ulp(double);
int lines_center(struct Map_info *, struct Map_info *, int,
struct cat_list *, int, int);
Modified: grass-addons/grass7/vector/v.centerpoint/main.c
===================================================================
--- grass-addons/grass7/vector/v.centerpoint/main.c 2013-09-25 08:26:27 UTC (rev 57832)
+++ grass-addons/grass7/vector/v.centerpoint/main.c 2013-09-25 08:26:54 UTC (rev 57833)
@@ -3,12 +3,11 @@
*
* MODULE: v.centerpoint
*
- * AUTHOR(S): GRASS Development Team, Radim Blazek, Maris Nartiss
+ * AUTHOR(S): Markus Metz
*
- * PURPOSE: copies vector data from source map to destination map
- * prints out all point coordinates and atributes
+ * PURPOSE: Calculates center points
*
- * COPYRIGHT: (C) 2002-2009 by the GRASS Development Team
+ * COPYRIGHT: (C) 2013 by the GRASS Development Team
*
* This program is free software under the
* GNU General Public License (>=v2).
@@ -84,8 +83,8 @@
"mean;%s;"
"median;%s;"
"pmedian;%s;",
- _("Geometric mean (center of gravity)"),
- _("Geometric median"),
+ _("Center of gravity"),
+ _("Geometric median (point of minimum distance)"),
_("Point closest to geometric median"));
pmode->descriptions = pdesc;
@@ -102,8 +101,8 @@
"mean;%s;"
"median;%s;",
_("Line mid point"),
- _("Geometric mean (center of gravity)"),
- _("Geometric median using line segments"));
+ _("Center of gravity"),
+ _("Geometric median (point of minimum distance) using line segments"));
lmode->descriptions = ldesc;
amode = G_define_option();
@@ -118,9 +117,9 @@
"mean;%s;"
"median;%s;"
"bmedian;%s;",
- _("Geometric mean (center of gravity)"),
- _("Geometric median using area sizes"),
- _("Geometric median using boundary segments"));
+ _("Center of gravity"),
+ _("Geometric median (point of minimum distance) using area sizes"),
+ _("Geometric median (point of minimum distance) using boundary segments"));
amode->descriptions = adesc;
topo_flag = G_define_standard_flag(G_FLG_V_TOPO);
Modified: grass-addons/grass7/vector/v.centerpoint/points.c
===================================================================
--- grass-addons/grass7/vector/v.centerpoint/points.c 2013-09-25 08:26:27 UTC (rev 57832)
+++ grass-addons/grass7/vector/v.centerpoint/points.c 2013-09-25 08:26:54 UTC (rev 57833)
@@ -6,7 +6,7 @@
#include <grass/glocale.h>
#include "local_proto.h"
-static double d_ulp(double d)
+double d_ulp(double d)
{
int exp;
@@ -41,7 +41,7 @@
/* coordinates' mean */
counter = n = 0;
xsum = ysum = zsum = 0.;
- G_message(_("Calculating mean point coordinates (center of gravity)..."));
+ G_message(_("Calculating center of gravity..."));
while ((type = Vect_read_next_line(In, Points, Cats)) > 0) {
G_percent(counter, n_primitives, 4);
counter++;
Modified: grass-addons/grass7/vector/v.centerpoint/v.centerpoint.html
===================================================================
--- grass-addons/grass7/vector/v.centerpoint/v.centerpoint.html 2013-09-25 08:26:27 UTC (rev 57832)
+++ grass-addons/grass7/vector/v.centerpoint/v.centerpoint.html 2013-09-25 08:26:54 UTC (rev 57833)
@@ -1,7 +1,7 @@
<h2>DESCRIPTION</h2>
<em>v.centerpoint</em> calculates center points for point clouds, lines
-and areas. Center points can be geometric means (centers of gravity) or
+and areas. Center points can be centers of gravity (coordinates' mean) or
geometric medians, which is more robust in case of outliers.
<p>
For points, center points are calculated considering all points. For
More information about the grass-commit
mailing list