Browse Source

remove sites element and library - https://trac.osgeo.org/grass/ticket/2440

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@62179 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 10 years ago
parent
commit
59b40aab6e

+ 0 - 4
gui/wxpython/gui_core/gselect.py

@@ -434,10 +434,6 @@ class TreeCtrlComboPopup(ListCtrlComboPopup):
                        'labels':'labels',
                        'label':'labels',
                        'paint label files':'labels',
-                       'site_lists':'sites',
-                       'sites':'sites',
-                       'site list':'sites',
-                       'site list files':'sites',
                        'windows':'region',
                        'region':'region',
                        'region definition':'region',

+ 0 - 1
lib/Makefile

@@ -27,7 +27,6 @@ SUBDIRS = \
 	cluster \
 	rowio \
 	segment \
-	sites \
 	rst \
 	lidar \
 	raster3d \

+ 0 - 1
lib/manage/element_list

@@ -25,7 +25,6 @@ dig:oldvect:old vector:old (GRASS 5.0) vector map(s)
 dig_ascii:asciivect:asciivector:ASCII vector map(s)
 icons:icon:icon:paint icon file(s)
 paint/labels:labels:label:paint label file(s)
-site_lists:sites:site list:site list file(s)
 windows:region:region definition:region definition(s)
 windows3d:region3d:region3D definition:3D region definition(s)
 group:group:imagery group:imagery group(s)

+ 1 - 2
lib/manage/option.c

@@ -50,8 +50,7 @@ struct Option* M_define_option(int n, const char *desc, int multiple)
     if (strcmp(p->key, "rast") == 0 || strcmp(p->key, "rast3d") == 0)
 	p->guisection = _("Raster");
     else if (strcmp(p->key, "vect") == 0 || strcmp(p->key, "oldvect") == 0 ||
-	     strcmp(p->key, "asciivect") == 0 ||
-	     strcmp(p->key, "sites") == 0)
+	     strcmp(p->key, "asciivect") == 0)
 	p->guisection = _("Vector");
     else if (strcmp(p->key, "region") == 0 || strcmp(p->key, "region3d") == 0)
 	p->guisection = _("Region");

+ 0 - 11
lib/sites/Makefile

@@ -1,11 +0,0 @@
-MODULE_TOPDIR = ../..
-
-
-LIB = SITES
-EXTRA_INC = $(VECT_INC)
-EXTRA_CFLAGS = $(VECT_CFLAGS)
-
-include $(MODULE_TOPDIR)/include/Make/Lib.make
-
-default: lib
-

+ 0 - 43
lib/sites/README

@@ -1,43 +0,0 @@
-Radim Blazek blazek at itc.it 
- Tue, 23 Sep 2003 12:11:27 +0200 
- [updated MN Oct 25 2003]
-
-I have modified G_site* functions to use vectors. It is temporary solution
-how to update s.* modules to 5.1/7 v.* without a lot of work. Attributes are
-supported by G_site_get() but G_site_put() writes CELL category only
-(attributes may be added later if needed). Old G_site* functions used by
-v.in.sites are renamed to G_oldsites*. There are only 2 s.* modules in 5.1/7
-(s.in.ascii,s.out.ascii; to be removed later) for tests of new SITESLIB. I
-updated 2 other modules, v.random and v.surf.idw. It is not my intention to
-update all other s.* modules as mostly I don't know too much about them and
-don't need them.
-
-To updated s.* to v.*, it is typically necessary:
-1) ->key = "sites"			=>  "input" / "output" / "vector"
-2) ->description="... sites ..."	=> "... vector points ..."
-3) ->gisprompt="old,site_lists,sites"	=> "old,vector,vector"
-   ->gisprompt="any,site_lists,sites"	=> "any,vector,vector"
-   ->gisprompt="new,site_lists,sites"	=> "new,vector,vector"
-4) new function name and less parameters:
-    G_find_file ("site_lists",,) 	=> G_find_sites (,)
-5) fclose() 				=> G_sites_close()
-   (Hint: to find close(), search for related G_fopen_sites_old())
-6) add
-    #include <grass/site.h>
-7) The Makefile needs a reference to $(SITESLIB).
-
-New version is slower (dbf driver, 10000 points): 
-                 time(200x200cells)   time(667x667cells)
-s.surf.idw              0.43                10.71
-v.surf.idw              1.76                11.35
-
-Radim
-
-##################
-
-G_site_put() currently only writes 2D sites files.
-
-##################
-This modified sites lib reads *vector* maps. Any old sites files
-have to be imported with v.in.sites first.
-

+ 0 - 905
lib/sites/sites.c

