randomfox: (Default)
[personal profile] randomfox
These two macros take coordinates from the clipboard, whether in dd.ddddd format or in dd mm.mmm format.

Then the first macro pastes dd.ddddd format coordinates into two form fields with 2 tabs separating the fields. The second macro does the same but with 1 tab instead of 2.

Use the first macro for Geosnapper and the second for Streets and Trips.


; Finds either dd mm.mmm coordinates or decimal-degree coordinates.
; Returns latitude and longitude in geolat and geolon.
; Returns true if there was a match. Returns false if no match.
CoordMatch(str, ByRef geolat, ByRef geolon)
{
    foundpos := RegExMatch(str, "(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)", matches)
    if foundpos > 0
    {
	geolat := matches1 + (matches2 + matches3 / 1000) / 60
	geolon := - (matches4 + (matches5 + matches6 / 1000) / 60)
	return true
    }
    else {
	foundpos := RegExMatch(str, "^.*?(\d+\.\d+).+?(-\d+\.\d+).*$", matches)
	if foundpos > 0
	{
	    geolat := matches1
	    geolon := matches2
	    return true
	}
    }
    return false
}

	
; Copy Topozone URL or dd mm.mmm coordinates to clipboard. Then use this
; macro to fill in Geosnapper coordinates fields.
!s::
KeyWait,Alt
saveclip := ClipboardAll
if CoordMatch(Clipboard, geolat, geolon) 
{
    BlockInput On
    clipboard := geolat
    SendInput ^a^v
    Sleep 50
    SendInput {tab 2}
    Sleep 50
    clipboard := geolon
    SendInput ^v
    Sleep 50
    ; Restore the clipboard.
    clipboard := saveclip
    saveclip =
    BlockInput Off
}
else {
    MsgBox,"Can't parse coordinates from clipboard"
}
return


; Copy Topozone URL or dd mm.mmm coordinates to clipboard. Then use this
; macro to fill in decimal degrees into two consecutive form fields in
; Streets and Trips.
!t::
KeyWait,Alt
saveclip := ClipboardAll
if CoordMatch(Clipboard, geolat, geolon) 
{
    BlockInput On
    clipboard := geolat
    SendInput {home}+{end}^v
    Sleep 50
    SendInput {tab}
    Sleep 50
    clipboard := geolon
    SendInput ^v
    Sleep 50
    ; Restore the clipboard.
    clipboard := saveclip
    saveclip =
    BlockInput Off
}
else {
    MsgBox,"Can't parse coordinates from clipboard"
}
return


From:
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

Profile

randomfox: (Default)
randomfox

November 2012

S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728 2930 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 23rd, 2017 10:44 am
Powered by Dreamwidth Studios