Rotate Polygon to be Parallel with the X Axis

المشرف العام

Administrator
طاقم الإدارة
By default, PostGIS calculates the Envelope or Extent of a polygon based on the bounding box of the polygon ((MINX, MINY), (MINX, MAXY), (MAXX, MAXY), (MAXX, MINY), (MINX, MINY)).

This gives a result like so:



However, I'm looking for a result more like this:



As far as I know, the best algorithm that I can come up with is:

  1. Determine angle a to rotate the polygon X to be parallel with the x-axis
  2. Rotate X a degrees, calculate the envelope Y of rotated polygon X
  3. Rotate Y -a degrees
How could you calculate step #1 in PostGIS?



أكثر...
 
أعلى