If I have a column called Poly of type polygon in MySQL and I want to get the NW corner and the NE corner and the SE corner and the SW corner, how would I do that? From an Envelope() there should be lat1, lat2, lon1, and lon2 that form the four corners as follows lat1,lon1 is NW; lat1,lon2 is NE; lat2,lon2 is SE; and lat2,lon1 is SW. When I try X(PointN(Envelope(Poly),1)) AS lat1 it always returns NULL. Can this be done in MySQL?
SELECT
X(PointN(Envelope(Poly),1)) AS lat1, X(PointN(Envelope(Poly),3)) AS lat2,
Y(PointN(Envelope(Poly),1)) AS lon1, Y(PointN(Envelope(Poly),2)) AS lon2
FROM boundaries.mt_us_zip5_2013_boundaries_polys_bin
WHERE zip = '00601';
The query above returns:
NULL,NULL,NULL,NULL
Here's what the Envelope looks like:
SELECT AsText(Envelope(Poly))
FROM boundaries.mt_us_zip5_2013_boundaries_polys_bin
WHERE zip = '00601';
This last query returns:
POLYGON((18.111929 -66.836366,18.250344 -66.836366,18.250344 -66.659293,18.111929 -66.659293,18.111929 -66.836366))
I'm using MySQL version 5.5.36, would upgrading to a new version of MySQL give me the functions I need?