(self, center_x, center_y, width)
return hexagon
Returns a hexagon geometry around the center point.
Returns a hexagon geometry around the center point.
Returns a hexagon geometry around the center point .
def create_hexagon(self, center_x, center_y, width):
        """
        Returns a hexagon geometry around the center point.
        """
        h_val = SQRT_3_DIV_4 * width
        width_quarter = width / 4
        width_half = width / 2
        ring = ogr.Geometry(ogr.wkbLinearRing)

        # Draw hexagon clockwise, beginning with northwest vertice
        ring.AddPoint(center_x - width_quarter, center_y + h_val)
        ring.AddPoint(center_x + width_quarter, center_y + h_val)
        ring.AddPoint(center_x + width_half, center_y)
        ring.AddPoint(center_x + width_quarter, center_y - h_val)
        ring.AddPoint(center_x - width_quarter, center_y - h_val)
        ring.AddPoint(center_x - width_half, center_y)
        ring.AddPoint(center_x - width_quarter, center_y + h_val)

        hexagon = ogr.Geometry(type=ogr.wkbPolygon)
        hexagon.AddGeometry(ring)
        return hexagon
def create_hexagon ( self , center_x , center_y , width ) : h_val = SQRT_3_DIV_4 * width width_quarter = width / 4 width_half = width / 2 ring = ogr . Geometry ( ogr . wkbLinearRing ) # Draw hexagon clockwise, beginning with northwest vertice ring . AddPoint ( center_x - width_quarter , center_y + h_val ) ring . AddPoint ( center_x + width_quarter , center_y + h_val ) ring . AddPoint ( center_x + width_half , center_y ) ring . AddPoint ( center_x + width_quarter , center_y - h_val ) ring . AddPoint ( center_x - width_quarter , center_y - h_val ) ring . AddPoint ( center_x - width_half , center_y ) ring . AddPoint ( center_x - width_quarter , center_y + h_val ) hexagon = ogr . Geometry ( type = ogr . wkbPolygon ) hexagon . AddGeometry ( ring ) return hexagon