Skip to content

Commit

Permalink
Added program parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ToninoTarsi committed Nov 20, 2013
1 parent 85f1ab0 commit 9ddf4a4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 22 deletions.
38 changes: 24 additions & 14 deletions TaskToKmz.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@


inIGCDir = "./igc"
outFile = "./task.kml"
outFile = "./task1.kml"
taskName = "Task"
modelscale = "5"
startTime = "1230" # or use "none"
startTime = "1214" # or use "none" remenber this is UTC
endTime = "1800"
crateFlyForAllPilots = True
pilots2follow = ["CHRISTIAN CIECH","ALESSANDRO PLONER","EDOARDO GIUDICEANDREA"] # Ingnored if crateFlyForAllPilots
Expand All @@ -28,13 +28,14 @@
min_distance = 1500
max_distance = 2500
split_tout_time = 1
heigth_offset = 50
heigth_offset = 0

################################# Do not modify below #####################################


def isAfterStart(theTime,startTime):
r = ( int(theTime[0:2])*60+int(theTime[3:4]) ) - ( int(startTime[0:2])*60+int(startTime[3:4]) )
#print theTime,startTime,theTime[0:2],theTime[2:4]
r = ( int(theTime[0:2])*60+int(theTime[2:4]) ) - ( int(startTime[0:2])*60+int(startTime[2:4]) )
if ( r >= 0):
return True
else:
Expand Down Expand Up @@ -181,7 +182,11 @@ def GetPoints(self):
i = 0
for pilot in listigc:
print pilot.PilotName


points = pilot.GetPoints()
if ( len(points) == 0) :
continue

template = string.Template("""<Placemark>
<name>$pilotName</name>
<styleUrl>#style$i</styleUrl>
Expand All @@ -194,7 +199,6 @@ def GetPoints(self):
outfo.write(""" <gx:Track>
<altitudeMode>absolute</altitudeMode>""")

points = pilot.GetPoints()
for point in points:
when = " <when>20"+pilot.year+"-"+pilot.month+"-"+pilot.day+"T"+point.t[0:2]+":"+point.t[2:4]+":"+point.t[4:6]+"Z</when>"
outfo.write(when+"\n")
Expand Down Expand Up @@ -232,12 +236,14 @@ def GetPoints(self):
</Placemark>
""")


d = dict(s=modelscale)
d.update(x=points[0].x)
d.update(y=points[0].y)
d.update(h=points[0].h)
outfo.write(template.safe_substitute(d))
try:
d = dict(s=modelscale)
d.update(x=points[0].x)
d.update(y=points[0].y)
d.update(h=points[0].h)
outfo.write(template.safe_substitute(d))
except:
print len(points)

i = i + 1

Expand All @@ -251,14 +257,18 @@ def GetPoints(self):

# ######################### Create tour

for pilot in listigc:
for pilot in listigc:

points = pilot.GetPoints()
if ( len(points) == 0) :
continue

if pilot.PilotName in pilots2follow or crateFlyForAllPilots :
print "Creating tour for" + pilot.PilotName
outfo.write("""<gx:Tour>
<name>"""+pilot.PilotName+"""</name>
<gx:Playlist>""")

points = pilot.GetPoints()
i = 0
hp = 0
heading = random.randint(0, 360)
Expand Down
26 changes: 18 additions & 8 deletions ViewTask.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>Trofeo Monte Cucco 2013 - Task 1</title>
<title>TaskToKmz</title>

<style>
.ajax_loader {background: url("img/spinner_squares_circle.gif") no-repeat bottom center transparent;width:100%;height:100%;}
Expand All @@ -22,19 +22,29 @@
<script id="loader" src="js/ajax-loader.js" type="text/javascript"></script>

<script type="text/javascript">

$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
$(function(){
box1 = new ajaxLoader($("#controls"));
});
</script>


<script type="text/javascript">

$(function(){
box1 = new ajaxLoader($("#controls"));
});



var href = 'http://www.vololiberomontecucco.it/docs/trofeo2013/task1.kmz';

var href = $.urlParam('kmz'); // name
var namearr = href.split("/");
name = namearr[namearr.length -1 ]
document.title = name.split(".")[0];
// if ( href == null ) {
// alert("kmz not defined. Usage : ViewTask.html?kmz=fullurl.kmz");
// return;
// }
//var href = 'http://www.vololiberomontecucco.it/TaskToKmz/trofeo2013_task1.kmz';
//var href = 'http://www.vololiberomontecucco.it/docs/05082013.kmz';

var box1;
Expand Down

0 comments on commit 9ddf4a4

Please sign in to comment.