def __init__(self,pts):
            """
            Create a new Circle helper. Constructing a Circle with one coordinate
            creates a 0 diameter circle, centered on the coordinate. Constructing
            a Circle with two coordinates creates a circle positioned between the
            two coordinates, with the diameter set to the distance between the
            points. Constructing a Circle with three coordinates creates a circle
            that passes through all three points.

            @param pts: A set of points that lay on the perimeter of this circle.

            @return: A calculated Circle that contains the coordinates.
            """
            if len(pts) == 1:
                # Create a zero diameter circle at the coordinate location
                self.cx = pts[0].coords[0]
                self.cy = pts[0].coords[1]
                self.r = 0
            elif len(pts) == 2:
                # Create a circle between the coordinates, with the diameter
                # set to the distance between the points.
                ls = LineString(pts)
                self.cx = ls.centroid.x
                self.cy = ls.centroid.y
                self.r = ls.length / 2
            elif len(pts) == 3:
                # Create a circle that contains all three points
                try:
                    (p1,p2,p3,) = self.deperpendicularize(pts)
                except ValueError:
                    # If the coordinates cannot be deperpendicularized, assume
                    # that they are colinear.
                    ls = LineString(pts)
                    self.cx = ls.centroid.x
                    self.cy = ls.centroid.y
                    self.r = ls.length / 2
                    return

                # If the coordinates describe a pair of lines that are perpendicular
                # and are parallel to the X and Y axes, the center of that rectangle
                # is the center of the circle.
                if abs(p2.coords[0] - p1.coords[0]) == 0 and abs(p3.coords[1] - p2.coords[1]) == 0:
                    self.cx = (p2.coords[0] + p3.coords[0]) / 2
                    self.cy = (p1.coords[1] + p2.coords[1]) / 2
                    ls = LineString([p1,Point(self.cx, self.cy)])
                    self.r = ls.length
                    return

                # Determination of the center point is described pretty well here:
                #
                # "Equation of a Circle from 3 Points (2 dimensions)"
                # http://paulbourke.net/geometry/circlefrom3/
                #
                m1 = (p2.coords[1] - p1.coords[1]) / (p2.coords[0] - p1.coords[0])
                m2 = (p3.coords[1] - p2.coords[1]) / (p3.coords[0] - p2.coords[0])

                self.cx = (m1 * m2 * (p1.coords[1] - p3.coords[1]) + \
                    m2 * (p1.coords[0] + p2.coords[0]) - \
                    m1 * (p2.coords[0] + p3.coords[0]) ) / \
                    (2 * (m2-m1) )
                self.cy = -1 * (self.cx - (p1.coords[0]+p2.coords[0]) / 2.0) / m1 + \
                    (p1.coords[1] + p2.coords[1]) / 2.0
                lsR = LineString(pts[0], (self.cx,self.cy,))
                self.r = lsR.length
            else:
                # Creating a circle with 0 or > 3 coordinates is not supported.
                self.cx = None
                self.cy = None
                self.r = None
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/calculators.py/Roeck.Circle.__init__/original