php - 与保存在数据库中的序列化数据的多边形相交
问题描述
在此处输入代码嗨,目前我正在关注此链接 如何处理 MySQL 多边形重叠查询?
但是我的数据是以序列化格式保存在数据库中的。如何使此示例适用于序列化数据。
目前我需要以这种格式发送数据
POLYGON((0 0,10 0,10 10,0 10,0 0));
但是我的整个网站数据都是形式
a:1:{i:0;a:10:{i:0;a:2:{i:0;d:174.9276744162897330170380882918834686279296875;i:1;d:-37.04082457174366282970368047244846820831298828125;}i:1;a:2:{i:0;d:174.927722386324973058435716666281223297119140625;i:1;d:-37.04080921055260233742956188507378101348876953125;}i:2;a:2:{i:0;d:174.927879097423243592857033945620059967041015625;i:1;d:-37.040758815066141096394858323037624359130859375;}i:3;a:2:{i:0;d:174.9279352870431694100261665880680084228515625;i:1;d:-37.0407408936765705220750533044338226318359375;}i:4;a:2:{i:0;d:174.927883544083812239477992989122867584228515625;i:1;d:-37.04063713826327131073412601836025714874267578125;}i:5;a:2:{i:0;d:174.927876806719297064773854799568653106689453125;i:1;d:-37.04062366353426938303528004325926303863525390625;}i:6;a:2:{i:0;d:174.927792454915760345102171413600444793701171875;i:1;d:-37.04065074773956212084158323705196380615234375;}i:7;a:2:{i:0;d:174.927659728835124042234383523464202880859375;i:1;d:-37.04069332788319712790325866080820560455322265625;}i:8;a:2:{i:0;d:174.927615935965860671785776503384113311767578125;i:1;d:-37.04070747634865057307251845486462116241455078125;}i:9;a:2:{i:0;d:174.9276744162897330170380882918834686279296875;i:1;d:-37.04082457174366282970368047244846820831298828125;}}}
他们有什么办法可以使这个查询工作吗
SELECT id,AsText(poly) FROM `spatial`
WHERE
ST_Intersects(`poly`,"**MY vertices here**"))', 0 )
)
;
这是我插入的php 代码,任何人都可以帮助完成这个任务,因为我在这个任务上停留了 2 周 -
$boundary_type='boundary'; $unstring_rings=json_decode($arguments[1]); $rings=serialize($unstring_rings);
$wpdb->insert($wpdb->prefix."hhq_listing_map", array('listing_id' => $arguments[0], 'location_type' => $arguments[2], 'boundary_coordinate' =>$rings, 'date_added' => date('Y-m-d') ));
这是我的表结构,我试图插入边界坐标库,但我的数据来自 php 的字符串化形式,我正在解码 json 并将其序列化以用于其余的地图工作以保存在数据库中
CREATE TABLE wp_hhq_listing_map_new ( listing_map_id int(20) NOT NULL, listing_id int(20) NOT NULL, location_type varchar(255) NOT NULL, location_coordinates longtext DEFAULT NULL,boundary_coordinate geometry NOT NULL, date_added date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
解决方案
推荐阅读
- html - 如何创建动态拖放占位符(HTML 或角度 CDK)
- javascript - 如何指定命令的选项?
- c++ - 传递可变数量的不同参数并在 C++ 中调用函数
- visual-studio-code - 如何防止 VSCode 要求我保存未保存的文件?
- python - 用 Python 下载 xlsx 文件
- javascript - 如何在一天的开始和一天结束时进入 .toDate() 对象?
- javascript - 如何在没有 jQuery 的情况下单击按钮打开 iframe
- android-jetpack-compose - 切换和取消切换 DropdownMenu 的外观
- html - css:在移动视图中将列显示为行
- python - Pydantic - 验证不会发生