X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNavaids%2Fpositioned.cxx;h=450c755d94195b229424445fff6c78f19c6eb91d;hb=6bf47cd248ed388e6a4dd3ffa2d00977b00b62fb;hp=18bb22f62b6e6717e494b5efe1680d5930dc3e01;hpb=1d99401c0427a2a4faae651995736d569f8bbd5e;p=flightgear.git diff --git a/src/Navaids/positioned.cxx b/src/Navaids/positioned.cxx index 18bb22f62..450c755d9 100644 --- a/src/Navaids/positioned.cxx +++ b/src/Navaids/positioned.cxx @@ -73,10 +73,25 @@ FGPositioned::~FGPositioned() 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 { @@ -111,12 +126,20 @@ FGPositioned::Type FGPositioned::typeFromName(const std::string& aName) {"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}, @@ -131,7 +154,7 @@ FGPositioned::Type FGPositioned::typeFromName(const std::string& aName) } } - 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; } @@ -139,6 +162,7 @@ const char* FGPositioned::nameForType(Type aTy) { switch (aTy) { case RUNWAY: return "runway"; + case HELIPAD: return "helipad"; case TAXIWAY: return "taxiway"; case PAVEMENT: return "pavement"; case PARKING: return "parking stand"; @@ -165,6 +189,10 @@ const char* FGPositioned::nameForType(Type aTy) 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"; } @@ -202,7 +230,20 @@ FGPositioned::findWithinRange(const SGGeod& aPos, double aRangeNm, Filter* aFilt 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; } @@ -238,10 +279,23 @@ FGPositioned::findClosestN(const SGGeod& aPos, unsigned int aN, double aCutoffNm 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) {