Esempio n. 1
0
GeoPoint
TeamCode::GetLocation(const GeoPoint ref) const
{
  Angle bearing = GetBearing();
  fixed distance = GetRange();

  return FindLatitudeLongitude(ref, bearing, distance);
}
Esempio n. 2
0
AircraftState
AircraftStateFilter::GetPredictedState(const double in_time) const
{
  AircraftState state_next = last_state;
  state_next.ground_speed = GetSpeed();
  state_next.vario = GetClimbRate();
  state_next.altitude = last_state.altitude + state_next.vario * in_time;
  state_next.location = GeoVector(state_next.ground_speed * in_time,
                                  GetBearing()).EndPoint(last_state.location);
  return state_next;
}
Esempio n. 3
0
void CalcTeammateBearingRange(double ownBear, double ownDist, TCHAR *TeamMateCode,  double *bearToMate, double *distToMate)
{
	double calcBearing = GetBearing(TeamMateCode)/*+ 180*/;
	double calcRange = GetRange(TeamMateCode);	


	//if (calcBearing > 360)
	//{
	//	calcBearing -= 360;
	//}
	

	CalcTeamMatePos(ownBear, ownDist, calcBearing, calcRange, bearToMate, distToMate);
}
Esempio n. 4
0
double GetTeammateBearingFromRef(TCHAR *code )
{
	return GetBearing(code);
}
Esempio n. 5
0
void DescriptionFactory::Run(const SearchEngine &sEngine, const unsigned zoomLevel) {

    if(0 == pathDescription.size())
        return;

//    unsigned entireLength = 0;
    /** starts at index 1 */
    pathDescription[0].length = 0;
    for(unsigned i = 1; i < pathDescription.size(); ++i) {
        pathDescription[i].length = ApproximateEuclideanDistance(pathDescription[i-1].location, pathDescription[i].location);
    }

    double lengthOfSegment = 0;
    unsigned durationOfSegment = 0;
    unsigned indexOfSegmentBegin = 0;

    std::string string0 = sEngine.GetEscapedNameForNameID(pathDescription[0].nameID);
    std::string string1;


    /*Simplify turn instructions
    Input :
    10. Turn left on B 36 for 20 km
    11. Continue on B 35; B 36 for 2 km
    12. Continue on B 36 for 13 km

    becomes:
    10. Turn left on B 36 for 35 km
    */
//TODO: rework to check only end and start of string.
//		stl string is way to expensive

//    unsigned lastTurn = 0;
//    for(unsigned i = 1; i < pathDescription.size(); ++i) {
//        string1 = sEngine.GetEscapedNameForNameID(pathDescription[i].nameID);
//        if(TurnInstructionsClass::GoStraight == pathDescription[i].turnInstruction) {
//            if(std::string::npos != string0.find(string1+";")
//            		|| std::string::npos != string0.find(";"+string1)
//            		|| std::string::npos != string0.find(string1+" ;")
//                    || std::string::npos != string0.find("; "+string1)
//                    ){
//                SimpleLogger().Write() << "->next correct: " << string0 << " contains " << string1;
//                for(; lastTurn != i; ++lastTurn)
//                    pathDescription[lastTurn].nameID = pathDescription[i].nameID;
//                pathDescription[i].turnInstruction = TurnInstructionsClass::NoTurn;
//            } else if(std::string::npos != string1.find(string0+";")
//            		|| std::string::npos != string1.find(";"+string0)
//                    || std::string::npos != string1.find(string0+" ;")
//                    || std::string::npos != string1.find("; "+string0)
//                    ){
//                SimpleLogger().Write() << "->prev correct: " << string1 << " contains " << string0;
//                pathDescription[i].nameID = pathDescription[i-1].nameID;
//                pathDescription[i].turnInstruction = TurnInstructionsClass::NoTurn;
//            }
//        }
//        if (TurnInstructionsClass::NoTurn != pathDescription[i].turnInstruction) {
//            lastTurn = i;
//        }
//        string0 = string1;
//    }


    for(unsigned i = 1; i < pathDescription.size(); ++i) {
        entireLength += pathDescription[i].length;
        lengthOfSegment += pathDescription[i].length;
        durationOfSegment += pathDescription[i].duration;
        pathDescription[indexOfSegmentBegin].length = lengthOfSegment;
        pathDescription[indexOfSegmentBegin].duration = durationOfSegment;


        if(TurnInstructionsClass::NoTurn != pathDescription[i].turnInstruction) {
            //SimpleLogger().Write() << "Turn after " << lengthOfSegment << "m into way with name id " << segment.nameID;
            assert(pathDescription[i].necessary);
            lengthOfSegment = 0;
            durationOfSegment = 0;
            indexOfSegmentBegin = i;
        }
    }
    //    SimpleLogger().Write() << "#segs: " << pathDescription.size();

    //Post-processing to remove empty or nearly empty path segments
    if(FLT_EPSILON > pathDescription.back().length) {
        //        SimpleLogger().Write() << "#segs: " << pathDescription.size() << ", last ratio: " << targetPhantom.ratio << ", length: " << pathDescription.back().length;
        if(pathDescription.size() > 2){
            pathDescription.pop_back();
            pathDescription.back().necessary = true;
            pathDescription.back().turnInstruction = TurnInstructions.NoTurn;
            targetPhantom.nodeBasedEdgeNameID = (pathDescription.end()-2)->nameID;
            //            SimpleLogger().Write() << "Deleting last turn instruction";
        }
    } else {
        pathDescription[indexOfSegmentBegin].duration *= (1.-targetPhantom.ratio);
    }
    if(FLT_EPSILON > pathDescription[0].length) {
        //TODO: this is never called actually?
        if(pathDescription.size() > 2) {
            pathDescription.erase(pathDescription.begin());
            pathDescription[0].turnInstruction = TurnInstructions.HeadOn;
            pathDescription[0].necessary = true;
            startPhantom.nodeBasedEdgeNameID = pathDescription[0].nameID;
            //            SimpleLogger().Write() << "Deleting first turn instruction, ratio: " << startPhantom.ratio << ", length: " << pathDescription[0].length;
        }
    } else {
        pathDescription[0].duration *= startPhantom.ratio;
    }

    //Generalize poly line
    dp.Run(pathDescription, zoomLevel);

    //fix what needs to be fixed else
    for(unsigned i = 0; i < pathDescription.size()-1 && pathDescription.size() >= 2; ++i){
        if(pathDescription[i].necessary) {
            double angle = GetBearing(pathDescription[i].location, pathDescription[i+1].location);
            pathDescription[i].bearing = angle;
        }
    }

//    BuildRouteSummary(entireLength, duration);
    return;
}