2010-03-19 17:16:15 +01:00
|
|
|
#encoding: utf8
|
2012-01-24 09:27:44 +01:00
|
|
|
import mapnik
|
2015-02-02 19:31:16 +01:00
|
|
|
from utilities import run_all
|
|
|
|
from nose.tools import eq_
|
2012-01-24 09:27:44 +01:00
|
|
|
|
|
|
|
def test_add_feature():
|
|
|
|
md = mapnik.MemoryDatasource()
|
|
|
|
eq_(md.num_features(), 0)
|
|
|
|
context = mapnik.Context()
|
|
|
|
context.push('foo')
|
|
|
|
feature = mapnik.Feature(context,1)
|
|
|
|
feature['foo'] = 'bar'
|
2015-03-23 18:04:37 +01:00
|
|
|
feature.geometry = mapnik.Geometry.from_wkt('POINT(2 3)')
|
2012-01-24 09:27:44 +01:00
|
|
|
md.add_feature(feature)
|
|
|
|
eq_(md.num_features(), 1)
|
|
|
|
|
|
|
|
featureset = md.features_at_point(mapnik.Coord(2,3))
|
|
|
|
retrieved = []
|
2012-08-08 18:31:30 +02:00
|
|
|
|
|
|
|
for feat in featureset:
|
2012-01-24 09:27:44 +01:00
|
|
|
retrieved.append(feat)
|
2012-02-24 22:13:56 +01:00
|
|
|
|
2012-01-24 09:27:44 +01:00
|
|
|
eq_(len(retrieved), 1)
|
|
|
|
f = retrieved[0]
|
|
|
|
eq_(f['foo'], 'bar')
|
|
|
|
|
2012-02-15 00:01:41 +01:00
|
|
|
featureset = md.features_at_point(mapnik.Coord(20,30))
|
2012-01-24 09:27:44 +01:00
|
|
|
retrieved = []
|
2012-08-08 18:31:30 +02:00
|
|
|
for feat in featureset:
|
2012-01-24 09:27:44 +01:00
|
|
|
retrieved.append(feat)
|
|
|
|
eq_(len(retrieved), 0)
|
2011-08-31 00:51:42 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2014-07-14 18:34:20 +02:00
|
|
|
exit(run_all(eval(x) for x in dir() if x.startswith("test_")))
|