当前位置: 首页>>代码示例>>Golang>>正文


Golang FlightDB.LookupById方法代码示例

本文整理汇总了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
}
开发者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: 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.LookupById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。