// Leave icaoid as empty string to get all complaints; else limits to that aircraft func (cdb ComplaintDB) GetComplaintPositionsInSpanByIcao(start, end time.Time, icaoid string) ([]geo.Latlong, error) { ret := []geo.Latlong{} q := datastore. NewQuery(kComplaintKind). Project("Profile.Lat", "Profile.Long"). Filter("Timestamp >= ", start). Filter("Timestamp < ", end) if icaoid != "" { cdb.Infof("Oho, adding id2=%s", icaoid) q = q.Filter("AircraftOverhead.Id2 = ", icaoid) } q = q.Limit(-1) var data = []types.Complaint{} if _, err := q.GetAll(cdb.Ctx(), &data); err != nil { return ret, err } for _, c := range data { // Round off the position data to a certain level of precision lat, long := toFixed(c.Profile.Lat, 2), toFixed(c.Profile.Long, 2) pos := geo.Latlong{Lat: lat, Long: long} if !pos.IsNil() { ret = append(ret, pos) } } return ret, nil }