当前位置: 首页>>代码示例>>Python>>正文


Python error.SRSException方法代码示例

本文整理汇总了Python中django.contrib.gis.gdal.error.SRSException方法的典型用法代码示例。如果您正苦于以下问题:Python error.SRSException方法的具体用法?Python error.SRSException怎么用?Python error.SRSException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.contrib.gis.gdal.error的用法示例。


在下文中一共展示了error.SRSException方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ogr

# 需要导入模块: from django.contrib.gis.gdal import error [as 别名]
# 或者: from django.contrib.gis.gdal.error import SRSException [as 别名]
def ogr(self):
        "Returns the OGR Geometry for this Geometry."
        if not gdal.HAS_GDAL:
            raise GEOSException('GDAL required to convert to an OGRGeometry.')
        if self.srid:
            try:
                return gdal.OGRGeometry(self.wkb, self.srid)
            except SRSException:
                pass
        return gdal.OGRGeometry(self.wkb) 
开发者ID:0daybug,项目名称:DjangoBlog,代码行数:12,代码来源:geometry.py

示例2: srs

# 需要导入模块: from django.contrib.gis.gdal import error [as 别名]
# 或者: from django.contrib.gis.gdal.error import SRSException [as 别名]
def srs(self):
        "Returns the OSR SpatialReference for SRID of this Geometry."
        if not gdal.HAS_GDAL:
            raise GEOSException('GDAL required to return a SpatialReference object.')
        if self.srid:
            try:
                return gdal.SpatialReference(self.srid)
            except SRSException:
                pass
        return None 
开发者ID:0daybug,项目名称:DjangoBlog,代码行数:12,代码来源:geometry.py

示例3: srs

# 需要导入模块: from django.contrib.gis.gdal import error [as 别名]
# 或者: from django.contrib.gis.gdal.error import SRSException [as 别名]
def srs(self):
        "Returns the Spatial Reference used in this Layer."
        try:
            ptr = capi.get_layer_srs(self.ptr)
            return SpatialReference(srs_api.clone_srs(ptr))
        except SRSException:
            return None 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:9,代码来源:layer.py

示例4: check_srs

# 需要导入模块: from django.contrib.gis.gdal import error [as 别名]
# 或者: from django.contrib.gis.gdal.error import SRSException [as 别名]
def check_srs(result, func, cargs):
    if isinstance(result, six.integer_types):
        result = c_void_p(result)
    if not result:
        raise SRSException('Invalid spatial reference pointer returned from "%s".' % func.__name__)
    return result

### Other error-checking routines ### 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:10,代码来源:errcheck.py

示例5: _get_srs

# 需要导入模块: from django.contrib.gis.gdal import error [as 别名]
# 或者: from django.contrib.gis.gdal.error import SRSException [as 别名]
def _get_srs(self):
        "Returns the Spatial Reference for this Geometry."
        try:
            srs_ptr = capi.get_geom_srs(self.ptr)
            return SpatialReference(srs_api.clone_srs(srs_ptr))
        except SRSException:
            return None 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:9,代码来源:geometries.py

示例6: __init__

# 需要导入模块: from django.contrib.gis.gdal import error [as 别名]
# 或者: from django.contrib.gis.gdal.error import SRSException [as 别名]
def __init__(self, srs_input='', srs_type='user'):
        """
        Creates a GDAL OSR Spatial Reference object from the given input.
        The input may be string of OGC Well Known Text (WKT), an integer
        EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand
        string (one of 'WGS84', 'WGS72', 'NAD27', 'NAD83').
        """

        if srs_type == 'wkt':
            self.ptr = capi.new_srs(c_char_p(b''))
            self.import_wkt(srs_input)
            return
        elif isinstance(srs_input, six.string_types):
            # Encoding to ASCII if unicode passed in.
            if isinstance(srs_input, six.text_type):
                srs_input = srs_input.encode('ascii')
            try:
                # If SRID is a string, e.g., '4326', then make acceptable
                # as user input.
                srid = int(srs_input)
                srs_input = 'EPSG:%d' % srid
            except ValueError:
                pass
        elif isinstance(srs_input, six.integer_types):
            # EPSG integer code was input.
            srs_type = 'epsg'
        elif isinstance(srs_input, self.ptr_type):
            srs = srs_input
            srs_type = 'ogr'
        else:
            raise TypeError('Invalid SRS type "%s"' % srs_type)

        if srs_type == 'ogr':
            # Input is already an SRS pointer.
            srs = srs_input
        else:
            # Creating a new SRS pointer, using the string buffer.
            buf = c_char_p(b'')
            srs = capi.new_srs(buf)

        # If the pointer is NULL, throw an exception.
        if not srs:
            raise SRSException('Could not create spatial reference from: %s' % srs_input)
        else:
            self.ptr = srs

        # Importing from either the user input string or an integer SRID.
        if srs_type == 'user':
            self.import_user_input(srs_input)
        elif srs_type == 'epsg':
            self.import_epsg(srs_input) 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:53,代码来源:srs.py

