소스 검색

v.split latlong bugfix

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53136 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 12 년 전
부모
커밋
613c8d3477
1개의 변경된 파일19개의 추가작업 그리고 6개의 파일을 삭제
  1. 19 6
      vector/v.split/main.c

+ 19 - 6
vector/v.split/main.c

@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
     double length = -1;
     int vertices = 0;
     double (*line_length) ();
-    int latlon = 0;
+    int geodesic = 0;
 
     G_gisinit(argv[0]);
 
@@ -114,8 +114,14 @@ int main(int argc, char *argv[])
 	    G_fatal_error(_("Unknown unit %s"), units_opt->answer); 
 
 	/* set line length function */
-	if ((latlon = (G_projection() == PROJECTION_LL)) == 1)
-	    line_length = Vect_line_geodesic_length;
+	if (G_projection() == PROJECTION_LL) {
+	    if (strcmp(units_opt->answer, "map") == 0)
+		line_length = Vect_line_length;
+	    else {
+		line_length = Vect_line_geodesic_length;
+		geodesic = 1;
+	    }
+	}
 	else {
 	    double factor;
 	    
@@ -129,7 +135,10 @@ int main(int argc, char *argv[])
 		length = length / factor;
 	    }
 	}
-	G_verbose_message(_("length in %s: %g"), (latlon ? "meters" : "map units"), length);
+	if (strcmp(units_opt->answer, "map") == 0)
+	    G_verbose_message(_("Length in map units: %g"), length);
+	else
+	    G_verbose_message(_("Length in meters: %g"), length);
     }
 
     if (vertices_opt->answer) {
@@ -178,14 +187,18 @@ int main(int argc, char *argv[])
 		    Vect_write_line(&Out, ltype, Points, Cats);
 		}
 		else {
-		    int n, i;
+		    long n, i;
+
+		    G_debug(3, "l: %f, length: %f", l, length);
 
 		    n = ceil(l / length);
-		    if (latlon)
+		    if (geodesic)
 			l = Vect_line_length(Points);
 
 		    step = l / n;
 		    from = 0.;
+		    
+		    G_debug(3, "n: %ld, step: %f", n, step);
 
 		    for (i = 0; i < n; i++) {
 			int ret;