计算坐标周边的坐标信息

Tim Huang 发表于 2013-01-07 浏览数 237

案例如下:

在一个GIS系统中,记录了每个地点的坐标。现在我在某一个坐标点中,希望得到周边有的地点。正常情况下,应该显示坐标直径范围内的坐标圆内的信息。但基于查看的内容为四边型,所以查询时,将查询正方型的满园内的数据

function cal_points($point, $dis){
    $default = array('lat'=>0,'lng'=>0);
    $point = array_merge($default, (array)$point);
    $angle = $dis*180/M_PI/EARTH_RADIUS;
    $one['lat'] = $point['lat'] +$angle;
    $one['lng'] = $point['lng'] -$angle;


    $two['lat'] = $point['lat'] +$angle;
    $two['lng'] = $point['lng'] +$angle;


    $third['lat'] = $point['lat'] -$angle;
    $third['lng'] = $point['lng'] -$angle;


    $four['lat'] = $point['lat'] -$angle;
    $four['lng'] = $point['lng'] +$angle;
    return array($one, $two, $third, $four);
}
$point1 = array('lng'=>116.360755, 'lat'=>39.992543);
$rs = cal_points($point1,1);
$where = array();
$where[]= "(`lat` <".($rs[0]['lat']*1000000)." AND `lng` > ".($rs[0]['lng']*1000000).")";
$where[]= "(`lat` <".($rs[1]['lat']*1000000)." AND `lng` < ".($rs[1]['lng']*1000000).")";
$where[]= "(`lat` >".($rs[2]['lat']*1000000)." AND `lng` > ".($rs[2]['lng']*1000000).")";
$where[]= "(`lat` >".($rs[3]['lat']*1000000)." AND `lng` < ".($rs[3]['lng']*1000000).")";


echo(join(' AND ', $where));


发表在 | 标签为 php GIS 坐标计算 | 留下评论

计算坐标周边的坐标信息有 0 条评论

发表评论

*

* Reload Image

*

分类