Distance in meters between two Spacial Points in MySQL query

前端 未结 2 751
你的背包
你的背包 2021-01-04 10:44

I am trying to query a MySQL database (version 5.7.15) to retrieve all locations that are within 300 meters from some coordinates (40.7542, -73.9961 in my case):

<         


        
2条回答
  •  太阳男子
    2021-01-04 11:26

    Note that in MySql the order of coordinates are:
    1. POINT(lng, lat) - no SRID
    2. ST_GeomFromText('POINT(lat lng)', 4326) - with SRID

    select st_distance_sphere(POINT(-73.9949,40.7501), POINT( -73.9961,40.7542)) 
    

    will return 466.9696023582369, as expected, and 466.9696023582369 > 300 of course

提交回复
热议问题