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


Golang Latlong.DistKM方法代码示例

本文整理汇总了Golang中github.com/skypies/geo.Latlong.DistKM方法的典型用法代码示例。如果您正苦于以下问题:Golang Latlong.DistKM方法的具体用法?Golang Latlong.DistKM怎么用?Golang Latlong.DistKM使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/skypies/geo.Latlong的用法示例。


在下文中一共展示了Latlong.DistKM方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: AirspaceToLocalizedAircraft

func AirspaceToLocalizedAircraft(as *airspace.Airspace, pos geo.Latlong, elev float64) []Aircraft {
	ret := []Aircraft{}

	if as == nil {
		return ret
	}

	for _, ad := range as.Aircraft {
		tp := fdb.TrackpointFromADSB(ad.Msg)
		altitudeDelta := tp.Altitude - elev

		icaoid := string(ad.Msg.Icao24)
		icaoid = strings.TrimPrefix(icaoid, "EE") // fr24 airspaces use this prefix
		icaoid = strings.TrimPrefix(icaoid, "FF") // fa airspaces use this prefix

		a := Aircraft{
			Dist:                pos.DistKM(tp.Latlong),
			Dist3:               pos.Dist3(tp.Latlong, altitudeDelta),
			BearingFromObserver: tp.Latlong.BearingTowards(pos),
			//Id: "someid", // This is set via an IdSpec string below
			Id2:      icaoid,
			Lat:      tp.Lat,
			Long:     tp.Long,
			Track:    tp.Heading,
			Altitude: tp.Altitude,
			Speed:    tp.GroundSpeed,
			// Squawk string
			Radar:        tp.ReceiverName,
			EquipType:    ad.Airframe.EquipmentType,
			Registration: ad.Airframe.Registration,
			Epoch:        float64(tp.TimestampUTC.Unix()),
			Origin:       ad.Schedule.Origin,
			Destination:  ad.Schedule.Destination,
			FlightNumber: ad.Schedule.IataFlight(),
			// Unknown float64
			VerticalSpeed: tp.VerticalRate,
			Callsign:      ad.Msg.Callsign, //"CAL123", //snap.Flight.Callsign,
			// Unknown2 float64
		}

		// Even though we may be parsing an fr24 airspace, generate a skypi idspec (which may break)
		if icaoid != "" {
			a.Id = fdb.IdSpec{IcaoId: icaoid, Time: tp.TimestampUTC}.String()
		}

		// Hack for Surf Air; promote their callsigns into flightnumbers.
		// The goal is to allow them to get past the filter, and be printable etc.
		// There is probably a much better place for this kind of munging. But it needs to happen
		//  regardless of the source of the airspace, so it can't be pushed upstream. (...?)
		if a.FlightNumber == "" && regexp.MustCompile("^URF\\d+$").MatchString(a.Callsign) {
			a.FlightNumber = a.Callsign
		}

		ret = append(ret, a)
	}

	sort.Sort(AircraftByDist3(ret))

	return ret
}
开发者ID:skypies,项目名称:complaints,代码行数:60,代码来源:flightid.go


注:本文中的github.com/skypies/geo.Latlong.DistKM方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。