MySQL 5.5 Reference Manual  /  ...  /  MultiPoint Class

11.5.2.9 MultiPoint Class

A `MultiPoint` is a geometry collection composed of `Point` elements. The points are not connected or ordered in any way.

`MultiPoint` Examples

• On a world map, a `MultiPoint` could represent a chain of small islands.

• On a city map, a `MultiPoint` could represent the outlets for a ticket office.

`MultiPoint` Properties

• A `MultiPoint` is a zero-dimensional geometry.

• A `MultiPoint` is simple if no two of its `Point` values are equal (have identical coordinate values).

• The boundary of a `MultiPoint` is the empty set.

User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
Posted by ALEXANDER SKAKUNOV on March 26, 2013
Re comparing equality of 2 points.

Although that sounds easy, it can be counter-intuitive. The problem is the precision of coordinates. For example, in our project ( http://dobrotvor.com/ ) we bumped into this due to the fact that the precision of geo coordinates incapsulates the zoom value of Google Maps points. It's not right just to compare (X1 == X2) AND (Y1 == Y2) since the results can be wrong in many cases.

To make it work right, it's better to use special function (couldn't find anything better built-in):

[code]
DELIMITER //

DROP FUNCTION IF EXISTS ArePointsEqual; //
CREATE FUNCTION ArePointsEqual(p1 POINT, p2 POINT) RETURNS BOOLEAN NO SQL DETERMINISTIC
BEGIN
RETURN IsZero(X(p1) - X(p2)) AND IsZero(Y(p1) - Y(p2));
END; //

DROP FUNCTION IF EXISTS IsZero; //
CREATE FUNCTION IsZero(n DOUBLE) RETURNS BOOLEAN NO SQL DETERMINISTIC
BEGIN
DECLARE epsilon DOUBLE DEFAULT 0.00000000001;
RETURN (ABS(n) <= epsilon);
END; //
[/code]

The trick is not to use 0 as "zero value", but to use a very small difference (called "epsilon") instead for comparison.
Posted by Shane Bester on December 8, 2013
The above IsZero function is needed due to the explanations give in the manual:
http://dev.mysql.com/doc/refman/5.6/en/problems-with-float.html