How to use the svgis.errors.SvgisError function in svgis

To help you get started, we’ve selected a few svgis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fitnr / svgis / tests / test_svgis.py View on Github external
def testSvgisError(self):
        with self.assertRaises(errors.SvgisError):
            raise errors.SvgisError('This is an error')
github fitnr / svgis / tests / test_error.py View on Github external
def testDrawInvalidGeometry(self):
        with self.assertRaises(errors.SvgisError):
            draw.geometry(self.feature['geometry'])
github fitnr / svgis / tests / test_svgis.py View on Github external
def testSvgisError(self):
        with self.assertRaises(errors.SvgisError):
            raise errors.SvgisError('This is an error')
github fitnr / svgis / tests / test_draw.py View on Github external
def testUnkownGeometry(self):
        with self.assertRaises(errors.SvgisError):
            draw.geometry({"type": "FooBar", "coordinates": []})
github fitnr / svgis / svgis / chloropleth.py View on Github external
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)
github fitnr / svgis / svgis / draw.py View on Github external
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']))
github fitnr / svgis / svgis / errors.py View on Github external
def __init__(self, arg):
        super(SvgisError, self).__init__(arg)
github fitnr / svgis / svgis / svgis.py View on Github external
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''