AutoHotkey Community

It is currently May 25th, 2012, 11:04 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: July 12th, 2007, 1:17 pm 
Offline

Joined: January 27th, 2007, 8:24 pm
Posts: 30
Location: Canada
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 !


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2007, 2:29 pm 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 13th, 2007, 5:42 am 
Offline

Joined: January 27th, 2007, 8:24 pm
Posts: 30
Location: Canada
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..


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], mrhobbeys, snyder, Yahoo [Bot] and 64 guests


You can post new topics in this forum
You can 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:
Powered by phpBB® Forum Software © phpBB Group