Index: /Swollen/doc/contract2_hours.txt
===================================================================
--- /Swollen/doc/contract2_hours.txt	(revision 61)
+++ /Swollen/doc/contract2_hours.txt	(revision 62)
@@ -4,7 +4,20 @@
 
 
+
+15 December, Tuesday (4 hours)
+- added -texture <filename> option for bedslope image
+- other code cleanups related to handling georeferenced data
+- small amount of work on background thread for data read
+
 14 December, Monday (6 hours)
 - visit to GA, swollen now compiling on-site under Windows/Visual Studio .NET
 - added command line params for tweaking transparency (see "swollen -help")
+- added -nosky option to omit surrounding sky map
+
+
+
+total = 113 hours (3.0 weeks)
+subtotal = 8 hours
+
 
 12 December, Saturday (4 hours)
@@ -17,4 +30,5 @@
 7 December, Wednesday (4 hours)
 - new distro released
+
 
 
@@ -36,4 +50,5 @@
 - searching for "popping" triangles in cairns sww file
 - gdal installation and recompilation (support for georef tiff)
+
 
 
@@ -59,4 +74,5 @@
 
 
+
 total = 79 hours (2 weeks)
 subtotal = 33 hours
@@ -80,4 +96,5 @@
 15 October, Friday (3 hours)
 - memory leaks
+
 
 
Index: /Swollen/doc/contract2_priorities.txt
===================================================================
--- /Swollen/doc/contract2_priorities.txt	(revision 61)
+++ /Swollen/doc/contract2_priorities.txt	(revision 62)
@@ -95,4 +95,5 @@
   "sww file couldn't read" [1]
 - add -version command line flag synced with Subversion revision number (useful for debugging) [?]
+- prune -help documentation removing irrelevant options [?]
 
 
Index: /Swollen/include/swwreader.h
===================================================================
--- /Swollen/include/swwreader.h	(revision 61)
+++ /Swollen/include/swwreader.h	(revision 62)
@@ -68,5 +68,9 @@
     virtual osg::ref_ptr<osg::DrawElementsUShort> getBedslopeIndexArray() {return _bedslopeindices;}
     virtual osg::ref_ptr<osg::Vec3Array> getBedslopeCentroidArray() {return _bedslopecentroids;}
-    virtual osg::ref_ptr<osg::Vec2Array> getBedslopeTextureCoords() {return _bedslopetexcoords;}
+    virtual osg::ref_ptr<osg::Vec2Array> getBedslopeTextureCoords();
+
+    virtual void setBedslopeTexture( std::string filename );
+    virtual osg::Image* getBedslopeTexture();
+
 
     // stage
@@ -90,5 +94,4 @@
     virtual void setHeightMin( float value ) {_heightmin = value;}     
     virtual void setHeightMax( float value ) {_heightmax = value;}        
-
     
     virtual triangle_list getConnectivity(unsigned int index) {return _connectivity.at(index);}
@@ -134,4 +137,7 @@
     osg::ref_ptr<osg::Vec4Array> _stagecolors;
 
+    // optional bedslope texture map
+    std::string* _bedslopetexture;
+
     // bedslope vertex scale and shift factors (for normalizing to unit cube)
     float _xscale, _yscale, _zscale, _scale;
Index: /Swollen/swollen/bedslope.cpp
===================================================================
--- /Swollen/swollen/bedslope.cpp	(revision 61)
+++ /Swollen/swollen/bedslope.cpp	(revision 62)
@@ -5,6 +5,4 @@
 #include <osg/BoundingBox>
 #include <osg/Texture2D>
-#include <osgDB/Registry>
-#include <osgDB/ReadFile>
 #include <osg/TexEnv>
 
