Example #1
0
func processLatLon(latLon string) (string, error) {
	latLonSplit := strings.Split(latLon, ",")
	if len(latLonSplit) != 2 {
		return "", fmt.Errorf("'%s'' is not a valid location (lat,lon)", latLon)
	}

	lat, err := strconv.ParseFloat(latLonSplit[0], 64)
	if err != nil {
		return "", err
	}

	lon, err := strconv.ParseFloat(latLonSplit[1], 64)
	if err != nil {
		return "", err
	}

	var gh string
	if flagPrecision > 0 {
		gh = geohash.Encode(lat, lon, flagPrecision)
	} else {
		gh = geohash.EncodeAuto(lat, lon)
	}
	return gh, nil
}
Example #2
0
func (_ Test) GeoHash() {
	lat := 56.162939
	long := 10.203921
	hash := geohash.EncodeAuto(lat, long)
	e.InfoLog.Println(hash)
}