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

added rotary convenience methods #329

Merged
merged 2 commits into from
Feb 20, 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
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ directions-fixtures:
curl "https://api.mapbox.com/directions/v5/mapbox/driving/-122.416667,37.783333;-121.900000,37.333333?geometries=polyline6&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
-o mapbox/libjava-services/src/test/fixtures/directions_v5_precision_6.json

directions-fixtures-exit-property:
curl "https://api.mapbox.com/directions/v5/mapbox/driving/-77.02962040901184,38.90728142481329;-77.02808618545532,38.910111607145296?geometries=polyline&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
-o mapbox/libjava-services/src/test/fixtures/directions_v5_exit_property.json
directions-fixtures-rotary:
curl "https://api.mapbox.com/directions/v5/mapbox/driving/-77.04430818557739,38.908650612656864;-77.04192638397217,38.90963574367117?geometries=polyline&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
-o mapbox/libjava-services/src/test/fixtures/directions_v5_fixtures_rotary.json

directions-traffic-fixtures:
curl "https://api.mapbox.com/directions/v5/mapbox/driving-traffic/-122.416667,37.783333;-121.900000,37.333333?geometries=polyline&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mapbox.services.api.directions.v5.models;

import com.google.gson.annotations.SerializedName;
import java.util.List;

/**
Expand All @@ -14,6 +15,11 @@ public class LegStep {
private String geometry;
private String name;
private String mode;
private String pronunciation;
@SerializedName("rotary_name")
private String rotaryName;
@SerializedName("rotary_pronunciation")
private String rotaryPronunciation;
private StepManeuver maneuver;
private List<StepIntersection> intersections;

Expand Down Expand Up @@ -78,4 +84,36 @@ public StepManeuver getManeuver() {
public List<StepIntersection> getIntersections() {
return intersections;
}


/**
* An optional string indicating the name of the rotary.
*
* @return String with the rotary name
* @since 2.0.0
*/
public String getRotaryName() {
return rotaryName;
}

/**
* An optional string indicating the pronunciation of the name of the rotary.
*
* @return String in IPA with the rotary name's pronunciation
* @since 2.0.0
*/
public String getRotaryPronunciation() {
return rotaryPronunciation;
}

/**
* The pronunciation hint of the way name. Will be undefined if no pronunciation is hit.
*
* @return String with the pronunciation
* @since 2.0.0
*/
public String getPronunciation() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghoshkaj why two getters for the same field getRotaryPronunciation and getPronunciation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I messed up :D fixed it!

