def test_python_extended_constructor(self): from mapnik2 import Geometry2d f = self.makeOne(1, Geometry2d.from_wkt('Point(3 6)'), foo="bar") self.failUnlessEqual(f['foo'], 'bar') env = f.get_geometry(0).envelope() self.failUnlessEqual(env.minx, 3) self.failUnlessEqual(env.miny, 6)
def test_add_wkb_geometry(self): from mapnik2 import Geometry2d def add_it(geometry): f = self.makeOne(1) self.failUnlessEqual(len(f.geometries), 0) f.add_geometry(geometry) self.failUnlessEqual(len(f.geometries), 1) env = f.get_geometry(0).envelope() self.failUnlessEqual(env.minx, 3) self.failUnlessEqual(env.minx, env.maxx) self.failUnlessEqual(env.miny, 6) self.failUnlessEqual(env.miny, env.maxy) add_it(Geometry2d.from_wkt('Point(3 6)'))
def test_add_feature(self): md = self.makeOne() self.failUnlessEqual(md.num_features(), 0) from mapnik2 import Geometry2d md.add_feature(self.makeFeature(Geometry2d.from_wkt('Point(2 3)'), foo='bar')) self.failUnlessEqual(md.num_features(), 1) from mapnik2 import Coord retrieved = md.features_at_point(Coord(2,3)).features self.failUnlessEqual(len(retrieved), 1) f = retrieved[0] self.failUnlessEqual(f['foo'], 'bar') retrieved = md.features_at_point(Coord(20,30)).features self.failUnlessEqual(len(retrieved), 0)
def test_add_feature(self): md = self.makeOne() self.failUnlessEqual(md.num_features(), 0) from mapnik2 import Geometry2d md.add_feature( self.makeFeature(Geometry2d.from_wkt('Point(2 3)'), foo='bar')) self.failUnlessEqual(md.num_features(), 1) from mapnik2 import Coord retrieved = md.features_at_point(Coord(2, 3)).features self.failUnlessEqual(len(retrieved), 1) f = retrieved[0] self.failUnlessEqual(f['foo'], 'bar') retrieved = md.features_at_point(Coord(20, 30)).features self.failUnlessEqual(len(retrieved), 0)