How to use svgis - 10 common examples

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 / svgis / projection.py View on Github external
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)
github fitnr / svgis / tests / test_style.py View on Github external
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')
github fitnr / svgis / tests / test_style.py View on Github external
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')
github fitnr / svgis / tests / test_style.py View on Github external
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_')
github fitnr / svgis / tests / test_style.py View on Github external
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')
github fitnr / svgis / tests / test_style.py View on Github external
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')
github fitnr / svgis / tests / test_style.py View on Github external
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')
github fitnr / svgis / tests / test_bounding.py View on Github external
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)
github fitnr / svgis / tests / test_bounding.py View on Github external
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)
github fitnr / svgis / tests / test_svg.py View on Github external
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