Skip to content

Instantly share code, notes, and snippets.

View 330k's full-sized avatar

330k 330k

View GitHub Profile
Routes.activeMap.activeRoute.flattenBridgesAndTunnels =
function() {
var e, t, n = !1, r = Routes.activeMap.activeRoute.trackPoints(), o = r.length;
r.some((function(e) {
return !(Number.isFinite(e.distance) && Number.isFinite(e.ele))
}
)) || r.forEach((function(i, a) {
if (!i.flattened)
if (i.roadEnv && !n)
for (n = !0,
function garmin(lat1, lon1, lat2, lon2) {
-180 == lon1 && (lon1 = 180);
var e;
var o;
var r;
var n;
var a;
var s;
var h = lat1 * Math.PI / 180;
var u = lon1 * Math.PI / 180;
// BRM名
console.log([...document.querySelectorAll("h3")].filter(e=>e.textContent.match(/BRM\d+.+/)).map(e=>e.textContent.replace(/・.*$/,"")).join("\n"))
// 距離
console.log([...document.querySelectorAll("h3")].filter(e=>e.textContent.match(/BRM\d+.+/)).map(e=>e.textContent.replace(/.*?(\d+)km.*$/,"$1")).join("\n"))
// BRM開催日時
console.log([...document.querySelectorAll("h3")].filter(e=>e.textContent.match(/BRM\d+.+/)).map(e=>e.textContent.replace(/BRM(\d+)(\d\d).*$/,"2023/$1/$2")).join("\n"))
// エントリー期間
/**
* 通れた道マップ(https://www.toyota.co.jp/jpn/auto/passable_route/map/)にGPXファイルをロードする機能を追加
*/
(function(){
const readXML = function(file){
return new Promise(function(resolve, reject){
try{
const reader = new FileReader();
const parser = new DOMParser();
@330k
330k / gsi_distance.js
Last active March 17, 2022 17:38
Geodesic Distance calculation function in JavaScript from 国土地理院(https://vldb.gsi.go.jp/sokuchi/surveycalc/surveycalc/algorithm/bl2st/bl2st.htm)
function gsidistance(lat1, lon1, lat2, lon2){
"use strict";
const a = 6378137.0;
const f = 1 / 298.257223563;
const MAX_ITERATION = 200;
const abs = Math.abs;
const sqrt = Math.sqrt;
const sin = Math.sin;
const cos = Math.cos;
@330k
330k / hubeny_series.js
Last active March 14, 2022 18:51
Geodesic Distance calculation functions of Hubeny formula 1st - 4th order
function hubeny1(lat1, lon1, lat2, lon2){
"use strict";
const a = 6378137.0;
const f = 1 / 298.257223563;
const e2 = f * (2 - f);
const e2p = e2 / (1 - e2);
const degree = Math.PI / 180.0;
const sin = Math.sin;
const cos = Math.cos;
const tan = Math.tan;
@330k
330k / vincenty.js
Last active March 18, 2022 03:00
Calculate Geodesic Distance with Vincenty(1975) method in JavaScript
/**
* Vincenty75 測地線距離計算式
* @param {number} lat1
* @param {number} lon1
* @param {number} lat2
* @param {number} lon2
* @return {number} distance [m]
*/
function vincenty(lat1, lon1, lat2, lon2){
"use strict";
@330k
330k / hubeny_full.js
Last active March 14, 2022 18:15
Calculate Geodesic Distance with Hubeny Full Formula in JavaScript
/**
* Hubeny測地線距離計算式(標準)
* https://amano-tec.com/apps/paceruler.html
* @param {number} lat1
* @param {number} lon1
* @param {number} lat2
* @param {number} lon2
* @return {number} distance [m]
*/
function hubeny(lat1, lon1, lat2, lon2){
/**
* L1, L2の2層のキャッシュ
* @param {string} cache_name Cache APIで使用する名前(cacheName)
* @param {function} parser responseを受け取ってキャッシュに保存する内容を返すコールバック関数(async function可)
* @param {number} l1_cache_size L1キャッシュに保持するURL件数
* @param {number} l2_cache_expiration L2キャッシュの有効期限
*/
function LayeredCache(cache_name, parser, l1_cache_size = 1000, cache_expiration = 30 * 86400 * 1000){
const HEADER_EXPIRATION = "_expire_on";
const l1_cache = [];
var map = Routes.activeMap, route = map.activeRoute, trackpoints = route.trackPoints(), update = () => {
if(trackpoints.length === trackpoints.filter((e)=>(e.roadEnv!==undefined)).length){
route.rebuildBounds();
route.flattenBridgesAndTunnels();
route.calculateMetrics();
map.loadElevationProfile();
console.log("完了");
}else{
setTimeout(update, 1000);
}