]> gitweb.michael.orlitzky.com - dead/census-tools.git/commitdiff
Updated all of the queries within the Database class to refer to the 'blocks' table.
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 9 Feb 2010 18:55:57 +0000 (13:55 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 9 Feb 2010 18:55:57 +0000 (13:55 -0500)
src/Census.py

index 0f8d23473144d38602e3094797de3f44cd9b05fb..761b380ba15f70c22ff75baf202cda86e8b501b8 100644 (file)
@@ -36,9 +36,8 @@ class Database:
                 
         query = """
         SELECT population_density
-        FROM (sf1_blocks INNER JOIN tiger_blocks
-              ON sf1_blocks.blkidfp00=tiger_blocks.blkidfp00)
-        WHERE ST_Contains(tiger_blocks.the_geom,
+        FROM blocks
+        WHERE ST_Contains(blocks.the_geom,
                           ST_SetSRID(ST_Point(%.6f, %.6f), %d));
         """
         
@@ -77,9 +76,9 @@ class Database:
         # result.
         #
         query = """
-        SELECT SUM(sf1_blocks.pop100 *
-                   ( ST_Area(ST_Intersection(%s, tiger_blocks.the_geom))
-                   / ST_Area(tiger_blocks.the_geom) )
+        SELECT SUM(pop100 *
+                   ( ST_Area(ST_Intersection(%s, blocks.the_geom))
+                   / ST_Area(blocks.the_geom) )
                ) AS covered_population
                """ % geometric_object
         sql_params = (well_known_text, self.srid)
@@ -88,15 +87,14 @@ class Database:
         # Join our two block tables, so that we have both the demographic
         # and geometric data.
         query += """
-        FROM (sf1_blocks INNER JOIN tiger_blocks
-              ON sf1_blocks.blkidfp00 = tiger_blocks.blkidfp00)
+        FROM blocks
         """
 
 
         # We only need to calculate the covered population for the blocks
         # that actually intersect our object.
         query += """
-        WHERE (ST_Intersects(%s, tiger_blocks.the_geom))
+        WHERE (ST_Intersects(%s, blocks.the_geom))
         """ % geometric_object
         # geometric_object hasn't been substituted yet, so we need
         # to add the sql_params twice.
@@ -129,9 +127,9 @@ class Database:
         cursor = self.connection.cursor()
 
         query = """
-        SELECT ST_AsText(tiger_blocks.the_geom)
-        FROM tiger_blocks
-        WHERE tiger_blocks.blkidfp00 = %s;
+        SELECT ST_AsText(the_geom)
+        FROM blocks
+        WHERE blkidfp00 = %s;
         """
         sql_params = (blkidfp00,)