MySQL Forums
Forum List  »  GIS

Re: spatial extensions
Posted by: Alexander Barkov
Date: December 01, 2006 07:50AM

Unfortunately, MySQL does not support the Distance() OpenGIS function.
As a workaround, you can calculate distance between two points by
extracting their coordinates:


mysql> set @a:=GeomFromText('POINT(1 1)');
Query OK, 0 rows affected (0.01 sec)

mysql> set @b:=GeomFromText('POINT(2 2)');
Query OK, 0 rows affected (0.01 sec)


mysql> select x(@a),y(@a),x(@b),y(@b), sqrt(pow(x(@a)-x(@b),2)+pow(y(@a)-y(@b),2)) as distance;
+-------+-------+-------+-------+-----------------+
| x(@a) | y(@a) | x(@b) | y(@b) | distance |
+-------+-------+-------+-------+-----------------+
| 1 | 1 | 2 | 2 | 1.4142135623731 |
+-------+-------+-------+-------+-----------------+
1 row in set (0.00 sec)

Options: ReplyQuote


Subject
Views
Written By
Posted
3950
September 05, 2006 12:04PM
Re: spatial extensions
2681
December 01, 2006 07:50AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.