49fbb37 ←b5dbccbantonApr 18, 2026 api

edit generate-map.js via macOS

M /anton/undefined +42 -0
M /anton/undefined +42 -0
235 unmodified lines
236function isFlightMode(mode) {
237 return mode.toLowerCase().startsWith('flight')
238}
239
240// great circle interpolation for antimeridian-crossing flights
241// returns a point at the given fraction (0-1) along the great circle from→to
242function interpolateGreatCircle(from, to, fraction) {
243 var toRad = Math.PI / 180
244 var toDeg = 180 / Math.PI
245 var lat1 = from[1] * toRad, lon1 = from[0] * toRad
246 var lat2 = to[1] * toRad, lon2 = to[0] * toRad
247
248 var d = 2 * Math.asin(Math.sqrt(
249 Math.pow(Math.sin((lat1 - lat2) / 2), 2) +
250 Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin((lon1 - lon2) / 2), 2)
251 ))
252 if (d < 1e-10) return from.slice()
253
254 var A = Math.sin((1 - fraction) * d) / Math.sin(d)
255 var B = Math.sin(fraction * d) / Math.sin(d)
256 var x = A * Math.cos(lat1) * Math.cos(lon1) + B * Math.cos(lat2) * Math.cos(lon2)
257 var y = A * Math.cos(lat1) * Math.sin(lon1) + B * Math.cos(lat2) * Math.sin(lon2)
258 var z = A * Math.sin(lat1) + B * Math.sin(lat2)
259
260 return [
261 Math.atan2(y, x) * toDeg,
262 Math.atan2(z, Math.sqrt(x * x + y * y)) * toDeg,
263 ]
264}
265
266// for flights crossing the antimeridian (|lon diff| > 180), compute waypoints
267// so each sub-arc stays under 180° longitude — renderer draws them correctly
268function flightCoordinates(fromCoord, toCoord) {
269 if (Math.abs(fromCoord[0] - toCoord[0]) <= 180) {
270 return [fromCoord, toCoord]
271 }
272 // 3 intermediate points at 0.25, 0.5, 0.75 → 4 sub-arcs, each ~30-45° max
273 return [
274 fromCoord,
275 interpolateGreatCircle(fromCoord, toCoord, 0.25),
276 interpolateGreatCircle(fromCoord, toCoord, 0.5),
277 interpolateGreatCircle(fromCoord, toCoord, 0.75),
278 toCoord,
279 ]
280}
281
282// country tag → center coordinates + display name
283const COUNTRY_CENTERS = {
284 'albania': { name: 'Albania', iso: 'AL', center: [20.17, 41.15] },
285 'argentina': { name: 'Argentina', iso: 'AR', center: [-63.62, -38.42] },
358 unmodified lines