@@ -1,905 +0,0 @@
-/*!
-  \brief Old sites library
-
-  These functions and definitions support the site format for 5.0
-  (format proposed by Dave Gerdes):
-  
-  \verbatim
-  easting|northing|[z|[d4|]...][#category_int] [ [@attr_text OR %flt] ... ]
-  \endverbatim
- 
-  to allow multidimensions (everything preceding the last '|') and any
-  number of text or numeric attribute fields.
-  
-  \author James Darrell McCauley <mccauley@ecn.purdue.edu> (31 Jan 1994)
-*/
-
-#include <ctype.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <grass/gis.h>
-#include <grass/site.h>
-#include <grass/dbmi.h>
-#include <grass/vector.h>
-#include <grass/glocale.h>
-
-#define DQUOTE '"'
-#define SPACE ' '
-#define BSLASH 92
-#define PIPE '|'
-
-#define ispipe(c) (c==PIPE)
-#define isnull(c) (c=='\0')
-
-#define FOUND_ALL(s,n,dim,c,d) (((s->cattype != -1 && !n) || \
-				 (dim < s->dim_alloc) || \
-				 (c < s->str_alloc) || \
-				 (d < s->dbl_alloc))?0:1)
-
-
-static char *next_att(const char *);
-static int cleanse_string(char *);
-static int G__oldsite_get(FILE *, Site *, int);
-
-static int site_att_cmp(const void *pa, const void *pb)
-{
-    const struct site_att *a = pa, *b = pb;
-
-    return a->cat - b->cat;
-}
-
-/*!
-  \brief Get site
-  
-  \param Map
-  \param s
-
-  \return 0 on success
-  \return -1 on EOF
-  \return -2 on other fatal error or insufficient data,
-  \return 1 on format mismatch (extra data)
-*/
-int G_site_get(struct Map_info *Map, Site * s)
-{
-    int i, type, cat;
-    static struct line_pnts *Points = NULL;
-    static struct line_cats *Cats = NULL;
-    struct site_att *sa;
-
-    if (Points == NULL)
-	Points = Vect_new_line_struct();
-    if (Cats == NULL)
-	Cats = Vect_new_cats_struct();
-
-    while (1) {
-	type = Vect_read_next_line(Map, Points, Cats);
-
-	if (type == -1)
-	    return -2;		/* Error */
-	if (type == -2)
-	    return -1;		/* EOF */
-	if (type != GV_POINT)
-	    continue;		/* Is not point */
-
-	Vect_cat_get(Cats, 1, &cat);
-
-	G_debug(4, "Site: %f|%f|%f|#%d", Points->x[0], Points->y[0],
-		Points->z[0], cat);
-
-	s->east = Points->x[0];
-	s->north = Points->y[0];
-	if (Vect_is_3d(Map))
-	    s->dim[0] = Points->z[0];
-
-	s->ccat = cat;
-
-	/* find att */
-
-	if (Map->n_site_att > 0) {
-	    sa = (struct site_att *) bsearch((void *)&cat, (void *)Map->site_att,
-				      Map->n_site_att, sizeof(struct site_att),
-				      site_att_cmp);
-
-	    if (sa == NULL) {
-		G_warning(_("Attributes for category %d not found"), cat);
-		for (i = 0; i < Map->n_site_dbl; i++)
-		    s->dbl_att[i] = 0;
-		for (i = 0; i < Map->n_site_str; i++)
-		    strncpy(s->str_att[i], "", MAX_SITE_STRING);
-	    }
-	    else {
-		for (i = 0; i < Map->n_site_dbl; i++)
-		    s->dbl_att[i] = sa->dbl[i];
-		for (i = 0; i < Map->n_site_str; i++)
-		    strncpy(s->str_att[i], sa->str[i], MAX_SITE_STRING);
-	    }
-	}
-
-	return 0;
-    }
-}
-
-/*!
-  \brief Writes a site to file open on fptr
-
-  \param Map
-  \param s
-  
-  \return
-*/
-int G_site_put(struct Map_info *Map, const Site * s)
-{
-    static struct line_pnts *Points = NULL;
-    static struct line_cats *Cats = NULL;
-
-    if (Points == NULL)
-	Points = Vect_new_line_struct();
-    if (Cats == NULL)
-	Cats = Vect_new_cats_struct();
-
-    Vect_reset_line(Points);
-    Vect_reset_cats(Cats);
-
-    /* no 3D support so far: s->dim[0] */
-    Vect_append_point(Points, s->east, s->north, 0.0);
-
-    G_debug(4, "cattype = %d", s->cattype);
-
-    if (s->cattype == FCELL_TYPE || s->cattype == DCELL_TYPE)
-	G_fatal_error(_("Category must be integer"));
-
-    if (s->cattype == CELL_TYPE)
-	Vect_cat_set(Cats, 1, s->ccat);
-
-    Vect_write_line(Map, GV_POINT, Points, Cats);
-
-    return 0;
-}
-
-/*!
-  \brief Tries to guess the format of a sites list
-
-   The dimensionality, the presence/type of a category, and the number
-   of string and decimal attributes) by reading the first record in
-   the file.
-
-   \return 0 on success
-   \return -1 on EOF
-   \return -2 for other error
-*/
-int G_site_describe(struct Map_info *Map, int *dims, int *cat, int *strs,
-		    int *dbls)
-{
-    if (Vect_is_3d(Map)) {
-	G_debug(1, "Vector is 3D -> number of site dimensions is 3");
-	*dims = 3;
-    }
-    else {
-	G_debug(1, "Vector is 2D -> number of site dimensions is 2");
-	*dims = 2;
-    }
-
-    *cat = CELL_TYPE;
-
-    /* attributes ignored for now, later read from DB */
-    *dbls = Map->n_site_dbl;
-    *strs = Map->n_site_str;
-
-    return 0;
-}
-
-/*!
-  \brief Writes site_head struct
-*/
-int G_site_put_head(struct Map_info *Map, Site_head * head)
-{
-    static char buf[128];
-
-    if (head->name != NULL)
-	Vect_set_map_name(Map, head->name);
-
-    /* crashes:
-       if (head->desc!=NULL)
-       Vect_set_comment (Map, head->desc);
-     */
-
-    /*
-       if (head->form!=NULL)
-       fprintf(ptr,"form|%s\n",head->form);
-       if (head->labels!=NULL)
-       fprintf(ptr,"labels|%s\n",head->labels);
-     */
-    /* time could be in (char *) stime, (struct TimeStamp *) time, 
-       both, or neither */
-    if (head->stime != NULL || head->time != NULL) {
-	if (head->time != NULL) {	/* TimeStamp struct has precendence */
-	    G_format_timestamp(head->time, buf);
-	    Vect_set_date(Map, buf);
-	}
-	else if (head->stime != NULL) {	/* next check string */
-	    if (head->time == NULL) {
-		if ((head->time =
-		     (struct TimeStamp *)G_malloc(sizeof(struct TimeStamp)))
-		    == NULL)
-		    G_fatal_error(_("Memory error in writing timestamp"));
-		else if (G_scan_timestamp(head->time, head->stime) < 0) {
-		    G_warning(_("Illegal TimeStamp string"));
-		    return -1;	/* added to prevent crash 5/2000 MN */
-		}
-	    }
-	    G_format_timestamp(head->time, buf);
-	    head->stime = G_store(buf);
-	    Vect_set_date(Map, head->stime);
-	}
-    }
-    return 0;
-}
-
-struct Map_info *G_sites_open_old(const char *name, const char *mapset)
-{
-    struct Map_info *Map;
-    struct field_info *fi;
-    int more, nrows, row, ncols, col, ndbl, nstr, adbl, astr, ctype;
-    struct site_att *sa;
-
-    dbDriver *driver;
-    dbString stmt;
-    dbCursor cursor;
-    dbTable *table;
-    dbColumn *column;
-    dbValue *value;
-
-    G_message(
-	_("Dev note: Adapted sites library used for vector points. "
-	  "(module should be updated to GRASS 6 vector library)"));
-
-    Map = (struct Map_info *)G_malloc(sizeof(struct Map_info));
-
-    Vect_set_open_level(1);
-
-    if (Vect_open_old(Map, name, mapset) < 0)
-	G_fatal_error(_("Unable to open vector map <%s>"), name);
-
-    G_debug(1, "Vector map opened");
-
-    /* Load attributes */
-    Map->site_att = NULL;
-    Map->n_site_att = 0;
-    Map->n_site_dbl = 0;
-    Map->n_site_str = 0;
-
-    fi = Vect_get_field(Map, 1);
-    if (fi == NULL) {		/* not attribute table */
-	G_debug(1, "No attribute table");
-	return Map;
-    }
-
-    driver = db_start_driver_open_database(fi->driver, fi->database);
-    if (driver == NULL)
-	G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
-		      fi->database,
-		      fi->driver);
-
-    db_init_string(&stmt);
-    db_set_string(&stmt, "select * from ");
-    db_append_string(&stmt, fi->table);
-
-    if (db_open_select_cursor(driver, &stmt, &cursor, DB_SEQUENTIAL) != DB_OK)
-	G_fatal_error(_("Unable to open select cursor: '%s'"),
-		      db_get_string(&stmt));
-
-    nrows = db_get_num_rows(&cursor);
-    G_debug(1, "%d rows selected from vector attribute table", nrows);
-
-    Map->site_att = (struct site_att *) malloc(nrows * sizeof(struct site_att));
-    Map->n_site_att = nrows;
-
-    table = db_get_cursor_table(&cursor);
-    ncols = db_get_table_number_of_columns(table);
-
-    row = 0;
-    adbl = astr = 0;
-    while (1) {
-	if (db_fetch(&cursor, DB_NEXT, &more) != DB_OK)
-	    G_fatal_error(_("Cannot fetch row"));
-
-	if (!more)
-	    break;
-
-	/* Get number of each type */
-	if (row == 0) {
-	    for (col = 0; col < ncols; col++) {
-		column = db_get_table_column(table, col);
-		ctype = db_sqltype_to_Ctype(db_get_column_sqltype(column));
-
-		if (strcmp(db_get_column_name(column), fi->key) == 0)
-		    continue;
-
-		switch (ctype) {
-		case DB_C_TYPE_INT:
-		case DB_C_TYPE_DOUBLE:
-		    adbl++;
-		    break;
-		case DB_C_TYPE_STRING:
-		case DB_C_TYPE_DATETIME:
-		    astr++;
-		    break;
-		}
-	    }
-	    Map->n_site_dbl = adbl;
-	    Map->n_site_str = astr;
-	    G_debug(1, "adbl = %d astr = %d", adbl, astr);
-	}
-
-	sa = &(Map->site_att[row]);
-	sa->dbl = (double *)malloc(adbl * sizeof(double));
-	sa->str = (char **)malloc(astr * sizeof(char *));
-
-	ndbl = nstr = 0;
-	for (col = 0; col < ncols; col++) {
-	    column = db_get_table_column(table, col);
-	    ctype = db_sqltype_to_Ctype(db_get_column_sqltype(column));
-	    value = db_get_column_value(column);
-
-	    if (strcmp(db_get_column_name(column), fi->key) == 0) {
-		sa->cat = db_get_value_int(value);
-	    }
-	    else {
-		switch (ctype) {
-		case DB_C_TYPE_INT:
-		    sa->dbl[ndbl] = db_get_value_int(value);
-		    ndbl++;
-		    break;
-		case DB_C_TYPE_DOUBLE:
-		    sa->dbl[ndbl] = db_get_value_double(value);
-		    ndbl++;
-		    break;
-		case DB_C_TYPE_STRING:
-		    sa->str[nstr] = G_store(db_get_value_string(value));
-		    nstr++;
-		    break;
-		case DB_C_TYPE_DATETIME:
-		    sa->str[nstr] = "";	/* TODO */
-		    nstr++;
-		    break;
-		}
-	    }
-	}
-	row++;
-    }
-    db_close_database_shutdown_driver(driver);
-
-    /* sort attributes */
-    qsort((void *)Map->site_att, Map->n_site_att, sizeof(struct site_att),
-	  site_att_cmp);
-
-    return Map;
-}
-
-
-struct Map_info *G_sites_open_new(const char *name)
-{
-    struct Map_info *Map;
-
-    G_message(
-	_("Dev note: Adapted sites library used for vector points. "
-	  "(module should be updated to GRASS 6 vector library)"));
-    G_warning("Site/vector attributes ignored.");
-
-    Map = (struct Map_info *)G_malloc(sizeof(struct Map_info));
-
-    if (Vect_open_new(Map, name, 0) < 0)
-	G_fatal_error(_("Unable to create vector map <%s>"), name);
-
-    G_debug(1, "New vector map opened");
-
-    return Map;
-}
-
-struct Map_info *G_fopen_sites_old(const char *name, const char *mapset)
-{
-    return G_sites_open_old(name, mapset);
-}
-
-struct Map_info *G_fopen_sites_new(const char *name)
-{
-    return G_sites_open_new(name);
-}
-
-/*!
-  \brief Free memory for a Site struct
-
-  \param s
-*/
-void G_site_free_struct(Site * s)
-{
-    if (s->dim_alloc)
-	G_free(s->dim);
-    if (s->str_alloc)
-	G_free(s->str_att);
-    if (s->dbl_alloc)
-	G_free(s->dbl_att);
-    G_free(s);
-
-    return;
-}
-
-/*!
-  \brief Allocate memory for a Site struct.
-
-  cattype= -1 (no cat), CELL_TYPE, FCELL_TYPE, or DCELL_TYPE 
-  
-  \return properly allocated site struct or NULL on error. 
-*/
-Site *G_site_new_struct(RASTER_MAP_TYPE cattype,
-			int n_dim, int n_s_att, int n_d_att)
-{
-    int i;
-    Site *s;
-
-    if (n_dim < 2 || n_s_att < 0 || n_d_att < 0)
-	G_fatal_error(_("G_oldsite_new_struct: invalid # dims or fields"));
-
-    if ((s = (Site *) G_malloc(sizeof(Site))) == NULL)
-	return (Site *) NULL;
-
-    s->cattype = cattype;
-    s->ccat = s->fcat = s->dcat = 0;
-
-    if (n_dim > 2) {
-	if ((s->dim =
-	     (double *)G_malloc((n_dim - 2) * sizeof(double))) == NULL) {
-	    G_free(s);
-	    return (Site *) NULL;
-	}
-    }
-    s->dim_alloc = n_dim - 2;
-
-    if (n_d_att > 0) {
-	if ((s->dbl_att =
-	     (double *)G_malloc(n_d_att * sizeof(double))) == NULL) {
-	    if (n_dim > 2)
-		G_free(s->dim);
-	    G_free(s);
-	    return (Site *) NULL;
-	}
-    }
-    s->dbl_alloc = n_d_att;
-
-    if (n_s_att > 0) {
-	if ((s->str_att =
-	     (char **)G_malloc(n_s_att * sizeof(char *))) == NULL) {
-	    if (n_d_att > 0)
-		G_free(s->dbl_att);
-	    if (n_dim > 2)
-		G_free(s->dim);
-	    G_free(s);
-	    return (Site *) NULL;
-	}
-	else
-	    for (i = 0; i < n_s_att; ++i)
-		if ((s->str_att[i] =
-		     (char *)G_malloc(MAX_SITE_STRING * sizeof(char))) ==
-		    NULL) {
-		    while (--i)
-			G_free(s->str_att[i]);
-		    G_free(s->str_att);
-		    if (n_d_att > 0)
-			G_free(s->dbl_att);
-		    if (n_dim > 2)
-			G_free(s->dim);
-		    G_free(s);
-		    return (Site *) NULL;
-		}
-    }
-    s->str_alloc = n_s_att;
-
-    return s;
-}
-
-/*!
-  \brief Writes a site to file open on fptr
-*/
-int G_oldsite_get(FILE * fptr, Site * s)
-{
-    return G__oldsite_get(fptr, s, G_projection());
-}
-
-/*!
-  \brief Get site (old version)
-
-  \return 0 on success,
-  \return -1 on EOF,
-  \return -2 on other fatal error or insufficient data,
-  \return 1 on format mismatch (extra data)
-*/
-int G__oldsite_get(FILE * ptr, Site * s, int fmt)
-{
-    char sbuf[MAX_SITE_LEN], *buf, *last, *p1, *p2;
-    char ebuf[128], nbuf[128];
-    int n = 0, d = 0, c = 0, dim = 0, err = 0, tmp;
-
-    buf = sbuf;
-
-    if ((buf = fgets(sbuf, 1024, ptr)) == (char *)NULL)
-	return EOF;
-
-    while ((*buf == '#' || !isdigit(*buf)) && *buf != '-' && *buf != '+')
-	if ((buf = fgets(sbuf, 1024, ptr)) == (char *)NULL)
-	    return EOF;
-
-    if (buf[strlen(buf) - 1] == '\n')
-	buf[strlen(buf) - 1] = '\0';
-
-    if (sscanf(buf, "%[^|]|%[^|]|%*[^\n]", ebuf, nbuf) < 2) {
-	fprintf(stderr, "ERROR: ebuf %s nbuf %s\n", ebuf, nbuf);
-	return -2;
-    }
-
-    if (!G_scan_northing(nbuf, &(s->north), fmt) ||
-	!G_scan_easting(ebuf, &(s->east), fmt)) {
-	fprintf(stderr, "ERROR: ebuf %s nbuf %s\n", ebuf, nbuf);
-	return -2;
-    }
-
-    /* move pointer past easting and northing fields */
-    if (NULL == (buf = strchr(buf, PIPE)))
-	return -2;
-    if (NULL == (buf = strchr(buf + 1, PIPE)))
-	return -2;
-
-    /* check for remaining dimensional fields */
-    do {
-	buf++;
-	if (isnull(*buf))
-	    return (FOUND_ALL(s, n, dim, c, d) ? 0 : -2);
-	last = buf;
-	if (dim < s->dim_alloc) {	/* should be more dims to read */
-	    if (sscanf(buf, "%lf|", &(s->dim[dim++])) < 1)
-		return -2;	/* no more dims, though expected */
-	}
-	else if (NULL != (p1 = strchr(buf, PIPE))) {
-	    if (NULL == (p2 = strchr(buf, DQUOTE)))
-		err = 1;	/* more dims, though none expected */
-	    else if (strlen(p1) > strlen(p2))
-		err = 1;	/* more dims, though none expected */
-	}
-    } while ((buf = strchr(buf, PIPE)) != NULL);
-    buf = last;
-
-    /* no more dimensions-now we parse attribute fields */
-    while (!isnull(*buf)) {
-	switch (*buf) {
-	case '#':		/* category field */
-	    if (n == 0) {
-		switch (s->cattype) {
-		case CELL_TYPE:
-		    if (sscanf(buf, "#%d", &s->ccat) == 1)
-			n++;
-		    break;
-		case FCELL_TYPE:
-		    if (sscanf(buf, "#%f", &s->fcat) == 1)
-			n++;
-		    break;
-		case DCELL_TYPE:
-		    if (sscanf(buf, "#%lf", &s->dcat) == 1)
-			n++;
-		    break;
-		default:
-		    err = 1;	/* has cat, none expected */
-		    break;
-		}
-	    }
-	    else {
-		err = 1;	/* extra cat */
-	    }
-
-	    /* move to beginning of next attribute */
-	    if ((buf = next_att(buf)) == (char *)NULL)
-		return (FOUND_ALL(s, n, dim, c, d) ? err : -2);
-	    break;
-
-	case '%':		/* decimal attribute */
-	    if (d < s->dbl_alloc) {
-		p1 = ++buf;
-		errno = 0;
-		s->dbl_att[d++] = strtod(buf, &p1);
-		if (p1 == buf || errno == ERANGE) {
-		    /* replace with:
-		     * s->dbl_att[d - 1] = NAN
-		     * when we add NULL attribute support
-		     */
-		    return -2;
-		}
-		/* err = 0; Make sure this is zeroed */
-	    }
-	    else {
-		err = 1;	/* extra decimal */
-	    }
-
-	    if ((buf = next_att(buf)) == (char *)NULL) {
-		return (FOUND_ALL(s, n, dim, c, d)) ? err : -2;
-	    }
-	    break;
-	case '@':		/* string attribute */
-	    if (isnull(*buf) || isnull(*(buf + 1)))
-		return (FOUND_ALL(s, n, dim, c, d) ? err : -2);
-	    else
-		buf++;
-	default:		/* defaults to string attribute */
-	    /* allow both prefixed and unprefixed strings */
-	    if (c < s->str_alloc) {
-		if ((tmp = cleanse_string(buf)) > 0) {
-		    strncpy(s->str_att[c++], buf, tmp);
-		    buf += tmp;
-		}
-		else
-		    return (FOUND_ALL(s, n, dim, c, d) ? err : -2);
-	    }
-	    if ((buf = next_att(buf)) == (char *)NULL) {
-		return (FOUND_ALL(s, n, dim, c, d) ? err : -2);
-	    }
-	    break;
-	}
-    }
-
-    return (FOUND_ALL(s, n, dim, c, d) ? err : -2);
-}
-
-/*!
-  \brief Tries to guess the format of a sites list (old version)
-
-  The dimensionality, the presence/type of a category, and the number
-  of string and decimal attributes) by reading the first record in the
-  file.
-
-  \return 0 on success,
-  \return -1 on EOF,
-  \return -2 for other error
-*/
-int G_oldsite_describe(FILE * ptr, int *dims, int *cat, int *strs, int *dbls)
-{
-    char sbuf[MAX_SITE_LEN], *buf;
-    char ebuf[128], nbuf[128];
-    int err;
-    int itmp;
-    float ftmp;
-
-    if (G_ftell(ptr) != 0L) {
-	G_warning(_("G_oldsite_describe() must be called "
-		    "immediately after G_fopen_sites_old()."));
-	return -2;
-    }
-
-    *dims = *strs = *dbls = 0;
-    *cat = -1;
-    buf = sbuf;
-
-    if ((buf = fgets(sbuf, 1024, ptr)) == (char *)NULL) {
-	rewind(ptr);
-	return EOF;
-    }
-    /* skip over comment & header lines */
-    while ((*buf == '#' || !isdigit(*buf)) && *buf != '-' && *buf != '+')
-	if ((buf = fgets(sbuf, 1024, ptr)) == (char *)NULL) {
-	    rewind(ptr);
-	    return EOF;
-	}
-
-    if (buf[strlen(buf) - 1] == '\n')
-	buf[strlen(buf) - 1] = '\0';
-
-    if ((err = sscanf(buf, "%[^|]|%[^|]|%*[^\n]", ebuf, nbuf)) < 2) {
-	G_debug(1, "ebuf %s nbuf %s", ebuf, nbuf);
-	rewind(ptr);
-	return -2;
-    }
-    *dims = 2;
-
-    /* move pointer past easting and northing fields */
-    while (!ispipe(*buf) && !isnull(*buf))
-	buf++;
-    if (!isnull(*buf) && !isnull(*(buf + 1)))
-	buf++;
-    else {
-	rewind(ptr);
-	return -2;
-    }
-    while (!ispipe(*buf) && !isnull(*buf))
-	buf++;
-    if (!isnull(*buf) && !isnull(*(buf + 1)))
-	buf++;
-    else {
-	rewind(ptr);
-	return 0;
-    }
-
-    /* check for remaining dimensional fields */
-    while (strchr(buf, PIPE) != (char *)NULL) {
-	(*dims)++;
-	while (!ispipe(*buf) && !isnull(*buf))
-	    buf++;
-	if (isnull(*buf) || isnull(*(buf + 1))) {
-	    rewind(ptr);
-	    return 0;
-	}
-	if (!isnull(*(buf + 1)))
-	    buf++;
-	else {
-	    rewind(ptr);
-	    return -2;
-	}
-    }
-
-    /* no more dimensions-now we parse attribute fields */
-    while (!isnull(*buf)) {
-	switch (*buf) {
-	case '#':		/* category field */
-	    sscanf(buf, "#%s ", ebuf);
-	    if (strstr(ebuf, ".") == NULL && sscanf(ebuf, "%d", &itmp) == 1)
-		*cat = CELL_TYPE;
-	    else if (strstr(ebuf, ".") != NULL &&
-		     sscanf(ebuf, "%f", &ftmp) == 1)
-		*cat = FCELL_TYPE;
-	    else
-		*cat = -1;
-
-	    /* move to beginning of next attribute */
-	    while (!isspace(*buf) && !isnull(*buf))
-		buf++;
-	    if (isnull(*buf) || isnull(*(buf + 1))) {
-		rewind(ptr);
-		return 0;
-	    }
-	    else
-		buf++;
-	    break;
-	case '%':		/* decimal attribute */
-	    (*dbls)++;
-	    /* move to beginning of next attribute */
-	    while (!isspace(*buf) && !isnull(*buf))
-		buf++;
-	    if (isnull(*buf) || isnull(*(buf + 1))) {
-		rewind(ptr);
-		return 0;
-	    }
-	    else
-		buf++;
-	    break;
-	case '@':		/* string attribute */
-	    if (isnull(*buf) || isnull(*(buf + 1))) {
-		rewind(ptr);
-		return 0;
-	    }
-	    else
-		buf++;
-	default:		/* defaults to string attribute */
-	    /* allow both prefixed and unprefixed strings */
-	    if ((err = cleanse_string(buf)) > 0) {
-		(*strs)++;
-		buf += err;
-	    }
-
-	    /* move to beginning of next attribute */
-	    while (!isspace(*buf) && !isnull(*buf))
-		buf++;
-	    if (isnull(*buf) || isnull(*(buf + 1))) {
-		rewind(ptr);
-		return 0;
-	    }
-	    else
-		buf++;
-	    break;
-	}
-    }
-
-    rewind(ptr);
-    return 0;
-}
-
-/*!
-  \brief Test if site is in region
-
-  \return 1 if site is contained within region
-  \return 0 otherwise
-*/
-int G_site_in_region(const Site * site, const struct Cell_head *region)
-{
-    /* northwest corner is in region, southeast corner is not. */
-    double e_ing;
-
-    e_ing = G_adjust_easting(site->east, region);
-    if (e_ing >= region->west &&
-	e_ing < region->east &&
-	site->north <= region->north && site->north > region->south)
-	return 1;
-
-    return 0;
-}
-
-int cleanse_string(char *buf)
-{
-    char *stop, *p, *p2;
-
-    p = buf;
-
-    /*
-     * get rid of any SPACEs at beginning while ( !isspace(*buf) && *buf !=
-     * (char) NULL) buf++; if (*buf == (char) NULL) return -1;
-     */
-
-    /* find where this string terminates */
-    if (*buf != DQUOTE) {	/* if no DQUOTEs, */
-	stop = strchr(buf, SPACE);	/* then SPACE separates */
-	if (stop == (char *)NULL)
-	    return strlen(buf);
-	else
-	    return (int)(stop - buf);
-    }
-    else {			/* otherwise string is in DQUOTEs */
-	/* but we must skip over escaped */
-	/* (BSLASHed) DQUOTEs */
-	if (*p == DQUOTE) {
-	    while (*p != '\0') {	/* get rid of first DQUOTE */
-		*p = *(p + 1);
-		p++;
-	    }
-	    p = buf;
-	    stop = strchr(p + 1, DQUOTE);
-	    while (*(stop - 1) == BSLASH)
-		stop = strchr(++stop, DQUOTE);
-	}
-    }
-    /* remove backslashes between buf and stop */
-    p = buf;
-    while ((p = strchr(p, BSLASH)) != (char *)NULL && p <= stop) {
-	p2 = p + 1;
-	if (*p2 != '\0' && (*p2 == DQUOTE || *p2 == BSLASH)) {
-	    while (*p != '\0') {
-		*p = *(p + 1);
-		p++;
-	    }
-	    stop--;
-	}
-	p = p2;
-    }
-    return (int)(stop - buf);
-}
-
-char *next_att(const char *buf)
-{
-    while (!isspace(*buf) && !isnull(*buf))
-	buf++;
-    if (isnull(*buf) || isnull(*(buf + 1)))
-	return NULL;
-    else
-	while (isspace(*(buf + 1)) && !isnull(*(buf + 1)))
-	    buf++;
-    buf++;
-    return (char *)buf;
-}
-
-int G_oldsite_s_cmp(const void *a, const void *b)
-/* qsort() comparison function for sorting an array of
-   site structures by first decimal attribute. */
-{
-    return strcmp((*(char **)((*(Site **) a)->str_att)),
-		  (*(char **)((*(Site **) b)->str_att)));
-}
-
-/*!
-  \brief Open site list (old version)
-
-  Opens the existing site list file 'name' in the 'mapset'.
-
-  \param name 
-  \param mapset mapset (empty for search path)
-
-  \return pointer to FILE
-*/
-FILE *G_oldsites_open_old(const char *name, const char *mapset)
-{
-    return G_fopen_old("site_lists", name, mapset);
-}

