mysql point WKB格式 php 解析 unpack

Wesley13
• 阅读 454
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

mysql point WKB格式 php 解析 unpack

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

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Easter79 Easter79
2年前
swap空间的增减方法
(1)增大swap空间去激活swap交换区:swapoff v /dev/vg00/lvswap扩展交换lv:lvextend L 10G /dev/vg00/lvswap重新生成swap交换区:mkswap /dev/vg00/lvswap激活新生成的交换区:swapon v /dev/vg00/lvswap
Stella981 Stella981
2年前
OpenCV 绘制图形
OpenCV绘制图形直线voidcv::line (InputOutputArray  img, //图像Point pt1,       //线的起点Point pt2,       //线的终点constScalar& color,  //线的颜色int
Stella981 Stella981
2年前
Mat 的几种初始化和赋值方法
这几天用到了由cv::Point3f和std::vector<float到cv::Mat数据类型的转换。本质上就是换一下容器。今晚做个小总结。由Point3f到Mat有两种方法,一种使用cv::Mat_<cv::Point3f(),另一种是在声明时使用{}初始化。\\注意:
Wesley13 Wesley13
2年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
2年前
PHP创建多级树型结构
<!lang:php<?php$areaarray(array('id'1,'pid'0,'name''中国'),array('id'5,'pid'0,'name''美国'),array('id'2,'pid'1,'name''吉林'),array('id'4,'pid'2,'n
Stella981 Stella981
2年前
Ecshop用户中心的收藏列表里显示商品缩略图
1)、修改includes/lib\_clips.php文件将下面代码$sql'SELECTg.goods_id,g.goods_name,g.market_price,g.shop_priceASorg_price,'.修改为$sql'SELECTg.goods_id,g.goods_nam
Stella981 Stella981
2年前
Android蓝牙连接汽车OBD设备
//设备连接public class BluetoothConnect implements Runnable {    private static final UUID CONNECT_UUID  UUID.fromString("0000110100001000800000805F9B34FB");
Wesley13 Wesley13
2年前
thinkphp 基本配置
12returnarray(34//定义数据库连接信息5'DB\_TYPE''mysql',//指定数据库是mysql67'DB\_HOST''localhost',89'DB\_NAME''uchome',//数据库名1011'DB\_USER''root
Stella981 Stella981
2年前
Point
!(http://static.oschina.net/uploads/img/201611/07130517_GQrf.gif)Figure1Figure1demonstratesatypicalcaseofaseverelyconcavepolygonwith14sides.Thereddoti