我想从字符串下方获取多边形坐标。
{"polygon":{"type":"Feature","properties":[],"geometry":{"type":"Polygon","coordinates":[[[-7302732.4720101,6527844.6333235],[-3193477.8319711,6606116.1502766],[-5111129.9973226,5001550.0527375],[-6637424.5779086,4884142.7773079],[-7772361.5737289,5158093.0866438],[-7302732.4720101,6527844.6333235]]]},"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}}}}
这是我使用以下代码解码为数组的 GeoJson 字符串:
$polygon = CJSON::decode($str);
当我想获得多边形时,我得到了错误!
$var= $polygon->polygon;
或使用以下代码:
$polygon = CJSON::decode($str,true);
$var = $polygon['polygon'];
虽然为了获取坐标:
foreach($polygon as $key=>$value)
$coordinates = $value['coordinates'];
or
$coordinates = $value[coordinates];
如何从我从 javascript 发送到 php 的 geojson 获取坐标,以便使用 postgis 保存在 postgresql 上?