本文整理汇总了Golang中github.com/skypies/flightdb/gae.FlightDB类的典型用法代码示例。如果您正苦于以下问题:Golang FlightDB类的具体用法?Golang FlightDB怎么用?Golang FlightDB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FlightDB类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:hugoh,项目名称:complaints,代码行数:26,代码来源:v2ui.go
示例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
}
开发者ID:hugoh,项目名称:complaints,代码行数:28,代码来源:v2ui.go
示例3: decodetrackHandler
func decodetrackHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
db := fdb.FlightDB{C: c}
icao := r.FormValue("icaoid")
callsign := strings.TrimSpace(r.FormValue("callsign"))
if icao == "" || callsign == "" {
http.Error(w, "need args {icaoid,callsign}", http.StatusInternalServerError)
return
}
if tracks, err := db.ReadTrackFragments(icao, callsign); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} else {
var params = map[string]interface{}{
"Tracks": tracks,
"Callsign": callsign,
"Icao24": icao,
}
if err := templates.ExecuteTemplate(w, "fdb-decodetrack", params); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
}
开发者ID:hugoh,项目名称:complaints,代码行数:25,代码来源:fdb.go
示例4: addtrackHandler
func addtrackHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
db := fdb.FlightDB{C: c}
icaoId := r.FormValue("icaoid")
callsign := strings.TrimSpace(r.FormValue("callsign"))
tStr := r.FormValue("track")
// Validate it works before persisting
t := ftype.Track{}
if err := t.Base64Decode(tStr); err != nil {
c.Errorf(" /mdb/addtrack: decode failed: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
}
ftf := ftype.FrozenTrackFragment{
TrackBase64: tStr,
Callsign: callsign,
Icao24: icaoId,
}
if err := db.AddTrackFrgament(ftf); err != nil {
c.Errorf(" /mdb/addtrack: db.AddTrackFragment failed: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
}
// 3. Routine to merge track fragments ? Extra credit ?
// c.Infof(" /mdb/addtrack: added %d points for [%s][%s]", len(t), icaoId, callsign)
w.Write([]byte(fmt.Sprintf("Added %d for %s\n", len(t), icaoId)))
}
开发者ID:hugoh,项目名称:complaints,代码行数:30,代码来源:fdb.go
示例5: skimmerReport
func skimmerReport(c appengine.Context, s, e time.Time, opt ReportOptions) ([]ReportRow, ReportMetadata, error) {
meta := ReportMetadata{}
fdb := fdb.FlightDB{C: c}
maybeMemcache(&fdb, e)
tags := []string{flightdb.KTagSERFR1}
if flights, err := fdb.LookupTimeRangeByTags(tags, s, e); err != nil {
return nil, nil, err
} else {
out := []ReportRow{}
for _, f := range flights {
t := f.BestTrack()
_, analysis := t.SkimsToSFO(opt.Skimmer_AltitudeTolerance, opt.Skimmer_MinDurationNM, 14.5, 50)
// Output one row per event, in a kind of hacky way
extras := fmt.Sprintf("&skim=1&alttol=%.0f&mindist=%.0f", opt.Skimmer_AltitudeTolerance,
opt.Skimmer_MinDurationNM)
for _, event := range analysis.Events {
row := SkimRow{Url: flight2Url(f) + template.HTML(extras), F: f, Source: t.LongSource(), A: analysis}
row.A.Events = []flightdb.SkimEvent{event}
out = append(out, row)
}
}
return out, meta, nil
}
}
开发者ID:hugoh,项目名称:complaints,代码行数:28,代码来源:reports.go
示例6: brixxViolationReport
func brixxViolationReport(c appengine.Context, s, e time.Time, opt ReportOptions) ([]ReportRow, ReportMetadata, error) {
meta := ReportMetadata{}
fdb := fdb.FlightDB{C: c}
maybeMemcache(&fdb, e)
tags := []string{flightdb.KTagBRIXX}
if flights, err := fdb.LookupTimeRangeByTags(tags, s, e); err != nil {
return nil, nil, err
} else {
out := []ReportRow{}
// Hmm. Really need a better way to link 'violations in this report' to dots on the map
for _, f := range flights {
t := f.BestTrack()
for i, tp := range t {
if tp.Latlong.DistNM(sfo.KLatlongSJC) > 20 {
continue
}
if tp.AltitudeFeet < 5500 && tp.Latlong.Long < sfo.KFixes["YADUT"].Long {
row := BrixxRow{
Url: flight2Url(f),
F: f,
Source: t.LongSource(),
TP: &t[i],
}
out = append(out, row)
break
}
}
}
return out, meta, nil
}
}
开发者ID:hugoh,项目名称:complaints,代码行数:33,代码来源:reports.go
示例7: jobTrackTimezoneHandler
func jobTrackTimezoneHandler(r *http.Request, f *oldfdb.Flight) (string, error) {
c := appengine.NewContext(r)
defaultTP := f.Track.ClosestTrackpoint(sfo.KFixes["EPICK"])
adsbTP := f.Tracks["ADSB"].ClosestTrackpoint(sfo.KFixes["EPICK"])
trackTimeDelta := defaultTP.TimestampUTC.Sub(adsbTP.TimestampUTC)
str := fmt.Sprintf("OK, looked up %s\n Default: %s\n ADSB : %s\n delta: %s\n",
f, defaultTP, adsbTP, trackTimeDelta)
if trackTimeDelta < -4*time.Hour || trackTimeDelta > 4*time.Hour {
str += fmt.Sprintf("* recoding\n* before: %s\n", f.Tracks["ADSB"])
for i, _ := range f.Tracks["ADSB"] {
f.Tracks["ADSB"][i].TimestampUTC = f.Tracks["ADSB"][i].TimestampUTC.Add(time.Hour * -8)
}
str += fmt.Sprintf("* after : %s\n", f.Tracks["ADSB"])
db := oldfgae.FlightDB{C: oldappengine.NewContext(r)}
if err := db.UpdateFlight(*f); err != nil {
log.Errorf(c, "Persist Flight %s: %v", f, err)
return str, err
}
log.Infof(c, "Updated flight %s", f)
str += fmt.Sprintf("--\nFlight was updated\n")
} else {
log.Debugf(c, "Skipped flight %s, delta=%s", f, trackTimeDelta)
str += "--\nFlight was OK, left untouched\n"
}
return str, nil
}
开发者ID:hugoh,项目名称:complaints,代码行数:33,代码来源:flight-batch.go
示例8: jobV2adsbHandler
func jobV2adsbHandler(r *http.Request, f *oldfdb.Flight) (string, error) {
c := appengine.NewContext(r)
str := ""
if f.HasTrack("ADSB") {
return "", nil
} // Already has one
err, deb := f.GetV2ADSBTrack(urlfetch.Client(c))
str += fmt.Sprintf("*getv2ADSB [%v]:-\n", err, deb)
if err != nil {
return str, err
}
if !f.HasTrack("ADSB") {
return "", nil
} // Didn't find one
f.Analyse() // Retrigger Class-B stuff
db := oldfgae.FlightDB{C: oldappengine.NewContext(r)}
if err := db.UpdateFlight(*f); err != nil {
log.Errorf(c, "Persist Flight %s: %v", f, err)
return str, err
}
log.Infof(c, "Updated flight %s", f)
str += fmt.Sprintf("--\nFlight was updated\n")
return str, nil
}
开发者ID:hugoh,项目名称:complaints,代码行数:30,代码来源:flight-batch.go
示例9: brixx1Report
func brixx1Report(c appengine.Context, s, e time.Time, opt ReportOptions) ([]ReportRow, ReportMetadata, error) {
meta := ReportMetadata{}
fdb := fdb.FlightDB{C: c}
maybeMemcache(&fdb, e)
tags := []string{flightdb.KTagBRIXX}
if flights, err := fdb.LookupTimeRangeByTags(tags, s, e); err != nil {
return nil, nil, err
} else {
out := []ReportRow{}
meta["[A] Total BRIXX flights "] = float64(len(flights))
for _, f := range flights {
hasAdsb := false
if _, exists := f.Tracks["ADSB"]; exists == true {
meta["[B] With data from "+f.Tracks["ADSB"].LongSource()]++
}
if t, exists := f.Tracks["FA"]; exists == true {
meta["[B] With data from "+f.Tracks["FA"].LongSource()]++
hasAdsb = t.IsFromADSB()
} else {
meta["[B] With data from "+f.Track.LongSource()]++
}
row := SERFR1Row{flight2Url(f), f, hasAdsb, false}
out = append(out, row)
}
return out, meta, nil
}
}
开发者ID:hugoh,项目名称:complaints,代码行数:32,代码来源:reports.go
示例10: batchFlightScanHandler
// This enqueues tasks for each individual day, or flight
func batchFlightScanHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
tags := []string{} //"ADSB"} // Maybe make this configurable ...
n := 0
str := ""
s, e, _ := widget.FormValueDateRange(r)
job := r.FormValue("job")
if job == "" {
http.Error(w, "Missing argument: &job=foo", http.StatusInternalServerError)
}
days := date.IntermediateMidnights(s.Add(-1*time.Second), e) // decrement start, to include it
for _, day := range days {
// Get the keys for all the flights on this day.
fdb := oldfgae.FlightDB{C: oldappengine.NewContext(r)}
dStart, dEnd := date.WindowForTime(day)
dEnd = dEnd.Add(-1 * time.Second)
keys, err := fdb.KeysInTimeRangeByTags(tags, dStart, dEnd)
if err != nil {
log.Errorf(c, "upgradeHandler: enqueue: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
singleFlightUrl := "/backend/fdb-batch/flight"
for _, key := range keys {
str += fmt.Sprintf("Enqueing day=%s: %s?job=%s&key=%s\n",
day.Format("2006.01.02"), singleFlightUrl, job, key.Encode())
t := taskqueue.NewPOSTTask(singleFlightUrl, map[string][]string{
"date": {day.Format("2006.01.02")},
"key": {key.Encode()},
"job": {job},
})
if _, err := taskqueue.Add(c, t, "batch"); err != nil {
log.Errorf(c, "upgradeHandler: enqueue: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
n++
}
}
log.Infof(c, "enqueued %d batch items for '%s'", n, job)
w.Header().Set("Content-Type", "text/plain")
w.Write([]byte(fmt.Sprintf("OK, batch, enqueued %d tasks for %s\n%s", n, job, str)))
}
开发者ID:hugoh,项目名称:complaints,代码行数:54,代码来源:flight-batch.go
示例11: formValueFlightByKey
// A super widget, for all the batch jobs
func formValueFlightByKey(r *http.Request) (*oldfdb.Flight, error) {
fdb := oldfgae.FlightDB{C: oldappengine.NewContext(r)}
key, err := olddatastore.DecodeKey(r.FormValue("key"))
if err != nil {
return nil, fmt.Errorf("fdb-batch: %v", err)
}
f, err := fdb.KeyToFlight(key)
if err != nil {
return nil, fmt.Errorf("fdb-batch: %v", err)
}
return f, nil
}
开发者ID:hugoh,项目名称:complaints,代码行数:14,代码来源:flight-batch.go
示例12: adsbClassbReport
func adsbClassbReport(c appengine.Context, s, e time.Time, opt ReportOptions) ([]ReportRow, ReportMetadata, error) {
fdb := fdb.FlightDB{C: c}
maybeMemcache(&fdb, e)
tags := []string{flightdb.KTagSERFR1}
if flights, err := fdb.LookupTimeRangeByTags(tags, s, e); err != nil {
return nil, nil, err
} else {
meta := ReportMetadata{}
rows := []ReportRow{}
for _, f := range flights {
row := ACBRow{F: f, Url: flight2Url(f)}
_, cbt := f.SFOClassB("FA", nil)
worst := cbt.FindWorstPoint()
row.FAViolation = (worst != nil)
if worst != nil {
row.FAAnalysis = worst.A
}
if f.HasTrack("ADSB") {
row.HadLocalTrack = true
_, cbt := f.SFOClassB("ADSB", nil)
worst := cbt.FindWorstPoint()
row.LocalViolation = (worst != nil)
if worst != nil {
row.LocalAnalysis = worst.A
}
}
if row.LocalViolation && !row.FAViolation {
row.FoundBonusViolation = true
}
if row.LocalViolation && row.FAViolation {
hFA := row.FAAnalysis.BelowBy
hLocal := row.LocalAnalysis.BelowBy
row.IncreasedViolationBy = hLocal - hFA
}
if row.LocalViolation || row.FAViolation {
rows = append(rows, row)
}
}
return rows, meta, nil
}
}
开发者ID:hugoh,项目名称:complaints,代码行数:47,代码来源:reports.go
示例13: discrepReport
func discrepReport(c appengine.Context, s, e time.Time, opt ReportOptions) ([]ReportRow, ReportMetadata, error) {
meta := ReportMetadata{}
fdb := fdb.FlightDB{C: c}
maybeMemcache(&fdb, e)
tags := []string{flightdb.KTagSERFR1}
if flights, err := fdb.LookupTimeRangeByTags(tags, s, e); err != nil {
return nil, nil, err
} else {
out := []ReportRow{}
for _, f := range flights {
// If only one source has ADS-B, flag it
interest := false
if f.HasTrack("ADSB") && !f.HasTrack("FA:TA") {
interest = true
meta["Missing from FlightAware ADS-B"] += 1
}
if !f.HasTrack("ADSB") && f.HasTrack("FA:TA") {
interest = true
meta["Missing from local ADS-B"] += 1
}
// If both have ADS-B, look for missed violations
if f.HasTrack("ADSB") && f.HasTrack("FA:TA") {
if f.HasTag("ClassB:ADSB") && !f.HasTag("ClassB:FA") {
interest = true
meta["Bonus violations"] += 1
}
if !f.HasTag("ClassB:ADSB") && f.HasTag("ClassB:FA") {
interest = true
meta["Missed violations"] += 1
}
}
if !interest {
continue
}
row := SERFR1Row{flight2Url(f), f, false, false}
out = append(out, row)
}
return out, meta, nil
}
}
开发者ID:hugoh,项目名称:complaints,代码行数:45,代码来源:reports.go
示例14: serfr1AtReport
func serfr1AtReport(c appengine.Context, s, e time.Time, opt ReportOptions) ([]ReportRow, ReportMetadata, error) {
meta := ReportMetadata{}
fdb := fdb.FlightDB{C: c}
maybeMemcache(&fdb, e)
tags := []string{flightdb.KTagSERFR1}
pos := sfo.KFixes[opt.Waypoint]
out := []ReportRow{}
iter := fdb.NewIter(fdb.QueryTimeRangeByTags(tags, s, e))
nSerfr1 := 0
for {
f, err := iter.NextWithErr()
if err != nil {
fdb.C.Errorf("serfr1AtReport iterator failed: %v", err)
return nil, nil, err
} else if f == nil {
break // We've hit EOF
}
nSerfr1++
if _, exists := f.Tracks["ADSB"]; exists == true {
meta["[B] with data from "+f.Tracks["ADSB"].LongSource()]++
}
if _, exists := f.Tracks["FA"]; exists == true {
meta["[B] with data from "+f.Tracks["FA"].LongSource()]++
} else {
meta["[B] with data from "+f.Track.LongSource()]++
}
if itp, err := f.BestTrack().PointOfClosestApproach(pos); err != nil {
c.Infof("Skipping flight %s: err=%v", f, err)
} else {
url := template.HTML(fmt.Sprintf("%s&waypoint=%s", flight2Url(*f), opt.Waypoint))
f.Tracks = nil // avoid running out of F1 RAM!
row := SERFR1AtRow{url, *f, itp}
out = append(out, row)
}
}
meta["[A] Total SERFR1 flights "] = float64(nSerfr1)
return out, meta, nil
}
开发者ID:hugoh,项目名称:complaints,代码行数:44,代码来源:reports.go
示例15: serfr1Report
func serfr1Report(c appengine.Context, s, e time.Time, opt ReportOptions) ([]ReportRow, ReportMetadata, error) {
fdb := fdb.FlightDB{C: c}
maybeMemcache(&fdb, e)
meta := ReportMetadata{}
out := []ReportRow{}
idspecs := []string{}
reportFunc := func(f *flightdb.Flight) {
classBViolation := f.HasTag(flightdb.KTagReliableClassBViolation)
hasAdsb := false
if _, exists := f.Tracks["ADSB"]; exists == true {
meta["[B] with data from "+f.Tracks["ADSB"].LongSource()]++
idspecs = append(idspecs, fmt.Sprintf("%[email protected]%d", f.Id.ModeS, f.EnterUTC.Unix()))
}
if t, exists := f.Tracks["FA"]; exists == true {
meta["[B] with data from "+f.Tracks["FA"].LongSource()]++
hasAdsb = t.IsFromADSB()
} else {
meta["[B] with data from "+f.Track.LongSource()]++
}
fClone := f.ShallowCopy()
row := SERFR1Row{flight2Url(*fClone), *fClone, hasAdsb, classBViolation}
out = append(out, row)
}
tags := []string{flightdb.KTagSERFR1}
if err := fdb.IterWith(fdb.QueryTimeRangeByTags(tags, s, e), reportFunc); err != nil {
return nil, nil, err
}
approachUrl := fmt.Sprintf("http://ui-dot-serfr0-fdb.appspot.com/fdb/approach?idspec=%s",
strings.Join(idspecs, ","))
meta[fmt.Sprintf("[Z] %s", approachUrl)] = 1
meta["[A] Total SERFR1 flights "] = float64(len(out))
return out, meta, nil
}
开发者ID:hugoh,项目名称:complaints,代码行数:42,代码来源:reports.go
示例16: jobOceanicTagHandler
func jobOceanicTagHandler(r *http.Request, f *oldfdb.Flight) (string, error) {
c := appengine.NewContext(r)
str := ""
if f.HasTag("OCEANIC") {
return "", nil
}
if !f.IsOceanic() {
return "", nil
}
// It's oceanic, but missing a tag ... update
f.Tags[oldfdb.KTagOceanic] = true
db := oldfgae.FlightDB{C: oldappengine.NewContext(r)}
if err := db.UpdateFlight(*f); err != nil {
log.Errorf(c, "Persist Flight %s: %v", f, err)
return str, err
}
log.Infof(c, "Updated flight %s", f)
str += fmt.Sprintf("--\nFlight was updated\n")
return str, nil
}
开发者ID:hugoh,项目名称:complaints,代码行数:24,代码来源:flight-batch.go
示例17: flightListHandler
// We examine the tags CGI arg, which should be a pipe-delimited set of flight tags.
func flightListHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
db := fdb.FlightDB{C: c}
tags := []string{}
if r.FormValue("tags") != "" {
tags = append(tags, strings.Split(r.FormValue("tags"), "|")...)
}
timeRange := regexp.MustCompile("/fdb/(.+)$").ReplaceAllString(r.URL.Path, "$1")
var flights []ftype.Flight
var err error
switch timeRange {
case "recent":
flights, err = db.LookupRecentByTags(tags, 200)
case "today":
s, e := date.WindowForToday()
flights, err = db.LookupTimeRangeByTags(tags, s, e)
case "yesterday":
s, e := date.WindowForYesterday()
flights, err = db.LookupTimeRangeByTags(tags, s, e)
}
if err != nil {
c.Errorf(" %s: %v", r.URL.Path, err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
var params = map[string]interface{}{
"Tags": tags,
"TimeRange": timeRange,
"Flights": flights2params(flights),
}
if err := templates.ExecuteTemplate(w, "fdb-recentlist", params); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
开发者ID:hugoh,项目名称:complaints,代码行数:40,代码来源:fdb.go
示例18: report3Handler
func report3Handler(w http.ResponseWriter, r *http.Request) {
if r.FormValue("rep") == "" {
var params = map[string]interface{}{
"Yesterday": date.NowInPdt().AddDate(0, 0, -1),
"Reports": report.ListReports(),
"FormUrl": "/report3/",
"Waypoints": sfo.ListWaypoints(),
}
if err := templates.ExecuteTemplate(w, "report3-form", params); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
return
}
rep, err := report.SetupReport(r)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if r.FormValue("debug") != "" {
str := fmt.Sprintf("Report Options\n\n%s\n", rep.Options)
w.Header().Set("Content-Type", "text/plain")
w.Write([]byte(fmt.Sprintf("OK\n\n%s\n", str)))
return
}
//airframes := ref.NewAirframeCache(c)
client := newurlfetch.Client(newappengine.NewContext(r))
metars, err := metar.FetchFromNOAA(client, "KSFO",
rep.Start.AddDate(0, 0, -1), rep.End.AddDate(0, 0, 1))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
v1idspecs := []string{}
v2idspecs := []string{}
v1idspecComplement := []string{}
reportFunc := func(oldF *oldfdb.Flight) {
newF, err := oldF.V2()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
} else {
newF.ComputeIndicatedAltitudes(metars)
if included, err := rep.Process(newF); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
} else if included {
v1idspecs = append(v1idspecs, oldF.UniqueIdentifier())
v2idspecs = append(v2idspecs, newF.IdSpec())
} else {
v1idspecComplement = append(v1idspecComplement, oldF.UniqueIdentifier())
}
}
}
tags := tagList(rep.Options)
db := oldfgae.FlightDB{C: oldappengine.Timeout(oldappengine.NewContext(r), 600*time.Second)}
s, e := rep.Start, rep.End
if err := db.LongIterWith(db.QueryTimeRangeByTags(tags, s, e), reportFunc); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
postButtons := ButtonPOST(fmt.Sprintf("%d Matches as a VectorMap", len(v1idspecs)),
fmt.Sprintf("/fdb/trackset2?%s", rep.ToCGIArgs()), v1idspecs)
postButtons += ButtonPOST(fmt.Sprintf("%d Non-matches as a VectorMap", len(v1idspecComplement)),
fmt.Sprintf("/fdb/trackset2?%s", rep.ToCGIArgs()), v1idspecComplement)
if rep.Name == "sfoclassb" {
postButtons += ButtonPOST(fmt.Sprintf("%d Matches as ClassBApproaches", len(v1idspecs)),
fmt.Sprintf("/fdb/approach2?%s", rep.ToCGIArgs()), v1idspecs)
// This is kinda useless, as it isn't limited to SERFR1 things
postButtons += ButtonPOST(fmt.Sprintf("%d Non-matches as ClassBApproaches", len(v1idspecComplement)),
fmt.Sprintf("/fdb/approach2?%s", rep.ToCGIArgs()), v1idspecComplement)
postButtons += ButtonPOST(fmt.Sprintf("%d Matches as ClassBApproaches (delta)",
len(v1idspecs)), fmt.Sprintf("/fdb/approach2?%s&colorby=delta", rep.ToCGIArgs()), v1idspecs)
// This is kinda useless, as it isn't limited to SERFR1 things
postButtons += ButtonPOST(fmt.Sprintf("%d Non-matches as ClassBApproaches (delta)",
len(v1idspecComplement)), fmt.Sprintf("/fdb/approach2?%s&colorby=delta",
rep.ToCGIArgs()), v1idspecComplement)
}
var params = map[string]interface{}{
"R": rep,
"Metadata": rep.MetadataTable(),
"PostButtons": template.HTML(postButtons),
"OptStr": template.HTML(fmt.Sprintf("<pre>%s</pre>\n", rep.Options)),
"IdSpecs": template.HTML(strings.Join(v1idspecs, ",")),
}
if err := templates.ExecuteTemplate(w, "report3-results", params); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
开发者ID:hugoh,项目名称:complaints,代码行数:98,代码来源:reports3.go
示例19: maybeMemcache
func maybeMemcache(fdb *fdb.FlightDB, queryEnd time.Time) {
if time.Now().Sub(queryEnd) > time.Hour {
fdb.Memcache = true
}
}
开发者ID:hugoh,项目名称:complaints,代码行数:5,代码来源:reports.go
示例20: 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" {
//.........这里部分代码省略.........
开发者ID:hugoh,项目名称:complaints,代码行数:101,代码来源:fdb.go
注:本文中的github.com/skypies/flightdb/gae.FlightDB类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论