Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testSvgisError(self):
with self.assertRaises(errors.SvgisError):
raise errors.SvgisError('This is an error')
def testDrawInvalidGeometry(self):
with self.assertRaises(errors.SvgisError):
draw.geometry(self.feature['geometry'])
def testSvgisError(self):
with self.assertRaises(errors.SvgisError):
raise errors.SvgisError('This is an error')
def testUnkownGeometry(self):
with self.assertRaises(errors.SvgisError):
draw.geometry({"type": "FooBar", "coordinates": []})
def databins(features, prop, bins, method):
'''
:features Sequence A sequence of GeoJSON-like features.
:property property to examine.
:n int Number of data bins to create.
:method string "quantile", "interval" (for equal interval).
'''
values = [f['properties'].get(prop) for f in features]
if not any(values):
raise SvgisError("No values found for field: %s" % prop)
bins = min(50, bins)
return _databins(values, bins, method)
if bbox:
geom = transform.clip(geom, bbox)
if geom['type'] in ('Point', 'MultiPoint'):
return points(geom, precision=precision, **kwargs)
if geom['type'] in ('LineString', 'MultiLineString'):
return lines(geom, precision=precision, **kwargs)
if geom['type'] in ('Polygon', 'MultiPolygon'):
return polygons(geom, precision=precision, **kwargs)
if geom['type'] == 'GeometryCollection':
return geometrycollection(geom, bbox, precision, **kwargs)
raise SvgisError("Can't draw features of type: {}".format(geom['type']))
def __init__(self, arg):
super(SvgisError, self).__init__(arg)
classes = _style.construct_classes(classes, feature['properties'])
# Add the layer name to the class list.
if name != '?':
classes.insert(0, _style.sanitize(name))
drawargs['class'] = ' '.join(classes)
if 'id_field' in kwargs and kwargs['id_field'] in feature['properties']:
drawargs['id'] = _style.sanitize(feature['properties'].get(kwargs['id_field']))
try:
# Draw the geometry.
return draw.geometry(geom, precision=precision, **drawargs)
except errors.SvgisError as e:
self.log.warning('unable to draw feature %s of %s: %s',
kwargs.get('id', feature.get('id', '?')), name, e)
return u''