Index: /anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
===================================================================
--- /anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py	(revision 4252)
+++ /anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py	(revision 4253)
@@ -738,37 +738,15 @@
         coordinates = self.domain.get_nodes(absolute=True)
         triangles = self.domain.triangles      #FIXME
-
-
-        # Use caching at this level until loading has been fixed.
-        if use_cache is True:
-            from anuga.caching import cache 
-            vertex_attributes = cache(fit_to_mesh,
-                                      (coordinates, triangles, filename),
-                                      {'alpha': alpha,
-                                       'attribute_name': attribute_name,
-                                       'use_cache': False,
-                                       'verbose': verbose,
-                                       'max_read_lines':max_read_lines},
-                                      verbose=verbose)
-        else:
-            vertex_attributes = fit_to_mesh(coordinates, triangles,filename,
-                                            alpha=alpha,
-                                            attribute_name=attribute_name,
-                                            use_cache=use_cache,
-                                            verbose=verbose,
-                                             max_read_lines=max_read_lines)
-            
-                                
+       
+        vertex_attributes = fit_to_mesh(coordinates, triangles,filename,
+                                        alpha=alpha,
+                                        attribute_name=attribute_name,
+                                        use_cache=use_cache,
+                                        verbose=verbose,
+                                        max_read_lines=max_read_lines)
+                                            
         #Call underlying method using array values
         self.set_values_from_array(vertex_attributes,
                                    location, indices, verbose)
-
-        #geospatial_data = Geospatial_data(filename)
-        
-        #self.set_values_from_geospatial_data(geospatial_data,
-        #                                     alpha,
-         #                                    location, indices,
-          #                                   verbose = verbose,
-           #                                  use_cache = use_cache)
 
    
Index: /anuga_core/source/anuga/fit_interpolate/fit.py
===================================================================
--- /anuga_core/source/anuga/fit_interpolate/fit.py	(revision 4252)
+++ /anuga_core/source/anuga/fit_interpolate/fit.py	(revision 4253)
@@ -433,4 +433,35 @@
                 attribute_name=None,
                 use_cache = False):
+    args = (vertex_coordinates, triangles, point_coordinates, )
+    kwargs = {'point_attributes': point_attributes,
+              'alpha': alpha,
+              'verbose': verbose,
+              'acceptable_overshoot': acceptable_overshoot,
+              'mesh_origin': mesh_origin,
+              'data_origin': data_origin,
+              'max_read_lines': max_read_lines,
+              'attribute_name': attribute_name
+              }
+    if use_cache is True:
+        return cache(_fit_to_mesh,
+                     args, kwargs,
+                     verbose=verbose,
+                     compression=False)
+    else:
+        return apply(_fit_to_mesh,
+                     args, kwargs)
+
+def _fit_to_mesh(vertex_coordinates,
+                triangles,
+                point_coordinates, # this can also be a .csv/.txt file name
+                point_attributes=None,
+                alpha=DEFAULT_ALPHA,
+                verbose=False,
+                acceptable_overshoot=1.01,
+                mesh_origin=None,
+                data_origin=None,
+                max_read_lines=None,
+                attribute_name=None,
+                use_cache = False):
     """
     Fit a smooth surface to a triangulation,
Index: /anuga_core/source/anuga/fit_interpolate/test_fit.py
===================================================================
--- /anuga_core/source/anuga/fit_interpolate/test_fit.py	(revision 4252)
+++ /anuga_core/source/anuga/fit_interpolate/test_fit.py	(revision 4253)
@@ -279,4 +279,45 @@
         os.remove(txt_file)
         
+    def cache_test_fit_to_mesh_pts(self):
+        a = [-1.0, 0.0]
+        b = [3.0, 4.0]
+        c = [4.0,1.0]
+        d = [-3.0, 2.0] #3
+        e = [-1.0,-2.0]
+        f = [1.0, -2.0] #5
+
+        vertices = [a, b, c, d,e,f]
+        triangles = [[0,1,3], [1,0,2], [0,4,5], [0,5,2]] #abd bac aef afc
+
+
+        fileName = tempfile.mktemp(".txt")
+        file = open(fileName,"w")
+        file.write(" x, y, elevation \n\
+-2.0, 2.0, 0.\n\
+-1.0, 1.0, 0.\n\
+0.0, 2.0 , 2.\n\
+1.0, 1.0 , 2.\n\
+ 2.0,  1.0 ,3. \n\
+ 0.0,  0.0 , 0.\n\
+ 1.0,  0.0 , 1.\n\
+ 0.0,  -1.0, -1.\n\
+ -0.2, -0.5, -0.7\n\
+ -0.9, -1.5, -2.4\n\
+ 0.5,  -1.9, -1.4\n\
+ 3.0,  1.0 , 4.\n")
+        file.close()
+        geo = Geospatial_data(fileName)
+        fileName_pts = tempfile.mktemp(".pts")
+        points = geo.get_data_points(absolute=True)
+        atts = geo.get_attributes()
+        f = fit_to_mesh(vertices, triangles,points,atts,
+                                alpha=0.0, max_read_lines=2,
+                        use_cache=True, verbose=True)
+        answer = linear_function(vertices)
+        #print "f\n",f
+        #print "answer\n",answer
+        assert allclose(f, answer)
+        os.remove(fileName)
+       
     def test_fit_to_mesh_pts(self):
         a = [-1.0, 0.0]
@@ -311,6 +352,5 @@
         geo.export_points_file(fileName_pts)
         f = fit_to_mesh(vertices, triangles,fileName_pts,
-                                alpha=0.0, max_read_lines=2) #,
-                        #use_cache=True, verbose=True)
+                                alpha=0.0, max_read_lines=2)
         answer = linear_function(vertices)
         #print "f\n",f
@@ -319,5 +359,5 @@
         os.remove(fileName)
         os.remove(fileName_pts)
-       
+        
     def test_fit_to_mesh(self):
 
@@ -729,6 +769,6 @@
 if __name__ == "__main__":
     suite = unittest.makeSuite(Test_Fit,'test')
-    #suite = unittest.makeSuite(Test_Fit,'test_fit_to_mesh_UTM_file')
-    #suite = unittest.makeSuite(Test_Fit,'test_smooth_attributes_to_mesh_one_point')
+    #suite = unittest.makeSuite(Test_Fit,'cache_test_fit_to_mesh_pts')
+    #suite = unittest.makeSuite(Test_Fit,'')
     runner = unittest.TextTestRunner(verbosity=1)
     runner.run(suite)
Index: /anuga_validation/automated_validation_tests/okushiri_tank_validation/loading_pts_test.py
===================================================================
--- /anuga_validation/automated_validation_tests/okushiri_tank_validation/loading_pts_test.py	(revision 4252)
+++ /anuga_validation/automated_validation_tests/okushiri_tank_validation/loading_pts_test.py	(revision 4253)
@@ -50,5 +50,5 @@
 bathymetry_filename='Benchmark_2_Bathymetry_very_thin.pts'
 print 'Starting domain.set_quantity.  Loading ', bathymetry_filename
-s = "domain.set_quantity('elevation',filename=bathymetry_filename,alpha=0.02,verbose=True,use_cache=False)"
+s = "domain.set_quantity('elevation',filename=bathymetry_filename,alpha=0.02,verbose=True,use_cache=True)"
 
 
@@ -62,5 +62,5 @@
 S = pstats.Stats(FN)
 #S.sort_stats('time').print_stats(20)
-s = S.sort_stats('cumulative').print_stats(30)
+s = S.sort_stats('cumulative').print_stats(60)
 
-print s
+#print s
