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
a4f9ef4f
Kaydet (Commit)
a4f9ef4f
authored
Kas 07, 2017
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Kas 07, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #28518 -- Improved performance of assigning values to GeometryFields.
üst
c69e4bc6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
fields.py
django/contrib/gis/db/models/fields.py
+1
-1
proxy.py
django/contrib/gis/db/models/proxy.py
+4
-3
No files found.
django/contrib/gis/db/models/fields.py
Dosyayı görüntüle @
a4f9ef4f
...
@@ -247,7 +247,7 @@ class GeometryField(BaseSpatialField):
...
@@ -247,7 +247,7 @@ class GeometryField(BaseSpatialField):
super
()
.
contribute_to_class
(
cls
,
name
,
**
kwargs
)
super
()
.
contribute_to_class
(
cls
,
name
,
**
kwargs
)
# Setup for lazy-instantiated Geometry object.
# Setup for lazy-instantiated Geometry object.
setattr
(
cls
,
self
.
attname
,
SpatialProxy
(
GEOSGeometry
,
self
))
setattr
(
cls
,
self
.
attname
,
SpatialProxy
(
self
.
geom_class
or
GEOSGeometry
,
self
,
load_func
=
GEOSGeometry
))
def
formfield
(
self
,
**
kwargs
):
def
formfield
(
self
,
**
kwargs
):
defaults
=
{
'form_class'
:
self
.
form_class
,
defaults
=
{
'form_class'
:
self
.
form_class
,
...
...
django/contrib/gis/db/models/proxy.py
Dosyayı görüntüle @
a4f9ef4f
...
@@ -9,13 +9,14 @@ from django.db.models.query_utils import DeferredAttribute
...
@@ -9,13 +9,14 @@ from django.db.models.query_utils import DeferredAttribute
class
SpatialProxy
(
DeferredAttribute
):
class
SpatialProxy
(
DeferredAttribute
):
def
__init__
(
self
,
klass
,
field
):
def
__init__
(
self
,
klass
,
field
,
load_func
=
None
):
"""
"""
Initialize on the given Geometry or Raster class (not an instance)
Initialize on the given Geometry or Raster class (not an instance)
and the corresponding field.
and the corresponding field.
"""
"""
self
.
_field
=
field
self
.
_field
=
field
self
.
_klass
=
klass
self
.
_klass
=
klass
self
.
_load_func
=
load_func
or
klass
super
()
.
__init__
(
field
.
attname
,
klass
)
super
()
.
__init__
(
field
.
attname
,
klass
)
def
__get__
(
self
,
instance
,
cls
=
None
):
def
__get__
(
self
,
instance
,
cls
=
None
):
...
@@ -42,7 +43,7 @@ class SpatialProxy(DeferredAttribute):
...
@@ -42,7 +43,7 @@ class SpatialProxy(DeferredAttribute):
else
:
else
:
# Otherwise, a geometry or raster object is built using the field's
# Otherwise, a geometry or raster object is built using the field's
# contents, and the model's corresponding attribute is set.
# contents, and the model's corresponding attribute is set.
geo_obj
=
self
.
_
klass
(
geo_value
)
geo_obj
=
self
.
_
load_func
(
geo_value
)
setattr
(
instance
,
self
.
_field
.
attname
,
geo_obj
)
setattr
(
instance
,
self
.
_field
.
attname
,
geo_obj
)
return
geo_obj
return
geo_obj
...
@@ -61,7 +62,7 @@ class SpatialProxy(DeferredAttribute):
...
@@ -61,7 +62,7 @@ class SpatialProxy(DeferredAttribute):
# For raster fields, assure input is None or a string, dict, or
# For raster fields, assure input is None or a string, dict, or
# raster instance.
# raster instance.
pass
pass
elif
isinstance
(
value
,
self
.
_klass
)
and
(
str
(
value
.
geom_type
)
.
upper
()
==
gtype
or
gtype
==
'GEOMETRY'
)
:
elif
isinstance
(
value
,
self
.
_klass
):
# The geometry type must match that of the field -- unless the
# The geometry type must match that of the field -- unless the
# general GeometryField is used.
# general GeometryField is used.
if
value
.
srid
is
None
:
if
value
.
srid
is
None
:
...
...
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