distance

Function to calculate distance between two coordinates

别来无恙 提交于 2019-11-26 19:22:24
I'm currently using the function below and it doesn't work properly. According to Google Maps, the distance between these coordinates (from 59.3293371,13.4877472 to 59.3225525,13.4619422 ) are 2.2 kilometres while the function returns 1.6 kilometres. How can I make this function return the correct distance? function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) { var R = 6371; // Radius of the earth in km var dLat = deg2rad(lat2-lat1); // deg2rad below var dLon = deg2rad(lon2-lon1); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin

how to calculate distance while walking in android?

余生长醉 提交于 2019-11-26 19:15:27
问题 I am developing a demo for my app, in which there are two buttons named as "START" and "STOP". When user taps on "START" he will start walking. What I want to do is make it so that when users tap "STOP" then the demo will calculate his distance between "START" and "STOP". If the user pressed "START" and pressed "STOP" without taking a single step, then it must show 0km or 0m. I don't have any idea how I should start this; please make a suggestion. 回答1: One way to go about it is using the

Function to calculate geospatial distance between two points (lat,long) using R [duplicate]

戏子无情 提交于 2019-11-26 19:05:43
问题 This question already has answers here : Geographic / geospatial distance between 2 lists of lat/lon points (coordinates) (3 answers) Calculate distance between two latitude-longitude points? (Haversine formula) (36 answers) Closed 2 years ago . I have geocoded points in long, lat format, and I want to calculate the distance between them using R. This seems pretty straight forward, yet I can't find a function that will do it easily. I've been attempting to do it with the gdistance package,

Calculating distance of all the points in a region with each other

♀尐吖头ヾ 提交于 2019-11-26 18:29:54
问题 I have a region with about 144 points. What i want to achieve is to measure the distance of a point with all others and store it in an array. I want to do this for all the points. If possible i would like to store this data in such a manner that there in no repetition. And i should be able to make queries like- All the distances between all the points without repetition, sum of all the distances for point no56 etc. I have a 3*144 array with two columns storing the coordinates of the points.

d3 force directed layout - link distance priority

天涯浪子 提交于 2019-11-26 17:14:24
问题 Using a force-directed layout in d3, how do I make the link distance a priority, while still keeping a nice graph layout? If I specify dynamic link distances, but keep the default charge, my graph distances are morphed a bit by the charge function, and are no longer accurate distances: However, if I remove the charge, the graph looks like this: Any advice appreciated! 回答1: If I understand correctly, I believe there is a potential solution. To get link distance to be accurate, you need to set

Geospatial coordinates and distance in kilometers

淺唱寂寞╮ 提交于 2019-11-26 15:32:58
问题 This is a followup to this question. I seem to be stuck on this. Basically, I need to be able to convert back and forth to referring to coordinates either in the standard degree system OR by measuring a distance north from the south pole along the international date line, and then a distance east starting from that point on the date line. To do this (as well as some more general distance-measuring stuff), I have one method for determining the distance between two lat/lon points, and another

distance calculations in mysql queries

为君一笑 提交于 2019-11-26 12:31:16
问题 I have to query a database of thousands of entries and order this by the distance from a specified point. The issue is that each entry has a latitude and longitude and I would need to retrieve each entry to calculate its distance. With a large database, I don\'t want to retrieve each row, this may take some time. Is there any way to build this into the mysql query so that I only need to retrieve the nearest 15 entries. E.g. `SELECT events.id, caclDistance($latlng, events.location) AS distance

Calculate distance in meters when you know longitude and latitude in java [duplicate]

痞子三分冷 提交于 2019-11-26 12:03:20
Possible Duplicate: Working with latitude/longitude values in Java Duplicate: Working with latitude/longitude values in Java How do I calculate distance between two latitude longitude points? I need to calculate the distance between two points given by two coordinates. The project I am working on is a Java-project, so Java-code will be great, but pseudo-code can also be given, then I can implement it myself :) As you probably know, there are three ways to represent coordinates: Degrees:Minutes:Seconds (49°30'00"N, 123°30'00"W) Degrees:Decimal Minutes (49°30.0', -123°30.0'), (49d30.0m,-123d30.0

How can I find distance traveled with a gyroscope and accelerometer?

眉间皱痕 提交于 2019-11-26 11:03:37
I want to build an app that calculates accurate Distance travelled by iPhone (not long distance) using Gyro+Accelerometer. No need for GPS here. How should I approach this problem? Basic calculus behind this problem is in the expression (and similar expressions for displacements in y and z) and basic geometry is the Pythagorean theorem So, once you have your accelerometer signals passed through a low-pass filter and binned in time with sampling interval dt, you can find the displacement in x as ( pardon my C... ) float dx=0.0f; float vx=0.0f; for (int i=1; i<n; i++) { vx+=(acceleration_x[i-1]

R - How to get row & column subscripts of matched elements from a distance matrix

拈花ヽ惹草 提交于 2019-11-26 08:36:24
问题 I have an integer vector vec1 and I am generating a distant matrix using dist function. I want to get the coordinates (row and column) of element of certain value in the distance matrix. Essentially I would like to get the pair of elements that are d-distant apart. For example: vec1 <- c(2,3,6,12,17) distMatrix <- dist(vec1) # 1 2 3 4 #2 1 #3 4 3 #4 10 9 6 #5 15 14 11 5 Say, I am interested in pair of elements in the vector that are 5 unit apart. I wanted to get the coordinate1 which are the