[GRASS-SVN] r49227 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Nov 14 03:14:43 EST 2011


Author: martinl
Date: 2011-11-14 00:14:43 -0800 (Mon, 14 Nov 2011)
New Revision: 49227

Modified:
   grass/trunk/lib/vector/Vlib/open.c
   grass/trunk/lib/vector/Vlib/overlap.c
   grass/trunk/lib/vector/Vlib/read_nat.c
   grass/trunk/lib/vector/Vlib/read_ogr.c
Log:
Vlib: update constraints which are now hidden in struct


Modified: grass/trunk/lib/vector/Vlib/open.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open.c	2011-11-14 08:13:33 UTC (rev 49226)
+++ grass/trunk/lib/vector/Vlib/open.c	2011-11-14 08:14:43 UTC (rev 49227)
@@ -214,8 +214,12 @@
 	/* try to find vector map (not for OGR mapset) */
 	fmapset = G_find_vector2(Map->name, Map->mapset);
 	if (fmapset == NULL) {
-	    sprintf(errmsg, _("Vector map <%s> not found"),
-		    Vect_get_full_name(Map));
+	    if (mapset && strcmp(mapset, G_mapset()) == 0)
+		sprintf(errmsg, _("Vector map <%s> not found in current mapset"),
+			Vect_get_name(Map));
+	    else
+		sprintf(errmsg, _("Vector map <%s> not found"),
+			Vect_get_full_name(Map));
 	    fatal_error(ferror, errmsg);
 	    return -1;
 	}
@@ -426,8 +430,6 @@
 	Map->head_only = 0;
     }
 
