예제 #1
0
파일: point.go 프로젝트: OpenZilia/parsemap
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
}
예제 #2
0
파일: point.go 프로젝트: OpenZilia/parsemap
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
}