HERE Android SDK Developer's Guide

Coverage Search

Urban Mobility Coverage Search provides detailed information about the regions and cities with public transit data that are supported by HERE SDK. For example, you can get a list of cities that have transit data coverage by using a query request with a search area. You can create this type of request by using RequestManager.createCityCoverageRequest(ResponseListener<CityCoverageResult>) to generate a city coverage request object.

// Geo coordinate of a reference point
GeoCoordinate coordinates = new GeoCoordinate(40.750488, -73.993546);  //somewhere in NY

// listener that will be notified after request is completed
RequestManager.ResponseListener<CityCoverageResult> responseListener = new RequestManager.ResponseListener<CityCoverageResult>() {
  @Override public void onSuccess(CityCoverageResult searchResult) {
    List<City> foundCities = searchResult.getCities();
    for (City city : foundCities) 
    {
      String cityName = city.getDisplayName();
      float percentCovered = city.getQuality();
      // ...
    }
  }

  @Override public void onError(ErrorCode errorCode, String errorMessage) {
    // report error
  }
};

// creating and executing the request
// search coverage by city name
CityCoverageRequest request = new RequestManager()
    .createCityCoverageRequest(responseListener).setLocation(coordinates) // if not specified, returns all cities
    .setRadius(150000) // meters
    .setUpdateType(CityCoverageRequest.UpdateType.ALL) // all cities
    .setTime(null); // works together with the UpdateType parameter
request.execute();

Another supported type of coverage search uses a query string to look for cities with names that begin with this substring. You can create this type of request by using RequestManager.createCitySearchRequest(String, ResponseListener<CitySearchResult>).

// name of the city to search
String name = "New York";

// listener that will be notified after request is completed
RequestManager.ResponseListener<CitySearchResult> responseListener = new RequestManager.ResponseListener<CitySearchResult>() {

  @Override public void onSuccess(CitySearchResult citySearchResult) {
  for (City city: citySearchResult.getCities()) 
  {
    String name = city.getName();
    GeoCoordinate coordinates = city.getLocation();
    int population = city.getPopulation();
    // ...
  }
  }

  @Override public void onError(ErrorCode errorCode, String errorMessage) {
  // report error
  }
};




// creating and executing the request
// search coverage by city name
CitySearchRequest request = new RequestManager().createCitySearchRequest(
  name, responseListener);
request.execute();

You can also use RequestManager.createNearbyCoverageRequest(GeoCoordinate, ResponseListener<NearbyCoverageResult>) to search for coverage information around a given location. This type of search returns information of the city that contains this location. If there is no transit stop within 2 kilometers of the location, the request returns the first five nearest transit stops outside of the 2 kilometers area. This type of search result is also known as an "Explored Coverage". The following code demonstrates how to retrieve both nearby and explored coverage results.

GeoCoordinate coordinates = new GeoCoordinate(40.750488, -73.993546);  //somewhere in NY

// listener that will be notified after request is completed
RequestManager.ResponseListener<NearbyCoverageResult> responseListener = new RequestManager.ResponseListener<NearbyCoverageResult>() {

  @Override public void onSuccess(NearbyCoverageResult nearbyCoverage) {
  City city = nearbyCoverage.getCity();
  ExploredCoverage exploredCoverage = nearbyCoverage.getExploredCoverage();
  ...
  }
  

  @Override public void onError(ErrorCode errorCode, String errorMessage) {
  // report error
  }
};

// creating and executing the request
// search coverage nearby
NearbyCoverageRequest request = new RequestManager().createNearbyCoverageRequest(coordinates, responseListener);
request.execute();