2009-10-20 01:46:38 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2011-08-31 00:51:42 +02:00
|
|
|
import os
|
2009-10-20 01:46:38 +02:00
|
|
|
from nose.tools import *
|
2011-08-31 00:51:42 +02:00
|
|
|
from utilities import execution_path
|
2009-10-20 01:46:38 +02:00
|
|
|
from utilities import Todo
|
|
|
|
|
2011-11-23 12:33:58 +01:00
|
|
|
import mapnik
|
2009-10-20 01:46:38 +02:00
|
|
|
|
2011-08-31 00:51:42 +02:00
|
|
|
def setup():
|
|
|
|
# All of the paths used are relative, if we run the tests
|
|
|
|
# from another directory we need to chdir()
|
|
|
|
os.chdir(execution_path('.'))
|
|
|
|
|
2009-10-20 01:46:38 +02:00
|
|
|
def test_introspect_symbolizers():
|
|
|
|
# create a symbolizer
|
2011-11-23 12:33:58 +01:00
|
|
|
p = mapnik.PointSymbolizer(mapnik.PathExpression("../data/images/dummy.png"))
|
2009-10-20 01:46:38 +02:00
|
|
|
p.allow_overlap = True
|
|
|
|
p.opacity = 0.5
|
|
|
|
|
|
|
|
eq_(p.allow_overlap, True)
|
|
|
|
eq_(p.opacity, 0.5)
|
|
|
|
eq_(p.filename,'../data/images/dummy.png')
|
|
|
|
|
|
|
|
# make sure the defaults
|
|
|
|
# are what we think they are
|
|
|
|
eq_(p.allow_overlap, True)
|
|
|
|
eq_(p.opacity,0.5)
|
|
|
|
eq_(p.filename,'../data/images/dummy.png')
|
|
|
|
|
|
|
|
# contruct objects to hold it
|
2011-11-23 12:33:58 +01:00
|
|
|
r = mapnik.Rule()
|
2009-10-20 01:46:38 +02:00
|
|
|
r.symbols.append(p)
|
2011-11-23 12:33:58 +01:00
|
|
|
s = mapnik.Style()
|
2009-10-20 01:46:38 +02:00
|
|
|
s.rules.append(r)
|
2011-11-23 12:33:58 +01:00
|
|
|
m = mapnik.Map(0,0)
|
2009-10-20 01:46:38 +02:00
|
|
|
m.append_style('s',s)
|
|
|
|
|
|
|
|
# try to figure out what is
|
|
|
|
# in the map and make sure
|
|
|
|
# style is there and the same
|
|
|
|
|
|
|
|
s2 = m.find_style('s')
|
|
|
|
rules = s2.rules
|
|
|
|
eq_(len(rules),1)
|
|
|
|
r2 = rules[0]
|
|
|
|
syms = r2.symbols
|
|
|
|
eq_(len(syms),1)
|
|
|
|
|
|
|
|
## TODO here, we can do...
|
|
|
|
sym = syms[0]
|
|
|
|
# this is hackish at best
|
|
|
|
p2 = sym.symbol()
|
2011-11-23 12:33:58 +01:00
|
|
|
assert isinstance(p2,mapnik.PointSymbolizer)
|
2009-10-20 01:46:38 +02:00
|
|
|
|
|
|
|
eq_(p2.allow_overlap, True)
|
|
|
|
eq_(p2.opacity, 0.5)
|
|
|
|
eq_(p2.filename,'../data/images/dummy.png')
|
|
|
|
|
|
|
|
## but we need to be able to do:
|
|
|
|
p2 = syms[0] # get the actual symbolizer, not the variant object
|
|
|
|
# this will throw for now...
|
2011-11-23 12:33:58 +01:00
|
|
|
assert isinstance(p2,mapnik.PointSymbolizer)
|
2009-10-20 01:46:38 +02:00
|
|
|
|
|
|
|
eq_(p2.allow_overlap, True)
|
|
|
|
eq_(p2.opacity, 0.5)
|
2011-08-31 00:51:42 +02:00
|
|
|
eq_(p2.filename,'../data/images/dummy.png')
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
setup()
|
|
|
|
[eval(run)() for run in dir() if 'test_' in run]
|