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

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Aug 12 06:06:33 EDT 2008


Author: glynn
Date: 2008-08-12 06:06:33 -0400 (Tue, 12 Aug 2008)
New Revision: 32717

Modified:
   grass/trunk/lib/gis/opencell.c
   grass/trunk/lib/vector/Vlib/map.c
Log:
Fix handling of qualified map names


Modified: grass/trunk/lib/gis/opencell.c
===================================================================
--- grass/trunk/lib/gis/opencell.c	2008-08-12 10:05:05 UTC (rev 32716)
+++ grass/trunk/lib/gis/opencell.c	2008-08-12 10:06:33 UTC (rev 32717)
@@ -158,10 +158,18 @@
     int MAP_NBYTES;
     RASTER_MAP_TYPE MAP_TYPE;
     struct Reclass reclass;
+    const char *xmapset;
 
     /* make sure window is set    */
     G__init_window();
 
+    xmapset = G_find_cell2(name, mapset);
+    if (!xmapset) {
+	G_warning(_("Unable to find <%s@%s>"), name, mapset);
+	return -1;
+    }
+    mapset = xmapset;
+
     /* Check for reclassification */
     reclass_flag = G_get_reclass(name, mapset, &reclass);
 
@@ -943,15 +951,17 @@
 int G_raster_map_is_fp(const char *name, const char *mapset)
 {
     char path[GPATH_MAX];
+    const char *xmapset;
 
-    if (G_find_cell2(name, mapset) == NULL) {
-	G_warning(_("Unable to find <%s@%s>"), name, mapset);
+    xmapset = G_find_cell2(name, mapset);
+    if (!xmapset) {
+	G_warning(_("Unable to find '%s' in '%s'"), name, mapset);
 	return -1;
     }
-    G__file_name(path, "fcell", name, mapset);
+    G__file_name(path, "fcell", name, xmapset);
     if (access(path, 0) == 0)
 	return 1;
-    G__file_name(path, "g3dcell", name, mapset);
+    G__file_name(path, "g3dcell", name, xmapset);
     if (access(path, 0) == 0)
 	return 1;
     
@@ -964,8 +974,6 @@
   Determines if the raster map is floating point or integer. Returns
   DCELL_TYPE for double maps, FCELL_TYPE for float maps, CELL_TYPE for 
   integer maps, -1 if error has occured
-  
-  This function just calls G_raster_map_type()!
 
   \param name map name 
   \param mapset mapset where map <i>name</i> lives
@@ -974,38 +982,23 @@
 */
 RASTER_MAP_TYPE G_raster_map_type(const char *name, const char *mapset)
 {
-    return G_raster_map_type2(name, mapset);
-}
-
-/*!
-  \brief Determine raster type (look but don't touch)
-
-  See G_raster_map_type().
-
-  \param name map name
-  \param mapset mapset where map <i>name</i> lives
-  
-  \return raster data type
-*/
-RASTER_MAP_TYPE G_raster_map_type2(const char *name, const char *mapset)
-{
     char path[GPATH_MAX];
+    const char *xmapset;
 
-    if (G_find_cell2(name, mapset) == NULL) {
-	if (mapset) {
+    xmapset = G_find_cell2(name, mapset);
+    if (!xmapset) {
+	if (mapset && *mapset)
 	    G_warning(_("Raster map <%s> not found in mapset <%s>"), name, mapset);
-	}
-	else {
+	else
 	    G_warning(_("Raster map <%s> not found"), name);
-	}
 	return -1;
     }
-    G__file_name(path, "fcell", name, mapset);
+    G__file_name(path, "fcell", name, xmapset);
 
     if (access(path, 0) == 0)
-	return G__check_fp_type(name, mapset);
+	return G__check_fp_type(name, xmapset);
 
-    G__file_name(path, "g3dcell", name, mapset);
+    G__file_name(path, "g3dcell", name, xmapset);
 
     if (access(path, 0) == 0)
 	return DCELL_TYPE;
@@ -1046,8 +1039,14 @@
     int in_stat;
     char *str, *str1;
     RASTER_MAP_TYPE map_type;
+    const char *xmapset;
 
-    G__file_name_misc(path, "cell_misc", FORMAT_FILE, name, mapset);
+    xmapset = G_find_cell2(name, mapset);
+    if (!xmapset) {
+	G_warning(_("Unable to find '%s' in '%s'"), name, mapset);
+	return -1;
+    }
+    G__file_name_misc(path, "cell_misc", FORMAT_FILE, name, xmapset);
 
     if (access(path, 0) != 0) {
 	G_warning(_("Unable to find '%s'"), path);

Modified: grass/trunk/lib/vector/Vlib/map.c
===================================================================
--- grass/trunk/lib/vector/Vlib/map.c	2008-08-12 10:05:05 UTC (rev 32716)
+++ grass/trunk/lib/vector/Vlib/map.c	2008-08-12 10:06:33 UTC (rev 32717)
@@ -166,6 +166,7 @@
 	GV_TOPO_ELEMENT, GV_SIDX_ELEMENT, GV_CIDX_ELEMENT,
 	NULL
     };
+    const char *xmapset;
 
     dbDriver *driver;
 
@@ -174,13 +175,20 @@
     if (Vect_legal_filename(out) < 0)
 	G_fatal_error(_("Vector map name is not SQL compliant"));
 
+    xmapset = G_find_vector2(in, mapset);
+    if (!xmapset) {
+	G_warning(_("Unable to find vector map <%s> in <%s>"), in, mapset);
+	return -1;
+    }
+    mapset = xmapset;
+
     /* Delete old vector if it exists */
     if (G_find_vector2(out, G_mapset())) {
 	G_warning(_("Vector map <%s> already exists and will be overwritten"),
 		  out);
 	ret = Vect_delete(out);
 	if (ret != 0) {
-	    G_warning(_("Unable to delete vector map <%s>"), in);
+	    G_warning(_("Unable to delete vector map <%s>"), out);
 	    return -1;
 	}
     }



More information about the grass-commit mailing list