Commit ad176d1f authored by liyuanhong's avatar liyuanhong

修改了角度为小数的时候,报错的bug

parent 32ef4e2f
......@@ -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:
......
......@@ -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:
......
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