2008-02-01 16:27:13 +01:00
|
|
|
#!/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)
|
2008-02-01 16:38:33 +01:00
|
|
|
styles = []
|
2008-02-01 16:27:13 +01:00
|
|
|
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
|
2008-02-01 16:38:33 +01:00
|
|
|
styles.append(s)
|
2008-02-01 16:27:13 +01:00
|
|
|
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)
|
2008-02-01 16:38:33 +01:00
|
|
|
print "Total number of styles %s" % len(set(styles)) # unique styles
|
2008-02-01 16:27:13 +01:00
|
|
|
print "Total number of rules %s" % num_rules
|
|
|
|
print "Total number of symbolizers %s" % num_sym
|