1 | Index: contrib/gis/db/models/fields/__init__.py
|
---|
2 | ===================================================================
|
---|
3 | --- contrib/gis/db/models/fields/__init__.py (revision 5178)
|
---|
4 | +++ contrib/gis/db/models/fields/__init__.py (working copy)
|
---|
5 | @@ -64,6 +64,7 @@
|
---|
6 | setattr(cls, 'get_%s_wkt' % self.name, curry(cls._get_GEOM_wkt, field=self))
|
---|
7 | setattr(cls, 'get_%s_centroid' % self.name, curry(cls._get_GEOM_centroid, field=self))
|
---|
8 | setattr(cls, 'get_%s_area' % self.name, curry(cls._get_GEOM_area, field=self))
|
---|
9 | + setattr(cls, 'get_%s_convex_hull' % self.name, curry(cls._get_GEOM_convex_hull, field=self))
|
---|
10 |
|
---|
11 | def get_internal_type(self):
|
---|
12 | return "NoField"
|
---|
13 | Index: contrib/gis/db/models/GeoMixin.py
|
---|
14 | ===================================================================
|
---|
15 | --- contrib/gis/db/models/GeoMixin.py (revision 5178)
|
---|
16 | +++ contrib/gis/db/models/GeoMixin.py (working copy)
|
---|
17 | @@ -1,5 +1,5 @@
|
---|
18 | # GEOS Routines
|
---|
19 | -from django.contrib.gis.geos import GEOSGeometry, hex_to_wkt, centroid, area
|
---|
20 | +from django.contrib.gis.geos import GEOSGeometry, hex_to_wkt, centroid, area, convex_hull
|
---|
21 |
|
---|
22 | # Until model subclassing is a possibility, a mixin class is used to add
|
---|
23 | # the necessary functions that may be contributed for geographic objects.
|
---|
24 | @@ -27,4 +27,8 @@
|
---|
25 | hex = getattr(self, field.attname)
|
---|
26 | return area(hex)
|
---|
27 |
|
---|
28 | + def _get_GEOM_convex_hull(self, field):
|
---|
29 | + "Gets the convex hull of the geometry."
|
---|
30 | + hex = getattr(self, field.attname)
|
---|
31 | + return convex_hull(hex)
|
---|
32 |
|
---|
33 | Index: contrib/gis/geos/__init__.py
|
---|
34 | ===================================================================
|
---|
35 | --- contrib/gis/geos/__init__.py (revision 5178)
|
---|
36 | +++ contrib/gis/geos/__init__.py (working copy)
|
---|
37 | @@ -15,4 +15,7 @@
|
---|
38 | def area(input, geom_type='hex'):
|
---|
39 | "Returns the area of the geometry (given in HEXEWKB)."
|
---|
40 | return GEOSGeometry(input, geom_type).area
|
---|
41 | -
|
---|
42 | +
|
---|
43 | +def convex_hull(input, geom_type='hex'):
|
---|
44 | + "Returns the convex hull of the geometry"
|
---|
45 | + return GEOSGeometry(input, geom_type).convex_hull
|
---|