[GRASS-SVN] r35944 - grass-addons/vector/v.in.gshhs

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Feb 19 06:13:03 EST 2009


Author: mmetz
Date: 2009-02-19 06:13:03 -0500 (Thu, 19 Feb 2009)
New Revision: 35944

Modified:
   grass-addons/vector/v.in.gshhs/main.c
Log:
changed line selection policy and bugfix

Modified: grass-addons/vector/v.in.gshhs/main.c
===================================================================
--- grass-addons/vector/v.in.gshhs/main.c	2009-02-19 10:44:22 UTC (rev 35943)
+++ grass-addons/vector/v.in.gshhs/main.c	2009-02-19 11:13:03 UTC (rev 35944)
@@ -324,6 +324,10 @@
 	}
 	
 	if (getme) {
+	    /* abusing getme flag a bit */
+	    if (getme == 2)
+		getme = 0;
+	    
 	    Vect_reset_line(Points);
 	    Vect_reset_cats(Cats);
 	    /* simple table and cats for layer 1: not unique, just per slevel */
@@ -346,36 +350,27 @@
 		    lon -= 360.0;
 		lat = p.y * GSHHS_SCL;
 
-		if (getme == 2) { /* overlap */
+		if (getme == 0) { /* overlap */
 		    /* datum border wrap around work around, clumsy code but works */
 		    if (maxx > 180. && lon < 0) {
-			if (lat >= minx && lat <= maxx && (lon + 360.) >= miny && (lon + 360.) <= maxy) {
-			    /* vertex inside current region, do nothing */
+			if (lat >= miny && lat <= maxy && (lon + 360.) >= minx && (lon + 360.) <= maxx) {
+			    /* vertex inside current region, import line */
+			    getme = 1;
 			}
-			else {
-			    /* vertex outside current region, skip whole line */
-			    Vect_reset_line(Points);
-			    getme = 0;
-			}
 		    }
 		    else {
-			if (lat >= minx && lat <= maxx && lon >= miny && lon <= maxy) {
-			    /* vertex inside current region, do nothing */
+			if (lat >= miny && lat <= maxy && lon >= minx && lon <= maxx) {
+			    /* vertex inside current region, import line */
+			    getme = 1;
 			}
-			else {
-			    /* vertex outside current region, skip whole line */
-			    Vect_reset_line(Points);
-			    getme = 0;
-			}
 		    }
 		
 		}
-
-                if (getme)
-		    Vect_append_point(Points, lon, lat, 0.);
+		Vect_append_point(Points, lon, lat, 0.);
+		
 	    }			/* done with line */
 
-	    if (Points->n_points) {
+	    if (getme && Points->n_points) {
 		/* change thresh if you want longer line segments */
 		Vect_write_line_tiled(&VectMap, type, Points, Cats, 2.);
 	    }
@@ -532,7 +527,7 @@
 	if (maxy < (curry - lasty))
 	    maxy = curry - lasty;
 	    
-	if (i && ((maxx - minx) > thresh || (maxy - miny) > thresh)) {
+	if (BPoints->n_points > 1 && ((maxx - minx) > thresh || (maxy - miny) > thresh)) {
 
 	    lastx = BPoints->x[BPoints->n_points - 1]; /* keep last x for new line */
 	    lasty = BPoints->y[BPoints->n_points - 1]; /* keep last y for new line */



More information about the grass-commit mailing list