original_docstring: Activated by user or when the map window is closed without connecting
              the polygon. Makes the polygon valid by making first and last point
              the same. This is reflected visually. Up until now the user has been
              drawing a line: a polygon is created and shown on the map.
docstring: Activated by user or when the map window is closed without connecting
  the polygon. Makes the polygon valid by making first and last point
  the same. This is reflected visually. Up until now the user has been
  drawing a line: a polygon is created and shown on the map.
docstring_tokens: Activated by user or when the map window is closed without connecting the polygon . Makes the polygon valid by making first and last point the same . This is reflected visually . Up until now the user has been drawing a line : a polygon is created and shown on the map .
code: def finishPolygon(self):
          """Activated by user or when the map window is closed without connecting
              the polygon. Makes the polygon valid by making first and last point
              the same. This is reflected visually. Up until now the user has been
              drawing a line: a polygon is created and shown on the map."""
          # nothing will happen if the code below has already been ran
          if self.finished:
              return
          # connecting the polygon is valid if there's already at least 3 points
          elif len(self.points)>2:
              first_point = self.points[0]
              self.points.append(first_point)
              self.rubberBand.closePoints()
              self.rubberBand.addPoint(first_point, True)
              self.finished = True
              # a polygon is created and added to the map for visual purposes
              map_polygon = QgsGeometry.fromPolygonXY([self.points])
              self.rubberBand.setToGeometry(map_polygon)
              # get the bounding box of this new polygon
              self.poly_bbox = self.rubberBand.asGeometry().boundingBox()
          else:
              self.finished = True
code_tokens: def finishPolygon ( self ) : if self . finished : return elif len ( self . points ) > 2 : first_point = self . points [ 0 ] self . points . append ( first_point ) self . rubberBand . closePoints ( ) self . rubberBand . addPoint ( first_point , True ) self . finished = True map_polygon = QgsGeometry . fromPolygonXY ( [ self . points ] ) self . rubberBand . setToGeometry ( map_polygon ) self . poly_bbox = self . rubberBand . asGeometry ( ) . boundingBox ( ) else : self . finished = True
short_docstring: Activated by user or when the map window is closed without connecting
  the polygon.
short_docstring_tokens: Activated by user or when the map window is closed without connecting the polygon .
comment: """Activated by user or when the map window is closed without connecting
              the polygon. Makes the polygon valid by making first and last point
              the same. This is reflected visually. Up until now the user has been
              drawing a line: a polygon is created and shown on the map."""$SEP$# nothing will happen if the code below has already been ran$SEP$# connecting the polygon is valid if there's already at least 3 points$SEP$# a polygon is created and added to the map for visual purposes$SEP$# get the bounding box of this new polygon