Commit fecfd503 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Properly assigned app_label to GIS test models.

Used abstract inheritance to cut down on code repetition.
parent a502bbb2
Loading
Loading
Loading
Loading
+17 −41
Original line number Diff line number Diff line
@@ -3,77 +3,53 @@ from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class SouthTexasCity(models.Model):
    "City model on projected coordinate system for South Texas."
class NamedModel(models.Model):
    name = models.CharField(max_length=30)
    point = models.PointField(srid=32140)

    objects = models.GeoManager()

    class Meta:
        abstract = True
        app_label = 'distapp'

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class SouthTexasCityFt(models.Model):
class SouthTexasCity(NamedModel):
    "City model on projected coordinate system for South Texas."
    point = models.PointField(srid=32140)


class SouthTexasCityFt(NamedModel):
    "Same City model as above, but U.S. survey feet are the units."
    name = models.CharField(max_length=30)
    point = models.PointField(srid=2278)
    objects = models.GeoManager()

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class AustraliaCity(models.Model):
class AustraliaCity(NamedModel):
    "City model for Australia, using WGS84."
    name = models.CharField(max_length=30)
    point = models.PointField()
    objects = models.GeoManager()

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class CensusZipcode(models.Model):
class CensusZipcode(NamedModel):
    "Model for a few South Texas ZIP codes (in original Census NAD83)."
    name = models.CharField(max_length=5)
    poly = models.PolygonField(srid=4269)
    objects = models.GeoManager()

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class SouthTexasZipcode(models.Model):
class SouthTexasZipcode(NamedModel):
    "Model for a few South Texas ZIP codes."
    name = models.CharField(max_length=5)
    poly = models.PolygonField(srid=32140, null=True)
    objects = models.GeoManager()

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class Interstate(models.Model):
class Interstate(NamedModel):
    "Geodetic model for U.S. Interstates."
    name = models.CharField(max_length=10)
    path = models.LineStringField()
    objects = models.GeoManager()

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class SouthTexasInterstate(models.Model):
class SouthTexasInterstate(NamedModel):
    "Projected model for South Texas Interstates."
    name = models.CharField(max_length=10)
    path = models.LineStringField(srid=32140)
    objects = models.GeoManager()
    def __str__(self):
        return self.name
+26 −48
Original line number Diff line number Diff line
@@ -3,85 +3,63 @@ from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class City3D(models.Model):
class NamedModel(models.Model):
    name = models.CharField(max_length=30)
    point = models.PointField(dim=3)

    objects = models.GeoManager()

    class Meta:
        abstract = True
        app_label = 'geo3d'

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class Interstate2D(models.Model):
    name = models.CharField(max_length=30)
    line = models.LineStringField(srid=4269)
    objects = models.GeoManager()
class City3D(NamedModel):
    point = models.PointField(dim=3)

    def __str__(self):
        return self.name

class Interstate2D(NamedModel):
    line = models.LineStringField(srid=4269)

@python_2_unicode_compatible
class Interstate3D(models.Model):
    name = models.CharField(max_length=30)
    line = models.LineStringField(dim=3, srid=4269)
    objects = models.GeoManager()

    def __str__(self):
        return self.name
class Interstate3D(NamedModel):
    line = models.LineStringField(dim=3, srid=4269)


@python_2_unicode_compatible
class InterstateProj2D(models.Model):
    name = models.CharField(max_length=30)
class InterstateProj2D(NamedModel):
    line = models.LineStringField(srid=32140)
    objects = models.GeoManager()

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class InterstateProj3D(models.Model):
    name = models.CharField(max_length=30)
class InterstateProj3D(NamedModel):
    line = models.LineStringField(dim=3, srid=32140)
    objects = models.GeoManager()

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class Polygon2D(models.Model):
    name = models.CharField(max_length=30)
class Polygon2D(NamedModel):
    poly = models.PolygonField(srid=32140)
    objects = models.GeoManager()

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class Polygon3D(models.Model):
    name = models.CharField(max_length=30)
class Polygon3D(NamedModel):
    poly = models.PolygonField(dim=3, srid=32140)


class SimpleModel(models.Model):

    objects = models.GeoManager()

    def __str__(self):
        return self.name
    class Meta:
        abstract = True
        app_label = 'geo3d'


class Point2D(models.Model):
class Point2D(SimpleModel):
    point = models.PointField()
    objects = models.GeoManager()


class Point3D(models.Model):
class Point3D(SimpleModel):
    point = models.PointField(dim=3)
    objects = models.GeoManager()


class MultiPoint3D(models.Model):
class MultiPoint3D(SimpleModel):
    mpoint = models.MultiPointField(dim=3)
    objects = models.GeoManager()
+4 −0
Original line number Diff line number Diff line
@@ -7,8 +7,12 @@ from django.utils.encoding import python_2_unicode_compatible
class City(models.Model):
    name = models.CharField(max_length=30)
    point = models.PointField()

    objects = models.GeoManager()

    class Meta:
        app_label = 'geoadmin'

    def __str__(self):
        return self.name

+29 −29
Original line number Diff line number Diff line
@@ -7,66 +7,66 @@ null_flag = not mysql


@python_2_unicode_compatible
class Country(models.Model):
class NamedModel(models.Model):
    name = models.CharField(max_length=30)
    mpoly = models.MultiPolygonField()  # SRID, by default, is 4326

    objects = models.GeoManager()

    class Meta:
        abstract = True
        app_label = 'geoapp'

    def __str__(self):
        return self.name

class Country(NamedModel):
    mpoly = models.MultiPolygonField()  # SRID, by default, is 4326

@python_2_unicode_compatible
class City(models.Model):
    name = models.CharField(max_length=30)
    point = models.PointField()
    objects = models.GeoManager()

    def __str__(self):
        return self.name
class City(NamedModel):
    point = models.PointField()


# This is an inherited model from City
class PennsylvaniaCity(City):
    county = models.CharField(max_length=30)
    founded = models.DateTimeField(null=True)
    objects = models.GeoManager()  # TODO: This should be implicitly inherited.

    # TODO: This should be implicitly inherited.

@python_2_unicode_compatible
class State(models.Model):
    name = models.CharField(max_length=30)
    poly = models.PolygonField(null=null_flag)  # Allowing NULL geometries here.
    objects = models.GeoManager()

    def __str__(self):
        return self.name
    class Meta:
       app_label = 'geoapp'


@python_2_unicode_compatible
class Track(models.Model):
    name = models.CharField(max_length=30)
    line = models.LineStringField()
    objects = models.GeoManager()
class State(NamedModel):
    poly = models.PolygonField(null=null_flag)  # Allowing NULL geometries here.

    def __str__(self):
        return self.name

class Track(NamedModel):
    line = models.LineStringField()


class Truth(models.Model):
    val = models.BooleanField(default=False)

    objects = models.GeoManager()

    class Meta:
        app_label = 'geoapp'


if not spatialite:
    @python_2_unicode_compatible
    class Feature(models.Model):
        name = models.CharField(max_length=20)

    class Feature(NamedModel):
        geom = models.GeometryField()
        objects = models.GeoManager()

        def __str__(self):
            return self.name

    class MinusOneSRID(models.Model):
        geom = models.PointField(srid=-1)  # Minus one SRID.

        objects = models.GeoManager()

        class Meta:
            app_label = 'geoapp'
+12 −13
Original line number Diff line number Diff line
@@ -3,31 +3,30 @@ from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class City(models.Model):
class NamedModel(models.Model):
    name = models.CharField(max_length=30)
    point = models.PointField(geography=True)

    objects = models.GeoManager()

    class Meta:
        abstract = True
        app_label = 'geogapp'

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class Zipcode(models.Model):
    code = models.CharField(max_length=10)
    poly = models.PolygonField(geography=True)
    objects = models.GeoManager()
class City(NamedModel):
    point = models.PointField(geography=True)

    def __str__(self):
        return self.code

class Zipcode(NamedModel):
    poly = models.PolygonField(geography=True)


@python_2_unicode_compatible
class County(models.Model):
    name = models.CharField(max_length=25)
class County(NamedModel):
    state = models.CharField(max_length=20)
    mpoly = models.MultiPolygonField(geography=True)
    objects = models.GeoManager()

    def __str__(self):
        return ' County, '.join([self.name, self.state])
Loading