geometry-property-functions

This page has moved or been replaced. The new page is located here:

http://dev.mysql.com/doc/refman/5.0/en/gis-property-functions.html

Please update any bookmarks that point to the old page.


User Comments
  Posted by Ritesh Ranjan on November 12, 2009
The GLength function can not be used for calculating the distance on a sphere ... like earth. correct me if i m wrong.
  Posted by Ben Griffin on April 20, 2010
Yes, IIRC mysql's geometry calculations are limited to the cartesian plane. This is important when needing to make calculations that involve non-cartesian coordinates (such as mercator coordinates)
  Posted by ALEXANDER SKAKUNOV on July 1, 2012
In case you want to get a center point of any geometry, consider the function I created:

DELIMITER //
DROP FUNCTION IF EXISTS GetCenterPoint; //
CREATE FUNCTION GetCenterPoint(g GEOMETRY) RETURNS POINT NO SQL DETERMINISTIC
BEGIN
DECLARE envelope POLYGON;
DECLARE sw, ne POINT; #South-West and North-East points
DECLARE lat, lng DOUBLE;

SET envelope = ExteriorRing(Envelope(g));
SET sw = PointN(envelope, 1);
SET ne = PointN(envelope, 3);
SET lat = X(sw) + (X(ne)-X(sw))/2;
SET lng = Y(sw) + (Y(ne)-Y(sw))/2;
RETURN POINT(lat, lng);
END; //

We use it a lot in our project http://www.sunnyrentals.com to distinguish coordinates to center a map to.
Sign Up Login You must be logged in to post a comment.