Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser geolocaton speed fix #217

Merged
merged 4 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion update-release-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ set -e
set -u

version=$1

# Swift
sed -i "" -E "s/(let releaseTag = \")[^\"]+(\")/\1$version\2/g" Package.swift

# Android
sed -i "" -E "s/(version = \")[^\"]+(\")/\1$version\2/g" android/build.gradle

# Rust
awk '{ if (!done && /version = \"/) { sub(/(version = \")[^\"]+(\")/, "version = \"" newVersion "\""); done=1 } print }' newVersion="$version" common/ferrostar/Cargo.toml > tmpfile && mv tmpfile common/ferrostar/Cargo.toml
cd common && cargo check && cd ..

git add Package.swift android/build.gradle common/Cargo.lock common/ferrostar/Cargo.toml
# Web components
sed -i "" -E "s/(\"version\": \")[^\"]+(\")/\1$version\2/g" web/package.json
cd web && npm install && cd ..

git add Package.swift android/build.gradle common/Cargo.lock common/ferrostar/Cargo.toml web/package.json web/package-lock.json
6 changes: 3 additions & 3 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@
}

// Initialize Ferrostar and the control buttons
if ( document.readyState === "complete" ) {
onload();
} else {
if ( document.readyState === "loading" ) {
document.addEventListener("DOMContentLoaded", onload);
} else {
onload();
}
</script>
</body>
Expand Down
5 changes: 3 additions & 2 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"Jacob Fielding <[email protected]>",
"Luke Seelenbinder <[email protected]>"
],
"version": "0.1.4",
"version": "0.9.2",
"license": "BSD-3-Clause",
"type": "module",
"main": "./dist/ferrostar-webcomponents.js",
Expand Down
12 changes: 9 additions & 3 deletions web/src/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,21 @@ export class BrowserLocationProvider {
enableHighAccuracy: true,
};

this.geolocationWatchId = navigator.geolocation.watchPosition((position) => {
this.lastLocation = {
this.geolocationWatchId = navigator.geolocation.watchPosition((position: GeolocationPosition) => {
let speed = null;
if (position.coords.speed) {
speed = {
value: position.coords.speed
}
}
this.lastLocation = {
coordinates: { lat: position.coords.latitude, lng: position.coords.longitude },
horizontalAccuracy: position.coords.accuracy,
courseOverGround: {
degrees: Math.floor(position.coords.heading || 0),
},
timestamp: position.timestamp,
speed: position.coords.speed,
speed: speed,
};

if (this.updateCallback) {
Expand Down
Loading