-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTMS.py
More file actions
240 lines (165 loc) · 5.6 KB
/
TMS.py
File metadata and controls
240 lines (165 loc) · 5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import csv
from gpxpy import geo
import random
GPSpointsFile=open('TMS.txt','r')
GPSPoints=csv.reader(GPSpointsFile)
GPSPoints=list(GPSPoints)
COLORS = ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#00FFFF', '#FF00FF', '#800000', '#008000', '#000080', '#808000', '#008080', '#800080']
i=0
fo = open('Test.html', 'w')
Header="""<!DOCTYPE html>
<html>
<head>
<title>Texas Motor Speedway Simulator Control lines</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 90%;
}
#current{
height: 10%;
}
</style>
</head>
<body>
<div id="map"></div>
<div id="current"></div>
<div id="List"></div>
<script>
var A= [];
var B=[];
var C=[];
function initMap() {
var myLatlng = {lat: 33.036998, lng: -97.281323};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 17,
center: myLatlng,
mapTypeId: 'satellite'
});
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
draggable: true,
title: 'Click to zoom'
});
google.maps.event.addListener(marker, 'dragend', function (evt) {
document.getElementById('current').innerHTML = '<p>Marker dropped: Current Lat: ' + evt.latLng.lat().toFixed(8) + ' Current Lng: ' + evt.latLng.lng().toFixed(8) + '</p>';
});
google.maps.event.addListener(marker, 'click', function (evt) {
for (j = 0; j < locations.length; j++) {
for (j = 0; j < locations.length; j++) {
E=A[j].getPosition();
F=B[j].getPosition();
G=E.lat().toFixed(8) +', '+ E.lng().toFixed(8) + ', ' + F.lat().toFixed(8) + ', ' + F.lng().toFixed(8) +'<br>' ;
C.push(G);
}
document.getElementById('current').innerHTML = C;
}
});
"""
fo.write(Header)
LocationDec="var locations = ["
fo.write(LocationDec)
i=0
while i < len(GPSPoints):
Locations = "[%s,%s,%s,%s]," %(GPSPoints[i][0],GPSPoints[i][1],GPSPoints[i][2],GPSPoints[i][3])
fo.write(Locations)
i+=1
fo.write('];')
Footer = """
var marker, controlline, poly, poly1, i, j;
for (i = 0; i < locations.length; i++) {
var markerA = makemarker(locations[i][0], locations[i][1],'A',i, map);
A.push(markerA);
var markerB = makemarker(locations[i][2], locations[i][3],'B',i, map);
B.push(markerB);
}
for (j = 0; j < locations.length; j++) {
var flightPath = new google.maps.Polyline({
path: [new google.maps.LatLng(locations[j][0], locations[j][1]),new google.maps.LatLng(locations[j][2], locations[j][3])],
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
};
var controlpoint={
start:{
center: {lat:33.03490233 , lng: -97.28442632},
radius: 50
},
lappoint:{
center: {lat: 33.03880806, lng: -97.28352778},
radius: 25
},
trappoint:{
center: {lat:33.03790 , lng: -97.28286},
radius: 20
},
driverchange:{
center: {lat:33.03769055, lng: -97.28342853},
radius: 20
},
garage:{
center: {lat:33.03759161, lng:-97.28215985 },
radius: 50
}
};
for (var point in controlpoint) {
// Add the circle for this city to the map.
var controlcirc = new google.maps.Circle({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
map: map,
center: controlpoint[point].center,
radius: controlpoint[point].radius
});
}
}
function makemarker(Lat, Lng,tag, i, map){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(Lat,Lng),
map: map,
draggable: true,
label: tag,
title: String(i)
});
google.maps.event.addListener(marker, 'dragend', function (evt) {
document.getElementById('current').innerHTML = '<p>Marker: ' + marker.title + '<br> Current Lat: ' + evt.latLng.lat().toFixed(8) + ' Current Lng: ' + evt.latLng.lng().toFixed(8) + '</p>';
updatemarker(marker, evt);
});
google.maps.event.addListener(marker, 'click', function (evt) {
document.getElementById('current').innerHTML = '<p>Marker: ' + marker.title + '<br>Current Lat: ' + evt.latLng.lat().toFixed(8) + ' Current Lng: ' + evt.latLng.lng().toFixed(8) + '</p>';
});
return marker;
}
function updatemarker(marker, evt){
var markernumber=parseInt(marker.title);
var markertype=marker.label;
if(markertype =='A')
{
A[markernumber].setPosition(evt.latlng());
};
if(markertype == 'B'){
B[markernumber].setPosition(evt.latlng());
};
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCZBP_xUomSDxJ207tr-pzGq_lGKN6ZMm8&callback=initMap">
</script>
</body>
</html>
"""
fo.write(Footer)
fo.close()