From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?=C5=81ukasz?= Stelmach Subject: geolocated notes Date: Mon, 27 Sep 2010 13:15:33 +0200 Message-ID: <877hi7mo8a.fsf@dasa3.iem.pw.edu.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from [140.186.70.92] (port=48162 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0BgX-00058l-2d for emacs-orgmode@gnu.org; Mon, 27 Sep 2010 07:15:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0BgV-0005M7-UE for emacs-orgmode@gnu.org; Mon, 27 Sep 2010 07:15:52 -0400 Received: from lo.gmane.org ([80.91.229.12]:53804) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0BgV-0005Lq-Jk for emacs-orgmode@gnu.org; Mon, 27 Sep 2010 07:15:51 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P0BgR-0005uq-GM for emacs-orgmode@gnu.org; Mon, 27 Sep 2010 13:15:47 +0200 Received: from dasa3.iem.pw.edu.pl ([194.29.147.110]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Sep 2010 13:15:47 +0200 Received: from lukasz.stelmach by dasa3.iem.pw.edu.pl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Sep 2010 13:15:47 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hello. I've just created a hack to for org-mode (and org-remember) to receive and parse URLs from OpenStreetMap and Google Maps. The function extracts longitude and latitude and sets GEO property of the node to geo: URI. The code is easily extendable. To add support for other maps one has to add a branch in the `cond' in stl/org-dnd-set-geo-property, that sets `lon' and `lat' appropriately *and* a regular expression in stl/org-dnd-add-geo-support. To see it running just drag and drop the URL that contains geographic coordinates from the address bar (or the "Link" link in the upper right corner of the Google Maps window) over a node to get its GEO property set. --8<---------------cut here---------------start------------->8--- (defun stl/org-dnd-set-geo-property (uri action) (save-excursion (let (lat lon) (cond ; OpenStreetMap ((string-match "^http://\\(?:www\.\\)openstreetmap\.org/" uri) (dolist (p (split-string (cadr (split-string uri "\?")) "&" )) (cond ((string-match "lat=\\(-?[.0-9]+\\)" p) (setq lat (match-string 1 p))) ((string-match "lon=\\(-?[.0-9]+\\)" p) (setq lon (match-string 1 p)))))) ; Google Maps ((string-match "^http://maps\.google\.com/.*ll=\\(-?[.0-9]+\\),\\(-?[.0-9]+\\)" uri) (setq lat (match-string 1 uri) lon (match-string 2 uri)))) (unless (outline-previous-heading) (search-forward-regexp org-outline-regexp)) (org-set-property "GEO" (concat "geo:" lat "," lon))))) (defun stl/org-dnd-add-geo-support () (org-set-local 'dnd-protocol-alist (append '(("^http://\\(?:\\(?:www\.\\)?openstreetmap\.org\\|maps\.google\.com\\)". stl/org-dnd-set-geo-property)) dnd-protocol-alist))) (add-hook 'org-mode-hook 'stl/org-dnd-add-geo-support) (add-hook 'org-remember-mode-hook 'stl/org-dnd-add-geo-support) --8<---------------cut here---------------end--------------->8--- -- Miłego dnia, Łukasz Stelmach