Code Coverage
A geocoding service developed in Go's way, idiomatic and elegant, not just in golang.
This product is designed to open to any Geocoding service. Based on it,
- Google Maps
- MapQuest
- OpenCage
- HERE
- Bing
- Mapbox
- OpenStreetMap
- PickPoint
- LocationIQ
- ArcGIS
- geocodio
- Mapzen
- TomTom
- Yandex.Maps
- French API Gouv
clients are implemented in ~50 LoC each.
It allows you to switch from one service to another by changing only 1 line, or enjoy all the free quota (requests/sec, day, month...) from them at the same time. Just like this.
package main
import (
"fmt"
"os"
"github.com/codingsince1985/geo-golang"
"github.com/codingsince1985/geo-golang/arcgis"
"github.com/codingsince1985/geo-golang/bing"
"github.com/codingsince1985/geo-golang/chained"
"github.com/codingsince1985/geo-golang/frenchapigouv"
"github.com/codingsince1985/geo-golang/geocod"
"github.com/codingsince1985/geo-golang/google"
"github.com/codingsince1985/geo-golang/here"
"github.com/codingsince1985/geo-golang/locationiq"
"github.com/codingsince1985/geo-golang/mapbox"
"github.com/codingsince1985/geo-golang/mapquest/nominatim"
"github.com/codingsince1985/geo-golang/mapquest/open"
"github.com/codingsince1985/geo-golang/mapzen"
"github.com/codingsince1985/geo-golang/opencage"
"github.com/codingsince1985/geo-golang/openstreetmap"
"github.com/codingsince1985/geo-golang/pickpoint"
"github.com/codingsince1985/geo-golang/tomtom"
"github.com/codingsince1985/geo-golang/yandex"
)
const (
addr = "Melbourne VIC"
lat, lng = -37.813611, 144.963056
radius = 50
zoom = 18
addrFR = "Champs de Mars Paris"
latFR, lngFR = 48.854395, 2.304770
)
func main() {
ExampleGeocoder()
}
// ExampleGeocoder demonstrates the different geocoding services
func ExampleGeocoder() {
fmt.Println("Google Geocoding API")
try(google.Geocoder(os.Getenv("GOOGLE_API_KEY")))
fmt.Println("Mapquest Nominatim")
try(nominatim.Geocoder(os.Getenv("MAPQUEST_NOMINATIM_KEY")))
fmt.Println("Mapquest Open streetmaps")
try(open.Geocoder(os.Getenv("MAPQUEST_OPEN_KEY")))
fmt.Println("OpenCage Data")
try(opencage.Geocoder(os.Getenv("OPENCAGE_API_KEY")))
fmt.Println("HERE API")
try(here.Geocoder(os.Getenv("HERE_APP_ID"), os.Getenv("HERE_APP_CODE"), radius))
fmt.Println("Bing Geocoding API")
try(bing.Geocoder(os.Getenv("BING_API_KEY")))
fmt.Println("Mapbox API")
try(mapbox.Geocoder(os.Getenv("MAPBOX_API_KEY")))
fmt.Println("OpenStreetMap")
try(openstreetmap.Geocoder())
fmt.Println("PickPoint")
try(pickpoint.Geocoder(os.Getenv("PICKPOINT_API_KEY")))
fmt.Println("LocationIQ")
try(locationiq.Geocoder(os.Getenv("LOCATIONIQ_API_KEY"), zoom))
fmt.Println("ArcGIS")
try(arcgis.Geocoder(os.Getenv("ARCGIS_TOKEN")))
fmt.Println("geocod.io")
try(geocod.Geocoder(os.Getenv("GEOCOD_API_KEY")))
fmt.Println("Mapzen")
try(mapzen.Geocoder(os.Getenv("MAPZEN_API_KEY")))
fmt.Println("TomTom")