Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
lencse committed May 18, 2021
1 parent cab71f9 commit 26733a6
Showing 1 changed file with 60 additions and 60 deletions.
120 changes: 60 additions & 60 deletions src/hiking-trails/okt/index.ts
Expand Up @@ -47,67 +47,67 @@ const getLinkUrlsFromHtml = (html: string): { links: string[] } => {
}

async function load() {
// const init = 'https://www.kektura.hu/okt-es-gykt-szakaszok'
// let d: any = await httpGet(init)
// d = getLinkUrlsFromHtml(d)
// d = ((args: any): any => ({
// pathGpxUrl: findByPattern(args.links, /okt_teljes_[0-9_]+\.gpx/),
// stampGpxUrl: findByPattern(args.links, /okt_bh_[0-9_]+\.gpx/)
// }))(d)
// d = await (async (args: any): Promise<any> => ({
// pathGpx: await httpGet(args.pathGpxUrl),
// stampGpx: await httpGet(args.stampGpxUrl),
// }))(d)
// d = await (async (args: any): Promise<any> => ({
// path: (await pointsFromGpx(args.pathGpx)),
// // path: (await pointsFromGpx(args.pathGpx)).filter((p, idx) => 0 === idx % 300),
// stampingLocations: (await stampsFromGpx(args.stampGpx))
// }))(d)
// d = ((args: any): any => {
// return {
// ...args,
// stampingLocations: args.stampingLocations.map(stamp => {
// let minDistance = Infinity
// let nearestIdx = -1
// args.path.forEach((point, idx) => {
// const distance = distanceInMeters(point, stamp.point)
// if (distance < minDistance) {
// minDistance = distance
// nearestIdx = idx
// }
// })
// return {
// ...stamp,
// pointIdx: nearestIdx
// }
// })
// }
// })(d)
// d = ((args: any): any => {
// const cp = new Map<string, any>()
// args.stampingLocations.forEach((stamp) => {
// if (!cp.has(stamp.name)) {
// cp.set(stamp.name, {
// name: stamp.name,
// stampingLocations: []
// })
// }
// const c = cp.get(stamp.name)
// c.stampingLocations.push(stamp)
// })
// const result = []
// for (const i of cp.values()) {
// result.push(i)
// }
// // console.log(result[2])
// // console.log(result.filter(c => c.name === 'Sirok')[0])
// return {
// path: args.path,
// checkpoints: result
// }
// })(d)
const init = 'https://www.kektura.hu/okt-es-gykt-szakaszok'
let d: any = await httpGet(init)
d = getLinkUrlsFromHtml(d)
d = ((args: any): any => ({
pathGpxUrl: findByPattern(args.links, /okt_teljes_[0-9_]+\.gpx/),
stampGpxUrl: findByPattern(args.links, /okt_bh_[0-9_]+\.gpx/)
}))(d)
d = await (async (args: any): Promise<any> => ({
pathGpx: await httpGet(args.pathGpxUrl),
stampGpx: await httpGet(args.stampGpxUrl),
}))(d)
d = await (async (args: any): Promise<any> => ({
path: (await pointsFromGpx(args.pathGpx)),
// path: (await pointsFromGpx(args.pathGpx)).filter((p, idx) => 0 === idx % 300),
stampingLocations: (await stampsFromGpx(args.stampGpx))
}))(d)
d = ((args: any): any => {
return {
...args,
stampingLocations: args.stampingLocations.map(stamp => {
let minDistance = Infinity
let nearestIdx = -1
args.path.forEach((point, idx) => {
const distance = distanceInMeters(point, stamp.point)
if (distance < minDistance) {
minDistance = distance
nearestIdx = idx
}
})
return {
...stamp,
pointIdx: nearestIdx
}
})
}
})(d)
d = ((args: any): any => {
const cp = new Map<string, any>()
args.stampingLocations.forEach((stamp) => {
if (!cp.has(stamp.name)) {
cp.set(stamp.name, {
name: stamp.name,
stampingLocations: []
})
}
const c = cp.get(stamp.name)
c.stampingLocations.push(stamp)
})
const result = []
for (const i of cp.values()) {
result.push(i)
}
// console.log(result[2])
// console.log(result.filter(c => c.name === 'Sirok')[0])
return {
path: args.path,
checkpoints: result
}
})(d)
// writeFileSync('/tmp/x.json', JSON.stringify(d))
let d = JSON.parse(readFileSync('/tmp/x.json').toString())
// let d = JSON.parse(readFileSync('/tmp/x.json').toString())
d = ((args: any): any => {
return ({
...args,
Expand Down

0 comments on commit 26733a6

Please sign in to comment.