|
@@ -419,135 +419,154 @@ void lct_coordcal_sel_minimum_value(flt32 *pfDelayDeviationSumMatrix, uint16 wMa
|
|
|
LCT_MINIMUM_VALUE_T astMinmumValueList[128] = {0}; // 极小值点列表
|
|
|
uint8 byMinimumValueNum = (uint8)gg_stLctCoordcalParam.dwMinimumValueNum; // 极小值个数
|
|
|
|
|
|
- // 遍历时延队列,查找极小值时延参考点
|
|
|
- for (uint16 wRow = 0; wRow < wMatrixRow; wRow++)
|
|
|
+ uint8 byWhildFlag = 1; //
|
|
|
+ int8 byValidThres = 5; // 有效校验点数门限
|
|
|
+
|
|
|
+ do
|
|
|
{
|
|
|
- for (uint16 wCol = 0; wCol < wMatrixCol; wCol++)
|
|
|
+ // 最小需要2个点来校验
|
|
|
+ if (byValidThres < 3)
|
|
|
{
|
|
|
- wIndex = wRow * wMatrixCol + wCol;
|
|
|
- fDeviation = pfDelayDeviationSumMatrix[wIndex]; // 当前点误差
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ byValidThres--; // 门限减1
|
|
|
|
|
|
- // 判断四周各点是否合法(若1点不合法则退出)
|
|
|
- byValidFlag = 1;
|
|
|
- for (uint8 i = 0; i < 1; i++)
|
|
|
+ // 遍历时延队列,查找极小值时延参考点
|
|
|
+ for (uint16 wRow = 0; wRow < wMatrixRow; wRow++)
|
|
|
+ {
|
|
|
+ for (uint16 wCol = 0; wCol < wMatrixCol; wCol++)
|
|
|
{
|
|
|
- // 1东方
|
|
|
- if ((wCol + 1) < wMatrixCol)
|
|
|
+ wIndex = wRow * wMatrixCol + wCol;
|
|
|
+ fDeviation = pfDelayDeviationSumMatrix[wIndex]; // 当前点误差
|
|
|
+
|
|
|
+ // 判断四周各点是否合法(若1点不合法则退出)
|
|
|
+ byValidFlag = 0;
|
|
|
+ for (uint8 i = 0; i < 1; i++)
|
|
|
{
|
|
|
- wTmpIndex = wRow * wMatrixCol + wCol + 1;
|
|
|
- fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
- if (fDeviation >= fTmpDeviation)
|
|
|
- { // 不合法
|
|
|
- byValidFlag = 0;
|
|
|
- break;
|
|
|
+ // 1东方
|
|
|
+ if ((wCol + 1) < wMatrixCol)
|
|
|
+ {
|
|
|
+ wTmpIndex = wRow * wMatrixCol + wCol + 1;
|
|
|
+ fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
+ if (fDeviation >= fTmpDeviation)
|
|
|
+ { // 不合法
|
|
|
+ byValidFlag = 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ byValidFlag++;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // // 2东北角
|
|
|
- // if ((wRow + 1) < wMatrixRow && (wCol + 1) < wMatrixCol)
|
|
|
- // {
|
|
|
- // wTmpIndex = (wRow + 1) * wMatrixCol + wCol + 1;
|
|
|
- // fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
- // if (fDeviation >= fTmpDeviation)
|
|
|
- // { // 不合法
|
|
|
- // byValidFlag = 0;
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // 3北方
|
|
|
- if ((wRow + 1) < wMatrixRow)
|
|
|
- {
|
|
|
- wTmpIndex = (wRow + 1) * wMatrixCol + wCol;
|
|
|
- fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
- if (fDeviation >= fTmpDeviation)
|
|
|
- { // 不合法
|
|
|
- byValidFlag = 0;
|
|
|
- break;
|
|
|
+ // // 2东北角
|
|
|
+ // if ((wRow + 1) < wMatrixRow && (wCol + 1) < wMatrixCol)
|
|
|
+ // {
|
|
|
+ // wTmpIndex = (wRow + 1) * wMatrixCol + wCol + 1;
|
|
|
+ // fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
+ // if (fDeviation >= fTmpDeviation)
|
|
|
+ // { // 不合法
|
|
|
+ // byValidFlag = 0;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 3北方
|
|
|
+ if ((wRow + 1) < wMatrixRow)
|
|
|
+ {
|
|
|
+ wTmpIndex = (wRow + 1) * wMatrixCol + wCol;
|
|
|
+ fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
+ if (fDeviation >= fTmpDeviation)
|
|
|
+ { // 不合法
|
|
|
+ byValidFlag = 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ byValidFlag++;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // // 4西北角
|
|
|
- // if ((wRow + 1) < wMatrixRow && (wCol - 1) >= 0)
|
|
|
- // {
|
|
|
- // wTmpIndex = (wRow + 1) * wMatrixCol + wCol - 1;
|
|
|
- // fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
- // if (fDeviation >= fTmpDeviation)
|
|
|
- // { // 不合法
|
|
|
- // byValidFlag = 0;
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // 5西方
|
|
|
- if ((wCol - 1) >= 0)
|
|
|
- {
|
|
|
- wTmpIndex = wRow * wMatrixCol + wCol - 1;
|
|
|
- fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
- if (fDeviation >= fTmpDeviation)
|
|
|
- { // 不合法
|
|
|
- byValidFlag = 0;
|
|
|
- break;
|
|
|
+ // // 4西北角
|
|
|
+ // if ((wRow + 1) < wMatrixRow && (wCol - 1) >= 0)
|
|
|
+ // {
|
|
|
+ // wTmpIndex = (wRow + 1) * wMatrixCol + wCol - 1;
|
|
|
+ // fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
+ // if (fDeviation >= fTmpDeviation)
|
|
|
+ // { // 不合法
|
|
|
+ // byValidFlag = 0;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 5西方
|
|
|
+ if ((wCol - 1) >= 0)
|
|
|
+ {
|
|
|
+ wTmpIndex = wRow * wMatrixCol + wCol - 1;
|
|
|
+ fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
+ if (fDeviation >= fTmpDeviation)
|
|
|
+ { // 不合法
|
|
|
+ byValidFlag = 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ byValidFlag++;
|
|
|
+ }
|
|
|
+
|
|
|
+ // // 6西南角
|
|
|
+ // if ((wRow - 1) >= 0 && (wCol - 1) >= 0)
|
|
|
+ // {
|
|
|
+ // wTmpIndex = (wRow - 1) * wMatrixCol + wCol - 1;
|
|
|
+ // fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
+ // if (fDeviation >= fTmpDeviation)
|
|
|
+ // { // 不合法
|
|
|
+ // byValidFlag = 0;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 7南方
|
|
|
+ if ((wRow - 1) >= 0)
|
|
|
+ {
|
|
|
+ wTmpIndex = (wRow - 1) * wMatrixCol + wCol;
|
|
|
+ fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
+ if (fDeviation >= fTmpDeviation)
|
|
|
+ { // 不合法
|
|
|
+ byValidFlag = 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ byValidFlag++;
|
|
|
}
|
|
|
+
|
|
|
+ // // 8东南角
|
|
|
+ // if ((wRow - 1) >= 0 && (wCol + 1) < wMatrixCol)
|
|
|
+ // {
|
|
|
+ // wTmpIndex = (wRow - 1) * wMatrixCol + wCol + 1;
|
|
|
+ // fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
+ // if (fDeviation >= fTmpDeviation)
|
|
|
+ // { // 不合法
|
|
|
+ // byValidFlag = 0;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
- // // 6西南角
|
|
|
- // if ((wRow - 1) >= 0 && (wCol - 1) >= 0)
|
|
|
- // {
|
|
|
- // wTmpIndex = (wRow - 1) * wMatrixCol + wCol - 1;
|
|
|
- // fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
- // if (fDeviation >= fTmpDeviation)
|
|
|
- // { // 不合法
|
|
|
- // byValidFlag = 0;
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // 7南方
|
|
|
- if ((wRow - 1) >= 0)
|
|
|
+ // 当前点合法,保存该点
|
|
|
+ if (byValidFlag == byValidThres)
|
|
|
{
|
|
|
- wTmpIndex = (wRow - 1) * wMatrixCol + wCol;
|
|
|
- fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
- if (fDeviation >= fTmpDeviation)
|
|
|
- { // 不合法
|
|
|
- byValidFlag = 0;
|
|
|
+ byWhildFlag = 0;
|
|
|
+ stMinimumValue.stCoord = pstRefPointMatrix[wIndex];
|
|
|
+ stMinimumValue.fDelayDeviationSum = fDeviation;
|
|
|
+ astMinmumValueList[wCounter] = stMinimumValue;
|
|
|
+
|
|
|
+ wCounter++;
|
|
|
+ if (wCounter >= 128)
|
|
|
+ {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // // 8东南角
|
|
|
- // if ((wRow - 1) >= 0 && (wCol + 1) < wMatrixCol)
|
|
|
- // {
|
|
|
- // wTmpIndex = (wRow - 1) * wMatrixCol + wCol + 1;
|
|
|
- // fTmpDeviation = pfDelayDeviationSumMatrix[wTmpIndex];
|
|
|
- // if (fDeviation >= fTmpDeviation)
|
|
|
- // { // 不合法
|
|
|
- // byValidFlag = 0;
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
- // 当前点合法,保存该点
|
|
|
- if (byValidFlag)
|
|
|
+ if (wCounter >= 128)
|
|
|
{
|
|
|
- stMinimumValue.stCoord = pstRefPointMatrix[wIndex];
|
|
|
- stMinimumValue.fDelayDeviationSum = fDeviation;
|
|
|
- astMinmumValueList[wCounter] = stMinimumValue;
|
|
|
-
|
|
|
- wCounter++;
|
|
|
- if (wCounter >= 128)
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
+ byWhildFlag = 0;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (wCounter >= 128)
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ } while (byWhildFlag);
|
|
|
|
|
|
// 有极小值存在
|
|
|
if (wCounter > 0)
|
|
@@ -702,7 +721,7 @@ void lct_coordcal_dbcheck_minimum_value(uint8 byFirstPathFlag, LCT_FIRSTPATH_T *
|
|
|
dwX = pstMiminumValueData->stCoord.dwX;
|
|
|
if (dwGapX < 350)
|
|
|
{
|
|
|
- dwX = util_distance_gen_rand_num((dwMaxValueX + dwMinValueX) / 2, 50);
|
|
|
+ dwX = util_distance_gen_rand_num((dwMaxValueX + dwMinValueX) / 2, dwGapX / 2);
|
|
|
}
|
|
|
else if (dwGapX >= 350 && dwGapX < 900)
|
|
|
{
|
|
@@ -718,7 +737,7 @@ void lct_coordcal_dbcheck_minimum_value(uint8 byFirstPathFlag, LCT_FIRSTPATH_T *
|
|
|
dwY = pstMiminumValueData->stCoord.dwY;
|
|
|
if (dwGapY < 350)
|
|
|
{
|
|
|
- dwY = util_distance_gen_rand_num((dwMaxValueY + dwMinValueY) / 2, 50);
|
|
|
+ dwY = util_distance_gen_rand_num((dwMaxValueY + dwMinValueY) / 2, dwGapY / 10);
|
|
|
}
|
|
|
else if (dwGapY >= 350 && dwGapY < 900)
|
|
|
{
|
|
@@ -731,7 +750,7 @@ void lct_coordcal_dbcheck_minimum_value(uint8 byFirstPathFlag, LCT_FIRSTPATH_T *
|
|
|
pstMiminumValueData->stCoord.dwY = dwY;
|
|
|
|
|
|
// 再次检查坐标是否合法
|
|
|
- if ((dwX >= dwMinValueX) && (dwX <= dwMaxValueX) && (dwY >= dwMinValueY) && (dwY <= dwMaxValueY))
|
|
|
+ if ((dwX >= (dwMinValueX - 300)) && (dwX <= (dwMaxValueX + 300)) && (dwY >= (dwMinValueY - 300)) && (dwY <= (dwMaxValueY + 300)))
|
|
|
{
|
|
|
if (byFirstPathFlag == CAL_PATH)
|
|
|
{
|
|
@@ -763,3 +782,90 @@ void lct_coordcal_dbcheck_minimum_value(uint8 byFirstPathFlag, LCT_FIRSTPATH_T *
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+// 根据手机在x轴和y轴上的移动方向,校验二维定位结果
|
|
|
+// pstMinmumValueGroup:极小值组
|
|
|
+// pstPredictionCoord:预测坐标
|
|
|
+// pstAheadCoord:前一点坐标
|
|
|
+// byDirectionX:手机在x轴的移动方向,1:向右,-1:向左
|
|
|
+// byDirectionY:手机在y轴的移动方向,1:向上,-1:向下
|
|
|
+void lct_coordcal_two_dimension_check(LCT_MINIMUM_VALUE_GROUP_T *pstMinmumValueGroup, COORD_T *pstPredictionCoord, COORD_T *pstAheadCoord, int8 byDirectionX, int8 byDirectionY)
|
|
|
+{
|
|
|
+ // 校验计算径
|
|
|
+ for (uint8 i = 0; i < pstMinmumValueGroup->byCalMinimumListLen; i++)
|
|
|
+ {
|
|
|
+ // x轴向右移动
|
|
|
+ if (byDirectionX == 1)
|
|
|
+ {
|
|
|
+ if (pstMinmumValueGroup->astCalMinimumList[i].stCoord.dwX <= pstAheadCoord->dwX)
|
|
|
+ {
|
|
|
+ pstMinmumValueGroup->astCalMinimumList[i].stCoord.dwX = pstPredictionCoord->dwX;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // x轴向左移动
|
|
|
+ else if (byDirectionX == -1)
|
|
|
+ {
|
|
|
+ if (pstMinmumValueGroup->astCalMinimumList[i].stCoord.dwX >= pstAheadCoord->dwX)
|
|
|
+ {
|
|
|
+ pstMinmumValueGroup->astCalMinimumList[i].stCoord.dwX = pstPredictionCoord->dwX;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // y轴向上移动
|
|
|
+ if (byDirectionY == 1)
|
|
|
+ {
|
|
|
+ if (pstMinmumValueGroup->astCalMinimumList[i].stCoord.dwY <= pstAheadCoord->dwY)
|
|
|
+ {
|
|
|
+ pstMinmumValueGroup->astCalMinimumList[i].stCoord.dwY = pstPredictionCoord->dwY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // y轴向下移动
|
|
|
+ else if (byDirectionY == -1)
|
|
|
+ {
|
|
|
+ if (pstMinmumValueGroup->astCalMinimumList[i].stCoord.dwY >= pstAheadCoord->dwY)
|
|
|
+ {
|
|
|
+ pstMinmumValueGroup->astCalMinimumList[i].stCoord.dwY = pstPredictionCoord->dwY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验跟踪径
|
|
|
+ for (uint8 i = 0; i < pstMinmumValueGroup->byTrackMinimumListLen; i++)
|
|
|
+ {
|
|
|
+ // x轴向右移动
|
|
|
+ if (byDirectionX == 1)
|
|
|
+ {
|
|
|
+ if (pstMinmumValueGroup->astTrackMinimumList[i].stCoord.dwX <= pstAheadCoord->dwX)
|
|
|
+ {
|
|
|
+ pstMinmumValueGroup->astTrackMinimumList[i].stCoord.dwX = pstPredictionCoord->dwX;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // x轴向左移动
|
|
|
+ else if (byDirectionX == -1)
|
|
|
+ {
|
|
|
+ if (pstMinmumValueGroup->astTrackMinimumList[i].stCoord.dwX >= pstAheadCoord->dwX)
|
|
|
+ {
|
|
|
+ pstMinmumValueGroup->astTrackMinimumList[i].stCoord.dwX = pstPredictionCoord->dwX;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // y轴向上移动
|
|
|
+ if (byDirectionY == 1)
|
|
|
+ {
|
|
|
+ if (pstMinmumValueGroup->astTrackMinimumList[i].stCoord.dwY <= pstAheadCoord->dwY)
|
|
|
+ {
|
|
|
+ pstMinmumValueGroup->astTrackMinimumList[i].stCoord.dwY = pstPredictionCoord->dwY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // y轴向下移动
|
|
|
+ else if (byDirectionY == -1)
|
|
|
+ {
|
|
|
+ if (pstMinmumValueGroup->astTrackMinimumList[i].stCoord.dwY >= pstAheadCoord->dwY)
|
|
|
+ {
|
|
|
+ pstMinmumValueGroup->astTrackMinimumList[i].stCoord.dwY = pstPredictionCoord->dwY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|