return rotaryPronunciation;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class StepManeuver {
@SerializedName("bearing_after")
private double bearingAfter;
private String type;
private String pronunciation;
private String modifier;
private String instruction;
private Integer exit;
Expand Down Expand Up @@ -92,16 +91,6 @@ public Integer getExit() {
return exit;
}

/**
* The pronunciation hint of the way name. Will be undefined if no pronunciation is hit.
*
* @return String with the pronunciation
* @since 1.3.0
*/
public String getPronunciation() {
return pronunciation;
}

/**
* This indicates the mode of the maneuver. If type is of turn, the modifier indicates the
* change in direction accomplished through the turn. If the type is of depart/arrive, the
Expand Down Expand Up @@ -147,7 +136,6 @@ public String toString() {
+ ", bearingAfter=" + bearingAfter
+ ", instruction='" + instruction + '\''
+ ", type='" + type + '\''
+ ", pronunciation='" + pronunciation + '\''
+ ", modifier='" + modifier + '\''
+ ", exit=" + exit
+ '}';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"routes":[{"legs":[{"steps":[{"intersections":[{"out":0,"entry":[true],"bearings":[36],"location":[-77.044347,38.908672]},{"out":1,"location":[-77.044058,38.908981],"bearings":[15,60,210],"entry":[false,true,false],"in":2}],"geometry":"ejnlFdvfuM}@y@GKEOCM?IAG","maneuver":{"bearing_after":36,"location":[-77.044347,38.908672],"bearing_before":0,"type":"depart","instruction":"Head northeast on New Hampshire Avenue Northwest"},"duration":48,"distance":71.5,"name":"New Hampshire Avenue Northwest","mode":"driving"},{"intersections":[{"out":0,"location":[-77.043755,38.909075],"bearings":[105,270,300],"entry":[true,false,false],"in":1},{"out":0,"location":[-77.04359,38.909036],"bearings":[105,120,135,285],"entry":[true,true,true,false],"in":3},{"out":0,"location":[-77.042938,38.909165],"bearings":[45,195,225],"entry":[true,false,false],"in":2},{"out":0,"location":[-77.042775,38.909307],"bearings":[30,90,210,255],"entry":[true,true,false,false],"in":2},{"out":1,"location":[-77.042668,38.909502],"bearings":[15,45,135,195,345],"entry":[true,true,false,false,true],"in":3},{"out":0,"location":[-77.042382,38.909645],"bearings":[90,255,285],"entry":[true,false,false],"in":1}],"geometry":"wlnlFnrfuMBK@I@K@I?I?I?I?GAI?IAICIAGCICGCGEGAECCCECCCCCCECGEGEGCECGAKKEGCICICQ@yA","maneuver":{"exit":3,"bearing_after":111,"type":"rotary","modifier":"slight right","bearing_before":84,"location":[-77.043755,38.909075],"instruction":"Enter Dupont Circle Northwest and take the 3rd exit onto P Street Northwest"},"mode":"driving","duration":150.6,"rotary_name":"Dupont Circle Northwest","distance":189.9,"name":"P Street Northwest"},{"intersections":[{"in":0,"entry":[true],"bearings":[270],"location":[-77.041926,38.909644]}],"geometry":"gpnlF`gfuM","maneuver":{"bearing_after":0,"location":[-77.041926,38.909644],"bearing_before":90,"type":"arrive","instruction":"You have arrived at your destination"},"duration":0,"distance":0,"name":"P Street Northwest","mode":"driving"}],"summary":"New Hampshire Avenue Northwest, Dupont Circle Northwest","duration":198.6,"distance":261.4}],"geometry":"ejnlFdvfuM}@y@M[E_@H_AGy@]y@w@e@U]G[@yA","duration":198.6,"distance":261.4}],"waypoints":[{"name":"New Hampshire Avenue Northwest","location":[-77.044347,38.908672]},{"name":"P Street Northwest","location":[-77.041926,38.909644]}],"code":"Ok"}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class MapboxDirectionsTest {
public static final String DIRECTIONS_V5_FIXTURE = "src/test/fixtures/directions_v5.json";
public static final String DIRECTIONS_V5_PRECISION6_FIXTURE = "src/test/fixtures/directions_v5_precision_6.json";
public static final String DIRECTIONS_TRAFFIC_FIXTURE = "src/test/fixtures/directions_v5_traffic.json";
public static final String DIRECTIONS_EXIT_FIXTURE = "src/test/fixtures/directions_v5_exit_property.json";
public static final String DIRECTIONS_ROTARY_FIXTURE = "src/test/fixtures/directions_v5_fixtures_rotary.json";
private static final double DELTA = 1E-10;

private MockWebServer server;
Expand All @@ -68,8 +68,8 @@ public MockResponse dispatch(RecordedRequest request) throws InterruptedExceptio
if (request.getPath().contains("driving-traffic")) {
resource = DIRECTIONS_TRAFFIC_FIXTURE;
}
if (request.getPath().contains("-77.02962")) {
resource = DIRECTIONS_EXIT_FIXTURE;
if (request.getPath().contains("-77.04430")) {
resource = DIRECTIONS_ROTARY_FIXTURE;
}

try {
Expand Down Expand Up @@ -358,10 +358,10 @@ public void testStepManeuver() throws ServicesException, IOException {


@Test
public void testStepManeuverForExit() throws ServicesException, IOException {
public void testRotaryLegStepAndStepManeuver() throws ServicesException, IOException {
List<Position> positionsExit = new ArrayList<>();
positionsExit.add(Position.fromCoordinates(-77.02962040901184, 38.90728142481329));
positionsExit.add(Position.fromCoordinates(-77.02808618545532, 38.910111607145296));
positionsExit.add(Position.fromCoordinates(-77.04430818557739, 38.908650612656864));
positionsExit.add(Position.fromCoordinates(-77.04192638397217, 38.90963574367117));

MapboxDirections client = new MapboxDirections.Builder()
.setAccessToken("pk.XXX")
Expand All @@ -372,15 +372,21 @@ public void testStepManeuverForExit() throws ServicesException, IOException {
Response<DirectionsResponse> response = client.executeCall();

StepManeuver maneuver = response.body().getRoutes().get(0).getLegs().get(0).getSteps().get(1).getManeuver();
assertEquals(maneuver.asPosition().getLongitude(), -77.029315, DELTA);
assertEquals(maneuver.asPosition().getLatitude(), 38.909144, DELTA);
assertEquals(maneuver.getBearingBefore(), 43.0, DELTA);
assertEquals(maneuver.getBearingAfter(), 63.0, DELTA);
assertEquals(maneuver.getType(), "roundabout");
assertEquals(maneuver.getModifier(), "straight");
assertEquals(maneuver.asPosition().getLongitude(), -77.043755, DELTA);
assertEquals(maneuver.asPosition().getLatitude(), 38.909075, DELTA);
assertEquals(maneuver.getBearingBefore(), 84.0, DELTA);
assertEquals(maneuver.getBearingAfter(), 111.0, DELTA);
assertEquals(maneuver.getType(), "rotary");
assertEquals(maneuver.getModifier(), "slight right");
assertEquals(maneuver.getInstruction(),
"Enter the roundabout and take the 2nd exit onto Rhode Island Avenue Northwest");
assertEquals(maneuver.getExit(), new Integer(2));
"Enter Dupont Circle Northwest and take the 3rd exit onto P Street Northwest");
assertEquals(maneuver.getExit(), new Integer(3));


LegStep step = response.body().getRoutes().get(0).getLegs().get(0).getSteps().get(1);
assertEquals(step.getRotaryName(), "Dupont Circle Northwest");
assertEquals(step.getRotaryPronunciation(), null);
assertEquals(step.getPronunciation(), null);
}


Expand Down