Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
J
jfxmap_python
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
oscar
jfxmap_python
Commits
c3a0386b
Commit
c3a0386b
authored
Jan 26, 2022
by
oscar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交接口更新
parent
11e6dcab
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
6 deletions
+60
-6
MapInterface.cpp
python_so/MapInterface.cpp
+53
-3
MapInterface.hpp
python_so/MapInterface.hpp
+1
-1
jfxmap_python.cpp
python_so/jfxmap_python.cpp
+3
-1
jfxmap_python.h
python_so/jfxmap_python.h
+3
-1
No files found.
python_so/MapInterface.cpp
View file @
c3a0386b
...
...
@@ -18,15 +18,35 @@ bool MapInterface::GetMapData(const Point &ptInLoc, double dCarAngle, int &nOutL
long
lRoadId
;
std
::
vector
<
long
>
vctlPreRoadId
=
{};
std
::
vector
<
long
>
vctlNxtRoadId
=
{};
int
isInCross
=
0
;
return
GetMapData
(
ptInLoc
,
dCarAngle
,
lRoadId
,
vctlPreRoadId
,
vctlNxtRoadId
,
nOutLaneCnt
,
nOutLaneNum
,
nOutLaneType
,
nOutLeftEdgeCrossType
,
nOutRightEdgeCrossType
,
nOutSpeedLimit
,
dOutLaneAngle
,
ptOutFoot
,
isInCross
);
}
return
GetMapData
(
ptInLoc
,
dCarAngle
,
lRoadId
,
vctlPreRoadId
,
vctlNxtRoadId
,
nOutLaneCnt
,
nOutLaneNum
,
nOutLaneType
,
nOutLeftEdgeCrossType
,
nOutRightEdgeCrossType
,
nOutSpeedLimit
,
dOutLaneAngle
,
ptOutFoot
);
// 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
)
{
EdgeCrossType
&
nOutLeftEdgeCrossType
,
EdgeCrossType
&
nOutRightEdgeCrossType
,
int
&
nOutSpeedLimit
,
double
&
dOutLaneAngle
,
Point
&
ptOutFoot
,
int
&
isInCross
)
{
std
::
vector
<
HdLinkId
>
vcthlLinkIds
=
{};
std
::
vector
<
HdLaneId
>
vcthlLaneIds
=
{};
// Locate lane failed
isInCross
=
0
;
if
(
false
==
m_mlMapLib
.
GetLocateLanes
(
ptInLoc
,
vcthlLinkIds
,
vcthlLaneIds
))
{
nOutLaneCnt
=
0
;
nOutLaneNum
=
0
;
...
...
@@ -39,7 +59,37 @@ bool MapInterface::GetMapData(const Point &ptInLoc, double dCarAngle, long &lOut
//std::cout << "MapInterface::GetMapData(), Locate lane failed." << std::endl;
return
false
;
}
std
::
vector
<
HdLaneId
>
vcthlLinkNearby
=
{};
if
(
false
==
m_mlMapLib
.
GetDataNearby
(
ptInLoc
,
10.0
f
,
10.0
f
,
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
))
{
isInCross
=
1
;
break
;
}
}
}
if
(
isInCross
==
1
)
break
;
}
int
nIndex
=
0
;
double
dMinAngleDiff
=
std
::
numeric_limits
<
double
>::
max
();
auto
func_GetAngleDiff
=
[](
double
dAngle1
,
double
dAngle2
)
{
return
std
::
min
(
std
::
abs
(
dAngle1
-
dAngle2
),
360
-
std
::
abs
((
dAngle1
-
dAngle2
)));
};
...
...
python_so/MapInterface.hpp
View file @
c3a0386b
...
...
@@ -49,7 +49,7 @@ class MapInterface {
bool
GetMapData
(
const
Point
&
ptInLoc
,
double
dCarAngle
,
int
&
nOutLaneCnt
,
int
&
nOutLaneNum
,
LaneType
&
nOutLaneType
,
EdgeCrossType
&
nOutLeftEdgeCrossType
,
EdgeCrossType
&
nOutRightEdgeCrossType
,
int
&
nOutSpeedLimit
,
double
&
dOutLaneAngle
,
Point
&
ptOutFoot
);
bool
GetMapData
(
const
Point
&
ptInLoc
,
double
dCarAngle
,
long
&
lOutRaodId
,
std
::
vector
<
long
>
&
vctlOutPreRoadId
,
std
::
vector
<
long
>
&
vctlOutNxtRoadId
,
int
&
nLaneCnt
,
int
&
nOutLaneNum
,
LaneType
&
nOutLaneType
,
EdgeCrossType
&
nOutLeftEdgeCrossType
,
EdgeCrossType
&
nOutRightEdgeCrossType
,
int
&
nOutSpeedLimit
,
double
&
dOutLaneAngle
,
Point
&
ptOutFoot
);
EdgeCrossType
&
nOutRightEdgeCrossType
,
int
&
nOutSpeedLimit
,
double
&
dOutLaneAngle
,
Point
&
ptOutFoot
,
int
&
isInCross
);
private
:
MapLib
m_mlMapLib
;
...
...
python_so/jfxmap_python.cpp
View file @
c3a0386b
...
...
@@ -45,7 +45,8 @@ MapInfo* GetMapData(double lat, double lon, double carAngle)
int
nOutSpeedLimit
;
double
dOutLaneAngle
;
jf
::
Point
ptOutFoot
;
if
(
g_jfMap
.
GetMapData
(
ptInLoc
,
carAngle
,
lOutRaodId
,
vctlOutPreRoadId
,
vctlOutNxtRoadId
,
nLaneCnt
,
nOutLaneNum
,
nOutLaneType
,
nOutLeftEdgeCrossType
,
nOutRightEdgeCrossType
,
nOutSpeedLimit
,
dOutLaneAngle
,
ptOutFoot
))
int
isInCross
=
0
;
if
(
g_jfMap
.
GetMapData
(
ptInLoc
,
carAngle
,
lOutRaodId
,
vctlOutPreRoadId
,
vctlOutNxtRoadId
,
nLaneCnt
,
nOutLaneNum
,
nOutLaneType
,
nOutLeftEdgeCrossType
,
nOutRightEdgeCrossType
,
nOutSpeedLimit
,
dOutLaneAngle
,
ptOutFoot
,
isInCross
))
{
g_info
.
isInMap
=
1
;
g_info
.
lOutRaodId
=
lOutRaodId
;
...
...
@@ -60,6 +61,7 @@ MapInfo* GetMapData(double lat, double lon, double carAngle)
g_info
.
dOutLaneAngle
=
dOutLaneAngle
;
g_info
.
ptOutFoot_lat
=
ptOutFoot
.
dLat
;
g_info
.
ptOutFoot_lon
=
ptOutFoot
.
dLon
;
g_info
.
isInCross
=
isInCross
;
}
}
return
&
g_info
;
...
...
python_so/jfxmap_python.h
View file @
c3a0386b
...
...
@@ -23,6 +23,7 @@ struct MapInfo
double
dOutLaneAngle
;
double
ptOutFoot_lat
;
double
ptOutFoot_lon
;
int
isInCross
;
};
int
add
(
int
i
,
int
j
);
...
...
@@ -49,7 +50,8 @@ PYBIND11_MODULE(libjfxmap_python, m)
.
def_readwrite
(
"nOutSpeedLimit"
,
&
MapInfo
::
nOutSpeedLimit
)
.
def_readwrite
(
"dOutLaneAngle"
,
&
MapInfo
::
dOutLaneAngle
)
.
def_readwrite
(
"ptOutFoot_lat"
,
&
MapInfo
::
ptOutFoot_lat
)
.
def_readwrite
(
"ptOutFoot_lon"
,
&
MapInfo
::
ptOutFoot_lon
);
.
def_readwrite
(
"ptOutFoot_lon"
,
&
MapInfo
::
ptOutFoot_lon
)
.
def_readwrite
(
"isInCross"
,
&
MapInfo
::
isInCross
);
// expose add function, and add keyword arguments and default arguments
m
.
def
(
"add"
,
&
add
,
"A function which adds two numbers"
,
py
::
arg
(
"i"
)
=
1
,
py
::
arg
(
"j"
)
=
2
);
m
.
def
(
"InitMap"
,
&
InitMap
,
"A function which init map"
,
py
::
return_value_policy
::
copy
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment