How to use the topojson.utils.point_compare 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 / line.py View on Github external
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):
github calvinmetcalf / topojson.py / topojson / line.py View on Github external
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) > 1:
            point0 = points[0]
            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 < 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:
github calvinmetcalf / topojson.py / topojson / arcs.py View on Github external
def check(self,arcs):
        a0 = arcs[0]
        a1 = arcs[-1]
        point = a0 if point_compare(a0, a1) < 0 else a1
        point_arcs = self.get_point_arcs(point)
        h = self.get_hash(arcs)
        if h in self.db:
            return int(self.db[h])
        else:
            index = self.length
            point_arcs.append(arcs)
            self.db[h]=index
            self.db[self.get_hash(list(reversed(arcs)))]=~index
            self.push(arcs)
            return index