-    Map->Constraint_region_flag = 0;
-    Map->Constraint_type_flag = 0;
     G_debug(1, "Vect_open_old(): vector opened on level %d", level);
 
     if (level == 1) {		/* without topology */
@@ -805,8 +807,6 @@
     Map->support_updated = 0;
     Map->plus.built = GV_BUILD_NONE;
     Map->mode = GV_MODE_RW;
-    Map->Constraint_region_flag = 0;
-    Map->Constraint_type_flag = 0;
     Map->plus.do_uplist = 0;
 
     Vect_set_proj(Map, G_projection());

Modified: grass/trunk/lib/vector/Vlib/overlap.c
===================================================================
--- grass/trunk/lib/vector/Vlib/overlap.c	2011-11-14 08:13:33 UTC (rev 49226)
+++ grass/trunk/lib/vector/Vlib/overlap.c	2011-11-14 08:14:43 UTC (rev 49227)
@@ -31,10 +31,10 @@
     struct Cell_head W;
 
     /* updated for Lat lon support 21 Jun 91 */
-    W.north = Map->Constraint_box.N;
-    W.south = Map->Constraint_box.S;
-    W.east = Map->Constraint_box.E;
-    W.west = Map->Constraint_box.W;
+    W.north = Map->constraint.box.N;
+    W.south = Map->constraint.box.S;
+    W.east = Map->constraint.box.E;
+    W.west = Map->constraint.box.W;
     W.proj = Map->head.proj;
 
     return G_window_overlap(&W, n, s, e, w);

Modified: grass/trunk/lib/vector/Vlib/read_nat.c
===================================================================
--- grass/trunk/lib/vector/Vlib/read_nat.c	2011-11-14 08:13:33 UTC (rev 49226)
+++ grass/trunk/lib/vector/Vlib/read_nat.c	2011-11-14 08:14:43 UTC (rev 49227)
@@ -71,7 +71,7 @@
 
     G_debug(3, "V1_read_next_line_nat()");
 
-    if (Map->Constraint_region_flag)
+    if (Map->constraint.region_flag)
 	Vect_get_constraint_box(Map, &mbox);
 
     while (1) {
@@ -86,13 +86,13 @@
 	/* Constraint on Type of line 
 	 * Default is all of  Point, Line, Area and whatever else comes along
 	 */
-	if (Map->Constraint_type_flag) {
-	    if (!(itype & Map->Constraint_type))
+	if (Map->constraint.type_flag) {
+	    if (!(itype & Map->constraint.type))
 		continue;
 	}
 
 	/* Constraint on specified region */
-	if (Map->Constraint_region_flag) {
+	if (Map->constraint.region_flag) {
 	    Vect_line_box(line_p, &lbox);
 
 	    if (!Vect_box_overlap(&lbox, &mbox))
@@ -153,20 +153,20 @@
 int V2_read_next_line_nat(struct Map_info *Map,
 			  struct line_pnts *line_p, struct line_cats *line_c)
 {
-    register int line, ret;
-    register struct P_line *Line;
+    int line, ret, i;
+    struct P_line *Line;
     struct bound_box lbox, mbox;
 
     G_debug(3, "V2_read_next_line_nat()");
 
-    if (Map->Constraint_region_flag)
+    if (Map->constraint.region_flag)
 	Vect_get_constraint_box(Map, &mbox);
-
+    
     while (TRUE) {
 	line = Map->next_line;
 
 	if (line > Map->plus.n_lines)
-	    return (-2);
+	    return -2;
 
 	Line = Map->plus.Line[line];
 	if (Line == NULL) {	/* Dead line */
@@ -174,20 +174,29 @@
 	    continue;
 	}
 
-	if ((Map->Constraint_type_flag &&
-	     !(Line->type & Map->Constraint_type))) {
+	if ((Map->constraint.type_flag &&
+	     !(Line->type & Map->constraint.type))) {
 	    Map->next_line++;
 	    continue;
 	}
 
 	ret = V2_read_line_nat(Map, line_p, line_c, Map->next_line++);
-	if (Map->Constraint_region_flag) {
+
+	if (Map->constraint.region_flag) {
 	    Vect_line_box(line_p, &lbox);
 	    if (!Vect_box_overlap(&lbox, &mbox)) {
 		continue;
 	    }
 	}
 
+	if (line_c && Map->constraint.field_flag) {
+	    for (i = 0; i < line_c->n_cats; i++) {
+		if (line_c->field[i] == Map->constraint.field)
+		    break;
+	    }
+	    if (i == line_c->n_cats)
+		continue;
+	}
 	return ret;
     }
     
@@ -263,7 +272,7 @@
 	    c->n_cats = n_cats;
 	    if (n_cats > 0) {
 		if (0 > dig_alloc_cats(c, (int)n_cats + 1))
-		    return (-1);
+		    return -1;
 
 		if (Map->head.Version_Minor == 1) {	/* coor format 5.1 */
 		    if (0 >=

Modified: grass/trunk/lib/vector/Vlib/read_ogr.c
===================================================================
--- grass/trunk/lib/vector/Vlib/read_ogr.c	2011-11-14 08:13:33 UTC (rev 49226)
+++ grass/trunk/lib/vector/Vlib/read_ogr.c	2011-11-14 08:14:43 UTC (rev 49227)
@@ -142,7 +142,7 @@
     if (line_c != NULL)
 	Vect_reset_cats(line_c);
 
-    if (Map->Constraint_region_flag && !ignore_constraint)
+    if (Map->constraint.region_flag && !ignore_constraint)
 	Vect_get_constraint_box(Map, &mbox);
 
     fInfo = &(Map->fInfo.ogr);
@@ -181,15 +181,15 @@
 	/* Constraint on Type of line 
 	 * Default is all of  Point, Line, Area and whatever else comes along
 	 */
-	if (Map->Constraint_type_flag && !ignore_constraint) {
-	    if (!(itype & Map->Constraint_type)) {
+	if (Map->constraint.type_flag && !ignore_constraint) {
+	    if (!(itype & Map->constraint.type)) {
 		fInfo->lines_next++;
 		continue;
 	    }
 	}
 
 	/* Constraint on specified region */
-	if (Map->Constraint_region_flag && !ignore_constraint) {
+	if (Map->constraint.region_flag && !ignore_constraint) {
 	    Vect_line_box(fInfo->lines[fInfo->lines_next],
 			  &lbox);
 
@@ -260,7 +260,7 @@
 
     G_debug(3, "V2_read_next_line_ogr()");
     
-    if (Map->Constraint_region_flag)
+    if (Map->constraint.region_flag)
 	Vect_get_constraint_box(Map, &mbox);
     
     while(TRUE) {
@@ -276,8 +276,8 @@
 	    continue;
 	}
 
-	if ((Map->Constraint_type_flag &&
-	     !(Line->type & Map->Constraint_type))) {
+	if ((Map->constraint.type_flag &&
+	     !(Line->type & Map->constraint.type))) {
 	    continue;
 	}
 
@@ -319,7 +319,7 @@
 	    ret = read_next_line_ogr(Map, line_p, line_c, TRUE);
 	}
 	
-	if (Map->Constraint_region_flag) {
+	if (Map->constraint.region_flag) {
 	    Vect_line_box(line_p, &lbox);
 	    if (!Vect_box_overlap(&lbox, &mbox)) {
 		continue;



More information about the grass-commit mailing list