Specialized search

VERSION 0.2.2822
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 to create AlongRouteQuery. 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 = AlongRouteQuery(
3 query: query,
4 route: route,
5 maxDetourTime: .tt.seconds(600),
6 limit: 10
7)

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.

1onlineSearch.searchAlongRoute(query: alongRouteSearchQuery) { result in
2 switch result {
3 case let .success(alongRouteResponse):
4 // handle success
5 break
6 case let .failure(error):
7 // handle error
8 break
9 }
10}

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.

.

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

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

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

1let onlineSearch = OnlineSearch(apiKey: "REPLACE_WITH_YOUR_API_KEY")
2onlineSearch.requestEvChargingStationsAvailability(query: query) { result in
3 switch result {
4 case let .success(response):
5 // handle success
6 break
7 case let .failure(error):
8 // handle error
9 break
10 }
11}

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:

  • PolygonGeometry - 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 polygon = PolygonGeometry(vertices: vertices)
  • CircleGeometry - center coordinates and a radius in meters.
    .

Provide the geometries and query to initialize the SearchQuery by defining the searchAreas parameter.. 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.

let query = SearchQuery("Pizza", searchAreas: polygon)

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

1let onlineSearch = OnlineSearch(apiKey: "REPLACE_WITH_YOUR_API_KEY")
2onlineSearch.search(query: query) { result in
3 switch result {
4 case let .success(geometrySearchResponse):
5 // handle success
6 break
7 case let .failure(error):
8 // handle error
9 break
10 }
11}

Geometry 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 Geometry Data search request, use the GeometryDataQuery. 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.

.

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 GeometryDataResponse object, or an Error if the request did not succeed.

1let onlineSearch = OnlineSearch(apiKey: "REPLACE_WITH_YOUR_API_KEY")
2onlineSearch.requestGeometryData(query: query) { result in
3 switch result {
4 case let .success(additionalDataResponse):
5 // handle success
6 break
7 case let .failure(error):
8 // handle error
9 break
10 }
11}