class RecordError(StandardError):
pass
+class InvalidAreaError(StandardError):
+ pass
class GeoRecord:
"""
# if the input string cannot be converted o the specified
# type.
self.block_number = int(geo_record.block)
+ self.tract_number = int(geo_record.tract)
self.population = int(geo_record.pop100)
self.area_land = float(geo_record.arealand)
self.area_water = float(geo_record.areawatr)
self.coordinates.latitude = float(geo_record.intptlat)
self.coordinates.longitude = float(geo_record.intptlon)
+ if (self.total_area() == 0):
+ raise InvalidAreaError('A block may not have zero area.')
+
def total_area(self):
return (self.area_land + self.area_water)
block = Block(record)
blocks.append(block)
except ValueError:
+ # A value couldn't be converted to the appropriate type.
+ continue
+ except InvalidAreaError:
+ # Something is funny with the geometry.
continue
return blocks