How to use location in org-roam?

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:

  1. Evaluate all the functions in the Gist
  2. Create a couple of test nodes with a :geo: property
  3. Visit a Org-roam node that has a :geo: property – where you are will be the origin
  4. Run command my/list-node-IDs-within-range-of-distance
  5. Enter a number: that is the max distance in kilometers
  6. 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).

Two notes:

  • 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)

:properties:
:modified: 2023-07-30T182055
:ID:       2023-07-30T163232
:geo: 37.3927 -122.042
:end:
#+title: test GEO Mountain View
#+filetags: test

File 2

:properties:
:modified: 2023-07-30T164943
:ID:       2023-07-30T164720
:geo: 37.3587 -122.075
:end:
#+title: test GEO 10km Ortega park
#+filetags:

File 3

:properties:
:modified: 2023-07-30T165100
:ID:       2023-07-30T165039
:geo: 37.0154 -122.211
:end:
#+title: test GEO more than 10km Devon Port
#+filetags: test