#include <simgear/math/sg_geodesy.hxx>
#include <simgear/timing/timestamp.hxx>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/misc/strutils.hxx>
#include "positioned.hxx"
return SGVec3d::fromGeod(mPosition);
}
+FGPositioned::Type FGPositioned::typeFromName(const std::string& aName)
+{
+ typedef struct {
+ const char* _name;
+ Type _ty;
+ } NameTypeEntry;
+
+ const NameTypeEntry names[] = {
+ {"airport", AIRPORT},
+ {"vor", VOR},
+ {"ndb", NDB},
+ {"wpt", WAYPOINT},
+ {"fix", FIX},
+ {"tacan", TACAN},
+ {"dme", DME},
+ // aliases
+ {"waypoint", WAYPOINT},
+
+ {NULL, INVALID}
+ };
+
+ std::string lowerName(simgear::strutils::convertToLowerCase(aName));
+
+ for (const NameTypeEntry* n = names; (n->_name != NULL); ++n) {
+ if (::strcmp(n->_name, lowerName.c_str()) == 0) {
+ return n->_ty;
+ }
+ }
+
+ SG_LOG(SG_GENERAL, SG_WARN, "FGPositioned::typeFromName: couldn't match:" << aName);
+ return INVALID;
+}
+
const char* FGPositioned::nameForType(Type aTy)
{
switch (aTy) {
*/
static List findClosestN(const SGGeod& aPos, unsigned int aN, double aCutoffNm, Filter* aFilter = NULL);
-
+ /**
+ * Map a candidate type string to a real type. Returns INVALID if the string
+ * does not correspond to a defined type.
+ */
+ static Type typeFromName(const std::string& aName);
/**
- * Debug helper, map a type to a human-readable string
+ * Map a type to a human-readable string
*/
static const char* nameForType(Type aTy);
protected: