(self, rectangles)
Process data to construct rectangles

        This method is built from the assumption that the rectangles parameter
        is a list of:
            lists :a list with 4 elements indicating [north, west, south, east]
            tuples:a tuple with 4 elements indicating (north, west, south,east)
            tuple of tuples: a tuple of 2 tuple elements of length 2 indicating
            (north_west, south_east)
            dicts: a dictionary with rectangle attributes

        So, for instance, we have this general scenario as a input parameter:
            [[22.345,45.44,23.345, 45.55],
             (22.345,45.44,23.345,45.55),
             ((22.345,45.44),(23.345,45.55)),
             [(22.345,45.44),(23.345,45.55)],
             {
            'stroke_color': stroke_color,
            'stroke_opacity': stroke_opacity,
            'stroke_weight': stroke_weight,
            'fill_color': fill_color,
            'fill_opacity': fill_opacity,
            'bounds': {'north': north,
                       'east': east,
                       'south': south,
                       'west': west,
                       }
            }]
Process data to construct rectangles
Process data to construct rectangles
def build_rectangles(self, rectangles):
        # type: (Optional[List[Union[List, Tuple, Tuple[Tuple], Dict]]]) -> None
        """Process data to construct rectangles

        This method is built from the assumption that the rectangles parameter
        is a list of:
            lists :a list with 4 elements indicating [north, west, south, east]
            tuples:a tuple with 4 elements indicating (north, west, south,east)
            tuple of tuples: a tuple of 2 tuple elements of length 2 indicating
            (north_west, south_east)
            dicts: a dictionary with rectangle attributes

        So, for instance, we have this general scenario as a input parameter:
            [[22.345,45.44,23.345, 45.55],
             (22.345,45.44,23.345,45.55),
             ((22.345,45.44),(23.345,45.55)),
             [(22.345,45.44),(23.345,45.55)],
             {
            'stroke_color': stroke_color,
            'stroke_opacity': stroke_opacity,
            'stroke_weight': stroke_weight,
            'fill_color': fill_color,
            'fill_opacity': fill_opacity,
            'bounds': {'north': north,
                       'east': east,
                       'south': south,
                       'west': west,
                       }
            }]
        """

        if not rectangles:
            return
        if not isinstance(rectangles, list):
            raise AttributeError("rectangles only accept lists as parameters")
        for rect in rectangles:

            # Check the instance of one rectangle in the list. Can be
            # list, tuple or dict
            if isinstance(rect, (list, tuple)):

                # If the rectangle bounds doesn't have size 4 or 2
                # an AttributeError is raised
                if len(rect) not in (2, 4):
                    raise AttributeError("The bound must have length" " 4 or 2")

                # If the tuple or list has size 4, the bounds order are
                # especified as north, west, south, east
                if len(rect) == 4:
                    rect_dict = self.build_rectangle_dict(*rect)
                    self.add_rectangle(**rect_dict)

                # Otherwise size 2, the tuple or list have the north_west and
                # south_east tuples. If the tuples doesn't have the correct
                # size, an AttributeError is raised.
                elif len(rect) == 2:
                    if len(rect[0]) != 2 or len(rect[1]) != 2:
                        raise AttributeError("Wrong size of rectangle bounds")
                    rect_dict = self.build_rectangle_dict(
                        rect[0][0], rect[0][1], rect[1][0], rect[1][1]
                    )
                    self.add_rectangle(**rect_dict)
                else:
                    raise AttributeError("Wrong bounds input size")
            elif isinstance(rect, dict):
                self.add_rectangle(**rect)
def build_rectangles ( self , rectangles ) : # type: (Optional[List[Union[List, Tuple, Tuple[Tuple], Dict]]]) -> None if not rectangles : return if not isinstance ( rectangles , list ) : raise AttributeError ( "rectangles only accept lists as parameters" ) for rect in rectangles : # Check the instance of one rectangle in the list. Can be # list, tuple or dict if isinstance ( rect , ( list , tuple ) ) : # If the rectangle bounds doesn't have size 4 or 2 # an AttributeError is raised if len ( rect ) not in ( 2 , 4 ) : raise AttributeError ( "The bound must have length" " 4 or 2" ) # If the tuple or list has size 4, the bounds order are # especified as north, west, south, east if len ( rect ) == 4 : rect_dict = self . build_rectangle_dict ( * rect ) self . add_rectangle ( * * rect_dict ) # Otherwise size 2, the tuple or list have the north_west and # south_east tuples. If the tuples doesn't have the correct # size, an AttributeError is raised. elif len ( rect ) == 2 : if len ( rect [ 0 ] ) != 2 or len ( rect [ 1 ] ) != 2 : raise AttributeError ( "Wrong size of rectangle bounds" ) rect_dict = self . build_rectangle_dict ( rect [ 0 ] [ 0 ] , rect [ 0 ] [ 1 ] , rect [ 1 ] [ 0 ] , rect [ 1 ] [ 1 ] ) self . add_rectangle ( * * rect_dict ) else : raise AttributeError ( "Wrong bounds input size" ) elif isinstance ( rect , dict ) : self . add_rectangle ( * * rect )