Ignore:
Timestamp:
Aug 7, 2007, 10:20:18 AM (17 years ago)
Author:
duncan
Message:

remove the .xya file format.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/geospatial_data/test_geospatial_data.py

    r4641 r4659  
    1313from anuga.coordinate_transforms.redfearn import degminsec2decimal_degrees
    1414from anuga.utilities.anuga_exceptions import ANUGAError
    15 # Ignore these warnings, since we still want to test .xya code.
    16 import warnings
    17 warnings.filterwarnings(action = 'ignore',
    18                         message='.xya format is deprecated.  Please use .txt.',
    19                         category=DeprecationWarning)
    20 
    21 warnings.filterwarnings(action = 'ignore',
    22                         message='The text file values must be ab',
    23                         category=DeprecationWarning)
    24 
    25 warnings.filterwarnings(action = 'ignore',
    26                         message='Text file format is moving to comma se',
    27                         category=DeprecationWarning)
    28 
    29 warnings.filterwarnings(action = 'ignore',
    30                         message='Specifying delimiters will be removed.',
    31                         category=DeprecationWarning)
    3215
    3316class Test_Geospatial_data(unittest.TestCase):
    3417    def setUp(self):
    35         import warnings
    36         warnings.filterwarnings(action = 'ignore',
    37                                 message='.xya format is deprecated.  Please use .txt.',
    38                                 category=DeprecationWarning)
    39        
    40         warnings.filterwarnings(action = 'ignore',
    41                                 message='The text file values must be ab',
    42                                 category=DeprecationWarning)
    43    
    44         warnings.filterwarnings(action = 'ignore',
    45                                 message='Text file format is moving to comma se',
    46                                 category=DeprecationWarning)
    47    
    48         warnings.filterwarnings(action = 'ignore',
    49                                 message='Specifying delimiters will be removed.',
    50                                 category=DeprecationWarning)
     18        pass
    5119
    5220    def tearDown(self):
     
    772740
    773741       
    774     def test_create_from_xya_file(self):
    775         """Check that object can be created from a points file (.pts and .xya)
    776         """
    777 
    778         points = [[1.0, 2.1], [3.0, 5.3], [5.0, 6.1], [6.0, 3.3]]
    779         attributes = [2, 4, 5, 76]
    780         '''
    781         # Use old pointsdict format
    782         pointsdict = {'pointlist': points,
    783                       'attributelist': {'att1': attributes,
    784                                         'att2': array(attributes) + 1}}
    785         '''
    786         att_dict = {'att1': attributes,
    787                     'att2': array(attributes) +1}
    788                    
    789         # Create points as an xya file
    790         FN = 'test_points.xya'
    791         G1 = Geospatial_data(points, att_dict)
    792         G1.export_points_file(FN)
    793 #        G1.export_points_file(ofile)
    794 
    795         #Create object from file
    796         G = Geospatial_data(file_name = FN)
    797        
    798         assert allclose(G.get_data_points(), points)
    799         assert allclose(G.get_attributes('att1'), attributes)
    800         assert allclose(G.get_attributes('att2'), array(attributes) + 1)
    801        
    802         os.remove(FN)
    803 
    804     def test_create_from_xya_file1(self):
    805         """
    806         Check that object can be created from an Absolute xya file
    807         """
    808 
    809         points = [[1.0, 2.1], [3.0, 5.3], [5.0, 6.1], [6.0, 3.3]]
    810         attributes = [2, 4, 5, 76]
    811 
    812         att_dict = {'att1': attributes,
    813                     'att2': array(attributes) +1}
    814 
    815         geo_ref = Geo_reference(56, 10, 5)
    816                    
    817         # Create points as an xya file
    818         FN = 'test_points.xya'
    819         G1 = Geospatial_data(points, att_dict, geo_ref)
    820 
    821         G1.export_points_file(FN, absolute=True)
    822 
    823         #Create object from file
    824         G = Geospatial_data(file_name = FN)
    825        
    826         assert allclose(G.get_data_points(absolute=True),
    827                         G1.get_data_points(absolute=True))
    828         assert allclose(G.get_attributes('att1'), attributes)
    829         assert allclose(G.get_attributes('att2'), array(attributes) + 1)
    830        
    831         os.remove(FN)
    832    
    833742    def test_load_csv(self):
    834743       
     
    844753        file.close()
    845754        #print fileName
    846         results = Geospatial_data(fileName, delimiter=',')
     755        results = Geospatial_data(fileName)
    847756        os.remove(fileName)
    848757#        print 'data', results.get_data_points()
     
    853762        assert allclose(results.get_attributes(attribute_name='speed'),
    854763                        [0.0, 10.0, 40.0])
    855 
    856        
    857     def test_load_xya(self):
    858         """ test_load_xya(self):
    859         comma delimited
    860         """
    861         fileName = tempfile.mktemp(".xya")
    862         file = open(fileName,"w")
    863         file.write("elevation  , speed \n\
    864 1.0, 0.0, 10.0, 0.0\n\
    865 0.0, 1.0, 0.0, 10.0\n\
    866 1.0, 0.0, 10.4, 40.0\n")
    867         file.close()
    868         results = Geospatial_data(fileName, delimiter=',')
    869         os.remove(fileName)
    870 #        print 'data', results.get_data_points()
    871         assert allclose(results.get_data_points(), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    872         assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
    873         assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
    874 
    875     def test_loadxya2(self):
    876         """ test_loadxya2(self):
    877         space delimited
    878         """
    879         import os
    880        
    881         fileName = tempfile.mktemp(".xya")
    882         file = open(fileName,"w")
    883         file.write("  elevation   speed \n\
    884 1.0 0.0 10.0 0.0\n\
    885 0.0 1.0 0.0 10.0\n\
    886 1.0 0.0 10.4 40.0\n")
    887         file.close()
    888 
    889         results = Geospatial_data(fileName, delimiter=' ')
    890 
    891         os.remove(fileName)
    892 
    893         assert allclose(results.get_data_points(), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    894         assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
    895         assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
    896      
    897     def test_loadxya3(self):
    898         """
    899         test_loadxya3(self):
    900         space delimited
    901         """
    902         import os
    903        
    904         fileName = tempfile.mktemp(".xya")
    905         file = open(fileName,"w")
    906         file.write("  elevation   speed \n\
    907 1.0 0.0 10.0 0.0\n\
    908 0.0 1.0 0.0 10.0\n\
    909 1.0 0.0 10.4 40.0\n\
    910 #geocrap\n\
    911 56\n\
    912 56.6\n\
    913 3\n")
    914         file.close()
    915 
    916         results = Geospatial_data(fileName, delimiter=' ')
    917 
    918         os.remove(fileName)
    919         assert allclose(results.get_data_points(absolute=False), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    920         assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
    921         assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
    922 
    923     def BADtest_loadxya4(self):
    924         """
    925         comma delimited
    926         """
    927         fileName = tempfile.mktemp(".xya")
    928         file = open(fileName,"w")
    929         file.write("elevation  , speed \n\
    930 1.0, 0.0, splat, 0.0\n\
    931 0.0, 1.0, 0.0, 10.0\n\
    932 1.0, 0.0, 10.4, 40.0\n")
    933         file.close()
    934         results = Geospatial_data(fileName, delimiter=',')
    935         os.remove(fileName)
    936 #        print 'data', results.get_data_points()
    937         assert allclose(results.get_data_points(), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    938         assert allclose(results.get_attributes(attribute_name='elevation'), ["splat", 0.0, 10.4])
    939         assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
    940        
    941     def test_read_write_points_file_bad2(self):
    942         att_dict = {}
    943         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    944         att_dict['elevation'] = array([10.0, 0.0, 10.4])
    945         att_dict['brightness'] = array([10.0, 0.0, 10.4])
    946         geo_reference=Geo_reference(56,1.9,1.9)
    947        
    948         G = Geospatial_data(pointlist, att_dict, geo_reference)
    949        
    950         try:
    951             G.export_points_file("_???/yeah.xya")
    952            
    953         except IOError:
    954             pass
    955         else:
    956             msg = 'bad points file extension did not raise error!'
    957             raise msg
    958 #            self.failUnless(0 == 1,
    959 #                        'bad points file extension did not raise error!')
    960                    
    961     def test_loadxy_bad(self):
    962         import os
    963        
    964         fileName = tempfile.mktemp(".xya")
    965         file = open(fileName,"w")
    966         file.write("  elevation   \n\
    967 1.0 0.0 10.0 0.0\n\
    968 0.0 1.0 0.0 10.0\n\
    969 1.0 0.0 10.4 40.0\n")
    970         file.close()
    971         #print fileName
    972         try:
    973             results = Geospatial_data(fileName, delimiter=' ')
    974         except IOError:
    975             pass
    976         else:
    977             msg = 'bad xya file did not raise error!'
    978             raise msg
    979 #            self.failUnless(0 == 1,
    980 #                        'bad xya file did not raise error!')
    981         os.remove(fileName)
    982        
    983     def test_loadxy_bad2(self):
    984         import os
    985        
    986         fileName = tempfile.mktemp(".xya")
    987         file = open(fileName,"w")
    988         file.write("elevation\n\
    989 1.0 0.0 10.0 \n\
    990 0.0 1.0\n\
    991 1.0 \n")
    992         file.close()
    993         #print fileName
    994         try:
    995             results = Geospatial_data(fileName, delimiter=' ')
    996         except IOError:
    997             pass
    998         else:
    999             msg = 'bad xya file did not raise error!'
    1000             raise msg
    1001         os.remove(fileName)
    1002    
    1003     def test_loadxy_bad3(self):
    1004         """ test_loadxy_bad3(self):
    1005         specifying wrong delimiter
    1006         """
    1007         import os
    1008        
    1009         fileName = tempfile.mktemp(".xya")
    1010         file = open(fileName,"w")
    1011         file.write("  elevation  , speed \n\
    1012 1.0, 0.0, 10.0, 0.0\n\
    1013 0.0, 1.0, 0.0, 10.0\n\
    1014 1.0, 0.0, 10.4, 40.0\n")
    1015         file.close()
    1016         try:
    1017             results = Geospatial_data(fileName, delimiter=' ')
    1018         except IOError:
    1019             pass
    1020         else:
    1021             msg = 'bad xya file did not raise error!'
    1022             raise msg
    1023         os.remove(fileName)
    1024      
    1025     def test_loadxy_bad4(self):
    1026         """ test_loadxy_bad4(self):
    1027          specifying wrong delimiter
    1028         """
    1029         import os
    1030         fileName = tempfile.mktemp(".xya")
    1031         file = open(fileName,"w")
    1032         file.write("  elevation   speed \n\
    1033 1.0 0.0 10.0 0.0\n\
    1034 0.0 1.0 0.0 10.0\n\
    1035 1.0 0.0 10.4 40.0\n\
    1036 #geocrap\n\
    1037 56\n\
    1038 56.6\n\
    1039 3\n"
    1040 )
    1041         file.close()
    1042         try:
    1043             results = Geospatial_data(fileName, delimiter=',')
    1044         except IOError:
    1045             pass
    1046         else:
    1047             msg = 'bad xya file did not raise error!'
    1048             raise msg
    1049 
    1050         os.remove(fileName)
    1051 
    1052     def test_loadxy_bad5(self):
    1053         """ test_loadxy_bad5(self):
    1054         specifying wrong delimiter
    1055         """
    1056         import os
    1057        
    1058         fileName = tempfile.mktemp(".xya")
    1059         file = open(fileName,"w")
    1060         file.write("  elevation   speed \n\
    1061 1.0 0.0 10.0 0.0\n\
    1062 0.0 1.0 0.0 10.0\n\
    1063 1.0 0.0 10.4 40.0\n\
    1064 #geocrap\n\
    1065 crap")
    1066         file.close()
    1067         try:
    1068 #            dict = import_points_file(fileName,delimiter=' ')
    1069 #            results = Geospatial_data()
    1070             results = Geospatial_data(fileName, delimiter=' ', verbose=False)
    1071 #            results.import_points_file(fileName, delimiter=' ')
    1072         except IOError:
    1073             pass
    1074         else:
    1075             msg = 'bad xya file did not raise error!'
    1076             raise msg
    1077 
    1078 #            self.failUnless(0 ==1,
    1079 #                        'bad xya file did not raise error!')   
    1080         os.remove(fileName)             
    1081 
    1082     def test_loadxy_bad_no_file_xya(self):
    1083         import os
    1084        
    1085         fileName = tempfile.mktemp(".xya")
    1086         try:
    1087             results = Geospatial_data(fileName, delimiter=' ')
    1088         except IOError:
    1089             pass
    1090         else:
    1091             msg = 'imaginary file did not raise error!'
    1092             raise msg
    1093 
    1094 #        except IOError:
    1095 #            pass
    1096 #        else:
    1097 #            self.failUnless(0 == 1,
    1098 #                        'imaginary file did not raise error!')
    1099764
    1100765
     
    14041069       
    14051070       
    1406     def test_export_xya_file(self):
    1407         # depreciated since it's testing using geo refs in a text file
    1408 #        dict = {}
    1409         att_dict = {}
    1410         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1411         att_dict['elevation'] = array([10.0, 0.0, 10.4])
    1412         att_dict['brightness'] = array([10.0, 0.0, 10.4])
    1413 #        dict['attributelist'] = att_dict
    1414         geo_reference=Geo_reference(56,1.9,1.9)
    1415        
    1416        
    1417         fileName = tempfile.mktemp(".xya")
    1418         G = Geospatial_data(pointlist, att_dict, geo_reference)
    1419         G.export_points_file(fileName, False)
    1420 
    1421 #        dict2 = import_points_file(fileName)
    1422         results = Geospatial_data(file_name = fileName)
    1423         #print "fileName",fileName
    1424         os.remove(fileName)
    1425        
    1426         assert allclose(results.get_data_points(absolute=False),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1427         assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
    1428         answer = [10.0, 0.0, 10.4]
    1429         assert allclose(results.get_attributes(attribute_name='brightness'), answer)
    1430         #print "dict2['geo_reference']",dict2['geo_reference']
    1431         self.failUnless(results.get_geo_reference() == geo_reference,
    1432                          'test_writepts failed. Test geo_reference')
    1433 
    1434     def test_export_xya_file2(self):
    1435         """ test_export_xya_file2(self):
    1436         test absolute xya file
    1437         """
    1438         att_dict = {}
    1439         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1440         att_dict['elevation'] = array([10.0, 0.0, 10.4])
    1441         att_dict['brightness'] = array([10.0, 0.0, 10.4])
    1442        
    1443         fileName = tempfile.mktemp(".xya")
    1444         G = Geospatial_data(pointlist, att_dict)
    1445         G.export_points_file(fileName)
    1446         results = Geospatial_data(file_name = fileName)
    1447 #        dict2 = import_points_file(fileName)
    1448         os.remove(fileName)
    1449        
    1450         assert allclose(results.get_data_points(False),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1451         assert allclose(results.get_attributes('elevation'), [10.0, 0.0, 10.4])
    1452         answer = [10.0, 0.0, 10.4]
    1453         assert allclose(results.get_attributes('brightness'), answer)
    1454 
    1455     def test_export_xya_file3(self):
    1456         """ test_export_xya_file3(self):
    1457         test absolute xya file with geo_ref
    1458         """
    1459         att_dict = {}
    1460         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1461         att_dict['elevation'] = array([10.0, 0.0, 10.4])
    1462         att_dict['brightness'] = array([10.0, 0.0, 10.4])
    1463         geo_reference=Geo_reference(56,1.9,1.9)
    1464        
    1465        
    1466         fileName = tempfile.mktemp(".xya")
    1467         G = Geospatial_data(pointlist, att_dict, geo_reference)
    1468        
    1469         G.export_points_file(fileName, absolute=True)
    1470        
    1471         results = Geospatial_data(file_name = fileName)
    1472         os.remove(fileName)
    1473 
    1474         assert allclose(results.get_data_points(),
    1475                         [[2.9, 1.9],[1.9, 2.9],[2.9, 1.9]])
    1476         assert allclose(results.get_attributes(attribute_name='elevation'),
    1477                          [10.0, 0.0, 10.4])
    1478         answer = [10.0, 0.0, 10.4]
    1479         assert allclose(results.get_attributes(attribute_name='brightness'), answer)
    1480         self.failUnless(results.get_geo_reference() == geo_reference,
    1481                          'test_writepts failed. Test geo_reference')                         
    1482                        
    1483                        
    1484                        
     1071
    14851072    def test_new_export_pts_file(self):
    14861073        att_dict = {}
     
    15851172                         'test_writepts failed. Test geo_reference')
    15861173
    1587     def test_write_xya_attributes(self):
    1588         #test_write xya: Test that storage of x,y,attributes works
     1174    def test_write_csv_attributes(self):
     1175        #test_write : Test that storage of x,y,attributes works
    15891176       
    15901177        att_dict = {}
     
    15931180        att_dict['brightness'] = array([10.0, 0.0, 10.4])
    15941181        geo_reference=Geo_reference(56,0,0)
    1595         # Test xya format
    1596         fileName = tempfile.mktemp(".xya")
    1597         G = Geospatial_data(pointlist, att_dict, geo_reference)
    1598         G.export_points_file(fileName)
    1599         results = Geospatial_data(file_name=fileName)
    1600         os.remove(fileName)
    1601         assert allclose(results.get_data_points(False),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1602         assert allclose(results.get_attributes('elevation'), [10.0, 0.0, 10.4])
    1603         answer = [10.0, 0.0, 10.4]
    1604         assert allclose(results.get_attributes('brightness'), answer)
    1605         self.failUnless(geo_reference == geo_reference,
    1606                          'test_writepts failed. Test geo_reference')
    1607 
    1608     def test_write_csv_attributes(self):
    1609         #test_write : Test that storage of x,y,attributes works
    1610        
    1611         att_dict = {}
    1612         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1613         att_dict['elevation'] = array([10.0, 0.0, 10.4])
    1614         att_dict['brightness'] = array([10.0, 0.0, 10.4])
    1615         geo_reference=Geo_reference(56,0,0)
    1616         # Test xya format
     1182        # Test txt format
    16171183        fileName = tempfile.mktemp(".txt")
    16181184        G = Geospatial_data(pointlist, att_dict, geo_reference)
     
    16661232                         'test_writepts failed. Test geo_reference')
    16671233       
    1668     def test_write_xya_no_attributes(self):
    1669         #test_write xya _no_attributes: Test that storage of x,y alone works
     1234       
     1235    def test_write_csv_no_attributes(self):
     1236        #test_write txt _no_attributes: Test that storage of x,y alone works
    16701237       
    16711238        att_dict = {}
    16721239        pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    16731240        geo_reference=Geo_reference(56,0,0)
    1674         # Test xya format
    1675         fileName = tempfile.mktemp(".xya")
    1676         G = Geospatial_data(pointlist, None, geo_reference)
    1677         G.export_points_file(fileName)
    1678         results = Geospatial_data(file_name=fileName)
    1679         os.remove(fileName)
    1680         assert allclose(results.get_data_points(False),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1681         self.failUnless(geo_reference == geo_reference,
    1682                          'test_writepts failed. Test geo_reference')
    1683 
    1684        
    1685     def test_write_csv_no_attributes(self):
    1686         #test_write xya _no_attributes: Test that storage of x,y alone works
    1687        
    1688         att_dict = {}
    1689         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1690         geo_reference=Geo_reference(56,0,0)
    1691         # Test xya format
     1241        # Test format
    16921242        fileName = tempfile.mktemp(".txt")
    16931243        G = Geospatial_data(pointlist, None, geo_reference)
     
    18121362    def test_add_(self):
    18131363        '''test_add_(self):
    1814         adds an xya and pts files, reads the files and adds them
     1364        adds an txt and pts files, reads the files and adds them
    18151365           checking results are correct
    18161366        '''
     
    18311381        G2 = Geospatial_data(pointlist2, att_dict2, geo_reference2)
    18321382       
    1833         fileName1 = tempfile.mktemp(".xya")
     1383        fileName1 = tempfile.mktemp(".txt")
    18341384        fileName2 = tempfile.mktemp(".pts")
    18351385
     
    19251475        assert allclose(new_points, ab_points)
    19261476
    1927        
    1928         fileName = tempfile.mktemp(".xya")
    1929         file = open(fileName,"w")
    1930         file.write("  elevation   speed \n\
    1931 1.0 0.0 10.0 0.0\n\
    1932 0.0 1.0 0.0 10.0\n\
    1933 1.0 0.0 10.4 40.0\n\
    1934 #geocrap\n\
    1935 56\n\
    1936 10\n\
    1937 20\n")
    1938         file.close()
    1939        
    1940         ab_points = ensure_absolute(fileName)
    1941         actual =  [[11, 20.0],[10.0, 21.0],[11.0, 20.0]]
    1942         assert allclose(ab_points, actual)
    1943         os.remove(fileName)
    19441477
    19451478       
     
    20101543        import os
    20111544       
    2012         fileName = tempfile.mktemp(".xya")
     1545        fileName = tempfile.mktemp(".csv")
    20131546        file = open(fileName,"w")
    2014         file.write("  elevation   speed \n\
    2015 1.0 0.0 10.0 0.0\n\
    2016 0.0 1.0 0.0 10.0\n\
    2017 1.0 0.0 10.4 40.0\n\
    2018 #geocrap\n\
    2019 56\n\
    2020 56.6\n\
    2021 3\n")
     1547        file.write("x,y,  elevation ,  speed \n\
     15481.0, 0.0, 10.0, 0.0\n\
     15490.0, 1.0, 0.0, 10.0\n\
     15501.0, 0.0, 10.4, 40.0\n")
    20221551        file.close()
    20231552
    20241553        results = Geospatial_data(fileName)
    2025         assert allclose(results.get_data_points(absolute=False), \
     1554        assert allclose(results.get_data_points(absolute=True), \
    20261555                        [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    20271556        assert allclose(results.get_attributes(attribute_name='elevation'), \
     
    20321561        os.remove(fileName)
    20331562       
    2034     def test_delimiter(self):
    2035        
    2036         try:
    2037             G = Geospatial_data(delimiter=',')
    2038 #            results = Geospatial_data(file_name = fileName)
    2039 #            dict = import_points_file(fileName)
    2040         except ValueError:
    2041             pass
    2042         else:
    2043             msg = 'Instance with No fileName but has a delimiter\
    2044                   did not raise error!'
    2045             raise msg
    20461563
    20471564    def test_no_constructors(self):
     
    20571574            raise msg       
    20581575
    2059     def test_check_geo_reference(self):
    2060         """
    2061         checks geo reference details are OK. eg can be called '#geo reference'
    2062         if not throws a clear error message
    2063         """
    2064         import os
    2065         fileName = tempfile.mktemp(".xya")
    2066         file = open(fileName,"w")
    2067         file.write("  elevation  \n\
    2068 1.0 0.0 10.0\n\
    2069 0.0 1.0 0.0\n\
    2070 1.0 0.0 10.4\n\
    2071 #ge oreference\n\
    2072 56\n\
    2073 1.1\n\
    2074 1.0\n")
    2075 
    2076         file.close()
    2077         results = Geospatial_data(fileName)
    2078         assert allclose(results.get_geo_reference().get_xllcorner(), 1.1)
    2079         assert allclose(results.get_geo_reference().get_yllcorner(), 1.0)
    2080 
    2081         os.remove(fileName)
    2082        
    2083         fileName = tempfile.mktemp(".xya")
    2084         file = open(fileName,"w")
    2085         file.write("  elevation  \n\
    2086 1.0 0.0 10.0\n\
    2087 0.0 1.0 0.0\n\
    2088 1.0 0.0 10.4\n")
    2089 
    2090         file.close()
    2091         results = Geospatial_data(fileName)
    2092        
    2093         os.remove(fileName)
    2094        
    2095     def test_check_geo_reference1(self):
    2096         """
    2097         checks geo reference details are OK. eg can be called '#geo reference'
    2098         if not throws a clear error message
    2099         """
    2100         import os
    2101         fileName = tempfile.mktemp(".xya")
    2102         file = open(fileName,"w")
    2103         file.write("  elevation  \n\
    2104 1.0 0.0 10.0\n\
    2105 0.0 1.0 0.0\n\
    2106 1.0 0.0 10.4\n\
    2107 #geo t t\n\
    2108 56\n\
    2109 1.1\n"
    2110 )
    2111         file.close()
    2112 
    2113         try:
    2114             results = Geospatial_data(fileName, delimiter = " ")
    2115         except IOError:
    2116             pass
    2117         else:
    2118             msg = 'Geo reference data format is incorrect'
    2119             raise msg       
    2120 
    2121 
    2122         os.remove(fileName)
    2123 
    2124 
    21251576    def test_load_csv_lat_long(self):
    21261577        """
     
    21341585150.0,-34,459.126000, 10\n")
    21351586        file.close()
    2136         results = Geospatial_data(fileName, delimiter=',')
     1587        results = Geospatial_data(fileName)
    21371588        os.remove(fileName)
    21381589        points = results.get_data_points()
     
    21551606-34,150.0,459.126000\n")
    21561607        file.close()
    2157         results = Geospatial_data(fileName, delimiter=',')
     1608        results = Geospatial_data(fileName)
    21581609        os.remove(fileName)
    21591610        points = results.get_data_points()
     
    21771628        file.close()
    21781629        try:
    2179             results = Geospatial_data(fileName, delimiter=',')
     1630            results = Geospatial_data(fileName)
    21801631        except ANUGAError:
    21811632            pass
Note: See TracChangeset for help on using the changeset viewer.