import pgdb
import GPS
+import SummaryFile1
class Database:
def __del__(self):
self.connection.close()
-
+
def find_average_population_density(self, coords):
"""
Find the average population density at a set of GPS coordinates.
else:
return None
+
+
+ def get_block_geometry_as_wkt(self, blkidfp00):
+ """
+ Find the geometry of a (uniquely-identified) block, in
+ Well-Known Text format.
+ """
+ cursor = self.connection.cursor()
+
+ query = """
+ SELECT ST_AsText(tiger.the_geom)
+ FROM tiger
+ WHERE tiger.blkidfp00 = %s;
+ """
+ sql_params = (blkidfp00,)
+
+ cursor.execute(query, sql_params)
+ rows = cursor.fetchall()
+ cursor.close()
+
+ if len(rows) > 0:
+ return rows[0][0]
+ else:
+ return None
+