View unanswered posts | View active topics It is currently Sat May 25, 2013 12:26 am



Reply to topic  [ 10 posts ] 
 Applescript for Instamapper GPS to Indigo integration. 
Author Message

Joined: Sep 16, 2009
Posts: 95
Post 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


Thu Oct 01, 2009 11:44 am
Profile

Joined: Jul 09, 2009
Posts: 270
Location: SW Florida
Post 
Very cool!

Looking forward to seeing details when posted.


Thu Oct 01, 2009 1:01 pm
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6665
Location: Austin, Texas
Post 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)
Image


Thu Oct 01, 2009 1:59 pm
Profile WWW
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6665
Location: Austin, Texas
Post 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)
Image


Thu Oct 01, 2009 2:22 pm
Profile WWW

Joined: Sep 16, 2009
Posts: 95
Post 
> 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


Thu Oct 01, 2009 2:46 pm
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6665
Location: Austin, Texas
Post 
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)
Image


Thu Oct 01, 2009 3:23 pm
Profile WWW

Joined: Sep 16, 2009
Posts: 95
Post 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


Sat Oct 03, 2009 10:54 pm
Profile

Joined: Jan 12, 2009
Posts: 27
Location: Ohio
Post 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


Wed Nov 04, 2009 3:23 pm
Profile

Joined: Sep 16, 2009
Posts: 95
Post 
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


Wed Nov 04, 2009 3:43 pm
Profile

Joined: Jan 12, 2009
Posts: 27
Location: Ohio
Post 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


Fri Jan 22, 2010 2:55 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: Google Feedfetcher, Juju and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.