+ 0 - 1
scripts/Makefile

@@ -62,7 +62,6 @@ SUBDIRS = \
 	v.in.gns \
 	v.in.lines \
 	v.in.mapgen \
-	v.in.sites.all \
 	v.in.wfs \
 	v.rast.stats \
 	v.report \

+ 0 - 7
scripts/v.in.sites.all/Makefile

@@ -1,7 +0,0 @@
-MODULE_TOPDIR = ../..
-
-PGM = v.in.sites.all
-
-include $(MODULE_TOPDIR)/include/Make/Script.make
-
-default: script

+ 0 - 38
scripts/v.in.sites.all/v.in.sites.all.html

@@ -1,38 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>v.in.sites.all</em> converts all GRASS 5.0/5.3/5.4 sites files in the current
-mapset into 6.0 vectors.
-
-<h2>NOTES</h2>
-
-Sites maps from 5.0/5.3/5.4 and vector maps from 6.0 do not interfere.
-They are stored in different directories, so you can use the same names.
-Old sites maps can be listed with <em>g.list sites</em>.
-<br>
-As this GRASS version uses SQL for attribute management, there are
-some <a href=sql.html>SQL restrictings concerning the file names</a>.
-This script changes dots (e.g. "foo.bar") in old vector map names into
-underline(s) (e.g. "foo_bar"). It also adds the extension '_points' to the
-new vector map name.
-
-<h2>EXAMPLE</h2>
-
-To convert all old vector maps in the current mapset to the new vector format:
-<br>
-<div class="code"><pre>
-v.in.sites.all
-</pre></div>
-
-<h2>SEE ALSO</h2>
-
-<em>
-<a href="g.list.html">g.list</a>,
-<a href="v.in.sites.html">v.in.sites</a>
-</em>
-
-
-<h2>AUTHOR</h2>
-
-Markus Neteler, ITC-Irst, Trento, Italy
-
-<p><i>Last changed: $Date$</i>

