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

Changed milestones to use duration values #208

Merged
merged 2 commits into from
Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public final class TriggerProperty {

public static final int NEXT_STEP_DISTANCE_METERS = 0x00000007;

public static final int NEXT_STEP_DURATION_SECONDS = 0x00000011;

public static final int FIRST_LEG = 0x00000009;

public static final int LAST_LEG = 0x000000010;
Expand All @@ -68,7 +70,7 @@ public final class TriggerProperty {

static SparseArray<Number[]> getSparseArray(RouteProgress previousRouteProgress, RouteProgress routeProgress) {
// Build hashMap matching the trigger properties to their corresponding current values.
SparseArray<Number[]> statementObjects = new SparseArray<>(12);
SparseArray<Number[]> statementObjects = new SparseArray<>(13);
statementObjects.put(TriggerProperty.STEP_DISTANCE_TOTAL_METERS,
new Number[] {routeProgress.currentLegProgress().currentStep().getDistance()});
statementObjects.put(TriggerProperty.STEP_DURATION_TOTAL_SECONDS,
Expand All @@ -90,6 +92,9 @@ static SparseArray<Number[]> getSparseArray(RouteProgress previousRouteProgress,
(routeProgress.currentLeg().getSteps().size() - 2)});
statementObjects.put(TriggerProperty.FIRST_STEP,
new Number[] {routeProgress.currentLegProgress().stepIndex(), 0});
statementObjects.put(TriggerProperty.NEXT_STEP_DURATION_SECONDS,
new Number[] {routeProgress.currentLegProgress().upComingStep() != null
? routeProgress.currentLegProgress().upComingStep().getDuration() : 0});
statementObjects.put(TriggerProperty.NEXT_STEP_DISTANCE_METERS,
new Number[] {
routeProgress.currentLegProgress().upComingStep() != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public String buildInstruction(RouteProgress routeProgress) {
})
.setTrigger(
Trigger.all(
Trigger.gt(TriggerProperty.STEP_DISTANCE_TOTAL_METERS, 15d),
Trigger.lte(TriggerProperty.STEP_DISTANCE_REMAINING_METERS, 15d),
Trigger.gt(TriggerProperty.NEXT_STEP_DISTANCE_METERS, 15d)
Trigger.gt(TriggerProperty.STEP_DURATION_TOTAL_SECONDS, 15d),
Trigger.lte(TriggerProperty.STEP_DURATION_REMAINING_SECONDS, 15d),
Trigger.gt(TriggerProperty.NEXT_STEP_DURATION_SECONDS, 15d)
)
)
.build()
Expand All @@ -63,9 +63,9 @@ public String buildInstruction(RouteProgress routeProgress) {
})
.setTrigger(
Trigger.all(
Trigger.gt(TriggerProperty.STEP_DISTANCE_TOTAL_METERS, 15d),
Trigger.lte(TriggerProperty.STEP_DISTANCE_REMAINING_METERS, 15d),
Trigger.lte(TriggerProperty.NEXT_STEP_DISTANCE_METERS, 15d)
Trigger.gt(TriggerProperty.STEP_DURATION_TOTAL_SECONDS, 15d),
Trigger.lte(TriggerProperty.STEP_DURATION_REMAINING_SECONDS, 15d),
Trigger.lte(TriggerProperty.NEXT_STEP_DURATION_SECONDS, 15d)
)
)
.build()
Expand All @@ -92,9 +92,8 @@ public String buildInstruction(RouteProgress routeProgress) {
})
.setTrigger(
Trigger.all(
Trigger.gt(TriggerProperty.STEP_DISTANCE_TOTAL_METERS, 400d),
Trigger.gt(TriggerProperty.STEP_DURATION_TOTAL_SECONDS, 80d),
Trigger.lt(TriggerProperty.STEP_DURATION_REMAINING_SECONDS, 70d)
Trigger.lte(TriggerProperty.STEP_DURATION_REMAINING_SECONDS, 70d)
)
)
.build()
Expand All @@ -117,9 +116,9 @@ public String buildInstruction(RouteProgress routeProgress) {
})
.setTrigger(
Trigger.all(
Trigger.neq(TriggerProperty.NEW_STEP, TriggerProperty.FALSE),
Trigger.neq(TriggerProperty.FIRST_STEP, TriggerProperty.TRUE),
Trigger.gt(TriggerProperty.STEP_DISTANCE_TOTAL_METERS, 100d)
Trigger.eq(TriggerProperty.NEW_STEP, TriggerProperty.TRUE),
Trigger.eq(TriggerProperty.FIRST_STEP, TriggerProperty.FALSE),
Trigger.gt(TriggerProperty.STEP_DURATION_TOTAL_SECONDS, 20d)
)
).build());

Expand Down Expand Up @@ -147,7 +146,7 @@ public String buildInstruction(RouteProgress routeProgress) {
Trigger.all(
Trigger.eq(TriggerProperty.FIRST_STEP, TriggerProperty.TRUE),
Trigger.eq(TriggerProperty.FIRST_LEG, TriggerProperty.TRUE),
Trigger.gt(TriggerProperty.NEXT_STEP_DISTANCE_METERS, 15)
Trigger.gt(TriggerProperty.NEXT_STEP_DURATION_SECONDS, 15d)
)
).build());

Expand All @@ -167,7 +166,7 @@ public String buildInstruction(RouteProgress routeProgress) {
Trigger.all(
Trigger.eq(TriggerProperty.FIRST_STEP, TriggerProperty.TRUE),
Trigger.eq(TriggerProperty.FIRST_LEG, TriggerProperty.TRUE),
Trigger.lte(TriggerProperty.NEXT_STEP_DISTANCE_METERS, 15)
Trigger.lte(TriggerProperty.NEXT_STEP_DURATION_SECONDS, 15d)
)
).build());

Expand Down Expand Up @@ -195,6 +194,6 @@ public String buildInstruction(RouteProgress routeProgress) {
private String getInstructionString(RouteProgress routeProgress) {
return routeProgress.currentLegProgress().upComingStep() != null
? routeProgress.currentLegProgress().upComingStep().getManeuver().getInstruction() :
routeProgress.currentLegProgress().currentStep().getManeuver().getInstruction();
"Arrived at your destination";
}
}