How to use the svgis.draw.geometry 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_draw.py View on Github external
def testUnkownGeometry(self):
        with self.assertRaises(errors.SvgisError):
            draw.geometry({"type": "FooBar", "coordinates": []})
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_draw.py View on Github external
def testDrawAndConvertToString(self):
        draw.geometry(self.linestring['geometry'])
        draw.geometry(self.multilinestring['geometry'])
        draw.geometry(self.polygon['geometry'])
        draw.geometry(self.multipolygon['geometry'])
github fitnr / svgis / tests / test_draw.py View on Github external
def testGeometryCollection(self):
        gc = {
            "type": "GeometryCollection",
            "id": "GC",
            "geometries": [
                self.polygon['geometry'],
                self.linestring['geometry'],
                self.point['geometry'],
                self.multipolygon['geometry'],
                self.multilinestring['geometry']
            ],
        }
        a = draw.geometry(gc, id='cats')
        assert isinstance(a, six.string_types)
        assert 'id="cats"' in a
github fitnr / svgis / svgis / osm.py View on Github external
'coordinates': scale(zip(px, py), scalar)
    }

    tipe = way.find('tag[@key="type"]')

    if tipe and tipe.get('v', None) == 'multipolygon':
        geometry['type'] = 'MultiPolygon'

    elif geometry['coordinates'][0] == geometry['coordinates'][-1]:
        geometry['type'] = 'Polygon'
        geometry['coordinates'] = [geometry['coordinates']]

    else:
        geometry['type'] = 'LineString'

    return svgisdraw.geometry(geometry, **kwargs)
github fitnr / svgis / svgis / svgis.py View on Github external
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',
                             kwargs.get('id', feature.get('id', '?')), name, e)
            return u''