def testAddPointLayer(self): points = Layer(self.map, name="Points", filename="points", layertype=LayerTypePoint) points.open(mode='w') self.map.addLayer(points) # Add a new point newpoint = CellElementPoint((16.185, 58.5912), objtype=10) newpoint.discretizeGeometry(points.getCell(1)) points.addCellElement(newpoint) self.map.close() map = createMap(self.testdatadir) map.open() points, group = map.getLayerAndGroupByName("Points") points.open('r') actual = Set(points.getCellElements()) expected = Set([newpoint]) self.assertSetsEqual(actual, expected)
def testAddPoint(self): outimage = os.path.join(self.tempdir.dir, 'test.imi') mi = MapImage(outimage) mi.open('w') m = mi.createMap() m.scale = 1e-3 m.bbox = ((-3.0, -4.0), (2.0, 1.0)) m.open("w") layer = Layer(m, name="The Layer", filename="layer", layertype=LayerTypePoint, nlevels = 1) m.addLayer(layer) layer.open("w") point = CellElementPoint((-1.5006, -3.5006)) layer.addCellElement(point) cell = layer.getCell(point.cellnum) self.assertEqual(point.cellnum, 4) point.discretizeGeometry(layer.getCell(point.cellnum)) self.assertAlmostEqual(point.x, -1.501) self.assertAlmostEqual(point.y, -3.501) mi.close() ## Read back mi = MapImage(outimage) mi.open('r') m = mi.maps[0]