[GRASS-SVN] r39533 - in grass/trunk: include lib/gis lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 16 17:15:25 EDT 2009


Author: martinl
Date: 2009-10-16 17:15:24 -0400 (Fri, 16 Oct 2009)
New Revision: 39533

Modified:
   grass/trunk/include/vector.h
   grass/trunk/lib/gis/find_file.c
   grass/trunk/lib/vector/Vlib/close.c
   grass/trunk/lib/vector/Vlib/field.c
   grass/trunk/lib/vector/Vlib/open.c
Log:
* direct OGR read access: switch to level 2 when pseudo-topology is
built successfully
* Vect_get_field2() added


Modified: grass/trunk/include/vector.h
===================================================================
--- grass/trunk/include/vector.h	2009-10-16 18:56:18 UTC (rev 39532)
+++ grass/trunk/include/vector.h	2009-10-16 21:15:24 UTC (rev 39533)
@@ -111,6 +111,7 @@
 struct field_info *Vect_get_dblink(const struct Map_info *, int);
 struct field_info *Vect_get_field(const struct Map_info *, int);
 struct field_info *Vect_get_field_by_name(const struct Map_info *, const char *);
+struct field_info *Vect_get_field2(const struct Map_info *, const char *);
 void Vect_set_db_updated(struct Map_info *);
 const char *Vect_get_column_names(const struct Map_info *, int);
 const char *Vect_get_column_types(const struct Map_info *, int);

Modified: grass/trunk/lib/gis/find_file.c
===================================================================
--- grass/trunk/lib/gis/find_file.c	2009-10-16 18:56:18 UTC (rev 39532)
+++ grass/trunk/lib/gis/find_file.c	2009-10-16 21:15:24 UTC (rev 39533)
@@ -45,6 +45,12 @@
 	pmapset = mapset;
     }
 
+    if (strcmp(element, "vector") == 0 &&
+	strcasecmp(pmapset, "ogr") == 0) {
+	/* don't check for virtual OGR mapset */
+	return G_store(pmapset);
+    }
+    
     /*
      * reject illegal names and mapsets
      */

Modified: grass/trunk/lib/vector/Vlib/close.c
===================================================================
--- grass/trunk/lib/vector/Vlib/close.c	2009-10-16 18:56:18 UTC (rev 39532)
+++ grass/trunk/lib/vector/Vlib/close.c	2009-10-16 21:15:24 UTC (rev 39533)
@@ -105,7 +105,9 @@
     }
     else {
 	/* spatial index must also be closed when opened with topo but not modified */
-	if (Map->plus.Spidx_built == 1 && Map->plus.built == GV_BUILD_ALL)
+	if (Map->format == GV_FORMAT_NATIVE &&
+	    Map->plus.Spidx_built == 1 &&
+	    Map->plus.built == GV_BUILD_ALL)
 	    Vect_save_sidx(Map);
     }
 

Modified: grass/trunk/lib/vector/Vlib/field.c
===================================================================
--- grass/trunk/lib/vector/Vlib/field.c	2009-10-16 18:56:18 UTC (rev 39532)
+++ grass/trunk/lib/vector/Vlib/field.c	2009-10-16 21:15:24 UTC (rev 39533)
@@ -447,6 +447,27 @@
 }
 
 /*!
+  \brief Get information about link to database (by layer name or layer number)
+  
+  \param Map pointer to Map_info structure
+  \param field layer name or number
+  
+  \return pointer to new field_info structure
+  \return NULL if not found
+*/
+struct field_info *Vect_get_field2(const struct Map_info *Map, const char *field)
+{
+    struct field_info *fi = NULL;
+    G_debug(1, "Vect_get_field2(): field = %s", field);
+    
+    fi = Vect_get_field_by_name(Map, field);
+    if (fi)
+	return fi;
+
+    return Vect_get_field(Map, atoi(field));
+}
+
+/*!
   \brief Read dblinks to existing structure.
   
   Variables are not substituted by values.

Modified: grass/trunk/lib/vector/Vlib/open.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open.c	2009-10-16 18:56:18 UTC (rev 39532)
+++ grass/trunk/lib/vector/Vlib/open.c	2009-10-16 21:15:24 UTC (rev 39533)
@@ -334,12 +334,8 @@
 	}
 #endif
 	if (level_request == 2 && level < 2) {
-	    if (ogr_mapset) {
-		G_warning(_("Topology level (2) is not supported when reading "
-			    "OGR layers directly. For topology level "
-			    "is required link to OGR layer via v.external command."));
-	    }
-	    else {
+	    if (!ogr_mapset) {
+		/* for direct OGR read access is built pseudo-topology on the fly */
 		sprintf(errmsg,
 			_("Unable to open vector map <%s> on level %d. "
 			  "Try to rebuild vector topology by v.build."),
@@ -376,6 +372,7 @@
 		      Map->fInfo.ogr.layer_name, Map->fInfo.ogr.dsn);
 	    G_set_verbose(0);
 	    Vect_build(Map);
+	    level = 2;
 	    G_set_verbose(verbose);
 	}
     }
@@ -418,8 +415,7 @@
 
     /* read db links */
     Map->dblnk = Vect_new_dblinks_struct();
-    if (!ogr_mapset)
-	Vect_read_dblinks(Map);
+    Vect_read_dblinks(Map);
 
     /* open history file */
     sprintf(buf, "%s/%s", GV_DIRECTORY, Map->name);



More information about the grass-commit mailing list