summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2016-12-15 22:15:08 +0500
committerTim Graham <timograham@gmail.com>2016-12-15 12:40:04 -0500
commitd013134ffb1e03cefa6ab0d987b72ac9231580d7 (patch)
treeaf097324740746655a7161c161ea79bbd80d2665
parentbf84d042e0bba636fe2199051fe25e96d89865da (diff)
Improved testing of num_seg kwarg of BoundingCircle GIS function.
-rw-r--r--tests/gis_tests/geoapp/test_functions.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py
index a2c172b001..3ce72b9d21 100644
--- a/tests/gis_tests/geoapp/test_functions.py
+++ b/tests/gis_tests/geoapp/test_functions.py
@@ -147,16 +147,25 @@ class GISFunctionsTests(TestCase):
@skipUnlessDBFeature("has_BoundingCircle_function")
def test_bounding_circle(self):
+ def circle_num_points(num_seg):
+ # num_seg is the number of segments per quarter circle.
+ return (4 * num_seg) + 1
+
# The weak precision in the assertions is because the BoundingCircle
# calculation changed on PostGIS 2.3.
qs = Country.objects.annotate(circle=functions.BoundingCircle('mpoly')).order_by('name')
self.assertAlmostEqual(qs[0].circle.area, 169, 0)
self.assertAlmostEqual(qs[1].circle.area, 136, 0)
+ # By default num_seg=48.
+ self.assertEqual(qs[0].circle.num_points, circle_num_points(48))
+ self.assertEqual(qs[1].circle.num_points, circle_num_points(48))
qs = Country.objects.annotate(circle=functions.BoundingCircle('mpoly', num_seg=12)).order_by('name')
self.assertGreater(qs[0].circle.area, 168.4, 0)
self.assertLess(qs[0].circle.area, 169.5, 0)
self.assertAlmostEqual(qs[1].circle.area, 136, 0)
+ self.assertEqual(qs[0].circle.num_points, circle_num_points(12))
+ self.assertEqual(qs[1].circle.num_points, circle_num_points(12))
@skipUnlessDBFeature("has_Centroid_function")
def test_centroid(self):