Applescript for Instamapper GPS to Indigo integration.

Posted on
Thu Oct 01, 2009 11:44 am
chrisla23 offline
Posts: 97
Joined: Sep 16, 2009

Applescript for Instamapper GPS to Indigo integration.

I wrote a script to get the GPS location of a cellphone from Instamapper http://www.instamapper.com/ , lookup the location with geoNames, http://www.geonames.org/ and update Indigo with the location.

The script will be updated into the user contribution library.

-Chris

Posted on
Thu Oct 01, 2009 1:01 pm
eme jota ce offline
Posts: 511
Joined: Jul 09, 2009
Location: SW Florida

(No subject)

Very cool!

Looking forward to seeing details when posted.

Posted on
Thu Oct 01, 2009 1:59 pm
jay (support) offline
Site Admin
User avatar
Posts: 13274
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Applescript for Instamapper GPS to Indigo integration.

chrisla23 wrote:
I wrote a script to get the GPS location of a cellphone from Instamapper http://www.instamapper.com/ , lookup the location with geoNames, http://www.geonames.org/ and update Indigo with the location.

The script will be updated into the user contribution library.

-Chris


Approved - thanks for the script!

A couple of notes:

1) It doesn't seem to find any street close to me, which doesn't really surprise me (I'm kinda out of town) - you might consider entering an "Unknown Location" in when locationText ends up empty.
2) It would also be nice if you stored the raw lon/lat values in a different set of variables - then someone could do a little math with the lon/lat that's configured in Indigo (and are available to AppleScripts through properties of the application object) to see how close the device is.

Again, thanks for the contribution!

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Oct 01, 2009 2:22 pm
jay (support) offline
Site Admin
User avatar
Posts: 13274
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Applescript for Instamapper GPS to Indigo integration.

jay wrote:
chrisla23 wrote:
I wrote a script to get the GPS location of a cellphone from Instamapper http://www.instamapper.com/ , lookup the location with geoNames, http://www.geonames.org/ and update Indigo with the location.

The script will be updated into the user contribution library.

-Chris


Approved - thanks for the script!

A couple of notes:

1) It doesn't seem to find any street close to me, which doesn't really surprise me (I'm kinda out of town) - you might consider entering an "Unknown Location" in when locationText ends up empty.
2) It would also be nice if you stored the raw lon/lat values in a different set of variables - then someone could do a little math with the lon/lat that's configured in Indigo (and are available to AppleScripts through properties of the application object) to see how close the device is.

Again, thanks for the contribution!


Actually, there appears to be a bug in the script when a location isn't found. You get the following XML in the file returned from geonames:

Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<geonames/>


when it doesn't find a match to the location passed in. When this line of the script is executed:

Code: Select all
set locationText to (value of XML element "placename")


It throws an error (-1728 - System Events got an error: Can’t get XML element "streetSegment" of XML element "geonames" of contents of XML file "tmp:xmlfile.xml") which, since you don't have an "on error" handler in the try block, just skips setting the variable altogether. I'd suggest putting the tell to "IndigoServer" outside the try block, then add an "on error" section that sets locationText to "Unknown Location" or something if an error is encountered - but there are other things you could do there as well.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Oct 01, 2009 2:46 pm
chrisla23 offline
Posts: 97
Joined: Sep 16, 2009

(No subject)

> 1) It doesn't seem to find any street close to me, which doesn't really
> surprise me (I'm kinda out of town) - you might consider entering an
> "Unknown Location" in when locationText ends up empty.
Interesting. I too live way out of town, about 10 minutes down a single lane road in a Redwood Forrest. I'm actually not displaying the street name (for this very reason b/c I loose cell coverage about 2 minutes into that 10 minute drive) I note how it could be modified to get the street name for those living someplace a bit more civil. If you don't mind PM your lat/lon so I can have a test case.

> 2) It would also be nice if you stored the raw lon/lat values in a different
> set of variables - then someone could do a little math with the lon/lat
> that's configured in Indigo (and are available to AppleScripts through
> properties of the application object) to see how close the device is.

Sure that's easy enough. The great polar circle equation or whatever it's called.

I was also thinking about adding a third setting in the table to define where "Home" was and then setting A variable true/false based on that, but then I thought that could be handled in the new multi-conditional feature of 4.1 anyhow. If people thought that was useful I could add that too.

> Actually, there appears to be a bug in the script when a location isn't
> found. You get the following XML in the file returned from geonames:

All you got were those two lines? That's not even valid XML! tsktsk geonames, I'll see what I can do to handle that case better.

> when it doesn't find a match to the location passed in. When this line of
> the script is executed:
Yep, saw this error plenty of times while teaching myself how to do XML in applescript.

How do I submit updates? Just use the same form? I assume I would not have to fill it all out again for an update.

Thanks,

-Chris

Posted on
Thu Oct 01, 2009 3:23 pm
jay (support) offline
Site Admin
User avatar
Posts: 13274
Joined: Mar 19, 2008
Location: Austin, Texas

(No subject)

chrisla23 wrote:
> 1) It doesn't seem to find any street close to me, which doesn't really
> surprise me (I'm kinda out of town) - you might consider entering an
> "Unknown Location" in when locationText ends up empty.
Interesting. I too live way out of town, about 10 minutes down a single lane road in a Redwood Forrest. I'm actually not displaying the street name (for this very reason b/c I loose cell coverage about 2 minutes into that 10 minute drive) I note how it could be modified to get the street name for those living someplace a bit more civil. If you don't mind PM your lat/lon so I can have a test case.

> 2) It would also be nice if you stored the raw lon/lat values in a different
> set of variables - then someone could do a little math with the lon/lat
> that's configured in Indigo (and are available to AppleScripts through
> properties of the application object) to see how close the device is.

Sure that's easy enough. The great polar circle equation or whatever it's called.

I was also thinking about adding a third setting in the table to define where "Home" was and then setting A variable true/false based on that, but then I thought that could be handled in the new multi-conditional feature of 4.1 anyhow. If people thought that was useful I could add that too.

> Actually, there appears to be a bug in the script when a location isn't
> found. You get the following XML in the file returned from geonames:

All you got were those two lines? That's not even valid XML! tsktsk geonames, I'll see what I can do to handle that case better.

> when it doesn't find a match to the location passed in. When this line of
> the script is executed:
Yep, saw this error plenty of times while teaching myself how to do XML in applescript.

How do I submit updates? Just use the same form? I assume I would not have to fill it all out again for an update.

Thanks,

-Chris


I'll pm the URL to geonames. When you get an update, just email it to indigo DASH support AT perceptiveautomation DOT com with a subject of "Script Update: [name of the item in the lib]".

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Oct 03, 2009 10:54 pm
chrisla23 offline
Posts: 97
Joined: Sep 16, 2009

Updates posted

FYI the problems mentioned here should now be fixed, and it has been updated to pass on the raw lat/lon. It also will do a rudimentary calculation of distance from the lat/lon defined in Indigo as the home location, and pass that on.

-Chris

Posted on
Wed Nov 04, 2009 3:23 pm
rlust offline
Posts: 81
Joined: Jan 12, 2009
Location: Ohio

InstanMapper

I have the script installed and running but I am never getting any variables entered or updated. Any ideas on what to check?

Thanks!

Randy

Posted on
Wed Nov 04, 2009 3:43 pm
chrisla23 offline
Posts: 97
Joined: Sep 16, 2009

(No subject)

Can you run it from script editor and post or send me the event log output (be sure to switch to that tab before hitting run). Also one section may have a problem if it's run in the background vs in script editor that I'm yet to track down why.

Thanks,

-Chris

Posted on
Fri Jan 22, 2010 2:55 pm
rlust offline
Posts: 81
Joined: Jan 12, 2009
Location: Ohio

Re: Applescript for Instamapper GPS to Indigo integration.

Chris,
Have you been able to test this using snow leopard? I have been trying to get this working again with the same results.

Thanks
Randy

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest