Index: test/spatial/metacat_testdata.shp
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: test/spatial/metacat_testdata.shp
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: test/spatial/metacat_testdata.dbf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: test/spatial/metacat_testdata.dbf
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: test/spatial/metacat_testdata.shx
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: test/spatial/metacat_testdata.shx
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/spatial/cpp/metacat_shapefile.cpp
===================================================================
--- src/spatial/cpp/metacat_shapefile.cpp	(revision 2638)
+++ src/spatial/cpp/metacat_shapefile.cpp	(revision 2639)
@@ -1,4 +1,3 @@
-
 /**
  *  '$RCSfile$'
  *  Copyright: 2000 Regents of the University of California and the
@@ -30,9 +29,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
-
 #include "iostream.h"
-
 #include <fstream>
 #include <string>
 #include <vector>
@@ -42,24 +39,33 @@
 
 /************************************************************************
  * Method to write the points array to the shape file and the associated
- * dbf file using the shapelib-1.2.xx libraries
+ * dbf file using the shapelib-1.2.ave_x libraries
  *
  * @param nSHPType -- the type of shapefile (eg. poly vs point )
  *
  * @param pszFilename -- the name of the shape file, sans the extension
  *
- * @param gridx -- this is the float value of the x-location (assuming points)
+ * @param min_pntx -- this is the float value of the min x-location
+ * @param max_pntx -- this is the float value of the max x-location
  *
- * @param gridy -- this is the float value of the y-location (assuming points)
+ * @param min_pnty -- this is the float value of the min y-location
+ * @param max_pnty -- this is the float value of the max y-location
  *
- * @param gridz -- this is the float value of the optional p-value
+ * @param pointz -- this is the float value of the optional p-value
  * (assuming points)
  *
  * @param the number of lines in the coordinates arrays
  ************************************************************************/
-static void WritePointsArray ( int nSHPType, const char * pszFilename,
-  float gridx[40000] [100], float gridy[40000] [100],float gridz[40000] [100],
-  vector<string> urlvec, vector<string> docidvec, int number_data_lines ) {
+static void WritePointsArray ( int nSHPType,
+  const char * pszFilename,
+  float min_pntx[40000][100],
+  float max_pntx[40000][100],
+  float min_pnty[40000][100],
+  float max_pnty[40000][100],
+  float pointz[40000][100],
+  vector<string> urlvec,
+  vector<string> docidvec,
+  int number_data_lines ) {
 
        SHPHandle hSHPHandle;
        SHPObject * psShape;
@@ -79,11 +85,11 @@
        }
 
        //add to the dbf file attributes for ID, pval(elevation), url
-       if ( DBFAddField( hDBF, "ID", FTDouble, 10, 10 ) == -1 )
+       if ( DBFAddField( hDBF, "ID", FTInteger, 10, 0 ) == -1 )
        {
-         printf( "DBFAddField(%s,FTDouble,%d,0) failed.\n" );
+         printf( "DBFAddField(%s,FTInteger,%d,0) failed.\n" );
        }
-       if ( DBFAddField( hDBF, "pval", FTDouble, 10, 10 ) == -1 )
+       if ( DBFAddField( hDBF, "area_coef", FTDouble, 10, 4 ) == -1 )
        {
          printf( "DBFAddField(%s,FTDouble,%d,0) failed.\n" );
        }
@@ -99,27 +105,23 @@
 
       //cout<<" DBF Record Count --> "<<iRecord<<endl;
       int id_field = DBFGetFieldIndex( hDBF, "ID" );
-      int pval_field = DBFGetFieldIndex( hDBF, "pval" );
       int url_field = DBFGetFieldIndex( hDBF, "url" );
       int docid_field = DBFGetFieldIndex( hDBF, "docid" );
+      int area_field = DBFGetFieldIndex( hDBF, "area_coef" );
 
-      //cout << "id field -> " << id_field << endl;
-      //cout << "pval field -> " << pval_field << endl;
-      //cout << "url field -> " << url_field << endl;
-
-
       hSHPHandle = SHPCreate( pszFilename, nSHPType );
 
        ii = 0;
        for ( ii = 0; ii < number_data_lines; ii++ )
        {
-         double xx = ( gridx[2] [ii] );
-         double yy = ( gridy[2] [ii] );
-         double zz = ( gridz[2] [ii] );
+         double area_coef = sqrt( pow((max_pntx[2][ii]-min_pntx[2][ii]),2) + pow((max_pnty[2][ii]-min_pnty[2][ii]),2)  );
+         double ave_x = ( (min_pntx[2][ii]+max_pntx[2][ii])/2 );
+         double ave_y = ( (min_pnty[2][ii]+max_pnty[2][ii])/2 );
+         double ave_z = ( pointz[2][ii] );
 
-         //if (xx < 180 && xx > -180 && yy < 90 && yy >-90 ) {
+         if (ave_x < 180 && ave_x > -180 && ave_y < 90 && ave_y >-90 ) {
 
-         psShape = SHPCreateObject( SHPT_POINT, ii, 0, NULL, NULL, 1, &xx, &yy, &zz, NULL );
+         psShape = SHPCreateObject( SHPT_POINT, ii, 0, NULL, NULL, 1, &ave_x, &ave_y, &ave_z, NULL );
 
          SHPWriteObject( hSHPHandle, -1, psShape );
          SHPDestroyObject( psShape );
@@ -126,12 +128,11 @@
          //do the update to the dbf file too
          iRecord = DBFGetRecordCount( hDBF );
 
-
         DBFWriteStringAttribute(hDBF, iRecord, url_field, urlvec[ii].c_str() );
         DBFWriteStringAttribute(hDBF, iRecord, docid_field, docidvec[ii].c_str() );
-        DBFWriteDoubleAttribute(hDBF, iRecord, pval_field, 999 );
-        DBFWriteDoubleAttribute(hDBF, iRecord, id_field, ii );
-       //  }
+        DBFWriteIntegerAttribute(hDBF, iRecord, id_field, int(ii) );
+        DBFWriteDoubleAttribute(hDBF, iRecord, area_field, area_coef );
+        }
        }
        //recompute the extents
        //SHPComputeExtents( psShape );
@@ -163,7 +164,7 @@
   std::cout<<"  ##           harris@nceas.ucsb.edu                 ##\n";
   std::cout<<"  ##           Copyright 1999-2003                   ##\n";
   std::cout<<"  ##><><><><><><><><><><><><><><><><><><><><><><><><>##\n";
-  
+
   std::cout << std::endl;
 
 }
