Menu

Find Stuff By Minimum Bounding Rectangle

mbr mysql minimum bounding rectangleMySQL offers ENVELOPE() to find the minimum bounding rectangle of a geometric object.

The result is a polygon with four segments, defined by five points. It took me a while to make sense of it, partially because the only documentation that I’ve run across so far for POLYGON() syntax is in the ENVELOPE() function mentioned above. I also had to draw a picture to think it through.

They write this: POLYGON(( MINX MINY, MAXX MINY, MAXX MAXY, MINX MAXY, MINX MINY )), I think this (in pseudocode-ish form): POLYGON(( $point_a, $point_b, $point_c, $point_d, $point_a )), with the $point_s corresponding to the diagram.