I've signed up for an API on openrouteservice.org. How do I import it into OSRMRoadManager? I've tried all the combinations from the examples on their website, but my every try results in the 403 error with a comment org.json.JSONException: No value for code and a link to the following:
{
"error": "Daily quota reached or API key unauthorized"
}
(I haven't used that API before, so I couldn't have used up the quota. The key is valid, as I have tested it with the links from the aforementioned website)
My Kotlin code (in my most recent attempt) is as following ([MY_API_KEY] is obviously replacing my real key):
val roadManager = OSRMRoadManager(context, context?.packageName)
(roadManager as OSRMRoadManager).setService("https://api.openrouteservice.org/v2/directions/driving-car/geojson?api_key=[MY_API_KEY]")
val waypoints = ArrayList<GeoPoint>()
waypoints.add(GeoPoint(lastLocLat, lastLocLong)) //last known location
val endPoint = GeoPoint(randomOverlay.getItem(0).point.latitude, randomOverlay.getItem(0).point.longitude) //destination
waypoints.add(endPoint)
val road = roadManager.getRoad(waypoints)
My guess is that the waypoint coordinates should be included differently in the link, but I don't know how to alter that.
openrouteservice directions format is not identical to OSRM, so you cannot use OSRMRoadManager.
If you really - really - want to use openrouteservice, you will have to develop corresponding openrouteserviceRoadManager.
Alternative: use one among the 3 routing services already accessible with OBP. Pros and cons here.
Related
I am creating an Android App that accesses the HERE Platform Data Extension Api (= PDE). Therefore I first load a map centering on my current location. This works fine so far. Then I try to load data from the PDE for the layer "SAFETY_ALERTS", but I get a 400 Error there with the message "tilexy lists 992 tiles but the limit is 64 tiles".
I am not sure where this "tilexy" comes from. I already researched through as much documentation of the PDE as I could find online, but I couldn't find an answer.
Set<String> layers = new HashSet<>(Arrays.asList("SAFETY_ALERTS"));
GeoBoundingBox bbox = map.getBoundingBox();
final PlatformDataRequest request = PlatformDataRequest.createBoundingBoxRequest(layers, bbox);
request.execute(new PlatformDataRequest.Listener<PlatformDataResult>() {
#Override
public void onCompleted(PlatformDataResult platformDataResult, PlatformDataRequest.Error error) {
if (error == null) {
//do something
} else {
//show error --> Here is where I get
}
I expected to get a PlatformDataItemCollection, which is a List of PlatformDataItems (they implement Map). Instead I got the 400-Error.
Does somebody know where this error comes from and can help me fix my mistake?
As per the error message, it would be advisable to check the API call as it seems that more than 64 coordinates has been passed in tilexy parameter in the rest call. tilexy is a string, which is passed in comma separated sequence of tilex,tiley pairs for the requested tiles. The tilex and tiley values are described in the "tile" resource.
please refer following documentation for more reference
developer.here.com/documentation/platform-data/topics/example-tiles.html
Happy Coding..!!
When I am trying to search some term from JAVA sdk of BOX API , I am getting only 400 Results while when i search the same term on app.box.com i am getting 1270 results.
Please help regarding this .
BoxAPIConnection api = new BoxAPIConnection("developer token");
BoxFolder rootFolder = BoxFolder.getRootFolder(api);
Iterable<BoxItem.Info> results = rootFolder.search("*.pdf");
for (BoxItem.Info result : results) {
System.out.println("Result:"+i+" FileName&ID:"+result.getName()+" "+result.getID());
//Only Returning 400 Results
}
There is no limit in the Java SDK for Box API with regards to how many items will be returned. The Iterable<BoxItem.Info> returned by BoxFolder.search() will iterate until the Box API returns no more results (in batches of 200 items).
Therefore, except if you are hitting some sort of an error in the communication with the Box API (use Charles Proxy or Fiddler or similar tool to monitor that), it means that you are hitting a scope issue. A possible explanation would be that when you search at box.com you search in enterprise scope, while when you search via the API you search in user scope. Can you check the results for that?
I am making a call from a server that is located in US to FindItemsAdvanced of ebay finding api.
I define ListedIn as "EBAY-ENCA", however, when I make the call - I see that it doesn't return results. I believe that this is because that items are not available to US.
I see that there is a parameter called: AvailableTo - but how can I say "to all countries" ? Writing each iso code in the world could be exhausting..
My code:
ItemFilter marketFilter = new ItemFilter();
marketFilter.setName(ItemFilterType.LISTED_IN);
marketFilter.getValue().add("EBAY-ENCA");
request.getItemFilter().add(marketFilter);
ItemFilter conditionFilter = new ItemFilter();
conditionFilter.setName(ItemFilterType.AVAILABLE_TO);
conditionFilter.getValue().add("UK");
request.getItemFilter().add(conditionFilter);
In general this call should work - regardless from where you call the API. So I assume that you get an error message from the API that prevent items from being returned. Be aware that the FindItemsAdvanced call of the eBay Finding API requires either a given "categoryId" or a "keyword". Do you set any of these?
Here is the XML payload of a working call:
<findItemsAdvancedRequest xmlns="http://www.ebay.com/marketplace/search/v1/services">
<keywords>iPhone6</keywords>
<itemFilter>
<name>ListedIn</name>
<value>EBAY-ENCA</value>
</itemFilter>
</findItemsAdvancedRequest>
I've created an example in our API playground. It uses the XML version of the Finding API. Just execute the call to see the valid response with items included. You can adapt and customize the request parameters to your needs and see how the API responses.
The "AvailableTo" filter can only be used once per request with exactly one value. So it won't be possible to add it multiple times or to add it once with multiple values. But I'm not sure if I get your use case right. Do you really want to get only those items that are available world wide? If yes, then I'm afraid this most probably isn't possible without filtering them locally (eg. by filtering for "Worldwide" in the "shipToLocations").
I am developing a functionality for my project that when user enters 'Postal Code' the co-ordinates(latitude, longitude) for the corresponding 'postal code' should display. the implementation platform is 'JAVA'.
I googled for the java api but i did not find any specific resource.
Any suggstions will be greatly appriciated
You can (now) check out the open-source Java client library for Geocoding, Directions, DistanceMatrix, Elevation and TimeZone too: https://github.com/googlemaps/google-maps-services-java
It's quite straight forward. E.g. have a look at the geocode method of this class. Pass your postalcode (along with the country) to the method and you should be fine. (The GLatLng class can be found here but should be replaced by you according to your needs.)
[edit]
I just saw that this example is still using Google Maps v2, but it should be a breeze to convert it to v3.
In the linked documents you can also find the restrictions regarding the use of this service (paragraph "Usage Limits")
You could try to write a REST client (using e.g. Apache HttpClient) for Google geocoding API RESTful web service.
The docs on this are not new user friendly. For me the java docs worked best although theyre quite rigid: https://www.javadoc.io/doc/com.google.maps/google-maps-services/latest/com/google/maps/GeocodingApiRequest.html
Here is how to do so using the newest Google Geocoding API:
//use your google api key to create a GeoApiContext instance
GeoApiContext context = new GeoApiContext.Builder().apiKey("xxxxxx").build();
//this will get geolocation details via zip
GeocodingResult[]results = GeocodingApi.newRequest(context).components(ComponentFiler.postalCode("75002")).await();
System.out.println(results[0]);
//this will get geolocation details via address
GeocodingResult[] results2 = GeocodingApi.geocode(context, "One Apple Park Way Cupertino, CA 95014").await();
System.out.println(results2[0]);
//another way to get geolocation details via address
GeocodingResult[] results3 = GeocodingApi.newRequest(context).address("One Apple Park Way Cupertino, CA 95014").await();
System.out.println(results3[0]);
//geolocation details via lat lng
GeocodingResult[] results4 = GeocodingApi.newRequest(context).latlng(latLng).await();
System.out.println(results4[0]);
from there you'll get a bunch of data on the returned location in the results array, you can parse it as you wish to extract your choice of data. heres an ex of what that data looks like....
[GeocodingResult placeId=ChIJyTSQVXm0j4ARmdUQoA1BpwQ [Geometry: 37.31317000,-122.07238160 (APPROXIMATE) bounds=[37.34159500,-121.99557710, 37.24799500,-122.14382300], viewport=[37.34159500,-121.99557710, 37.24799500,-122.14382300]], formattedAddress=MONTE VISTA, CA 95014, USA, types=[postal_code], addressComponents=[[AddressComponent: "95014" ("95014") (postal_code)], [AddressComponent: "MONTE VISTA" ("MONTE VISTA") (locality, political)], [AddressComponent: "Santa Clara County" ("Santa Clara County") (administrative_area_level_2, political)], [AddressComponent: "California" ("CA") (administrative_area_level_1, political)], [AddressComponent: "United States" ("US") (country, political)]], postcodeLocalities=[Cupertino, MONTE VISTA, Permanente]]
Here is a way for doing it (include source):
http://halexv.blogspot.mx/2015/07/java-geocoding-using-google-maps-api.html
The blog explain how to do it without having and API_KEY and a way for filtering the locatiotions into the most probable one.
Give it a try.
I have this code for requesting google to correct the typed in address, and need it to return the English name for the city:
function gmap_query_xml($in_address) {
$base_url = "http://maps.google.com/maps/geo?output=xml®ion=US&language=en&key=". KEY;
$request_url = $base_url . "&q=" . urlencode($in_address);
return simplexml_load_file($request_url);
}
Then,
$xml = gmap_query_xml($in_address);
And finally to get the city name:
if ($xml) {
$city = (string) $xml->Response->Placemark->AddressDetails->Country->AdministrativeArea->SubAdministrativeArea->Locality->LocalityName;
}
This returns the correct city name, BUT! it's represented in the native language. Try Rome - you get Roma, try Kiev and you will get Киев.
How this can be solved? Thank!!
There seems to be a bit of a chaos in that regard. See this list of Google Geocoding API bug reports.
You are using the old V2 API.
According to this post and my own tests, the new V3 API:
http://maps.google.com/maps/api/geocode/xml?address=Rome&sensor=false&language=en
is more sensitive to the language parameter and translates locality names correctly. I get correct results for language=en (Rome), language=de (Rom) and even language=fi (Rooma)!
However, V3 serves its geocoding results in a different format so you would have to change your parsing considerably (Due to the way addressComponents is structured now, this bugged the heck out of me too).