-
Notifications
You must be signed in to change notification settings - Fork 120
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
Added walking options #991
Conversation
3cb42c8
to
6fa2fc8
Compare
@@ -152,6 +174,12 @@ | |||
@Field("waypoints") String waypointIndices, | |||
@Field("waypoint_names") String waypointNames, | |||
@Field("waypoint_targets") String waypointTargets, | |||
@Field("enable_refresh") Boolean enableRefresh | |||
@Field("enable_refresh") Boolean enableRefresh, | |||
@Query("walking_speed") Double walkingSpeed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed that we're using @Query
here instead of @Field
and wondering if there are any implications 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Guardiola31337 My understanding is that @Field
is only used for POST
because it's @FormUrlEncoded
, but if you think this shouldn't be the case let me know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Guardiola31337 nevermind I just understood what you were saying. It's interesting because I thought they were supposed to be @Field
but the example test passed with @Query
... I'll update them anyway
services-directions/src/main/java/com/mapbox/api/directions/v5/MapboxDirections.java
Outdated
Show resolved
Hide resolved
if (walkingOptions() == null) { | ||
walkingOptions(WalkingOptions.builder().build()); | ||
} else if (!DirectionsCriteria.PROFILE_WALKING.equals(profile())) { | ||
throw new ServicesException("Walking options are for use with the walking profile"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the backend service return any error in this situation? If so, we should bubble up that error and not thrown an exception at this point.
* @since 4.6.0 | ||
*/ | ||
@AutoValue | ||
public abstract class WalkingOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include these options as part of RouteOptions
? If so, we should make sure that toJson
/ fromJson
methods are implemented and serialization / deserializations work 👌
services-core/gradle.properties
Outdated
@@ -1,4 +1,4 @@ | |||
VERSION_NAME=4.5.0-SNAPSHOT | |||
VERSION_NAME=4.6.0-SNAPSHOT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this when I was just releasing 4.6.0.
If you rebase this PR to master - you will not need this commit.
66ecedc
to
5b11c99
Compare
f70b8d5
to
87cce2d
Compare
2f23f0f
to
b41ad6a
Compare
.profile(DirectionsCriteria.PROFILE_WALKING) | ||
.walkingOptions(WalkingOptions.builder().alleyBias(2d).build()) | ||
.build(); | ||
assertTrue(directions.cloneCall().request().url().toString().contains("alley_bias=2.0")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ok that this test is using a value that is out of bounds? valid values are from -1
to 1
/** | ||
* A factor that modifies the cost when encountering roads or paths that do not allow | ||
* vehicles and are set aside for pedestrian use. Pedestrian routes generally attempt to | ||
* favor using these walkways and sidewalks. The default walkway_factor is 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May want to indicate what the range of bias
values mean and their effect. Suggest adding something like: The allowed range of values is from -1 to 1, where -1 indicates indicates preference to _avoid_ pedestrian walkways, 1 indicates preference to _favor_ pedestrian walkways, and 0 indicates no preference
. Same comment for alleyBias below.
@devotaaabel Make sure the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good @devotaaabel
Left some minor comments to address / discuss before merging here.
} | ||
|
||
private Call<DirectionsResponse> post() { | ||
// todo add walking options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we revert these changes back? It seems walking supports POST
too now.
|
||
@Nullable | ||
Double walkingSpeed() { | ||
if (hasWalkingOptions()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment: Guard clauses normally represent the unexpected behavior i.e.
if (!hasWalkingOptions()) {
return null;
}
return walkingOptions().walkingSpeed();
* @since 4.8.0 | ||
*/ | ||
@Nullable | ||
public abstract Double walkingSpeed(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't options include the @SerializedName
? That’s what the backend expects / generates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import static org.junit.Assert.assertEquals; | ||
|
||
public class WalkingOptionsTest extends TestUtils { | ||
private static final String JSON = "{\"walkingSpeed\":1.0,\"walkwayBias\":2.0,\"alleyBias\":3.0}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This JSON isn’t something the backend would return they would return snake_case except for maxHikingDifficulty
- wondering if we could ask to services team to make it snake_case too for consistency 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just 👀 that maxHikingDifficulty
is not supported anymore and edited ☝️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be good for alpha. Let's give it a spin.
@devotaaabel |
This is currently blocked until testing on staging is complete.