]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - wkt2pop
89bb5955b480d69a4a5592cc36c99f0084d1f261
4 Find the total population contained within a geometric object.
6 Our input is an OGC Well-Known Text[1] string. This string is used as
7 part of a database query that finds the population contained within
8 (i.e. 'underneath') the geometric object corresponding to the WKT
11 [1] http://en.wikipedia.org/wiki/Well-known_text
18 # Basically, add '../src' to our path.
19 # Needed for the imports that follow.
20 site
.addsitedir(os
.path
.dirname(os
.path
.abspath(sys
.argv
[0])) + '/../src')
24 import Configuration
.Defaults
27 usage
= '%prog [options] <well-known text representation>'
28 parser
= CLI
.default_option_parser(usage
)
30 # Use this module's docstring as the description.
31 parser
.description
= __doc__
34 parser
.add_option('-s',
37 help="SRID of the input geometry. Defaults to %s." % Configuration
.Defaults
.SRID
,
38 default
=Configuration
.Defaults
.SRID
)
41 (options
, args
) = parser
.parse_args()
44 print "\nERROR: You must supply a geometric object in Well-Known Text format.\n"
46 print '' # Print a newline.
47 raise SystemExit(ExitCodes
.NOT_ENOUGH_ARGS
)
50 cdb
= Census
.Database(options
.host
,
55 population
= cdb
.find_contained_population(args
[0])
57 if (population
!= None):
60 print 'Error: No rows returned.'
61 raise SystemExit(ExitCodes
.NO_RESULTS
)