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


Python fields.GeometryField方法代碼示例

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


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

示例1: remove_field

# 需要導入模塊: from django.contrib.gis.db.models import fields [as 別名]
# 或者: from django.contrib.gis.db.models.fields import GeometryField [as 別名]
def remove_field(self, model, field):
        if isinstance(field, GeometryField) and field.spatial_index:
            qn = self.connection.ops.quote_name
            sql = self.sql_drop_spatial_index % {
                'index': qn(self._create_spatial_index_name(model, field)),
                'table': qn(model._meta.db_table),
            }
            try:
                self.execute(sql)
            except OperationalError:
                logger.error(
                    "Couldn't remove spatial index: %s (may be expected "
                    "if your storage engine doesn't support them)." % sql
                )

        super(MySQLGISSchemaEditor, self).remove_field(model, field) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:18,代碼來源:schema.py

示例2: column_sql

# 需要導入模塊: from django.contrib.gis.db.models import fields [as 別名]
# 或者: from django.contrib.gis.db.models.fields import GeometryField [as 別名]
def column_sql(self, model, field, include_default=False):
        column_sql = super(OracleGISSchemaEditor, self).column_sql(model, field, include_default)
        if isinstance(field, GeometryField):
            db_table = model._meta.db_table
            self.geometry_sql.append(
                self.sql_add_geometry_metadata % {
                    'table': self.geo_quote_name(db_table),
                    'column': self.geo_quote_name(field.column),
                    'dim0': field._extent[0],
                    'dim1': field._extent[1],
                    'dim2': field._extent[2],
                    'dim3': field._extent[3],
                    'tolerance': field._tolerance,
                    'srid': field.srid,
                }
            )
            if field.spatial_index:
                self.geometry_sql.append(
                    self.sql_add_spatial_index % {
                        'index': self.quote_name(self._create_spatial_index_name(model, field)),
                        'table': self.quote_name(db_table),
                        'column': self.quote_name(field.column),
                    }
                )
        return column_sql 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:27,代碼來源:schema.py

示例3: delete_model

# 需要導入模塊: from django.contrib.gis.db.models import fields [as 別名]
# 或者: from django.contrib.gis.db.models.fields import GeometryField [as 別名]
def delete_model(self, model, **kwargs):
        from django.contrib.gis.db.models.fields import GeometryField
        # Drop spatial metadata (dropping the table does not automatically remove them)
        for field in model._meta.local_fields:
            if isinstance(field, GeometryField):
                self.remove_geometry_metadata(model, field)
        # Make sure all geom stuff is gone
        for geom_table in self.geometry_tables:
            try:
                self.execute(
                    self.sql_discard_geometry_columns % {
                        "geom_table": geom_table,
                        "table": self.quote_name(model._meta.db_table),
                    }
                )
            except DatabaseError:
                pass
        super(SpatialiteSchemaEditor, self).delete_model(model, **kwargs) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:20,代碼來源:schema.py

示例4: process_rhs

# 需要導入模塊: from django.contrib.gis.db.models import fields [as 別名]
# 或者: from django.contrib.gis.db.models.fields import GeometryField [as 別名]
def process_rhs(self, compiler, connection):
        rhs, rhs_params = super(GISLookup, self).process_rhs(compiler, connection)
        if hasattr(self.rhs, '_as_sql'):
            # If rhs is some QuerySet, don't touch it
            return rhs, rhs_params

        geom = self.rhs
        if isinstance(self.rhs, Col):
            # Make sure the F Expression destination field exists, and
            # set an `srid` attribute with the same as that of the
            # destination.
            geo_fld = self.rhs.output_field
            if not hasattr(geo_fld, 'srid'):
                raise ValueError('No geographic field found in expression.')
            self.rhs.srid = geo_fld.srid
        elif isinstance(self.rhs, Expression):
            raise ValueError('Complex expressions not supported for GeometryField')
        elif isinstance(self.rhs, (list, tuple)):
            geom = self.rhs[0]
        rhs = connection.ops.get_geom_placeholder(self.lhs.output_field, geom, compiler)
        return rhs, rhs_params 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:23,代碼來源:lookups.py

示例5: _build_kml_sources

# 需要導入模塊: from django.contrib.gis.db.models import fields [as 別名]
# 或者: from django.contrib.gis.db.models.fields import GeometryField [as 別名]
def _build_kml_sources(self, sources):
        """
        Goes through the given sources and returns a 3-tuple of
        the application label, module name, and field name of every
        GeometryField encountered in the sources.

        If no sources are provided, then all models.
        """
        kml_sources = []
        if sources is None:
            sources = apps.get_models()
        for source in sources:
            if isinstance(source, models.base.ModelBase):
                for field in source._meta.fields:
                    if isinstance(field, GeometryField):
                        kml_sources.append((source._meta.app_label,
                                            source._meta.model_name,
                                            field.name))
            elif isinstance(source, (list, tuple)):
                if len(source) != 3:
                    raise ValueError('Must specify a 3-tuple of (app_label, module_name, field_name).')
                kml_sources.append(source)
            else:
                raise TypeError('KML Sources must be a model or a 3-tuple.')
        return kml_sources 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:27,代碼來源:kml.py

示例6: remove_field

# 需要導入模塊: from django.contrib.gis.db.models import fields [as 別名]
# 或者: from django.contrib.gis.db.models.fields import GeometryField [as 別名]
def remove_field(self, model, field):
        if isinstance(field, GeometryField) and field.spatial_index:
            qn = self.connection.ops.quote_name
            sql = self.sql_drop_spatial_index % {
                'index': qn(self._create_spatial_index_name(model, field)),
                'table': qn(model._meta.db_table),
            }
            try:
                self.execute(sql)
            except OperationalError:
                logger.error(
                    "Couldn't remove spatial index: %s (may be expected "
                    "if your storage engine doesn't support them).", sql
                )

        super(MySQLGISSchemaEditor, self).remove_field(model, field) 
開發者ID:KimJangHyeon,項目名稱:NarshaTech,代碼行數:18,代碼來源:schema.py

示例7: skip_default

# 需要導入模塊: from django.contrib.gis.db.models import fields [as 別名]
# 或者: from django.contrib.gis.db.models.fields import GeometryField [as 別名]
def skip_default(self, field):
        return (
            super(MySQLGISSchemaEditor, self).skip_default(field) or
            # Geometry fields are stored as BLOB/TEXT and can't have defaults.
            isinstance(field, GeometryField)
        ) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:8,代碼來源:schema.py


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