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


Python backend.Geometry类代码示例

本文整理汇总了Python中django.contrib.gis.geometry.backend.Geometry的典型用法代码示例。如果您正苦于以下问题:Python Geometry类的具体用法?Python Geometry怎么用?Python Geometry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: get_prep_value

    def get_prep_value(self, value):
        obj = super().get_prep_value(value)
        # When the input is not a geometry or raster, attempt to construct one
        # from the given string input.
        if isinstance(obj, Geometry):
            pass
        else:
            # Check if input is a candidate for conversion to raster or geometry.
            is_candidate = isinstance(obj, (bytes, str)) or hasattr(obj, '__geo_interface__')
            # Try to convert the input to raster.
            raster = self.get_raster_prep_value(obj, is_candidate)

            if raster:
                obj = raster
            elif is_candidate:
                try:
                    obj = Geometry(obj)
                except (GeometryException, GDALException):
                    raise ValueError("Couldn't create spatial object from lookup value '%s'." % obj)
            else:
                raise ValueError('Cannot use object with type %s for a spatial lookup parameter.' % type(obj).__name__)

        # Assigning the SRID value.
        obj.srid = self.get_srid(obj)
        return obj
开发者ID:atombrella,项目名称:django,代码行数:25,代码来源:fields.py

示例2: from_db_value

 def from_db_value(self, value, expression, connection, context):
     if value:
         if not isinstance(value, Geometry):
             value = Geometry(value)
         srid = value.srid
         if not srid and self.srid != -1:
             value.srid = self.srid
     return value
开发者ID:MichaelLiaoFeng,项目名称:django,代码行数:8,代码来源:fields.py

示例3: get_prep_value

    def get_prep_value(self, value):
        """
        Spatial lookup values are either a parameter that is (or may be
        converted to) a geometry or raster, or a sequence of lookup values
        that begins with a geometry or raster. This routine sets up the
        geometry or raster value properly and preserves any other lookup
        parameters.
        """
        value = super(BaseSpatialField, self).get_prep_value(value)

        # For IsValid lookups, boolean values are allowed.
        if isinstance(value, (Expression, bool)):
            return value
        elif isinstance(value, (tuple, list)):
            obj = value[0]
            seq_value = True
        else:
            obj = value
            seq_value = False

        # When the input is not a geometry or raster, attempt to construct one
        # from the given string input.
        if isinstance(obj, Geometry):
            pass
        else:
            # Check if input is a candidate for conversion to raster or geometry.
            is_candidate = isinstance(obj, (bytes, six.string_types)) or hasattr(obj, '__geo_interface__')
            # With GDAL installed, try to convert the input to raster.
            raster = False
            if HAS_GDAL:
                raster = self.get_raster_prep_value(obj, is_candidate)

            if raster:
                obj = raster
            elif is_candidate:
                try:
                    obj = Geometry(obj)
                except (GeometryException, GDALException):
                    raise ValueError("Couldn't create spatial object from lookup value '%s'." % obj)
            else:
                raise ValueError('Cannot use object with type %s for a spatial lookup parameter.' % type(obj).__name__)

        # Assigning the SRID value.
        obj.srid = self.get_srid(obj)

        if seq_value:
            lookup_val = [obj]
            lookup_val.extend(value[1:])
            return tuple(lookup_val)
        else:
            return obj
开发者ID:756613351,项目名称:django,代码行数:51,代码来源:fields.py

示例4: get_prep_value

    def get_prep_value(self, value):
        """
        Spatial lookup values are either a parameter that is (or may be
        converted to) a geometry, or a sequence of lookup values that
        begins with a geometry.  This routine will setup the geometry
        value properly, and preserve any other lookup parameters before
        returning to the caller.
        """
        from django.contrib.gis.gdal import GDALRaster

        value = super(GeometryField, self).get_prep_value(value)
        if isinstance(value, (Expression, bool)):
            return value
        elif isinstance(value, (tuple, list)):
            geom = value[0]
            seq_value = True
        else:
            geom = value
            seq_value = False

        # When the input is not a GEOS geometry, attempt to construct one
        # from the given string input.
        if isinstance(geom, (Geometry, GDALRaster)):
            pass
        elif isinstance(geom, (bytes, six.string_types)) or hasattr(geom, '__geo_interface__'):
            try:
                geom = Geometry(geom)
            except GeometryException:
                raise ValueError('Could not create geometry from lookup value.')
        else:
            raise ValueError('Cannot use object with type %s for a geometry lookup parameter.' % type(geom).__name__)

        # Assigning the SRID value.
        geom.srid = self.get_srid(geom)

        if seq_value:
            lookup_val = [geom]
            lookup_val.extend(value[1:])
            return tuple(lookup_val)
        else:
            return geom
开发者ID:2015E8007361074,项目名称:django,代码行数:41,代码来源:fields.py

示例5: get_prep_value

    def get_prep_value(self, value):
        """
        Spatial lookup values are either a parameter that is (or may be
        converted to) a geometry, or a sequence of lookup values that
        begins with a geometry.  This routine will setup the geometry
        value properly, and preserve any other lookup parameters before
        returning to the caller.
        """
        if isinstance(value, SQLEvaluator):
            return value
        elif isinstance(value, (tuple, list)):
            geom = value[0]
            seq_value = True
        else:
            geom = value
            seq_value = False

        # When the input is not a GEOS geometry, attempt to construct one
        # from the given string input.
        if isinstance(geom, Geometry):
            pass
        elif isinstance(geom, basestring) or hasattr(geom, '__geo_interface__'):
            try:
                geom = Geometry(geom)
            except GeometryException:
                raise ValueError('Could not create geometry from lookup value.')
        else:
            raise ValueError('Cannot use parameter of `%s` type as lookup parameter.' % type(value))

        # Assigning the SRID value.
        geom.srid = self.get_srid(geom)

        if seq_value:
            lookup_val = [geom]
            lookup_val.extend(value[1:])
            return tuple(lookup_val)
        else:
            return geom
开发者ID:StephanHoyer,项目名称:django,代码行数:38,代码来源:fields.py

示例6: convert_geometry

 def convert_geometry(self, value, expression, connection, context):
     if value:
         value = Geometry(value)
         if 'transformed_srid' in context:
             value.srid = context['transformed_srid']
     return value
开发者ID:1check1,项目名称:my-first-blog,代码行数:6,代码来源:operations.py

示例7:

from django.contrib.gis import forms
开发者ID:letouriste001,项目名称:SmartForest_2.0,代码行数:1,代码来源:fields.py

示例8:

"""
开发者ID:letouriste001,项目名称:SmartForest_2.0,代码行数:1,代码来源:operations.py


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