當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。