Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raise ValueError('generatecrs missing bounds and file crs')
is_longlat = _is_longlat(file_crs)
if method == 'default':
# Check if file_crs _is_longlat, if not use that.
# Option to continue returning default if we didn't get a file_crs
if is_longlat:
method = 'local'
else:
return fiona.crs.to_string(file_crs)
if is_longlat:
longlat_bounds = bounds
else:
longlat_bounds = bounding.transform(file_crs, DEFAULT_GEOID, bounds)
minx, miny, maxx, maxy = longlat_bounds
if method == 'utm':
midx = (minx + maxx) / 2
midy = (miny + maxy) / 2
return utm_proj4(midx, midy)
elif method == 'local':
# Create a custom TM projection
x0 = (float(minx) + float(maxx)) // 2
return tm_proj4(x0, miny, maxy)
def testSanitize(self):
assert style.sanitize(None) == u'None'
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
self.assertEqual(style.sanitize(u'"huh"'), u'huh')
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
self.assertEqual(style.sanitize(u'"huh"'), u'huh')
def testSanitize(self):
assert style.sanitize(None) == u'None'
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
def testSanitize(self):
assert style.sanitize(None) == u'None'
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
self.assertEqual(style.sanitize(u'"huh"'), u'huh')
def testSanitize(self):
assert style.sanitize(None) == u'None'
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
self.assertEqual(style.sanitize(u'"huh"'), u'huh')
def testSanitize(self):
assert style.sanitize(None) == u'None'
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
self.assertEqual(style.sanitize(u'"huh"'), u'huh')
def testTransformBounds(self):
bounds = (-74, 42, -73, 43)
with self.assertRaises(TypeError):
bounding.transform(None, {'init': 'epsg:4269'}, bounds)
with self.assertRaises(TypeError):
bounding.transform({'init': 'epsg:4269'}, None, bounds)
a = bounding.transform({'init': 'epsg:4269'}, {'init': 'epsg:3102'}, bounds)
fixture = (43332273.50269379, 15584115.894447982, 44004519.424246654, 16320640.928220816)
for z in zip(a, fixture):
self.assertAlmostEqual(*z, places=5)
def testTransformBounds(self):
bounds = (-74, 42, -73, 43)
with self.assertRaises(TypeError):
bounding.transform(None, {'init': 'epsg:4269'}, bounds)
with self.assertRaises(TypeError):
bounding.transform({'init': 'epsg:4269'}, None, bounds)
a = bounding.transform({'init': 'epsg:4269'}, {'init': 'epsg:3102'}, bounds)
fixture = (43332273.50269379, 15584115.894447982, 44004519.424246654, 16320640.928220816)
for z in zip(a, fixture):
self.assertAlmostEqual(*z, places=5)
def testGroup(self):
g = svg.group()
self.assertIsInstance(g, six.string_types)
g = svg.group(transform="translate(10,10)")
self.assertIn('transform="translate(10,10)"', g)
g = svg.group(transform="scale(10)")
assert 'transform="scale(10)"' in g