* geolocated notes
@ 2010-09-27 11:15 Łukasz Stelmach
2010-09-28 16:11 ` Carsten Dominik
0 siblings, 1 reply; 4+ messages in thread
From: Łukasz Stelmach @ 2010-09-27 11:15 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: geolocated notes
2010-09-27 11:15 geolocated notes Łukasz Stelmach
@ 2010-09-28 16:11 ` Carsten Dominik
2010-09-29 8:04 ` Łukasz Stelmach
0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2010-09-28 16:11 UTC (permalink / raw)
To: Łukasz Stelmach; +Cc: emacs-orgmode
Nice!
- Carsten
On Sep 27, 2010, at 1:15 PM, Łukasz 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
> 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
>
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: geolocated notes
2010-09-28 16:11 ` Carsten Dominik
@ 2010-09-29 8:04 ` Łukasz Stelmach
2010-09-29 17:47 ` Łukasz Stelmach
0 siblings, 1 reply; 4+ messages in thread
From: Łukasz Stelmach @ 2010-09-29 8:04 UTC (permalink / raw)
To: emacs-orgmode
Carsten Dominik <carsten.dominik@gmail.com> writes:
> On Sep 27, 2010, at 1:15 PM, Łukasz Stelmach wrote:
>
>> 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.
[...]
> Nice!
There are few things to do: accept `geo:' URIs[1] simply putting them in
the GEO property without any modification, some sanity and error checks
too. I am going to work on this for myself[2] but I will follow this thread
waiting for any suggestions too.
What I would like to achieve is a "geospatial aware todo list" that
enables one to choose todos along or near a route between two selected
points, so one can visit them when traveling. Probably there will be a
link to the Google Maps on the bootom of such a list to visualise such a
list.
[1] http://geouri.org/
[2] I'll create org-geo branch in http://github.com/steelman/org-mode
--
Miłego dnia,
Łukasz Stelmach
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-09-29 17:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-27 11:15 geolocated notes Łukasz Stelmach
2010-09-28 16:11 ` Carsten Dominik
2010-09-29 8:04 ` Łukasz Stelmach
2010-09-29 17:47 ` Łukasz Stelmach
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).