Geocoding Demo

Requirements

  1. Implemented in Python
  2. Support Multiple Geocoding Services
  3. Implements Fallback To Backup Geocoding Services
  4. RESTful HTTP Interface
  5. JSON for Data Serialization
  6. Provides Documentation - How To Run The Service
  7. Provides Documentation - How To Use The Services API
  8. Uses git and github for for revision control

Non-Requirements

  1. Does Not Have To Be Performant or Scalable

Resources

  1. Geocoding Service by HERE
  2. Geocoding Service by Google

Build and Deployment

  1. [Optional Step] - Setup environment:
    vagrant plugin install vagrant-vbguest
    vagrant up
    vagrant ssh
    
    # FIXME make the following two sentences part of the Vagrantfile
    bash miniconda.sh -b
    PATH="${HOME}/miniconda3/bin:$PATH"
    
    cd /vagrant
  2. Setup the conda environment:
    conda env create -f conda_environment.yml
    source activate geocoding_demo
  3. Build the docker image.
    ansible-playbook --ask-vault-pass playbook.yml
  4. Provide the ansible vault password.
  5. The docker image will only get created if the unit tests succeed without any failure.
  6. Run the docker image.
    docker run -d -p 8000:8000 geocoding/demo
  7. The server should be running in the background.
  8. Execute the following sanity tests to check the http server:
    ./tests.sh http://localhost:8000

Usage

  1. The following query parameters need to be provided:
    1. latlng=latitude,longitude
    2. provider can be either google or here.

Google Provider:

curl 'localhost:8000/reverse_geocode?latlng=41.8842,-87.6388&provider=google' -v

Here Provider:

curl 'localhost:8000/reverse_geocode?latlng=41.8842,-87.6388&provider=here' -v

Running the Tests

  1. Run the unit tests:
python -m unittest tests
  1. Run the http server tests:
./tests.sh http://localhost:8000

Assumptions

  1. The server code doesn't have any dependencies other than Python3 standard libraries.
  2. However, there are some tools that will be needed on the host machine for the following purposes:
    1. Build / Deployment
      1. conda
      2. docker
    2. Sanity Tests (to check if the http server is properly running)
      1. bash
      2. curl
      3. jq
  3. config.ini.j2 is a jinja file which will eventually reside as config.ini where the real secrets need to be filled for the different providers.
    1. ansible provides the config.ini when building the docker image.
    2. If the config.ini is missing or incorrect - the docker image won't be built due to failing tests.
  4. Google provider is the fallback provider (the default provider could have been defined in the config.ini).
  5. Backend provider api usage
    1. Google api - provides the first street_address match found in the google api's json response.
    2. Here api - provides the first houseNumber match found in the here api's json response.
  6. The sample json responses can be found in the mock folder.