2009-10-19 23:46:38 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2011-08-30 22:51:42 +00:00
|
|
|
import os
|
2015-02-02 18:31:16 +00:00
|
|
|
from nose.tools import eq_
|
2013-06-03 02:28:24 +00:00
|
|
|
from utilities import execution_path, run_all
|
2009-10-19 23:46:38 +00:00
|
|
|
|
2011-11-23 11:33:58 +00:00
|
|
|
import mapnik
|
2009-10-19 23:46:38 +00:00
|
|
|
|
2011-08-30 22:51:42 +00: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-19 23:46:38 +00:00
|
|
|
def test_introspect_symbolizers():
|
|
|
|
# create a symbolizer
|
2014-04-25 05:09:07 +00:00
|
|
|
p = mapnik.PointSymbolizer()
|
|
|
|
p.file = "../data/images/dummy.png"
|
2009-10-19 23:46:38 +00:00
|
|
|
p.allow_overlap = True
|
|
|
|
p.opacity = 0.5
|
2012-02-24 21:13:56 +00:00
|
|
|
|
2009-10-19 23:46:38 +00:00
|
|
|
eq_(p.allow_overlap, True)
|
|
|
|
eq_(p.opacity, 0.5)
|
|
|
|
eq_(p.filename,'../data/images/dummy.png')
|
2012-02-24 21:13:56 +00:00
|
|
|
|
2009-10-19 23:46:38 +00:00
|
|
|
# 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')
|
2012-02-24 21:13:56 +00:00
|
|
|
|
2009-10-19 23:46:38 +00:00
|
|
|
# contruct objects to hold it
|
2011-11-23 11:33:58 +00:00
|
|
|
r = mapnik.Rule()
|
2009-10-19 23:46:38 +00:00
|
|
|
r.symbols.append(p)
|
2011-11-23 11:33:58 +00:00
|
|
|
s = mapnik.Style()
|
2009-10-19 23:46:38 +00:00
|
|
|
s.rules.append(r)
|
2011-11-23 11:33:58 +00:00
|
|
|
m = mapnik.Map(0,0)
|
2009-10-19 23:46:38 +00:00
|
|
|
m.append_style('s',s)
|
|
|
|
|
|
|
|
# try to figure out what is
|
|
|
|
# in the map and make sure
|
|
|
|
# style is there and the same
|
2012-02-24 21:13:56 +00:00
|
|
|
|
2009-10-19 23:46:38 +00:00
|
|
|
s2 = m.find_style('s')
|
|
|
|
rules = s2.rules
|
|
|
|
eq_(len(rules),1)
|
|
|
|
r2 = rules[0]
|
|
|
|
syms = r2.symbols
|
|
|
|
eq_(len(syms),1)
|
2012-02-24 21:13:56 +00:00
|
|
|
|
2009-10-19 23:46:38 +00:00
|
|
|
## TODO here, we can do...
|
|
|
|
sym = syms[0]
|
2014-04-25 05:09:07 +00:00
|
|
|
p2 = sym.extract()
|
2011-11-23 11:33:58 +00:00
|
|
|
assert isinstance(p2,mapnik.PointSymbolizer)
|
2009-10-19 23:46:38 +00:00
|
|
|
|
|
|
|
eq_(p2.allow_overlap, True)
|
|
|
|
eq_(p2.opacity, 0.5)
|
|
|
|
eq_(p2.filename,'../data/images/dummy.png')
|
2012-02-24 21:13:56 +00:00
|
|
|
|
2011-08-30 22:51:42 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
setup()
|
2014-07-14 16:34:20 +00:00
|
|
|
exit(run_all(eval(x) for x in dir() if x.startswith("test_")))
|