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
2dc32802
Kaydet (Commit)
2dc32802
authored
May 03, 2017
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28160 -- Prevented hiding GDAL exceptions when it's not installed.
üst
89053725
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
119 additions
and
183 deletions
+119
-183
__init__.py
django/contrib/gis/gdal/__init__.py
+17
-26
geojson.py
django/contrib/gis/serializers/geojson.py
+1
-4
__init__.py
django/contrib/gis/utils/__init__.py
+9
-11
geolibs.txt
docs/ref/contrib/gis/install/geolibs.txt
+2
-11
1.11.1.txt
docs/releases/1.11.1.txt
+3
-0
test_driver.py
tests/gis_tests/gdal_tests/test_driver.py
+1
-6
test_ds.py
tests/gis_tests/gdal_tests/test_ds.py
+48
-50
test_envelope.py
tests/gis_tests/gdal_tests/test_envelope.py
+1
-6
test_geom.py
tests/gis_tests/gdal_tests/test_geom.py
+4
-9
test_raster.py
tests/gis_tests/gdal_tests/test_raster.py
+2
-8
test_srs.py
tests/gis_tests/gdal_tests/test_srs.py
+3
-6
tests.py
tests/gis_tests/geoapp/tests.py
+4
-5
test_geos.py
tests/gis_tests/geos_tests/test_geos.py
+0
-9
tests.py
tests/gis_tests/inspectapp/tests.py
+3
-7
tests.py
tests/gis_tests/layermap/tests.py
+1
-2
models.py
tests/gis_tests/rasterapp/models.py
+16
-16
test_rasterfield.py
tests/gis_tests/rasterapp/test_rasterfield.py
+2
-5
test_discover_runner.py
tests/test_runner/test_discover_runner.py
+2
-2
No files found.
django/contrib/gis/gdal/__init__.py
Dosyayı görüntüle @
2dc32802
...
@@ -25,32 +25,23 @@
...
@@ -25,32 +25,23 @@
by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
library on your system.
library on your system.
"""
"""
from
django.contrib.gis.gdal.datasource
import
DataSource
from
django.contrib.gis.gdal.driver
import
Driver
from
django.contrib.gis.gdal.envelope
import
Envelope
from
django.contrib.gis.gdal.envelope
import
Envelope
from
django.contrib.gis.gdal.error
import
(
# NOQA
from
django.contrib.gis.gdal.error
import
(
GDALException
,
OGRException
,
OGRIndexError
,
SRSException
,
check_err
,
GDALException
,
OGRException
,
OGRIndexError
,
SRSException
,
check_err
,
)
)
from
django.contrib.gis.gdal.geomtype
import
OGRGeomType
# NOQA
from
django.contrib.gis.gdal.geometries
import
OGRGeometry
from
django.contrib.gis.gdal.geomtype
import
OGRGeomType
__all__
=
[
from
django.contrib.gis.gdal.libgdal
import
(
'check_err'
,
'Envelope'
,
'GDALException'
,
'OGRException'
,
'OGRIndexError'
,
GDAL_VERSION
,
gdal_full_version
,
gdal_version
,
'SRSException'
,
'OGRGeomType'
,
'HAS_GDAL'
,
)
]
from
django.contrib.gis.gdal.raster.source
import
GDALRaster
from
django.contrib.gis.gdal.srs
import
CoordTransform
,
SpatialReference
# Attempting to import objects that depend on the GDAL library. The
# HAS_GDAL flag will be set to True if the library is present on
__all__
=
(
# the system.
'Driver'
,
'DataSource'
,
'CoordTransform'
,
'Envelope'
,
'GDALException'
,
try
:
'GDALRaster'
,
'GDAL_VERSION'
,
'OGRException'
,
'OGRGeometry'
,
'OGRGeomType'
,
from
django.contrib.gis.gdal.driver
import
Driver
# NOQA
'OGRIndexError'
,
'SpatialReference'
,
'SRSException'
,
from
django.contrib.gis.gdal.datasource
import
DataSource
# NOQA
'check_err'
,
'gdal_version'
,
'gdal_full_version'
,
from
django.contrib.gis.gdal.libgdal
import
gdal_version
,
gdal_full_version
,
GDAL_VERSION
# NOQA
)
from
django.contrib.gis.gdal.raster.source
import
GDALRaster
# NOQA
from
django.contrib.gis.gdal.srs
import
SpatialReference
,
CoordTransform
# NOQA
from
django.contrib.gis.gdal.geometries
import
OGRGeometry
# NOQA
HAS_GDAL
=
True
__all__
+=
[
'Driver'
,
'DataSource'
,
'gdal_version'
,
'gdal_full_version'
,
'GDALRaster'
,
'GDAL_VERSION'
,
'SpatialReference'
,
'CoordTransform'
,
'OGRGeometry'
,
]
except
GDALException
:
HAS_GDAL
=
False
django/contrib/gis/serializers/geojson.py
Dosyayı görüntüle @
2dc32802
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.gdal
import
CoordTransform
,
SpatialReference
from
django.core.serializers.base
import
SerializerDoesNotExist
from
django.core.serializers.base
import
SerializerDoesNotExist
from
django.core.serializers.json
import
Serializer
as
JSONSerializer
from
django.core.serializers.json
import
Serializer
as
JSONSerializer
if
HAS_GDAL
:
from
django.contrib.gis.gdal
import
CoordTransform
,
SpatialReference
class
Serializer
(
JSONSerializer
):
class
Serializer
(
JSONSerializer
):
"""
"""
...
...
django/contrib/gis/utils/__init__.py
Dosyayı görüntüle @
2dc32802
"""
"""
This module contains useful utilities for GeoDjango.
This module contains useful utilities for GeoDjango.
"""
"""
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.utils.ogrinfo
import
ogrinfo
# NOQA
from
django.contrib.gis.utils.ogrinspect
import
mapping
,
ogrinspect
# NOQA
from
django.contrib.gis.utils.srs
import
add_srs_entry
# NOQA
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.exceptions
import
ImproperlyConfigured
if
HAS_GDAL
:
try
:
from
django.contrib.gis.utils.ogrinfo
import
ogrinfo
# NOQA
# LayerMapping requires DJANGO_SETTINGS_MODULE to be set,
from
django.contrib.gis.utils.ogrinspect
import
mapping
,
ogrinspect
# NOQA
# so this needs to be in try/except.
from
django.contrib.gis.utils.srs
import
add_srs_entry
# NOQA
from
django.contrib.gis.utils.layermapping
import
LayerMapping
,
LayerMapError
# NOQA
try
:
except
ImproperlyConfigured
:
# LayerMapping requires DJANGO_SETTINGS_MODULE to be set,
pass
# so this needs to be in try/except.
from
django.contrib.gis.utils.layermapping
import
LayerMapping
,
LayerMapError
# NOQA
except
ImproperlyConfigured
:
pass
docs/ref/contrib/gis/install/geolibs.txt
Dosyayı görüntüle @
2dc32802
...
@@ -225,17 +225,8 @@ Troubleshooting
...
@@ -225,17 +225,8 @@ Troubleshooting
Can't find GDAL library
Can't find GDAL library
^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^
When GeoDjango can't find the GDAL library, the ``HAS_GDAL`` flag
When GeoDjango can't find the GDAL library, configure your :ref:`libsettings`
will be false:
*or* set :ref:`gdallibrarypath` in your settings.
.. code-block:: pycon
>>> from django.contrib.gis import gdal
>>> gdal.HAS_GDAL
False
The solution is to properly configure your :ref:`libsettings` *or* set
:ref:`gdallibrarypath` in your settings.
.. _gdallibrarypath:
.. _gdallibrarypath:
...
...
docs/releases/1.11.1.txt
Dosyayı görüntüle @
2dc32802
...
@@ -94,3 +94,6 @@ Bugfixes
...
@@ -94,3 +94,6 @@ Bugfixes
* Fixed ``QuerySet.prefetch_related()`` crash when fetching relations in nested
* Fixed ``QuerySet.prefetch_related()`` crash when fetching relations in nested
``Prefetch`` objects (:ticket:`27554`).
``Prefetch`` objects (:ticket:`27554`).
* Prevented hiding GDAL errors if it's not installed when using ``contrib.gis``
(:ticket:`28160`). (It's a required dependency as of Django 1.11.)
tests/gis_tests/gdal_tests/test_driver.py
Dosyayı görüntüle @
2dc32802
import
unittest
import
unittest
from
unittest
import
mock
from
unittest
import
mock
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.gdal
import
Driver
,
GDALException
if
HAS_GDAL
:
from
django.contrib.gis.gdal
import
Driver
,
GDALException
valid_drivers
=
(
valid_drivers
=
(
# vector
# vector
...
@@ -29,7 +25,6 @@ aliases = {
...
@@ -29,7 +25,6 @@ aliases = {
}
}
@unittest.skipUnless
(
HAS_GDAL
,
"GDAL is required"
)
class
DriverTest
(
unittest
.
TestCase
):
class
DriverTest
(
unittest
.
TestCase
):
def
test01_valid_driver
(
self
):
def
test01_valid_driver
(
self
):
...
...
tests/gis_tests/gdal_tests/test_ds.py
Dosyayı görüntüle @
2dc32802
import
os
import
os
import
unittest
import
unittest
from
unittest
import
skipUnless
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.gdal
import
(
GDAL_VERSION
,
DataSource
,
Envelope
,
GDALException
,
OGRGeometry
,
OGRIndexError
,
)
from
django.contrib.gis.gdal.field
import
OFTInteger
,
OFTReal
,
OFTString
from
..test_data
import
TEST_DATA
,
TestDS
,
get_ds_file
from
..test_data
import
TEST_DATA
,
TestDS
,
get_ds_file
if
HAS_GDAL
:
# List of acceptable data sources.
from
django.contrib.gis.gdal
import
DataSource
,
Envelope
,
OGRGeometry
,
GDALException
,
OGRIndexError
,
GDAL_VERSION
ds_list
=
(
from
django.contrib.gis.gdal.field
import
OFTReal
,
OFTInteger
,
OFTString
TestDS
(
'test_point'
,
nfeat
=
5
,
nfld
=
3
,
geom
=
'POINT'
,
gtype
=
1
,
driver
=
'ESRI Shapefile'
,
# List of acceptable data sources.
fields
=
{
'dbl'
:
OFTReal
,
'int'
:
OFTInteger
,
'str'
:
OFTString
},
ds_list
=
(
extent
=
(
-
1.35011
,
0.166623
,
-
0.524093
,
0.824508
),
# Got extent from QGIS
TestDS
(
srs_wkt
=
(
'test_point'
,
nfeat
=
5
,
nfld
=
3
,
geom
=
'POINT'
,
gtype
=
1
,
driver
=
'ESRI Shapefile'
,
'GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",'
fields
=
{
'dbl'
:
OFTReal
,
'int'
:
OFTInteger
,
'str'
:
OFTString
},
'6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",'
extent
=
(
-
1.35011
,
0.166623
,
-
0.524093
,
0.824508
),
# Got extent from QGIS
'0.017453292519943295]]'
srs_wkt
=
(
'GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",'
'6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",'
'0.017453292519943295]]'
),
field_values
=
{
'dbl'
:
[
float
(
i
)
for
i
in
range
(
1
,
6
)],
'int'
:
list
(
range
(
1
,
6
)),
'str'
:
[
str
(
i
)
for
i
in
range
(
1
,
6
)],
},
fids
=
range
(
5
)
),
),
TestDS
(
field_values
=
{
'test_vrt'
,
ext
=
'vrt'
,
nfeat
=
3
,
nfld
=
3
,
geom
=
'POINT'
,
gtype
=
'Point25D'
,
'dbl'
:
[
float
(
i
)
for
i
in
range
(
1
,
6
)],
driver
=
'OGR_VRT'
if
GDAL_VERSION
>=
(
2
,
0
)
else
'VRT'
,
'int'
:
list
(
range
(
1
,
6
)),
fields
=
{
'str'
:
[
str
(
i
)
for
i
in
range
(
1
,
6
)],
'POINT_X'
:
OFTString
,
},
'POINT_Y'
:
OFTString
,
fids
=
range
(
5
)
'NUM'
:
OFTString
,
),
},
# VRT uses CSV, which all types are OFTString.
TestDS
(
extent
=
(
1.0
,
2.0
,
100.0
,
523.5
),
# Min/Max from CSV
'test_vrt'
,
ext
=
'vrt'
,
nfeat
=
3
,
nfld
=
3
,
geom
=
'POINT'
,
gtype
=
'Point25D'
,
field_values
=
{
driver
=
'OGR_VRT'
if
GDAL_VERSION
>=
(
2
,
0
)
else
'VRT'
,
'POINT_X'
:
[
'1.0'
,
'5.0'
,
'100.0'
],
fields
=
{
'POINT_Y'
:
[
'2.0'
,
'23.0'
,
'523.5'
],
'POINT_X'
:
OFTString
,
'NUM'
:
[
'5'
,
'17'
,
'23'
],
'POINT_Y'
:
OFTString
,
},
'NUM'
:
OFTString
,
fids
=
range
(
1
,
4
)
},
# VRT uses CSV, which all types are OFTString.
extent
=
(
1.0
,
2.0
,
100.0
,
523.5
),
# Min/Max from CSV
field_values
=
{
'POINT_X'
:
[
'1.0'
,
'5.0'
,
'100.0'
],
'POINT_Y'
:
[
'2.0'
,
'23.0'
,
'523.5'
],
'NUM'
:
[
'5'
,
'17'
,
'23'
],
},
fids
=
range
(
1
,
4
)
),
TestDS
(
'test_poly'
,
nfeat
=
3
,
nfld
=
3
,
geom
=
'POLYGON'
,
gtype
=
3
,
driver
=
'ESRI Shapefile'
,
fields
=
{
'float'
:
OFTReal
,
'int'
:
OFTInteger
,
'str'
:
OFTString
},
extent
=
(
-
1.01513
,
-
0.558245
,
0.161876
,
0.839637
),
# Got extent from QGIS
srs_wkt
=
(
'GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",'
'6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",'
'0.017453292519943295]]'
),
),
TestDS
(
'test_poly'
,
nfeat
=
3
,
nfld
=
3
,
geom
=
'POLYGON'
,
gtype
=
3
,
driver
=
'ESRI Shapefile'
,
fields
=
{
'float'
:
OFTReal
,
'int'
:
OFTInteger
,
'str'
:
OFTString
},
extent
=
(
-
1.01513
,
-
0.558245
,
0.161876
,
0.839637
),
# Got extent from QGIS
srs_wkt
=
(
'GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",'
'6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",'
'0.017453292519943295]]'
),
)
)
)
)
bad_ds
=
(
TestDS
(
'foo'
),)
bad_ds
=
(
TestDS
(
'foo'
),)
@skipUnless
(
HAS_GDAL
,
"GDAL is required"
)
class
DataSourceTest
(
unittest
.
TestCase
):
class
DataSourceTest
(
unittest
.
TestCase
):
def
test01_valid_shp
(
self
):
def
test01_valid_shp
(
self
):
...
...
tests/gis_tests/gdal_tests/test_envelope.py
Dosyayı görüntüle @
2dc32802
import
unittest
import
unittest
from
unittest
import
skipUnless
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.gdal
import
Envelope
,
GDALException
if
HAS_GDAL
:
from
django.contrib.gis.gdal
import
Envelope
,
GDALException
class
TestPoint
:
class
TestPoint
:
...
@@ -13,7 +9,6 @@ class TestPoint:
...
@@ -13,7 +9,6 @@ class TestPoint:
self
.
y
=
y
self
.
y
=
y
@skipUnless
(
HAS_GDAL
,
"GDAL is required"
)
class
EnvelopeTest
(
unittest
.
TestCase
):
class
EnvelopeTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
...
tests/gis_tests/gdal_tests/test_geom.py
Dosyayı görüntüle @
2dc32802
...
@@ -2,20 +2,15 @@ import json
...
@@ -2,20 +2,15 @@ import json
import
pickle
import
pickle
import
unittest
import
unittest
from
binascii
import
b2a_hex
from
binascii
import
b2a_hex
from
unittest
import
skipUnless
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.gdal
import
(
CoordTransform
,
GDALException
,
OGRGeometry
,
OGRGeomType
,
OGRIndexError
,
SpatialReference
,
)
from
..test_data
import
TestDataMixin
from
..test_data
import
TestDataMixin
if
HAS_GDAL
:
from
django.contrib.gis.gdal
import
(
CoordTransform
,
GDALException
,
OGRGeometry
,
OGRGeomType
,
OGRIndexError
,
SpatialReference
,
)
@skipUnless
(
HAS_GDAL
,
"GDAL is required"
)
class
OGRGeomTest
(
unittest
.
TestCase
,
TestDataMixin
):
class
OGRGeomTest
(
unittest
.
TestCase
,
TestDataMixin
):
"This tests the OGR Geometry."
"This tests the OGR Geometry."
...
...
tests/gis_tests/gdal_tests/test_raster.py
Dosyayı görüntüle @
2dc32802
...
@@ -43,21 +43,16 @@ Band 1 Block=163x50 Type=Byte, ColorInterp=Gray
...
@@ -43,21 +43,16 @@ Band 1 Block=163x50 Type=Byte, ColorInterp=Gray
import
os
import
os
import
struct
import
struct
import
tempfile
import
tempfile
import
unittest
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.gdal
import
GDAL_VERSION
,
GDALRaster
from
django.contrib.gis.gdal.error
import
GDALException
from
django.contrib.gis.gdal.error
import
GDALException
from
django.contrib.gis.gdal.raster.band
import
GDALBand
from
django.contrib.gis.shortcuts
import
numpy
from
django.contrib.gis.shortcuts
import
numpy
from
django.test
import
SimpleTestCase
from
django.test
import
SimpleTestCase
from
..data.rasters.textrasters
import
JSON_RASTER
from
..data.rasters.textrasters
import
JSON_RASTER
if
HAS_GDAL
:
from
django.contrib.gis.gdal
import
GDALRaster
,
GDAL_VERSION
from
django.contrib.gis.gdal.raster.band
import
GDALBand
@unittest.skipUnless
(
HAS_GDAL
,
"GDAL is required"
)
class
GDALRasterTests
(
SimpleTestCase
):
class
GDALRasterTests
(
SimpleTestCase
):
"""
"""
Test a GDALRaster instance created from a file (GeoTiff).
Test a GDALRaster instance created from a file (GeoTiff).
...
@@ -383,7 +378,6 @@ class GDALRasterTests(SimpleTestCase):
...
@@ -383,7 +378,6 @@ class GDALRasterTests(SimpleTestCase):
)
)
@unittest.skipUnless
(
HAS_GDAL
,
"GDAL is required"
)
class
GDALBandTests
(
SimpleTestCase
):
class
GDALBandTests
(
SimpleTestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
rs_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'../data/rasters/raster.tif'
)
self
.
rs_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'../data/rasters/raster.tif'
)
...
...
tests/gis_tests/gdal_tests/test_srs.py
Dosyayı görüntüle @
2dc32802
import
unittest
import
unittest
from
unittest
import
skipUnless
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.gdal
import
(
CoordTransform
,
GDALException
,
SpatialReference
,
SRSException
,
if
HAS_GDAL
:
)
from
django.contrib.gis.gdal
import
SpatialReference
,
CoordTransform
,
GDALException
,
SRSException
class
TestSRS
:
class
TestSRS
:
...
@@ -148,7 +146,6 @@ bad_srlist = (
...
@@ -148,7 +146,6 @@ bad_srlist = (
)
)
@skipUnless
(
HAS_GDAL
,
"GDAL is required"
)
class
SpatialRefTest
(
unittest
.
TestCase
):
class
SpatialRefTest
(
unittest
.
TestCase
):
def
test01_wkt
(
self
):
def
test01_wkt
(
self
):
...
...
tests/gis_tests/geoapp/tests.py
Dosyayı görüntüle @
2dc32802
...
@@ -79,11 +79,10 @@ class GeoModelTest(TestCase):
...
@@ -79,11 +79,10 @@ class GeoModelTest(TestCase):
self
.
assertEqual
(
ply
,
ns
.
poly
)
self
.
assertEqual
(
ply
,
ns
.
poly
)
# Testing the `ogr` and `srs` lazy-geometry properties.
# Testing the `ogr` and `srs` lazy-geometry properties.
if
gdal
.
HAS_GDAL
:
self
.
assertIsInstance
(
ns
.
poly
.
ogr
,
gdal
.
OGRGeometry
)
self
.
assertIsInstance
(
ns
.
poly
.
ogr
,
gdal
.
OGRGeometry
)
self
.
assertEqual
(
ns
.
poly
.
wkb
,
ns
.
poly
.
ogr
.
wkb
)
self
.
assertEqual
(
ns
.
poly
.
wkb
,
ns
.
poly
.
ogr
.
wkb
)
self
.
assertIsInstance
(
ns
.
poly
.
srs
,
gdal
.
SpatialReference
)
self
.
assertIsInstance
(
ns
.
poly
.
srs
,
gdal
.
SpatialReference
)
self
.
assertEqual
(
'WGS 84'
,
ns
.
poly
.
srs
.
name
)
self
.
assertEqual
(
'WGS 84'
,
ns
.
poly
.
srs
.
name
)
# Changing the interior ring on the poly attribute.
# Changing the interior ring on the poly attribute.
new_inner
=
LinearRing
((
30
,
30
),
(
30
,
70
),
(
70
,
70
),
(
70
,
30
),
(
30
,
30
))
new_inner
=
LinearRing
((
30
,
30
),
(
30
,
70
),
(
70
,
70
),
(
70
,
30
),
(
30
,
30
))
...
...
tests/gis_tests/geos_tests/test_geos.py
Dosyayı görüntüle @
2dc32802
...
@@ -7,7 +7,6 @@ from io import BytesIO
...
@@ -7,7 +7,6 @@ from io import BytesIO
from
unittest
import
mock
,
skipUnless
from
unittest
import
mock
,
skipUnless
from
django.contrib.gis
import
gdal
from
django.contrib.gis
import
gdal
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.geos
import
(
from
django.contrib.gis.geos
import
(
HAS_GEOS
,
GeometryCollection
,
GEOSException
,
GEOSGeometry
,
LinearRing
,
HAS_GEOS
,
GeometryCollection
,
GEOSException
,
GEOSGeometry
,
LinearRing
,
LineString
,
MultiLineString
,
MultiPoint
,
MultiPolygon
,
Point
,
Polygon
,
LineString
,
MultiLineString
,
MultiPoint
,
MultiPolygon
,
Point
,
Polygon
,
...
@@ -134,7 +133,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
...
@@ -134,7 +133,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
self
.
assertEqual
(
srid
,
poly
.
shell
.
srid
)
self
.
assertEqual
(
srid
,
poly
.
shell
.
srid
)
self
.
assertEqual
(
srid
,
fromstr
(
poly
.
ewkt
)
.
srid
)
# Checking export
self
.
assertEqual
(
srid
,
fromstr
(
poly
.
ewkt
)
.
srid
)
# Checking export
@skipUnless
(
HAS_GDAL
,
"GDAL is required."
)
def
test_json
(
self
):
def
test_json
(
self
):
"Testing GeoJSON input/output (via GDAL)."
"Testing GeoJSON input/output (via GDAL)."
for
g
in
self
.
geometries
.
json_geoms
:
for
g
in
self
.
geometries
.
json_geoms
:
...
@@ -145,7 +143,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
...
@@ -145,7 +143,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
self
.
assertEqual
(
json
.
loads
(
g
.
json
),
json
.
loads
(
geom
.
geojson
))
self
.
assertEqual
(
json
.
loads
(
g
.
json
),
json
.
loads
(
geom
.
geojson
))
self
.
assertEqual
(
GEOSGeometry
(
g
.
wkt
,
4326
),
GEOSGeometry
(
geom
.
json
))
self
.
assertEqual
(
GEOSGeometry
(
g
.
wkt
,
4326
),
GEOSGeometry
(
geom
.
json
))
@skipUnless
(
HAS_GDAL
,
"GDAL is required."
)
def
test_json_srid
(
self
):
def
test_json_srid
(
self
):
geojson_data
=
{
geojson_data
=
{
"type"
:
"Point"
,
"type"
:
"Point"
,
...
@@ -730,7 +727,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
...
@@ -730,7 +727,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
with
self
.
assertRaisesMessage
(
ValueError
,
'Input geometry already has SRID:
%
d.'
%
pnt
.
srid
):
with
self
.
assertRaisesMessage
(
ValueError
,
'Input geometry already has SRID:
%
d.'
%
pnt
.
srid
):
GEOSGeometry
(
pnt
.
ewkb
,
srid
=
1
)
GEOSGeometry
(
pnt
.
ewkb
,
srid
=
1
)
@skipUnless
(
HAS_GDAL
,
"GDAL is required."
)
def
test_custom_srid
(
self
):
def
test_custom_srid
(
self
):
"""Test with a null srid and a srid unknown to GDAL."""
"""Test with a null srid and a srid unknown to GDAL."""
for
srid
in
[
None
,
999999
]:
for
srid
in
[
None
,
999999
]:
...
@@ -1016,7 +1012,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
...
@@ -1016,7 +1012,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
# And, they should be equal.
# And, they should be equal.
self
.
assertEqual
(
gc1
,
gc2
)
self
.
assertEqual
(
gc1
,
gc2
)
@skipUnless
(
HAS_GDAL
,
"GDAL is required."
)
def
test_gdal
(
self
):
def
test_gdal
(
self
):
"Testing `ogr` and `srs` properties."
"Testing `ogr` and `srs` properties."
g1
=
fromstr
(
'POINT(5 23)'
)
g1
=
fromstr
(
'POINT(5 23)'
)
...
@@ -1042,7 +1037,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
...
@@ -1042,7 +1037,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
self
.
assertNotEqual
(
poly
.
_ptr
,
cpy1
.
_ptr
)
self
.
assertNotEqual
(
poly
.
_ptr
,
cpy1
.
_ptr
)
self
.
assertNotEqual
(
poly
.
_ptr
,
cpy2
.
_ptr
)
self
.
assertNotEqual
(
poly
.
_ptr
,
cpy2
.
_ptr
)
@skipUnless
(
HAS_GDAL
,
"GDAL is required to transform geometries"
)
def
test_transform
(
self
):
def
test_transform
(
self
):
"Testing `transform` method."
"Testing `transform` method."
orig
=
GEOSGeometry
(
'POINT (-104.609 38.255)'
,
4326
)
orig
=
GEOSGeometry
(
'POINT (-104.609 38.255)'
,
4326
)
...
@@ -1067,13 +1061,11 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
...
@@ -1067,13 +1061,11 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
self
.
assertAlmostEqual
(
trans
.
x
,
p
.
x
,
prec
)
self
.
assertAlmostEqual
(
trans
.
x
,
p
.
x
,
prec
)
self
.
assertAlmostEqual
(
trans
.
y
,
p
.
y
,
prec
)
self
.
assertAlmostEqual
(
trans
.
y
,
p
.
y
,
prec
)
@skipUnless
(
HAS_GDAL
,
"GDAL is required to transform geometries"
)
def
test_transform_3d
(
self
):
def
test_transform_3d
(
self
):
p3d
=
GEOSGeometry
(
'POINT (5 23 100)'
,
4326
)
p3d
=
GEOSGeometry
(
'POINT (5 23 100)'
,
4326
)
p3d
.
transform
(
2774
)
p3d
.
transform
(
2774
)
self
.
assertEqual
(
p3d
.
z
,
100
)
self
.
assertEqual
(
p3d
.
z
,
100
)
@skipUnless
(
HAS_GDAL
,
"GDAL is required."
)
def
test_transform_noop
(
self
):
def
test_transform_noop
(
self
):
""" Testing `transform` method (SRID match) """
""" Testing `transform` method (SRID match) """
# transform() should no-op if source & dest SRIDs match,
# transform() should no-op if source & dest SRIDs match,
...
@@ -1090,7 +1082,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
...
@@ -1090,7 +1082,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
self
.
assertEqual
(
g1
.
srid
,
4326
)
self
.
assertEqual
(
g1
.
srid
,
4326
)
self
.
assertIsNot
(
g1
,
g
,
"Clone didn't happen"
)
self
.
assertIsNot
(
g1
,
g
,
"Clone didn't happen"
)
@skipUnless
(
HAS_GDAL
,
"GDAL is required."
)
def
test_transform_nosrid
(
self
):
def
test_transform_nosrid
(
self
):
""" Testing `transform` method (no SRID or negative SRID) """
""" Testing `transform` method (no SRID or negative SRID) """
...
...
tests/gis_tests/inspectapp/tests.py
Dosyayı görüntüle @
2dc32802
...
@@ -2,7 +2,8 @@ import os
...
@@ -2,7 +2,8 @@ import os
import
re
import
re
from
io
import
StringIO
from
io
import
StringIO
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.gdal
import
GDAL_VERSION
,
Driver
,
GDALException
from
django.contrib.gis.utils.ogrinspect
import
ogrinspect
from
django.core.management
import
call_command
from
django.core.management
import
call_command
from
django.db
import
connection
,
connections
from
django.db
import
connection
,
connections
from
django.test
import
TestCase
,
skipUnlessDBFeature
from
django.test
import
TestCase
,
skipUnlessDBFeature
...
@@ -10,12 +11,7 @@ from django.test.utils import modify_settings
...
@@ -10,12 +11,7 @@ from django.test.utils import modify_settings
from
..test_data
import
TEST_DATA
from
..test_data
import
TEST_DATA
from
..utils
import
postgis
from
..utils
import
postgis
from
.models
import
AllOGRFields
if
HAS_GDAL
:
from
django.contrib.gis.gdal
import
Driver
,
GDALException
,
GDAL_VERSION
from
django.contrib.gis.utils.ogrinspect
import
ogrinspect
from
.models
import
AllOGRFields
class
InspectDbTests
(
TestCase
):
class
InspectDbTests
(
TestCase
):
...
...
tests/gis_tests/layermap/tests.py
Dosyayı görüntüle @
2dc32802
...
@@ -4,12 +4,11 @@ from copy import copy
...
@@ -4,12 +4,11 @@ from copy import copy
from
decimal
import
Decimal
from
decimal
import
Decimal
from
django.conf
import
settings
from
django.conf
import
settings
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.geos
import
HAS_GEOS
from
django.contrib.gis.geos
import
HAS_GEOS
from
django.db
import
connection
from
django.db
import
connection
from
django.test
import
TestCase
,
override_settings
from
django.test
import
TestCase
,
override_settings
if
HAS_GEOS
and
HAS_GDAL
:
if
HAS_GEOS
:
from
django.contrib.gis.utils.layermapping
import
(
from
django.contrib.gis.utils.layermapping
import
(
LayerMapping
,
LayerMapError
,
InvalidDecimal
,
InvalidString
,
LayerMapping
,
LayerMapError
,
InvalidDecimal
,
InvalidString
,
MissingForeignKey
,
MissingForeignKey
,
...
...
tests/gis_tests/rasterapp/models.py
Dosyayı görüntüle @
2dc32802
from
django.contrib.gis.db
import
models
from
django.contrib.gis.db
import
models
from
django.contrib.gis.gdal
import
HAS_GDAL
if
HAS_GDAL
:
class
RasterModel
(
models
.
Model
):
rast
=
models
.
RasterField
(
'A Verbose Raster Name'
,
null
=
True
,
srid
=
4326
,
spatial_index
=
True
,
blank
=
True
)
rastprojected
=
models
.
RasterField
(
'A Projected Raster Table'
,
srid
=
3086
,
null
=
True
)
geom
=
models
.
PointField
(
null
=
True
)
class
Meta
:
class
RasterModel
(
models
.
Model
):
required_db_features
=
[
'supports_raster'
]
rast
=
models
.
RasterField
(
'A Verbose Raster Name'
,
null
=
True
,
srid
=
4326
,
spatial_index
=
True
,
blank
=
True
)
rastprojected
=
models
.
RasterField
(
'A Projected Raster Table'
,
srid
=
3086
,
null
=
True
)
geom
=
models
.
PointField
(
null
=
True
)
def
__str__
(
self
)
:
class
Meta
:
return
str
(
self
.
id
)
required_db_features
=
[
'supports_raster'
]
class
RasterRelatedModel
(
models
.
Model
):
def
__str__
(
self
):
r
astermodel
=
models
.
ForeignKey
(
RasterModel
,
models
.
CASCADE
)
r
eturn
str
(
self
.
id
)
class
Meta
:
required_db_features
=
[
'supports_raster'
]
def
__str__
(
self
):
class
RasterRelatedModel
(
models
.
Model
):
return
str
(
self
.
id
)
rastermodel
=
models
.
ForeignKey
(
RasterModel
,
models
.
CASCADE
)
class
Meta
:
required_db_features
=
[
'supports_raster'
]
def
__str__
(
self
):
return
str
(
self
.
id
)
tests/gis_tests/rasterapp/test_rasterfield.py
Dosyayı görüntüle @
2dc32802
...
@@ -3,7 +3,7 @@ import json
...
@@ -3,7 +3,7 @@ import json
from
django.contrib.gis.db.models.fields
import
BaseSpatialField
from
django.contrib.gis.db.models.fields
import
BaseSpatialField
from
django.contrib.gis.db.models.functions
import
Distance
from
django.contrib.gis.db.models.functions
import
Distance
from
django.contrib.gis.db.models.lookups
import
DistanceLookupBase
,
GISLookup
from
django.contrib.gis.db.models.lookups
import
DistanceLookupBase
,
GISLookup
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.gdal
import
GDALRaster
from
django.contrib.gis.geos
import
GEOSGeometry
from
django.contrib.gis.geos
import
GEOSGeometry
from
django.contrib.gis.measure
import
D
from
django.contrib.gis.measure
import
D
from
django.contrib.gis.shortcuts
import
numpy
from
django.contrib.gis.shortcuts
import
numpy
...
@@ -11,10 +11,7 @@ from django.db.models import Q
...
@@ -11,10 +11,7 @@ from django.db.models import Q
from
django.test
import
TransactionTestCase
,
skipUnlessDBFeature
from
django.test
import
TransactionTestCase
,
skipUnlessDBFeature
from
..data.rasters.textrasters
import
JSON_RASTER
from
..data.rasters.textrasters
import
JSON_RASTER
from
.models
import
RasterModel
,
RasterRelatedModel
if
HAS_GDAL
:
from
django.contrib.gis.gdal
import
GDALRaster
from
.models
import
RasterModel
,
RasterRelatedModel
@skipUnlessDBFeature
(
'supports_raster'
)
@skipUnlessDBFeature
(
'supports_raster'
)
...
...
tests/test_runner/test_discover_runner.py
Dosyayı görüntüle @
2dc32802
...
@@ -135,8 +135,8 @@ class DiscoverRunnerTest(TestCase):
...
@@ -135,8 +135,8 @@ class DiscoverRunnerTest(TestCase):
"""
"""
Tests shouldn't be discovered twice when discovering on overlapping paths.
Tests shouldn't be discovered twice when discovering on overlapping paths.
"""
"""
base_app
=
'
gi
s_tests'
base_app
=
'
form
s_tests'
sub_app
=
'
gis_tests.geo3d
'
sub_app
=
'
forms_tests.field_tests
'
with
self
.
modify_settings
(
INSTALLED_APPS
=
{
'append'
:
sub_app
}):
with
self
.
modify_settings
(
INSTALLED_APPS
=
{
'append'
:
sub_app
}):
single
=
DiscoverRunner
()
.
build_suite
([
base_app
])
.
countTestCases
()
single
=
DiscoverRunner
()
.
build_suite
([
base_app
])
.
countTestCases
()
dups
=
DiscoverRunner
()
.
build_suite
([
base_app
,
sub_app
])
.
countTestCases
()
dups
=
DiscoverRunner
()
.
build_suite
([
base_app
,
sub_app
])
.
countTestCases
()
...
...
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