Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testUnkownGeometry(self):
with self.assertRaises(errors.SvgisError):
draw.geometry({"type": "FooBar", "coordinates": []})
def testDrawInvalidGeometry(self):
with self.assertRaises(errors.SvgisError):
draw.geometry(self.feature['geometry'])
def testDrawAndConvertToString(self):
draw.geometry(self.linestring['geometry'])
draw.geometry(self.multilinestring['geometry'])
draw.geometry(self.polygon['geometry'])
draw.geometry(self.multipolygon['geometry'])
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
'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)
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''