本文整理汇总了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
}