# How to use topojson - 10 common examples

## 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. calvinmetcalf / topojson.py / topojson / topology.py View on Github ``````y1 = 90
if is_infinit(x0):
x0 = 0
if is_infinit(x1):
x1 = 0

if is_infinit(y0):
y0 = 0
if is_infinit(y1):
y1 = 0
[kx,ky]=make_ks(quantization,x0,x1,y0,y1)
if not quantization:
quantization = x1 + 1
x0 = y0 = 0

class findEmax(Types):
def __init__(self,obj):
self.emax=0
self.obj(obj)
def point(self,point):
x1 = point
y1 = point
x = ((x1 - x0) * kx)
y =((y1 - y0) * ky)
ee = system.distance(x1, y1, x / kx + x0, y / ky + y0)
if ee > self.emax:
self.emax = ee
point = int(x)
point = int(y)
finde=findEmax(objects)
emax = finde.emax
# Clock(objects,system.ring_area)`````` calvinmetcalf / topojson.py / topojson / line.py View on Github ``````i+=1
point = points[(i + k) % n]
p = self.arcs.peak(point)
if not mysterious_line_test(p, t):
tInP = all(map(lambda line: line in p,t))
pInT = all(map(lambda line: line in t,p))
if tInP:
current_arc.append(point);
self.arc(current_arc)
if not tInP and not pInT and len(current_arc):
self.arc(Strut([current_arc[-1], point]))
if pInT and len(current_arc):
current_arc = Strut([current_arc[-1]])
else:
current_arc = Strut();
if not len(current_arc) or point_compare(current_arc[-1], point):
current_arc.append(point) # skip duplicate points
t = p
self.arc(current_arc, True)
return self.line_arcs
def line_closed(self,points):`````` calvinmetcalf / topojson.py / topojson / line.py View on Github ``````if p and not mysterious_line_test(p, t):
tInP = all(map(lambda line:line in p,t))
pInT = all(map(lambda line:line in t,p))
if tInP and not pInT:
k-=1
break
p = t
k+=1
# If no shared starting point is found for closed lines, rotate to minimum.
if k == n and isinstance(p,list) and len(p) &gt; 1:
point0 = points
i = 2
k=0
while i 0:
point0 = point
k = i
i+=1
i = -1
if opened:
m = n-1
else:
m = n
while i &lt; m:
i+=1
point = points[(i + k) % n]
p = self.arcs.peak(point)
if not mysterious_line_test(p, t):
tInP = all(map(lambda line: line in p,t))
pInT = all(map(lambda line: line in t,p))
if tInP:`````` calvinmetcalf / topojson.py / topojson / line.py View on Github ``````while i &lt; m:
i+=1
point = points[(i + k) % n]
p = self.arcs.peak(point)
if not mysterious_line_test(p, t):
tInP = all(map(lambda line: line in p,t))
pInT = all(map(lambda line: line in t,p))
if tInP:
current_arc.append(point);
self.arc(current_arc)
if not tInP and not pInT and len(current_arc):
self.arc(Strut([current_arc[-1], point]))
if pInT and len(current_arc):
current_arc = Strut([current_arc[-1]])
else:
current_arc = Strut();
if not len(current_arc) or point_compare(current_arc[-1], point):
current_arc.append(point) # skip duplicate points
t = p
self.arc(current_arc, True)
return self.line_arcs
def line_closed(self,points):`````` calvinmetcalf / topojson.py / topojson / line.py View on Github ``````if opened:
m = n-1
else:
m = n
while i &lt; m:
i+=1
point = points[(i + k) % n]
p = self.arcs.peak(point)
if not mysterious_line_test(p, t):
tInP = all(map(lambda line: line in p,t))
pInT = all(map(lambda line: line in t,p))
if tInP:
current_arc.append(point);
self.arc(current_arc)
if not tInP and not pInT and len(current_arc):
self.arc(Strut([current_arc[-1], point]))
if pInT and len(current_arc):
current_arc = Strut([current_arc[-1]])
else:
current_arc = Strut();
if not len(current_arc) or point_compare(current_arc[-1], point):
current_arc.append(point) # skip duplicate points
t = p
self.arc(current_arc, True)
return self.line_arcs
def line_closed(self,points):`````` calvinmetcalf / topojson.py / topojson / line.py View on Github ``````else:
m = n
while i &lt; m:
i+=1
point = points[(i + k) % n]
p = self.arcs.peak(point)
if not mysterious_line_test(p, t):
tInP = all(map(lambda line: line in p,t))
pInT = all(map(lambda line: line in t,p))
if tInP:
current_arc.append(point);
self.arc(current_arc)
if not tInP and not pInT and len(current_arc):
self.arc(Strut([current_arc[-1], point]))
if pInT and len(current_arc):
current_arc = Strut([current_arc[-1]])
else:
current_arc = Strut();
if not len(current_arc) or point_compare(current_arc[-1], point):
current_arc.append(point) # skip duplicate points
t = p
self.arc(current_arc, True)
return self.line_arcs
def line_closed(self,points):`````` calvinmetcalf / topojson.py / topojson / line.py View on Github ``````def line(self,points,opened):
self.line_arcs = [];
n = len(points)
current_arc = Strut()
k = 0
p=False
t=False
if not opened:
points.pop()
n-=1
while k &lt; n:
t = self.arcs.peak(points[k])
if opened:
break
if p and not mysterious_line_test(p, t):
tInP = all(map(lambda line:line in p,t))
pInT = all(map(lambda line:line in t,p))
if tInP and not pInT:
k-=1
break
p = t
k+=1
# If no shared starting point is found for closed lines, rotate to minimum.
if k == n and isinstance(p,list) and len(p) &gt; 1:
point0 = points
i = 2
k=0
while i 0:
point0 = point`````` calvinmetcalf / topojson.py / topojson / line.py View on Github ``````while i 0:
point0 = point
k = i
i+=1
i = -1
if opened:
m = n-1
else:
m = n
while i &lt; m:
i+=1
point = points[(i + k) % n]
p = self.arcs.peak(point)
if not mysterious_line_test(p, t):
tInP = all(map(lambda line: line in p,t))
pInT = all(map(lambda line: line in t,p))
if tInP:
current_arc.append(point);
self.arc(current_arc)
if not tInP and not pInT and len(current_arc):
self.arc(Strut([current_arc[-1], point]))
if pInT and len(current_arc):
current_arc = Strut([current_arc[-1]])
else:
current_arc = Strut();
if not len(current_arc) or point_compare(current_arc[-1], point):
current_arc.append(point) # skip duplicate points
t = p
self.arc(current_arc, True)
return self.line_arcs`````` calvinmetcalf / topojson.py / topojson / topology.py View on Github ``````stitch(objects)
[x0,x1,y0,y1] = bound(objects)
if x0 &lt; -180 + E:
x0 = -180
if x1 &gt; 180 - E:
x1 = 180
if y0 &lt; -90 + E:
y0 = -90
if y1 &gt; 90 - E:
y1 = 90
if is_infinit(x0):
x0 = 0
if is_infinit(x1):
x1 = 0

