]> gitweb.michael.orlitzky.com - dead/census-tools.git/blobdiff - src/Census.py
Renamed the "tiger" table to "tiger_blocks" in preparation for the addition of the...
[dead/census-tools.git] / src / Census.py
index a69ff58b9cb68fea0e8c398d5fce289f7954a87e..da9283d2efb20c4c7d1f8896b120fad8f98b3815 100644 (file)
@@ -30,9 +30,9 @@ class Database:
                 
         query = """
         SELECT population_density
-        FROM (sf1_blocks INNER JOIN tiger
-              ON sf1_blocks.tiger_blkidfp00=tiger.blkidfp00)
-        WHERE ST_Contains(tiger.the_geom,
+        FROM (sf1_blocks INNER JOIN tiger_blocks
+              ON sf1_blocks.blkidfp00=tiger_blocks.blkidfp00)
+        WHERE ST_Contains(tiger_blocks.the_geom,
                           ST_SetSRID(ST_Point(%.6f, %.6f), %d));
         """
         
@@ -71,8 +71,8 @@ class Database:
         #
         query = """
         SELECT SUM(sf1_blocks.pop100 *
-                   ( ST_Area(ST_Intersection(%s, tiger.the_geom))
-                   / ST_Area(tiger.the_geom) )
+                   ( ST_Area(ST_Intersection(%s, tiger_blocks.the_geom))
+                   / ST_Area(tiger_blocks.the_geom) )
                ) AS covered_population
                """ % geometric_object
         sql_params = (well_known_text, self.srid)
@@ -81,15 +81,15 @@ class Database:
         # Join our two block tables, so that we have both the demographic
         # and geometric data.
         query += """
-        FROM (sf1_blocks INNER JOIN tiger
-              ON sf1_blocks.tiger_blkidfp00 = tiger.blkidfp00)
+        FROM (sf1_blocks INNER JOIN tiger_blocks
+              ON sf1_blocks.blkidfp00 = tiger_blocks.blkidfp00)
         """
 
 
         # We only need to calculate the covered population for the blocks
         # that actually intersect our object.
         query += """
-        WHERE (ST_Intersects(%s, tiger.the_geom))
+        WHERE (ST_Intersects(%s, tiger_blocks.the_geom))
         """ % geometric_object
         # geometric_object hasn't been substituted yet, so we need
         # to add the sql_params twice.
@@ -121,9 +121,9 @@ class Database:
         cursor = self.connection.cursor()
 
         query = """
-        SELECT ST_AsText(tiger.the_geom)
-        FROM tiger
-        WHERE tiger.blkidfp00 = %s;
+        SELECT ST_AsText(tiger_blocks.the_geom)
+        FROM tiger_blocks
+        WHERE tiger_blocks.blkidfp00 = %s;
         """
         sql_params = (blkidfp00,)