branch: externals/osm commit adc8156a708263ddf202aef5622fcf74bb8e2564 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
README: Add more examples --- README.org | 2 ++ osm.el | 29 ++++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/README.org b/README.org index 58e4cdee18..98adeaebac 100644 --- a/README.org +++ b/README.org @@ -34,6 +34,8 @@ Examples: - [[osm:opentopomap:44.00862011541535,9.99755859375,6][Italia, 44.01° 10.00° OpenTopoMap]] - [[osm:51.48950698022105,-0.144195556640625,11][London, England, 51.49° -0.14°]] - [[osm:cyclosm:55.686875255964424,12.569732666015625,12][København, Danmark, 55.69° 12.57° CyclOSM]] +- [[osm:stamen-watercolor:40.72956780913898,-73.97918701171875,12][New York, United States, 40.73° -73.98° Stamen Watercolor]] +- [[osm:opentopomap:27.961656050984658,86.89224243164062,13][Mount Everest, 27.96° 86.89° OpenTopoMap]] In order to retrieve a meaningful name for the current location press ~n~ in the ~org-mode~ buffer first. Then the buffer is renamed. The links and bookmarks will diff --git a/osm.el b/osm.el index 965b2ebd23..aee90ed706 100644 --- a/osm.el +++ b/osm.el @@ -660,26 +660,29 @@ We need two distinct images which are not `eq' for the display properties.") (car bm) (format "*%s*" (car bm)))))) -(defun osm--description () +(defun osm--location-name () "Return descriptive string for current map." (message "Fetching location name...") - (alist-get - 'display_name - (json-parse-string - (shell-command-to-string - (concat - "curl -s " - (shell-quote-argument - (format "https://nominatim.openstreetmap.org/reverse?format=json&zoom=%s&lon=%s&lat=%s" - (min 18 (max 3 osm--zoom)) (osm--lon) (osm--lat))))) - :array-type 'list - :object-type 'alist))) + (let ((name + (alist-get + 'display_name + (json-parse-string + (shell-command-to-string + (concat + "curl -s " + (shell-quote-argument + (format "https://nominatim.openstreetmap.org/reverse?format=json&zoom=%s&lon=%s&lat=%s" + (min 18 (max 3 osm--zoom)) (osm--lon) (osm--lat))))) + :array-type 'list + :object-type 'alist)))) + (message "%s" (or name "No name found")) + name)) ;;;###autoload (defun osm-rename () "Rename buffer, use name of current location." (interactive) - (when-let (desc (osm--description)) + (when-let (desc (osm--location-name)) (rename-buffer (format "*osm: %s, %.2f° %.2f° %s*" desc (osm--lat) (osm--lon)