Beispiel #1
0
func createPoint(request *createPointRequest) (string, error) {
	identifier := newUUID()

	geohash := geohash.GeohashFromCoordinates(request.Latitude, request.Longitude)

	if _, err := db.Exec("select * from create_point($1, $2, $3, $4, $5, $6, $7, $8)", identifier, geohash, request.Latitude, request.Longitude, request.Name, request.Provider, request.ProviderId, request.version); err != nil {
		return "", err
	}
	return identifier, nil
}
Beispiel #2
0
func updatePoint(request *updatePointRequest) error {
	if request.Latitude.Valid == false || request.Longitude.Valid == false {
		request.Latitude.Valid = false
		request.Longitude.Valid = false
	}

	var geohashString null.String = null.NewString("", false)
	if request.Latitude.Valid == true && request.Longitude.Valid == true {
		geohashString.SetValid(geohash.GeohashFromCoordinates(request.Latitude.Float64, request.Longitude.Float64))
	}

	_, err := db.Exec("select update_point($1, $2, $3, $4, $5, $6, $7)", request.point, request.Name, request.Point, geohashString, request.Latitude, request.Longitude, request.NoEvent)
	if err != nil {
		return err
	}
	return nil
}