gpt4 book ai didi

php - 如何从 MySQL 中的 Multipolygon 检索纬度和经度点

转载 作者:可可西里 更新时间:2023-11-01 06:52:06 25 4
gpt4 key购买 nike

有没有人用PHP解析过MySql中的Polygon/Multipolygon几何数据?我是 MySQL 空间函数的新手。请帮我从 MySQL 中的多面体中获取经纬度点。

我有一个表格,其中有一个类型为 MULTIPOLYGON 的几何列,我希望列出多边形中的所有离散点。

首先,我获得第 N 个感兴趣的多边形作为文本:

SELECT AsText( GeometryN( polygon_geom, 1)) FROM spatial_search_geometry

这给了我一个这种形式的字符串:

POLYGON((280593.054673555 254679.164020664,280554.160845461 254662.495237195,280515.267017367 254645.826453727,280531.935800836 254573.595058695,280562.495237195 254448.57918268,280593.054673555 254270.77882568,280556.938976039 254065.197162898,280518.045147945 253745.712146414,280476.373189273 253759.602799305,280429.144969445 253779.049713352,280423.588708289 253876.284283586,280398.585533086 253917.956242258,280454.148144648 253981.853245555,280512.488886789 254101.312860414,280518.045147945 254231.884997586,280495.82010332 254368.013395914,280468.038797539 254423.576007477,280495.82010332 254454.135443836,280501.376364477 254490.251141352,280429.144969445 254604.154495055,280493.041972742 254643.048323148,280479.151319852 254690.276542977,280495.82010332 254795.845504945,280473.595058695 254848.62998593,280493.041972742 254948.642686742,280462.482536383 254998.649037148,280448.591883492 255087.549215648,280484.707581008 255223.677613977,280556.938976039 255426.48114618,280593.054673555 255423.703015602,280645.839154539 255420.924885023,280709.736157836 255429.259276758,280729.183071883 255387.587318086,280729.183071883 255323.690314789,280706.958027258 255276.462094961,280684.732982633 255254.237050336,280651.395415695 255232.012005711,280656.951676852 255195.896308195,280665.286068586 255126.443043742,280665.286068586 255076.436693336,280665.286068586 255029.208473508,280620.835979336 254951.42081732,280584.72028182 254934.752033852,280531.935800836 254940.308295008,280593.054673555 254679.164020664))

如何从这个输出中获取每个纬度和经度点?

最佳答案

看来你需要解析一个数组,这个怎么样?

假设第一个数字是经度,然后是纬度,每对数字都是合适的坐标。

$i=0;
foreach(POLYGON[]){
echo="Longitude: ".POLYGON[$i];
echo="Latitude: ".POLYGON[$i+1];
$i= $i+2;
}

关于php - 如何从 MySQL 中的 Multipolygon 检索纬度和经度点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39209615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com