Преглед на файлове

Vlib: update constraints which are now hidden in struct

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@49227 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa преди 13 години
родител
ревизия
d855a1780a
променени са 4 файла, в които са добавени 40 реда и са изтрити 31 реда
  1. 6 6
      lib/vector/Vlib/open.c
  2. 4 4
      lib/vector/Vlib/overlap.c
  3. 22 13
      lib/vector/Vlib/read_nat.c
  4. 8 8
      lib/vector/Vlib/read_ogr.c

+ 6 - 6
lib/vector/Vlib/open.c

@@ -214,8 +214,12 @@ int Vect__open_old(struct Map_info *Map, const char *name, const char *mapset, c
 	/* 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 @@ int Vect__open_old(struct Map_info *Map, const char *name, const char *mapset, c
 	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 @@ int Vect_open_new(struct Map_info *Map, const char *name, int with_z)
     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());

+ 4 - 4
lib/vector/Vlib/overlap.c

@@ -31,10 +31,10 @@ V__map_overlap(struct Map_info *Map, double n, double s, double e, double w)
     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);

+ 22 - 13
lib/vector/Vlib/read_nat.c

@@ -71,7 +71,7 @@ int V1_read_next_line_nat(struct Map_info *Map,
 
     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 @@ int V1_read_next_line_nat(struct Map_info *Map,
 	/* 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_line_nat(struct Map_info *Map,
 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 @@ int V2_read_next_line_nat(struct Map_info *Map,
 	    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 @@ int read_line_nat(struct Map_info *Map,
 	    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 >=

+ 8 - 8
lib/vector/Vlib/read_ogr.c

@@ -142,7 +142,7 @@ int read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
     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 @@ int read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
 	/* 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 @@ int V2_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
 
     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 @@ int V2_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
 	    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 @@ int V2_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
 	    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;