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
0193bf87
Kaydet (Commit)
0193bf87
authored
Mar 20, 2019
tarafından
Francisco Couzo
Kaydeden (comit)
Tim Graham
Mar 20, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28738 -- Added the GeometryDistance function.
üst
638d5ea3
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
62 additions
and
22 deletions
+62
-22
AUTHORS
AUTHORS
+1
-0
operations.py
django/contrib/gis/db/backends/base/operations.py
+4
-4
operations.py
django/contrib/gis/db/backends/mysql/operations.py
+3
-3
operations.py
django/contrib/gis/db/backends/oracle/operations.py
+2
-2
operations.py
django/contrib/gis/db/backends/spatialite/operations.py
+1
-1
functions.py
django/contrib/gis/db/models/functions.py
+9
-1
functions.txt
docs/ref/contrib/gis/functions.txt
+24
-11
3.0.txt
docs/releases/3.0.txt
+3
-0
test_functions.py
tests/gis_tests/geoapp/test_functions.py
+15
-0
No files found.
AUTHORS
Dosyayı görüntüle @
0193bf87
...
@@ -282,6 +282,7 @@ answer newbie questions, and generally made Django that much better:
...
@@ -282,6 +282,7 @@ answer newbie questions, and generally made Django that much better:
Florian Apolloner <florian@apolloner.eu>
Florian Apolloner <florian@apolloner.eu>
Florian Moussous <florian.moussous@gmail.com>
Florian Moussous <florian.moussous@gmail.com>
Francisco Albarran Cristobal <pahko.xd@gmail.com>
Francisco Albarran Cristobal <pahko.xd@gmail.com>
Francisco Couzo <franciscouzo@gmail.com>
François Freitag <mail@franek.fr>
François Freitag <mail@franek.fr>
Frank Tegtmeyer <fte@fte.to>
Frank Tegtmeyer <fte@fte.to>
Frank Wierzbicki
Frank Wierzbicki
...
...
django/contrib/gis/db/backends/base/operations.py
Dosyayı görüntüle @
0193bf87
...
@@ -40,10 +40,10 @@ class BaseSpatialOperations:
...
@@ -40,10 +40,10 @@ class BaseSpatialOperations:
unsupported_functions
=
{
unsupported_functions
=
{
'Area'
,
'AsGeoJSON'
,
'AsGML'
,
'AsKML'
,
'AsSVG'
,
'Azimuth'
,
'Area'
,
'AsGeoJSON'
,
'AsGML'
,
'AsKML'
,
'AsSVG'
,
'Azimuth'
,
'BoundingCircle'
,
'Centroid'
,
'Difference'
,
'Distance'
,
'Envelope'
,
'BoundingCircle'
,
'Centroid'
,
'Difference'
,
'Distance'
,
'Envelope'
,
'GeoHash'
,
'
Intersection'
,
'IsValid'
,
'Length'
,
'LineLocatePoint
'
,
'GeoHash'
,
'
GeometryDistance'
,
'Intersection'
,
'IsValid'
,
'Length
'
,
'
MakeValid'
,
'MemSize'
,
'NumGeometries'
,
'NumPoints'
,
'Perimeter
'
,
'
LineLocatePoint'
,
'MakeValid'
,
'MemSize'
,
'NumGeometries
'
,
'
PointOnSurface'
,
'Reverse'
,
'Scale'
,
'SnapToGrid'
,
'SymDifferenc
e'
,
'
NumPoints'
,
'Perimeter'
,
'PointOnSurface'
,
'Reverse'
,
'Scal
e'
,
'Transform'
,
'Translate'
,
'Union'
,
'
SnapToGrid'
,
'SymDifference'
,
'
Transform'
,
'Translate'
,
'Union'
,
}
}
# Constructors
# Constructors
...
...
django/contrib/gis/db/backends/mysql/operations.py
Dosyayı görüntüle @
0193bf87
...
@@ -54,9 +54,9 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
...
@@ -54,9 +54,9 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
def
unsupported_functions
(
self
):
def
unsupported_functions
(
self
):
unsupported
=
{
unsupported
=
{
'AsGML'
,
'AsKML'
,
'AsSVG'
,
'Azimuth'
,
'BoundingCircle'
,
'AsGML'
,
'AsKML'
,
'AsSVG'
,
'Azimuth'
,
'BoundingCircle'
,
'ForcePolygonCW'
,
'
LineLocatePoint'
,
'MakeValid'
,
'MemSize
'
,
'ForcePolygonCW'
,
'
GeometryDistance'
,
'LineLocatePoint
'
,
'
Perimeter'
,
'PointOnSurface'
,
'Reverse'
,
'Scale'
,
'SnapToGrid
'
,
'
MakeValid'
,
'MemSize'
,
'Perimeter'
,
'PointOnSurface'
,
'Reverse
'
,
'Transform'
,
'Translate'
,
'
Scale'
,
'SnapToGrid'
,
'
Transform'
,
'Translate'
,
}
}
if
self
.
connection
.
mysql_is_mariadb
:
if
self
.
connection
.
mysql_is_mariadb
:
unsupported
.
update
({
'GeoHash'
,
'IsValid'
})
unsupported
.
update
({
'GeoHash'
,
'IsValid'
})
...
...
django/contrib/gis/db/backends/oracle/operations.py
Dosyayı görüntüle @
0193bf87
...
@@ -107,8 +107,8 @@ class OracleOperations(BaseSpatialOperations, DatabaseOperations):
...
@@ -107,8 +107,8 @@ class OracleOperations(BaseSpatialOperations, DatabaseOperations):
unsupported_functions
=
{
unsupported_functions
=
{
'AsGeoJSON'
,
'AsKML'
,
'AsSVG'
,
'Azimuth'
,
'ForcePolygonCW'
,
'GeoHash'
,
'AsGeoJSON'
,
'AsKML'
,
'AsSVG'
,
'Azimuth'
,
'ForcePolygonCW'
,
'GeoHash'
,
'
LineLocatePoint'
,
'MakeValid'
,
'MemSize'
,
'Scale'
,
'SnapToGrid
'
,
'
GeometryDistance'
,
'LineLocatePoint'
,
'MakeValid'
,
'MemSize
'
,
'Translate'
,
'
Scale'
,
'SnapToGrid'
,
'
Translate'
,
}
}
def
geo_quote_name
(
self
,
name
):
def
geo_quote_name
(
self
,
name
):
...
...
django/contrib/gis/db/backends/spatialite/operations.py
Dosyayı görüntüle @
0193bf87
...
@@ -79,7 +79,7 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
...
@@ -79,7 +79,7 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
@cached_property
@cached_property
def
unsupported_functions
(
self
):
def
unsupported_functions
(
self
):
unsupported
=
{
'BoundingCircle'
,
'MemSize'
}
unsupported
=
{
'BoundingCircle'
,
'
GeometryDistance'
,
'
MemSize'
}
if
not
self
.
lwgeom_version
():
if
not
self
.
lwgeom_version
():
unsupported
|=
{
'Azimuth'
,
'GeoHash'
,
'IsValid'
,
'MakeValid'
}
unsupported
|=
{
'Azimuth'
,
'GeoHash'
,
'IsValid'
,
'MakeValid'
}
return
unsupported
return
unsupported
...
...
django/contrib/gis/db/models/functions.py
Dosyayı görüntüle @
0193bf87
...
@@ -48,7 +48,7 @@ class GeoFuncMixin:
...
@@ -48,7 +48,7 @@ class GeoFuncMixin:
return
self
.
source_expressions
[
self
.
geom_param_pos
[
0
]]
.
field
return
self
.
source_expressions
[
self
.
geom_param_pos
[
0
]]
.
field
def
as_sql
(
self
,
compiler
,
connection
,
function
=
None
,
**
extra_context
):
def
as_sql
(
self
,
compiler
,
connection
,
function
=
None
,
**
extra_context
):
if
not
self
.
function
and
not
function
:
if
self
.
function
is
None
and
function
is
None
:
function
=
connection
.
ops
.
spatial_function_name
(
self
.
name
)
function
=
connection
.
ops
.
spatial_function_name
(
self
.
name
)
return
super
()
.
as_sql
(
compiler
,
connection
,
function
=
function
,
**
extra_context
)
return
super
()
.
as_sql
(
compiler
,
connection
,
function
=
function
,
**
extra_context
)
...
@@ -299,6 +299,14 @@ class GeoHash(GeoFunc):
...
@@ -299,6 +299,14 @@ class GeoHash(GeoFunc):
return
clone
.
as_sql
(
compiler
,
connection
,
**
extra_context
)
return
clone
.
as_sql
(
compiler
,
connection
,
**
extra_context
)
class
GeometryDistance
(
GeoFunc
):
output_field
=
FloatField
()
arity
=
2
function
=
''
arg_joiner
=
' <-> '
geom_param_pos
=
(
0
,
1
)
class
Intersection
(
OracleToleranceMixin
,
GeomOutputGeoFunc
):
class
Intersection
(
OracleToleranceMixin
,
GeomOutputGeoFunc
):
arity
=
2
arity
=
2
geom_param_pos
=
(
0
,
1
)
geom_param_pos
=
(
0
,
1
)
...
...
docs/ref/contrib/gis/functions.txt
Dosyayı görüntüle @
0193bf87
...
@@ -20,17 +20,17 @@ get a ``NotImplementedError`` exception.
...
@@ -20,17 +20,17 @@ get a ``NotImplementedError`` exception.
Function's summary:
Function's summary:
==================
========================
====================== ======================= ================== =====================
==================
======= ========================
====================== ======================= ================== =====================
Measurement
Relationships
Operations Editors Output format Miscellaneous
Measurement
Relationships
Operations Editors Output format Miscellaneous
==================
========================
====================== ======================= ================== =====================
==================
======= ========================
====================== ======================= ================== =====================
:class:`Area`
:class:`Azimuth`
:class:`Difference` :class:`ForcePolygonCW` :class:`AsGeoJSON` :class:`IsValid`
:class:`Area`
:class:`Azimuth`
:class:`Difference` :class:`ForcePolygonCW` :class:`AsGeoJSON` :class:`IsValid`
:class:`Distance`
:class:`BoundingCircle`
:class:`Intersection` :class:`MakeValid` :class:`AsGML` :class:`MemSize`
:class:`Distance`
:class:`BoundingCircle`
:class:`Intersection` :class:`MakeValid` :class:`AsGML` :class:`MemSize`
:class:`
Length` :class:`Centroid`
:class:`SymDifference` :class:`Reverse` :class:`AsKML` :class:`NumGeometries`
:class:`
GeometryDistance` :class:`Centroid`
:class:`SymDifference` :class:`Reverse` :class:`AsKML` :class:`NumGeometries`
:class:`
Perimeter` :class:`Envelope`
:class:`Union` :class:`Scale` :class:`AsSVG` :class:`NumPoints`
:class:`
Length` :class:`Envelope`
:class:`Union` :class:`Scale` :class:`AsSVG` :class:`NumPoints`
.. :class:`LineLocatePoint`
:class:`SnapToGrid` :class:`GeoHash`
:class:`Perimeter` :class:`LineLocatePoint`
:class:`SnapToGrid` :class:`GeoHash`
..
:class:`PointOnSurface`
:class:`Transform`
..
:class:`PointOnSurface`
:class:`Transform`
.. :class:`Translate`
..
:class:`Translate`
==================
========================
====================== ======================= ================== =====================
==================
======= ========================
====================== ======================= ================== =====================
``Area``
``Area``
========
========
...
@@ -308,6 +308,19 @@ result.
...
@@ -308,6 +308,19 @@ result.
__ https://en.wikipedia.org/wiki/Geohash
__ https://en.wikipedia.org/wiki/Geohash
``GeometryDistance``
====================
.. class:: GeometryDistance(expr1, expr2, **extra)
.. versionadded:: 3.0
*Availability*: `PostGIS <https://postgis.net/docs/geometry_distance_knn.html>`__
Accepts two geographic fields or expressions and returns the distance between
them. When used in an :meth:`~django.db.models.query.QuerySet.order_by` clause,
it provides index-assisted nearest-neighbor result sets.
``Intersection``
``Intersection``
================
================
...
...
docs/releases/3.0.txt
Dosyayı görüntüle @
0193bf87
...
@@ -67,6 +67,9 @@ Minor features
...
@@ -67,6 +67,9 @@ Minor features
* Allowed MySQL spatial lookup functions to operate on real geometries.
* Allowed MySQL spatial lookup functions to operate on real geometries.
Previous support was limited to bounding boxes.
Previous support was limited to bounding boxes.
* Added the :class:`~django.contrib.gis.db.models.functions.GeometryDistance`
function, supported on PostGIS.
:mod:`django.contrib.messages`
:mod:`django.contrib.messages`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
tests/gis_tests/geoapp/test_functions.py
Dosyayı görüntüle @
0193bf87
...
@@ -240,6 +240,21 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
...
@@ -240,6 +240,21 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
self
.
assertEqual
(
ref_hash
,
h1
.
geohash
[:
len
(
ref_hash
)])
self
.
assertEqual
(
ref_hash
,
h1
.
geohash
[:
len
(
ref_hash
)])
self
.
assertEqual
(
ref_hash
[:
5
],
h2
.
geohash
)
self
.
assertEqual
(
ref_hash
[:
5
],
h2
.
geohash
)
@skipUnlessDBFeature
(
'has_GeometryDistance_function'
)
def
test_geometry_distance
(
self
):
point
=
Point
(
-
90
,
40
,
srid
=
4326
)
qs
=
City
.
objects
.
annotate
(
distance
=
functions
.
GeometryDistance
(
'point'
,
point
))
.
order_by
(
'distance'
)
self
.
assertEqual
([
city
.
distance
for
city
in
qs
],
[
2.99091995527296
,
5.33507274054713
,
9.33852187483721
,
9.91769193646233
,
11.556465744884
,
14.713098433352
,
34.3635252198568
,
276.987855073372
,
])
@skipUnlessDBFeature
(
"has_Intersection_function"
)
@skipUnlessDBFeature
(
"has_Intersection_function"
)
def
test_intersection
(
self
):
def
test_intersection
(
self
):
geom
=
Point
(
5
,
23
,
srid
=
4326
)
geom
=
Point
(
5
,
23
,
srid
=
4326
)
...
...
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