使用 python 和 mysql 获取圆圈内的 id
get id inside circle with python and mysql
我有两个点 A(lat1,lng1) 和 B(lat2,lng2),我想获取这两个点(A 和 B)内的 MySQL table 的所有 ID作为圆的直径)。
我怎样才能做到这一点?我有点卡住了
非常感谢你
see this image here
例如,我有两个点,我想在这两个定义的点内搜索点。我计算这两点之间的距离并除以二得到半径。中心纬度 = (lat_point1 + lat_point2)/2 与经度相同。然后我从这个中心搜索半径内的所有点。
SET center = ST_GeomFromText( 'POINT(35.322825 139.52769)', 4326 ); #center between spot_1 and 2
SET spot_1 = ST_GeomFromText( 'POINT(35.30633 139.50644 )', 4326 );
SET spot_2 = ST_GeomFromText( 'POINT(35.33932 139.54894 )', 4326 );
SELECT id, lat, lng, ROUND(ST_Distance(geometry, center, 'kilometre'), 2) FROM points where ST_Distance(spot_2 ,geometry, 'kilometre') <=radius
我有两个点 A(lat1,lng1) 和 B(lat2,lng2),我想获取这两个点(A 和 B)内的 MySQL table 的所有 ID作为圆的直径)。 我怎样才能做到这一点?我有点卡住了 非常感谢你 see this image here
例如,我有两个点,我想在这两个定义的点内搜索点。我计算这两点之间的距离并除以二得到半径。中心纬度 = (lat_point1 + lat_point2)/2 与经度相同。然后我从这个中心搜索半径内的所有点。
SET center = ST_GeomFromText( 'POINT(35.322825 139.52769)', 4326 ); #center between spot_1 and 2
SET spot_1 = ST_GeomFromText( 'POINT(35.30633 139.50644 )', 4326 );
SET spot_2 = ST_GeomFromText( 'POINT(35.33932 139.54894 )', 4326 );
SELECT id, lat, lng, ROUND(ST_Distance(geometry, center, 'kilometre'), 2) FROM points where ST_Distance(spot_2 ,geometry, 'kilometre') <=radius