Here are the examples of the python api django.contrib.gis.geos.error.GEOSException taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
47 Examples
3
View Complete Implementation : geometry.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
def __setstate__(self, state):
# Instantiating from the tuple state that was pickled.
wkb, srid = state
ptr = wkb_r().read(six.memoryview(wkb))
if not ptr:
raise GEOSException('Invalid Geometry loaded from pickled state.')
self.ptr = ptr
self._post_init(srid)
3
View Complete Implementation : geometry.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
def relate_pattern(self, other, pattern):
"""
Returns true if the elements in the DE-9IM intersection matrix for the
two Geometries match the elements in pattern.
"""
if not isinstance(pattern, six.string_types) or len(pattern) > 9:
raise GEOSException('invalid intersection matrix pattern')
return capi.geos_relatepattern(self.ptr, other.ptr, force_bytes(pattern))
3
View Complete Implementation : libgeos.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
def geos_version_info():
"""
Returns a dictionary containing the various version metadata parsed from
the GEOS version string, including the version number, whether the version
is a release candidate (and what number release candidate), and the C API
version.
"""
ver = geos_version().decode()
m = version_regex.match(ver)
if not m:
raise GEOSException('Could not parse version info string "%s"' % ver)
return {key: m.group(key) for key in (
'version', 'release_candidate', 'capi_version', 'major', 'minor', 'subminor')}
3
View Complete Implementation : linestring.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
def _set_list(self, length, items):
ndim = self._cs.dims
hasz = self._cs.hasz # I don't understand why these are different
# create a new coordinate sequence and populate accordingly
cs = GEOSCoordSeq(capi.create_cs(length, ndim), z=hasz)
for i, c in enumerate(items):
cs[i] = c
ptr = self._init_func(cs.ptr)
if ptr:
capi.destroy_geom(self.ptr)
self.ptr = ptr
self._post_init(self.srid)
else:
# can this happen?
raise GEOSException('Geometry resulting from slice deletion was invalid.')
3
View Complete Implementation : point.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
def _set_list(self, length, items):
ptr = self._create_point(length, items)
if ptr:
capi.destroy_geom(self.ptr)
self._ptr = ptr
self._set_cs()
else:
# can this happen?
raise GEOSException('Geometry resulting from slice deletion was invalid.')
3
View Complete Implementation : point.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
@z.setter
def z(self, value):
"Sets the Z component of the Point."
if not self.hasz:
raise GEOSException('Cannot set Z on 2D Point.')
self._cs.setOrdinate(2, 0, value)
3
View Complete Implementation : errcheck.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
def check_minus_one(result, func, cargs):
"Error checking on routines that should not return -1."
if result == -1:
raise GEOSException('Error encountered in GEOS C function "%s".' % func.__name__)
else:
return result
3
View Complete Implementation : errcheck.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
def check_predicate(result, func, cargs):
"Error checking for unary/binary predicate functions."
val = ord(result) # getting the ordinal from the character
if val == 1:
return True
elif val == 0:
return False
else:
raise GEOSException('Error encountered on GEOS C predicate function "%s".' % func.__name__)
3
View Complete Implementation : errcheck.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
def check_sized_string(result, func, cargs):
"""
Error checking for routines that return explicitly sized strings.
This frees the memory allocated by GEOS at the result pointer.
"""
if not result:
raise GEOSException('Invalid string pointer returned by GEOS C function "%s"' % func.__name__)
# A c_size_t object is pasted in by reference for the second
# argument on these routines, and its needed to determine the
# correct size.
s = string_at(result, last_arg_byref(cargs))
# Freeing the memory allocated within GEOS
free(result)
return s
3
View Complete Implementation : errcheck.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
def check_string(result, func, cargs):
"""
Error checking for routines that return strings.
This frees the memory allocated by GEOS at the result pointer.
"""
if not result:
raise GEOSException('Error encountered checking string return value in GEOS C function "%s".' % func.__name__)
# Getting the string value at the pointer address.
s = string_at(result)
# Freeing the memory allocated within GEOS
free(result)
return s