Hi, I'd like to add a k-Nearest Neighbor functionality to mysql for
spatial data. I'm thinking that the usage will look something like
this:
CREATE TABLE geom2 (g GEOMETRY);
// ... insert some data
SET @g = GeomFromText('POINT(1 1)');
SELECT k_nearest_neighbor(@g, 3) FROM geom2;
The k_nearest_neighbor would then return the three closest objects to
the point (1,1). From the portion of the manual on user-defined
functions (http://dev.mysql.com/doc/refman/5.0/en/adding-udf.html), it
looks like only strings, ints and reals can be returned from
functions. How would I go about returning a row from a spatially
indexed table? How do I deal with returning multiple rows? Am I wrong
in thinking that functions are the way to go about solving this? I'm
very new to mysql development, so I would not be surprised if this is
the case.
Any help is appreciated.
Thanks,
JJ Tavernier