Skip to content

A simple network service that can resolve the lat, lng coordinates for an address by using third party geocoding services

License

Notifications You must be signed in to change notification settings

VBot2410/Geocoding-Proxy-Service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Geocoding-Proxy-Service

A simple network service that can resolve the lat, lng coordinates for an address by using third party geocoding services and RESTFul HTTP Interface.

Codacy Badge License: MIT

Overview

Geocoding is the process of converting addresses (like a street address) into geographic coordinates (like latitude and longitude), which you can use to place markers on a map, or position the map.
This package provides a service that resolves the latitude and longitude for a given address using Google Maps Geocoding service, and uses HERE geocoding as a fallback if Google fails to resolve the address.

Geocoding Services Used

1. Google Maps API: More info on Google Maps Geocoder API can be found here
2. HERE Geocoder API: More info on HERE Geocoder API can be found here

This project was developed using Python3.5 and tested on a Ubuntu 16.04 LTS system.

Disclaimer

MIT License

Copyright (c) 2018 Vaibhav Bhilare

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. © 2018 GitHub, Inc.

Dependencies

This project uses standard python 3.5 libraries and hence do not require any third-party libraries to work. List of standard libraries used is as follows:

  • json
  • argparse
  • http.server
  • urllib.request

Repository Cloning & Running the Server (Tested on Ubuntu 16.04 LTS with Python3.5)

Cloning

git clone --recursive https://github.com/VBot2410/Geocoding-Proxy-Service.git

Exporting the API Keys as environment variables

In order to use the Google and HERE APIs, API keys are required which can be obtained from their websites linked above. After getting these keys, follow these instructions(For Ubuntu Systems):

echo -e "\nexport GOOGLE_KEY=\"<RECEIVED KEY>\"">>~/.bashrc
echo -e "\nexport HERE_APP_ID=\"<RECEIVED APP ID>\"">>~/.bashrc
echo -e "\nexport HERE_APP_CODE=\"<RECEIVED APP CODE>\"">>~/.bashrc

These will store the API keys in .bashrc and can be imported on that local machine as environment variables.

Running the Server

After exporting the keys as environment variables, follow these instructions:

cd Geocoding-Proxy-Service
python3 main.py

This will start the server with default host 127.0.0.1 and port 5000.
You can also specify the server host and port using --host and --port arguments as follows:

python3 main.py --host 0.0.0.0 --port 8000

This will start the server with host 0.0.0.0 and port 8000
For more information, use -h argument as follows:

python3 main.py -h

Querying

After starting the server, service API can be called by using GET method and specifying address field using following URL syntax:

HOST:PORT/geocode?address=ADDRESS

Where HOST and PORT is the host and port used for launching the server in the previous step.

Sample Output

For the query, output similar to this will be shown:
Query:
http://127.0.0.1:5000/geocode?address=1600%20Amphitheatre%20Parkway%20Mountain%20View,%20CA%2094043
Output:
{"API": "google", "status": "OK", "lng": -122.0856086, "lat": 37.4224082}

Future Scope

  1. Adding support for more APIs
  2. Adding support for more RESTful HTTP interface methods like PUT, POST.

About

A simple network service that can resolve the lat, lng coordinates for an address by using third party geocoding services

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages