[GRASS-user] grass map names rules

Glynn Clements glynn at gclements.plus.com
Tue Nov 11 09:12:33 EST 2008


iomeneandrei wrote:

> where can I find a doc with the rules for the names I can give to a grass
> map object.
> I know I ca not use "space" and accented character, but I'm looking for the
> complete rules set.

Raster maps (as well as 3D rasters, imagery groups and regions) are
all checked using G_legal_filename() in lib/gis/legal_name.c:

	int G_legal_filename(const char *s)
	{
	    if (*s == '.' || *s == 0) {
		fprintf(stderr, _("Illegal filename.  Cannot be '.' or 'NULL'\n"));
		return -1;
	    }
	
	    for (; *s; s++)
		if (*s == '/' || *s == '"' || *s == '\'' || *s <= ' ' ||
		    *s == '@' || *s == ',' || *s == '=' || *s == '*' || *s > 0176) {
		    fprintf(stderr,
			    _("Illegal filename. Character <%c> not allowed.\n"), *s);
		    return -1;
		}
	
	    return 1;
	}

Such names cannot contain control characters (<32), 8-bit characters
(>=128), space, DEL (127), or any of /"'@,=* (slash, double quote,
single quote, at, comma, equals, asterisk).

If you want the map to be usable on Windows, you also cannot use any
of \:?<>| (backslash, colon, question mark, less-than, greater-than,
vertical bar), as those aren't allowed in filenames on Windows.

If a map name contains any of #()[]+-%><!&|?:;~ (hash, parentheses,
square brackets, plus, minus, percent, greater-than, less-than,
exclamation mark, ampersand, vertical bar, question mark, colon,
semicolon, tilde), it must be quoted within r.mapcalc, as must any
name which is a valid integer or floating-point literal.

Finally, vector map names are limited to valid SQL table names, which
means that they must begin with a letter, can only contain letters,
digits and underscores, and must not be an SQL keyword.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list