+ 0 - 51
scripts/v.in.sites.all/v.in.sites.all.py

@@ -1,51 +0,0 @@
-#!/usr/bin/env python
-############################################################################
-#
-# MODULE:	v.in.sites.all
-# AUTHOR(S):	Markus Neteler, converted to Python by Glynn Clements
-# PURPOSE:	converts all old GRASS < V5.7 sites maps to vector maps
-#		in current mapset
-# COPYRIGHT:	(C) 2004, 2008 by the GRASS Development Team
-#
-#		This program is free software under the GNU General Public
-#		License (>=v2). Read the file COPYING that comes with GRASS
-#		for details.
-#
-#############################################################################
-
-#%module
-#% description: Converts all old GRASS < Ver5.7 sites maps in current mapset to vector maps.
-#% keywords: sites
-#% keywords: import
-#% keywords: vector
-#%end
-
-import sys
-from grass.script import core as grass
-
-def main():
-    env = grass.gisenv()
-    mapset = env['MAPSET']
-    converted = 0
-    ret = 0
-    for site in grass.list_grouped('sites')[mapset]:
-	inmap = "%s@%s" % (site, mapset)
-	outmap = site.replace(".", "_") + "_points"
-	grass.message(_("Processing %s -> %s") % (inmap, outmap))
-	if grass.run_command("v.in.sites", input = inmap, output = outmap) == 0:
-	    converted += 1
-	else:
-	    grass.warning(_("Error converting map %s to %s") % (inmap, outmap))
-	    ret = 1
-
-	if converted < 1:
-	    grass.warning(_("No sites maps converted as no old sites maps present in current mapset."))
-	else:
-	    grass.message(_("Total %u sites maps in current mapset converted to vector maps (original names extended by '_points')") % converted)
-	    grass.message(_("Please verify new vector map(s) before deleting old sites map(s)."))
-
-	sys.exit(ret)
-
-if __name__ == "__main__":
-    options, flags = grass.parser()
-    main()

