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
fabc678f
Kaydet (Commit)
fabc678f
authored
Ock 30, 2014
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added new srs test and various cleaning
üst
e9d12bae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
19 deletions
+32
-19
test_spatialrefsys.py
django/contrib/gis/tests/test_spatialrefsys.py
+30
-17
srs.py
django/contrib/gis/utils/srs.py
+2
-2
No files found.
django/contrib/gis/tests/test_spatialrefsys.py
Dosyayı görüntüle @
fabc678f
...
@@ -3,6 +3,8 @@ import unittest
...
@@ -3,6 +3,8 @@ import unittest
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.tests.utils
import
(
no_mysql
,
oracle
,
postgis
,
from
django.contrib.gis.tests.utils
import
(
no_mysql
,
oracle
,
postgis
,
spatialite
,
HAS_SPATIALREFSYS
,
SpatialRefSys
)
spatialite
,
HAS_SPATIALREFSYS
,
SpatialRefSys
)
from
django.contrib.gis.utils
import
add_srs_entry
from
django.db
import
connection
from
django.utils
import
six
from
django.utils
import
six
...
@@ -38,8 +40,10 @@ test_srs = ({'srid': 4326,
...
@@ -38,8 +40,10 @@ test_srs = ({'srid': 4326,
class
SpatialRefSysTest
(
unittest
.
TestCase
):
class
SpatialRefSysTest
(
unittest
.
TestCase
):
@no_mysql
@no_mysql
def
test01_retrieve
(
self
):
def
test_retrieve
(
self
):
"Testing retrieval of SpatialRefSys model objects."
"""
Test retrieval of SpatialRefSys model objects.
"""
for
sd
in
test_srs
:
for
sd
in
test_srs
:
srs
=
SpatialRefSys
.
objects
.
get
(
srid
=
sd
[
'srid'
])
srs
=
SpatialRefSys
.
objects
.
get
(
srid
=
sd
[
'srid'
])
self
.
assertEqual
(
sd
[
'srid'
],
srs
.
srid
)
self
.
assertEqual
(
sd
[
'srid'
],
srs
.
srid
)
...
@@ -59,8 +63,10 @@ class SpatialRefSysTest(unittest.TestCase):
...
@@ -59,8 +63,10 @@ class SpatialRefSysTest(unittest.TestCase):
six
.
assertRegex
(
self
,
srs
.
proj4text
,
sd
[
'proj4_re'
])
six
.
assertRegex
(
self
,
srs
.
proj4text
,
sd
[
'proj4_re'
])
@no_mysql
@no_mysql
def
test02_osr
(
self
):
def
test_osr
(
self
):
"Testing getting OSR objects from SpatialRefSys model objects."
"""
Test getting OSR objects from SpatialRefSys model objects.
"""
for
sd
in
test_srs
:
for
sd
in
test_srs
:
sr
=
SpatialRefSys
.
objects
.
get
(
srid
=
sd
[
'srid'
])
sr
=
SpatialRefSys
.
objects
.
get
(
srid
=
sd
[
'srid'
])
self
.
assertEqual
(
True
,
sr
.
spheroid
.
startswith
(
sd
[
'spheroid'
]))
self
.
assertEqual
(
True
,
sr
.
spheroid
.
startswith
(
sd
[
'spheroid'
]))
...
@@ -76,13 +82,15 @@ class SpatialRefSysTest(unittest.TestCase):
...
@@ -76,13 +82,15 @@ class SpatialRefSysTest(unittest.TestCase):
if
postgis
or
spatialite
:
if
postgis
or
spatialite
:
srs
=
sr
.
srs
srs
=
sr
.
srs
six
.
assertRegex
(
self
,
srs
.
proj4
,
sd
[
'proj4_re'
])
six
.
assertRegex
(
self
,
srs
.
proj4
,
sd
[
'proj4_re'
])
# No `srtext` field in the `spatial_ref_sys` table in SpatiaLite
# No `srtext` field in the `spatial_ref_sys` table in SpatiaLite
< 4
if
not
spatialite
:
if
not
spatialite
or
connection
.
ops
.
spatial_version
[
0
]
>=
4
:
self
.
assertTrue
(
srs
.
wkt
.
startswith
(
sd
[
'srtext'
]))
self
.
assertTrue
(
srs
.
wkt
.
startswith
(
sd
[
'srtext'
]))
@no_mysql
@no_mysql
def
test03_ellipsoid
(
self
):
def
test_ellipsoid
(
self
):
"Testing the ellipsoid property."
"""
Test the ellipsoid property.
"""
for
sd
in
test_srs
:
for
sd
in
test_srs
:
# Getting the ellipsoid and precision parameters.
# Getting the ellipsoid and precision parameters.
ellps1
=
sd
[
'ellipsoid'
]
ellps1
=
sd
[
'ellipsoid'
]
...
@@ -95,12 +103,17 @@ class SpatialRefSysTest(unittest.TestCase):
...
@@ -95,12 +103,17 @@ class SpatialRefSysTest(unittest.TestCase):
for
i
in
range
(
3
):
for
i
in
range
(
3
):
self
.
assertAlmostEqual
(
ellps1
[
i
],
ellps2
[
i
],
prec
[
i
])
self
.
assertAlmostEqual
(
ellps1
[
i
],
ellps2
[
i
],
prec
[
i
])
@no_mysql
def
suite
():
def
test_add_entry
(
self
):
s
=
unittest
.
TestSuite
()
"""
s
.
addTest
(
unittest
.
makeSuite
(
SpatialRefSysTest
))
Test adding a new entry in the SpatialRefSys model using the
return
s
add_srs_entry utility.
"""
add_srs_entry
(
900913
)
def
run
(
verbosity
=
2
):
self
.
assertTrue
(
unittest
.
TextTestRunner
(
verbosity
=
verbosity
)
.
run
(
suite
())
SpatialRefSys
.
objects
.
filter
(
srid
=
900913
)
.
exists
()
)
srs
=
SpatialRefSys
.
objects
.
get
(
srid
=
900913
)
self
.
assertTrue
(
SpatialRefSys
.
get_spheroid
(
srs
.
wkt
)
.
startswith
(
'SPHEROID['
)
)
django/contrib/gis/utils/srs.py
Dosyayı görüntüle @
fabc678f
from
django.contrib.gis.gdal
import
SpatialReference
from
django.contrib.gis.gdal
import
SpatialReference
from
django.db
import
connections
,
DEFAULT_DB_ALIAS
def
add_srs_entry
(
srs
,
auth_name
=
'EPSG'
,
auth_srid
=
None
,
ref_sys_name
=
None
,
def
add_srs_entry
(
srs
,
auth_name
=
'EPSG'
,
auth_srid
=
None
,
ref_sys_name
=
None
,
...
@@ -30,10 +31,9 @@ def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
...
@@ -30,10 +31,9 @@ def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
database:
database:
The name of the database connection to use; the default is the value
The name of the database connection to use; the default is the value
of `django.db.DEFAULT_DB_ALIAS` (at the time of this writing, it
'
s value
of `django.db.DEFAULT_DB_ALIAS` (at the time of this writing, its value
is 'default').
is 'default').
"""
"""
from
django.db
import
connections
,
DEFAULT_DB_ALIAS
if
not
database
:
if
not
database
:
database
=
DEFAULT_DB_ALIAS
database
=
DEFAULT_DB_ALIAS
connection
=
connections
[
database
]
connection
=
connections
[
database
]
...
...
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