Index: /inundation/ga/storm_surge/pyvolution/least_squares.py
===================================================================
--- /inundation/ga/storm_surge/pyvolution/least_squares.py	(revision 1096)
+++ /inundation/ga/storm_surge/pyvolution/least_squares.py	(revision 1097)
@@ -115,5 +115,16 @@
         
     point_coordinates = point_dict['pointlist']
-    title_list,point_attributes = concatinate_attributelist(point_dict['attributelist'])  
+    title_list,point_attributes = concatinate_attributelist(point_dict['attributelist'])
+    
+    if point_dict.has_key('geo_reference')and not point_dict['geo_reference'] is None:
+        data_origin = point_dict['geo_reference'].get_origin()
+    else:
+        data_origin = (56, 0, 0) #FIXME(DSG-DSG)
+        
+    if mesh_dict.has_key('geo_reference')and not mesh_dict['geo_reference'] is None:
+        mesh_origin = mesh_dict['geo_reference'].get_origin()
+    else:
+        mesh_origin = (56, 0, 0) #FIXME(DSG-DSG)
+        
     if verbose: print "points file loaded"
     if verbose:print "fitting to mesh"
@@ -146,4 +157,5 @@
 
     #FIXME (Ole): Remember to output mesh_origin as well    
+    if verbose: print "exporting to file ",mesh_output_file
     export_mesh_file(mesh_output_file, mesh_dict)
         
Index: /inundation/ga/storm_surge/pyvolution/test_least_squares.py
===================================================================
--- /inundation/ga/storm_surge/pyvolution/test_least_squares.py	(revision 1096)
+++ /inundation/ga/storm_surge/pyvolution/test_least_squares.py	(revision 1097)
@@ -9,4 +9,6 @@
 from least_squares import *
 from Numeric import allclose, array, transpose
+
+from coordinate_transforms.geo_reference import Geo_reference
 
 def distance(x, y):
@@ -1104,4 +1106,57 @@
         os.remove(mesh_output_file)
 
+    def test_fit_to_mesh_file3(self):
+        from load_mesh.loadASCII import mesh_file_to_mesh_dictionary, \
+             export_mesh_file
+        import tempfile
+        import os
+
+        # create a .tsh file, no user outline
+        mesh_dic = {}
+        mesh_dic['vertices'] = [[0.76, 0.76],
+                                          [0.76, 5.76],
+                                          [5.76, 0.76]]
+        mesh_dic['triangles'] =  [[0, 2, 1]]
+        mesh_dic['segments'] = [[0, 1], [2, 0], [1, 2]]
+        mesh_dic['triangle_tags'] = [['']]
+        mesh_dic['vertex_attributes'] = [[], [], []]
+        mesh_dic['vertiex_attribute_titles'] = []
+        mesh_dic['triangle_neighbors'] = [[-1, -1, -1]]
+        mesh_dic['segment_tags'] = ['external',
+                                                  'external',
+                                                  'external']
+        mesh_dic['geo_reference'] = Geo_reference(56,-0.76,-0.76)
+        mesh_file = tempfile.mktemp(".tsh")
+        export_mesh_file(mesh_file,mesh_dic)
+
+        #FIXME - make this test the georef in the points file as well.
+        # create an .xya file
+        point_file = tempfile.mktemp(".xya")
+        fd = open(point_file,'w')
+        fd.write("elevation, stage \n 1.0, 1.0,2.,4 \n 1.0, 3.0,4,8 \n 3.0,1.0,4.,8 \n")
+        fd.close()
+
+        mesh_output_file = "new_trianlge.tsh"
+        fit_to_mesh_file(mesh_file,
+                         point_file,
+                         mesh_output_file,
+                         alpha = 0.0)
+        # load in the .tsh file we just wrote
+        mesh_dic = mesh_file_to_mesh_dictionary(mesh_output_file)
+        #print "mesh_dic",mesh_dic
+        ans =[[0.0, 0.0],
+              [5.0, 10.0],
+              [5.0,10.0]]
+        assert allclose(mesh_dic['vertex_attributes'],ans)
+
+        self.failUnless(mesh_dic['vertex_attribute_titles']  ==
+                        ['elevation','stage'],
+                        'test_fit_to_mesh_file failed')
+
+        #clean up
+        os.remove(mesh_file)
+        os.remove(point_file)
+        os.remove(mesh_output_file)
+
     def test_fit_to_mesh_fileII(self):
         from load_mesh.loadASCII import mesh_file_to_mesh_dictionary, \