+ 0 - 1
vector/Makefile

@@ -28,7 +28,6 @@ SUBDIRS = \
 	v.in.db \
 	v.in.dxf \
 	v.in.region \
-	v.in.sites \
 	v.kcv \
 	v.kernel \
 	v.label \

+ 0 - 13
vector/v.in.sites/Makefile

@@ -1,13 +0,0 @@
-
-MODULE_TOPDIR = ../..
-
-PGM = v.in.sites
-
-LIBES = $(SITESLIB) $(VECTORLIB) $(DBMILIB) $(GISLIB)
-DEPENDENCIES = $(SITESDEP) $(VECTORDEP) $(DBMIDEP) $(GISDEP)
-EXTRA_INC = $(VECT_INC)
-EXTRA_CFLAGS = $(VECT_CFLAGS)
-
-include $(MODULE_TOPDIR)/include/Make/Module.make
-
-default: cmd

+ 0 - 262
vector/v.in.sites/main.c

@@ -1,262 +0,0 @@
-
-/******************************************************************************
- * MODULE:       v.in.sites -- Convert site_list to a vector point layer.
- *               (was s.to.vect)
- * AUTHOR(S):    Original author (1991) R.L. Glenn 
- *                  - USDA, Soil Conservation Service
- *               Changes (1995) -- PWC (??) from NRCS
- *               Modified (2000-1) Eric G. Miller <egm2@jps.net>
- *               Update to GRASS 5.7               
- *               
- * PURPOSE:      A general module to convert site_lists to vector point layers.
- * 	    
- * COPYRIGHT:    (C) 2000-2008 by the GRASS Development Team
- *
- *               This program is free software under the GNU General Public
- *               License (>=v2). Read the file COPYING that comes with GRASS
- *               for details.
- *
- ******************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <ctype.h>
-#include <grass/gis.h>
-#include <grass/dbmi.h>
-#include <grass/site.h>
-#include <grass/vector.h>
-#include <grass/glocale.h>
-
-int main(int argc, char *argv[])
-{
-    int i, cat, *clen, len;
-    const char *sname, *mapset;
-    char buf[1024];
-    int count, withz;
-    int dims, dbls, strs;
-    double z;
-    FILE *site;
-    struct Option *sitein, *outvect;
-    struct GModule *module;
-    struct Map_info Map;
-    struct line_pnts *Points;
-    struct line_cats *Cats;
-    dbString sql, strval;
-    dbDriver *driver;
-    dbHandle handle;
-    struct field_info *fi;
-
-    Site *s;
-    RASTER_MAP_TYPE map_type;
-
-    G_gisinit(argv[0]);
-
-    module = G_define_module();
-    G_add_keyword(_("vector"));
-    G_add_keyword(_("import"));
-    G_add_keyword(_("sites"));
-    module->description =
-	_("Converts a GRASS site_lists file into a vector map.");
-
-    sitein = G_define_option();
-    sitein->key = "input";
-    sitein->description = "Name of site input file";
-    sitein->type = TYPE_STRING;
-    sitein->required = YES;
-    sitein->multiple = NO;
-    sitein->gisprompt = "old,site_lists,site list";
-
-    outvect = G_define_standard_option(G_OPT_V_OUTPUT);
-
-    if (G_parser(argc, argv))
-	exit(EXIT_FAILURE);
-
-    Points = Vect_new_line_struct();
-    Cats = Vect_new_cats_struct();
-    db_init_string(&sql);
-    db_init_string(&strval);
-
-    sname = sitein->answer;
-
-    mapset = G_find_file2("site_lists", sname, "");
-    if (mapset == NULL)
-	G_fatal_error(_("Site file <%s> not found"), sname);
-
-    if ((site = G_oldsites_open_old(sname, mapset)) == NULL)
-	G_fatal_error(_("Unable to open site file <%s@%s>"), sname, mapset);
-
-    if (G_oldsite_describe(site, &dims, &map_type, &strs, &dbls) != 0)
-	G_fatal_error(_("Unable to guess site_list format"));
-
-    if ((s = G_site_new_struct(map_type, dims, strs, dbls)) == NULL)
-	G_fatal_error(_("Failed to allocate site structure"));
-
-    G_verbose_message(_("Input format: dimension: %d strings: %d FP: %d"),
-		      dims, strs, dbls);
-
-    if (map_type == FCELL_TYPE || map_type == DCELL_TYPE) {
-	G_message(_("Floating point category values, using sequential integer for category"));
-    }
-    else if (map_type != CELL_TYPE) {
-	G_message(_("No category values, using sequential integer for category"));
-    }
-
-    clen = (int *)G_calloc(strs, sizeof(int));
-    while (G_oldsite_get(site, s) >= 0) {
-	for (i = 0; i < strs; i++) {
-	    len = strlen(s->str_att[i]);
-	    if (len > clen[i])
-		clen[i] = len;
-	}
-    }
-    for (i = 0; i < strs; i++)
-	clen[i] += 10;
-
-    if (dims == 3)
-	withz = 1;
-    else
-	withz = 0;
-
-    if (Vect_open_new(&Map, outvect->answer, withz) < 0)
-	G_fatal_error(_("Unable to create vector map <%s>"), outvect->answer);
-
-    Vect_hist_command(&Map);
-
-    fi = Vect_default_field_info(&Map, 1, NULL, GV_1TABLE);
-    Vect_map_add_dblink(&Map, 1, NULL, fi->table, GV_KEY_COLUMN, fi->database,
-			fi->driver);
-
-    /* Create new table */
-    sprintf(buf, "create table %s ( ", fi->table);
-    db_append_string(&sql, buf);
-    db_append_string(&sql, "cat integer");
-
-    if (dims > 3) {
-	for (i = 2; i < dims; i++) {
-	    sprintf(buf, ", dim%d double precision", i - 1);
-	    db_append_string(&sql, buf);
-	}
-    }
-
-    if (map_type == FCELL_TYPE || map_type == DCELL_TYPE) {
-	db_append_string(&sql, ", fcat double precision");
-    }
-
-    for (i = 0; i < strs; i++) {
-	sprintf(buf, ", str%d varchar ( %d )", i + 1, clen[i]);
-	db_append_string(&sql, buf);
-    }
-
-    for (i = 0; i < dbls; i++) {
-	sprintf(buf, ", flt%d double precision", i + 1);
-	db_append_string(&sql, buf);
-    }
-    db_append_string(&sql, ")");
-
-    G_debug(1, db_get_string(&sql));
-
-    driver = db_start_driver(fi->driver);
-    if (driver == NULL)
-	G_fatal_error(_("Unable to start driver <%s>"), fi->driver);
-    db_init_handle(&handle);
-    db_set_handle(&handle, Vect_subst_var(fi->database, &Map), NULL);
-    if (db_open_database(driver, &handle) != DB_OK) {
-	db_shutdown_driver(driver);
-	G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
-		      fi->database, fi->driver);
-    }
-
-    if (db_execute_immediate(driver, &sql) != DB_OK) {
-	db_close_database(driver);
-	db_shutdown_driver(driver);
-	G_fatal_error(_("Unable to create table: %s"), db_get_string(&sql));
-    }
-
-    if (db_create_index2(driver, fi->table, GV_KEY_COLUMN) != DB_OK)
-	G_warning(_("Unable to create index for table <%s>, key <%s>"),
-		  fi->table, GV_KEY_COLUMN);
-
-    if (db_grant_on_table
-	(driver, fi->table, DB_PRIV_SELECT, DB_GROUP | DB_PUBLIC) != DB_OK)
-	G_fatal_error(_("Unable to grant privileges on table <%s>"),
-		      fi->table);
-
-    /* Convert */
-    G_verbose_message(_("Transferring sites to vector point map..."));
-
-    count = 0;
-    rewind(site);
-    while (G_oldsite_get(site, s) >= 0) {
-	/* Geometry */
-	Vect_reset_line(Points);
-	Vect_reset_cats(Cats);
-
-	if (withz)
-	    z = s->dim[0];
-	else
-	    z = 0;
-	Vect_append_point(Points, s->east, s->north, z);
-
-	if (map_type == CELL_TYPE)
-	    cat = s->ccat;
-	else
-	    cat = count + 1;
-
-	Vect_cat_set(Cats, 1, cat);
-
-	Vect_write_line(&Map, GV_POINT, Points, Cats);
-
-	/* Attributes */
-	db_zero_string(&sql);
-	sprintf(buf, "insert into %s values ( %d ", fi->table, cat);
-	db_append_string(&sql, buf);
-
-	if (map_type == FCELL_TYPE) {
-	    sprintf(buf, ", %f", s->fcat);
-	    db_append_string(&sql, buf);
-	}
-	if (map_type == DCELL_TYPE) {
-	    sprintf(buf, ", %f", s->dcat);
-	    db_append_string(&sql, buf);
-	}
-
-	for (i = 0; i < strs; i++) {
-	    db_set_string(&strval, s->str_att[i]);
-	    db_double_quote_string(&strval);
-	    sprintf(buf, ", '%s'", db_get_string(&strval));
-	    db_append_string(&sql, buf);
-	}
-
-	for (i = 0; i < dbls; i++) {
-	    sprintf(buf, ", %f", s->dbl_att[i]);
-	    db_append_string(&sql, buf);
-	}
-
-	db_append_string(&sql, ")");
-
-	G_debug(3, db_get_string(&sql));
-
-	if (db_execute_immediate(driver, &sql) != DB_OK) {
-	    db_close_database(driver);
-	    db_shutdown_driver(driver);
-	    G_fatal_error(_("Unable to insert new record: %s"),
-			  db_get_string(&sql));
-	}
-	count++;
-    }
-
-    fclose(site);
-    db_close_database(driver);
-    db_shutdown_driver(driver);
-
-    Vect_build(&Map);
-    Vect_close(&Map);
-
-    G_site_free_struct(s);
-
-    G_done_msg(_("%d sites written."), count);
-
-    exit(EXIT_SUCCESS);
-}

