X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=bin%2Fpg2kml;h=bef23fa4393b8a40e2e596bd0a554ec8b88f64b5;hb=d67b2e640133c45a31813ec853e58a866553134a;hp=1fddabec07811fc147d8a160db4a9654730f97f5;hpb=63612d67421c5bd193e6b97f4d777742e07fbbba;p=dead%2Fcensus-tools.git diff --git a/bin/pg2kml b/bin/pg2kml index 1fddabe..bef23fa 100755 --- a/bin/pg2kml +++ b/bin/pg2kml @@ -7,7 +7,6 @@ upon their blocks' average population densities. Output is written to stdout. """ -from optparse import OptionParser import os import pgdb import site @@ -17,6 +16,7 @@ import sys # Needed for the imports that follow. site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src') +import CLI import Configuration.Defaults import ExitCodes import GPS @@ -29,31 +29,14 @@ Parse the command line options. All of these are optional; defaults are provided for the database information and the output is written to stdout. """ -# -h (help) Conflicts with -h HOSTNAME -parser = OptionParser(add_help_option = False) + +parser = CLI.default_option_parser() # Use this module's docstring as the description. parser.description = __doc__.strip() - -parser.add_option('-h', - '--host', - help='The hostname/address where the database is located.', - default=Configuration.Defaults.DATABASE_HOST) - -parser.add_option('-d', - '--database', - help='The database in which the population data are stored.', - default=Configuration.Defaults.DATABASE_NAME) - -parser.add_option('-U', - '--username', - help='The username who has access to the database.', - default=Configuration.Defaults.DATABASE_USERNAME) - (options, args) = parser.parse_args() - def GenerateRedStyles(alpha='7f'): """ Generate 256 styles (0-255), each corresponding to a shade of red. @@ -128,9 +111,9 @@ for style in red_styles: query = """ -SELECT tiger.blkidfp00, population_density, AsKML(the_geom) as geom - FROM (sf1_blocks INNER JOIN tiger - ON sf1_blocks.tiger_blkidfp00=tiger.blkidfp00); +SELECT tiger_blocks.blkidfp00, population_density, AsKML(the_geom) as geom + FROM (sf1_blocks INNER JOIN tiger_blocks + ON sf1_blocks.blkidfp00 = tiger_blocks.blkidfp00); """ cursor.execute(query) @@ -170,6 +153,6 @@ for row in rows: doc.children.append(placemark) -print doc.to_kml() +doc.print_kml() conn.close()