- 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);