[GRASS5] readsites() TODO list...
Bill Brown - staff
brown at gis.uiuc.edu
Wed Sep 20 11:25:14 EDT 2000
Hi Eric,
just a few suggestions...
1. We already have a struct Site, so to avoid confusion how about using
"xyz_site" instead of "site" ? (If typedef'd then the convention would
be to capitalize), e.g.
typedef struct{
double x, y, z;
} XYZ_site;
This typedef would then be added to site.h
2. I think that Z-dim is not really defined by the sites interface - only
the first 2 dimensions are recognized as X and Y and any others dimensions
are just referred to as dim[2], dim[3], ... so a user might have a sites
file with 5 dimensions and no attributes, and want to use the 4th dimension
as Z. From your example, I'd guess that I'd call readsites with type=0 and
index=2 (2nd extra dimension?) That might need to be clarified.
3. num should probably be a *num so that the number actually read can be
returned in it (in case file ends) Or else add another parameter. You might
be able to eliminate done then (*num = 0).
4. What about the cat? User might want to use that as Z.
5. I suggest having a G_allocate_xyz_sites(numsites) so the allocation
and freeing would be handled outside readsites, allowing
users to re-use a block within a loop without re-allocating.
6. type should be defined and added to site.h, e.g.:
#define SITE_DIM 0
#define SITE_CAT 1
#define SITE_DBL 2
#define SITE_STR 3
- Bill
>
>/* readsites: Reads a sites file converting to a site struct of xyz values.
> * The Z value can come from one of the z-dimensions, a double attribute,
> * or a string attribute converted to a double with strtod().
> * If 'num' is less than one, attempt to read entire site file, otherwise
> * read 'num' records. The number of records read is returned. If an
> * error occurs, a negative value is returned. The caller can decide to
> * abort or retry. Error values are:
> * Couldn't allocate memory -1
> * Attribute 'type' not found -2
> * Attribute 'index' out of range -3
> * Format error in file (includes conversion error) -4
> * Something else (probably never happen) -5
> */
>
>typedef struct _site {
> double x, y, z;
>} site;
>
>int readsites(
> FILE * fdsite, /* The FILE stream to the sites file */
> int num, /* Number of records to read */
> int type, /* Attribute type: 0 =3D Z-dim, 1 =3D double, 2 =3D string=
> */
> int index, /* The field index (1 based) for the attribute */
> int * done, /* No more records in file? 0 =3D false, 1 =3D true */
> site **xyz /* The site array, caller must free between calls */
> );
>
----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo at geog.uni-hannover.de with
subject 'unsubscribe grass5'
More information about the grass-dev
mailing list