haversine

How to transform raw SQL into Yii2 like find query

此生再无相见时 提交于 2020-03-05 05:20:04
问题 I can't convert raw SQL query in to Yii2 like method. I'd like to implement grid view from my RAW sql with filtering and sorting. I'm using ActiveDataProvider with method in the ModelSearch as Yii default way. I did try to use Model::findBySql but it is not letting me filter or sort my results in the grid view. I don't want to useSQLDataProvider because I have relations in my queries. I see that changing Model::FindBySql($sql) to Model::find is letting me sort and filter but the results are

Haversine and Laravel

笑着哭i 提交于 2020-01-23 12:52:38
问题 I'm attempting to compare a users location (Sent via params in the URL) to offers.offer_lat and offers.offer_long (in my DB) by a distance argument (set in miles) I'm going crazy right now, a lot of solutions I have found online are proving hard to port over to laravels query builder using DB::raw, I currently have the function in a query scope as the user will be filtering API results using distance, no luck though! I found some functions online for calculating the haversine but I have no

From pandas dataframe to tuples (for haversine module)

北城余情 提交于 2020-01-15 06:49:30
问题 I have a pandas dataframe my_df with the following columns : id lat1 lon1 lat2 lon2 1 45 0 41 3 2 40 1 42 4 3 42 2 37 1 Basically, I'd like to do the following : import haversine haversine.haversine((45, 0), (41, 3)) # just to show syntax of haversine() > 507.20410687342115 # what I'd like to do my_df["dist"] = haversine.haversine((my_df["lat1"], my_df["lon1"]),(my_df["lat2"], my_df["lon2"])) TypeError: cannot convert the series to < class 'float' > Using this, I tried the following : my_df[

segmenting or grouping a df based on parameters or differences within columns going down the dataframe rows?

僤鯓⒐⒋嵵緔 提交于 2020-01-15 05:27:06
问题 I was trying to figure out if there was a way in which where I had a dataframe with multiple fields and I wanted to segment or group the dataframe into a new dataframe based on if the values of specific columns were within x amount of each other? I.D | Created_Time | Home_Longitude | Home_Latitude | Work_Longitude | Home_Latitude Faa1 2019-02-23 20:01:13.362 -77.0364 38.8951 -72.0364 38.8951 Above is how the original df looks with multiple rows. I want to create a new dataframe where all rows

segmenting or grouping a df based on parameters or differences within columns going down the dataframe rows?

本秂侑毒 提交于 2020-01-15 05:27:04
问题 I was trying to figure out if there was a way in which where I had a dataframe with multiple fields and I wanted to segment or group the dataframe into a new dataframe based on if the values of specific columns were within x amount of each other? I.D | Created_Time | Home_Longitude | Home_Latitude | Work_Longitude | Home_Latitude Faa1 2019-02-23 20:01:13.362 -77.0364 38.8951 -72.0364 38.8951 Above is how the original df looks with multiple rows. I want to create a new dataframe where all rows

Querying MySQL for latitude and longitude coordinates that are within a given mile radius

六眼飞鱼酱① 提交于 2020-01-12 03:35:07
问题 I currently have a MySQL table that is structured as follows: id name lon lat ----- ----- ----------- ----------- 1 Mark -76.316528 40.036027 2 John -95.995102 41.25716 3 Paul -82.337036 29.645095 4 Dave -82.337036 29.645095 5 Chris -76.316528 40.036027 The way I currently query the DB to see if a user's location is within a certain mile radius of a given location is by doing this. function Haversine($lat_from, $lon_from, $lat_to, $lon_to) { $radius = 6371000; $delta_lat = deg2rad($lat_to-

SQL Distance Query without Trigonometry

廉价感情. 提交于 2020-01-10 20:15:11
问题 I have an SQLite database, which does not support trig functions. I would like to sort a set of lat,lng pairs in my table by distance as compared to a second lat,lng pair. I'm familiar with the standard haversine distance formula for sorting lat,lng pairs by distance. In this case I don't care particularly for precision, my points are separated by large distances, so I don't mind rounding off the distances by treating curves as straight lines. My question, is there a generally accepted

Haversine formula using SQL server to find closest venue - vb.net

馋奶兔 提交于 2020-01-10 20:11:08
问题 I am grabbing a postcode from a form. I can then convert this postcode to lng,lat coordinates as I have these stored in a table. SELECT lng, lat from postcodeLngLat WHERE postcode = 'CV1' I have another table which stores the lng,lat of a selection of venues. SELECT v.lat, v.lng, v.name, p.lat, p.lng, p.postcode, 'HAVERSINE' AS distance FROM venuepostcodes v, postcodeLngLat p WHERE p.outcode = 'CB6' ORDER BY distance What I am trying to do is create a datagrid which shows the distance of each

VBA haversine formula

倖福魔咒の 提交于 2020-01-02 07:03:14
问题 I am trying to implement Haversine formula into excel function. Its looks like this: Public Function Haversine(Lat1 As Variant, Lon1 As Variant, Lat2 As Variant, Lon2 As Variant) Dim R As Integer, dlon As Variant, dlat As Variant, Rad1 As Variant Dim a As Variant, c As Variant, d As Variant, Rad2 As Variant R = 6371 dlon = Excel.WorksheetFunction.Radians(Lon2 - Lon1) dlat = Excel.WorksheetFunction.Radians(Lat2 - Lat1) Rad1 = Excel.WorksheetFunction.Radians(Lat1) Rad2 = Excel.WorksheetFunction