本文整理汇总了Golang中github.com/skypies/flightdb/gae.FlightDB.LookupById方法的典型用法代码示例。如果您正苦于以下问题:Golang FlightDB.LookupById方法的具体用法?Golang FlightDB.LookupById怎么用?Golang FlightDB.LookupById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skypies/flightdb/gae.FlightDB
的用法示例。
在下文中一共展示了FlightDB.LookupById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: idspecsToFlightV2s
func idspecsToFlightV2s(r *http.Request) ([]*newfdb.Flight, error) {
c := oldappengine.NewContext(r)
db := oldfgae.FlightDB{C: c}
newFlights := []*newfdb.Flight{}
idspecs, err := FormValueIdSpecs(r)
if err != nil {
return newFlights, err
}
for _, idspec := range idspecs {
oldF, err := db.LookupById(idspec)
if err != nil {
return newFlights, err
} else if oldF == nil {
return newFlights, fmt.Errorf("flight '%s' not found", idspec)
}
newF, err := oldF.V2()
if err != nil {
return newFlights, err
}
newFlights = append(newFlights, newF)
}
return newFlights, nil
}
示例2: idspecsToMapLines
func idspecsToMapLines(r *http.Request) ([]newui.MapLine, error) {
c := oldappengine.NewContext(r)
db := oldfgae.FlightDB{C: c}
lines := []newui.MapLine{}
idspecs, err := FormValueIdSpecs(r)
if err != nil {
return lines, err
}
for _, idspec := range idspecs {
oldF, err := db.LookupById(idspec)
if err != nil {
return lines, err
} else if oldF == nil {
return lines, fmt.Errorf("flight '%s' not found", idspec)
}
newF, err := oldF.V2()
if err != nil {
return lines, err
}
flightLines := newui.FlightToMapLines(newF)
lines = append(lines, flightLines...)
}
return lines, nil
}
示例3: lookupHandler
func lookupHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
db := fdb.FlightDB{C: c}
id := r.FormValue("id")
if f, err2 := db.LookupById(id); err2 != nil {
c.Errorf(" /mdb/lookup: %v", err2)
http.Error(w, err2.Error(), http.StatusInternalServerError)
} else if f == nil {
http.Error(w, fmt.Sprintf("id=%s not found", id), http.StatusInternalServerError)
} else {
c.Infof("Tags: %v, Tracks: %v", f.TagList(), f.TrackList())
_, classBTrack := f.SFOClassB("", nil)
f.Analyse() // Repopulate the flight tags; useful when debugging new analysis stuff
// Todo: collapse all these separate tracks down into the single point/line list thing
fr24TrackJSVar := classBTrack.ToJSVar()
// For Flightaware tracks
//faClassBTrack := fdb.ClassBTrack{}
faTrackJSVar := template.JS("{}")
if _, exists := f.Tracks["FA"]; exists == true {
_, faClassBTrack := f.SFOClassB("FA", nil)
faTrackJSVar = faClassBTrack.ToJSVar()
//fr24TrackJSVar = template.JS("{}")
}
// For ADS-B tracks !
adsbTrackJSVar := template.JS("{}")
if _, exists := f.Tracks["ADSB"]; exists == true {
_, adsbClassBTrack := f.SFOClassB("ADSB", nil)
adsbTrackJSVar = adsbClassBTrack.ToJSVar()
}
skimTrackJSVar := template.JS("{}")
if r.FormValue("skim") != "" {
alttol, _ := strconv.ParseFloat(r.FormValue("alttol"), 64)
mindist, _ := strconv.ParseFloat(r.FormValue("mindist"), 64)
skimTrack, _ := f.BestTrack().SkimsToSFO(alttol, mindist, 15.0, 40.0)
skimTrackJSVar = skimTrack.ToJSVar()
fr24TrackJSVar = template.JS("{}")
faTrackJSVar = template.JS("{}")
adsbTrackJSVar = template.JS("{}")
}
mapPoints := []MapPoint{}
mapLines := []MapLine{}
// &waypoint=EPICK
if waypoint := r.FormValue("waypoint"); waypoint != "" {
//pos := geo.Latlong{37.060312, -121.990814}
pos := sfo.KFixes[waypoint]
if itp, err := f.BestTrack().PointOfClosestApproach(pos); err != nil {
c.Infof(" ** Error: %v", err)
} else {
mapPoints = append(mapPoints, MapPoint{Icon: "red", ITP: &itp})
mapPoints = append(mapPoints, MapPoint{Pos: &itp.Ref, Text: "** Reference point"})
mapLines = append(mapLines, MapLine{Line: &itp.Line, Color: "#ff8822"})
mapLines = append(mapLines, MapLine{Line: &itp.Perp, Color: "#ff2288"})
}
}
// &boxes=1
if r.FormValue("boxes") != "" {
if true {
// fr24
for _, box := range f.Track.AsContiguousBoxes() {
mapLines = append(mapLines, LatlongTimeBoxToMapLines(box, "#118811")...)
}
}
if t, exists := f.Tracks["FA"]; exists == true {
for _, box := range t.AsContiguousBoxes() {
mapLines = append(mapLines, LatlongTimeBoxToMapLines(box, "#1111aa")...)
}
}
if t, exists := f.Tracks["ADSB"]; exists == true {
for _, box := range t.AsContiguousBoxes() {
mapLines = append(mapLines, LatlongTimeBoxToMapLines(box, "#aaaa11")...)
}
}
}
pointsStr := "{\n"
for i, mp := range mapPoints {
pointsStr += fmt.Sprintf(" %d: {%s},\n", i, mp.ToJSStr(""))
}
pointsJS := template.JS(pointsStr + " }\n")
linesStr := "{\n"
for i, ml := range mapLines {
linesStr += fmt.Sprintf(" %d: {%s},\n", i, ml.ToJSStr(""))
}
linesJS := template.JS(linesStr + " }\n")
box := sfo.KBoxSFO120K
if r.FormValue("report") == "level" {
box = sfo.KBoxPaloAlto20K
} else if r.FormValue("report") == "stack" {
//.........这里部分代码省略.........