How to use the topojson.coordinatesystems.systems function in topojson

To help you get started, we’ve selected a few topojson 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 calvinmetcalf / topojson.py / topojson / topology.py View on Github external
def topology (objects, stitchPoles=True,quantization=1e4,id_key='id',property_transform=property_transform,system = False,simplify=False):
    ln = Line(quantization)
    id_func = lambda x:x.get(id_key, None)
    if simplify:
        objects = simplify_object(objects,simplify)
    [x0,x1,y0,y1]=bound(objects)
    
    oversize = x0 < -180 - E or x1 > 180 + E or y0 < -90 - E or y1 > 90 + E
    if not system:
        if oversize:
            system =systems["cartesian"]
        else:
            system = systems["spherical"]
    if system.name == 'spherical':
        if oversize:
            raise Exception(u"spherical coordinates outside of [±180°, ±90°]")
        if stitchPoles:
            stitch(objects)
            [x0,x1,y0,y1] = bound(objects)
        if x0 < -180 + E:
            x0 = -180
        if x1 > 180 - E:
            x1 = 180
        if y0 < -90 + E:
            y0 = -90
        if y1 > 90 - E:
            y1 = 90
    if is_infinit(x0):
        x0 = 0