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
53c8b2c0
Kaydet (Commit)
53c8b2c0
authored
Eki 04, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #17959 -- Silenced output during GIS tests
üst
0ad6d7e6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
34 deletions
+38
-34
libgdal.py
django/contrib/gis/gdal/libgdal.py
+21
-1
test_ds.py
django/contrib/gis/gdal/tests/test_ds.py
+1
-2
test_geom.py
django/contrib/gis/gdal/tests/test_geom.py
+2
-9
libgeos.py
django/contrib/gis/geos/libgeos.py
+9
-5
test_geos.py
django/contrib/gis/geos/tests/test_geos.py
+5
-17
No files found.
django/contrib/gis/gdal/libgdal.py
Dosyayı görüntüle @
53c8b2c0
from
__future__
import
unicode_literals
import
logging
import
os
import
re
from
ctypes
import
c_char_p
,
CDLL
from
ctypes
import
c_char_p
,
c_int
,
CDLL
,
CFUNCTYPE
from
ctypes.util
import
find_library
from
django.contrib.gis.gdal.error
import
OGRException
logger
=
logging
.
getLogger
(
'django.contrib.gis'
)
# Custom library path set?
try
:
from
django.conf
import
settings
...
...
@@ -86,3 +91,18 @@ GDAL_MINOR_VERSION = int(_verinfo['minor'])
GDAL_SUBMINOR_VERSION
=
_verinfo
[
'subminor'
]
and
int
(
_verinfo
[
'subminor'
])
GDAL_VERSION
=
(
GDAL_MAJOR_VERSION
,
GDAL_MINOR_VERSION
,
GDAL_SUBMINOR_VERSION
)
del
_verinfo
# Set library error handling so as errors are logged
CPLErrorHandler
=
CFUNCTYPE
(
None
,
c_int
,
c_int
,
c_char_p
)
def
err_handler
(
error_class
,
error_number
,
message
):
logger
.
error
(
'GDAL_ERROR
%
d:
%
s'
%
(
error_number
,
message
))
err_handler
=
CPLErrorHandler
(
err_handler
)
def
function
(
name
,
args
,
restype
):
func
=
std_call
(
name
)
func
.
argtypes
=
args
func
.
restype
=
restype
return
func
set_error_handler
=
function
(
'CPLSetErrorHandler'
,
[
CPLErrorHandler
],
CPLErrorHandler
)
set_error_handler
(
err_handler
)
django/contrib/gis/gdal/tests/test_ds.py
Dosyayı görüntüle @
53c8b2c0
...
...
@@ -4,6 +4,7 @@ from django.contrib.gis.gdal import DataSource, Envelope, OGRGeometry, OGRExcept
from
django.contrib.gis.gdal.field
import
OFTReal
,
OFTInteger
,
OFTString
from
django.contrib.gis.geometry.test_data
import
get_ds_file
,
TestDS
,
TEST_DATA
# List of acceptable data sources.
ds_list
=
(
TestDS
(
'test_point'
,
nfeat
=
5
,
nfld
=
3
,
geom
=
'POINT'
,
gtype
=
1
,
driver
=
'ESRI Shapefile'
,
fields
=
{
'dbl'
:
OFTReal
,
'int'
:
OFTInteger
,
'str'
:
OFTString
,},
...
...
@@ -59,7 +60,6 @@ class DataSourceTest(unittest.TestCase):
def
test03a_layers
(
self
):
"Testing Data Source Layers."
print
(
"
\n
BEGIN - expecting out of range feature id error; safe to ignore.
\n
"
)
for
source
in
ds_list
:
ds
=
DataSource
(
source
.
ds
)
...
...
@@ -108,7 +108,6 @@ class DataSourceTest(unittest.TestCase):
# the feature values here while in this loop.
for
fld_name
in
fld_names
:
self
.
assertEqual
(
source
.
field_values
[
fld_name
][
i
],
feat
.
get
(
fld_name
))
print
(
"
\n
END - expecting out of range feature id error; safe to ignore."
)
def
test03b_layer_slice
(
self
):
"Test indexing and slicing on Layers."
...
...
django/contrib/gis/gdal/tests/test_geom.py
Dosyayı görüntüle @
53c8b2c0
...
...
@@ -235,15 +235,8 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
# Both rings in this geometry are not closed.
poly
=
OGRGeometry
(
'POLYGON((0 0, 5 0, 5 5, 0 5), (1 1, 2 1, 2 2, 2 1))'
)
self
.
assertEqual
(
8
,
poly
.
point_count
)
print
(
"
\n
BEGIN - expecting IllegalArgumentException; safe to ignore.
\n
"
)
try
:
c
=
poly
.
centroid
except
OGRException
:
# Should raise an OGR exception, rings are not closed
pass
else
:
self
.
fail
(
'Should have raised an OGRException!'
)
print
(
"
\n
END - expecting IllegalArgumentException; safe to ignore.
\n
"
)
with
self
.
assertRaises
(
OGRException
):
_
=
poly
.
centroid
poly
.
close_rings
()
self
.
assertEqual
(
10
,
poly
.
point_count
)
# Two closing points should've been added
...
...
django/contrib/gis/geos/libgeos.py
Dosyayı görüntüle @
53c8b2c0
...
...
@@ -6,13 +6,17 @@
This module also houses GEOS Pointer utilities, including
get_pointer_arr(), and GEOM_PTR.
"""
import
logging
import
os
import
re
import
sys
from
ctypes
import
c_char_p
,
Structure
,
CDLL
,
CFUNCTYPE
,
POINTER
from
ctypes.util
import
find_library
from
django.contrib.gis.geos.error
import
GEOSException
logger
=
logging
.
getLogger
(
'django.contrib.gis'
)
# Custom library path set?
try
:
from
django.conf
import
settings
...
...
@@ -56,23 +60,23 @@ lgeos = CDLL(lib_path)
# Supposed to mimic the GEOS message handler (C below):
# typedef void (*GEOSMessageHandler)(const char *fmt, ...);
NOTICEFUNC
=
CFUNCTYPE
(
None
,
c_char_p
,
c_char_p
)
def
notice_h
(
fmt
,
lst
,
output_h
=
sys
.
stdout
):
def
notice_h
(
fmt
,
lst
):
fmt
,
lst
=
fmt
.
decode
(),
lst
.
decode
()
try
:
warn_msg
=
fmt
%
lst
except
:
warn_msg
=
fmt
output_h
.
write
(
'GEOS_NOTICE:
%
s
\n
'
%
warn_msg
)
logger
.
warn
(
'GEOS_NOTICE:
%
s
\n
'
%
warn_msg
)
notice_h
=
NOTICEFUNC
(
notice_h
)
ERRORFUNC
=
CFUNCTYPE
(
None
,
c_char_p
,
c_char_p
)
def
error_h
(
fmt
,
lst
,
output_h
=
sys
.
stderr
):
def
error_h
(
fmt
,
lst
):
fmt
,
lst
=
fmt
.
decode
(),
lst
.
decode
()
try
:
err_msg
=
fmt
%
lst
except
:
err_msg
=
fmt
output_h
.
write
(
'GEOS_ERROR:
%
s
\n
'
%
err_msg
)
logger
.
error
(
'GEOS_ERROR:
%
s
\n
'
%
err_msg
)
error_h
=
ERRORFUNC
(
error_h
)
#### GEOS Geometry C data structures, and utility functions. ####
...
...
django/contrib/gis/geos/tests/test_geos.py
Dosyayı görüntüle @
53c8b2c0
...
...
@@ -147,18 +147,13 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
def
test_errors
(
self
):
"Testing the Error handlers."
# string-based
print
(
"
\n
BEGIN - expecting GEOS_ERROR; safe to ignore.
\n
"
)
for
err
in
self
.
geometries
.
errors
:
try
:
g
=
fromstr
(
err
.
wkt
)
except
(
GEOSException
,
ValueError
):
pass
with
self
.
assertRaises
((
GEOSException
,
ValueError
)):
_
=
fromstr
(
err
.
wkt
)
# Bad WKB
self
.
assertRaises
(
GEOSException
,
GEOSGeometry
,
memoryview
(
b
'0'
))
print
(
"
\n
END - expecting GEOS_ERROR; safe to ignore.
\n
"
)
class
NotAGeometry
(
object
):
pass
...
...
@@ -458,7 +453,6 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
def
test_multipolygons
(
self
):
"Testing MultiPolygon objects."
print
(
"
\n
BEGIN - expecting GEOS_NOTICE; safe to ignore.
\n
"
)
prev
=
fromstr
(
'POINT (0 0)'
)
for
mp
in
self
.
geometries
.
multipolygons
:
mpoly
=
fromstr
(
mp
.
wkt
)
...
...
@@ -477,8 +471,6 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
self
.
assertEqual
(
p
.
valid
,
True
)
self
.
assertEqual
(
mpoly
.
wkt
,
MultiPolygon
(
*
tuple
(
poly
.
clone
()
for
poly
in
mpoly
))
.
wkt
)
print
(
"
\n
END - expecting GEOS_NOTICE; safe to ignore.
\n
"
)
def
test_memory_hijinks
(
self
):
"Testing Geometry __del__() on rings and polygons."
#### Memory issues with rings and polygons
...
...
@@ -1025,19 +1017,15 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
g
=
GEOSGeometry
(
"POINT(0 0)"
)
self
.
assertTrue
(
g
.
valid
)
self
.
assert
True
(
isinstance
(
g
.
valid_reason
,
six
.
string_types
)
)
self
.
assert
IsInstance
(
g
.
valid_reason
,
six
.
string_types
)
self
.
assertEqual
(
g
.
valid_reason
,
"Valid Geometry"
)
print
(
"
\n
BEGIN - expecting GEOS_NOTICE; safe to ignore.
\n
"
)
g
=
GEOSGeometry
(
"LINESTRING(0 0, 0 0)"
)
self
.
assert
True
(
not
g
.
valid
)
self
.
assert
True
(
isinstance
(
g
.
valid_reason
,
six
.
string_types
)
)
self
.
assert
False
(
g
.
valid
)
self
.
assert
IsInstance
(
g
.
valid_reason
,
six
.
string_types
)
self
.
assertTrue
(
g
.
valid_reason
.
startswith
(
"Too few points in geometry component"
))
print
(
"
\n
END - expecting GEOS_NOTICE; safe to ignore.
\n
"
)
@unittest.skipUnless
(
geos_version_info
()[
'version'
]
>=
'3.2.0'
,
"geos >= 3.2.0 is required"
)
def
test_linearref
(
self
):
"Testing linear referencing"
...
...
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