Patrick Giraudoux wrote:
> >> (...)
> >> Enter name of site map
> >> Enter 'list' for a list of existing vector files
> >> Hit RETURN to cancel request
> >>     
> >>> sites5
> >>>       
> >> <sites5>
> >> WARNING: Adapted sites library used for vector points (module should be
> >>        updated to GRASS 6 vector library).
> >> ERROR: G_get_site() not yet updated.
...
> Hm... This is quite strange. I have removed grass and then re-install 
> 6.2.3 completely. No success at all and still this frustrating message:
...
> I really wonder what the origin can be. I have re-installed thinking 
> that some library could have escaped for some reason during a former 
> updating. This ws obviously not the case since complete intallation does 
> not fix the problem. I have also tried other mapsets... with the same 
> result.

r.le.setup was not fully ported from GRASS 5. GRASS 5's "sites" format was
independent from its vector lines/areas format. In GRASS 6 these were merged.
To ease the change the GRASS 5 sites library was partially adapted to work with
GRASS 6 vectors, but as you are finding not fully.

Fortunately it is not hard to update r.le.setup, patch attached.


> My system is Ubuntu Gusty. Wonder if it could come from that ???

No, it affects everyone.

Maciek:
> > FWIW this stage works for me with current GRASS 6.2 CVS and
> > GRASS 6.3 CVS.

spearfish example:

r.le.setup map=elevation.dem vect=archsites
Setup sampling units (3)
Use keyboard to enter sampling unit dimensions (1)
How many different SCALES do you want (1-15)?   1
Centered over sites         5
Do you want to sample using rectangles
    (including squares) (y) or circles (n)?   (y/n) [y] y

Sampling unit SHAPE (aspect ratio, #cols/#rows) expressed as real number
    (e.g., 10 cols/5 rows = 2.0) for sampling units of scale 1? 1.0

    What size (in pixels) for each sampling unit of scale 1?  50
    The nearest size is 7 cells wide X 7 cells high = 49 cells
    Is this SIZE OK?   (y/n) [y] y

Enter name of site map
Enter 'list' for a list of existing vector files
Hit RETURN to cancel request
> archsites

WARNING: Adapted sites library used for vector points (module should be
         updated to GRASS 6 vector library).
ERROR: G_get_site() not yet updated.


Hamish


      
____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
Index: raster/r.le/r.le.setup/sample.c
===================================================================
RCS file: /home/grass/grassrepository/grass6/raster/r.le/r.le.setup/sample.c,v
retrieving revision 2.11
diff -u -r2.11 sample.c
--- raster/r.le/r.le.setup/sample.c	24 Apr 2007 08:21:22 -0000	2.11
+++ raster/r.le/r.le.setup/sample.c	9 Dec 2007 19:15:19 -0000
@@ -22,11 +22,12 @@
 
 #include <stdlib.h>
 #include <grass/gis.h>
-#include <grass/site.h>
-#include "setup.h"
+#include <grass/Vect.h>
 #include <grass/config.h>
 #include <grass/raster.h>
 #include <grass/display.h>
+#include <grass/glocale.h>
+#include "setup.h"
 
 
 static int calc_unit_loc (double radius, int top, int bot, int left, int right,
@@ -729,13 +730,16 @@
 	int *sites, double startx, int starty, int fmask,
 	double nx, double x, double y)
 {
-  char	  *sites_mapset, sites_file_name[GNAME_MAX], *desc, *cmd;
-  FILE	  *sites_fp;
+  char	  *sites_mapset, sites_file_name[GNAME_MAX], *cmd;
+  struct  Map_info Map;
   struct  Cell_head region;
   double  east_coord, north_coord, D_u_to_a_col(), D_u_to_a_row();
   int     i, j, k, cnt=0, w_w = right - left, w_l = bot - top, exp1, exp2,
           dx = w_w, dy = w_l, l, t, left1 = left, top1 = top, n, tmp,
 	  ulrow, ulcol, *row_buf, lap=0;
+  static struct line_pnts *Points;
+  struct line_cats *Cats;
+  int ltype;
 
 /*   VARIABLES:
 	UNITS FOR ALL DIMENSION VARIABLES IN THIS ROUTINE ARE IN PIXELS
@@ -914,23 +918,30 @@
 				/* for centered over sites */
 
   else if (method==5){
-     sites_mapset=G_ask_sites_old("    Enter name of site map", sites_file_name) ;
+     sites_mapset = G_ask_vector_old("    Enter name of vector points map", sites_file_name) ;
      if (sites_mapset == NULL) {
         G_system("d.frame -e");
         exit(0);
      }
 
-     if ((sites_fp = G_fopen_sites_old(sites_file_name,sites_mapset)) == NULL) {
-        fprintf(stderr, "\n    Can't open sites file %s\n",sites_file_name);
+     Vect_open_old(&Map, sites_file_name, sites_mapset);
+/*    fprintf(stderr, "\n    Can't open vector points file %s\n", sites_file_name); */
 
-     }
      *sites = 0;
      i = 0;
      n = 0;
 
-     while( G_get_site(sites_fp,&east_coord,&north_coord,&desc) > 0) {
-	ulcol = ((int)(D_u_to_a_col(east_coord))) + 1 - u_w/2;
-	ulrow = ((int)(D_u_to_a_row(north_coord))) + 1 - u_l/2;
+     Points = Vect_new_line_struct();    /* init line_pnts struct */
+     Cats = Vect_new_cats_struct();
+
+     while (1) {
+        ltype =  Vect_read_next_line (&Map, Points, Cats);
+        if ( ltype == -1 ) G_fatal_error(_("Cannot read vector"));
+        if ( ltype == -2 ) break;  /* EOF */
+        if (!(ltype & GV_POINTS)) continue; /* points only */
+
+	ulcol = ((int)(D_u_to_a_col(Points->x[0]))) + 1 - u_w/2;
+	ulrow = ((int)(D_u_to_a_row(Points->y[0]))) + 1 - u_l/2;
 	if (ulcol <= left || ulrow <= top || ulcol+u_w-1 > right || ulrow+u_l-1 > bot) {
 	   fprintf(stderr, "    No sampling unit over site %d at east=%8.1f north=%8.1f\n",
 	      n+1,east_coord,north_coord);
@@ -953,6 +964,10 @@
      sprintf(cmd, "d.vect %s color=black",sites_file_name);
      G_system(cmd);
      G_free (cmd);
+
+     Vect_close(&Map);
+     G_free(Points);
+     G_free(Cats);
 
   }
 
_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to