Use Google Maps Geocoding API to calculate distances between two addresses of a collection of persons.
We're using the Google API only to geocode an address and viceversa (reverse geocoding). The haversine formula is used to calculate the distance between two addresses in order to keep API calls to a minimum.
See e-commuter.pdf
for more details.
Download a Postal Code collection from Geonames and use it as you please. Please keep in mind that duplicates will generate an exception. I've used a SQL database to clean down the Italian file.
Set API_KEY
environment variable with your Google Maps API Key.
Launch the application and use the included Postman collection to interact with the API.
- Load a territories set (or use the included
geo_data.csv
) - Add the persons included in
persons.txt
- Locate nearby persons
- Play with addresses and geo coordinates to fetch addresses from Google Geocode API
- Create a work address invoking endpoint
addressToGeo
, in the JSON specify the formatted address string, the other parameters are not necessary - Create a home address as above
- Paste the above addresses into the fields workAddress and homeAddress of a Person object and send to endpoint
addPerson
- Repeat previous steps for various persons living and working nearby
- Send one of the created persons to
nearbyPersons
with the desired radius to extract a list of Persons living and working nearby
See e-commuter-generator to generate data programmatically.
Automated documentation provided by Swagger: API Documentation
Spring Boot actuators are deployed, set the management.port
parameter in application.properties
:
- http://your_ip:management.port/beans
- http://your_ip:management.port/metrics
- http://your_ip:management.port/autoconfig
Any class that references org.systemexception.ecommuter.services.LocationImpl
will produce logs with your google
api key, remember to use the spring context to disable the logs if using public repositories or continuous
integration services.
Logging in test application.properties
has been disabled for class org.systemexception.ecommuter.services.GeoApi
to hide the api key in Travis logs, re-enable in local environment for debugging or analysis.
This implies that the Spring context has to be booted in order to read the properties file and disable the Google logging, add the necessary configuration annotations to every impacted test or class:
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {Application.class})
@TestPropertySource(locations = "classpath:application.properties")
In sparse order:
- Add google api key in properties file if needed, otherwise fetch key from environment variable
- Frontend
- Investigate Google Directions API to calculate distance with different travel types (foot, bike, transport)
- Pending
spring-boot-starter-data-neo4j
release for refactor - Add export functionality
- Add endpoints to query database data
- Upgrade Neo4J 4.x
- Geonames for the Postal Code Database