def testLoadDynamicRaster(self): aRaster = DynamicRaster() loader = GeneralState.rasterLoader() loader.fillGDALRaster(aRaster, '../../resources/test.tiff') self.assertEqual(120, aRaster.getSize()._width) self.assertEqual(120, aRaster.getSize()._height) self.assertEqual(139, aRaster.getValue(Point2DInt(39,39)))
def testLoadDynamicRaster(self): aRaster = DynamicRaster() loader = GeneralState.rasterLoader() loader.fillGDALRaster(aRaster, '../../resources/test.tiff') self.assertEqual(120, aRaster.getSize()._width) self.assertEqual(120, aRaster.getSize()._height) self.assertEqual(139, aRaster.getValue(Point2DInt(39, 39)))
def testLoadShapefile(self): loader = GeneralState.shpLoader() loader.open('../../resources/test.shp') self.assertEqual(4,loader.getNumFeatures()) self.assertEqual(Point2DInt(32,22), loader.getPosition(3)) self.assertEqual('label d', loader.getFieldAsString(3, 'label')) self.assertEqual(4, loader.getFieldAsInt(3, 'intValue')) self.assertAlmostEqual(4.5, loader.getFieldAsFloat(3, 'floatValue'))
def testLoadShapefile(self): loader = GeneralState.shpLoader() loader.open('../../resources/test.shp') self.assertEqual(4, loader.getNumFeatures()) self.assertEqual(Point2DInt(32, 22), loader.getPosition(3)) self.assertEqual('label d', loader.getFieldAsString(3, 'label')) self.assertEqual(4, loader.getFieldAsInt(3, 'intValue')) self.assertAlmostEqual(4.5, loader.getFieldAsFloat(3, 'floatValue'))
def createAgents(self): loader = GeneralState.shpLoader() loader.open(self._shpFileName) for i in range(0, loader.getNumFeatures()): newAgent = ShpAgent('ShpAgent_'+loader.getFieldAsString(i, 'name')) position = loader.getPosition(i) position._y = self.getBoundaries()._size._height - position._y if not self.getBoundaries().contains(position): continue newAgent.position = position newAgent._label = loader.getFieldAsString(i, 'label') newAgent._intValue = loader.getFieldAsInt(i, 'intValue') newAgent._floatValue = loader.getFieldAsFloat(i, 'floatValue') print('loading agent num:',i,'-',newAgent) self.addAgent(newAgent)
def createAgents(self): loader = GeneralState.shpLoader() loader.open(self._shpFileName) for i in range(0, loader.getNumFeatures()): newAgent = ShpAgent('ShpAgent_' + loader.getFieldAsString(i, 'name')) position = loader.getPosition(i) position._y = self.getBoundaries()._size._height - position._y if not self.getBoundaries().contains(position): continue newAgent.position = position newAgent._label = loader.getFieldAsString(i, 'label') newAgent._intValue = loader.getFieldAsInt(i, 'intValue') newAgent._floatValue = loader.getFieldAsFloat(i, 'floatValue') print('loading agent num:', i, '-', newAgent) self.addAgent(newAgent)
def createRasters(self): self.registerStaticRaster('raster', True) loader = GeneralState.rasterLoader() loader.fillGDALRaster(self.getStaticRaster('raster'), self._rasterFileName) return
def createRasters(self): self.registerDynamicRaster('raster', True) loader = GeneralState.rasterLoader() loader.fillGDALRaster(self.getDynamicRaster('raster'), self._rasterFileName) return