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
e2bd2539
Kaydet (Commit)
e2bd2539
authored
Mar 31, 2017
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Nis 07, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Made get_srid_info() cache use a namedtuple.
üst
24ae244a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
fields.py
django/contrib/gis/db/models/fields.py
+12
-7
No files found.
django/contrib/gis/db/models/fields.py
Dosyayı görüntüle @
e2bd2539
from
collections
import
defaultdict
from
collections
import
defaultdict
,
namedtuple
from
django.contrib.gis
import
forms
,
gdal
from
django.contrib.gis.db.models.proxy
import
SpatialProxy
...
...
@@ -15,6 +15,9 @@ from django.utils.translation import gettext_lazy as _
_srid_cache
=
defaultdict
(
dict
)
SRIDCacheEntry
=
namedtuple
(
'SRIDCacheEntry'
,
[
'units'
,
'units_name'
,
'spheroid'
])
def
get_srid_info
(
srid
,
connection
):
"""
Return the units, unit name, and spheroid WKT associated with the
...
...
@@ -38,9 +41,11 @@ def get_srid_info(srid, connection):
if
srid
not
in
_srid_cache
[
alias
]:
srs
=
get_srs
(
srid
)
units
,
units_name
=
srs
.
units
sphere_name
=
srs
[
'spheroid'
]
spheroid
=
'SPHEROID["
%
s",
%
s,
%
s]'
%
(
sphere_name
,
srs
.
semi_major
,
srs
.
inverse_flattening
)
_srid_cache
[
alias
][
srid
]
=
(
units
,
units_name
,
spheroid
)
_srid_cache
[
alias
][
srid
]
=
SRIDCacheEntry
(
units
=
units
,
units_name
=
units_name
,
spheroid
=
'SPHEROID["
%
s",
%
s,
%
s]'
%
(
srs
[
'spheroid'
],
srs
.
semi_major
,
srs
.
inverse_flattening
),
)
return
_srid_cache
[
alias
][
srid
]
...
...
@@ -116,13 +121,13 @@ class BaseSpatialField(Field):
return
connection
.
ops
.
geo_db_type
(
self
)
def
spheroid
(
self
,
connection
):
return
get_srid_info
(
self
.
srid
,
connection
)
[
2
]
return
get_srid_info
(
self
.
srid
,
connection
)
.
spheroid
def
units
(
self
,
connection
):
return
get_srid_info
(
self
.
srid
,
connection
)
[
0
]
return
get_srid_info
(
self
.
srid
,
connection
)
.
units
def
units_name
(
self
,
connection
):
return
get_srid_info
(
self
.
srid
,
connection
)
[
1
]
return
get_srid_info
(
self
.
srid
,
connection
)
.
units_name
def
geodetic
(
self
,
connection
):
"""
...
...
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