GIS fields #12

Open
ouhouhsami opened this Issue Jun 9, 2011 · 1 comment

Comments

Projects
None yet
1 participant

It could be interesting to have generator for geographic fields.

GeometryField
PointField
LineStringField
PolygonField
MultiPointField
MultiLineStringField
MultiPolygonField
GeometryCollectionField

Could you give me a way to add support to these types of field ?

Thx

a first generator for pointfield, (we should ad srid value, this example is for google srid) :

class GeoPointGenerator(generators.Generator):
    def __init__(self, *args, **kwargs):
        super(GeoPointGenerator, self).__init__(*args, **kwargs)

    def generate(self):
        coord_0 = decimal.Decimal(str(random.randrange(2003750834)/100 - 20037508.34/2))
        coord_1 = decimal.Decimal(str(random.randrange(2003750834)/100 - 20037508.34/2))
        value = 'POINT(%s %s)' % (coord_0, coord_1)
        return value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment