Given 2 coordinates of a bounding box, bottom left..

  • I have a strange one for you please..

    Given 2 coordinates of a bounding box from a geography polygon, bottom left and top right, how can I find all 4 coordinates of the whole bounding box?

    I know this is a strange one, but I currently have a system where only the bottom left coordinate and top right one are recorded in the db, I need to work backwards from these two points to ascertain the original 4 points of the bounding box.

    I've run many Google searches but have come up blank, can am aware of the ST_Envelope command, which will give me the bounding box of a geography type, but given just two coordinates of a box, how can I get the other two (bottom right and top left).

    Hope this is clear.. any help would be much appreciated. thanks!

    Duncan.

  • dburtenshaw (10/14/2013)


    I have a strange one for you please..

    Given 2 coordinates of a bounding box from a geography polygon, bottom left and top right, how can I find all 4 coordinates of the whole bounding box?

    I know this is a strange one, but I currently have a system where only the bottom left coordinate and top right one are recorded in the db, I need to work backwards from these two points to ascertain the original 4 points of the bounding box.

    I've run many Google searches but have come up blank, can am aware of the ST_Envelope command, which will give me the bounding box of a geography type, but given just two coordinates of a box, how can I get the other two (bottom right and top left).

    Hope this is clear.. any help would be much appreciated. thanks!

    Duncan.

    The bottom left should be expressed as (MINX,MINY) and the top right as (MAXX, MAXY) so the other two can be derived (MINX, MAXY) is top left and (MAXX, MINY) is bottom right.

  • "The bottom left should be expressed as (MINX,MINY) and the top right as (MAXX, MAXY) so the other two can be derived (MINX, MAXY) is top left and (MAXX, MINY) is bottom right."

    Thank you for your response Batgirl, that makes sense, I will have a play tomorrow.

    D.

  • [font="Courier New"]

    If what they're saying is true, the 4 coordinates are simply:

    (MINX, MAXY) ------------ (MAXX, MAXY)

    (MINX, MINY) ------------ (MAXX, MINY)

    Height = ABS(MAXY - MINY)

    Width = ABS(MAXX - MINX)

    [/font]

  • Worked a treat, thanks all for your input - my GSCE maths escaped me and I was looking for an over engineered solution..!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply