当前位置: 首页>>代码示例>>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;未经允许,请勿转载。