예제 #1
0
func (r *Release) parseWaypoint(line string) error {
	waypoint := waypoint.Waypoint{
		Name: strings.Trim(line[0:6], " "), ID: strings.Trim(line[0:6], " "),
		Description: strings.Trim(line[7:41], " "),
		Latitude:    spatial.DMS2Decimal(line[45:52]), Longitude: spatial.DMS2Decimal(line[52:60]),
		Region: line[60:62], Update: r.Date,
	}
	elevation := strings.Trim(line[41:45], " ")
	waypoint.Elevation, _ = strconv.Atoi(elevation)
	r.Waypoints = append(r.Waypoints, waypoint)
	return nil
}
예제 #2
0
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
}