本文整理汇总了Golang中github.com/skypies/flightdb/gae.FlightDB.LookupSnapshotsAtTimestampUTC方法的典型用法代码示例。如果您正苦于以下问题:Golang FlightDB.LookupSnapshotsAtTimestampUTC方法的具体用法?Golang FlightDB.LookupSnapshotsAtTimestampUTC怎么用?Golang FlightDB.LookupSnapshotsAtTimestampUTC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skypies/flightdb/gae.FlightDB
的用法示例。
在下文中一共展示了FlightDB.LookupSnapshotsAtTimestampUTC方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: queryHandler
func queryHandler(w http.ResponseWriter, r *http.Request) {
if r.FormValue("date") == "" && r.FormValue("epoch") == "" {
var params = map[string]interface{}{
"TwoHoursAgo": date.NowInPdt().Add(-2 * time.Hour),
}
if err := templates.ExecuteTemplate(w, "fdb-queryform", params); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
return
}
c := appengine.NewContext(r)
db := fdb.FlightDB{C: c, Memcache: true}
var t time.Time
if r.FormValue("epoch") != "" {
if epoch, err := strconv.ParseInt(r.FormValue("epoch"), 10, 64); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} else {
t = time.Unix(epoch, 0)
}
} else {
var err2 error
t, err2 = date.ParseInPdt("2006/01/02 15:04:05", r.FormValue("date")+" "+r.FormValue("time"))
if err2 != nil {
http.Error(w, err2.Error(), http.StatusInternalServerError)
return
}
}
var refPoint *geo.Latlong = nil
if r.FormValue("lat") != "" {
refPoint = &geo.Latlong{}
var err error
if refPoint.Lat, err = strconv.ParseFloat(r.FormValue("lat"), 64); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if refPoint.Long, err = strconv.ParseFloat(r.FormValue("long"), 64); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
if snapshots, err := db.LookupSnapshotsAtTimestampUTC(t.UTC(), refPoint, 1000); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
} else {
var params = map[string]interface{}{
"Legend": buildLegend(t),
"SearchTimeUTC": t.UTC(),
"SearchTime": date.InPdt(t),
"Flights": snapshots2params(snapshots),
"FlightsJS": ftype.FlightSnapshotSet(snapshots).ToJSVar(),
"MapsAPIKey": kGoogleMapsAPIKey,
"Center": sfo.KLatlongSERFR1,
"Zoom": 9,
// "CaptureArea": fdb.KBoxSFO120K, // comment out, as we don't want it in this view
}
if r.FormValue("resultformat") == "json" {
for i, _ := range snapshots {
snapshots[i].F.Track = nil
snapshots[i].F.Tracks = nil
}
js, err := json.Marshal(snapshots)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
w.Write(js)
} else {
templateName := "fdb-queryresults-map"
if r.FormValue("resultformat") == "list" {
templateName = "fdb-queryresults-list"
}
if err := templates.ExecuteTemplate(w, templateName, params); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
}
}