Commit f284442e authored by oscar's avatar oscar

提交接口修改

parent 872bbca3
......@@ -78,6 +78,49 @@ bool HdLib::GetDataNearby(const Point &ptPoint, float fLonIntervalHalfMetre, flo
return true;
}
// The function will return YES if the point x,y is inside the polygon, or
// NO if it is not. If the point is exactly on the edge of the polygon,
// then the function may return YES or NO.
bool IsPointInPolygon(std::vector<std::vector<float>>& poly, Point& pt)
{
int i, j;
bool c = false;
for (i = 0, j = poly.size() - 1; i < poly.size(); j = i++)
{
if ((((poly[i][1] <= pt.dLat) && (pt.dLat < poly[j][1])) ||
((poly[j][1] <= pt.dLat) && (pt.dLat < poly[i][1])))
&& (pt.dLon < (poly[j][0] - poly[i][0]) * (pt.dLat - poly[i][1]) / (poly[j][1] - poly[i][1]) + poly[i][0]))
{
c = !c;
}
}
return c;
}
bool HdLib::GetIsInCross(const Point& ptPoint)
{
std::vector<const HdLink*> vcthlLinkNearby = {};
if (false == GetDataNearby(ptInLoc, 10.0f, 10.0f, vcthlLinkNearby))
{
return false;
}
isInCross = 0;
for (int i = 0; i < vcthlLinkNearby.size(); i++)
{
if (vcthlLinkNearby[i])
{
for (int j = 0; j < vcthlLinkNearby[i]->vctcrCrossing; j++)
{
if (IsPointInPolygon(vcthlLinkNearby[i]->vctcrCrossing[j]->vctvdGeoArea, ptInLoc))
{
return true;
}
}
}
}
return false;
}
/**
* 求某个点在一系列轨迹点上的Index位置
*/
......
......@@ -152,7 +152,7 @@ class HdLib {
// 可以选择GetDataNearby_param参数过滤和排序
// TODO : 为了兼容旧版本,hdlib不做tile管理
bool GetDataNearby(const Point &ptPoint, float lon_interval_half_metre, float flatintervalhalfmetre, std::vector<const HdLink *> &vcthlOutLink, GetDataNearby_param p = GetDataNearby_param::none, bool bManageTile = true);
bool GetIsInCross(const Point& ptPoint);
// 查看link是否可达
bool IsLinkArrivable(const HdLink *hlFrom, const HdLink *hlTo, int nMaxDepth = 5);
bool LoadTile(const Point &ptPoint, bool nManageTile = true);
......
......@@ -64,6 +64,10 @@ bool MapLib::GetLinkPreNxt(const HdLinkId &lLinkId, std::vector<HdLinkId> &vctli
void MapLib::HmmBindRoad(const BindRoadInput &input, BindRoadOutput &output) { return m_brdBindroad.BindRoadHmm(input, output); }
// bool MapLib::GetDataNearby(const Point &ptPoint, float fLonIntervalHalfMetre, float fLatIntervalHalfMetre, std::vector<HdLinkId> &vcthlOutLink) { return m_spHdLib->GetDataNearby(ptPoint, fLonIntervalHalfMetre, fLatIntervalHalfMetre, vcthlOutLink); }
bool MapLib::GetIsInCross(const Point& ptPoint)
{
return m_spHdLib->GetIsInCross(ptPoint);
}
bool MapLib::GetNearEndpoints(const Point &ptPoint, std::vector<Point> &vctptOutPoint, std::vector<LinkEndpoint> &vctleOutLinkEp, std::vector<double> &vctdOutDistance) {
return m_spHdLib->GetNearEndpoints(ptPoint, MapConfig::route_rect_lon, MapConfig::route_rect_lat, vctptOutPoint, vctleOutLinkEp, vctdOutDistance);
......
......@@ -16,6 +16,8 @@ class MapLib {
bool BFSLinks(const HdLinkId &from, double &ret, bool backward, bool &outFound, double outIterMetre, HdLinkId &outLink);
void HmmBindRoad(const BindRoadInput &input, BindRoadOutput &output);
bool GetDataNearby(const Point &ptPoint, float fLonIntervalHalfMetre, float fLatIntervalHalfMetre, std::vector<HdLinkId> &vcthlOutLink);
bool GetIsInCross(const Point& ptPoint);
/**
* @brief 初始化
......
......@@ -16,6 +16,7 @@ class MapLib {
bool BFSLinks(const HdLinkId &from, double &ret, bool backward, bool &outFound, double outIterMetre, HdLinkId &outLink);
bool HmmBindRoad(const BindRoadInput &input, BindRoadOutput &output);
bool GetDataNearby(const Point &ptPoint, float fLonIntervalHalfMetre, float fLatIntervalHalfMetre, std::vector<HdLinkId> &vcthlOutLink);
bool GetIsInCross(const Point& ptPoint);
/**
* @brief 初始化
......
......@@ -22,25 +22,6 @@ bool MapInterface::GetMapData(const Point &ptInLoc, double dCarAngle, int &nOutL
return GetMapData(ptInLoc, dCarAngle, lRoadId, vctlPreRoadId, vctlNxtRoadId, nOutLaneCnt, nOutLaneNum, nOutLaneType, nOutLeftEdgeCrossType, nOutRightEdgeCrossType, nOutSpeedLimit, dOutLaneAngle, ptOutFoot, isInCross);
}
// The function will return YES if the point x,y is inside the polygon, or
// NO if it is not. If the point is exactly on the edge of the polygon,
// then the function may return YES or NO.
bool IsPointInPolygon(std::vector<std::vector<float>>& poly, Point& pt)
{
int i, j;
bool c = false;
for (i = 0, j = poly.size() - 1; i < poly.size(); j = i++)
{
if ((((poly[i][1] <= pt.dLat) && (pt.dLat < poly[j][1])) ||
((poly[j][1] <= pt.dLat) && (pt.dLat < poly[i][1])))
&& (pt.dLon < (poly[j][0] - poly[i][0]) * (pt.dLat - poly[i][1]) / (poly[j][1] - poly[i][1]) + poly[i][0]))
{
c = !c;
}
}
return c;
}
bool MapInterface::GetMapData(const Point &ptInLoc, double dCarAngle, long &lOutRaodId, std::vector<long> &vctlOutPreRoadId, std::vector<long> &vctlOutNxtRoadId, int &nOutLaneCnt, int &nOutLaneNum, LaneType &nOutLaneType,
EdgeCrossType &nOutLeftEdgeCrossType, EdgeCrossType &nOutRightEdgeCrossType, int &nOutSpeedLimit, double &dOutLaneAngle, Point &ptOutFoot,int &isInCross) {
std::vector<HdLinkId> vcthlLinkIds = {};
......@@ -59,36 +40,9 @@ bool MapInterface::GetMapData(const Point &ptInLoc, double dCarAngle, long &lOut
//std::cout << "MapInterface::GetMapData(), Locate lane failed." << std::endl;
return false;
}
std::vector<HdLinkId> vcthlLinkNearby = {};
if (false == m_mlMapLib.GetDataNearby(ptInLoc, 10.0f, 10.0f, vcthlLinkNearby))
{
nOutLaneCnt = 0;
nOutLaneNum = 0;
nOutLaneType = LaneType::NotInvestigated;
nOutLeftEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutRightEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutSpeedLimit = 0;
dOutLaneAngle = 0.0;
ptOutFoot = ptInLoc;
return false;
}
for (int i = 0; i < vcthlLinkNearby.size(); i++)
{
const HdLinkId& hlLinkId = vcthlLinkNearby[i];
const HdLink* cphlLink = m_mlMapLib.GetLinkData(hlLinkId);
if (cphlLink)
{
for (int j = 0; j < cphlLink->vctcrCrossing; j++)
{
if (IsPointInPolygon(cphlLink->vctcrCrossing[j]->vctvdGeoArea, ptInLoc))
if (true == m_mlMapLib.GetIsInCross(ptInLoc))
{
isInCross = 1;
break;
}
}
}
if (isInCross == 1)
break;
}
int nIndex = 0;
double dMinAngleDiff = std::numeric_limits<double>::max();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment