Esempio n. 1
0
 def test_create(self):
     category = mommy.make(models.GareaCategory)
     garea = models.Garea(
         name="Esgalduin",
         category=category,
         geom=MultiPolygon(Polygon(((30, 20), (45, 40), (10, 40), (30, 20)))),
     )
     garea.save()
     self.assertEqual(models.Garea.objects.first().name, "Esgalduin")
Esempio n. 2
0
 def _get_garea(self, feature, category):
     garea = models.Garea()
     if isinstance(feature.geom.geos, MultiPolygon):
         garea.geom = feature.geom.geos
     else:
         garea.geom = MultiPolygon(feature.geom.geos)
     garea.name = self._get_feature_attr(feature, "Name")
     garea.code = self._get_feature_attr(feature, "Code",
                                         allow_empty=True) or ""
     garea.category = category
     return garea