]> www.wagner.pp.ru Git - oss/fgis.git/blob - dll/fgisCount.c
The second attempt to automate building :-) A lot of work here should be
[oss/fgis.git] / dll / fgisCount.c
1 #include <epp.h>
2 #include <stdlib.h>
3 #include <tcl.h>
4 #include "fgisInt.h"
5 #include "fgis.h"
6 /*
7  * This file is part of fGIS C library
8  * fgisCount.c Various routines to perform area counting on rasters
9  */
10 int count_to_array(Tcl_Interp *interp,RASTER_OBJECT raster,char *array /* here geomerty spec should be*/)
11 { EPP *e=epp(raster);
12   int *accumulate;
13   RECLASS r=raster->reclass;
14   int v,i,j,size=Fgis_RasterMax(raster)+1;
15   accumulate=calloc(ize,sizeof(int));
16 /* loop should vary according to geometry specifications */
17   for (i=e->fr;i<e->lr;i++) 
18       for (j=e->fc;j<e->lc;j++) {
19         v=epp_get(e,j,i);
20         if (v!=e->offsite)) {
21           accumulate[r[v]]++;
22       }
23   }
24   for (i=0;i<size;i++) {  
25      if (accumulate[i]) {
26        char result[32],index[8];
27        Tcl_PrintDouble(interp,accumulate[i]*e->cell_area,result);
28        sprintf(index,"%d",i);
29        Tcl_SetVar2(interp,array.index,result)
30      }
31   }
32   free(accumulate)
33   return TCL_OK;
34 }