Reputation:
I didnt find any documentation about geo dgango that contains details about the fields. Only this https://docs.djangoproject.com/en/1.9/ref/contrib/gis/model-api/#django.contrib.gis.db.models.MultiPolygonField but as you can see it is not telling us what is inside the fields and how to get it... Where can I find a deep view on the fields of geodjango such as MultiPolygonField ?
Im trying to extract all the points that are in MultiPolygonField. I tried:
mpoly = models.MultiPolygonField(srid=4326, null=False, blank=False)
def get_tooltip_title(self):
result = "Polygon: [["
for poly in self.mpoly.choices:
for point in poly.coordinates:
result += "("
result += str(point.x)
result += ","
result += str(point.y)
result += "),"
result += "],"
result += "]"
return result
But there is no "choises" in the field and I didnt found any good documentation about the field. So how can I get the points of a MultiPolygonField?
Upvotes: 0
Views: 1022
Reputation: 53734
Though geodjango MultiPolygon isn't very well documented, mysql multipolygon is
A MultiPolygon is a MultiSurface object composed of Polygon elements.
MultiPolygon Examples
On a region map, a MultiPolygon could represent a system of lakes.
The postgis MultiPolygon is also very well documented with a few visual examples.
Basically a MultiPolygon is a collection of elements that may touch but not intersect.
Upvotes: 0
Reputation:
Ok, this is so stupid. There is no good documentation?!
I found the solution in someones post from 2009 http://www.paolocorti.net/2009/04/01/a-day-with-geodjango/ . It is like:
class LocationPolygon(models.Model):
mpoly = models.MultiPolygonField(srid=4326, null=False, blank=False)
objects = models.GeoManager()
def get_tooltip_title(self):
return str(self.mpoly.coords)
Upvotes: 1