示例#1
0
func main() {
	gominatim.SetServer("http://nominatim.openstreetmap.org/")

	//Get by a Querystring
	qry := gominatim.SearchQuery{
		Q: "Hamburg",
	}
	resp, _ := qry.Get() // Returns []gominatim.Result
	fmt.Printf("Found location: %s (%s, %s)\n", resp[0].DisplayName, resp[0].Lat, resp[0].Lon)

	//Get by City
	qry = gominatim.SearchQuery{
		City: "Berlin",
	}
	resp, _ = qry.Get()
	fmt.Printf("Found location: %s (%s, %s)\n", resp[0].DisplayName, resp[0].Lat, resp[0].Lon)

	//Reverse Geocoding
	rqry := gominatim.ReverseQuery{
		Lat: "52.5170365",
		Lon: "13.3888599",
	}
	rresp, _ := rqry.Get()
	fmt.Printf("Found %s\n", rresp.DisplayName)
}
示例#2
0
文件: building.go 项目: momo-aux/void
func (b *Building) getGeoloc() {
	qry := new(gominatim.SearchQuery)
	qry.Q = b.Number + ", " + b.Street + ", " + b.City + ", " + b.Zip
	res, err := qry.Get()
	if err == nil {
		b.Lat = res[0].Lat
		b.Lat_f, _ = strconv.ParseFloat(b.Lat, 64)
		b.Lon = res[0].Lon
		b.Lon_f, _ = strconv.ParseFloat(b.Lon, 64)
	}
}