@@ -180,9 +181,12 @@
   }
 
   //these arrays are for the input x, y, z data
-  float gridx[1000] [100];
-  float gridy[1000] [100];
-  float gridz[1000] [100];
+  float min_pntx[1000] [100];
+  float min_pnty[1000] [100];
+  float max_pntx[1000] [100];
+  float max_pnty[1000] [100];
+
+  float pointz[1000] [100];
   vector<string> docidvec;
   vector<string> urlvec;
 
@@ -192,10 +196,12 @@
 
   int cnt = 0;
   int number_lines = 0;
-  char bufa[100];
-  char buf[100];
-  char buf1[100];
-  char buf2[100];
+  char buf_docid[100];
+  char buf_xmin[100];
+  char buf_xmax[100];
+  char buf_ymin[100];
+  char buf_ymax[100];
+  char buf_url[100];
 
   SHPHandle hSHP;
   int nShapeType, nEntities, i, iPart;
@@ -208,11 +214,21 @@
     exit( 2 );
   }
 
-  /* read the data into an array -- first the grid nodes */
+  /* read the data into an array -- first the grid nodes
+   *
+   * the data should have the following columns (from left to right)
+   *
+   * nrs.239.1
+   * -121.558333333333
+   * -121.558333333333
+   * 36.2083333333333
+   * 36.2083333333333
+   * http://metacat.nceas.ucsb.edu/knb/servlet/metacat?action=read&docid=nrs.239.1&qformat=knb
+   */
   infile = fopen( argv[1], "r" );
   char const * out_shape = argv[2];
   while ( fgets( oneline, 199, infile ) ) {
-    sscanf( oneline, "%s %s %s %s", bufa, buf, buf1, buf2 );
+    sscanf( oneline, "%s %s %s %s %s %s %s", buf_docid, buf_xmin, buf_xmax, buf_ymin, buf_ymax, buf_url);
 
     /**** cout<<" docid -> " << bufa
       <<"\n cnt -> " << cnt
@@ -221,12 +237,14 @@
       <<"\n p -> " << buf2
       <<endl; *******/
 
-    gridx[2] [cnt] = atof( buf );
-    gridy[2] [cnt] = atof( buf1 );
-    gridz[2] [cnt] = atof( buf2 );
-    //char const * sLine = buf2;
-    urlvec.push_back(buf2);
-    docidvec.push_back(bufa);
+    min_pntx[2] [cnt] = atof(buf_xmin);
+    max_pntx[2] [cnt] = atof(buf_xmax);
+    min_pnty[2] [cnt] = atof(buf_ymin);
+    max_pnty[2] [cnt] = atof(buf_ymax);
+
+    urlvec.push_back(buf_url);
+    docidvec.push_back(buf_docid);
+
     cnt++;
     number_lines = cnt;
   }
@@ -233,8 +251,16 @@
   fclose( infile );
 
   cout<<"creating a new shape file, with "<< number_lines <<" records "<<endl;
-  WritePointsArray( SHPT_POINT, out_shape, gridx, gridy, gridz,
-                    urlvec, docidvec, number_lines );
+  WritePointsArray( SHPT_POINT,
+                    out_shape,
+                    min_pntx,
+                    max_pntx,
+                    min_pnty,
+                    max_pnty,
+                    pointz,
+                    urlvec,
+                    docidvec,
+                    number_lines );
 
 #ifdef USE_DBMALLOC
   malloc_dump( 2 );
Index: bin/metacat_shapefile
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: build.xml
===================================================================
--- build.xml	(revision 2638)
+++ build.xml	(revision 2639)
@@ -1308,7 +1308,7 @@
      </java>
   </target>
   
-  <target name="spatial_option" depends="init" description=" -- compiles code for the spatial option">
+  <target name="spatial_option" depends="prepare" description=" -- compiles code for the spatial option">
 
     <echo message="Compiling the metatcat shapefile creator"/>
     <echo message="using the shapelib at: ${shapelib.dir}"/>
@@ -1317,7 +1317,7 @@
     </exec>
   
     <exec dir="." executable="g++" os="Linux, Unix" failonerror="true">
-     <arg line="build/metacat_shapefile.o ${shapelib.dir}/libshp.a -o bin/test.out" />
+     <arg line="build/metacat_shapefile.o ${shapelib.dir}/.libs/libshp.a -o bin/metacat_shapefile" />
     </exec>
   </target>
 
