SET @g = ST_GeomFromText('POINT(118.624653 31.919936)');
SELECT HEX(@g);
输出: 00000000 01 01000000 A435069D10B55D40 26C5C72764FB3F40
Internal Geometry Storage Format
https://dev.mysql.com/doc/refman/5.7/en/gis-data-formats.html
php 函数 unpack对应解析
var_dump(
unpack('H*', $l), // H 十六进位字符串,高位在前
unpack('ISRID/corder/Itype/dx/dy ', $l)
);
array(1) { [1]=> string(50) "000000000101000000e8f9d34675b55d40598b4f0130fa3f40" }
array(5) { ["SRID"]=> int(0) ["order"]=> int(1) ["type"]=> int(1) ["x"]=> float(118.624653) ["y "]=> float(31.919936) }
参数说明
'ISRID/corder/Itype/dx/dy'
ISRID:
"I" 无号整数 4个byte
"SRID" Spatial Reference System Identifier 空间参照标识符 0是二维平面
corder:
"c" byte 1个byte
"order" 1是little-endian编码 0是big-endian编码
Itype:
"I" 无号整数 4个byte
"type" Geometry types 如 0001:point 0003 polygon
dx:
"d"倍精确浮点数 8个byte
"x" x-coordinate
dy:
"d"倍精确浮点数 8个byte
"y" y-coordinate
更多请参见
SRID http://dcx.sybase.com/1200/zh/dbspatial/spatial-reference-identifier.html
wkb格式 https://en.wikipedia.org/wiki/Well-known_text#Well-known_binary
https://www.cnblogs.com/khfang/p/6074688.html
php unpack http://blog.csdn.net/xiexingshishu/article/details/51222451