UNPKG

@gooin/fit2spatial

Version:

Convert Garmin FIT files to GeoJSON, SHP, KML, GPX

33 lines (32 loc) 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fit2shp = exports.fit2geojson = void 0; const file_1 = require("./file"); const geojson_1 = require("./geojson"); const shp_1 = require("./shp"); const fit2geojson = async (input, output) => { // console.log(`${input} is a FIT file`) const event = await (0, file_1.parseFitFile)(input); if (!event) { console.warn(`[${input}] does not contain any GPS data. skipping`); return; } const outputPath = output; // const fileName = getFitFileName(input) (0, geojson_1.eventToGeoJSON)(event, outputPath); console.log(`[${input}] converted to GeoJSON file: [${outputPath}]`); }; exports.fit2geojson = fit2geojson; const fit2shp = async (input, output) => { const event = await (0, file_1.parseFitFile)(input); if (!event) { console.warn(`[${input}] does not contain any GPS data. skipping`); return; } const outputPath = output; // console.log('fit2shp - outputPath:', outputPath) await (0, shp_1.eventToSHP)(event, outputPath); await (0, file_1.extractZipFile)(outputPath); console.log(`[${input}] converted to SHP file: [${outputPath}]`); }; exports.fit2shp = fit2shp;