void OGRXPlaneFixReader::ParseRecord() { double dfLat, dfLon; CPLString osName; RET_IF_FAIL(readLatLon(&dfLat, &dfLon, 0)); osName = readStringUntilEnd(2); if (poFIXLayer) poFIXLayer->AddFeature(osName, dfLat, dfLon); }
void OGRXPlaneNavReader::ParseRecord( int nType ) { double dfVal = 0.0; double dfTrueHeading = 0.0; double dfLat = 0.0; double dfLon = 0.0; RET_IF_FAIL(readLatLon(&dfLat, &dfLon, 1)); double dfElevation = 0.0; /* feet to meter */ RET_IF_FAIL(readDoubleWithBoundsAndConversion(&dfElevation, 3, "elevation", FEET_TO_METER, -1000., 10000.)); double dfFrequency = 0.0; RET_IF_FAIL(readDouble(&dfFrequency, 4, "frequency")); /* NDB frequencies are in kHz. Others must be divided by 100 */ /* to get a frequency in MHz */ if (nType != NAVAID_NDB) dfFrequency /= 100.; double dfRange = 0.0; /* nautical miles to kilometer */ RET_IF_FAIL(readDouble(&dfRange, 5, "range")); dfRange *= NM_TO_KM; char* pszNavaidId = papszTokens[7]; if (nType == NAVAID_NDB) { const char* pszSubType = ""; CPLString osNavaidName; if (EQUAL(papszTokens[nTokens-1], "NDB") || EQUAL(papszTokens[nTokens-1], "LOM") || EQUAL(papszTokens[nTokens-1], "NDB-DME")) { pszSubType = papszTokens[nTokens-1]; nTokens--; } else { CPLDebug("XPlane", "Unexpected NDB subtype : %s", papszTokens[nTokens-1]); } osNavaidName = readStringUntilEnd(8); if (poNDBLayer) poNDBLayer->AddFeature(pszNavaidId, osNavaidName, pszSubType, dfLat, dfLon, dfElevation, dfFrequency, dfRange); } else if (nType == NAVAID_VOR) { const char* pszSubType = ""; CPLString osNavaidName; double dfSlavedVariation = 0.0; RET_IF_FAIL(readDoubleWithBounds(&dfSlavedVariation, 6, "slaved variation", -180., 180.)); if (EQUAL(papszTokens[nTokens-1], "VOR") || EQUAL(papszTokens[nTokens-1], "VORTAC") || EQUAL(papszTokens[nTokens-1], "VOR-DME")) { pszSubType = papszTokens[nTokens-1]; nTokens--; } else { CPLDebug("XPlane", "Unexpected VOR subtype : %s", papszTokens[nTokens-1]); } osNavaidName = readStringUntilEnd(8); if (poVORLayer) poVORLayer->AddFeature(pszNavaidId, osNavaidName, pszSubType, dfLat, dfLon, dfElevation, dfFrequency, dfRange, dfSlavedVariation); } else if (nType == NAVAID_LOC_ILS || nType == NAVAID_LOC_STANDALONE) { RET_IF_FAIL(readDoubleWithBounds(&dfTrueHeading, 6, "true heading", 0.0, 360.)); RET_IF_FAIL(assertMinCol(11)); const char *pszAptICAO = papszTokens[8]; const char *pszRwyNum = papszTokens[9]; const char *pszSubType = papszTokens[10]; if (EQUAL(pszSubType, "ILS-cat-I") || EQUAL(pszSubType, "ILS-cat-II") || EQUAL(pszSubType, "ILS-cat-III") || EQUAL(pszSubType, "LOC") || EQUAL(pszSubType, "LDA") || EQUAL(pszSubType, "SDF") || EQUAL(pszSubType, "IGS") || EQUAL(pszSubType, "LDA-GS")) { if (poILSLayer) poILSLayer->AddFeature(pszNavaidId, pszAptICAO, pszRwyNum, pszSubType, dfLat, dfLon, dfElevation, dfFrequency, dfRange, dfTrueHeading); } else { CPLDebug("XPlane", "Line %d : invalid localizer subtype: '%s'", nLineNumber, pszSubType); return; } } else if (nType == NAVAID_GS) { RET_IF_FAIL(readDouble(&dfVal, 6, "slope & heading")); const double dfSlope = (int)(dfVal / 1000) / 100.; dfTrueHeading = dfVal - dfSlope * 100000; if (dfTrueHeading < 0 || dfTrueHeading > 360) { CPLDebug("XPlane", "Line %d : invalid true heading '%f'", nLineNumber, dfTrueHeading); return; } RET_IF_FAIL(assertMinCol(11)); const char *pszAptICAO = papszTokens[8]; const char *pszRwyNum = papszTokens[9]; const char *pszSubType = papszTokens[10]; if (EQUAL(pszSubType, "GS") ) { if (poGSLayer) poGSLayer->AddFeature(pszNavaidId, pszAptICAO, pszRwyNum, dfLat, dfLon, dfElevation, dfFrequency, dfRange, dfTrueHeading, dfSlope); } else { CPLDebug("XPlane", "Line %d : invalid glideslope subtype: '%s'", nLineNumber, pszSubType); return; } } else if (nType == NAVAID_OM || nType == NAVAID_MM || nType == NAVAID_IM) { const char* pszAptICAO, * pszRwyNum, * pszSubType; RET_IF_FAIL(readDoubleWithBounds(&dfTrueHeading, 6, "true heading", 0.0, 360.0)); RET_IF_FAIL(assertMinCol(11)); pszAptICAO = papszTokens[8]; pszRwyNum = papszTokens[9]; pszSubType = papszTokens[10]; if (EQUAL(pszSubType, "OM") || EQUAL(pszSubType, "MM") || EQUAL(pszSubType, "IM") ) { if (poMarkerLayer) poMarkerLayer->AddFeature(pszAptICAO, pszRwyNum, pszSubType, dfLat, dfLon, dfElevation, dfTrueHeading); } else { CPLDebug("XPlane", "Line %d : invalid localizer marker subtype: '%s'", nLineNumber, pszSubType); return; } } else if (nType == NAVAID_DME_COLOC || nType == NAVAID_DME_STANDALONE) { const char* pszSubType = ""; CPLString osNavaidName; double dfDMEBias = 0.0; RET_IF_FAIL(readDouble(&dfDMEBias, 6, "DME bias")); dfDMEBias *= NM_TO_KM; if (EQUAL(papszTokens[nTokens-1], "DME-ILS")) { char* pszAptICAO, * pszRwyNum /* , * pszSubType */; if (nTokens != 11) { CPLDebug("XPlane", "Line %d : not enough columns : %d", nLineNumber, nTokens); return; } pszAptICAO = papszTokens[8]; pszRwyNum = papszTokens[9]; /* pszSubType = papszTokens[10]; */ if (poDMEILSLayer) poDMEILSLayer->AddFeature(pszNavaidId, pszAptICAO, pszRwyNum, dfLat, dfLon, dfElevation, dfFrequency, dfRange, dfDMEBias); } else { if (EQUAL(papszTokens[nTokens-1], "DME")) { nTokens--; if (EQUAL(papszTokens[nTokens-1], "VORTAC") || EQUAL(papszTokens[nTokens-1], "VOR-DME") || EQUAL(papszTokens[nTokens-1], "TACAN") || EQUAL(papszTokens[nTokens-1], "NDB-DME")) { /* pszSubType = papszTokens[nTokens-1]; */ nTokens--; } } else { CPLDebug("XPlane", "Line %d : Unexpected DME subtype : %s", nLineNumber, papszTokens[nTokens-1]); } osNavaidName = readStringUntilEnd(8); if (poDMELayer) poDMELayer->AddFeature(pszNavaidId, osNavaidName, pszSubType, dfLat, dfLon, dfElevation, dfFrequency, dfRange, dfDMEBias); } } else { CPLAssert(0); } }