distance

how to calculate the distance between two points in android app

社会主义新天地 提交于 2019-12-04 04:18:52
问题 in my app i am trying to calculate the distance a person traveling from one place to the other. For that i am using the Haversine formula, R = earth’s radius (mean radius = 6,371km) Δlat = lat2− lat1 Δlong = long2− long1 a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2) c = 2.atan2(√a, √(1−a)) d = R.c getting the latitude and longitude of starting place and reaching place i am calculating the distance in kms. But others say that this distance calculation works only if travelled by airways

Latitude / Longitude and meters

大憨熊 提交于 2019-12-04 03:49:49
I have a small algorithmic problem. I am developing an Android application. I get GPS coordinates. For example: latitude: 23.23907 , longitude: 50.45786 . So I get a point. I want to compute bounds details on this point plus or minus 5 meters. I.e.: [23.23907 - 5 meters ; 23.23907 + 5 meters] [50.45786 - 5 meters ; 50.45786 + 5 meters] How to make this calculation? Thank you very much! The haversine formula can be simplified a great deal when you work in north-south and east-west directions only. If Earth's circumference is C, the point at d kilometers to south of a given point is 360*d/C

Symfony2, Doctrine search and order by distance

前提是你 提交于 2019-12-04 03:37:14
问题 I have a database of places which I store the latitude and longitude for. I want to query the database to find all places within a radius ( $requestedDistance ) of a specific latitude ( $latitude ) and longitude ( $longitude ). The below query works and returns only those places within this radius, however how would I order them by distance so the closest is first? In the past, using raw SQL I have done the calculation within the SELECT statement and set it as 'distance' and then used HAVING

Wrong Euclidean distance H2O calculations R

老子叫甜甜 提交于 2019-12-04 03:37:11
问题 I am using H2O with R to calculate the euclidean distance between 2 data.frames: set.seed(121) #create the data df1<-data.frame(matrix(rnorm(1000),ncol=10)) df2<-data.frame(matrix(rnorm(300),ncol=10)) #init h2o h2o.init() #transform to h2o df1.h<-as.h2o(df1) df2.h<-as.h2o(df2) if I use normal calculations, i.e. the first row: distance1<-sqrt(sum((df1[1,]-df2[1,])^2)) And If I use the H2O library: distance.h2o<-h2o.distance(df1.h[1,],df2.h[1,],"l2") print(distance1) print(distance.h2o) The

Finding out distance between router and receiver?

旧街凉风 提交于 2019-12-04 01:38:33
问题 A general question: is it possible to retrieve information about how far away e.g. a computer is from a wifi-router. For instance I want to get data on my computer if I'm 10 meters away from my home-wifispot or 2 meters. Any idea if that is even possible? Edit: How about bluetooth? Is it possible to get information about how far away bluetooth-connected devices are one from another? 回答1: I would recommend a measuring line or just good-old-fashioned guesstimating. There is no "simple" way to

Recalculating distance matrix

三世轮回 提交于 2019-12-03 23:10:34
I’ve got a large input matrix (4000x10000). I use dist() to calculate the Euclidean distance matrix for it (it takes about 5 hours). I need to calculate the distance matrix for the "same" matrix with an additional row (for a 4001x10000 matrix). What is the fastest way to determine the distance matrix without recalculating the whole matrix? I'll assume your extra row means an extra point. If it means an extra variable/dimension, it will call for a different answer. First of all, for euclidean distance of matrices, I'd recommend the rdist function from the fields package. It is written in

Google Map API v2 - Get Driving Distance from Current Location to Known Locations

爷,独闯天下 提交于 2019-12-03 21:54:34
I'm trying to figure out how to display the driving distance from the current location to four known locations. I'm not showing a map on the screen, I just need to display how many miles away the user currently is from those locations. I took an example from Here and modified it a little. It is bringing back the correct distance but I can't figure out how to pass in each of the 4 end locations, or differentiate between them. What do I need to do in order to get the distance to each of the 4 locations and display each of those distances in separate TextViews? Update question: How do I calculate

How to use R to compute Tanimoto/Jacquard Score as distance matrix

时光怂恿深爱的人放手 提交于 2019-12-03 20:06:15
I would like to calculate the distance matrix of the rows in an array in R using Tanimoto/Jacquard Score as distance matrix. Is it possible to be done? If yes, could you mind to teach me how to do it? vegan package has a vegdist function that can calculate, among other things, the Jaccard index. Assuming that's what you're after. It's use is pretty straightforward. library(vegan) data(varespec) vare.dist <- vegdist(varespec, method = "jaccard") Other available methods are method Dissimilarity index, partial match to "manhattan", "euclidean", "canberra", "bray", "kulczynski", "jaccard", "gower"

Extract diagonals from a distance matrix in R

帅比萌擦擦* 提交于 2019-12-03 18:17:49
问题 I would like to know how can I extract the values of the first diagonal from a distance matrix. For example: > mymatrix [,1] [,2] [1,] 1 2 [2,] 3 4 [3,] 6 4 [4,] 8 6 > dist(mymatrix) 1 2 3 2 2.828427 3 5.385165 3.000000 4 8.062258 5.385165 2.828427 I want to get in a vector the values: 2.828427, 3.000000, 2.828427 Thanks! 回答1: One work around is to convert the dist object to matrix and then extract elements where row index is one larger than the column index: mat = as.matrix(dist(mymatrix))

Distance between two coordinates, how can I simplify this and/or use a different technique?

北城余情 提交于 2019-12-03 18:00:23
问题 I need to write a query which allows me to find all locations within a range (Miles) from a provided location. The table is like this: id | name | lat | lng So I have been doing research and found: this my sql presentation I have tested it on a table with around 100 rows and will have plenty more! - Must be scalable. I tried something more simple like this first: //just some test data this would be required by user input set @orig_lat=55.857807; set @orig_lng=-4.242511; set @dist=10; SELECT *