distance

Calculate Distance in Km and Miles

蹲街弑〆低调 提交于 2020-01-02 05:50:48
问题 I have two points whose latitude and longitude i know. How can i calculate the distance(in Km and Miles) between them. What is the formulae? 回答1: You can use the haversine formula to calculate such distances. 回答2: Use the haversine Formula for this... Here is the link having java script code to calculate distance http://www.movable-type.co.uk/scripts/latlong.html 回答3: A = LAT1, B = LONG1 C = LAT2, D = LONG2 (all converted to radians: degree/57.29577951) IF A = C AND B = D THEN DISTANCE = 0;

Calculating the driving distance between two points using PHP only (Bing maps)

独自空忆成欢 提交于 2020-01-01 21:37:09
问题 I'd like to work out the distance between two points. No map. No javascript. Just the distance. I understand Google maps prohibits this and it's against their terms of service. But Bing Maps doesn't have this restriction. I want to give the points in a general format, i.e "Cambridge" "Church Street, Newcastle" How would I go about doing it? As basic as possible. It's for a mobile device. 回答1: 1.) Sign up for a Bing Maps key at http://www.bingmapsportal.com. A key is a alphanumeric string of

How to calculate distance between 2 coordinates below a certain threshold in R?

旧街凉风 提交于 2020-01-01 12:26:07
问题 I have 44,000 US Zip codes and it's corresponding centroid lat/long in R. This is from the package 'zipcode' in R. I need to calculate the distance between each zipcode and keep those distances that are less than 5 miles. The problem is to calculate all distances between the zipcodes I have to create a vector of size 44,000x44,0000 which I can't due to space issues. I checked through the posts in R, the closest to my requirement is one that spits out the minimum distance between 2 datasets

Django Sort By Calculated Field

旧巷老猫 提交于 2020-01-01 07:01:46
问题 Using the distance logic from this SO post, I'm getting back a properly-filtered set of objects with this code: class LocationManager(models.Manager): def nearby_locations(self, latitude, longitude, radius, max_results=100, use_miles=True): if use_miles: distance_unit = 3959 else: distance_unit = 6371 from django.db import connection, transaction cursor = connection.cursor() sql = """SELECT id, (%f * acos( cos( radians(%f) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(

Distance between Long Lat coord using SQLITE

一曲冷凌霜 提交于 2020-01-01 00:44:07
问题 I've got an sqlite db with long and lat of shops and I want to find out the closest 5 shops. So the following code works fine. if(sqlite3_prepare_v2(db, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) { while (sqlite3_step(compiledStatement) == SQLITE_ROW) { NSString *branchStr = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)]; NSNumber *fLat = [NSNumber numberWithFloat:(float)sqlite3_column_double(compiledStatement, 1)]; NSNumber *fLong = [NSNumber

Efficient way to calculate distance matrix given latitude and longitude data in Python

烈酒焚心 提交于 2019-12-31 13:55:28
问题 I have data for latitude and longitude, and I need to calculate distance matrix between two arrays containing locations. I used this This to get distance between two locations given latitude and longitude. Here is an example of my code: import numpy as np import math def get_distances(locs_1, locs_2): n_rows_1 = locs_1.shape[0] n_rows_2 = locs_2.shape[0] dists = np.empty((n_rows_1, n_rows_2)) # The loops here are inefficient for i in xrange(n_rows_1): for j in xrange(n_rows_2): dists[i, j] =

Efficient way to calculate distance matrix given latitude and longitude data in Python

走远了吗. 提交于 2019-12-31 13:55:05
问题 I have data for latitude and longitude, and I need to calculate distance matrix between two arrays containing locations. I used this This to get distance between two locations given latitude and longitude. Here is an example of my code: import numpy as np import math def get_distances(locs_1, locs_2): n_rows_1 = locs_1.shape[0] n_rows_2 = locs_2.shape[0] dists = np.empty((n_rows_1, n_rows_2)) # The loops here are inefficient for i in xrange(n_rows_1): for j in xrange(n_rows_2): dists[i, j] =

JavaFX distance between two circle and keep updating property

↘锁芯ラ 提交于 2019-12-31 06:57:04
问题 For assignment, I created 2 draggable circle and connect them with line with javaFX. I need add text which calculate distance between two circle (or length of line) and that text need to keep updating when I drag circles, but that's where I stuck Circle circle1 = new Circle(); circle1.setCenterX(40); circle1.setCenterY(40); circle1.setRadius(10); Circle circle2 = new Circle(); circle2.setCenterX(120); circle2.setCenterY(150); circle2.setRadius(10); Line line = new Line (); line.startXProperty

Modifying Levenshtein Distance for positional Bias

独自空忆成欢 提交于 2019-12-31 03:10:09
问题 I am using the Levenshtein distance algorithm to compare a company name provided as a user input against a database of known company names to find closest match. By itself, the algorithm works okay, but I want to build in a Bias so that the edit distance is considered lower if the initial parts of the strings match. For Example, if the search criteria is "ABCD", then both "ABCD Co." and "XYX ABCD" have identical Edit Distance. However I want to add weight to the fact that the initial parts of

Measure distance to iBeacon from Android device

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 06:49:07
问题 I am working on an app that has to measure the distance to an iBeacon. When a user is within a distance (1 meter) the user should be notified. It is working fine on iOS but on Android I get various results. I am using the Estimote Android SDK (https://github.com/Estimote/Android-SDK) and Android 4.3. Below is measurement from a Nexus 4 and a Nexus 5. The iBeacon is placed one meter away from the phone (the measurements are consistent with more samples): Nexus 4: 08-25 11:39:04.788: : Major: