I’m working on an application integrating mapquest maps and using the mapquest API.
At this moment I want to achieve the following: the registered user has to input latitude and longitude information, and in the database this information has to be stored as geometry type field. Conversely, a user looking at their account should see the latitude and longitude information that was entered.
In an earlier simplified codebase I achieved this directly in the MySQL query, by using the MySQL functions AsText and GeomFromText. But now I’m on CodeIgniter and need to do the conversion in PHP
Is there anything equivalent in PHP to MySQL's AsText and GeomFromText functions?
It appears that the
PHPunpackfunction is what is needed to extract the coordinate information.MySQLstores the geometry fields in the WKB (Well Known Binary) format. Theunpackfunction is able to extract that information when provided the proper format specifier. The following code is from a test script which successfully extracted the desired information.Please note that my
formatfor unpack differs slightly from that of the reference. This is because the WKB string wasn't retrieved from MySQL with theAsWKB()function, so it contains extra padding.References MySQL and ESRI Network.