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
f909fa84
Kaydet (Commit)
f909fa84
authored
Kas 09, 2015
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Ara 07, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25708 -- Fixed annotations with geometry values.
üst
4a246a02
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
0 deletions
+39
-0
fields.py
django/contrib/gis/db/models/fields.py
+6
-0
expressions.py
django/db/models/expressions.py
+2
-0
test_expressions.py
tests/gis_tests/geoapp/test_expressions.py
+31
-0
No files found.
django/contrib/gis/db/models/fields.py
Dosyayı görüntüle @
f909fa84
...
...
@@ -312,6 +312,12 @@ class GeometryField(GeoSelectFormatMixin, BaseSpatialField):
"""
return
connection
.
ops
.
get_distance
(
self
,
value
,
lookup_type
)
def
get_db_prep_value
(
self
,
value
,
connection
,
*
args
,
**
kwargs
):
return
connection
.
ops
.
Adapter
(
super
(
GeometryField
,
self
)
.
get_db_prep_value
(
value
,
connection
,
*
args
,
**
kwargs
),
**
({
'geography'
:
True
}
if
self
.
geography
else
{})
)
def
from_db_value
(
self
,
value
,
expression
,
connection
,
context
):
if
value
:
if
not
isinstance
(
value
,
Geometry
):
...
...
django/db/models/expressions.py
Dosyayı görüntüle @
f909fa84
...
...
@@ -579,6 +579,8 @@ class Value(Expression):
val
=
self
.
output_field
.
get_db_prep_save
(
val
,
connection
=
connection
)
else
:
val
=
self
.
output_field
.
get_db_prep_value
(
val
,
connection
=
connection
)
if
hasattr
(
self
.
_output_field
,
'get_placeholder'
):
return
self
.
_output_field
.
get_placeholder
(
val
,
compiler
,
connection
),
[
val
]
if
val
is
None
:
# cx_Oracle does not always convert None to the appropriate
# NULL type (like in case expressions using numbers), so we
...
...
tests/gis_tests/geoapp/test_expressions.py
0 → 100644
Dosyayı görüntüle @
f909fa84
from
unittest
import
skipUnless
from
django.contrib.gis.db.models
import
GeometryField
,
Value
,
functions
from
django.contrib.gis.geos
import
Point
,
Polygon
from
django.test
import
TestCase
,
skipUnlessDBFeature
from
..utils
import
postgis
from
.models
import
City
@skipUnlessDBFeature
(
'gis_enabled'
)
class
GeoExpressionsTests
(
TestCase
):
fixtures
=
[
'initial'
]
def
test_geometry_value_annotation
(
self
):
p
=
Point
(
1
,
1
,
srid
=
4326
)
point
=
City
.
objects
.
annotate
(
p
=
Value
(
p
,
GeometryField
(
srid
=
4326
)))
.
first
()
.
p
self
.
assertEqual
(
point
,
p
)
@skipUnlessDBFeature
(
'supports_transform'
)
def
test_geometry_value_annotation_different_srid
(
self
):
p
=
Point
(
1
,
1
,
srid
=
32140
)
point
=
City
.
objects
.
annotate
(
p
=
Value
(
p
,
GeometryField
(
srid
=
4326
)))
.
first
()
.
p
self
.
assertTrue
(
point
.
equals_exact
(
p
.
transform
(
4326
,
clone
=
True
),
10
**
-
5
))
self
.
assertEqual
(
point
.
srid
,
4326
)
@skipUnless
(
postgis
,
'Only postgis has geography fields.'
)
def
test_geography_value
(
self
):
p
=
Polygon
(((
1
,
1
),
(
1
,
2
),
(
2
,
2
),
(
2
,
1
),
(
1
,
1
)))
area
=
City
.
objects
.
annotate
(
a
=
functions
.
Area
(
Value
(
p
,
GeometryField
(
srid
=
4326
,
geography
=
True
))))
.
first
()
.
a
self
.
assertAlmostEqual
(
area
.
sq_km
,
12305.1
,
0
)
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