Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
717a54c8
Kaydet (Commit)
717a54c8
authored
Kas 25, 2015
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Ara 04, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25797 -- Fixed regex for getting units from SRS WKT.
üst
b52b9cf6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
25 deletions
+26
-25
models.py
django/contrib/gis/db/backends/base/models.py
+1
-6
tests.py
tests/gis_tests/distapp/tests.py
+25
-19
No files found.
django/contrib/gis/db/backends/base/models.py
Dosyayı görüntüle @
717a54c8
...
...
@@ -21,12 +21,7 @@ class SpatialRefSysMixin(object):
# TODO: Figure out how to pull out angular units of projected coordinate system and
# fix for LOCAL_CS types. GDAL should be highly recommended for performing
# distance queries.
units_regex
=
re
.
compile
(
r'.+UNIT ?\["(?P<unit_name>[\w \'\(\)]+)", ?(?P<unit>[\d\.]+)'
r'(,AUTHORITY\["(?P<unit_auth_name>[\w \'\(\)]+)",'
r'"(?P<unit_auth_val>\d+)"\])?\]([\w ]+)?(,'
r'AUTHORITY\["(?P<auth_name>[\w \'\(\)]+)","(?P<auth_val>\d+)"\])?\]$'
)
units_regex
=
re
.
compile
(
r'.+UNIT ?\["(?P<unit_name>[\w \.\'\(\)]+)", ?(?P<unit>[^ ,\]]+)'
,
re
.
DOTALL
)
@property
def
srs
(
self
):
...
...
tests/gis_tests/distapp/tests.py
Dosyayı görüntüle @
717a54c8
from
__future__
import
unicode_literals
from
unittest
import
skipUnless
from
django.contrib.gis.db.models.functions
import
(
Area
,
Distance
,
Length
,
Perimeter
,
Transform
,
)
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.geos
import
GEOSGeometry
,
LineString
,
Point
from
django.contrib.gis.measure
import
D
# alias for Distance
from
django.db
import
connection
from
django.db.models
import
F
,
Q
from
django.test
import
TestCase
,
ignore_warnings
,
skipUnlessDBFeature
from
django.test
import
TestCase
,
ignore_warnings
,
mock
,
skipUnlessDBFeature
from
django.utils.deprecation
import
RemovedInDjango20Warning
from
..utils
import
no_oracle
,
oracle
,
postgis
...
...
@@ -487,6 +490,7 @@ class DistanceFunctionsTests(TestCase):
tol
)
@skipUnless
(
HAS_GDAL
,
"GDAL is required."
)
@skipUnlessDBFeature
(
"has_Distance_function"
,
"has_Transform_function"
)
def
test_distance_projected
(
self
):
"""
...
...
@@ -509,24 +513,26 @@ class DistanceFunctionsTests(TestCase):
455411.438904354
,
519386.252102563
,
696139.009211594
,
232513.278304279
,
542445.630586414
,
456679.155883207
]
# Testing using different variations of parameters and using models
# with different projected coordinate systems.
dist1
=
SouthTexasCity
.
objects
.
annotate
(
distance
=
Distance
(
'point'
,
lagrange
))
.
order_by
(
'id'
)
if
oracle
:
dist_qs
=
[
dist1
]
else
:
dist2
=
SouthTexasCityFt
.
objects
.
annotate
(
distance
=
Distance
(
'point'
,
lagrange
))
.
order_by
(
'id'
)
dist_qs
=
[
dist1
,
dist2
]
# Original query done on PostGIS, have to adjust AlmostEqual tolerance
# for Oracle.
tol
=
2
if
oracle
else
5
# Ensuring expected distances are returned for each distance queryset.
for
qs
in
dist_qs
:
for
i
,
c
in
enumerate
(
qs
):
self
.
assertAlmostEqual
(
m_distances
[
i
],
c
.
distance
.
m
,
tol
)
self
.
assertAlmostEqual
(
ft_distances
[
i
],
c
.
distance
.
survey_ft
,
tol
)
for
has_gdal
in
[
False
,
True
]:
with
mock
.
patch
(
'django.contrib.gis.gdal.HAS_GDAL'
,
has_gdal
):
# Testing using different variations of parameters and using models
# with different projected coordinate systems.
dist1
=
SouthTexasCity
.
objects
.
annotate
(
distance
=
Distance
(
'point'
,
lagrange
))
.
order_by
(
'id'
)
if
oracle
:
dist_qs
=
[
dist1
]
else
:
dist2
=
SouthTexasCityFt
.
objects
.
annotate
(
distance
=
Distance
(
'point'
,
lagrange
))
.
order_by
(
'id'
)
dist_qs
=
[
dist1
,
dist2
]
# Original query done on PostGIS, have to adjust AlmostEqual tolerance
# for Oracle.
tol
=
2
if
oracle
else
5
# Ensuring expected distances are returned for each distance queryset.
for
qs
in
dist_qs
:
for
i
,
c
in
enumerate
(
qs
):
self
.
assertAlmostEqual
(
m_distances
[
i
],
c
.
distance
.
m
,
tol
)
self
.
assertAlmostEqual
(
ft_distances
[
i
],
c
.
distance
.
survey_ft
,
tol
)
@skipUnlessDBFeature
(
"has_Distance_function"
,
"supports_distance_geodetic"
)
def
test_distance_geodetic
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment