Questions tagged [haversine]

The haversine formula is an equation important in navigation, giving great-circle distances between two points on a sphere from their longitudes and latitudes.

429 questions
0
votes
1 answer

Adaptation of nearest neighbour R code to identify locations of ponds within 1 km for each pond

I have a csv file with the pond areas and Latitude and Longitude coordinates for 17,305 ponds. For each pond I would like to identify the coordinates of all the ponds within 1 km of it. I am an R novice so I thought I could adapt some nearest…
0
votes
2 answers

using the haversine formula in javascript with variables

hi i have been struggling with using the have sine formula to get the distance between the users current location and objects in an array, i have found a great answer to this question but when i try to use variables instead of actual coordinates the…
0
votes
2 answers

Incorporating Haversine formula with PHP PDO

Originally using the following query: SELECT username, latitude, longitude, ( 3959 * acos( cos( radians(':lat') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(':lng') ) + sin( radians(':lat') ) * sin( radians( latitude ) ) ) )…
user1026996
0
votes
2 answers

MySQL CREATE FUNCTION breaking on END IF

I'm trying to create a function for calculating distances between two lat/lon points; however, the CREATE FUNCTION is breaking on the END IF; portion of the function body (confirmed by removing the IF/ELSE/END block). Any ideas? I would like to keep…
user1262516
0
votes
3 answers

Data in the database is not fetched from MySQL in PHP code

I have implemented my database and then I am retrieving data from database via PHP. In my code I am supposed to filter data by name and if the name exists, I want to print the data. Although the wanted item is in the table, nothing is displayed. I…
user2086258
  • 613
  • 1
  • 6
  • 7
0
votes
2 answers

How to prepare existing database for location aware searching?

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…
Kishor Kundan
  • 3,135
  • 1
  • 23
  • 30
0
votes
0 answers

SQLSTATE[42000] on the Haversine formula in PHP/MySQL and CakePHP

I am just testing the Haversine formula taking from Google Developers: https://developers.google.com/maps/articles/phpsqlsearch_v3#findnearsql I've put the snippet into my code and it gives me a SQL error. This is my Model in…
Johnathan Au
  • 5,244
  • 18
  • 70
  • 128
0
votes
1 answer

Distance between two coordinates in php using haversine

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,…
NCoder
  • 325
  • 3
  • 10
  • 25
0
votes
1 answer

How to Return Additional Columns With Values Generated in Stored Procedures On the 'Fly'?

I have a stored procedure in SQL 2005 that calculates distance using the Haversine formula. Everything works quite nicely but I'd like to return the calculated distance with my result set. How do I go about adding that column/value pair? DECLARE…
Mikecancook
  • 761
  • 2
  • 13
  • 21
0
votes
1 answer

Errors in the calculator program

I'm working with a program who will calculate the distance between two geographical points on the Earth's surface. Im pretty new at C++ and I apologize if my English is bad Any suggestions on how i can get the content at the program at the bottom…
0
votes
1 answer

Find markers around a route's start and end points (LatLng)

So, I have a database in which "routes" are saved (i.e. start points and end points, in the Latitude/Longitude format 'StartLat', 'StartLng' and 'EndLat', my'EndLng'). Currently, people can search for these routes by either their start point or…
user1259798
  • 171
  • 1
  • 16
0
votes
1 answer

Sorting multiple JavaScript array

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",…
Oliver Tappin
  • 2,511
  • 1
  • 24
  • 43
0
votes
1 answer

calculate distance of two cities using Haversine formula-how to deal with minus longitudes

I'm going to find the distance between two cities using Haversine formula. below is the code in VC++. But I could't find the distance between the points (18.567367, -68.363431) and (33.636719,-84.428067) [first value is latitude, second is…
user1815763
  • 103
  • 2
  • 10
0
votes
2 answers

distance calculation with haversine and float... kinda working

I'm using a haversine query to pull locations nearest to a lat/lon provided from a mobile app. The query looks like this: SELECT *,(((acos(sin(($latitude *pi()/180)) * sin((`lat`*pi()/180))+cos(($latitude *pi()/180)) * cos((`lat`*pi()/180))*…
ppetree
  • 826
  • 3
  • 15
  • 31
0
votes
2 answers

Use result of substring function to compute values for multiple columns

I am trying to run to find the closest point with a long and lat. Which works fine is i have separate value stored in my db, however i have a single piped string, which i am able to split with a substring index. However when i try and combine these…
Jim Doodle
  • 569
  • 1
  • 6
  • 7