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
e158ec0b
Kaydet (Commit)
e158ec0b
authored
May 11, 2016
tarafından
Nicolas Noé
Kaydeden (comit)
Tim Graham
May 13, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26333 -- Made GIS Geometry classes deconstructible.
üst
32dc8c0b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
+67
-0
geometry.py
django/contrib/gis/geos/geometry.py
+2
-0
test_geos.py
tests/gis_tests/geos_tests/test_geos.py
+65
-0
No files found.
django/contrib/gis/geos/geometry.py
Dosyayı görüntüle @
e158ec0b
...
...
@@ -21,10 +21,12 @@ from django.contrib.gis.geos.prototypes.io import (
ewkb_w
,
wkb_r
,
wkb_w
,
wkt_r
,
wkt_w
,
)
from
django.utils
import
six
from
django.utils.deconstruct
import
deconstructible
from
django.utils.deprecation
import
RemovedInDjango20Warning
from
django.utils.encoding
import
force_bytes
,
force_text
@deconstructible
class
GEOSGeometry
(
GEOSBase
,
ListMixin
):
"A class that, generally, encapsulates a GEOS geometry."
...
...
tests/gis_tests/geos_tests/test_geos.py
Dosyayı görüntüle @
e158ec0b
...
...
@@ -1246,6 +1246,71 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
self
.
assertEqual
(
mls
.
interpolate
(
9
),
Point
(
0
,
9
))
self
.
assertEqual
(
mls
.
interpolate
(
17
),
Point
(
10
,
7
))
def
test_deconstructible
(
self
):
"""
Geometry classes should be deconstructible.
"""
point
=
Point
(
4.337844
,
50.827537
,
srid
=
4326
)
path
,
args
,
kwargs
=
point
.
deconstruct
()
self
.
assertEqual
(
path
,
'django.contrib.gis.geos.point.Point'
)
self
.
assertEqual
(
args
,
(
4.337844
,
50.827537
))
self
.
assertEqual
(
kwargs
,
{
'srid'
:
4326
})
ls
=
LineString
(((
0
,
0
),
(
1
,
1
)))
path
,
args
,
kwargs
=
ls
.
deconstruct
()
self
.
assertEqual
(
path
,
'django.contrib.gis.geos.linestring.LineString'
)
self
.
assertEqual
(
args
,
(((
0
,
0
),
(
1
,
1
))))
self
.
assertEqual
(
kwargs
,
{})
ls2
=
LineString
([
Point
(
0
,
0
),
Point
(
1
,
1
)],
srid
=
4326
)
path
,
args
,
kwargs
=
ls2
.
deconstruct
()
self
.
assertEqual
(
path
,
'django.contrib.gis.geos.linestring.LineString'
)
self
.
assertEqual
(
args
,
([
Point
(
0
,
0
),
Point
(
1
,
1
)]))
self
.
assertEqual
(
kwargs
,
{
'srid'
:
4326
})
ext_coords
=
((
0
,
0
),
(
0
,
1
),
(
1
,
1
),
(
1
,
0
),
(
0
,
0
))
int_coords
=
((
0.4
,
0.4
),
(
0.4
,
0.6
),
(
0.6
,
0.6
),
(
0.6
,
0.4
),
(
0.4
,
0.4
))
poly
=
Polygon
(
ext_coords
,
int_coords
)
path
,
args
,
kwargs
=
poly
.
deconstruct
()
self
.
assertEqual
(
path
,
'django.contrib.gis.geos.polygon.Polygon'
)
self
.
assertEqual
(
args
,
(
ext_coords
,
int_coords
))
self
.
assertEqual
(
kwargs
,
{})
lr
=
LinearRing
((
0
,
0
),
(
0
,
1
),
(
1
,
1
),
(
0
,
0
))
path
,
args
,
kwargs
=
lr
.
deconstruct
()
self
.
assertEqual
(
path
,
'django.contrib.gis.geos.linestring.LinearRing'
)
self
.
assertEqual
(
args
,
((
0
,
0
),
(
0
,
1
),
(
1
,
1
),
(
0
,
0
)))
self
.
assertEqual
(
kwargs
,
{})
mp
=
MultiPoint
(
Point
(
0
,
0
),
Point
(
1
,
1
))
path
,
args
,
kwargs
=
mp
.
deconstruct
()
self
.
assertEqual
(
path
,
'django.contrib.gis.geos.collections.MultiPoint'
)
self
.
assertEqual
(
args
,
(
Point
(
0
,
0
),
Point
(
1
,
1
)))
self
.
assertEqual
(
kwargs
,
{})
ls1
=
LineString
((
0
,
0
),
(
1
,
1
))
ls2
=
LineString
((
2
,
2
),
(
3
,
3
))
mls
=
MultiLineString
(
ls1
,
ls2
)
path
,
args
,
kwargs
=
mls
.
deconstruct
()
self
.
assertEqual
(
path
,
'django.contrib.gis.geos.collections.MultiLineString'
)
self
.
assertEqual
(
args
,
(
ls1
,
ls2
))
self
.
assertEqual
(
kwargs
,
{})
p1
=
Polygon
(((
0
,
0
),
(
0
,
1
),
(
1
,
1
),
(
0
,
0
)))
p2
=
Polygon
(((
1
,
1
),
(
1
,
2
),
(
2
,
2
),
(
1
,
1
)))
mp
=
MultiPolygon
(
p1
,
p2
)
path
,
args
,
kwargs
=
mp
.
deconstruct
()
self
.
assertEqual
(
path
,
'django.contrib.gis.geos.collections.MultiPolygon'
)
self
.
assertEqual
(
args
,
(
p1
,
p2
,
))
self
.
assertEqual
(
kwargs
,
{})
poly
=
Polygon
(((
0
,
0
),
(
0
,
1
),
(
1
,
1
),
(
0
,
0
)))
gc
=
GeometryCollection
(
Point
(
0
,
0
),
MultiPoint
(
Point
(
0
,
0
),
Point
(
1
,
1
)),
poly
)
path
,
args
,
kwargs
=
gc
.
deconstruct
()
self
.
assertEqual
(
path
,
'django.contrib.gis.geos.collections.GeometryCollection'
)
self
.
assertEqual
(
args
,
(
Point
(
0
,
0
),
MultiPoint
(
Point
(
0
,
0
),
Point
(
1
,
1
)),
poly
))
self
.
assertEqual
(
kwargs
,
{})
def
test_geos_version
(
self
):
"""Testing the GEOS version regular expression."""
from
django.contrib.gis.geos.libgeos
import
version_regex
...
...
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