AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with google earth overlay script

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Dave72



Joined: 27 Jan 2007
Posts: 30
Location: Canada

PostPosted: Thu Jul 12, 2007 12:17 pm    Post subject: Help with google earth overlay script Reply with quote

I have an ahk script that finds a url to a weather radar gif file, and downloads it to make it available to a .kml file for useage as an overlay in Google Earth.

The image of the gif file changes periodically, (as does the gif url, but Ive got that part solved..), but Im stumped as to how to refresh the data without running the ahk in a full-time loop.

Google Earth itself can reread the image indexed by the kml file on a periodic basis, or you can set the refresh period inside of the kml file itself. If I was to have my ahk script loop-remake the image every nn minutes, then the google earth refresh would work fine, but does this mean I need to make my .ahk run full-time (waiting for google earth to start up, then start refreshing the gif even though I might have that radar image/kml file checkbox turned "off" inside of google earth ???

Turning the kml/image on and off doesnt seem to affect the FileAccess "A" variable..

I suppose this post might be more applicable in a google earth forum.. since i appear to be asking how to run and stop an external file (the ahk or compiled exe) via google earth.. but maybe someone here has played with google earth ? There is a google earth com api , but its completely over my head !
Back to top
View user's profile Send private message
ManaUser



Joined: 24 May 2007
Posts: 1121

PostPosted: Thu Jul 12, 2007 1:29 pm    Post subject: Reply with quote

Personally, I can think of alot of good reasons to keep one autohotkey script running all the time. You don't need a whole script dedicated to that task. If you've got the script doing other useful things for you, that makes it easier to justify the overhead.
Back to top
View user's profile Send private message
Dave72



Joined: 27 Jan 2007
Posts: 30
Location: Canada

PostPosted: Fri Jul 13, 2007 4:42 am    Post subject: Reply with quote

Thats a good thought, ManaUser...

Make one script that can auto-watch running tasks (or has right click taskbar controls) that covers all the other scripts you might want to run.

I have a good working radar overlay now.. i had to mess around some to get transparencies into the radar image, but considering the lack of Canadian radar overlays for google earth.. im happy.

FWIW, if anyone is barking up this path.. heres the steps..

Of course you need Google Earth.
In googleearth options, find the option to change your lat/long to decimal degrees.
Get a free app called EarthPlot , to help you make the kml file for Google Earth.
Get the old dos util called Gifsicle (will be used to mask the transparency channels in the radar image gif)

Use this code..


Code:
#singleinstance
#noenv
;
TheBeginning:
Station= xni
RadarHTTPsite = http://www.weatheroffice.gc.ca/radar/index_e.html?id=%station%
RootRadarSite = http://www.weatheroffice.gc.ca
SearchBlock = image.php?base=/data/radar/temp_image
URLDownloadToFile, %RadarHTTPSite%, radarhttp.html
FileRead, html, radarhttp.html
StringGetPos, blockfoundat, html, %SearchBlock%
EnvAdd, blockfoundat, 16
StringMid, imagename, html, %blockfoundat%, 63
RadarURL = %RootRadarSite%%imagename%
URLDownloadToFile,%RadarURL%, Radar.gif
Run "gifsicle.exe" --change-color #333366 #999966 -o radar2.gif radar.gif,,Hide
Sleep, 500
Run "gifsicle.exe" -t #999966 -o radar.gif radar2.gif,,Hide
Sleep,300000
Goto, TheBeginning


but remark out the 2 "Run" commands for now, and also put your own Station = id in it (for the Environment Canada sites, when you 'zoom' into your own radar, the id will be in your addressbar of the browser)

Run that script once, and you should have the radar.gif image for your location. Start up Google Earth, then start up EarthPlot. Load the image into EarthPlot (Raster) , and transfer it to GoogleEarth via the icon.

Now you need to align the 2 images, hopefully you have some lakes or features that you can use.. You need to align the N,S,E,W borders . Find your imported image in the GE list (should be under Temporary Places ) right click and edit.. and you have stretch/zoom etc control box (green lines)

Once you have it aligned, click the Advanced checkbox in GE, and it will show you the NSEW values.. copy these over to EarthPlot.. and then make Earthplot 'export to KML'

You can view/edit the KML with notepad/etc... mine ended up looking like this..

Code:
<kml xmlns="http://earth.google.com/kml/2.0">
  <Folder>
    <name>Thunder Bay Radar</name>
    <visibility>1</visibility>
    <open>0</open>
    <GroundOverlay>
      <name>Image</name>
      <visibility>1</visibility>
      <drawOrder>0</drawOrder>
      <color>FFffffff</color>
      <Icon>
        <href>Radar.gif</href>
      </Icon>
      <LatLonBox>
        <rotation>0</rotation>
        <west>-92.412119</west>
        <east>-84.493534</east>
        <south>46.697112</south>
        <north>51.024428</north>
      </LatLonBox>
    </GroundOverlay>
  </Folder>
</kml>


Now, save the new kml into GE, and edit for a refresh of 10 mins or so.
Make sure you installed the Gifsicle in the same folder as your ahk script, uncomment the Run lines in the ahk , and you should be good to go. The ahk script above is set to 5 min refreshing.. adjust as you see fit.

At least.. I *think* thats how this all went down.. its been a strange trip indeed.. lol

You can check out the Gifsicle docs (run in command/window to get help) if you want to further mask the outline box etc etc)

Open to comments..
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group