Convert MySQL's POINT to text in PHP
Using PHP, how can I convert a value inPOINT
datatype to a string likePOINT (-34.601020 -58.371020)
(an ouput in WKT or GeoJSON is preferable)
If I echo the raw value, I get weird characters.
I've tried usingbin2hex
and then tried to convert the hex to string but with no luck.
I'm aware of MySQL'sAsText()
, but I would like to do it in PHP.
Answer
Solution:
Finally I've got this working!!!
I had to use unpack in order to extract the binary data from MySQL
Here is a tutotial that helped me with this issue