Invalid non-geometric value "aswkb (...)" found during parsing

I used the tutorial from http://dev.mysql.com/tech-resources/articles/4.1/gis-with-mysql.html so I created two tables, inserted some data, and when I tried to get some data using a script

SELECT c.cab_driver, ROUND(GLength(LineStringFromWKB(LineString(AsBinary(c.cab_loc), AsBinary(a.address_loc))))) AS distance FROM cab c, address a WHERE a.address = 'Foobar street 110' ORDER BY distance ASC LIMIT 1; 

I got an error: "Error code: 1367 Invalid non-geometric value aswkb ( c . cab_loc )" found during parsing "

Any suggestions?

I have some progress on this issue, I tried to run

 SELECT asbinary(c.cab_loc) FROM usercoordinates.cab c; 

and I get NULL in each line, but if I use astext, I get POINT (...) in each line

Finally, I realized, maybe this is not the best solution, but

 SELECT c.cab_driver, Round(glength(LineStringFromWKB(LineString(GeomFromText(astext(c.cab_loc)),GeomFromText(astext(a.address_loc)))))) AS distance FROM cab c, address a WHERE a.address = 'Foobar street 99' ORDER BY distance ASC LIMIT 1; 
+4
source share
3 answers
 SELECT c.cab_driver, Round(glength(LineStringFromWKB(LineString(GeomFromText(astext(c.cab_loc)), GeomFromText(astext(a.address_loc)))))) AS distance FROM cab c, address a WHERE a.address = 'Foobar street 99' ORDER BY distance ASC LIMIT 1; 
+3
source

A very ugly solution, but I could not find another.

By the way, we can shorten the request a bit using the optional wrap function:

 DELIMITER $$ DROP FUNCTION IF EXISTS pointIt $$ CREATE function pointIt (src POINT) RETURNS POINT BEGIN RETURN GeomFromText(astext(src)); END $$ DELIMITER ; 
0
source

I had to slightly modify Hituptony's solution for Mysql 5.6:

 SELECT c.cab_driver, Round(glength(LineStringFromWKB(LineString(c.cab_loc, a.address_loc)))) AS distance FROM cab c, address a WHERE a.address = 'Foobar street 99' ORDER BY distance ASC LIMIT 1; 
0
source

All Articles