X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=bin%2Flines2kml;h=3fc3d784d4f60ff70fbd83e0391a806004af318b;hb=d67b2e640133c45a31813ec853e58a866553134a;hp=9a4b6d384264886186cd559a08b8dfda6b535264;hpb=717a5d47751909c5b2e0d9e984c340cb2e50be82;p=dead%2Fcensus-tools.git diff --git a/bin/lines2kml b/bin/lines2kml index 9a4b6d3..3fc3d78 100755 --- a/bin/lines2kml +++ b/bin/lines2kml @@ -6,7 +6,6 @@ Language (KML). The exported roads should have both a human-readable name and a globally-unique identifier (gid). """ -from optparse import OptionParser import os import pgdb import site @@ -16,6 +15,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 KML @@ -26,27 +26,12 @@ 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) - parser.add_option('-s', '--state', help='The FIPS id of the State whose roads you would like.') @@ -72,7 +57,7 @@ if (options.state != None): statefp = "'%s'" % options.state lines_query = """ -SELECT gid, tlid, fullname, the_geom +SELECT gid, tlid, fullname, ST_AsKml(the_geom) FROM tiger_lines WHERE statefp=%s """ % statefp @@ -91,7 +76,7 @@ for row in rows: # Some streets don't have a fullname. fullname = 'Unknown' - name = KML.Name(fullname + '(' + str(row[1]) + ')') + name = KML.Name(fullname + ' (' + str(row[1]) + ')') placemark.children.append(name) geometry = KML.RawText(row[3])