if is_infinit(y0):
y0 = 0
if is_infinit(y1):
y1 = 0
[kx,ky]=make_ks(quantization,x0,x1,y0,y1)
if not quantization:
quantization = x1 + 1
x0 = y0 = 0

class findEmax(Types):
def __init__(self,obj):
self.emax=0
self.obj(obj)
def point(self,point):
x1 = point
y1 = point
x = ((x1 - x0) * kx)`````` calvinmetcalf / topojson.py / topojson / topology.py View on Github ``````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 &lt; -180 + E:
x0 = -180
if x1 &gt; 180 - E:
x1 = 180
if y0 &lt; -90 + E:
y0 = -90
if y1 &gt; 90 - E:
y1 = 90
if is_infinit(x0):
x0 = 0
if is_infinit(x1):
x1 = 0

if is_infinit(y0):
y0 = 0
if is_infinit(y1):
y1 = 0
[kx,ky]=make_ks(quantization,x0,x1,y0,y1)
if not quantization:
quantization = x1 + 1
x0 = y0 = 0

class findEmax(Types):
def __init__(self,obj):
self.emax=0``````

## topojson

topojson - a powerful library to encode geographic data as topology in Python!🌍 GitHub BSD-3-Clause Latest version published 9 months ago

59 / 100

## Popular Python code snippets

Find secure code to use in your application or website