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
c0fff644
Kaydet (Commit)
c0fff644
authored
Haz 23, 2015
tarafından
Daniel Wiesmann
Kaydeden (comit)
Tim Graham
Haz 23, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25011, Refs #23804 -- Added check for GDAL on RasterField initialization
üst
4202959b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
8 deletions
+43
-8
fields.py
django/contrib/gis/db/models/fields.py
+8
-1
__init__.py
django/contrib/gis/gdal/__init__.py
+2
-1
models.py
tests/gis_tests/models.py
+9
-4
models.py
tests/gis_tests/rasterapp/models.py
+1
-1
test_rasterfield.py
tests/gis_tests/rasterapp/test_rasterfield.py
+23
-1
No files found.
django/contrib/gis/db/models/fields.py
Dosyayı görüntüle @
c0fff644
from
django.contrib.gis
import
forms
from
django.contrib.gis.db.models.lookups
import
gis_lookups
from
django.contrib.gis.db.models.proxy
import
SpatialProxy
from
django.contrib.gis.gdal
.raster.source
import
GDALRaster
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.geometry.backend
import
Geometry
,
GeometryException
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db.models.expressions
import
Expression
...
...
@@ -405,6 +405,11 @@ class RasterField(BaseSpatialField):
description
=
_
(
"Raster Field"
)
geom_type
=
'RASTER'
def
__init__
(
self
,
*
args
,
**
kwargs
):
if
not
HAS_GDAL
:
raise
ImproperlyConfigured
(
'RasterField requires GDAL.'
)
super
(
RasterField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
_check_connection
(
self
,
connection
):
# Make sure raster fields are used only on backends with raster support.
if
not
connection
.
features
.
gis_enabled
or
not
connection
.
features
.
supports_raster
:
...
...
@@ -426,6 +431,8 @@ class RasterField(BaseSpatialField):
def
contribute_to_class
(
self
,
cls
,
name
,
**
kwargs
):
super
(
RasterField
,
self
)
.
contribute_to_class
(
cls
,
name
,
**
kwargs
)
# Importing GDALRaster raises an exception on systems without gdal.
from
django.contrib.gis.gdal
import
GDALRaster
# Setup for lazy-instantiated Raster object. For large querysets, the
# instantiation of all GDALRasters can potentially be expensive. This
# delays the instantiation of the objects to the moment of evaluation
...
...
django/contrib/gis/gdal/__init__.py
Dosyayı görüntüle @
c0fff644
...
...
@@ -53,7 +53,8 @@ try:
HAS_GDAL
=
True
__all__
+=
[
'Driver'
,
'DataSource'
,
'gdal_version'
,
'gdal_full_version'
,
'GDAL_VERSION'
,
'SpatialReference'
,
'CoordTransform'
,
'OGRGeometry'
,
'GDALRaster'
,
'GDAL_VERSION'
,
'SpatialReference'
,
'CoordTransform'
,
'OGRGeometry'
,
]
except
GDALException
:
HAS_GDAL
=
False
...
...
tests/gis_tests/models.py
Dosyayı görüntüle @
c0fff644
...
...
@@ -6,12 +6,12 @@ class DummyField(models.Field):
def
__init__
(
self
,
dim
=
None
,
srid
=
None
,
geography
=
None
,
spatial_index
=
True
,
*
args
,
**
kwargs
):
super
(
DummyField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
try
:
from
django.contrib.gis.db
import
models
try
:
models
.
RasterField
()
except
ImproperlyConfigured
:
models
.
RasterField
=
DummyField
# Store a version of the original raster field for testing the exception
# raised if GDAL isn't installed.
models
.
OriginalRasterField
=
models
.
RasterField
except
ImproperlyConfigured
:
models
.
GeoManager
=
models
.
Manager
models
.
GeometryField
=
DummyField
...
...
@@ -21,3 +21,8 @@ except ImproperlyConfigured:
models
.
PointField
=
DummyField
models
.
PolygonField
=
DummyField
models
.
RasterField
=
DummyField
try
:
models
.
RasterField
()
except
ImproperlyConfigured
:
models
.
RasterField
=
DummyField
tests/gis_tests/rasterapp/models.py
Dosyayı görüntüle @
c0fff644
...
...
@@ -2,7 +2,7 @@ from ..models import models
class
RasterModel
(
models
.
Model
):
rast
=
models
.
RasterField
(
null
=
True
,
srid
=
4326
,
spatial_index
=
True
,
blank
=
True
)
rast
=
models
.
RasterField
(
'A Verbose Raster Name'
,
null
=
True
,
srid
=
4326
,
spatial_index
=
True
,
blank
=
True
)
class
Meta
:
required_db_features
=
[
'supports_raster'
]
...
...
tests/gis_tests/rasterapp/test_rasterfield.py
Dosyayı görüntüle @
c0fff644
import
json
from
unittest
import
skipIf
from
django.contrib.gis.gdal
import
HAS_GDAL
from
django.contrib.gis.shortcuts
import
numpy
from
django.test
import
TransactionTestCase
,
skipUnlessDBFeature
from
django.core.exceptions
import
ImproperlyConfigured
from
django.test
import
TestCase
,
TransactionTestCase
,
skipUnlessDBFeature
from
..data.rasters.textrasters
import
JSON_RASTER
from
..models
import
models
from
.models
import
RasterModel
...
...
@@ -70,3 +74,21 @@ class RasterFieldTest(TransactionTestCase):
[
-
87.9298551266551
,
9.459646421449934e-06
,
0.0
,
23.94249275457565
,
0.0
,
-
9.459646421449934e-06
]
)
def
test_verbose_name_arg
(
self
):
"""
RasterField should accept a positional verbose name argument.
"""
self
.
assertEqual
(
RasterModel
.
_meta
.
get_field
(
'rast'
)
.
verbose_name
,
'A Verbose Raster Name'
)
@skipIf
(
HAS_GDAL
,
'Test raster field exception on systems without GDAL.'
)
class
RasterFieldWithoutGDALTest
(
TestCase
):
def
test_raster_field_without_gdal_exception
(
self
):
msg
=
'RasterField requires GDAL.'
with
self
.
assertRaisesMessage
(
ImproperlyConfigured
,
msg
):
models
.
OriginalRasterField
()
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