Cast a geography to a geometry field for an aggregate function that expects a geometry input.
(self)
| 120 | |
| 121 | @skipUnlessDBFeature("supports_extent_aggr") |
| 122 | def test_cast_aggregate(self): |
| 123 | """ |
| 124 | Cast a geography to a geometry field for an aggregate function that |
| 125 | expects a geometry input. |
| 126 | """ |
| 127 | if not connection.features.supports_geography: |
| 128 | self.skipTest("This test needs geography support") |
| 129 | expected = ( |
| 130 | -96.8016128540039, |
| 131 | 29.7633724212646, |
| 132 | -95.3631439208984, |
| 133 | 32.782058715820, |
| 134 | ) |
| 135 | res = City.objects.filter(name__in=("Houston", "Dallas")).aggregate( |
| 136 | extent=models.Extent(Cast("point", models.PointField())) |
| 137 | ) |
| 138 | for val, exp in zip(res["extent"], expected): |
| 139 | self.assertAlmostEqual(exp, val, 4) |
| 140 | |
| 141 | @skipUnlessDBFeature("has_Distance_function", "supports_distance_geodetic") |
| 142 | def test_distance_function(self): |