func makeGeoRect(lat, lon, radius float64) (rtreego.Rect, error) { earth := float64(6371000) dlat := (radius / (math.Pi * earth)) * 180.0 r := earth * math.Cos((math.Pi*lat)/180.0) dlon := (radius / (math.Pi * r)) * 180. lon -= dlon lat -= dlat return rtreego.NewRect(rtreego.Point{lon, lat}, [2]float64{2 * dlon, 2 * dlat}) }
func makeOfferLocation(id string, date time.Time, loc *Location) ( *OfferLoc, error) { if loc == nil { return nil, nil } lon := loc.Lon - locExtent[0]/2 lat := loc.Lat - locExtent[1]/2 rect, err := rtreego.NewRect(rtreego.Point{lon, lat}, locExtent) if err != nil { return nil, err } return &OfferLoc{ Id: id, Date: date, Loc: rect, Point: Point{ Lon: loc.Lon, Lat: loc.Lat, }, }, nil }