Specialized search

VERSION 0.2.1455
PUBLIC PREVIEW

Search along a route

Use this search to find POIs along a specific route with the fuzzy search algorithm. The search is constrained by a time limit for detours from the route. The route must consist of at least 2 points. You can use the Routing module to create a route.

See the instructions in the planning a route. To create the request you need AlongRouteQuery that can be built using AlongRouteQueryBuilder. The query, route, and maxDetourTime (in seconds, with a maximum of 3600) parameters are required. You can also specify more detailed options for the underlying Fuzzy Search. More information about Along Route Search is in the Search API Along Route Search documentation.

1let query = "ATM"
2let alongRouteSearchQuery = AlongRouteQueryBuilder.create(
3 route: route,
4 maxDetourTime: 600,
5 query: query
6)
7.withResultLimit(limit: 10)
8.build()

Parameter completion: The completion closure is called after the response to the request has been processed. If no errors occurred, SearchResponse contains an array of categories and subcategories together with their translations and synonyms.

1searchService.alongRoute(query: alongRouteSearchQuery) { alongRouteResponse, error in
2 if let alongRouteResponse = alongRouteResponse {
3 // handle success
4 } else if let error = error {
5 // handle error
6 }
7}

The EV charging stations availability search checks the availability of Electric Vehicle (EV) charging points at a specific charging station. To make the request, you need to create EVChargingStationsAvailabilityQuery using EVChargingStationsAvailabilityQueryBuilder. The only mandatory parameter is the charging station identifier. You can get this identifier from the result of a Fuzzy Search. The identifier is in the DataSources of the SearchResult, labeled ChargingAvailabilityDataSource.

Not every SearchResult contains charging station information.

var searchResult = fuzzySearchResponse.results.first
var chargingStationId = searchResult?.dataSources?.chargingAvailability?.id ?? ""

You can add optional restrictions to the request: connector type, minimum power (expressed in kilowatts) and maximum power (expressed in kilowatts).

1let query = EVChargingStationsAvailabilityQueryBuilder(chargingAvailability: chargingStationId)
2 .with(connectorSet: ["IEC62196Type1", "IEC62196Type1CCS"])
3 .with(minPowerKW: 1)
4 .with(maxPowerKW: 5).build()

A successful request returns EVChargingStationsAvailabilityResponse. If the request fails, Error is provided.

1let searchService = TomTomOnlineSearchService()
2searchService.evChargingStationsAvailability(query: query) { evChargingStationsAvailabilityResponse, error in
3 if let evChargingStationsAvailabilityResponse = evChargingStationsAvailabilityResponse {
4 // handle success
5 } else if let error = error {
6 // handle error
7 }
8}

The geometry search allows you to perform a free-form search inside one or more defined geographic areas (geometries). By default, POIs are returned as a result. For other result types, the idxSet parameter should be used.

There are two types of geometries that are supported:

  • SearchPolygon - an array of coordinates of vertices.
    1let vertices: [CLLocationCoordinate2D] = [
    2 CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070),
    3 CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070),
    4 CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070),
    5 CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070),
    6]
    7let searchPolygon = SearchPolygon(vertices: vertices)
  • SearchCircle - center coordinates and a radius in meters.
    1let center = CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070)
    2let radiusInMeters = 1000
    3let circleGeometry = SearchCircle(position: center, radius: radiusInMeters)

As you have your search shapes, you can create GeometrySearchQuery using GeometrySearchQueryBuilder. You can also define optional parameters such as the number of results to return, language, and various constraints on what is searched for. More information about optional parameters and the geometry search can be found in the Search API Geometry Search documentation.

1let query = GeometrySearchQueryBuilder(
2 term: "Pizza",
3 searchGeometry: SearchGeometry(geometryList: [searchPolygon, circleGeometry])
4)
5.build()

If the search was successful, the response is presented as a SearchResponse object. Otherwise, error is returned.

1let searchService = TomTomOnlineSearchService()
2searchService.geometrySearch(query: query) { geometrySearchResponse, error in
3 if let geometrySearchResponse = geometrySearchResponse {
4 // handle success
5 } else if let error = error {
6 // handle error
7 }
8}

Additional data search is used to obtain geometries to represent the outline of a city, county, or land area. It supports batch requests for up to 20 identifiers per call. To build the Additional Data search request, use the AdditionalDataQueryBuilder that will produce AdditionalDataQuery. The only required parameter is a list of identifiers you want to get geometry for. To get these identifiers, first get the DataSources of the selected SearchResults of a Fuzzy Search. Then use its GeometryDataSources property to get the geometry ID.

Not every SearchResult has this information.

let geometryIds = searchResponse.results.compactMap { $0.dataSources?.geometry?.id }
let query = AdditionalDataQueryBuilder(geometriesID: geometryIds).with(zoomLvl: 15).build()

You can provide an optional zoom level parameter, which defines the precision of the returned geometries. For more information about the additional data search, go to the Search API Additional Data Search documentation.

The call returns an AdditionalDataResponse object, or an Error if the request did not succeed.

1let searchService = TomTomOnlineSearchService()
2searchService.additionalData(query: query) { additionalDataResponse, error in
3 if let additionalDataResponse = additionalDataResponse {
4 // handle success
5 } else if let error = error {
6 // handle error
7 }
8}