short StreetSpeedModel::ChooseSpeed(unsigned int iRecord) const
{
	if (iRecord == (unsigned)-1)
		return 0;
	else
		return (short)round(SECSPERHOUR / TimeFactor(g_pMapDB->GetRecord(iRecord)));
}
Exemple #2
0
double UNITS::ConvFactor() {
    
    bool InIsLinear=false, OutIsLinear=false;
    for (int i=ANG;i<=MPC;i++) {
        InIsLinear  = InIsLinear  || in==i;
        OutIsLinear = OutIsLinear || out==i;
    }
    if (InIsLinear && OutIsLinear) return LinearFactor();
    
    bool InIsTime=false, OutIsTime=false;
    for (int i=S;i<=GYR;i++) {
        InIsTime  = InIsTime  || in==i;
        OutIsTime = OutIsTime || out==i;
    }
    if (InIsTime && OutIsTime) return TimeFactor();
    
    bool InIsMass=false, OutIsMass=false;
    for (int i=GR;i<=MSUN;i++) {
        InIsMass  = InIsMass  || in==i;
        OutIsMass = OutIsMass || out==i;
    }
    if (InIsMass && OutIsMass) return MassFactor();
    
    bool InIsFreq=false, OutIsFreq=false;
    for (int i=HZ;i<=GHZ;i++) {
        InIsFreq  = InIsFreq  || in==i;
        OutIsFreq = OutIsFreq || out==i;
    }
    if (InIsFreq && OutIsFreq) return FrequencyFactor();
    
    bool InIsAngle=false, OutIsAngle=false;
    for (int i=DEG;i<=RAD;i++) {
        InIsAngle  = InIsAngle  || in==i;
        OutIsAngle = OutIsAngle || out==i;
    }
    if (InIsAngle && OutIsAngle) return AngleFactor();
    
    bool InIsVel=false, OutIsVel=false;
    for (int i=CM_S;i<=KM_H;i++) {
        InIsVel  = InIsVel  || in==i;
        OutIsVel = OutIsVel || out==i;
    }
    if (InIsVel && OutIsVel) {
        Unit NumIn=M, NumOut=M, DenIn=S, DenOut=S;
        if (in==CM_S) NumIn = CM; 
        else if (in==M_S) NumIn = M;
        else if (in==KM_S || in==KM_H) NumIn = KM;  
        if (out==CM_S) NumOut = CM; 
        else if (out==M_S) NumOut = M;
        else if (out==KM_S || out==KM_H) NumOut = KM;
        if (in==CM_S || in==M_S || in==KM_S) DenIn = S;
        else if (in==KM_H) DenIn = H;
        if (out==CM_S || out==M_S || out==KM_S) DenOut = S;
        else if (out==KM_H) DenOut = H;
        UNITS NUM(NumIn,NumOut), DENOM(DenIn,DenOut);
        return NUM.factor/DENOM.factor;
    }

    std::cout << "Unknown conversion!!" << std::endl;
    
    return -1;
}