Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 2.9 KB

README.md

File metadata and controls

59 lines (43 loc) · 2.9 KB

Feature collector "Geolocation-fc"

Version: 1.0

Date: 15.02.2022

Authors: Milan Straka, Ľuboš Buzna; Address: University of Žilina, Univerzitná 8215/1, 010 26 Žilina, Slovakia

Description

Feature collector extracts records from the Offer-cache containing geographical coordinates and translates them using the Nominatim service into city names. Only records required by the Thor ranker are translated. The city names are then written back to the Offer-cache.

The post request is calling the method compute from the "geolocation-fc.py". The API takes the coordinates stored in list geo_attribute_list of class GeolocationManager and extracts them from the Offer-Cache. The coordinates are rounded to 3 decimal spaces. The rounded coordinates are translated to city names using Nominatim api. All the coordinates (not rounded) are writen to the Offer-Cache under the key formated as request_id:city_coordinates:longitude:latitude. with the city name as the value. The classes implementing the feature collector are stored in scripts "communicators.py" and "geolocators.py" in the folder codes.

Configuration

The following values of parameters can be defined in the configuration file "geolocation-fc.conf".

Section "running":

  • "verbose" - if value "1" is used, then feature collector is run in the verbose mode

Section "cache":

  • "host" - host address where the Offer-cache service is available
  • "port" - port number where the Offer-cache service is available

Section "nominatim_options":

  • "domain" - Domain of the Nominatim service. If value "default" is used, then the public Nominatim service is used.
  • "user" - User_agent to be sent to the public Nominatim service. If value "default" is used, then the user_agent is randomly generated for each request. This can help improve the response as the public Nomination service limits the number of responses per user_agent.

Usage

The API listens at "/compute" URL path and the port configured in the config file. The request should have the following parameters in the data part:

  • "request_id" - request identifier
  • "geo_attributes" - list of attribute names to be translated

An example of the POST request:

curl -X POST http://127.0.0.1:5015/compute -d '{"request_id": "123x", "geo_attributes": ["start_point", "end_point", "via_locations"]}' \
     -H "Content-Type: application/json"

Responses

  • If everything went fine, API returns JSON and 200 response code.
  • If there is a wrong geo attribute name, API returns JSON reason with 400 response code
  • In case of bad input data API returns 400 response code.
  • If the writing or reading the cache fails, API returns 500 response code.