From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: geolocated notes Date: Tue, 28 Sep 2010 18:11:12 +0200 Message-ID: <5A188987-6627-4932-9B87-56174CF8E907@gmail.com> References: <877hi7mo8a.fsf@dasa3.iem.pw.edu.pl> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=36385 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0dSn-0007Kz-2e for emacs-orgmode@gnu.org; Tue, 28 Sep 2010 12:55:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0dSl-0006or-SB for emacs-orgmode@gnu.org; Tue, 28 Sep 2010 12:55:32 -0400 Received: from mail-ey0-f169.google.com ([209.85.215.169]:37368) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0dSl-0006l4-9a for emacs-orgmode@gnu.org; Tue, 28 Sep 2010 12:55:31 -0400 Received: by mail-ey0-f169.google.com with SMTP id 5so2359169eyh.0 for ; Tue, 28 Sep 2010 09:55:30 -0700 (PDT) In-Reply-To: <877hi7mo8a.fsf@dasa3.iem.pw.edu.pl> 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: =?UTF-8?Q?=C5=81ukasz_Stelmach?= Cc: emacs-orgmode@gnu.org Nice! - Carsten On Sep 27, 2010, at 1:15 PM, =C5=81ukasz Stelmach wrote: > 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 =20 > 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 =20= > 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 =20 > 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=3D\\(-?[.0-9]+\\)" p) > (setq lat (match-string 1 p))) > ((string-match "lon=3D\\(-?[.0-9]+\\)" p) > (setq lon (match-string 1 p)))))) > ; Google Maps > ((string-match > = "^http://maps\.google\.com/.*ll=3D\\(-?[.0-9]+\\),\\(-?[.0-9]+\\)" =20 > 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\\|=20 > maps\.google\.com\\)". stl/org-dnd-set-geo-property)) dnd-protocol-=20 > 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--- > > --=20 > Mi=C5=82ego dnia, > =C5=81ukasz Stelmach > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode