Пример #1
0
    def _getBandItemActions(self, item=None, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = self._actionsmap['BandItem']

        action = actionsgroup.findChild(QtWidgets.QAction,
                                        'actionOpenImageView')
        action.setEnabled(True)

        if item is not None:
            assert isinstance(item, modelitems.BandItem)

            # @TODO: find a better solution
            allowcomplex = True
            if gdal.DataTypeIsComplex(item.DataType) and not allowcomplex:
                action.setEnabled(False)
            else:
                # @TODO: remove this to allow multiple views on the same item
                for subwin in self._app.mdiarea.subWindowList():
                    #if subwin.item == item:
                    #    action.setEnabled(False)
                    #    break

                    # @COMPATIBILITY: pyside 1.2.2
                    try:
                        if subwin.item == item:
                            action.setEnabled(False)
                            break
                    except NotImplementedError:
                        if id(subwin.item) == id(item):
                            action.setEnabled(False)
                            break

        return actionsgroup
Пример #2
0
    def _dataRange(band, data=None):
        if band and gdalsupport.hasFastStats(band):
            vmin, vmax, mean, stddev = gdalsupport.SafeGetStatistics(
                band, True)
            if None not in (vmin, vmax, mean, stddev):
                if gdal.DataTypeIsComplex(band.DataType):
                    vmin, vmax = 0, vmax * np.sqrt(2)
                return vmin, vmax

        if data is not None and data.size <= 4 * 1024**2:
            vmin, vmax, mean, stddev = safeDataStats(band)
            if None not in (vmin, vmax, mean, stddev):
                return data.min(), data.max()

        if band:
            tmap = {
                gdal.GDT_Byte: (0, 255),
                gdal.GDT_UInt16: (0, 2**16 - 1),
                gdal.GDT_UInt32: (0, 2**32 - 1),
                gdal.GDT_Int16: (-2**15, 2**15 - 1),
                gdal.GDT_Int32: (-2**31, 2**31 - 1),
                gdal.GDT_CInt16: (0, 2**15 * np.sqrt(2)),
                gdal.GDT_CInt32: (0, 2**31 * np.sqrt(2)),
                gdal.GDT_CFloat32: (0, None),
                gdal.GDT_CFloat64: (0, None),
            }
            return tmap.get(band.DataType, (None, None))

        return None, None
Пример #3
0
def has_complex_bands(dataset):
    result = False
    for band_id in range(1, dataset.RasterCount + 1):
        band = dataset.GetRasterBand(band_id)
        result = gdal.DataTypeIsComplex(band.DataType)
        if result:
            break
    return result
Пример #4
0
    def __init__(self, band, parent=None, scene=None, **kwargs):
        super(GdalGraphicsItem, self).__init__(band, parent, scene, **kwargs)

        if gdal.DataTypeIsComplex(band.DataType):
            # @TODO: raise ItemTypeError or NotImplementedError
            typename = gdal.GetDataTypeName(band.DataType)
            raise NotImplementedError('support for "%s" data type not '
                                      'avalable' % typename)
Пример #5
0
    def __init__(self, band, parent=None, **kwargs):
        super(GdalGraphicsItem, self).__init__(band, parent, **kwargs)
        self.colortable = qtsupport.GRAY_COLORTABLE

        if gdal.DataTypeIsComplex(band.DataType):
            # @TODO: raise ItemTypeError or NotImplementedError
            typename = gdal.GetDataTypeName(band.DataType)
            raise NotImplementedError(
                'support for "%s" data type not avalable' % typename)
Пример #6
0
def graphicsItemFactory(gdalobj, parent=None):
    '''Factory function for GDAL graphics items.

    Instantiates on object of the GDAL graphics item class taht best
    fits the *gdalobj* passed as argument.

    '''

    if gdalsupport.isRGB(gdalobj):
        _log.debug('new GdalRgbGraphicsItem')
        return GdalRgbGraphicsItem(gdalobj, parent)
    elif gdalobj.DataType in (gdal.GDT_Byte, gdal.GDT_UInt16):
        _log.debug('new GdalUIntGraphicsItem')
        return UIntGdalGraphicsItem(gdalobj, parent)
    elif gdal.DataTypeIsComplex(gdalobj.DataType):
        _log.debug('new GdalComplexGraphicsItem')
        return GdalComplexGraphicsItem(gdalobj, parent)
    else:
        _log.debug('new GdalGraphicsItem')
        return GdalGraphicsItem(gdalobj, parent)