How to use the svgis.style.construct_classes 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_style.py View on Github external
def testCreateClasses(self):
        classes = style.construct_classes(self.classes, self.properties)
        self.assertEqual(classes, [u'apple_fruit'])

        classes = style.construct_classes(self.classes, {'apple': u'fruit'})
        self.assertEqual(classes, [u'apple_fruit'])

        classes = style.construct_classes(self.classes, {'apple': u'früit'})
        self.assertEqual(classes, [u'apple_früit'])

        classes = style.construct_classes(self.classes, {'apple': 1})
        self.assertEqual(classes, [u'apple_1'])
github fitnr / svgis / tests / test_style.py View on Github external
def testCreateClasses(self):
        classes = style.construct_classes(self.classes, self.properties)
        self.assertEqual(classes, [u'apple_fruit'])

        classes = style.construct_classes(self.classes, {'apple': u'fruit'})
        self.assertEqual(classes, [u'apple_fruit'])

        classes = style.construct_classes(self.classes, {'apple': u'früit'})
        self.assertEqual(classes, [u'apple_früit'])

        classes = style.construct_classes(self.classes, {'apple': 1})
        self.assertEqual(classes, [u'apple_1'])
github fitnr / svgis / tests / test_style.py View on Github external
def testCreateClassesMissing(self):
        classes = style.construct_classes(self.classes, {'apple': ''})
        self.assertEqual(classes, [u'apple_'])

        classes = style.construct_classes(self.classes, {'apple': None})
        self.assertEqual(classes, [u'apple_None'])
github fitnr / svgis / tests / test_style.py View on Github external
def testConstructClasses(self):
        self.assertEqual(style.construct_classes(('foo',), {'foo': 'bar'}), [u'foo_bar'])
        self.assertEqual(style.construct_classes(['foo'], {'foo': 'bar'}), [u'foo_bar'])

        self.assertEqual(style.construct_classes(['foo'], {'foo': None}), [u'foo_None'])
github fitnr / svgis / svgis / svgis.py View on Github external
if geom is None:
                raise ValueError('NULL geometry')

            # Apply transformations to the geometry.
            for t in transforms:
                geom = t(geom) if t is not None else geom

        except ValueError as e:
            self.log.warning('error transforming feature %s of %s: %s',
                             kwargs.get('id', feature.get('id', '?')), name, e)
            return ''

        # Set up the element's properties.
        drawargs = _style.construct_datas(datas, feature['properties'])

        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',