X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FSummaryFile1.py;h=75868673aacd02b72482e506aaa665774e68466c;hb=d797c850a8493c0027b1e8b8dbc4d3e78840d4d9;hp=d646b07e70df62fd9bc0c7d478626840fe91ab7d;hpb=63f2205c95de0992570d3f83ad07786c0102c3ce;p=dead%2Fcensus-tools.git diff --git a/src/SummaryFile1.py b/src/SummaryFile1.py index d646b07..7586867 100644 --- a/src/SummaryFile1.py +++ b/src/SummaryFile1.py @@ -1,12 +1,10 @@ import os +from Errors import RecordError import GPS import StringUtils -class RecordError(StandardError): - pass - class GeoRecord: """ This class wraps one record in an SF1 geo file. @@ -60,7 +58,7 @@ class Block: self.coordinates.longitude = (float(geo_record.intptlon) / (10**6)) - def tiger_blkidfp00(self): + def blkidfp00(self): # From the Tiger/Line shapefile documentation: # # Current block identifier; a concatenation of Census 2000 @@ -410,32 +408,3 @@ class GeoRecordParser: return record - - - -def FindClosestBlock(blocks, target_coords): - """ - Find the closest block (from within blocks) to the GPS - coordinates given by target_coords. - """ - - # Empty by default. Hopefully we're passed some blocks. - closest_block = None - min_distance = 999999999.0 # Don't look at me like that. - - for block in blocks: - this_distance = GPS.CalculateDistance(target_coords, block.coordinates) - if (this_distance < min_distance): - closest_block = block - min_distance = this_distance - - return closest_block - - - -def FindAveragePopulationDensity(coords, geo_file_path): - grp = GeoRecordParser() - blocks = grp.parse_blocks(geo_file_path) - closest_block = FindClosestBlock(blocks, coords) - - return closest_block.population_density()