有没有人用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,2807 09.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))
从这个输出中我如何获得每个纬度和经度点?
答案 0 :(得分:0)
看起来你需要解析一个数组,这个怎么样?
假设第一个数字是经度,那么纬度和每对数字都是合适的坐标。
$i=0;
foreach(POLYGON[]){
echo="Longitude: ".POLYGON[$i];
echo="Latitude: ".POLYGON[$i+1];
$i= $i+2;
}