當前位置: 首頁>>代碼示例>>Python>>正文


Python error.GDALException方法代碼示例

本文整理匯總了Python中django.contrib.gis.gdal.error.GDALException方法的典型用法代碼示例。如果您正苦於以下問題:Python error.GDALException方法的具體用法?Python error.GDALException怎麽用?Python error.GDALException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.contrib.gis.gdal.error的用法示例。


在下文中一共展示了error.GDALException方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def __init__(self, feat, index):
        """
        Initializes on the feature object and the integer index of
        the field within the feature.
        """
        # Setting the feature pointer and index.
        self._feat = feat
        self._index = index

        # Getting the pointer for this field.
        fld_ptr = capi.get_feat_field_defn(feat.ptr, index)
        if not fld_ptr:
            raise GDALException('Cannot create OGR Field, invalid pointer given.')
        self.ptr = fld_ptr

        # Setting the class depending upon the OGR Field Type (OFT)
        self.__class__ = OGRFieldTypes[self.type]

        # OFTReal with no precision should be an OFTInteger.
        if isinstance(self, OFTReal) and self.precision == 0:
            self.__class__ = OFTInteger
            self._double = True 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:24,代碼來源:field.py

示例2: __init__

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def __init__(self, type_input):
        "Figures out the correct OGR Type based upon the input."
        if isinstance(type_input, OGRGeomType):
            num = type_input.num
        elif isinstance(type_input, six.string_types):
            type_input = type_input.lower()
            if type_input == 'geometry':
                type_input = 'unknown'
            num = self._str_types.get(type_input)
            if num is None:
                raise GDALException('Invalid OGR String Type "%s"' % type_input)
        elif isinstance(type_input, int):
            if type_input not in self._types:
                raise GDALException('Invalid OGR Integer Type: %d' % type_input)
            num = type_input
        else:
            raise TypeError('Invalid OGR input type given.')

        # Setting the OGR geometry type number.
        self.num = num 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:22,代碼來源:geomtype.py

示例3: get_raster_prep_value

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def get_raster_prep_value(self, value, is_candidate):
        """
        Return a GDALRaster if conversion is successful, otherwise return None.
        """
        from django.contrib.gis.gdal import GDALRaster

        if isinstance(value, GDALRaster):
            return value
        elif is_candidate:
            try:
                return GDALRaster(value)
            except GDALException:
                pass
        elif isinstance(value, dict):
            try:
                return GDALRaster(value)
            except GDALException:
                raise ValueError("Couldn't create spatial object from lookup value '%s'." % value) 
開發者ID:KimJangHyeon,項目名稱:NarshaTech,代碼行數:20,代碼來源:fields.py

示例4: get_raster_prep_value

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def get_raster_prep_value(self, value, is_candidate):
        """
        Return a GDALRaster if conversion is successful, otherwise return None.
        """
        if isinstance(value, gdal.GDALRaster):
            return value
        elif is_candidate:
            try:
                return gdal.GDALRaster(value)
            except GDALException:
                pass
        elif isinstance(value, dict):
            try:
                return gdal.GDALRaster(value)
            except GDALException:
                raise ValueError("Couldn't create spatial object from lookup value '%s'." % value) 
開發者ID:prakharchoudhary,項目名稱:Scrum,代碼行數:18,代碼來源:fields.py

示例5: __init__

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def __init__(self, type_input):
        "Figures out the correct OGR Type based upon the input."
        if isinstance(type_input, OGRGeomType):
            num = type_input.num
        elif isinstance(type_input, six.string_types):
            type_input = type_input.lower()
            if type_input == 'geometry':
                type_input = 'unknown'
            num = self._str_types.get(type_input, None)
            if num is None:
                raise GDALException('Invalid OGR String Type "%s"' % type_input)
        elif isinstance(type_input, int):
            if type_input not in self._types:
                raise GDALException('Invalid OGR Integer Type: %d' % type_input)
            num = type_input
        else:
            raise TypeError('Invalid OGR input type given.')

        # Setting the OGR geometry type number.
        self.num = num 
開發者ID:0daybug,項目名稱:DjangoBlog,代碼行數:22,代碼來源:geomtype.py

示例6: __init__

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def __init__(self, ds_input, write=False):
        self._write = 1 if write else 0
        Driver.ensure_registered()

        # If input is a valid file path, try setting file as source.
        if isinstance(ds_input, six.string_types):
            if os.path.exists(ds_input):
                try:
                    # GDALOpen will auto-detect the data source type.
                    self.ptr = capi.open_ds(force_bytes(ds_input), self._write)
                except GDALException as err:
                    raise GDALException('Could not open the datasource at "{}" ({}).'.format(
                        ds_input, err))
            else:
                raise GDALException('Unable to read raster source input "{}"'.format(ds_input))
        else:
            raise GDALException('Invalid data source input type: "{}".'.format(type(ds_input))) 
開發者ID:0daybug,項目名稱:DjangoBlog,代碼行數:19,代碼來源:source.py

示例7: as_datetime

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def as_datetime(self):
        "Retrieves the Field's value as a tuple of date & time components."
        yy, mm, dd, hh, mn, ss, tz = [c_int() for i in range(7)]
        status = capi.get_field_as_datetime(
            self._feat.ptr, self._index, byref(yy), byref(mm), byref(dd),
            byref(hh), byref(mn), byref(ss), byref(tz))
        if status:
            return (yy, mm, dd, hh, mn, ss, tz)
        else:
            raise GDALException('Unable to retrieve date & time information from the field.')

    # #### Field Properties #### 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:14,代碼來源:field.py

