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
a7bb5af5
Kaydet (Commit)
a7bb5af5
authored
Eki 24, 2015
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Eki 24, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25583 -- Allowed calling `transform` with `CoordTransform` even if SRID is invalid.
üst
02ef96c5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
19 deletions
+32
-19
geometry.py
django/contrib/gis/geos/geometry.py
+6
-2
geos.txt
docs/ref/contrib/gis/geos.txt
+8
-0
test_geos.py
tests/gis_tests/geos_tests/test_geos.py
+18
-17
No files found.
django/contrib/gis/geos/geometry.py
Dosyayı görüntüle @
a7bb5af5
...
...
@@ -494,14 +494,18 @@ class GEOSGeometry(GEOSBase, ListMixin):
else
:
return
if
(
srid
is
None
)
or
(
srid
<
0
):
if
isinstance
(
ct
,
gdal
.
CoordTransform
):
# We don't care about SRID because CoordTransform presupposes
# source SRS.
srid
=
None
elif
srid
is
None
or
srid
<
0
:
raise
GEOSException
(
"Calling transform() with no SRID set is not supported"
)
if
not
gdal
.
HAS_GDAL
:
raise
GEOSException
(
"GDAL library is not available to transform() geometry."
)
# Creating an OGR Geometry, which is then transformed.
g
=
self
.
ogr
g
=
gdal
.
OGRGeometry
(
self
.
wkb
,
srid
)
g
.
transform
(
ct
)
# Getting a new GEOS pointer
ptr
=
wkb_r
()
.
read
(
g
.
wkb
)
...
...
docs/ref/contrib/gis/geos.txt
Dosyayı görüntüle @
a7bb5af5
...
...
@@ -553,6 +553,14 @@ is returned instead.
Requires GDAL. Raises :class:`~django.contrib.gis.geos.GEOSException` if
GDAL is not available or if the geometry's SRID is ``None`` or less than 0.
It doesn't impose any constraints on the geometry's SRID if called with a
:class:`~django.contrib.gis.gdal.CoordTransform` object.
.. versionchanged:: 1.10
In previous versions, it required the geometry's SRID to be a positive
integer even if it was called with a
:class:`~django.contrib.gis.gdal.CoordTransform` object.
``Point``
---------
...
...
tests/gis_tests/geos_tests/test_geos.py
Dosyayı görüntüle @
a7bb5af5
...
...
@@ -656,23 +656,24 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
@skipUnless
(
HAS_GDAL
,
"GDAL is required."
)
def
test_custom_srid
(
self
):
""" Test with a srid unknown from GDAL """
pnt
=
Point
(
111200
,
220900
,
srid
=
999999
)
self
.
assertTrue
(
pnt
.
ewkt
.
startswith
(
"SRID=999999;POINT (111200.0"
))
self
.
assertIsInstance
(
pnt
.
ogr
,
gdal
.
OGRGeometry
)
self
.
assertIsNone
(
pnt
.
srs
)
# Test conversion from custom to a known srid
c2w
=
gdal
.
CoordTransform
(
gdal
.
SpatialReference
(
'+proj=mill +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +R_A +ellps=WGS84 '
'+datum=WGS84 +units=m +no_defs'
),
gdal
.
SpatialReference
(
4326
))
new_pnt
=
pnt
.
transform
(
c2w
,
clone
=
True
)
self
.
assertEqual
(
new_pnt
.
srid
,
4326
)
self
.
assertAlmostEqual
(
new_pnt
.
x
,
1
,
3
)
self
.
assertAlmostEqual
(
new_pnt
.
y
,
2
,
3
)
"""Test with a null srid and a srid unknown to GDAL."""
for
srid
in
[
None
,
999999
]:
pnt
=
Point
(
111200
,
220900
,
srid
=
srid
)
self
.
assertTrue
(
pnt
.
ewkt
.
startswith
((
"SRID=
%
s;"
%
srid
if
srid
else
''
)
+
"POINT (111200.0"
))
self
.
assertIsInstance
(
pnt
.
ogr
,
gdal
.
OGRGeometry
)
self
.
assertIsNone
(
pnt
.
srs
)
# Test conversion from custom to a known srid
c2w
=
gdal
.
CoordTransform
(
gdal
.
SpatialReference
(
'+proj=mill +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +R_A +ellps=WGS84 '
'+datum=WGS84 +units=m +no_defs'
),
gdal
.
SpatialReference
(
4326
))
new_pnt
=
pnt
.
transform
(
c2w
,
clone
=
True
)
self
.
assertEqual
(
new_pnt
.
srid
,
4326
)
self
.
assertAlmostEqual
(
new_pnt
.
x
,
1
,
3
)
self
.
assertAlmostEqual
(
new_pnt
.
y
,
2
,
3
)
def
test_mutable_geometries
(
self
):
"Testing the mutability of Polygons and Geometry Collections."
...
...
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