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
183f5015
Kaydet (Commit)
183f5015
authored
Haz 17, 2016
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Ara 06, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26789 -- Fixed handling of empty geometries in BaseSpatialField.get_db_prep_save().
üst
b90d72fa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
5 deletions
+31
-5
features.py
django/contrib/gis/db/backends/base/features.py
+2
-0
features.py
django/contrib/gis/db/backends/postgis/features.py
+1
-0
fields.py
django/contrib/gis/db/models/fields.py
+3
-3
tests.py
tests/gis_tests/geoapp/tests.py
+25
-2
No files found.
django/contrib/gis/db/backends/base/features.py
Dosyayı görüntüle @
183f5015
...
...
@@ -26,6 +26,8 @@ class BaseSpatialFeatures(object):
supports_real_shape_operations
=
True
# Can geometry fields be null?
supports_null_geometries
=
True
# Are empty geometries supported?
supports_empty_geometries
=
False
# Can the the function be applied on geodetic coordinate systems?
supports_distance_geodetic
=
True
supports_length_geodetic
=
True
...
...
django/contrib/gis/db/backends/postgis/features.py
Dosyayı görüntüle @
183f5015
...
...
@@ -8,3 +8,4 @@ class DatabaseFeatures(BaseSpatialFeatures, Psycopg2DatabaseFeatures):
supports_3d_functions
=
True
supports_left_right_lookups
=
True
supports_raster
=
True
supports_empty_geometries
=
True
django/contrib/gis/db/models/fields.py
Dosyayı görüntüle @
183f5015
...
...
@@ -177,10 +177,10 @@ class BaseSpatialField(Field):
"""
Prepare the value for saving in the database.
"""
if
not
value
:
return
None
else
:
if
isinstance
(
value
,
Geometry
)
or
value
:
return
connection
.
ops
.
Adapter
(
self
.
get_prep_value
(
value
))
else
:
return
None
def
get_raster_prep_value
(
self
,
value
,
is_candidate
):
"""
...
...
tests/gis_tests/geoapp/tests.py
Dosyayı görüntüle @
183f5015
...
...
@@ -6,8 +6,8 @@ import tempfile
from
django.contrib.gis
import
gdal
from
django.contrib.gis.db.models
import
Extent
,
MakeLine
,
Union
from
django.contrib.gis.geos
import
(
GeometryCollection
,
GEOSGeometry
,
LinearRing
,
LineString
,
Point
,
Polygon
,
fromstr
,
GeometryCollection
,
GEOSGeometry
,
LinearRing
,
LineString
,
MultiLineString
,
MultiPoint
,
MultiPolygon
,
Point
,
Polygon
,
fromstr
,
)
from
django.core.management
import
call_command
from
django.db
import
connection
...
...
@@ -215,6 +215,29 @@ class GeoModelTest(TestCase):
call_command
(
'loaddata'
,
tmp
.
name
,
verbosity
=
0
)
self
.
assertListEqual
(
original_data
,
list
(
City
.
objects
.
all
()
.
order_by
(
'name'
)))
@skipUnlessDBFeature
(
"supports_empty_geometries"
)
def
test_empty_geometries
(
self
):
geometry_classes
=
[
Point
,
LineString
,
LinearRing
,
Polygon
,
MultiPoint
,
MultiLineString
,
MultiPolygon
,
GeometryCollection
,
]
for
klass
in
geometry_classes
:
g
=
klass
(
srid
=
4326
)
feature
=
Feature
.
objects
.
create
(
name
=
'Empty
%
s'
%
klass
.
__name__
,
geom
=
g
)
feature
.
refresh_from_db
()
if
klass
is
LinearRing
:
# LinearRing isn't representable in WKB, so GEOSGeomtry.wkb
# uses LineString instead.
g
=
LineString
(
srid
=
4326
)
self
.
assertEqual
(
feature
.
geom
,
g
)
self
.
assertEqual
(
feature
.
geom
.
srid
,
g
.
srid
)
@skipUnlessDBFeature
(
"gis_enabled"
)
class
GeoLookupTest
(
TestCase
):
...
...
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