Clean up FromWKB, FromWKT code
Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
This commit is contained in:
parent
abc5a54c78
commit
f26698f8e6
|
@ -63,8 +63,8 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
|||
)
|
||||
|
||||
function_names = {
|
||||
'FromWKB': 'ST_GeomFromWKB',
|
||||
'FromWKT': 'ST_GeomFromText',
|
||||
"FromWKB": "ST_GeomFromWKB",
|
||||
"FromWKT": "ST_GeomFromText",
|
||||
}
|
||||
|
||||
@cached_property
|
||||
|
|
|
@ -328,7 +328,7 @@ are returned unchanged.
|
|||
|
||||
.. class:: FromWKB(expression, **extra)
|
||||
|
||||
.. versionadded:: 3.1
|
||||
.. versionadded:: 4.2
|
||||
|
||||
*Availability*: MariaDB, `MySQL
|
||||
<https://dev.mysql.com/doc/refman/en/gis-wkb-functions.html#function_st-geomfromwkb>`__,
|
||||
|
@ -341,7 +341,7 @@ Creates geometry from `Well-known binary (WKB)`_ representation.
|
|||
|
||||
.. class:: FromWKT(expression, **extra)
|
||||
|
||||
.. versionadded:: 3.1
|
||||
.. versionadded:: 4.2
|
||||
|
||||
*Availability*: MariaDB, `MySQL
|
||||
<https://dev.mysql.com/doc/refman/en/gis-wkt-functions.html#function_st-geomfromtext>`__,
|
||||
|
|
|
@ -6,7 +6,7 @@ from decimal import Decimal
|
|||
from django.contrib.gis.db.models import GeometryField, PolygonField, functions
|
||||
from django.contrib.gis.geos import GEOSGeometry, LineString, Point, Polygon, fromstr
|
||||
from django.contrib.gis.measure import Area
|
||||
from django.db import NotSupportedError, connection, models
|
||||
from django.db import NotSupportedError, connection
|
||||
from django.db.models import IntegerField, Sum, Value
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
|
||||
|
@ -330,12 +330,7 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
|
|||
def test_fromwkb(self):
|
||||
g = Point(56.811078, 60.608647)
|
||||
g2 = City.objects.values_list(
|
||||
functions.FromWKB(
|
||||
models.Value(
|
||||
bytes(g.wkb),
|
||||
output_field=models.BinaryField(),
|
||||
)
|
||||
),
|
||||
functions.FromWKB(Value(g.wkb.tobytes())),
|
||||
flat=True,
|
||||
)[0]
|
||||
self.assertEqual(g, g2)
|
||||
|
@ -344,7 +339,7 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
|
|||
def test_fromwkt(self):
|
||||
g = Point(56.811078, 60.608647)
|
||||
g2 = City.objects.values_list(
|
||||
functions.FromWKT(models.Value(g.wkt)),
|
||||
functions.FromWKT(Value(g.wkt)),
|
||||
flat=True,
|
||||
)[0]
|
||||
self.assertEqual(g, g2)
|
||||
|
|
Loading…
Reference in New Issue