Questions tagged [earthdistance]

25 questions
14
votes
3 answers

Custom Database Type in ActiveRecord

I am using Rails 3.1.1 with PostgreSQL 9.1 and the earthdistance module. To be able to calculate the distance between different locations properly, I have setup a column with the earth type in my branches table. The problem I am experiencing now is…
Patrick Glandien
  • 7,791
  • 5
  • 41
  • 47
13
votes
3 answers

How to compute "EMD" for 2 numpy arrays i.e "histogram" using opencv?

Since I'm new to opencv, I don't know how to use the cv.CalcEMD2 function with numpy arrays. I have two arrays: a=[1,2,3,4,5] b=[1,2,3,4] How can I transfer numpy array to CVhistogram and from Cvhistogram to the function parameter signature? I…
Someone Someoneelse
  • 487
  • 2
  • 8
  • 27
8
votes
2 answers

Postgresql earthdistance - earth_box with radius

Please, can you explain me this behaviour of earth_box function ... or what I'm doing wrong? data used 40.749276, -73.985643 = Empire State Building - is in my table 40.689266, -74.044512 = Statue of Liberty - is my current position in select -…
Noe
  • 85
  • 1
  • 5
8
votes
1 answer

Convert latitude and longitude to ECEF coordinates system

I am studying pArk Apple sample code, and how it is works. anyone knows how convert the latitude and longitude to ECEF coordinates, and Covert ECEF to ENU coordinates centered at given lat, lon functions are work? I just want to understand what is…
Crazy
  • 386
  • 2
  • 4
  • 13
5
votes
4 answers

What units does the PostgreSQL "earthdistance" module use?

I'm guessing that the units it uses is meters (m), but it doesn't seem clear from the documentation I've found. Is this correct? If so, just to verify, in order to convert between miles/meters, I presume these functions should do the trick: public…
Matt Huggins
  • 81,398
  • 36
  • 149
  • 218
4
votes
1 answer

How to create a PostgreSQL index that includes Latitude/Longitude (using GIST), but also regular fields

I have a table of locations that users of my app need to be able to search in. Baically "locations within x miles of me" I'm using a query like this: select * from job_locations where earth_box(ll_to_earth(51.5, -0.085), 5000) @>…
Daniel Magliola
  • 30,898
  • 61
  • 164
  • 243
3
votes
1 answer

Why is <@> not returning the right distance in Postgresql?

Essentially, I have three coordinates in play. Cleveland, TN -- (35.255097,-84.86844) -- This is the origin. Atlanta, GA -- (32.4608333,-84.9877778) -- This is much closer to that origin. Columbus, GA -- (33.7488889,-84.3880556) -- This is…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
2
votes
2 answers

Find intersection coordinates of two circles on earth?

I'm trying to find a second intersection point of two circles. One of the points that I already know was used to calculate a distance and then used as the circle radius (exemple). The problem is that im not getting the know point, im getting two new…
Pioca
  • 53
  • 10
2
votes
1 answer

What do 'a' and 'c' stand for in 'Haversine formula' to measure the distance between two points?

var R = 6371e3; // metres var φ1 = lat1.toRadians(); var φ2 = lat2.toRadians(); var Δφ = (lat2-lat1).toRadians(); var Δλ = (lon2-lon1).toRadians(); var a = Math.sin(Δφ/2) * Math.sin(Δφ/2) + Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ/2) *…
Mukhammad Ali
  • 810
  • 7
  • 14
2
votes
1 answer

Use earthdistance Postgresql extension in HQL

I am facing a problem with the earthdistance extension of PostgreSQL. Following this guide, I have added the following extensions: CREATE EXTENSION cube; CREATE EXTENSION earthdistance; I tried to run the following SQL query from Postgres command…
Giu87
  • 96
  • 5
2
votes
2 answers

Finding Earth Coordinates (latitude,longitude), Distance (meters) and Bearing (angle)

I need to deal with Earth coordinates in various ways. There is no function in C/C++ which does this straight away. Referred below questions: Python: Get lat/long given current point, distance and bearing C: Given point of (latitude,longitude),…
iammilind
  • 68,093
  • 33
  • 169
  • 336
2
votes
1 answer

PostgreSQL: How to get all points in certain radius

I'm using Postgresql 9.3 and iv'e installed cube and earthdistance extensions. I'm trying to follow this tutorial, so i have a simple events table with 4 fields: id, name, lat, lng. Now i'm trying to run this query, to get all events within 1 km…
Tomer
  • 17,787
  • 15
  • 78
  • 137
1
vote
1 answer

How to cast earth datatype to json in Postgresql

I want to cast the earth datatype to a json array in Postgresql (9.5). This is what I have: CREATE OR REPLACE FUNCTION earth_to_json (inpt earth) RETURNS json AS $$ SELECT json_build_array(latitude(inpt), longitude(inpt)) $$ LANGUAGE…
1
vote
1 answer

PostgreSQL earthdistance Installation Mac

The installation of earthdistance module in Postgresql 9.6.5 on OSX El Capitan 10.11.6. PG is already installed, working. I created the extension, which installs cube first: rich=# CREATE EXTENSION earthdistance CASCADE; NOTICE: installing…
Rich_F
  • 1,830
  • 3
  • 24
  • 45
1
vote
1 answer

Trying to calculate distance between two lat-lng points in PostgreSQL - what is the unit of PostgreSQL earth_box(ll_to_earth) return value?

I have a query like so: SELECT * FROM chat_rooms WHERE earth_box(ll_to_earth(5, 5), 111000) @> ll_to_earth(lat, lng); Essentially, I have lat = lng = 5 in the query, and in my chat_rooms table I have two entries, one with lat=lng=5, the other with…
BeardMagician
  • 647
  • 13
  • 26
1
2