示例7: __init__

# 需要导入模块: from django.contrib.gis.gdal import error [as 别名]
# 或者: from django.contrib.gis.gdal.error import SRSException [as 别名]
def __init__(self, srs_input='', srs_type='user'):
        """
        Creates a GDAL OSR Spatial Reference object from the given input.
        The input may be string of OGC Well Known Text (WKT), an integer
        EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand
        string (one of 'WGS84', 'WGS72', 'NAD27', 'NAD83').
        """

        if srs_type == 'wkt':
            self.ptr = capi.new_srs(c_char_p(b''))
            self.import_wkt(srs_input)
            return
        elif isinstance(srs_input, six.string_types):
            try:
                # If SRID is a string, e.g., '4326', then make acceptable
                # as user input.
                srid = int(srs_input)
                srs_input = 'EPSG:%d' % srid
            except ValueError:
                pass
        elif isinstance(srs_input, six.integer_types):
            # EPSG integer code was input.
            srs_type = 'epsg'
        elif isinstance(srs_input, self.ptr_type):
            srs = srs_input
            srs_type = 'ogr'
        else:
            raise TypeError('Invalid SRS type "%s"' % srs_type)

        if srs_type == 'ogr':
            # Input is already an SRS pointer.
            srs = srs_input
        else:
            # Creating a new SRS pointer, using the string buffer.
            buf = c_char_p(b'')
            srs = capi.new_srs(buf)

        # If the pointer is NULL, throw an exception.
        if not srs:
            raise SRSException('Could not create spatial reference from: %s' % srs_input)
        else:
            self.ptr = srs

        # Importing from either the user input string or an integer SRID.
        if srs_type == 'user':
            self.import_user_input(srs_input)
        elif srs_type == 'epsg':
            self.import_epsg(srs_input) 
开发者ID:prakharchoudhary,项目名称:Scrum,代码行数:50,代码来源:srs.py

示例8: __init__

# 需要导入模块: from django.contrib.gis.gdal import error [as 别名]
# 或者: from django.contrib.gis.gdal.error import SRSException [as 别名]
def __init__(self, srs_input=''):
        """
        Creates a GDAL OSR Spatial Reference object from the given input.
        The input may be string of OGC Well Known Text (WKT), an integer
        EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand
        string (one of 'WGS84', 'WGS72', 'NAD27', 'NAD83').
        """
        srs_type = 'user'

        if isinstance(srs_input, six.string_types):
            # Encoding to ASCII if unicode passed in.
            if isinstance(srs_input, six.text_type):
                srs_input = srs_input.encode('ascii')
            try:
                # If SRID is a string, e.g., '4326', then make acceptable
                # as user input.
                srid = int(srs_input)
                srs_input = 'EPSG:%d' % srid
            except ValueError:
                pass
        elif isinstance(srs_input, six.integer_types):
            # EPSG integer code was input.
            srs_type = 'epsg'
        elif isinstance(srs_input, self.ptr_type):
            srs = srs_input
            srs_type = 'ogr'
        else:
            raise TypeError('Invalid SRS type "%s"' % srs_type)

        if srs_type == 'ogr':
            # Input is already an SRS pointer.
            srs = srs_input
        else:
            # Creating a new SRS pointer, using the string buffer.
            buf = c_char_p(b'')
            srs = capi.new_srs(buf)

        # If the pointer is NULL, throw an exception.
        if not srs:
            raise SRSException('Could not create spatial reference from: %s' % srs_input)
        else:
            self.ptr = srs

        # Importing from either the user input string or an integer SRID.
        if srs_type == 'user':
            self.import_user_input(srs_input)
        elif srs_type == 'epsg':
            self.import_epsg(srs_input) 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:50,代码来源:srs.py


注:本文中的django.contrib.gis.gdal.error.SRSException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。