func feature2Airfield(f *geojson.Feature) airfield.Airfield { a := airfield.Airfield{ ID: f.PropertyMustString("ID"), ShortName: f.PropertyMustString("ShortName"), Name: f.PropertyMustString("Name"), Region: f.PropertyMustString("Region"), ICAO: f.PropertyMustString("ICAO"), Flags: f.PropertyMustInt("Flags"), Catalog: f.PropertyMustInt("Catalog"), Length: f.PropertyMustInt("Length"), Elevation: f.PropertyMustInt("Elevation"), Runway: f.PropertyMustString("Runway"), Frequency: f.PropertyMustFloat64("Frequency"), } a.Longitude = f.Geometry.Point[0] a.Latitude = f.Geometry.Point[1] return a }
func (r *Release) parseAirfield(line string) error { afield := airfield.Airfield{Update: r.Date} if line[4] == '2' { // unclear airstrip afield.Flags |= airfield.UnclearAirstrip afield.ShortName = strings.Trim(line[0:4], " ") } else { // regular airstrip afield.ShortName = strings.Trim(line[0:5], " ") } afield.Name = strings.Trim(line[7:20], " ") if line[23] == '#' && line[24] != ' ' && string(line[24:28]) != "GLD!" { // ICAO available afield.ICAO = line[24:28] afield.ID = afield.ICAO } else { afield.ID = afield.ShortName } if line[23:27] == "*ULM" { // ultralight site afield.Flags |= airfield.ULMSite } else if line[5] == '2' { // outlanding afield.Flags |= airfield.Outlanding afield.Catalog, _ = strconv.Atoi(line[26:28]) } else if line[20:24] == "GLD#" || line[23:28] == "#GLD" { // glider site afield.Flags |= airfield.GliderSite } afield.Flags |= r.runwayType2Bit(line[28]) afield.Length, _ = strconv.Atoi(line[29:32]) afield.Length *= 10 afield.Runway = line[32:36] decimal, _ := strconv.ParseFloat(line[39:41], 64) afield.Frequency, _ = strconv.ParseFloat(line[36:39], 64) afield.Frequency += decimal * 0.01 elevation := strings.Trim(line[41:45], " ") afield.Elevation, _ = strconv.Atoi(elevation) afield.Latitude = spatial.DMS2Decimal(line[45:52]) afield.Longitude = spatial.DMS2Decimal(line[52:60]) afield.Region = line[60:62] r.Airfields = append(r.Airfields, afield) return nil }