Skip to content

Commit

Permalink
fix: Rename heartRates coordinate property to heart (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
RalucaNicola authored Apr 27, 2021
1 parent b621100 commit 8fc03f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/gpx.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function coordPair(x) {
];
const ele = get1(x, "ele");
// handle namespaced attribute in browser
const heartRate = get1(x, "gpxtpx:hr") || get1(x, "hr");
const heart = get1(x, "gpxtpx:hr") || get1(x, "hr");
const time = get1(x, "time");
let e;
if (ele) {
Expand All @@ -84,8 +84,8 @@ function coordPair(x) {
extendedValues: [],
};

if (heartRate) {
result.extendedValues.push(["heartRate", parseFloat(nodeVal(heartRate))]);
if (heart) {
result.extendedValues.push(["heart", parseFloat(nodeVal(heart))]);
}

const extensions = get1(x, "extensions");
Expand Down Expand Up @@ -129,7 +129,7 @@ function getPoints(node, pointname) {
if (c.time) times.push(c.time);
for (let j = 0; j < c.extendedValues.length; j++) {
const [name, val] = c.extendedValues[j];
const plural = name + "s";
const plural = name === "heart" ? name : name + "s";
if (!extendedValues[plural]) {
extendedValues[plural] = Array(pts.length).fill(null);
}
Expand Down Expand Up @@ -179,7 +179,7 @@ function getTrack(node) {
track.push(line.line);
for (const [name, val] of Object.entries(line.extendedValues)) {
let props = properties;
if (name === "heartRates") {
if (name === "heart") {
if (!properties.coordinateProperties) {
properties.coordinateProperties = {};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/tcx.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function getLap(node) {
: {},
heartRates.length
? {
heartRates: track.length === 1 ? heartRates[0] : heartRates,
heart: track.length === 1 ? heartRates[0] : heartRates,
}
: {}
);
Expand Down
8 changes: 4 additions & 4 deletions tap-snapshots/test-index.test.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13245,7 +13245,7 @@ Object {
"properties": Object {
"_gpxType": "trk",
"coordinateProperties": Object {
"heartRates": Array [
"heart": Array [
Array [
null,
null,
Expand Down Expand Up @@ -17971,7 +17971,7 @@ Object {
"properties": Object {
"_gpxType": "trk",
"coordinateProperties": Object {
"heartRates": Array [
"heart": Array [
130,
134,
139,
Expand Down Expand Up @@ -18620,7 +18620,7 @@ Object {
"properties": Object {
"_gpxType": "trk",
"coordinateProperties": Object {
"heartRates": Array [
"heart": Array [
111,
111,
111,
Expand Down Expand Up @@ -23356,7 +23356,7 @@ Object {
},
"properties": Object {
"coordinateProperties": Object {
"heartRates": Array [
"heart": Array [
121,
122,
123,
Expand Down

0 comments on commit 8fc03f2

Please sign in to comment.