distance

Android - How to get estimated drive time from one place to another?

烈酒焚心 提交于 2019-11-27 00:24:18
问题 I need to find the estimate drive time from one place to another. I've got latitudes and longitudes for both places but I have no idea how to do that. Is there is any API for that. help thanks. 回答1: yes you get the time and distance value as well as many like direction details in driving, walking etc mode. all you got from the google direction api service check our this links http://code.google.com/apis/maps/documentation/directions/ 回答2: Location location1 = new Location(""); location1

Making a Location object in Android with latitude and longitude values

二次信任 提交于 2019-11-27 00:14:03
问题 I have a program in which latitude and longitude values of a location are stored in a database, which I download. I want to get the distance between these coordinates, and my current location. The Location class has a simple method to find the distance between two Location objects, so I figured I'd make a Location object with the coordinates, then call the method. Is there an easy way to do this? Also, if there's another reliable, fairly simple equation that won't clutter things too much,

Find K nearest neighbors, starting from a distance matrix

我与影子孤独终老i 提交于 2019-11-26 23:00:52
I'm looking for a well-optimized function that accepts an n X n distance matrix and returns an n X k matrix with the indices of the k nearest neighbors of the ith datapoint in the ith row. I find a gazillion different R packages that let you do KNN, but they all seem to include the distance computations along with the sorting algorithm within the same function. In particular, for most routines the main argument is the original data matrix, not a distance matrix. In my case, I'm using a nonstandard distance on mixed variable types, so I need to separate the sorting problem from the distance

Coordinates of the closest points of two geometries in Shapely

限于喜欢 提交于 2019-11-26 22:50:24
问题 There is a polyline with a list of coordinates of the vertices = [(x1,y1), (x2,y2), (x3,y3),...] and a point(x,y). In Shapely, geometry1.distance(geometry2) returns the shortest distance between the two geometries. >>> from shapely.geometry import LineString, Point >>> line = LineString([(0, 0), (5, 7), (12, 6)]) # geometry2 >>> list(line.coords) [(0.0, 0.0), (5.0, 7.0), (12.0, 6.0)] >>> p = Point(4,8) # geometry1 >>> list(p.coords) [(4.0, 8.0)] >>> p.distance(line) 1.4142135623730951 But I

iphone accelerometer speed and distance

久未见 提交于 2019-11-26 22:46:46
问题 I want to find distance traveled and velocity from accelerometer events. Like iphone's gMeter application is doing. Any suggestion, by which value or formula I should use for that? Thanks in advance. 回答1: You can use the acceleration values from the accelerometer to measure the velocity and distance. There is really good paper (Implementing Positioning Algorithms Using Accelerometers) which explains the errors you get from the accelerometer and the techniques to get the velocity and position

How to find my distance to a known location in JavaScript

折月煮酒 提交于 2019-11-26 22:37:35
问题 Using JavaScript in the browser, how can I determine the distance from my current location to another location for which I have the latitude and longitude? 回答1: If your code runs in a browser, you can use the HTML5 geolocation API: window.navigator.geolocation.getCurrentPosition(function(pos) { console.log(pos); var lat = pos.coords.latitude; var lon = pos.coords.longitude; }) Once you know the current position and the position of your "target", you can calculate the distance between them in

Convert a dataframe to an object of class “dist” without actually calculating distances in R

耗尽温柔 提交于 2019-11-26 22:26:18
问题 I have a dataframe with distances df<-data.frame(site.x=c("A","A","A","B","B","C"), site.y=c("B","C","D","C","D","D"),Distance=c(67,57,64,60,67,60)) I need to convert this to an object of class "dist" but I do not need to calculate a distance so therefore I cannon use the dist() function. Any advice? 回答1: I had a similar problem not to long ago and solved it like this: n <- max(table(df$site.x)) + 1 # +1, so we have diagonal of res <- lapply(with(df, split(Distance, df$site.x)), function(x) c

Calculating distance between zip codes in PHP

本秂侑毒 提交于 2019-11-26 21:42:38
I grabbed a database of the zip codes and their langitudes/latitudes, etc from this This page . It has got the following fields: ZIP, LATITUDE, LONGITUDE, CITY, STATE, COUNTY, ZIP_CLASS The data was in a text file but I inserted it into a MySQL table. My question now is, how can i utilise the fields above to calculate the distance between two zip codes that a user can enter on the website? Working code in PHP will be appreciated You can also try hitting a web service to calc the distance. Let someone else do the heavy lifting. https://www.zipcodeapi.com/API#distance Adam Bellaire This is mike

Distance moved by Accelerometer

女生的网名这么多〃 提交于 2019-11-26 19:57:20
I want to move objects on iPhone screen (rectangle, circle and so on) by moving iPhone. For example, I move iPhone along X-axis and the object moves along X-axis. The same for Y,Z-axis. How can I do this? Can I get algorithm for it? Thank you. P.S: I looked for a while and seems like it is possible using accelerometer. Ali You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice. Here is an explanation why (Google Tech Talk) at 23:20. I highly recommend this video. However the gyro mouse might work for your application, see between 37

Jaro–Winkler distance algorithm in C#

房东的猫 提交于 2019-11-26 19:38:10
问题 How would the Jaro–Winkler distance string comparison algorithm be implemented in C#? 回答1: public static class JaroWinklerDistance { /* The Winkler modification will not be applied unless the * percent match was at or above the mWeightThreshold percent * without the modification. * Winkler's paper used a default value of 0.7 */ private static readonly double mWeightThreshold = 0.7; /* Size of the prefix to be concidered by the Winkler modification. * Winkler's paper used a default value of 4