Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Handle lack of positioning data better
Browse files Browse the repository at this point in the history
Closes #6.
  • Loading branch information
otsaloma committed Jan 3, 2016
1 parent bb48be5 commit d2848ed
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 10 deletions.
3 changes: 1 addition & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Poor Maps 0.22
* [x] Add begin, pause and clear navigation buttons to the maneuver list page
* [x] Have begin navigation turn on auto-rotate
* [x] Bump font sizes of the scalebar and meters
* [ ] Handle lack of positioning data better (#6)
- Navigate, Nearby venues, Share current position
* [x] Handle lack of positioning data better (#6)
* [x] Update Sputnik tile source definition and add Sputnik @2x tiles

Poor Maps 1.0
Expand Down
23 changes: 17 additions & 6 deletions qml/MenuPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,23 @@ Page {
height: Theme.itemSizeSmall
text: "Share current position"
}
onClicked: app.pageStack.push("SharePage.qml", {
"coordinate": QtPositioning.coordinate(
gps.position.coordinate.latitude,
gps.position.coordinate.longitude),
"title": "Share Current Position"
});
BusyIndicator {
anchors.right: parent.right
anchors.rightMargin: Theme.paddingLarge
anchors.verticalCenter: parent.verticalCenter
running: !gps.ready
size: BusyIndicatorSize.Small
z: parent.z + 1
}
onClicked: {
if (!gps.ready) return;
app.pageStack.push("SharePage.qml", {
"coordinate": QtPositioning.coordinate(
gps.position.coordinate.latitude,
gps.position.coordinate.longitude),
"title": "Share Current Position"
});
}
}
ListItem {
id: findCurrentPositionItem
Expand Down
12 changes: 11 additions & 1 deletion qml/NearbyPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import "."
Page {
id: page
allowedOrientations: app.defaultAllowedOrientations
canNavigateForward: page.near && page.query.length > 0
canNavigateForward: page.near &&
(page.nearText !== "Current position" || gps.ready) &&
page.query.length > 0
property var near: null
property string nearText: ""
property string query: ""
Expand Down Expand Up @@ -59,6 +61,14 @@ Page {
value: page.nearText
// Avoid putting label and value on different lines.
width: 3*parent.width
BusyIndicator {
anchors.right: parent.right
anchors.rightMargin: Theme.paddingLarge + (parent.width - page.width)
anchors.verticalCenter: parent.verticalCenter
running: page.nearText === "Current position" && !gps.ready
size: BusyIndicatorSize.Small
z: parent.z + 1
}
onClicked: {
var dialog = app.pageStack.push("RoutePointPage.qml");
dialog.accepted.connect(function() {
Expand Down
5 changes: 5 additions & 0 deletions qml/PositionSource.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ PositionSource {
property var coordHistory: []
property var direction: undefined
property var directionHistory: []
property var ready: false
property var timeActivate: Date.now()
property var timeDirection: Date.now()
property var timePosition: Date.now()
Expand All @@ -41,6 +42,10 @@ PositionSource {
// Calculate direction as a median of individual direction values
// calculated after significant changes in position. This should be
// more stable than any direct value and usable with map.autoRotate.
gps.ready = gps.position.latitudeValid &&
gps.position.longitudeValid &&
gps.position.coordinate.latitude &&
gps.position.coordinate.longitude;
gps.timePosition = Date.now();
var threshold = gps.position.horizontalAccuracy || 15;
if (threshold < 0 || threshold > 40) return;
Expand Down
20 changes: 19 additions & 1 deletion qml/RoutePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import "."
Page {
id: page
allowedOrientations: app.defaultAllowedOrientations
canNavigateForward: page.from && page.to
canNavigateForward: page.from && page.to &&
(page.fromText !== "Current position" || gps.ready) &&
(page.toText !== "Current position" || gps.ready)
property var from: null
property string fromText: ""
property var params: {}
Expand Down Expand Up @@ -59,6 +61,14 @@ Page {
value: page.fromText
// Avoid putting label and value on different lines.
width: 3*parent.width
BusyIndicator {
anchors.right: parent.right
anchors.rightMargin: Theme.paddingLarge + (parent.width - page.width)
anchors.verticalCenter: parent.verticalCenter
running: page.fromText === "Current position" && !gps.ready
size: BusyIndicatorSize.Small
z: parent.z + 1
}
onClicked: {
var dialog = app.pageStack.push("RoutePointPage.qml");
dialog.accepted.connect(function() {
Expand All @@ -80,6 +90,14 @@ Page {
value: page.toText
// Avoid putting label and value on different lines.
width: 3*parent.width
BusyIndicator {
anchors.right: parent.right
anchors.rightMargin: Theme.paddingLarge + (parent.width - page.width)
anchors.verticalCenter: parent.verticalCenter
running: page.toText === "Current position" && !gps.ready
size: BusyIndicatorSize.Small
z: parent.z + 1
}
onClicked: {
var dialog = app.pageStack.push("RoutePointPage.qml");
dialog.accepted.connect(function() {
Expand Down

0 comments on commit d2848ed

Please sign in to comment.