+ 0 - 37
vector/v.in.sites/v.in.sites.html

@@ -1,37 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>v.in.sites</em> converts GRASS site_lists file into vector format. 
-<em>Site_lists</em> file values are used as category values.
-
-<h2>NOTE</h2>
-
-The requirements of the site_lists file are standard 
-(i.e., a regular site_lists file format is required)
-
-<div class="code"><pre>
-name|test
-desc|Imported from points shapefile test.shp.
-time|3 Feb 2003 15:09:11 +0000
-3571629.904|5943214.399|#1
-3571323.64|5944517.464|#2 
-</pre></div>
-
-<b>Format example of old GRASS site_lists</b><br>
-<div class="code"><pre>
-easting|northing|[z|[d4|]...][#category_int] [ [@attr_text OR %flt] ... ]
-</pre></div>
-
-In case of a 3D sites file, the module generates a 3D vector map.
-Attributes are written into an attribute table.
-
-<h2>EXAMPLE</h2>
-<div class="code"><pre>
-v.in.sites in=sites_file out=vector_map
-</pre></div>
-
-<h2>AUTHOR</h2>
-
-R.L. Glenn, USDA, SCS, NHQ-CGIS <br>
-Radim Blazek, ITC-Irst, Trento, Italy
-
-<p><i>Last changed: $Date$</i>