本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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,
})
示例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)
示例9: test_deconstruct_empty
def test_deconstruct_empty(self):
field = GeometryField()
*_, kwargs = field.deconstruct()
self.assertEqual(kwargs, {'srid': 4326})