Ignore:
Timestamp:
May 23, 2006, 10:50:19 AM (19 years ago)
Author:
duncan
Message:

changing errors thrown by geo_ref. adding tests to geospatial

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/coordinate_transforms/geo_reference.py

    r2941 r2942  
    99from Numeric import array, Float, ArrayType, reshape
    1010from utilities.numerical_tools import ensure_numeric
    11 from utilities.anuga_exceptions import ANUGAError
    12 
    13 import exceptions
    14 class TitleError(exceptions.IOError): pass
     11from utilities.anuga_exceptions import ANUGAError, TitleError, ParsingError
     12
     13
     14#import exceptions
     15#class TitleError(exceptions.IOError): pass
     16#class ParsingError(exceptions.IOError): pass
    1517
    1618DEFAULT_ZONE = -1
     
    107109
    108110    def read_ASCII(self, fd,read_title=None):
    109         if read_title == None:
    110             read_title = fd.readline() # remove the title line
    111         #print "gr read_title[0:2].upper()",read_title[0:2].upper()
    112         #print "gr TITLE[0:2].upper()",TITLE[0:2].upper()
    113         if read_title[0:2].upper() != TITLE[0:2].upper():
    114             msg = 'File error.  Expecting line: %s.  Got this line: %s' \
    115                   %(TITLE, read_title)
    116             raise TitleError, msg
    117         self.zone = int(fd.readline())
    118         self.xllcorner = float(fd.readline())
    119         self.yllcorner = float(fd.readline())
     111        try:
     112            if read_title == None:
     113                read_title = fd.readline() # remove the title line
     114            if read_title[0:2].upper() != TITLE[0:2].upper():
     115                msg = 'File error.  Expecting line: %s.  Got this line: %s' \
     116                      %(TITLE, read_title)
     117                raise TitleError, msg
     118            self.zone = int(fd.readline())
     119            self.xllcorner = float(fd.readline())
     120            self.yllcorner = float(fd.readline())
     121        except SyntaxError:
     122                msg = 'File error.  Got syntax error while parsing geo reference'
     123                raise ParsingError, msg
    120124           
    121125        # Fix some assertion failures
Note: See TracChangeset for help on using the changeset viewer.