소스 검색

chaiken forgot first point

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@42124 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 15 년 전
부모
커밋
b23bf30a60
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      vector/v.generalize/smoothing.c

+ 4 - 3
vector/v.generalize/smoothing.c

@@ -212,8 +212,9 @@ int chaiken(struct line_pnts *Points, double thresh, int with_z)
 
     head.next = NULL;
     cur = &head;
-    point_assign(Points, 0, with_z, &head.p);
     point_assign(Points, 0, with_z, &p0);
+    point_list_add(cur, p0); /* always keep first point */
+    cur = cur->next;
 
     for (i = 2; i <= n; i++) {
 	if (i == n)
@@ -235,7 +236,7 @@ int chaiken(struct line_pnts *Points, double thresh, int with_z)
 		point_scalar(tmp, 0.5, &p1);
 	    }
 	    else {
-		break;		/* good approximatin */
+		break;		/* good approximation */
 	    }
 	}
 
@@ -246,7 +247,7 @@ int chaiken(struct line_pnts *Points, double thresh, int with_z)
     }
 
     point_assign(Points, n - 1, with_z, &p0);
-    point_list_add(cur, p0);
+    point_list_add(cur, p0); /* always keep last point */
 
     if (point_list_copy_to_line_pnts(head, Points) == -1) {
 	G_fatal_error(_("Out of memory"));