示例8: value

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def value(self):
        "Returns a Python `date` object for the OFTDate field."
        try:
            yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
            return date(yy.value, mm.value, dd.value)
        except (ValueError, GDALException):
            return None 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:9,代碼來源:field.py

示例9: __init__

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def __init__(self, feat, layer):
        """
        Initializes Feature from a pointer and its Layer object.
        """
        if not feat:
            raise GDALException('Cannot create OGR Feature, invalid pointer given.')
        self.ptr = feat
        self._layer = layer 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:10,代碼來源:feature.py

示例10: gdal_version_info

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def gdal_version_info():
    ver = gdal_version().decode()
    m = version_regex.match(ver)
    if not m:
        raise GDALException('Could not parse GDAL version string "%s"' % ver)
    return {key: m.group(key) for key in ('major', 'minor', 'subminor')} 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:8,代碼來源:libgdal.py

示例11: _flush

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def _flush(self):
        """
        Flush all data from memory into the source file if it exists.
        The data that needs flushing are geotransforms, coordinate systems,
        nodata_values and pixel values. This function will be called
        automatically wherever it is needed.
        """
        # Raise an Exception if the value is being changed in read mode.
        if not self._write:
            raise GDALException('Raster needs to be opened in write mode to change values.')
        capi.flush_ds(self._ptr) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:13,代碼來源:source.py

示例12: __getitem__

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def __getitem__(self, index):
        try:
            return GDALBand(self.source, index + 1)
        except GDALException:
            raise GDALException('Unable to get band index %d' % index) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:7,代碼來源:band.py

示例13: __init__

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def __init__(self, *args):
        """
        The initialization function may take an OGREnvelope structure, 4-element
        tuple or list, or 4 individual arguments.
        """

        if len(args) == 1:
            if isinstance(args[0], OGREnvelope):
                # OGREnvelope (a ctypes Structure) was passed in.
                self._envelope = args[0]
            elif isinstance(args[0], (tuple, list)):
                # A tuple was passed in.
                if len(args[0]) != 4:
                    raise GDALException('Incorrect number of tuple elements (%d).' % len(args[0]))
                else:
                    self._from_sequence(args[0])
            else:
                raise TypeError('Incorrect type of argument: %s' % str(type(args[0])))
        elif len(args) == 4:
            # Individual parameters passed in.
            #  Thanks to ww for the help
            self._from_sequence([float(a) for a in args])
        else:
            raise GDALException('Incorrect number (%d) of arguments.' % len(args))

        # Checking the x,y coordinates
        if self.min_x > self.max_x:
            raise GDALException('Envelope minimum X > maximum X.')
        if self.min_y > self.max_y:
            raise GDALException('Envelope minimum Y > maximum Y.') 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:32,代碼來源:envelope.py

示例14: __eq__

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def __eq__(self, other):
        """
        Returns True if the envelopes are equivalent; can compare against
        other Envelopes and 4-tuples.
        """
        if isinstance(other, Envelope):
            return (self.min_x == other.min_x) and (self.min_y == other.min_y) and \
                   (self.max_x == other.max_x) and (self.max_y == other.max_y)
        elif isinstance(other, tuple) and len(other) == 4:
            return (self.min_x == other[0]) and (self.min_y == other[1]) and \
                   (self.max_x == other[2]) and (self.max_y == other[3])
        else:
            raise GDALException('Equivalence testing only works with other Envelopes.') 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:15,代碼來源:envelope.py

示例15: expand_to_include

# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import GDALException [as 別名]
def expand_to_include(self, *args):
        """
        Modifies the envelope to expand to include the boundaries of
        the passed-in 2-tuple (a point), 4-tuple (an extent) or
        envelope.
        """
        # We provide a number of different signatures for this method,
        # and the logic here is all about converting them into a
        # 4-tuple single parameter which does the actual work of
        # expanding the envelope.
        if len(args) == 1:
            if isinstance(args[0], Envelope):
                return self.expand_to_include(args[0].tuple)
            elif hasattr(args[0], 'x') and hasattr(args[0], 'y'):
                return self.expand_to_include(args[0].x, args[0].y, args[0].x, args[0].y)
            elif isinstance(args[0], (tuple, list)):
                # A tuple was passed in.
                if len(args[0]) == 2:
                    return self.expand_to_include((args[0][0], args[0][1], args[0][0], args[0][1]))
                elif len(args[0]) == 4:
                    (minx, miny, maxx, maxy) = args[0]
                    if minx < self._envelope.MinX:
                        self._envelope.MinX = minx
                    if miny < self._envelope.MinY:
                        self._envelope.MinY = miny
                    if maxx > self._envelope.MaxX:
                        self._envelope.MaxX = maxx
                    if maxy > self._envelope.MaxY:
                        self._envelope.MaxY = maxy
                else:
                    raise GDALException('Incorrect number of tuple elements (%d).' % len(args[0]))
            else:
                raise TypeError('Incorrect type of argument: %s' % str(type(args[0])))
        elif len(args) == 2:
            # An x and an y parameter were passed in
                return self.expand_to_include((args[0], args[1], args[0], args[1]))
        elif len(args) == 4:
            # Individual parameters passed in.
            return self.expand_to_include(args)
        else:
            raise GDALException('Incorrect number (%d) of arguments.' % len(args[0])) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:43,代碼來源:envelope.py


注:本文中的django.contrib.gis.gdal.error.GDALException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。