def readXml(self, node):
        self.readCustomProperties(node)

        service_url = self.customProperty("service_url", "")
        imageid = self.customProperty("imageid", "")
        bucket_name = self.customProperty("bucket_name", "")
        zmin = int(self.customProperty("zmin", TileDefaultSettings.ZMIN))
        zmax = int(self.customProperty("zmax", TileDefaultSettings.ZMAX))
        bbox = BoundingBox.fromString(self.customProperty("bbox", ""))
        epsg = int(self.customProperty("epsg", 3857))
        max_connections = int(self.customProperty("max_connections", 16))

        self.layerDef = IdahoLayerDefinition(service_url=service_url, imageid=imageid, bucket_name=bucket_name,
                                             zmin=zmin, zmax=zmax, bbox=bbox, epsg=epsg,
                                             max_connections=max_connections)

         # set parameters
        self.layerDef.parameters.colorinterpretation = self.customProperty("colorinterpretation", "UNSPECIFIED")
        self.layerDef.parameters.bands = self.customProperty("bands", [0])
        self.layerDef.parameters.format = self.customProperty("format", None)
        self.layerDef.parameters.token = self.customProperty("token", None)
        self.layerDef.parameters.doDRA = self.customProperty("doDRA", None)
        self.layerDef.parameters.lowCutoff = self.customProperty("lowCutoff", None)
        self.layerDef.parameters.highCutoff = self.customProperty("highCutoff", None)
        self.layerDef.update()

        self.tile_manager = TileManager(self, self.layerDef)

        self.setExtent(BoundingBox.asPseudoMercator(self.layerDef.bbox, self.layerDef.epsg).toQgsRectangle())

        # layer style
        self.setTransparency(int(self.customProperty("transparency", 0)))
        self.setBlendModeByName(self.customProperty("blendMode", self.DEFAULT_BLEND_MODE))
        self.setSmoothRender(int(self.customProperty("smoothRender", self.DEFAULT_SMOOTH_RENDER)))


        return True
    def __init__(self, plugin, layerDef):
        QgsPluginLayer.__init__(self, IdahoLayer.LAYER_TYPE, layerDef.imageid)

        self.plugin = plugin
        self.iface = plugin.iface
        self.layerDef = layerDef
        self.tile_manager = TileManager(self, layerDef)
        self.zoom = 0
        self.tile_range = None

        # set custom properties
        self.setCustomProperty("service_url", layerDef.service_url)
        self.setCustomProperty("bucket_name", layerDef.bucket_name)
        self.setCustomProperty("imageid", layerDef.imageid)
        self.setCustomProperty("zmin", layerDef.zmin)
        self.setCustomProperty("zmax", layerDef.zmax)
        self.setCustomProperty("bbox", layerDef.bbox.toString())
        self.setCustomProperty("epsg", layerDef.epsg)
        self.setCustomProperty("max_connections", layerDef.max_connections)

        # set crs default to Pseudo Mercator
        if plugin.crs3857 is None:
            # create a QgsCoordinateReferenceSystem instance if plugin has no instance yet
            plugin.crs3857 = QgsCoordinateReferenceSystem(3857)

        self.setCrs(plugin.crs3857)

        # set QGIS extent as QgsRectangle
        if not layerDef.epsg:
            layerDef.epsg = 4326
        if layerDef.epsg == 3857 or layerDef.epsg == 900913:
            self.setExtent(layerDef.bbox.toQgsRectangle())
        else:
            self.setExtent(BoundingBox.asPseudoMercator(layerDef.bbox, layerDef.epsg).toQgsRectangle())

        # set styles
        self.setTransparency(0)
        self.setBrightness(0)
        self.setContrast(1.0)
        self.setSaturation(1.0)
        self.setBlendModeByName(self.DEFAULT_BLEND_MODE)
        self.setSmoothRender(self.DEFAULT_SMOOTH_RENDER)


        if self.iface:
            self.statusSignal.connect(self.showStatusMessageSlot)
            self.messageBarSignal.connect(self.showMessageBarSlot)

        self.setValid(True)