Skip to content

Geocoding Service

Maciej Mionskowski edited this page Mar 4, 2017 · 2 revisions

Geocoding is the process of converting addresses (like “1600 Amphitheatre Parkway, Mountain View, CA”) into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers on a map or position the map.

Geocoding endpoints

Creating Service

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	client := route4me.NewClient("your-api-key")
	service := &geocoding.Service{Client: client}
}

Forward Geocode Address

Forward geocoding is the process of converting place name information into latitude and longitude values.

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	client := route4me.NewClient("your-api-key")
	service := &geocoding.Service{Client: client}
	geo, err := service.ForwardAddress("Los20%Angeles20%International20%Airport,20%CA")
	if err != nil {
		//handle error
	}
	//do something with geo
}

Forward Geocode Addresses in Bulk

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	client := route4me.NewClient("your-api-key")
	service := &geocoding.Service{Client: client}
	resp, err := service.ForwardBulk([]Row{Row{Address:"someaddress"}})
	if err != nil {
		//handle error
	}
	//do something with the response
}

Reverse Geocode Address

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	client := route4me.NewClient("your-api-key")
	service := &geocoding.Service{Client: client}
	geo, err := service.ReverseAddress(33.945705, -118.391105)
	if err != nil {
		//handle error
	}
	//do something with geo
}

Rapid Geocoding endpoints

Creating Service

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	service := geocoding.NewRapidService("your-api-key")
}

Rapid Address Search

Single Address

Single address geocoding refers to the process of getting a geographic address by address name.

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	rapidService := geocoding.NewRapidService("your-api-key")
	addr, err := rapidService.GetSingleAddress(1)
	if err != nil {
		//handle error
	}
	//do something with an address
}

Get Addresses

This example refers to the process of getting all addresses.

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	rapidService := geocoding.NewRapidService("your-api-key")
	addrs, err := rapidService.GetAddresses()
	if err != nil {
		//handle error
	}
	//do something with an array of addresses
}

Get Limited Addresses

This example refers to the process of getting a limited number of the addresses. The limitation parameters are: offset and limit.

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	rapidService := geocoding.NewRapidService("your-api-key")
	//                                             limit, offset
	addrs, err := rapidService.GetLimitedAddresses(10,    5)
	if err != nil {
		//handle error
	}
	//do something with an array of addresses
}

Get Addresses by zipcode

This example refers to the process of getting all addresses containing a specified zip code.

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	rapidService := geocoding.NewRapidService("your-api-key")
	addrs, err := rapidService.GetAddressesByZipcode("00601")
	if err != nil {
		//handle error
	}
	//do something with an array of addresses
}

Get Limited Addresses by zipcode

This example refers to the process of getting all addresses containing a specified zip code.

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	rapidService := geocoding.NewRapidService("your-api-key")
	//                                                      zipcode, limit, offset
	addrs, err := rapidService.GetLimitedAddressesByZipcode("00601", 20,   0)
	if err != nil {
		//handle error
	}
	//do something with an array of addresses
}

Get Addresses by zipcode and house number

This example refers to the process of getting all addresses containing a specified zip code and house number.

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	rapidService := geocoding.NewRapidService("your-api-key")
	addrs, err := rapidService.GetAddressesByZipcodeAndHousenumber("00601", 17)
	if err != nil {
		//handle error
	}
	//do something with an array of addresses
}

Get limited Addresses by zipcode and house number

This example refers to the process of getting a limited number of addresses containing a specified zip code and house number.

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/geocoding"
)

func main() {
	rapidService := geocoding.NewRapidService("your-api-key")
	//                                                                       zipcode, housenumber, limit, offset
	addrs, err := rapidService.GetLimitedAddressesByZipcodeAndHousenumber("00601", 17,          0,     20);
	if err != nil {
		//handle error
	}
	//do something with an array of addresses
}
You can’t perform that action at this time.