python script to print stats about map definition file

This commit is contained in:
Artem Pavlenko 2008-02-01 15:27:13 +00:00
parent cdfaf36ee9
commit 4485d71ab2

26
utils/stats/mapdef_stats.py Executable file
View file

@ -0,0 +1,26 @@
#!/usr/bin/env python
import sys
from mapnik import *
if __name__ == "__main__":
if len(sys.argv) != 2:
print "usage : ./mapdef_stats.py <mapdefinition file>"
sys.exit(0)
m = Map(100,100)
num_rules = 0
num_sym = 0
load_map(m,sys.argv[1])
for l in m.layers:
print "Layer:%s" % l.name
for s in l.styles:
print " Style:%s" % s
style = m.find_style(s)
num_rules += len(style.rules)
for r in style.rules:
print " Filter: %s" % r.filter
num_sym += len(r.symbols)
print "Total number of layers %s" % len(m.layers)
print "Total number of rules %s" % num_rules
print "Total number of symbolizers %s" % num_sym