def test_translate(self): xfac, yfac = 5, -23 qs = Country.objects.annotate(translated=functions.Translate('mpoly', xfac, yfac)) for c in qs: for p1, p2 in zip(c.mpoly, c.translated): for r1, r2 in zip(p1, p2): for c1, c2 in zip(r1.coords, r2.coords): # The low precision is for SpatiaLite self.assertAlmostEqual(c1[0] + xfac, c2[0], 5) self.assertAlmostEqual(c1[1] + yfac, c2[1], 5)
def test_update_with_expression(self): city = City.objects.create(point=Point(1, 1, srid=4326)) City.objects.filter(pk=city.pk).update(point=functions.Translate("point", 1, 1)) city.refresh_from_db() self.assertEqual(city.point, Point(2, 2, srid=4326))
def _trans_scale(self, colname, deltax, deltay, xfactor, yfactor): if connection.ops.spatialite: return geofn.Scale(geofn.Translate(colname, deltax, deltay), xfactor, yfactor) else: return TransScale(colname, deltax, deltay, xfactor, yfactor)