haversine

Pandas Dataframe: join items in range based on their geo coordinates (longitude and latitude)

时光怂恿深爱的人放手 提交于 2019-12-18 13:25:26
问题 I got a dataframe that contains places with their latitude and longitude. Imagine for example cities. df = pd.DataFrame([{'city':"Berlin", 'lat':52.5243700, 'lng':13.4105300}, {'city':"Potsdam", 'lat':52.3988600, 'lng':13.0656600}, {'city':"Hamburg", 'lat':53.5753200, 'lng':10.0153400}]); Now I'm trying to get all cities in a radius around another. Let's say all cities in a distance of 500km from Berlin, 500km from Hamburg and so on. I would do this by duplicating the original dataframe and

Haversine distance calculation between two points in Laravel

拈花ヽ惹草 提交于 2019-12-17 22:25:18
问题 I'm working on a laravel appliciation in which I need to find all the products that are within a certain radius of the user's coordinates. Products have a one to many relationship with users, so users can have multiple products. I've found that the haversine formula can calculate the distance between two points, but I can't seem to make it work. I've got the following query in my controller: $latitude = 51.0258761; $longitude = 4.4775362; $radius = 20000; $products = Product::with('user') -

PHP轻松实现"附近的人"功能,根据IP确定经纬度,根据经纬度计算距离

五迷三道 提交于 2019-12-17 17:58:52
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> PHP安装GeoIP扩展和数据库根据IP获取访客所在国家/城市/经纬度等信息 然后就可以用geoip_record_by_name($_SERVER['REMOTE_ADDR'])根据用户IP确定经纬度了. 注意:geoip_record_by_name()返回的西经和南纬是负数. 5000米转成经纬度: 纬度 Latitude: 1 deg = 110852 m 经度 Longitude: 1 deg = 111320*cos(lat) m 同一经线上,相差一纬度约为 110852 米 同一纬线上,相差一经度约为 111320*cos(lat) 米 (lat为该纬线的纬度) <?php //以当前用户经纬度为中心,查询5000米内的其他用户 $y = 5000 / 110852; //纬度的范围 $x = 5000 / (111320*cos($lat)); //经度的范围 $sql = ' select * from user where lat >= ($lat-$y) and lat <= ($lat+$y) and lon >= ($lon-$x) and lon <= ($lon+$x); '; 数据库用户表中设两个字段,分别存储用户的经度lat和纬度lon. ($lat-$y) <= lat <=

Query for Haversine formula in Oracle

南楼画角 提交于 2019-12-14 04:24:03
问题 This query is working fine but I want to use the MIN function in this query, because I want only one station which has the least distance from the given current location. How can I use MIN in this query? select * from ( SELECT fc_station_mst.station_name,fc_station_mst.station_id,fc_station_mst.lat, fc_station_mst.longitude,fc_station_mst.state, fc_station_param_dtl.fc_date,fc_station_param_dtl.param_value,fc_parameter_mst.param_name,fc_parameter_mst.param_unit, 6371*(2*atan2 (sqrt(sin(((3.14

Haversine formula in Java producing incorrect result

好久不见. 提交于 2019-12-13 09:49:01
问题 I am trying to use this implementation of Haversine formula given on wikipedia for trial but this formula is not giving expected result. public class Haversine { public static final double R = 6372.8; // In kilometers public static double haversine(double lat1, double lon1, double lat2, double lon2) { double dLat = Math.toRadians(lat2 - lat1); double dLon = Math.toRadians(lon2 - lon1); lat1 = Math.toRadians(lat1); lat2 = Math.toRadians(lat2); double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)

Sorting multiple JavaScript array

不羁的心 提交于 2019-12-12 03:48:56
问题 I have created this script with the help of the Haversine formula, the problem is that it keeps directing me to the first location on the array, no matter how many time I swap them about. Any ideas? var locations = new Array( Array("Brighton", 50.82253, -0.137163), Array("Chichester", 50.83761, -0.774936), Array("Portsmouth", 50.8166667, -1.0833333), Array("Worthing", 50.81787, -0.372882) ); function deg2rad(degrees){ radians = degrees * (Math.PI/180); return radians; } function haversine

haversine formula php / mysql

我们两清 提交于 2019-12-12 03:44:37
问题 I'm trying to get a common database of geo points working with a radius search. I've found several good tutorials on this topic, but I'm failing at the very end. The main tutorial is here: http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates. The basic formula, in the form of an SQL query, is SELECT * FROM Places WHERE (Lat => 1.2393 AND Lat <= 1.5532) AND (Lon >= -1.8184 AND Lon <= 0.4221) AND acos(sin(1.3963) * sin(Lat) + cos(1.3963) * cos(Lat) * cos(Lon - (-0.6981))) <= 0.1570; I've

Distance between two coordinates in php using haversine

懵懂的女人 提交于 2019-12-11 18:33:25
问题 I've looked around and seen mention of the haversine formula to determine distance between two coordinates (lat1, lng1) and (lat2, lng2). I've implemented this code: function haversineGreatCircleDistance( $latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, $earthRadius = 6371000) { // convert from degrees to radians $latFrom = deg2rad($latitudeFrom); $lonFrom = deg2rad($longitudeFrom); $latTo = deg2rad($latitudeTo); $lonTo = deg2rad($longitudeTo); $latDelta = $latTo - $latFrom;

How to prepare existing database for location aware searching?

橙三吉。 提交于 2019-12-11 18:08:44
问题 Requirement : I am currently working on an app that has over 30000 records. The requirement is to have location based/aware searching . For eg. within 5mi from my present location. How will this service be accessed : This service will be accessed from both web and iOS app. Development platforms : Web : Cakephp, php and python DB : MySql iOS : objective-c External libraries currently being used : Google Maps Javascript Api v3 Location based searching I have been doing some research on this

Haversine calculation: Show users within set [closed]

怎甘沉沦 提交于 2019-12-11 10:17:24
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Building a carpooling app for my local community built on PHP and SQL. While I'm usually ofay with php coding, I'm stumped looking for the mathematical formula needed to list: Top 5 nearby users, ordered from closest to furthest given the long / lat of the primary user Limited to those within 500 meters of the