distance

Sort list of lon\\lat points, start with nearest

那年仲夏 提交于 2019-11-28 20:53:52
I have location from GPS (lon_base, lat_base). I have a list of locations (lon1, lat1|lon2, lat2|lon3, lat3...) This list is very long and is around the world. My questions are: 1. How do I get from that list only the lon\lat that are 1 mile from my lon_base\lat_base? 2. How do I sort them from closest to farthest? Thanks in advance! You want to define your own Comparator that, in general, looks something like this: LonLat myHouse = /* whatever */ ; Comparable comp = new Comparable () { LonLat a; int compareTo (Object b) { int aDist = calcDistance(a, myHouse) ; int bDist = calcDistance(b,

Percentage rank of matches using Levenshtein Distance matching

只愿长相守 提交于 2019-11-28 20:20:21
I am trying to match a single search term against a dictionary of possible matches using a Levenshtein distance algorithm. The algorithm returns a distance expressed as number of operations required to convert the search string into the matched string. I want to present the results in ranked percentage list of top "N" (say 10) matches. Since the search string can be longer or shorter than the individual dictionary strings, what would be an appropriate logic for expressing the distance as a percentage, which would qualitatively refelct how close "as a percentage" is each result to the query

calculating distance between a point and a rectangular box (nearest point)

二次信任 提交于 2019-11-28 20:19:57
is there a easy formula to calculate this? i've been working on some math but i can only find a way to calculate the distance directed to the center of the box, not directed to the nearest point.. are there some resources on this problem? Here is a single formula that avoids all the case logic. (I happen to be working in JS right now, so here's a JS implementation). Let rect = {max:{x:_, y:_}, min:{x:_, y:_}} and p={x:_, y:_} function distance(rect, p) { var dx = Math.max(rect.min.x - p.x, 0, p.x - rect.max.x); var dy = Math.max(rect.min.y - p.y, 0, p.y - rect.max.y); return Math.sqrt(dx*dx +

Distance of point feature to nearest polygon in R

拥有回忆 提交于 2019-11-28 19:55:05
I working on a project at the moment, where I have a point feature -- the point feature includes a 142 points -- and multiple polygon (around 10). I want to calculate the distance between every single point and the nearest polygon feature in R. My current approach is tedious and a bit long winded. I am currently planning to calculate the distance between every single point and every single polygon. For example, I would calculate the distance between the 142 points and Polygon A, the distance between the 142 points and Polygon B, the distance between 142 points and Polygon C, etc. Here is a

Mahalanobis distance in R

北城余情 提交于 2019-11-28 19:01:17
I have found the mahalanobis.dist function in package StatMatch ( http://cran.r-project.org/web/packages/StatMatch/StatMatch.pdf ) but it isn't doing exactly what I want. It seems to be calculating the mahalanobis distance from each observation in data.y to each observation in data.x I would like to calculate the mahalanobis distance of one observation in data.y to all observations in data.x. Basically calculate a mahalanobis distance of one point to a "cloud" of points if that makes sense. Kind of getting at the idea of the probability of an observation being part of another group of

Find the distance between HTML element and browser (or window) sides

こ雲淡風輕ζ 提交于 2019-11-28 18:25:24
问题 How to find the distance in pixels between html element and one of the browser (or window) sides (left or top) using jQuery? 回答1: You can use the offset function for that. It gives you the element's position relative to the (left,top) of the document : var offset = $("#target").offset(); display("span is at " + offset.left + "," + offset.top + " of document"); Live example On my browser, that example says that the span we've targeted is at 157,47 (left,top) of the document. This is because I

Algorithm to find two points furthest away from each other

我只是一个虾纸丫 提交于 2019-11-28 17:52:15
Im looking for an algorithm to be used in a racing game Im making. The map/level/track is randomly generated so I need to find two locations, start and goal, that makes use of the most of the map. The algorithm is to work inside a two dimensional space From each point, one can only traverse to the next point in four directions; up, down, left, right Points can only be either blocked or nonblocked, only nonblocked points can be traversed Regarding the calculation of distance, it should not be the "bird path" for a lack of a better word. The path between A and B should be longer if there is a

Convert and save distance matrix to a specific format

痴心易碎 提交于 2019-11-28 17:37:26
I got a distance matrix with the following steps: x <- read.table(textConnection(' t0 t1 t2 aaa 0 1 0 bbb 1 0 1 ccc 1 1 1 ddd 1 1 0 ' ), header=TRUE) As such x is a data frame with column and row headers t0 t1 t2 aaa 0 1 0 bbb 1 0 1 ccc 1 1 1 ddd 1 1 0 require(vegan) d <- vegdist(x, method="jaccard") The distance matrix d is obtained as follows: aaa bbb ccc bbb 1.0000000 ccc 0.6666667 0.3333333 ddd 0.5000000 0.6666667 0.3333333 By typing str(d), I found it is not a ordinary table nor csv format. Class 'dist' atomic [1:6] 1 0.667 0.5 0.333 0.667 ... ..- attr(*, "Size")= int 4 ..- attr(*,

Google Distance Matrix API Alternatives? [closed]

ぐ巨炮叔叔 提交于 2019-11-28 17:24:17
问题 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 9 months ago . Can you recommend alternatives for the Google Distance Matrix API? This service is great but has some serious quota limitations and the Terms of use are also pretty tough. Thanks! 回答1: MapQuest RouteMatrix is pretty much the same thing: http://www.mapquestapi.com/directions/ 回答2: Bing's Route Data API may be an

How to calculate distance based on phone acceleration

て烟熏妆下的殇ゞ 提交于 2019-11-28 17:19:55
I want to build something like this but using an android phone: http://www.youtube.com/watch?v=WOt9mb5QqRs I've already built an app that sends sensor information via socket (still looking for a good websocket implementation for android). I intend to use that information to interact with a web app, so for example i would be able to move an image based on the phone movement. The problem is that I tried to calculate distance based on the accelerometer data but the results are really bad. I wonder if anyone could help me with the correct equation, but first of all, is it possible to do this? Till