Hello,
I was working on adding an identifying field to each region for whether is it OSRM vs. OTP in OTP region directory, and creating/adapting client code for OSRM into OTP Android app.
I think I am going in the right direction.
I have created a spreadsheet of my own which have a additional 10th column specifying the server_name the app is currently using. It can be any server OTP/OSRM/any that's why i choose it to be a text field rather than a Boolean value.
Subsequently i have changed the code to take into account the server_name.
Here are the changes in the code (result of git diff):
1.Server.java :
+ private String serverName ;
+
public Server() {
super();
}
@@ -93,11 +95,12 @@ public class Server {
setContactName(s.getContactName());
setContactEmail(s.getContactEmail());
setOffersBikeRental(s.getOffersBikeRental());
+ setServerName(s.getServerName());
}
public Server(Long d, String region, String baseURL, String bounds,
String language, String contactName, String contactEmail, String center, String zoom,
- String offersBikeRental)
+ String offersBikeRental, String serverName)
throws ServerListParsingException {
super();
setDate(d);
@@ -110,11 +113,12 @@ public class Server {
setContactName(contactName);
setContactEmail(contactEmail);
setBikeRental(offersBikeRental);
+ setServerName(serverName);
}
public Server(String region, String baseURL, String bounds,
String language, String contactName, String contactEmail, String center, String zoom,
- String offersBikeRental)
+ String offersBikeRental, String serverName)
throws ServerListParsingException {
super();
setRegion(region);
@@ -126,6 +130,7 @@ public class Server {
setContactName(contactName);
setContactEmail(contactEmail);
setBikeRental(offersBikeRental);
+ setServerName(serverName);
}
@@ -145,6 +150,7 @@ public class Server {
this.contactEmail = applicationContext.getResources()
.getString(R.string.server_checker_info_custom_server_unknown_email);
this.offersBikeRental = false;
+ this.serverName = "unknown";
}
+ public String getServerName() {
+ return serverName;
+ }
+
+ public void setServerName(String serverName) {
+ this.serverName = serverName;
+ }
+
}
2. ServerSelector.java
public class ServerSelector extends AsyncTask<LatLng, Integer, Integer>
break;
}
}
- if (allFieldsNotNull && (serverString.length >= 9)) {
+ if (allFieldsNotNull && (serverString.length >= 10)) {
try {
Server s = new Server(currentTime, serverString[0], serverString[1],
serverString[2], serverString[3], serverString[4],
serverString[5], serverString[6], serverString[7],
- serverString[8]);
+ serverString[8], serverString[9] );
serverList.add(s);
} catch (ServerListParsingException e) {
Log.e(OTPApp.TAG,
Now that we have a server name in our application we can switch to different servers as per our choice and users choice.
Now the next step is to integrate OSRM servers in OTP. Does any one have any lead on how to go about it (how to set up OSRM server and connection setting).
Please tell me if I'm going in the right direction?
Regards,
Sarthak