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


Python fields.GeometryField类代码示例

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


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

示例1: as_sqlite

 def as_sqlite(self, compiler, connection):
     geo_field = GeometryField(
         srid=self.srid)  # Fake field to get SRID info
     if geo_field.geodetic(connection):
         raise NotImplementedError(
             "Perimeter cannot use a non-projected field.")
     return super(Perimeter, self).as_sql(compiler, connection)
开发者ID:erozqba,项目名称:django,代码行数:7,代码来源:functions.py

示例2: as_sqlite

 def as_sqlite(self, compiler, connection):
     geo_field = GeometryField(srid=self.srid)
     if geo_field.geodetic(connection):
         if self.spheroid:
             self.function = 'GeodesicLength'
         else:
             self.function = 'GreatCircleLength'
     return super(Length, self).as_sql(compiler, connection)
开发者ID:aakash201,项目名称:OnlineJudge,代码行数:8,代码来源:functions.py

示例3: as_postgresql

 def as_postgresql(self, compiler, connection):
     geo_field = GeometryField(srid=self.srid)  # Fake field to get SRID info
     if geo_field.geodetic(connection) and not self.source_is_geography():
         raise NotImplementedError("ST_Perimeter cannot use a non-projected non-geography field.")
     dim = min(f.dim for f in self.get_source_fields())
     if dim > 2:
         self.function = connection.ops.perimeter3d
     return super(Perimeter, self).as_sql(compiler, connection)
开发者ID:2015E8007361074,项目名称:django,代码行数:8,代码来源:functions.py

示例4: as_sql

 def as_sql(self, compiler, connection):
     geo_field = GeometryField(
         srid=self.srid)  # Fake field to get SRID info
     if geo_field.geodetic(
             connection
     ) and not connection.features.supports_length_geodetic:
         raise NotImplementedError(
             "This backend doesn't support Length on geodetic fields")
     return super(Length, self).as_sql(compiler, connection)
开发者ID:erozqba,项目名称:django,代码行数:9,代码来源:functions.py

示例5: as_postgresql

 def as_postgresql(self, compiler, connection):
     function = None
     geo_field = GeometryField(srid=self.srid)  # Fake field to get SRID info
     if self.source_is_geography():
         self.source_expressions.append(Value(self.spheroid))
     elif geo_field.geodetic(connection):
         # Geometry fields with geodetic (lon/lat) coordinates need length_spheroid
         function = connection.ops.spatial_function_name('LengthSpheroid')
         self.source_expressions.append(Value(geo_field.spheroid(connection)))
     else:
         dim = min(f.dim for f in self.get_source_fields() if f)
         if dim > 2:
             function = connection.ops.length3d
     return super().as_sql(compiler, connection, function=function)
开发者ID:denys-duchier,项目名称:django,代码行数:14,代码来源:functions.py

示例6: convert_value

 def convert_value(self, value, expression, connection, context):
     if value is None:
         return None
     geo_field = GeometryField(srid=self.srid)  # Fake field to get SRID info
     if geo_field.geodetic(connection):
         dist_att = 'm'
     else:
         units = geo_field.units_name(connection)
         if units:
             dist_att = DistanceMeasure.unit_attname(units)
         else:
             dist_att = None
     if dist_att:
         return DistanceMeasure(**{dist_att: value})
     return value
开发者ID:aakash201,项目名称:OnlineJudge,代码行数:15,代码来源:functions.py

示例7: test_deconstruct_values

 def test_deconstruct_values(self):
     field = GeometryField(
         srid=4067,
         dim=3,
         geography=True,
         extent=(50199.4814, 6582464.0358, -50000.0, 761274.6247, 7799839.8902, 50000.0),
         tolerance=0.01,
     )
     *_, kwargs = field.deconstruct()
     self.assertEqual(kwargs, {
         'srid': 4067,
         'dim': 3,
         'geography': True,
         'extent': (50199.4814, 6582464.0358, -50000.0, 761274.6247, 7799839.8902, 50000.0),
         'tolerance': 0.01,
     })
开发者ID:EmadMokhtar,项目名称:django,代码行数:16,代码来源:test_fields.py

示例8: as_sqlite

 def as_sqlite(self, compiler, connection):
     function = None
     geo_field = GeometryField(srid=self.srid)
     if geo_field.geodetic(connection):
         function = 'GeodesicLength' if self.spheroid else 'GreatCircleLength'
     return super().as_sql(compiler, connection, function=function)
开发者ID:denys-duchier,项目名称:django,代码行数:6,代码来源:functions.py

示例9: test_deconstruct_empty

 def test_deconstruct_empty(self):
     field = GeometryField()
     *_, kwargs = field.deconstruct()
     self.assertEqual(kwargs, {'srid': 4326})
开发者ID:EmadMokhtar,项目名称:django,代码行数:4,代码来源:test_fields.py

示例10:

from decimal import Decimal
开发者ID:letouriste001,项目名称:SmartForest_2.0,代码行数:1,代码来源:functions.py


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