| 44 | | pnt = self.stx_pnt |
|---|
| 45 | | dists = [7000, D(km=7), D(mi=4.349)] |
|---|
| 46 | | for dist in dists: |
|---|
| | 44 | # Distances -- all should be equal (except for the |
|---|
| | 45 | # degree/meter pair in au_cities, that's somewhat |
|---|
| | 46 | # approximate). |
|---|
| | 47 | tx_dists = [7000, D(km=7), D(mi=4.349)] |
|---|
| | 48 | au_dists = [(0.5, 32000), D(km=32), D(mi=19.884)] |
|---|
| | 49 | |
|---|
| | 50 | # Expected cities for Australia and Texas. |
|---|
| | 51 | tx_cities = ['Downtown Houston', 'Southside Place'] |
|---|
| | 52 | au_cities = ['Mittagong', 'Shellharbour', 'Thirroul', 'Wollongong'] |
|---|
| | 53 | |
|---|
| | 54 | for dist in tx_dists: |
|---|
| 50 | | if isinstance(dist, D): |
|---|
| 51 | | # A TypeError should be raised when trying to pass Distance objects |
|---|
| 52 | | # into a DWithin query using a geodetic field. |
|---|
| 53 | | qs = AustraliaCity.objects.filter(point__dwithin=(self.au_pnt, dist)) |
|---|
| | 58 | for dist in au_dists: |
|---|
| | 59 | if isinstance(dist, D) and not oracle: type_error = True |
|---|
| | 60 | else: type_error = False |
|---|
| | 61 | |
|---|
| | 62 | if isinstance(dist, tuple): |
|---|
| | 63 | if oracle: dist = dist[1] |
|---|
| | 64 | else: dist = dist[0] |
|---|
| | 65 | |
|---|
| | 66 | # Creating the query set. |
|---|
| | 67 | qs = AustraliaCity.objects.filter(point__dwithin=(self.au_pnt, dist)).order_by('name') |
|---|
| | 68 | if type_error: |
|---|
| | 69 | # A TypeError should be raised on PostGIS when trying to pass |
|---|
| | 70 | # Distance objects into a DWithin query using a geodetic field. |
|---|