FGPositioned*
FGPositioned::createUserWaypoint(const std::string& aIdent, const SGGeod& aPos)
{
- PositionedID id = NavDataCache::instance()->createUserWaypoint(aIdent, aPos);
- return NavDataCache::instance()->loadById(id);
+ NavDataCache* cache = NavDataCache::instance();
+ TypeFilter filter(WAYPOINT);
+ FGPositioned::List existing = cache->findAllWithIdent(aIdent, &filter, true);
+ if (!existing.empty()) {
+ SG_LOG(SG_NAVAID, SG_WARN, "attempt to insert duplicate WAYPOINT:" << aIdent);
+ return existing.front().ptr();
+ }
+
+ PositionedID id = cache->createPOI(WAYPOINT, aIdent, aPos);
+ return cache->loadById(id);
+}
+
+void FGPositioned::deleteUserWaypoint(const std::string& aIdent)
+{
+ NavDataCache* cache = NavDataCache::instance();
+ cache->removePOI(WAYPOINT, aIdent);
}
+
const SGVec3d&
FGPositioned::cart() const
{
{"ground", FREQ_GROUND},
{"approach", FREQ_APP_DEP},
{"departure", FREQ_APP_DEP},
+ {"runway", RUNWAY},
+ {"helipad", HELIPAD},
+ {"country", COUNTRY},
+ {"city", CITY},
+ {"town", TOWN},
+ {"village", VILLAGE},
+
// aliases
{"gnd", FREQ_GROUND},
{"twr", FREQ_TOWER},
{"waypoint", WAYPOINT},
{"apt", AIRPORT},
{"arpt", AIRPORT},
+ {"rwy", RUNWAY},
{"any", INVALID},
{"all", INVALID},
}
}
- SG_LOG(SG_GENERAL, SG_WARN, "FGPositioned::typeFromName: couldn't match:" << aName);
+ SG_LOG(SG_NAVAID, SG_WARN, "FGPositioned::typeFromName: couldn't match:" << aName);
return INVALID;
}
{
switch (aTy) {
case RUNWAY: return "runway";
+ case HELIPAD: return "helipad";
case TAXIWAY: return "taxiway";
case PAVEMENT: return "pavement";
case PARKING: return "parking stand";
case FREQ_UNICOM: return "unicom";
case FREQ_APP_DEP: return "approach-departure";
case TAXI_NODE: return "taxi-node";
+ case COUNTRY: return "country";
+ case CITY: return "city";
+ case TOWN: return "town";
+ case VILLAGE: return "village";
default:
return "unknown";
}
List result;
Octree::findAllWithinRange(SGVec3d::fromGeod(aPos),
- aRangeNm * SG_NM_TO_METER, aFilter, result);
+ aRangeNm * SG_NM_TO_METER, aFilter, result, 0xffffff);
+ return result;
+}
+
+FGPositioned::List
+FGPositioned::findWithinRangePartial(const SGGeod& aPos, double aRangeNm, Filter* aFilter, bool& aPartial)
+{
+ validateSGGeod(aPos);
+
+ int limitMsec = 32;
+ List result;
+ aPartial = Octree::findAllWithinRange(SGVec3d::fromGeod(aPos),
+ aRangeNm * SG_NM_TO_METER, aFilter, result,
+ limitMsec);
return result;
}
validateSGGeod(aPos);
List result;
- Octree::findNearestN(SGVec3d::fromGeod(aPos), aN, aCutoffNm * SG_NM_TO_METER, aFilter, result);
+ int limitMsec = 0xffff;
+ Octree::findNearestN(SGVec3d::fromGeod(aPos), aN, aCutoffNm * SG_NM_TO_METER, aFilter, result, limitMsec);
return result;
}
-
+
+FGPositioned::List
+FGPositioned::findClosestNPartial(const SGGeod& aPos, unsigned int aN, double aCutoffNm, Filter* aFilter, bool &aPartial)
+{
+ validateSGGeod(aPos);
+
+ List result;
+ int limitMsec = 32;
+ aPartial = Octree::findNearestN(SGVec3d::fromGeod(aPos), aN, aCutoffNm * SG_NM_TO_METER, aFilter, result,
+ limitMsec);
+ return result;
+}
+
void
FGPositioned::sortByRange(List& aResult, const SGGeod& aPos)
{