@@ -15,5 +13,4 @@
 BedSlope::BedSlope(SWWReader* sww)
 {
-
     // persistent
     _sww = sww;
@@ -41,5 +38,5 @@
     texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
     texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
-    texture->setImage(osgDB::readImageFile("bedslope.jpg"));
+    texture->setImage( _sww->getBedslopeTexture() );
     
     _stateset = new osg::StateSet;
Index: /Swollen/swollen/main.cpp
===================================================================
--- /Swollen/swollen/main.cpp	(revision 61)
+++ /Swollen/swollen/main.cpp	(revision 62)
@@ -39,10 +39,11 @@
     arguments.getApplicationUsage()->addCommandLineOption("-help","Display this information");
     arguments.getApplicationUsage()->addCommandLineOption("-scale <float>","Vertical scale factor");
-    arguments.getApplicationUsage()->addCommandLineOption("-tps <rate>","timesteps per second");
-    arguments.getApplicationUsage()->addCommandLineOption("-hmin <float>","height below which transparency is set to zero");    
+    arguments.getApplicationUsage()->addCommandLineOption("-tps <rate>","Timesteps per second");
+    arguments.getApplicationUsage()->addCommandLineOption("-hmin <float>","Height below which transparency is set to zero");    
     arguments.getApplicationUsage()->addCommandLineOption("-hmax <float>","Height above which transparency is set to alphamax");       
-    arguments.getApplicationUsage()->addCommandLineOption("-alphamin <float>","transparency value at hmin");    
-    arguments.getApplicationUsage()->addCommandLineOption("-alphamax <float>","maximum transparency clamp value");
-    arguments.getApplicationUsage()->addCommandLineOption("-nosky","omit background sky");
+    arguments.getApplicationUsage()->addCommandLineOption("-alphamin <float>","Transparency value at hmin");    
+    arguments.getApplicationUsage()->addCommandLineOption("-alphamax <float>","Maximum transparency clamp value");
+    arguments.getApplicationUsage()->addCommandLineOption("-nosky","Omit background sky");
+    arguments.getApplicationUsage()->addCommandLineOption("-texture <file>","Image to use for bedslope topography");
 
     // construct the viewer.
@@ -89,4 +90,7 @@
     float vscale;
     if( !arguments.read("-scale",vscale) ) vscale = 1.0;
+
+    std::string bedslopetexture;
+    if( arguments.read("-texture",bedslopetexture) ) sww->setBedslopeTexture( bedslopetexture );
 
     float tmpfloat;
Index: /Swollen/swollen/watersurface.cpp
===================================================================
--- /Swollen/swollen/watersurface.cpp	(revision 61)
+++ /Swollen/swollen/watersurface.cpp	(revision 62)
@@ -36,6 +36,5 @@
     _node->setStateSet(_stateset);
 
-    // FIXME: if set to true, wireframe doesn't work - need to dirty to force update?
-    _geom->setUseDisplayList( false );
+    _geom->setUseDisplayList( true );
 
     // initial geometry
Index: /Swollen/swwreader/Makefile
===================================================================
--- /Swollen/swwreader/Makefile	(revision 61)
+++ /Swollen/swwreader/Makefile	(revision 62)
@@ -11,5 +11,6 @@
 OSG_INCLUDE      =  ${OSGHOME}/include
 LOCAL_INCLUDE    =  $(TOPDIR)/include
-INCLUDES         =  -I $(LOCAL_INCLUDE) -I $(NETCDF_INCLUDE) -I $(OSG_INCLUDE)
+GDAL_INCLUDE     =  `gdal-config --cflags`
+INCLUDES         =  -I $(LOCAL_INCLUDE) -I $(NETCDF_INCLUDE) -I $(OSG_INCLUDE) $(GDAL_INCLUDE)
 
 CARBON_LIB       =  -framework Carbon
@@ -17,6 +18,7 @@
 NETCDF_LIBS      =  -lnetcdf
 X_LIBS           =  -lX11
+GDAL_LIBS        =  `gdal-config --libs`
 OTHER_LIBS       =  -lm -lstdc++ -lobjc
-LIBS            +=  -losg -lOpenThreads $(NETCDF_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) $(CARBON_LIB)
+LIBS            +=  -losg -losgDB -lOpenThreads $(NETCDF_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) $(CARBON_LIB) $(GDAL_LIBS)
 LIBDIRS          =  -L/usr/lib -L/usr/X11R6/lib -L/sw/lib -L/usr/local/lib
 
Index: /Swollen/swwreader/swwreader.cpp
===================================================================
--- /Swollen/swwreader/swwreader.cpp	(revision 61)
+++ /Swollen/swwreader/swwreader.cpp	(revision 62)
@@ -3,23 +3,4 @@
 
     Reader of SWW files from within OpenSceneGraph.
-
-    An SWW file is the visualization output of the pyVolution
-    Shallow Water Wave equation solver.  SWW files contain bedslope
-    geometry and a sequence of stages at known timesteps.  The
-    internal format is NetCDF:
-
-    netcdf demo.sww {
-        dimensions:
-            number_of_volumes = <integer> ;
-            number_of_vertices = 3 ;
-            number_of_points = <integer> ;
-            number_of_timesteps = UNLIMITED ;
-        variables:
-            float x(number_of_points) ;
-            float y(number_of_points) ;
-            float z(number_of_points) ;
-            int volumes(number_of_volumes, number_of_vertices) ;
-            float time(number_of_timesteps) ;
-            float stage(number_of_timesteps, number_of_points) ;
 
     copyright (C) 2004 Geoscience Australia
@@ -32,6 +13,10 @@
 #include <osg/Notify>
 
+#include <osgDB/Registry>
+#include <osgDB/ReadFile>
+
 #include <stdlib.h>
 #include <stdio.h>
+#include <gdal_priv.h>
 
 
@@ -148,4 +133,8 @@
 
 
+    // default texture map
+    _bedslopetexture = new std::string("bedslope.jpg");
+
+
     osg::notify(osg::INFO) << "[SWWReader] xmin: " << xmin <<  std::endl;
     osg::notify(osg::INFO) << "[SWWReader] xmax: " << xmax <<  std::endl;
@@ -186,10 +175,4 @@
 
 
-    // bedslope texture coords based on (x,y) locations scaled by extents into range [0,1]
-    _bedslopetexcoords = new osg::Vec2Array;
-    for( iv=0; iv < _npoints; iv++ )
-      _bedslopetexcoords->push_back( osg::Vec2( (_px[iv]-_xoffset)*_xscale, (_py[iv]-_yoffset)*_yscale ) );
-
-
     // calculate bedslope primitive normal and centroid arrays
     _bedslopenormals = new osg::Vec3Array;
@@ -226,4 +209,65 @@
     _status.push_back( nc_close(_ncid) );
     delete[]( _px, _py, _pz, _ptime, _pvolumes, _pstage );
+}
+
+
+
+void SWWReader::setBedslopeTexture( std::string filename )
+{
+    osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] filename: " << filename <<  std::endl;
+   _bedslopetexture = new std::string(filename);
+
+   // attempt to extract geospatial metadata from image file
+   GDALDataset  *poDataset;
+   GDALAllRegister();
+   poDataset = (GDALDataset *) GDALOpen( filename.c_str(), GA_ReadOnly );
+   if( poDataset == NULL )
+      osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] GDAL unable to open file: " << filename <<  std::endl;
+   else
+   {
+      // extract metadata
+      double adfGeoTransform[6];
+
+      printf( "Driver: %s/%s\n",
+	      poDataset->GetDriver()->GetDescription(), 
+	      poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) );
+
+      printf( "Size is %dx%dx%d\n", 
+	      poDataset->GetRasterXSize(), poDataset->GetRasterYSize(),
+	      poDataset->GetRasterCount() );
+
+      if( poDataset->GetProjectionRef()  != NULL )
+	 printf( "Projection is `%s'\n", poDataset->GetProjectionRef() );
+
+      if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None )
+      {
+	 printf( "Origin = (%.6f,%.6f)\n",
+		 adfGeoTransform[0], adfGeoTransform[3] );
+
+	 printf( "Pixel Size = (%.6f,%.6f)\n",
+		 adfGeoTransform[1], adfGeoTransform[5] );
+      }
+   }
+
+}
+
+
+
+osg::Image* SWWReader::getBedslopeTexture()
+{
+   return osgDB::readImageFile( _bedslopetexture->c_str() );
+}
+
+
+
+osg::ref_ptr<osg::Vec2Array> SWWReader::getBedslopeTextureCoords()
+{
+
+   // bedslope texture coords based on (x,y) locations scaled by extents into range [0,1]
+   _bedslopetexcoords = new osg::Vec2Array;
+   for( unsigned int iv=0; iv < _npoints; iv++ )
+      _bedslopetexcoords->push_back( osg::Vec2( (_px[iv]-_xoffset)*_xscale, (_py[iv]-_yoffset)*_yscale ) );
+
+   return _bedslopetexcoords;
 }
 
