################################################################################ # MacVersion = 1.0 # MacDescription = Filter your database for Caches along a Route # MacAuthor = Bushman4 # MacFileName = CachesAlongARoute.gsk # MacURL = http://gsak.net/board/index.php?showtopic=5984&view=getlastpost ################################################################################ # MSG scherm by GeoFlowers, tbv presentatie ################################################################################ Pause msg=$info VarName=$info Caches langs een gegeven route: Vertrekpunt is "Locations" (Home...) Eindpunt is een cache, een Coördinaat of Adres Een filter tot op één cache, is gelijk het eindpunt! Adres, elk geldig Google map adres Options: Find waypoints, (afstand buiten de route) .5 = 500 meter Destination Selection: Selecteer een WP uit de lijst Google Earth route staat hier: C:\GSAK\html\Directions.kml Option Explicit=Yes Declare Var=$info Type=String Declare Var=$cboWaypoints Type=String Declare Var=$DynamicFilter Type=String Declare Var=$Filter Type=String Declare Var=$frmMain Type=String Declare Var=$GetHTML Type=String Declare Var=$intLoop Type=Numeric Declare Var=$intResult Type=String Declare Var=$rbtWaypoint Type=Boolean Declare Var=$result Type=Boolean Declare Var=$strArguments Type=String Declare Var=$strBATFile Type=String Declare Var=$strCurrentCode Type=String Declare Var=$strEnd Type=String Declare Var=$strFilter Type=String Declare Var=$strHTMLFile Type=String Declare Var=$strHTMLFilePath Type=String Declare Var=$strKML Type=String Declare Var=$strKMLPath Type=String Declare Var=$strLat Type=String Declare Var=$strLon Type=String Declare Var=$strSelected Type=String Declare Var=$strStart Type=String Declare Var=$strVBSFile Type=String Declare Var=$strWaypoints Type=String Declare Var=$txtDistance Type=String GoSub Name=GetComboBox $cboWaypoints = $strSelected $rbtWaypoint = True $txtDistance = ".5" If ShowForm($frmMain) If $btnOK # Continue If $rbtWayPoint $result = Seek(AllTrim(Extract($cboWaypoints, "-", 1))) $strEnd = "&daddr=" + allTrim($d_Latitude) + "," + allTrim($d_Longitude) Table Active=Waypoints Scope=Parent While Not($_EOL) If $d_cType="Parking Area" $strEnd = "&daddr=" + allTrim($d_cLat) + "," + allTrim($d_cLon) EndIf Goto Position=Next EndWhile Table Active=Caches EndIf If $rbtCoordinates $strEnd = "&daddr=" + Replace(" ", "+", allTrim($txtLat), True) + "," + Replace(" ", "+", allTrim($txtLon), True) EndIf If $rbtAddress $strEnd = "&daddr=" + Replace(" ", "+", allTrim($txtAddress), True) EndIf Else Cancel Msg="Macro Cancelled" EndIf EndIf $strHTMLFilePath = $_Install + "\html" $strHTMLFile= $strHTMLFilePath + "\Directions.kml" $strStart = "&saddr=" + allTrim(Sysinfo("gsakini;LastCenter;Lat")) + "," + allTrim(Sysinfo("gsakini;LastCenter;Lon")) $strKMLPath = "http://maps.google.com/maps?f=d&hl=en$strStart$strEnd&output=kml" If NOT(FolderExists($strHTMLFilePath)) $strBATFile = $_Install + "\babel.bat" $intResult = PutFile($strBATFile, "MD " + quote($strHTMLFilePath)) FileOpen File="$strBATFile" Wait=yes EndIf $intResult = PutFile($strHTMLFilePath + "\GetHTML.vbs", MimeDecode($GetHTML)) # Use external VBS file to get the KML file ShowStatus msg="Getting online KML file, please wait..." Width=350 $strVBSFile = Quote($strHTMLFilePath + "\GetHTML.vbs") $strArguments = Quote($strKMLPath) + " " + Quote($strHTMLFile) RunPgm pgm=$strVBSFile parms=$strArguments wait=yes ShowStatus msg="Parsing the KML File, please wait..." Width=350 # Get the file $strKML = GetFile($strHTMLFile) #Strip out the extra crap $strKML = Extract($strKML, "", 2) $strKML = Extract($strKML, "", 2) $strKML = Extract($strKML, "", 1) $intLoop = 1 $strFilter = "" While $intLoop <= RegExCount(" ", $strKML) + 1 $strLat = AllTrim(Extract(Extract($strKML, " ", $intLoop) , ",", 2)) $strLon = AllTrim(Extract(Extract($strKML, " ", $intLoop) , ",", 1)) If $strLat <> "" and $strLon <> "" $strFilter = $strFilter + "~" + $strLat + "," + $strLon EndIf $intLoop = $intLoop + 1 EndWhile $DynamicFilter = Replace("DynamicArcFilter", "$strFilter", $Filter, True) $DynamicFilter = Replace("DynamicDistance", "$txtDistance", $DynamicFilter, True) ShowStatus msg="Applying filter, please wait..." Width=350 MacroSet Dialog=Filter VarName=$DynamicFilter Filter Name= ShowStatus Msg="Done" Display=off BeginSub Name=GetComboBox ShowStatus msg="Building Waypoint List, please wait..." Width=350 $strWaypoints = "" $strCurrentCode = $d_Code Goto Position=Top While Not($_EOL) $strWaypoints = $strWaypoints + $d_Code + " - " + $d_Name + ";" If $strCurrentCode = $d_Code $strSelected = $d_Code + " - " + $d_Name EndIf Goto Position=Next EndWhile $result = Seek($strCurrentCode) EndSub Varname=$frmMain #******************************************************************** # Form generated by GSAK form designer on Wed 15-Aug-2007 08:33:45 #******************************************************************** Name = frmMain type = form height = 244 width = 489 caption = Caches Along A Route Options Name = Lbl18 type = Label left = 8 top = 16 height = 13 width = 222 Caption = Find Waypoints that are this far from your route: container = fmMacro_2 Name = btnOK type = Button left = 388 top = 12 height = 25 width = 75 Caption = OK enter = yes container = fmMacro_2 Name = btnCancel type = Button left = 390 top = 58 height = 25 width = 75 caption = Cancel escape = no container = fmMacro_2 Name = txtDistance type = Edit left = 233 top = 13 height = 21 width = 121 container = fmMacro_2 Name = Grp19 type = GroupBox left = 19 top = 53 height = 143 width = 355 caption = Destination Selection container = fmMacro_2 Name = Lbl23 type = Label left = 31 top = 33 height = 13 width = 58 container = Grp19 caption = A Waypoint: Name = Lbl24 type = Label left = 31 top = 63 height = 13 width = 85 container = Grp19 caption = A Coordinate Pair: Name = Lbl25 type = Label left = 31 top = 113 height = 13 width = 57 container = Grp19 caption = An Address: Name = rbtWaypoint type = RadioButton left = 14 top = 32 height = 17 width = 15 container = Grp19 Name = rbtCoordinates type = RadioButton left = 14 top = 62 height = 17 width = 15 container = Grp19 Name = rbtAddress type = RadioButton left = 14 top = 112 height = 17 width = 15 container = Grp19 Name = cboWaypoints type = ComboBox left = 94 top = 30 height = 21 width = 247 container = Grp19 values = $strWaypoints Name = txtLat type = Edit left = 119 top = 60 height = 21 width = 147 container = Grp19 Name = txtAddress type = Edit left = 92 top = 109 height = 21 width = 249 container = Grp19 Name = Lbl30 type = Label left = 271 top = 63 height = 13 width = 59 container = Grp19 Caption = Latitude Name = Lbl31 type = Label left = 271 top = 87 height = 13 width = 62 container = Grp19 Caption = Longitude Name = txtLon type = Edit left = 119 top = 83 height = 21 width = 148 container = Grp19 VarName=$Filter edtArcDistance=DynamicDistance chkArcExclude=False rbtArc=True rbtPoly=False rbtPoint=False rbtReplace=True rbtAppend=False ArcFilter=DynamicArcFilter VarName=$GetHTML JyBWQlMgZmlsZSB0byBnZXQgdGhlIHNvdXJjZSBodG1sIG9mIGEgd2ViIHBhZ2UNCicgDQonIFRha2Vz IHR3byBjb21tYW5kIGxpbmUgcGFyYW1ldGVyczoNCicgRmlyc3QgaXMgdGhlIGZ1bGwgVVJMIG9mIHRo ZSBwYWdlIHRvIGdldA0KJyBTZWNvbmQgaXMgdGhlIGZ1bGwgcGF0aCB0byB0aGUgZmlsZSB0byBzdG9y ZSBpdCBpbg0KJyBUaGF0J3MgaXQgLSBubyBmcmlsbHMuDQonIEZyZWUgZm9yIHVzZSB1bmRlciBHTlUg R1BMDQonIExpZ251bWFxdWENCicgNC0yOS0wNyBWMC4xIEINCg0KDQoNCg0KU2V0IG9iakFyZ3MgPSBX U2NyaXB0LkFyZ3VtZW50cw0KcmVxdWlyZWRVUkwgPSBvYmpBcmdzKDApDQpyZXF1aXJlZEZpbGUgPSBv YmpBcmdzKDEpDQoNCkNhbGwgR2V0SFRNTCAocmVxdWlyZWRVUkwscmVxdWlyZWRGaWxlKQ0KDQonLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQ0KDQoNCkZ1bmN0aW9uIEdldEhUTUwoZmls ZVVSTCxoZExvY2F0aW9uKQ0KJ2Nvbm5lY3QgdG8gYSBVUkwgYW5kIGRvd25sb2FkcyB0aGUgZmlsZQ0K DQoJU2V0IHhtbEhUVFAgPSBDcmVhdGVPYmplY3QoIk1TWE1MMi5TZXJ2ZXJYTUxIVFRQIikNCg0KCQl4 bWxIVFRQLm9wZW4gIkdFVCIsIGZpbGVVUkwsIGZhbHN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