mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #25869 -- Added trim and precision properties to WKTWriter.
This commit is contained in:
parent
cd3c042b04
commit
c984e2bc15
4 changed files with 108 additions and 3 deletions
|
@ -1052,6 +1052,44 @@ Returns the WKT of the given geometry. Example::
|
|||
>>> wkt_w.write(pnt)
|
||||
'POINT (1.0000000000000000 1.0000000000000000)'
|
||||
|
||||
.. attribute:: WKTWriter.trim
|
||||
|
||||
.. versionadded:: 1.10
|
||||
|
||||
This property is used to enable or disable trimming of
|
||||
unnecessary decimals.
|
||||
|
||||
>>> from django.contrib.gis.geos import Point, WKTWriter
|
||||
>>> pnt = Point(1, 1)
|
||||
>>> wkt_w = WKTWriter()
|
||||
>>> wkt_w.trim
|
||||
False
|
||||
>>> wkt_w.write(pnt)
|
||||
'POINT (1.0000000000000000 1.0000000000000000)'
|
||||
>>> wkt_w.trim = True
|
||||
>>> wkt_w.write(pnt)
|
||||
'POINT (1 1)'
|
||||
|
||||
.. attribute:: WKTWriter.precision
|
||||
|
||||
.. versionadded:: 1.10
|
||||
|
||||
This property controls the rounding precision of coordinates;
|
||||
if set to ``None`` rounding is disabled.
|
||||
|
||||
>>> from django.contrib.gis.geos import Point, WKTWriter
|
||||
>>> pnt = Point(1.44, 1.66)
|
||||
>>> wkt_w = WKTWriter()
|
||||
>>> print(wkt_w.precision)
|
||||
None
|
||||
>>> wkt_w.write(pnt)
|
||||
'POINT (1.4399999999999999 1.6599999999999999)'
|
||||
>>> wkt_w.precision = 0
|
||||
>>> wkt_w.write(pnt)
|
||||
'POINT (1 2)'
|
||||
>>> wkt_w.precision = 1
|
||||
>>> wkt_w.write(pnt)
|
||||
'POINT (1.4 1.7)'
|
||||
|
||||
.. rubric:: Footnotes
|
||||
.. [#fnogc] *See* `PostGIS EWKB, EWKT and Canonical Forms <http://postgis.net/docs/using_postgis_dbmanagement.html#EWKB_EWKT>`_, PostGIS documentation at Ch. 4.1.2.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue