2010-03-19 16:16:15 +00:00
|
|
|
#encoding: utf8
|
2012-01-24 08:27:44 +00:00
|
|
|
import mapnik
|
|
|
|
from nose.tools import *
|
|
|
|
|
|
|
|
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'
|
|
|
|
feature.add_geometries_from_wkt('POINT(2 3)')
|
|
|
|
md.add_feature(feature)
|
|
|
|
eq_(md.num_features(), 1)
|
|
|
|
|
|
|
|
featureset = md.features_at_point(mapnik.Coord(2,3))
|
|
|
|
retrieved = []
|
|
|
|
feat = featureset.next()
|
2012-02-14 23:01:41 +00:00
|
|
|
while feat:
|
2012-01-24 08:27:44 +00:00
|
|
|
retrieved.append(feat)
|
2012-02-14 23:01:41 +00:00
|
|
|
feat = featureset.next()
|
2012-02-24 21:13:56 +00:00
|
|
|
|
2012-01-24 08:27:44 +00:00
|
|
|
eq_(len(retrieved), 1)
|
|
|
|
f = retrieved[0]
|
|
|
|
eq_(f['foo'], 'bar')
|
|
|
|
|
2012-02-14 23:01:41 +00:00
|
|
|
featureset = md.features_at_point(mapnik.Coord(20,30))
|
2012-01-24 08:27:44 +00:00
|
|
|
retrieved = []
|
|
|
|
feat = featureset.next()
|
2012-02-14 23:01:41 +00:00
|
|
|
while feat:
|
2012-01-24 08:27:44 +00:00
|
|
|
retrieved.append(feat)
|
|
|
|
eq_(len(retrieved), 0)
|
2011-08-30 22:51:42 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
[eval(run)() for run in dir() if 'test_' in run]
|