]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - bin/wkt2pop
4 Find the total population contained within a geometric object.
8 Our input is an OGC Well-Known Text[1] string. This string is used as
9 part of a database query that finds the population contained within
10 (i.e. 'underneath') the geometric object corresponding to the WKT
13 [1] http://en.wikipedia.org/wiki/Well-known_text
20 # Basically, add '../src' to our path.
21 # Needed for the imports that follow.
22 site
.addsitedir(os
.path
.dirname(os
.path
.abspath(sys
.argv
[0])) + '/../src')
26 import Configuration
.Defaults
29 usage
= '%prog [options] <well-known text representation>'
30 parser
= CLI
.default_option_parser(usage
)
32 # Use this module's docstring as the description.
33 parser
.description
= __doc__
.strip()
36 parser
.add_option('-s',
39 help="SRID of the input geometry. Defaults to %s." % Configuration
.Defaults
.SRID
,
40 default
=Configuration
.Defaults
.SRID
)
43 (options
, args
) = parser
.parse_args()
46 print "\nERROR: You must supply a geometric object in Well-Known Text format.\n"
48 print '' # Print a newline.
49 raise SystemExit(ExitCodes
.NOT_ENOUGH_ARGS
)
52 cdb
= Census
.Database(options
.host
,
57 population
= cdb
.find_contained_population(args
[0])
59 if (population
!= None):
62 print 'Error: No rows returned.'
63 raise SystemExit(ExitCodes
.NO_RESULTS
)