'Testing Length() function on 3D fields.'

def test_length(self):

    self._load_interstate_data()
    tol = 3
    ref_length_2d = 4368.1721949481
    ref_length_3d = 4368.62547052088
    inter2d = Interstate2D.objects.annotate(length=Length('line')).get(name='I-45')
    self.assertAlmostEqual(ref_length_2d, inter2d.length.m, tol)
    inter3d = Interstate3D.objects.annotate(length=Length('line')).get(name='I-45')
    self.assertAlmostEqual(ref_length_3d, inter3d.length.m, tol)
    ref_length_2d = 4367.71564892392
    ref_length_3d = 4368.16897234101
    inter2d = InterstateProj2D.objects.annotate(length=Length('line')).get(name='I-45')
    self.assertAlmostEqual(ref_length_2d, inter2d.length.m, tol)
    inter3d = InterstateProj3D.objects.annotate(length=Length('line')).get(name='I-45')
    self.assertAlmostEqual(ref_length_3d, inter3d.length.m, tol)
