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
e7a56eb4
Kaydet (Commit)
e7a56eb4
authored
Haz 19, 2018
tarafından
Melvyn Sopacua
Kaydeden (comit)
Tim Graham
Tem 27, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28659 -- Fixed LayerMapping crash with null geometry and unique.
üst
c72dde41
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
5 deletions
+20
-5
layermapping.py
django/contrib/gis/utils/layermapping.py
+8
-4
models.py
tests/gis_tests/layermap/models.py
+1
-1
tests.py
tests/gis_tests/layermap/tests.py
+11
-0
No files found.
django/contrib/gis/utils/layermapping.py
Dosyayı görüntüle @
e7a56eb4
...
...
@@ -558,10 +558,14 @@ class LayerMapping:
# one from the kwargs WKT, adding in additional
# geometries, and update the attribute with the
# just-updated geometry WKT.
geom
=
getattr
(
m
,
self
.
geom_field
)
.
ogr
new
=
OGRGeometry
(
kwargs
[
self
.
geom_field
])
for
g
in
new
:
geom
.
add
(
g
)
geom_value
=
getattr
(
m
,
self
.
geom_field
)
if
geom_value
is
None
:
geom
=
OGRGeometry
(
kwargs
[
self
.
geom_field
])
else
:
geom
=
geom_value
.
ogr
new
=
OGRGeometry
(
kwargs
[
self
.
geom_field
])
for
g
in
new
:
geom
.
add
(
g
)
setattr
(
m
,
self
.
geom_field
,
geom
.
wkt
)
except
ObjectDoesNotExist
:
# No unique model exists yet, create.
...
...
tests/gis_tests/layermap/models.py
Dosyayı görüntüle @
e7a56eb4
...
...
@@ -17,7 +17,7 @@ class State(NamedModel):
class
County
(
NamedModel
):
state
=
models
.
ForeignKey
(
State
,
models
.
CASCADE
)
mpoly
=
models
.
MultiPolygonField
(
srid
=
4269
)
# Multipolygon in NAD83
mpoly
=
models
.
MultiPolygonField
(
srid
=
4269
,
null
=
True
)
# Multipolygon in NAD83
class
CountyFeat
(
NamedModel
):
...
...
tests/gis_tests/layermap/tests.py
Dosyayı görüntüle @
e7a56eb4
...
...
@@ -310,6 +310,17 @@ class LayerMapTest(TestCase):
self
.
assertEqual
(
City
.
objects
.
count
(),
1
)
self
.
assertEqual
(
City
.
objects
.
all
()[
0
]
.
name
,
"Zürich"
)
def
test_null_geom_with_unique
(
self
):
"""LayerMapping may be created with a unique and a null geometry."""
State
.
objects
.
bulk_create
([
State
(
name
=
'Colorado'
),
State
(
name
=
'Hawaii'
),
State
(
name
=
'Texas'
)])
hw
=
State
.
objects
.
get
(
name
=
'Hawaii'
)
hu
=
County
.
objects
.
create
(
name
=
'Honolulu'
,
state
=
hw
,
mpoly
=
None
)
lm
=
LayerMapping
(
County
,
co_shp
,
co_mapping
,
transform
=
False
,
unique
=
'name'
)
lm
.
save
(
silent
=
True
,
strict
=
True
)
hu
.
refresh_from_db
()
self
.
assertIsNotNone
(
hu
.
mpoly
)
self
.
assertEqual
(
hu
.
mpoly
.
ogr
.
num_coords
,
449
)
class
OtherRouter
:
def
db_for_read
(
self
,
model
,
**
hints
):
...
...
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