Geocoding Demo
Requirements
Implemented in Python
Support Multiple Geocoding Services
Implements Fallback To Backup Geocoding Services
RESTful HTTP Interface
JSON for Data Serialization
Provides Documentation - How To Run The Service
Provides Documentation - How To Use The Services API
Uses git and github for for revision control
Non-Requirements
Does Not Have To Be Performant or Scalable
Resources
Geocoding Service by HERE
Geocoding Service by Google
Build and Deployment
[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
Setup the conda environment:
conda env create -f conda_environment.yml
source activate geocoding_demo
Build the docker image.
ansible-playbook --ask-vault-pass playbook.yml
Provide the ansible vault password.
The docker image will only get created if the unit tests succeed without any failure.
Run the docker image.
docker run -d -p 8000:8000 geocoding/demo
The server should be running in the background.
Execute the following sanity tests to check the http server:
./tests.sh http://localhost:8000
Usage
The following query parameters need to be provided:
latlng=latitude,longitude
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
Run the unit tests:
Run the http server tests:
./tests.sh http://localhost:8000
Assumptions
The server code doesn't have any dependencies other than Python3 standard libraries.
However, there are some tools that will be needed on the host machine for the following purposes:
Build / Deployment
conda
docker
Sanity Tests (to check if the http server is properly running)
bash
curl
jq
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.
ansible
provides the config.ini
when building the docker image.
If the config.ini
is missing or incorrect - the docker image won't be built due to failing tests.
Google provider is the fallback provider (the default provider could have been defined in the config.ini
).
Backend provider api usage
Google api - provides the first street_address
match found in the google api's json response.
Here api - provides the first houseNumber
match found in the here api's json response.
The sample json responses can be found in the mock
folder.