Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
new-socketemulator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李远洪
new-socketemulator
Commits
ad176d1f
Commit
ad176d1f
authored
Apr 26, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了角度为小数的时候,报错的bug
parent
32ef4e2f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
lib/socket/service/MessageSimulaterService.py
lib/socket/service/MessageSimulaterService.py
+5
-5
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+5
-4
No files found.
lib/socket/service/MessageSimulaterService.py
View file @
ad176d1f
...
...
@@ -512,20 +512,20 @@ class MessageSimulaterService():
self
.
travelStatus
=
0
self
.
serviceStatus
=
0
###########################################################
###########################################################
#获取方向角
###########################################################
def
getDirAngle
(
self
):
dire
=
self
.
directAngle
if
self
.
travelDirection
==
0
:
if
self
.
gpsLineIndex
==
0
:
return
self
.
directAngle
return
int
(
self
.
directAngle
)
lngCut
=
(
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
])
-
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
-
1
][
"lng"
]))
*
1000000
latCut
=
(
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lat"
])
-
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
-
1
][
"lat"
]))
*
1000000
if
latCut
==
0
:
#除数维度不能为0
latCut
=
1
if
lngCut
==
0
or
latCut
==
0
:
return
self
.
directAngle
return
int
(
self
.
directAngle
)
val
=
lngCut
/
latCut
dire
=
math
.
atan2
(
1
,
val
)
*
180
/
math
.
pi
if
lngCut
>
0
and
latCut
>
0
:
...
...
@@ -539,13 +539,13 @@ class MessageSimulaterService():
self
.
directAngle
=
dire
elif
self
.
travelDirection
==
1
:
if
self
.
gpsLineIndex
==
(
len
(
self
.
gpsLine
)
-
1
):
return
self
.
directAngle
return
int
(
self
.
directAngle
)
lngCut
=
(
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
])
-
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
+
1
][
"lng"
]))
*
1000000
latCut
=
(
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lat"
])
-
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
+
1
][
"lat"
]))
*
1000000
if
latCut
==
0
:
#除数维度不能为0
latCut
=
1
if
lngCut
==
0
or
latCut
==
0
:
return
self
.
directAngle
return
int
(
self
.
directAngle
)
val
=
lngCut
/
latCut
dire
=
math
.
atan2
(
1
,
val
)
*
180
/
math
.
pi
if
lngCut
>
0
and
latCut
>
0
:
...
...
lib/socket/service/ProtocolSimulaterService.py
View file @
ad176d1f
...
...
@@ -357,6 +357,7 @@ class ProtocolSimulaterService():
gpsObj
=
GPSReport_protocol
(
DEV_ID
=
self
.
carId
,
WATER_CODE
=
self
.
sn
)
gpsObj
.
setLatitude
(
latitude
)
gpsObj
.
setLongitude
(
longtitude
)
gpsObj
.
setDirectionAngle
(
self
.
getDirAngle
())
timeS
=
int
(
time
.
time
())
-
8
*
3600
timeArray
=
time
.
localtime
(
timeS
)
UTCTime
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
timeArray
)
...
...
@@ -391,13 +392,13 @@ class ProtocolSimulaterService():
dire
=
self
.
directAngle
if
self
.
travelDirection
==
0
:
if
self
.
gpsLineIndex
==
0
:
return
self
.
directAngle
return
int
(
self
.
directAngle
)
lngCut
=
(
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
])
-
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
-
1
][
"lng"
]))
*
1000000
latCut
=
(
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lat"
])
-
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
-
1
][
"lat"
]))
*
1000000
if
latCut
==
0
:
#除数维度不能为0
latCut
=
1
if
lngCut
==
0
or
latCut
==
0
:
return
self
.
directAngle
return
int
(
self
.
directAngle
)
val
=
lngCut
/
latCut
dire
=
math
.
atan2
(
1
,
val
)
*
180
/
math
.
pi
if
lngCut
>
0
and
latCut
>
0
:
...
...
@@ -411,13 +412,13 @@ class ProtocolSimulaterService():
self
.
directAngle
=
dire
elif
self
.
travelDirection
==
1
:
if
self
.
gpsLineIndex
==
(
len
(
self
.
gpsLine
)
-
1
):
return
self
.
directAngle
return
int
(
self
.
directAngle
)
lngCut
=
(
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
])
-
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
+
1
][
"lng"
]))
*
1000000
latCut
=
(
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lat"
])
-
float
(
self
.
gpsLine
[
self
.
gpsLineIndex
+
1
][
"lat"
]))
*
1000000
if
latCut
==
0
:
#除数维度不能为0
latCut
=
1
if
lngCut
==
0
or
latCut
==
0
:
return
self
.
directAngle
return
int
(
self
.
directAngle
)
val
=
lngCut
/
latCut
dire
=
math
.
atan2
(
1
,
val
)
*
180
/
math
.
pi
if
lngCut
>
0
and
latCut
>
0
:
...
...
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