I would like to be able to put, say, the latitude and longitude for a place into a node for that place, and then be able to find org-roam nodes that are within a specified distance from the first place.
For example, I make nodes for cities that have a person or company or institution I’m interested in. Take for argument’s sake, these nodes I really have:
#+title: Palo Alto, CA
#+title: Mountain View, CA
What if I added a LATLONG property like this: (I got the lat long from Wikipedia)
:LATLONG: 37°22′16″N 122°2′15″W
#+title: Sunnyvale, CA
If I had the Mountain View node open in Emacs, I would like to be able to issue a command that would return all the nodes that are within say 10 miles of the lat long (I could put) in the Mountain View node.
I searched the discourse for proximity and location and didn’t find any conversation relevant to this.
I’m interested in this concept as well – very interesting use case.
From my understanding, this should be possible programmatically. This page has a good example as well as some code in different languages (no Lisp though).
I’d try to write something up in Lisp, but my primary coding language is C, so I’m probably not the best person to provide that.
I have done a quick experiment (code in Gist). It works on my end.
If someone can make it better, I’d love to see improvement. I just took it on as a technical exercise.
To use it:
- Evaluate all the functions in the Gist
- Create a couple of test nodes with a
- Visit a Org-roam node that has a
:geo: property – where you are will be the origin
- Run command
- Enter a number: that is the max distance in kilometers
- You will see a list of nodes ID that are within the kilometer distance
Please try not to be confused with the fact that the prompt asks for the max distance in kilometers and the resultant pop-up buffer shows the distance in meters. I could not show kilometers without rounding the values to 4km and 44km respectively (4 km vs 4.75 km is large enough for me to care).
- I used
GEO property name, not
LATLONG but they denote the same thing
- The value of
GEO property must be decimal degrees and must be separated by a space
- If you want to use this notation
37°22′16″N 122°2′15″W, you’d need to convert it
- The algorithm is from this website – see the source code for a bit more detail
My test files are as follows.
File 1 (the origin)
:geo: 37.3927 -122.042
#+title: test GEO Mountain View
:geo: 37.3587 -122.075
#+title: test GEO 10km Ortega park
:geo: 37.0154 -122.211
#+title: test GEO more than 10km Devon Port