-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
413 lines (382 loc) · 14.7 KB
/
index.html
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<!DOCTYPE html>
<html lang="en" class="h-100">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Waypoints to cylinders converter</title>
<meta
name="description"
content="Convert SeeYou CUP waypoint files into airspace cylinders for easy identification of turnpoints, meant for free-flying waypoint tag competitions."
/>
<meta name="author" content="Marco Gandi" />
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
crossorigin="anonymous"
/>
<link
rel="apple-touch-icon"
sizes="180x180"
href="/airspace-tag-converter/favicons/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/airspace-tag-converter/favicons/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/airspace-tag-converter/favicons/favicon-16x16.png"
/>
<link
rel="manifest"
href="/airspace-tag-converter/favicons/site.webmanifest"
/>
<link
rel="mask-icon"
href="/airspace-tag-converter/favicons/safari-pinned-tab.svg"
color="#5bbad5"
/>
<link
rel="shortcut icon"
href="/airspace-tag-converter/favicons/favicon.svg"
/>
<meta name="msapplication-TileColor" content="#da532c" />
<meta
name="msapplication-config"
content="/airspace-tag-converter/favicons/browserconfig.xml"
/>
<style>
@media (prefers-color-scheme: dark) {
:root {
color-scheme: dark;
--bs-body-color: #adb5bd;
--bs-body-color-rgb: 173, 181, 189;
--bs-body-bg: #212529;
--bs-body-bg-rgb: 33, 37, 41;
--bs-emphasis-color: #fff;
--bs-emphasis-color-rgb: 255, 255, 255;
--bs-secondary-color: rgba(173, 181, 189, 0.75);
--bs-secondary-color-rgb: 173, 181, 189;
--bs-secondary-bg: #343a40;
--bs-secondary-bg-rgb: 52, 58, 64;
--bs-tertiary-color: rgba(173, 181, 189, 0.5);
--bs-tertiary-color-rgb: 173, 181, 189;
--bs-tertiary-bg: #2b3035;
--bs-tertiary-bg-rgb: 43, 48, 53;
--bs-primary-text-emphasis: #6ea8fe;
--bs-secondary-text-emphasis: #a7acb1;
--bs-success-text-emphasis: #75b798;
--bs-info-text-emphasis: #6edff6;
--bs-warning-text-emphasis: #ffda6a;
--bs-danger-text-emphasis: #ea868f;
--bs-light-text-emphasis: #f8f9fa;
--bs-dark-text-emphasis: #dee2e6;
--bs-primary-bg-subtle: #031633;
--bs-secondary-bg-subtle: #161719;
--bs-success-bg-subtle: #051b11;
--bs-info-bg-subtle: #032830;
--bs-warning-bg-subtle: #332701;
--bs-danger-bg-subtle: #2c0b0e;
--bs-light-bg-subtle: #343a40;
--bs-dark-bg-subtle: #1a1d20;
--bs-primary-border-subtle: #084298;
--bs-secondary-border-subtle: #41464b;
--bs-success-border-subtle: #0f5132;
--bs-info-border-subtle: #087990;
--bs-warning-border-subtle: #997404;
--bs-danger-border-subtle: #842029;
--bs-light-border-subtle: #495057;
--bs-dark-border-subtle: #343a40;
--bs-heading-color: inherit;
--bs-link-color: #6ea8fe;
--bs-link-hover-color: #8bb9fe;
--bs-link-color-rgb: 110, 168, 254;
--bs-link-hover-color-rgb: 139, 185, 254;
--bs-code-color: #e685b5;
--bs-border-color: #495057;
--bs-border-color-translucent: rgba(255, 255, 255, 0.15);
--bs-form-valid-color: #75b798;
--bs-form-valid-border-color: #75b798;
--bs-form-invalid-color: #ea868f;
--bs-form-invalid-border-color: #ea868f;
}
}
</style>
</head>
<body class="d-flex flex-column h-100">
<div class="container flex-shrink-0 mb-5">
<div class="px-4 py-lg-5 my-5 text-center">
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
class="bi d-block mx-auto mb-4"
width="96"
height="96"
fill="currentColor"
>
<symbol class="bi bi-cloud-haze" viewBox="0 0 16 16" id="cloud-haze">
<path
d="M4 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm-3 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm2 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM13.405 4.027a5.001 5.001 0 0 0-9.499-1.004A3.5 3.5 0 1 0 3.5 10H13a3 3 0 0 0 .405-5.973zM8.5 1a4 4 0 0 1 3.976 3.555.5.5 0 0 0 .5.445H13a2 2 0 0 1 0 4H3.5a2.5 2.5 0 1 1 .605-4.926.5.5 0 0 0 .596-.329A4.002 4.002 0 0 1 8.5 1z"
/>
</symbol>
<use xlink:href="#cloud-haze" />
</svg>
<h1 class="display-5 fw-bold text-body-emphasis">
Waypoints to cylinders converter
</h1>
<div class="col-lg-6 mx-auto">
<p class="lead mb-4">
Convert SeeYou CUP waypoint files into airspace cylinders for easy
identification of turnpoints, meant for free-flying waypoint tag
competitions.
</p>
</div>
</div>
<div class="container" style="max-width: 600px">
<form class="mt-3">
<div class="mb-3">
<label for="cupFile" class="form-label">SeeYou CUP file:</label>
<input
type="file"
class="form-control"
id="cupFile"
accept=".cup"
required
/>
<div id="cupFileHelp" class="form-text">
Only the waypoints will be converted.
</div>
</div>
<div class="mb-3">
<label for="category" class="form-label">Airspace Category</label>
<input
type="text"
class="form-control"
id="category"
maxlength="5"
placeholder="F"
/>
<div id="categoryHelp" class="form-text">
Max 5 letters, default is 'F. This will change the color and
behaviour of the airspaces on your flight computer. See the
available classes of the
<a
href="http://www.winpilot.com/usersguide/userairspace.asp"
target="_blank"
>WinPilot OpenAir format</a
>.
</div>
</div>
<div class="mb-3">
<label for="radius" class="form-label">Radius in meters:</label>
<input
type="number"
class="form-control"
id="radius"
min="1"
placeholder="400"
/>
<div id="cupFileHelp" class="form-text">
Default radius is 400m.
</div>
</div>
<button
type="button"
class="btn btn-primary"
onclick="convertCUPtoOpenAir()"
>
<svg class="bi" width="16" height="16" fill="currentColor">
<use xlink:href="#cloud-haze" />
</svg>
Convert
</button>
</form>
<div id="previewArea" style="display: none">
<hr class="mt-4" />
<h2 class="mt-3">Cylinders airspace</h2>
<pre
id="openAirContent"
style="overflow: auto; max-height: 400px"
class="bg-body-tertiary border p-3"
></pre>
<button
id="downloadButton"
class="btn btn-sm btn-success"
onclick="downloadOpenAirFile()"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-cloud-arrow-down-fill"
viewBox="0 0 16 16"
>
<path
d="M8 2a5.53 5.53 0 0 0-3.594 1.342c-.766.66-1.321 1.52-1.464 2.383C1.266 6.095 0 7.555 0 9.318 0 11.366 1.708 13 3.781 13h8.906C14.502 13 16 11.57 16 9.773c0-1.636-1.242-2.969-2.834-3.194C12.923 3.999 10.69 2 8 2zm2.354 6.854-2 2a.5.5 0 0 1-.708 0l-2-2a.5.5 0 1 1 .708-.708L7.5 9.293V5.5a.5.5 0 0 1 1 0v3.793l1.146-1.147a.5.5 0 0 1 .708.708z"
/>
</svg>
Download
</button>
</div>
</div>
</div>
<footer
class="my-4 mt-auto d-flex flex-wrap justify-content-between align-items-center py-3 border-top container"
>
<div class="col-md-4 d-flex align-items-center">
<span
class="me-2 mb-md-0 text-body-secondary text-decoration-none lh-1"
>
<svg class="bi" width="16" height="16" fill="currentColor">
<use xlink:href="#cloud-haze" />
</svg>
</span>
<span class="mb-md-0 text-body-secondary"
>2023
<a
class="text-body-secondary"
href="https://marcogandi.com/"
target="_blank"
>Marco Gandi</a
></span
>
</div>
<ul class="nav col-md-4 justify-content-end list-unstyled d-flex">
<li class="ms-3">
<a
class="text-body-secondary"
href="https://github.com/elgandoz/airspace-tag-converter"
target="_blank"
title="Contribute on GitHub"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-github"
viewBox="0 0 16 16"
>
<path
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"
/>
</svg>
<span class="visually-hidden">Contribute on GitHub</span>
</a>
</li>
</ul>
</footer>
<!--
<script
src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+"
crossorigin="anonymous"
></script>
-->
<script>
function convertCoordinateToSexagesimal(coordinate) {
const direction = coordinate.slice(-1)
const minutesDec = parseFloat(coordinate.substr(-7, 6))
const minutes = Math.floor(minutesDec).toString().padStart(2, '0')
const seconds = Math.round((minutesDec - Math.floor(minutesDec)) * 60)
.toString()
.padStart(2, '0')
let length = 3
if (['N', 'S'].includes(direction)) {
length = 2
}
const degrees = coordinate.substr(0, length)
return `${degrees}:${minutes}:${seconds} ${direction}`
}
function convertMetersToNauticalMiles(meters) {
// 1 meter is approximately 0.00053996 nautical miles
return (meters * 0.00053996).toFixed(4)
}
function convertCUPtoOpenAir() {
const cupFileInput = document.getElementById('cupFile')
const openAirContent = document.getElementById('openAirContent')
const categoryInput = document.getElementById('category')
const radiusInput = document.getElementById('radius')
const downloadButton = document.getElementById('downloadButton')
const previewArea = document.getElementById('previewArea')
const cupFile = cupFileInput.files[0]
if (!cupFile) {
alert('Please select a CUP file to convert.')
return
}
const reader = new FileReader()
reader.onload = function (e) {
const cupContent = e.target.result
const cupLines = cupContent.split('\n')
let openAirContentText = ''
let inRelatedTasks = false
// Skip the first line (header)
let skipFirstLine = true
const category =
categoryInput.value.toUpperCase().substring(0, 5) || 'F'
const radius = convertMetersToNauticalMiles(radiusInput.value || 400)
for (const line of cupLines) {
if (skipFirstLine) {
skipFirstLine = false
continue
}
if (line.trim() === '-----Related Tasks-----') {
break // Exit the loop when "-----Related Tasks-----" is encountered
}
const fields = line.split(',')
if (fields.length >= 5) {
const name = fields[0].replace(/"/g, '')
const code = fields[1]
const lat = convertCoordinateToSexagesimal(fields[3])
const lon = convertCoordinateToSexagesimal(fields[4])
const airspaceName = `AN ${code} ${name}`
const center = `V X=${lat} ${lon}`
const radiusParam = `DC ${radius}` // Radius in nautical miles
openAirContentText += `AC ${category}\n${airspaceName}\nAL SFC\nAH UNL\n${center}\n${radiusParam}\n\n`
}
}
openAirContent.textContent = openAirContentText
previewArea.style.display = 'block'
}
reader.readAsText(cupFile)
}
function downloadOpenAirFile() {
const openAirContent =
document.getElementById('openAirContent').textContent
const filename =
(document
.getElementById('cupFile')
.files[0].name.replace('.cup', '') || 'airspace') + '-airspace.txt'
const blob = new Blob([openAirContent], { type: 'text/plain' })
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = filename
link.click()
}
</script>
<!-- Google tag (gtag.js) -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-7MV0SH5FYE"
></script>
<script>
window.dataLayer = window.dataLayer || []
function gtag() {
dataLayer.push(arguments)
}
gtag('js', new Date())
gtag('config', 'G-7MV0SH5FYE')
</script>
</body>
</html>