class Parcel(SimpleModel): name = models.CharField(max_length=30) city = models.ForeignKey(City, models.CASCADE) center1 = models.PointField() # Throwing a curveball w/`db_column` here. center2 = models.PointField(srid=2276, db_column='mycenter') border1 = models.PolygonField() border2 = models.PolygonField(srid=2276) def __str__(self): return self.name
class UniqueTogetherModel(models.Model): city = models.CharField(max_length=30) point = models.PointField() class Meta: unique_together = ('city', 'point') required_db_features = ['supports_geometry_field_unique_index']
class City(models.Model): name = models.CharField(max_length=30) point = models.PointField() class Meta: app_label = 'geoadmin' def __str__(self): return self.name
class City(NamedModel): name_txt = models.TextField(default='') name_short = models.CharField(max_length=5) population = models.IntegerField() density = models.DecimalField(max_digits=7, decimal_places=1) dt = models.DateField() point = models.PointField() class Meta: app_label = 'layermap'
def test_cast_aggregate(self): """ Cast a geography to a geometry field for an aggregate function that expects a geometry input. """ if not connection.ops.geography: self.skipTest("This test needs geography support") expected = (-96.8016128540039, 29.7633724212646, -95.3631439208984, 32.782058715820) res = City.objects.filter( name__in=('Houston', 'Dallas') ).aggregate(extent=models.Extent(Cast('point', models.PointField()))) for val, exp in zip(res['extent'], expected): self.assertAlmostEqual(exp, val, 4)
}, bases=(models.Model,), ), migrations.CreateModel( name='Household', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('neighborhood', models.ForeignKey( 'gis_migrations.Neighborhood', models.SET_NULL, to_field='id', null=True, )), ('address', models.CharField(max_length=100)), ('zip_code', models.IntegerField(null=True, blank=True)), ('geom', models.PointField(srid=4326, geography=True)), ], options={ }, bases=(models.Model,), ), migrations.CreateModel( name='Family', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('name', models.CharField(max_length=100, unique=True)), ], options={ }, bases=(models.Model,), ),
class City(NamedModel): point = models.PointField(geography=True) class Meta: app_label = 'geogapp'
class Invalid(models.Model): point = models.PointField()
class AustraliaCity(NamedModel): "City model for Australia, using WGS84." point = models.PointField() radius = models.IntegerField(default=10000)
class SouthTexasCityFt(NamedModel): "Same City model as above, but U.S. survey feet are the units." point = models.PointField(srid=2278)
class SouthTexasCity(NamedModel): "City model on projected coordinate system for South Texas." point = models.PointField(srid=32140) radius = models.IntegerField(default=10000)
class ManyPointModel(NamedModel): point1 = models.PointField() point2 = models.PointField() point3 = models.PointField(srid=3857)
class NonConcreteModel(NamedModel): non_concrete = NonConcreteField() point = models.PointField(geography=True)
class CityBase(NamedModel): population = models.IntegerField() density = models.DecimalField(max_digits=7, decimal_places=1) point = models.PointField()
class City3D(NamedModel): point = models.PointField(dim=3) pointg = models.PointField(dim=3, geography=True)
class MultiFields(NamedModel): city = models.ForeignKey(City, models.CASCADE) point = models.PointField() poly = models.PolygonField()
class City(NamedModel): point = models.PointField() class Meta: app_label = 'geoapp'
class Point3D(SimpleModel): point = models.PointField(dim=3)
class Point2D(SimpleModel): point = models.PointField()
class Location(SimpleModel): point = models.PointField() def __str__(self): return self.point.wkt
class MinusOneSRID(models.Model): geom = models.PointField(srid=-1) # Minus one SRID.