Skip to content

Commit

Permalink
Merge pull request #36 from r00tat/bugfix/track-recording
Browse files Browse the repository at this point in the history
Fix recording
  • Loading branch information
r00tat authored Jan 18, 2024
2 parents 7f57f4d + f8b51ab commit b2293c1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
19 changes: 19 additions & 0 deletions src/components/FirecallItems/elements/FirecallLine.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ReactNode } from 'react';
import { Line } from '../../firebase/firestore';
import { FirecallConnection } from './FirecallConnection';
import { FirecallItemBase } from './FirecallItemBase';
import { LatLngPosition } from '../../../common/geo';

export class FirecallLine extends FirecallConnection {
opacity?: number;
Expand Down Expand Up @@ -43,4 +45,21 @@ export class FirecallLine extends FirecallConnection {
opacity: this.opacity,
};
}

public body(): ReactNode {
return (
<>
{super.body()}
<br />
Positionen:
<br />
{(JSON.parse(this.positions || '[]') as LatLngPosition[]).map((p) => (
<>
{p[0].toFixed(4)},{p[1].toFixed(4)}
<br />
</>
))}
</>
);
}
}
7 changes: 5 additions & 2 deletions src/components/Map/RecordButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function RecordButton() {
distance: calculateDistance(allPos),
};
await updateFirecallItem(newRecord);
setRecordItem(newRecord);
} else {
console.warn(`tracking not possible, record id undefined`);
}
Expand Down Expand Up @@ -104,8 +105,10 @@ export default function RecordButton() {
const lastPos = positions[positions.length - 1];
const distance = position.distanceTo(toLatLng(lastPos[0], lastPos[1]));

// more than 5m or 30 seconds
if (distance > 5 || (+currentTime - +timestamp) / 1000 > 30) {
// more than 5m and > 1 sec or > 30 seconds

const timeSinceLastPos = (+currentTime - +timestamp) / 1000;
if ((distance > 5 && timeSinceLastPos > 1) || timeSinceLastPos > 30) {
map.setView(position);
setTimestamp(new Date());
addPos([lastPos[0], lastPos[1]], recordItem);
Expand Down
10 changes: 6 additions & 4 deletions src/components/pages/Layers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,16 @@ export default function LayersPage() {
Object.fromEntries(
Object.keys(layers).map((key) => [
key,
items.filter((i) => i.layer === key),
items
.filter((i) => i.layer === key)
.sort((a, b) => a.datum?.localeCompare(b.datum || '') || 0),
])
)
);

elements['default'] = items.filter(
(i) => i.layer === '' || i.layer === undefined
);
elements['default'] = items
.filter((i) => i.layer === '' || i.layer === undefined)
.sort((a, b) => a.datum?.localeCompare(b.datum || '') || 0);

return elements;
}, [items, layers]);
Expand Down

0 comments on commit b2293c1

Please sign in to comment.